Commit e63b060b authored by Lukas Riedel's avatar Lukas Riedel

Revamp variable names and types in BC code

* Use references to shared pointers where applicable.
* Minor additions to docstrings.
* Add more comments.
parent 430b87fc
......@@ -76,16 +76,20 @@ private:
}
/// Return true of the given BC type is permitted for this model
/** \param type The BC type as string
* \return TypeHandle if this type is permitted by this model
*/
static TypeHandle type_handle (const std::string_view type)
{
const auto permitted_types = get_permitted_type_strs();
if (std::find(begin(permitted_types), end(permitted_types), type)
!= end(permitted_types))
!= end(permitted_types))
return TypeHandle::permitted;
const auto& known_types = known_type_strs;
if (std::find(begin(known_types), end(known_types), type)
!= end(known_types))
!= end(known_types))
return TypeHandle::known;
return TypeHandle::unknown;
......
......@@ -180,9 +180,8 @@ public:
const std::shared_ptr<BC> bc)
{
const auto& time_int = bc->time_interval();
using namespace Dune::FloatCmp;
return ge(time, time_int.begin)
&& lt(time, time_int.end);
return FloatCmp::ge(time, time_int.begin)
&& FloatCmp::lt(time, time_int.end);
};
// iterate over all boundary segments
......@@ -235,10 +234,13 @@ private:
const auto time_begin = config.get<RF>("time.start");
const auto time_end = config.get<RF>("time.end");
// read the boundary conditions from the YAML file
// Read the boundary conditions from the YAML file
// Store BCs in a list for every boundary index. Indices may be
// missing, in which case the default BC is inserted.
std::map<int, BCList> bc_association_map;
for (const auto node : bc_file)
for (const auto&& node : bc_file)
{
// extract keys and values from the node
const auto& key = node.first;
const auto& values = node.second;
......@@ -250,7 +252,7 @@ private:
// list up the conditions on this boundary segment
BCList conditions_list;
for (const auto condition : values["conditions"]) {
for (const auto& condition : values["conditions"]) {
const auto name = condition.first.as<std::string>();
_log->trace(" Creating boundary condition. ",
"Mapping index: {}, Name: {}",
......@@ -287,7 +289,7 @@ private:
});
// insert an initial boundary condition, if needed
const auto bc_initial = list.front();
const auto& bc_initial = list.front();
const auto bc_initial_begin = bc_initial->time_interval().begin;
if (FloatCmp::gt(bc_initial_begin, time_begin))
{
......@@ -301,7 +303,7 @@ private:
}
// insert a final boundary condition, if needed
const auto bc_final = list.back();
const auto& bc_final = list.back();
const auto bc_final_end = bc_final->time_interval().end;
if (FloatCmp::lt(bc_final_end, time_end))
{
......@@ -314,26 +316,26 @@ private:
time_end));
}
// iterate over all BCs in this list`
// iterate over all BCs in this list but the last one
for (auto it = list.begin(); std::next(it) != list.end(); ++it)
{
const auto first = *it;
const auto& first = *it;
const auto time_first_end = first->time_interval().end;
const auto second = *std::next(it);
const auto time_sec_begin = second->time_interval().begin;
const auto& second = *std::next(it);
const auto time_second_begin = second->time_interval().begin;
// check if time intervals overlap
if (FloatCmp::gt(time_first_end, time_sec_begin))
if (FloatCmp::gt(time_first_end, time_second_begin))
{
_log->error("Two boundary conditions overlap in time: "
"'{}' ends at '{}', but '{}' begins at '{}'",
first->name(), time_first_end,
second->name(), time_sec_begin);
second->name(), time_second_begin);
DUNE_THROW(IOError, "Boundary conditions overlap");
}
// insert default condition if time interval is missing
else if (FloatCmp::lt(time_first_end, time_sec_begin))
else if (FloatCmp::lt(time_first_end, time_second_begin))
{
_log->trace(" Inserting default boundary condition "
"between conditions '{}' and '{}'",
......@@ -341,7 +343,7 @@ private:
list.insert(std::next(it),
read_default_bc(bc_file["default"],
time_first_end,
time_sec_begin));
time_second_begin));
}
}
}
......
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