OGS
CheckMPLPhasesForSinglePhaseFlow.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
6#include <range/v3/algorithm/any_of.hpp>
7#include <range/v3/algorithm/for_each.hpp>
8#include <range/v3/view/transform.hpp>
9
13#include "MeshLib/Mesh.h"
14
15namespace MaterialPropertyLib
16{
18 MeshLib::Mesh const& mesh,
20{
21 // Check all of the elements have a medium defined.
22 ranges::for_each(mesh.getElements() | MeshLib::views::ids,
23 [&](auto const& element_id)
24 { media_map.checkElementHasMedium(element_id); });
25
26 // Collect phases of all elements...
27 auto all_phases =
28 media_map.media() |
29 ranges::views::transform([&](auto const& medium)
30 { return &fluidPhase(*medium); }) |
31 ranges::to_vector;
32
33 assert(!all_phases.empty());
34
35 // ... and check if any of the phases are different by name.
36 if (ranges::any_of(all_phases,
37 [p0 = all_phases.front()](auto const* const p)
38 { return p->name != p0->name; }))
39 {
41 "You are mixing liquid and gas phases in your model domain. OGS "
42 "does not yet know how to handle this.");
43 }
44}
45} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:19
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:100
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:91
constexpr ranges::views::view_closure ids
For an element of a range view return its id.
Definition Mesh.h:216