40 std::unordered_map<std::string, double>& initial_value_dict,
43 std::vector<double> sigma0(pv_num_components, 0.0);
44 sigma0[0] = initial_value_dict[
"sxx"];
45 sigma0[1] = initial_value_dict[
"syy"];
46 sigma0[2] = initial_value_dict[
"szz"];
48 std::transform(new_pv.begin() + pv_bulk_mesh->
size(),
50 new_pv.begin() + pv_bulk_mesh->
size(),
52 { return static_cast<T>(sigma0[i++ % sigma0.size()]); });
58 int const pv_num_components,
60 std::unordered_map<std::string, double>& initial_value_dict)
66 std::copy(pv_bulk_mesh->begin(), pv_bulk_mesh->end(), new_pv->begin());
68 if (pv_num_components > 1)
70 if (pv_name.find(
"sigma") != std::string::npos)
72 setSigma0(pv_num_components, pv_bulk_mesh, initial_value_dict,
80 const std::unordered_map<std::string, std::string> pv_to_dict_key = {
83 {
"gas_pressure",
"pg"},
85 {
"capillary_pressure",
"pc"},
90 T value =
static_cast<T
>(0.0);
91 auto it = pv_to_dict_key.find(pv_name);
92 if (it != pv_to_dict_key.end() && initial_value_dict.contains(it->second))
94 value =
static_cast<T
>(initial_value_dict[it->second]);
96 std::fill(new_pv->begin() + pv_bulk_mesh->
size(), new_pv->end(), value);
124 int const pv_num_components,
126 std::unordered_map<std::string, double>& initial_value_dict,
127 std::optional<MeshLib::IntegrationPointMetaData>
const&
128 integration_point_meta_data)
135 std::size_t counter = 0;
137 integration_point_meta_data, pv_name);
139 for (
auto const element : merged_mesh.
getElements())
141 int const number_of_integration_points =
144 counter += number_of_integration_points;
146 new_pv->resize(counter * pv_num_components);
148 std::copy(pv_bulk_mesh->begin(), pv_bulk_mesh->end(), new_pv->begin());
150 if (pv_name.find(
"sigma") != std::string::npos)
152 setSigma0(pv_num_components, pv_bulk_mesh, initial_value_dict, *new_pv);
161 std::unordered_map<std::string, double>& initial_value_dict,
163 std::optional<MeshLib::IntegrationPointMetaData>
const&
164 integration_point_meta_data)
166 if (pv_bulk_mesh ==
nullptr)
183 if (pv_name ==
"OGS_VERSION" || pv_name ==
"IntegrationPointMetaData")
186 merged_mesh, pv_name, item_type, pv_num_components);
187 new_pv->resize(pv_bulk_mesh->
size());
189 std::copy(pv_bulk_mesh->begin(), pv_bulk_mesh->end(), new_pv->begin());
196 pv_bulk_mesh, initial_value_dict);
202 pv_bulk_mesh, initial_value_dict);
208 merged_mesh, pv_name, pv_num_components, pv_bulk_mesh,
209 initial_value_dict, integration_point_meta_data);
227 std::unordered_map<std::string, double>& initial_value_dict)
229 auto const& other_mesh_nodes = other_mesh.
getNodes();
230 GeoLib::AABB aabb(other_mesh_nodes.begin(), other_mesh_nodes.end());
232 auto const& bulk_mesh_nodes = bulk_mesh.
getNodes();
233 auto const bulk_nodes_in_aabb =
238 bulk_nodes_in_aabb, other_mesh_nodes, aabb,
240 auto interface_nodes_of_bulk_mesh = pn_bulk_mesh.paired_nodes;
244 other_mesh_nodes, bulk_nodes_in_aabb, aabb);
245 auto const interface_nodes_of_other_mesh = pn_other_mesh.paired_nodes;
246 auto const internal_nodes_of_other_mesh = *(pn_other_mesh.non_paired_nodes);
249 auto cn_id_mapping_m2b = *(pn_other_mesh.id_mapping);
251 std::unordered_map<std::size_t, std::size_t> other_mesh_node_id_dict;
253 for (
auto const&& [id_mapping, node] :
254 ranges::views::zip(cn_id_mapping_m2b, interface_nodes_of_other_mesh))
256 other_mesh_node_id_dict.insert({node->getID(), id_mapping});
260 std::vector<MeshLib::Node*> new_node_vector;
261 new_node_vector.reserve(bulk_mesh_nodes.size() +
262 internal_nodes_of_other_mesh.size());
264 new_node_vector.insert(new_node_vector.end(), bulk_mesh_nodes.begin(),
265 bulk_mesh_nodes.end());
267 std::size_t new_node_id = bulk_mesh_nodes.size();
268 for (
auto node : internal_nodes_of_other_mesh)
270 other_mesh_node_id_dict.insert({node->getID(), new_node_id});
271 new_node_vector.push_back(node);
276 auto const elements_bulk = bulk_mesh.
getElements();
277 auto const elements_other_mesh = other_mesh.
getElements();
278 std::vector<MeshLib::Element*> new_element_vector;
279 new_element_vector.reserve(elements_bulk.size() +
280 elements_other_mesh.size());
282 new_element_vector.insert(new_element_vector.end(), elements_bulk.begin(),
283 elements_bulk.end());
286 for (
auto element : elements_other_mesh)
288 auto const nn = element->getNumberOfNodes();
289 for (
unsigned i = 0; i < nn; ++i)
294 auto const new_id = other_mesh_node_id_dict[node->
getID()];
295 element->setNode(i, new_node_vector[new_id]);
297 new_element_vector.push_back(element);
304 auto merged_mesh = std::make_unique<MeshLib::Mesh>(
305 "merged_mesh", new_node_vector, new_element_vector);
308 auto const integration_point_meta_data =
312 properties_bulk_mesh,
313 [&](
auto type,
auto const& property)
316 *merged_mesh, initial_value_dict,
319 integration_point_meta_data);
322 for (
auto node : interface_nodes_of_other_mesh)