OGS
CheckMPLPhasesForSinglePhaseFlow.cpp
Go to the documentation of this file.
1
13
14#include <range/v3/algorithm/any_of.hpp>
15#include <range/v3/algorithm/for_each.hpp>
16#include <range/v3/view/transform.hpp>
17
21#include "MeshLib/Mesh.h"
22
23namespace MaterialPropertyLib
24{
26 MeshLib::Mesh const& mesh,
28{
29 // Check all of the elements have a medium defined.
30 ranges::for_each(mesh.getElements() | MeshLib::views::ids,
31 [&](auto const& element_id)
32 { media_map.checkElementHasMedium(element_id); });
33
34 // Collect phases of all elements...
35 auto all_phases =
36 media_map.media() |
37 ranges::views::transform([&](auto const& medium)
38 { return &fluidPhase(*medium); }) |
39 ranges::to_vector;
40
41 assert(!all_phases.empty());
42
43 // ... and check if any of the phases are different by name.
44 if (ranges::any_of(all_phases,
45 [p0 = all_phases.front()](auto const* const p)
46 { return p->name != p0->name; }))
47 {
49 "You are mixing liquid and gas phases in your model domain. OGS "
50 "does not yet know how to handle this.");
51 }
52}
53} // namespace MaterialPropertyLib
Definition of the Element class.
#define OGS_FATAL(...)
Definition Error.h:26
Definition of the Mesh class.
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:109
void checkMPLPhasesForSinglePhaseFlow(MeshLib::Mesh const &mesh, MaterialPropertyLib::MaterialSpatialDistributionMap const &media_map)
Phase const & fluidPhase(Medium const &medium)
Returns a gas or aqueous liquid phase of the given medium.
Definition Medium.cpp:100
constexpr ranges::views::view_closure ids
For an element of a range view return its id.
Definition Mesh.h:225