80 if (used[i] && !hasMeshProperty<bool>(
"duct_mesh",
_input_names[i]))
85 "' has no duct mesh. Its edge and corner subchannels are still bounded by a "
86 "duct wall, which the overlap check also uses, but the wall does not appear in "
87 "the mesh. Use a duct mesh generator to include it.");
98 if (
overlap(input_a, input_b, center_b - center_a))
99 overlaps +=
"\n Assembly " + std::to_string(
a) +
" ('" +
_input_names[input_a] +
100 "') and assembly " + std::to_string(
b) +
" ('" +
_input_names[input_b] +
"')";
102 if (!overlaps.empty())
104 "The following assemblies overlap. Increase 'assembly_pitch' or use smaller "
108 std::vector<std::unique_ptr<MeshBase>> inputs;
109 for (
const auto i : index_range(
_meshes))
111 inputs.push_back(std::move(*
_meshes[i]));
112 if (!inputs.back()->is_replicated())
116 "' is not a replicated mesh. SCM core meshes require a replicated mesh; run "
117 "without --distributed-mesh.");
121 mesh->set_spatial_dimension(3);
125 subdomain_id_type next_subdomain_id = 0;
126 boundary_id_type next_boundary_id = 0;
130 auto assembly = dynamic_pointer_cast<UnstructuredMesh>(inputs[input]->clone());
131 const std::string suffix =
"_" + std::to_string(k);
133 std::set<subdomain_id_type> subdomain_ids;
134 for (
const auto *
const elem : assembly->element_ptr_range())
135 subdomain_ids.insert(elem->subdomain_id());
136 std::map<subdomain_id_type, subdomain_id_type> subdomain_map;
137 const auto & old_subdomain_names = assembly->get_subdomain_name_map();
138 std::map<subdomain_id_type, std::string> subdomain_names;
139 for (
const auto old_id : subdomain_ids)
141 subdomain_map[old_id] = next_subdomain_id;
142 const auto it = old_subdomain_names.find(old_id);
143 subdomain_names[next_subdomain_id] =
144 (it == old_subdomain_names.end() ? std::to_string(old_id) : it->second) + suffix;
147 assembly->set_subdomain_name_map() = subdomain_names;
149 if (assembly->has_elem_integer(
"assembly_id"))
153 "' already has an 'assembly_id' extra element integer, which this mesh "
154 "generator would overwrite.");
155 const auto assembly_id_index = assembly->add_elem_integer(
"assembly_id");
156 for (
auto *
const elem : assembly->element_ptr_range())
158 elem->subdomain_id() = libmesh_map_find(subdomain_map, elem->subdomain_id());
159 elem->set_extra_integer(assembly_id_index, k);
162 auto & boundary_info = assembly->get_boundary_info();
163 const auto side_list = boundary_info.build_side_list();
164 const auto node_list = boundary_info.build_node_list();
165 const auto sideset_names = boundary_info.get_sideset_name_map();
166 const auto nodeset_names = boundary_info.get_nodeset_name_map();
167 std::map<boundary_id_type, boundary_id_type> boundary_map;
168 const auto map_boundary = [&boundary_map, &next_boundary_id](
const boundary_id_type old_id)
170 const auto [it, inserted] = boundary_map.try_emplace(old_id, next_boundary_id);
175 for (
const auto old_id : boundary_info.get_boundary_ids())
176 map_boundary(old_id);
177 for (
const auto & [old_id, _] : sideset_names)
178 map_boundary(old_id);
179 for (
const auto & [old_id, _] : nodeset_names)
180 map_boundary(old_id);
184 boundary_info.clear();
185 for (
const auto & [elem_id, side, old_id] : side_list)
186 boundary_info.add_side(elem_id, side, libmesh_map_find(boundary_map, old_id));
187 for (
const auto & [node_id, old_id] : node_list)
188 boundary_info.add_node(node_id, libmesh_map_find(boundary_map, old_id));
189 for (
const auto & [old_id, old_name] : sideset_names)
190 boundary_info.sideset_name(libmesh_map_find(boundary_map, old_id)) = old_name + suffix;
191 for (
const auto & [old_id, old_name] : nodeset_names)
192 boundary_info.nodeset_name(libmesh_map_find(boundary_map, old_id)) = old_name + suffix;
194 MeshTools::Modification::translate(*assembly,
center(0),
center(1), 0.0);
204 mesh->unset_is_prepared();
205 return dynamic_pointer_cast<MeshBase>(
mesh);
void copyIntoMesh(MeshGenerator &mg, UnstructuredMesh &destination, const UnstructuredMesh &source, const bool avoid_merging_subdomains, const bool avoid_merging_boundaries, const Parallel::Communicator &communicator, const bool skip_preparation=false)