Commit d6e0a7be authored by GILLES Sebastien's avatar GILLES Sebastien

#1498 Various fixes found while truing to update models:

- Seldon error were still caught in XCode template.
- When reading OptionFile, '<=' and '>=' could mess up the parsing.
parent 40b1ee4d
......@@ -141,7 +141,6 @@ namespace MoReFEM
using morefem_data_type = MoReFEMData<InputData, program_type::model>;
} // namespace ElasticityNS
......
......@@ -28,7 +28,18 @@ section2 = {
function (x, y, z)
return x + y - z;
end
]]
]],
function_with_if =
[[
function(x, y, z)
if (((x>=4) and (x<=5.99)) or ((x>=7.01) and (x<=8.99))) then
return 1.;
else
return 0.
end
end
]]
}
......
......@@ -188,6 +188,15 @@ BOOST_FIXTURE_TEST_CASE(lua_functions, TestNS::FixtureNS::Environment)
BOOST_CHECK(NumericNS::AreEqual(several_arg_function(3., 4., 5.), 2.));
decltype(auto) function_with_if =
ReadLuaOptionFile<Utilities::InputDataNS::LuaFunction<double(double, double, double)>>(lua_option_file,
"section2.function_with_if",
__FILE__, __LINE__);
BOOST_CHECK(NumericNS::AreEqual(function_with_if(5., 0., 0.), 1.));
BOOST_CHECK(NumericNS::AreEqual(function_with_if(15., 0., 0.), 0.));
}
......@@ -243,7 +252,8 @@ BOOST_FIXTURE_TEST_CASE(map_in_vector, TestNS::FixtureNS::Environment)
"TransientSource4.nature, TransientSource4.value, "
"TransientSource5.nature, TransientSource5.value, "
"TransientSource5.whatever.sublevel, "
"TransientSource5.whatever.sublevel2]");
"TransientSource5.whatever.sublevel2, "
"InitialCondition1.nature, InitialCondition1.value]");
}
......
......@@ -38,3 +38,24 @@ TransientSource5 = {
}
} -- TransientSource5
InitialCondition1 = {
nature = { 'lua_function', 'constant', 'constant' },
value = { [[
function(x, y, z)
if (((x >= 4) and (x <= 5.99)) or ((x >= 7.01) and (x <= 8.99))) then
return 1.;
else
return 0.
end
end
]],
0., 0. }
} -- InitialCondition1
......@@ -202,7 +202,6 @@ namespace MoReFEM
variable = std::string_view(&entry_key.at(pos + 1), entry_key.size() - pos - 1);
}
if (!tuple_iteration::DoMatchIdentifier(section_name, variable))
throw ExceptionNS::UnboundInputData(filename, section_name, variable,
__FILE__, __LINE__);
......
......@@ -302,9 +302,15 @@ namespace MoReFEM
int inside_map = 0;
assert(!content_.empty());
if (content_[0] == '=')
throw Exception("Content should not begin with '='!", __FILE__, __LINE__);
for (auto i = 0ul; i < size; ++i)
{
if (content_[i] == '=')
// We want to avoid taking in the process symbols <= and >=
if (content_[i] == '=' && content_[i - 1] != '>' && content_[i - 1] != '<')
{
if (!is_last_non_space_character_close_bracket)
equal_position_list_.push_back(i);
......
......@@ -45,10 +45,6 @@ int main(int argc, char** argv)
{
ExceptionNS::PrintAndAbort(mpi, e.what());
}
catch(Seldon::Error& e)
{
ExceptionNS::PrintAndAbort(mpi, e.What());
}
}
catch(const ExceptionNS::GracefulExit&)
{
......
......@@ -91,10 +91,6 @@ int main(int argc, char** argv)
{
ExceptionNS::PrintAndAbort(mpi, e.what());
}
catch(Seldon::Error& e)
{
ExceptionNS::PrintAndAbort(mpi, e.What());
}
}
catch(const ExceptionNS::GracefulExit&)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment