32 std::unordered_map<std::string, double>& initial_value_dict,
35 std::vector<double> sigma0(pv_num_components, 0.0);
36 sigma0[0] = initial_value_dict[
"sxx"];
37 sigma0[1] = initial_value_dict[
"syy"];
38 sigma0[2] = initial_value_dict[
"szz"];
40 std::transform(new_pv.
begin() + pv_bulk_mesh->
size(),
44 { return static_cast<T>(sigma0[i++ % sigma0.size()]); });
50 int const pv_num_components,
52 std::unordered_map<std::string, double>& initial_value_dict)
58 std::copy(pv_bulk_mesh->
begin(), pv_bulk_mesh->
end(), new_pv->begin());
60 if (pv_num_components > 1)
62 if (pv_name.find(
"sigma") != std::string::npos)
64 setSigma0(pv_num_components, pv_bulk_mesh, initial_value_dict,
72 const std::unordered_map<std::string, std::string> pv_to_dict_key = {
75 {
"gas_pressure",
"pg"},
77 {
"capillary_pressure",
"pc"},
82 T value =
static_cast<T
>(0.0);
83 auto it = pv_to_dict_key.find(pv_name);
84 if (it != pv_to_dict_key.end() && initial_value_dict.contains(it->second))
86 value =
static_cast<T
>(initial_value_dict[it->second]);
88 std::fill(new_pv->begin() + pv_bulk_mesh->
size(), new_pv->end(), value);
116 int const pv_num_components,
118 std::unordered_map<std::string, double>& initial_value_dict,
119 std::optional<MeshLib::IntegrationPointMetaData>
const&
120 integration_point_meta_data)
127 std::size_t counter = 0;
129 integration_point_meta_data, pv_name);
131 for (
auto const element : merged_mesh.
getElements())
133 int const number_of_integration_points =
136 counter += number_of_integration_points;
138 new_pv->resize(counter * pv_num_components);
140 std::copy(pv_bulk_mesh->
begin(), pv_bulk_mesh->
end(), new_pv->begin());
142 if (pv_name.find(
"sigma") != std::string::npos)
144 setSigma0(pv_num_components, pv_bulk_mesh, initial_value_dict, *new_pv);
153 std::unordered_map<std::string, double>& initial_value_dict,
155 std::optional<MeshLib::IntegrationPointMetaData>
const&
156 integration_point_meta_data)
158 if (pv_bulk_mesh ==
nullptr)
175 if (pv_name ==
"OGS_VERSION" || pv_name ==
"IntegrationPointMetaData")
178 merged_mesh, pv_name, item_type, pv_num_components);
179 new_pv->resize(pv_bulk_mesh->
size());
181 std::copy(pv_bulk_mesh->
begin(), pv_bulk_mesh->
end(), new_pv->begin());
188 pv_bulk_mesh, initial_value_dict);
194 pv_bulk_mesh, initial_value_dict);
200 merged_mesh, pv_name, pv_num_components, pv_bulk_mesh,
201 initial_value_dict, integration_point_meta_data);
219 std::unordered_map<std::string, double>& initial_value_dict)
221 auto const& other_mesh_nodes = other_mesh.
getNodes();
222 GeoLib::AABB aabb(other_mesh_nodes.begin(), other_mesh_nodes.end());
224 auto const& bulk_mesh_nodes = bulk_mesh.
getNodes();
225 auto const bulk_nodes_in_aabb =
230 bulk_nodes_in_aabb, other_mesh_nodes, aabb,
232 auto interface_nodes_of_bulk_mesh = pn_bulk_mesh.paired_nodes;
236 other_mesh_nodes, bulk_nodes_in_aabb, aabb);
237 auto const interface_nodes_of_other_mesh = pn_other_mesh.paired_nodes;
238 auto const internal_nodes_of_other_mesh = *(pn_other_mesh.non_paired_nodes);
241 auto cn_id_mapping_m2b = *(pn_other_mesh.id_mapping);
243 std::unordered_map<std::size_t, std::size_t> other_mesh_node_id_dict;
245 for (
auto const&& [id_mapping, node] :
246 ranges::views::zip(cn_id_mapping_m2b, interface_nodes_of_other_mesh))
248 other_mesh_node_id_dict.insert({node->getID(), id_mapping});
252 std::vector<MeshLib::Node*> new_node_vector;
253 new_node_vector.reserve(bulk_mesh_nodes.size() +
254 internal_nodes_of_other_mesh.size());
256 new_node_vector.insert(new_node_vector.end(), bulk_mesh_nodes.begin(),
257 bulk_mesh_nodes.end());
259 std::size_t new_node_id = bulk_mesh_nodes.size();
260 for (
auto node : internal_nodes_of_other_mesh)
262 other_mesh_node_id_dict.insert({node->getID(), new_node_id});
263 new_node_vector.push_back(node);
268 auto const elements_bulk = bulk_mesh.
getElements();
269 auto const elements_other_mesh = other_mesh.
getElements();
270 std::vector<MeshLib::Element*> new_element_vector;
271 new_element_vector.reserve(elements_bulk.size() +
272 elements_other_mesh.size());
274 new_element_vector.insert(new_element_vector.end(), elements_bulk.begin(),
275 elements_bulk.end());
278 for (
auto element : elements_other_mesh)
280 auto const nn = element->getNumberOfNodes();
281 for (
unsigned i = 0; i < nn; ++i)
286 auto const new_id = other_mesh_node_id_dict[node->
getID()];
287 element->setNode(i, new_node_vector[new_id]);
289 new_element_vector.push_back(element);
296 auto merged_mesh = std::make_unique<MeshLib::Mesh>(
297 "merged_mesh", new_node_vector, new_element_vector);
300 auto const integration_point_meta_data =
304 properties_bulk_mesh,
305 [&](
auto type,
auto const& property)
308 *merged_mesh, initial_value_dict,
311 integration_point_meta_data);
314 for (
auto node : interface_nodes_of_other_mesh)