OGS
ProcessLib::ComponentTransport Namespace Reference

Classes

struct  AssembledMatrixCache
 
class  ComponentTransportLocalAssemblerInterface
 
class  ComponentTransportProcess
 
struct  ComponentTransportProcessData
 
struct  Field
 
struct  IntegrationPointData
 
struct  InterpolationPoint
 
class  LocalAssemblerData
 
struct  LookupTable
 

Functions

void checkMPLProperties (MeshLib::Mesh const &mesh, MaterialPropertyLib::MaterialSpatialDistributionMap const &media_map)
 
std::unique_ptr< ProcesscreateComponentTransportProcess (std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< MeshLib::Mesh > > const &meshes, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media, std::unique_ptr< ChemistryLib::ChemicalSolverInterface > &&chemical_solver_interface)
 
std::unique_ptr< LookupTablecreateLookupTable (std::optional< std::string > const tabular_file, std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > const &process_variables)
 
static void intersection (std::vector< std::size_t > &vec1, std::vector< std::size_t > const &vec2)
 

Function Documentation

◆ checkMPLProperties()

void ProcessLib::ComponentTransport::checkMPLProperties ( MeshLib::Mesh const &  mesh,
MaterialPropertyLib::MaterialSpatialDistributionMap const &  media_map 
)

Definition at line 31 of file CreateComponentTransportProcess.cpp.

34{
35 std::array const required_properties_medium = {
40
41 std::array const required_properties_liquid_phase = {
44
45 std::array const required_properties_components = {
49
50 for (auto const& element_id : mesh.getElements() | MeshLib::views::ids)
51 {
52 auto const& medium = *media_map.getMedium(element_id);
53 checkRequiredProperties(medium, required_properties_medium);
54
55 // check if liquid phase definition and the corresponding properties
56 // exist
57 auto const& liquid_phase = medium.phase("AqueousLiquid");
58 checkRequiredProperties(liquid_phase, required_properties_liquid_phase);
59
60 // check if components and the corresponding properties exist
61 auto const number_of_components = liquid_phase.numberOfComponents();
62 for (std::size_t component_id = 0; component_id < number_of_components;
63 ++component_id)
64 {
65 if (!liquid_phase.hasComponent(component_id))
66 {
68 "The component {:d} in the AqueousLiquid phase isn't "
69 "specified.",
70 component_id);
71 }
72 auto const& component = liquid_phase.component(component_id);
73 checkRequiredProperties(component, required_properties_components);
74 }
75 }
76}
#define OGS_FATAL(...)
Definition: Error.h:26
void checkRequiredProperties(Component const &c, std::span< PropertyType const > const required_properties)
Definition: Component.cpp:60
@ longitudinal_dispersivity
used to compute the hydrodynamic dispersion tensor.
Definition: PropertyType.h:60
@ transversal_dispersivity
used to compute the hydrodynamic dispersion tensor.
Definition: PropertyType.h:110
@ retardation_factor
specify retardation factor used in component transport process.
Definition: PropertyType.h:84
constexpr ranges::views::view_closure ids
For an element of a range view return its id.
Definition: Mesh.h:217

References MaterialPropertyLib::decay_rate, MaterialPropertyLib::density, MeshLib::Mesh::getElements(), MaterialPropertyLib::MaterialSpatialDistributionMap::getMedium(), MeshLib::views::ids, MaterialPropertyLib::longitudinal_dispersivity, OGS_FATAL, MaterialPropertyLib::permeability, MaterialPropertyLib::pore_diffusion, MaterialPropertyLib::porosity, MaterialPropertyLib::retardation_factor, MaterialPropertyLib::transversal_dispersivity, and MaterialPropertyLib::viscosity.

Referenced by createComponentTransportProcess().

◆ createComponentTransportProcess()

std::unique_ptr< Process > ProcessLib::ComponentTransport::createComponentTransportProcess ( std::string const &  name,
MeshLib::Mesh mesh,
std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&  jacobian_assembler,
std::vector< ProcessVariable > const &  variables,
std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &  parameters,
unsigned const  integration_order,
BaseLib::ConfigTree const &  config,
std::vector< std::unique_ptr< MeshLib::Mesh > > const &  meshes,
std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &  media,
std::unique_ptr< ChemistryLib::ChemicalSolverInterface > &&  chemical_solver_interface 
)
Input File Parameter:
prj__processes__process__type
Input File Parameter:
prj__processes__process__ComponentTransport__coupling_scheme

Process Variables

Input File Parameter:
prj__processes__process__ComponentTransport__process_variables

Primary process variables as they appear in the global component vector:

Input File Parameter:
prj__processes__process__ComponentTransport__process_variables__pressure
Input File Parameter:
prj__processes__process__ComponentTransport__process_variables__concentration

Process Parameters

Input File Parameter:
prj__processes__process__ComponentTransport__specific_body_force
Input File Parameter:
prj__processes__process__ComponentTransport__non_advective_form
Input File Parameter:
prj__processes__process__ComponentTransport__chemically_induced_porosity_change
Input File Parameter:
prj__processes__process__ComponentTransport__temperature_field
Input File Parameter:
prj__processes__process__ComponentTransport__tabular_file
Input File Parameter:
prj__processes__process__ComponentTransport__aperture_size
Input File Parameter:
prj__processes__process__ComponentTransport__aperture_size__parameter
Input File Parameter:
prj__processes__process__ComponentTransport__is_linear
Input File Parameter:
prj__processes__process__calculatesurfaceflux

Definition at line 78 of file CreateComponentTransportProcess.cpp.

90{
92 config.checkConfigParameter("type", "ComponentTransport");
93
94 DBUG("Create ComponentTransportProcess.");
95
96 auto const coupling_scheme =
98 config.getConfigParameter<std::string>("coupling_scheme",
99 "monolithic_scheme");
100 const bool use_monolithic_scheme = (coupling_scheme != "staggered");
101
103
105 auto const pv_config = config.getConfigSubtree("process_variables");
106
107 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
108 process_variables;
109
111 auto const collected_process_variables = findProcessVariables(
112 variables, pv_config,
113 {
114 "pressure",
116 "concentration"});
117
118 // Check number of components for each process variable
119 auto it = std::find_if(
120 collected_process_variables.cbegin(),
121 collected_process_variables.cend(),
122 [](std::reference_wrapper<ProcessLib::ProcessVariable> const& pv)
123 { return pv.get().getNumberOfGlobalComponents() != 1; });
124
125 if (it != collected_process_variables.end())
126 {
127 OGS_FATAL(
128 "Number of components for process variable '{:s}' should be 1 "
129 "rather "
130 "than {:d}.",
131 it->get().getName(),
132 it->get().getNumberOfGlobalComponents());
133 }
134
135 // Allocate the collected process variables into a two-dimensional vector,
136 // depending on what scheme is adopted
137 if (use_monolithic_scheme) // monolithic scheme.
138 {
139 process_variables.push_back(std::move(collected_process_variables));
140 }
141 else // staggered scheme.
142 {
143 std::vector<std::reference_wrapper<ProcessLib::ProcessVariable>>
144 per_process_variable;
145
146 if (!chemical_solver_interface)
147 {
148 for (auto& pv : collected_process_variables)
149 {
150 per_process_variable.emplace_back(pv);
151 process_variables.push_back(std::move(per_process_variable));
152 }
153 }
154 else
155 {
156 auto sort_by_component =
157 [&per_process_variable,
158 collected_process_variables](auto const& c_name)
159 {
160 auto pv = std::find_if(collected_process_variables.begin(),
161 collected_process_variables.end(),
162 [&c_name](auto const& v) -> bool
163 { return v.get().getName() == c_name; });
164
165 if (pv == collected_process_variables.end())
166 {
167 OGS_FATAL(
168 "Component {:s} given in "
169 "<chemical_system>/<solution>/"
170 "<components> is not found in specified "
171 "coupled processes (see "
172 "<process>/<process_variables>/"
173 "<concentration>).",
174 c_name);
175 }
176
177 per_process_variable.emplace_back(*pv);
178 return std::move(per_process_variable);
179 };
180
181 auto const components =
182 chemical_solver_interface->getComponentList();
183 // pressure
184 per_process_variable.emplace_back(collected_process_variables[0]);
185 process_variables.push_back(std::move(per_process_variable));
186 // concentration
187 assert(components.size() + 1 == collected_process_variables.size());
188 std::transform(components.begin(), components.end(),
189 std::back_inserter(process_variables),
190 sort_by_component);
191 }
192 }
193
195 std::vector<double> const b =
197 config.getConfigParameter<std::vector<double>>("specific_body_force");
198 assert(!b.empty() && b.size() < 4);
199 // Specific body force parameter.
200 Eigen::VectorXd specific_body_force(b.size());
201 int const mesh_space_dimension =
203 if (static_cast<int>(b.size()) != mesh_space_dimension)
204 {
205 OGS_FATAL(
206 "specific body force (gravity vector) has {:d} components, mesh "
207 "dimension is {:d}",
208 b.size(), mesh_space_dimension);
209 }
210 bool const has_gravity = MathLib::toVector(b).norm() > 0;
211 if (has_gravity)
212 {
213 std::copy_n(b.data(), b.size(), specific_body_force.data());
214 }
215
216 bool const non_advective_form =
218 config.getConfigParameter<bool>("non_advective_form", false);
219
220 bool chemically_induced_porosity_change =
222 config.getConfigParameter<bool>("chemically_induced_porosity_change",
223 false);
224
225 auto const temperature = ParameterLib::findOptionalTagParameter<double>(
227 config, "temperature_field", parameters, 1, &mesh);
228
229 auto media_map =
231
232 auto lookup_table = ComponentTransport::createLookupTable(
234 config.getConfigParameterOptional<std::string>("tabular_file"),
235 process_variables);
236
237 DBUG("Check the media properties of ComponentTransport process ...");
238 checkMPLProperties(mesh, *media_map);
239 DBUG("Media properties verified.");
240
241 auto stabilizer = NumLib::createNumericalStabilization(mesh, config);
242
243 auto const* aperture_size_parameter = &ParameterLib::findParameter<double>(
245 auto const aperture_config =
247 config.getConfigSubtreeOptional("aperture_size");
248 if (aperture_config)
249 {
250 aperture_size_parameter = &ParameterLib::findParameter<double>(
252 *aperture_config, "parameter", parameters, 1);
253 }
254
255 auto const is_linear =
257 config.getConfigParameter("is_linear", false);
258
259 auto const rotation_matrices = MeshLib::getElementRotationMatrices(
260 mesh_space_dimension, mesh.getDimension(), mesh.getElements());
261 std::vector<Eigen::VectorXd> projected_specific_body_force_vectors;
262 projected_specific_body_force_vectors.reserve(rotation_matrices.size());
263
264 std::transform(rotation_matrices.begin(), rotation_matrices.end(),
265 std::back_inserter(projected_specific_body_force_vectors),
266 [&specific_body_force](const auto& R)
267 { return R * R.transpose() * specific_body_force; });
268
269 ComponentTransportProcessData process_data{
270 std::move(media_map),
271 has_gravity,
272 non_advective_form,
274 chemically_induced_porosity_change,
275 chemical_solver_interface.get(),
276 std::move(lookup_table),
277 std::move(stabilizer),
278 projected_specific_body_force_vectors,
279 mesh_space_dimension,
280 *aperture_size_parameter};
281
282 SecondaryVariableCollection secondary_variables;
283
284 ProcessLib::createSecondaryVariables(config, secondary_variables);
285
286 std::unique_ptr<ProcessLib::SurfaceFluxData> surfaceflux;
287 auto surfaceflux_config =
289 config.getConfigSubtreeOptional("calculatesurfaceflux");
290 if (surfaceflux_config)
291 {
293 *surfaceflux_config, meshes);
294 }
295
296 return std::make_unique<ComponentTransportProcess>(
297 std::move(name), mesh, std::move(jacobian_assembler), parameters,
298 integration_order, std::move(process_variables),
299 std::move(process_data), std::move(secondary_variables),
300 use_monolithic_scheme, std::move(surfaceflux),
301 std::move(chemical_solver_interface), is_linear);
302}
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition: Logging.h:30
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition: Mesh.h:102
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition: Mesh.h:105
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition: Mesh.h:84
static PROCESSLIB_EXPORT const std::string constant_one_parameter_name
Definition: Process.h:49
std::unique_ptr< MaterialSpatialDistributionMap > createMaterialSpatialDistributionMap(std::map< int, std::shared_ptr< Medium > > const &media, MeshLib::Mesh const &mesh)
Eigen::Map< const Vector > toVector(std::vector< double > const &data, Eigen::VectorXd::Index size)
Creates an Eigen mapped vector from the given data vector.
std::vector< Eigen::MatrixXd > getElementRotationMatrices(int const space_dimension, int const mesh_dimension, std::vector< Element * > const &elements)
Element rotation matrix computation.
int getSpaceDimension(std::vector< Node * > const &nodes)
Computes dimension of the embedding space containing the set of given points.
NumericalStabilization createNumericalStabilization(MeshLib::Mesh const &mesh, BaseLib::ConfigTree const &config)
void checkMPLProperties(MeshLib::Mesh const &mesh, MaterialPropertyLib::MaterialSpatialDistributionMap const &media_map)
std::vector< std::reference_wrapper< ProcessVariable > > findProcessVariables(std::vector< ProcessVariable > const &variables, BaseLib::ConfigTree const &pv_config, std::initializer_list< std::string > tags)
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables)
static std::unique_ptr< ProcessLib::SurfaceFluxData > createSurfaceFluxData(BaseLib::ConfigTree const &calculatesurfaceflux_config, std::vector< std::unique_ptr< MeshLib::Mesh > > const &meshes)

References BaseLib::ConfigTree::checkConfigParameter(), checkMPLProperties(), ProcessLib::Process::constant_one_parameter_name, createLookupTable(), MaterialPropertyLib::createMaterialSpatialDistributionMap(), NumLib::createNumericalStabilization(), ProcessLib::createSecondaryVariables(), ProcessLib::SurfaceFluxData::createSurfaceFluxData(), DBUG(), ProcessLib::findProcessVariables(), BaseLib::ConfigTree::getConfigParameter(), BaseLib::ConfigTree::getConfigParameterOptional(), BaseLib::ConfigTree::getConfigSubtree(), BaseLib::ConfigTree::getConfigSubtreeOptional(), MeshLib::Mesh::getDimension(), MeshLib::getElementRotationMatrices(), MeshLib::Mesh::getElements(), MeshLib::Mesh::getNodes(), MeshLib::getSpaceDimension(), OGS_FATAL, and MathLib::toVector().

Referenced by ProjectData::parseProcesses().

◆ createLookupTable()

std::unique_ptr< LookupTable > ProcessLib::ComponentTransport::createLookupTable ( std::optional< std::string > const  tabular_file,
std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > const &  process_variables 
)

Definition at line 55 of file CreateLookupTable.cpp.

59{
60 if (!tabular_file)
61 {
62 return nullptr;
63 }
64
65 auto const path_to_tabular_file =
67
68 if (!BaseLib::IsFileExisting(path_to_tabular_file))
69 {
71 "Not found the tabular file with the specified file path: {:s}",
72 path_to_tabular_file);
73 }
74
75 INFO("Found the tabular file: {:s}", path_to_tabular_file);
76
77 std::ifstream in(path_to_tabular_file);
78 if (!in)
79 {
80 OGS_FATAL("Couldn't open the tabular file: {:s}.",
81 path_to_tabular_file);
82 }
83
84 // read field names
85 std::string line;
86 std::getline(in, line);
87 std::vector<std::string> field_names;
88 boost::split(field_names, line, boost::is_any_of("\t "));
89
90 // categorize entry fields
91 std::vector<std::string> input_field_names;
92 std::copy_if(field_names.begin(), field_names.end(),
93 std::back_inserter(input_field_names),
94 [](auto const& field_name) -> bool
95 { return field_name.find("_new") == std::string::npos; });
96
97 // read table entries
98 std::map<std::string, std::vector<double>> tabular_data;
99 while (std::getline(in, line))
100 {
101 std::vector<std::string> field_data;
102 boost::split(field_data, line, boost::is_any_of("\t "));
103
104 assert(field_data.size() == field_names.size());
105 for (std::size_t field_id = 0; field_id < field_data.size(); ++field_id)
106 {
107 tabular_data[field_names[field_id]].push_back(
108 std::stod(field_data[field_id]));
109 }
110 }
111 in.close();
112
113 std::vector<Field> input_fields;
114 input_fields.reserve(input_field_names.size());
115 for (auto const& field_name : input_field_names)
116 {
117 auto pv = std::find_if(process_variables.begin(),
118 process_variables.end(),
119 [&field_name](auto const& v) -> bool
120 {
121 return v[0].get().getName() == field_name ||
122 v[0].get().getName() + "_prev" ==
123 field_name;
124 });
125
126 if (pv == process_variables.end())
127 {
128 OGS_FATAL(
129 "Not found field name {:s} in the group of process variables "
130 "defined in the project file.",
131 field_name);
132 }
133
134 auto const process_id =
135 static_cast<int>(std::distance(process_variables.cbegin(), pv));
136
137 auto seed_points = tabular_data[field_name];
138 BaseLib::makeVectorUnique(seed_points);
139
140 std::vector<std::vector<std::size_t>> point_id_groups;
141 for (auto const seed_point : seed_points)
142 {
143 auto const point_id_group =
144 getIndexVector(tabular_data[field_name], seed_point);
145 point_id_groups.push_back(point_id_group);
146 }
147
148 input_fields.emplace_back(point_id_groups, seed_points, field_name,
149 process_id);
150 }
151
152 return std::make_unique<LookupTable>(std::move(input_fields),
153 std::move(tabular_data));
154}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition: Logging.h:35
std::string const & getProjectDirectory()
Returns the directory where the prj file resides.
Definition: FileTools.cpp:223
bool IsFileExisting(const std::string &strFilename)
Returns true if given file exists.
Definition: FileTools.cpp:47
std::string joinPaths(std::string const &pathA, std::string const &pathB)
Definition: FileTools.cpp:217
void makeVectorUnique(std::vector< T > &v)
Definition: Algorithm.h:165
std::vector< std::size_t > getIndexVector(std::vector< double > const &data, double const value)

References BaseLib::getProjectDirectory(), INFO(), BaseLib::IsFileExisting(), BaseLib::joinPaths(), BaseLib::makeVectorUnique(), and OGS_FATAL.

Referenced by createComponentTransportProcess().

◆ intersection()

static void ProcessLib::ComponentTransport::intersection ( std::vector< std::size_t > &  vec1,
std::vector< std::size_t > const &  vec2 
)
static

Definition at line 21 of file LookupTable.cpp.

23{
24 std::unordered_set<std::size_t> set(vec1.begin(), vec1.end());
25 vec1.clear();
26 for (auto const a : vec2)
27 {
28 if (set.contains(a))
29 {
30 vec1.push_back(a);
31 set.erase(a);
32 }
33 }
34}

Referenced by ProcessLib::ComponentTransport::LookupTable::getTableEntryID().