20 "Sets of nodes per dimension. Node values "
21 "must be monotonically increasing");
33 auto& node_sets_param = params.
GetParam(
"node_sets");
36 for (
const auto& node_list_block : node_sets_param)
40 "The entries of \"node_sets\" are required to be of type \"Array\".");
42 node_sets_.push_back(node_list_block.GetVectorValue<
double>());
49 "No nodes have been provided. At least one node set must be provided");
52 "More than 3 node sets have been provided. The "
53 "maximum allowed is 3.");
60 "Node set " + std::to_string(ns) +
" only has " +
61 std::to_string(node_set.size()) +
62 " nodes. A minimum of 2 is required to define a cell.");
67 size_t set_number = 0;
71 "Node set " + std::to_string(set_number) +
72 " in parameter \"node_sets\" may not be empty");
74 bool monotonic =
true;
75 double prev_value = node_set[0];
76 for (
size_t k = 1; k < node_set.size(); ++k)
78 if (node_set[k] <= prev_value)
84 prev_value = node_set[k];
88 std::stringstream outstr;
89 for (
double value : node_set)
90 outstr << value <<
" ";
92 "values to be monotonically increasing. Node set: " +
99std::unique_ptr<UnpartitionedMesh>
101 std::unique_ptr<UnpartitionedMesh> input_umesh)
104 input_umesh !=
nullptr,
105 "OrthogonalMeshGenerator can not be preceded by another"
106 " mesh generator because it cannot process an input mesh");
116 throw std::logic_error(
121std::unique_ptr<UnpartitionedMesh>
123 const std::vector<double>& vertices)
125 auto umesh = std::make_unique<UnpartitionedMesh>();
128 std::vector<Vertex> zverts;
129 zverts.reserve(vertices.size());
130 for (
double z_coord : vertices)
131 zverts.emplace_back(0.0, 0.0, z_coord);
136 size_t Nz = vertices.size();
138 umesh->GetMeshOptions().ortho_Nx = 1;
139 umesh->GetMeshOptions().ortho_Ny = 1;
140 umesh->GetMeshOptions().ortho_Nz = Nz - 1;
141 umesh->GetMeshOptions().boundary_id_map[4] =
"ZMAX";
142 umesh->GetMeshOptions().boundary_id_map[5] =
"ZMIN";
144 umesh->GetVertices().reserve(Nz);
145 for (
auto& vertex : zverts)
146 umesh->GetVertices().push_back(vertex);
149 const size_t max_cz = zverts.size() - 2;
150 for (
size_t c = 0; c < (zverts.size() - 1); ++c)
155 cell->vertex_ids = {c, c + 1};
177 cell->faces.push_back(left_face);
178 cell->faces.push_back(rite_face);
180 umesh->AddCell(cell);
183 umesh->ComputeCentroidsAndCheckQuality();
184 umesh->BuildMeshConnectivity();
190std::unique_ptr<UnpartitionedMesh>
192 const std::vector<double>& vertices_1d_x,
193 const std::vector<double>& vertices_1d_y)
195 auto umesh = std::make_unique<UnpartitionedMesh>();
200 const size_t Nx = vertices_1d_x.size();
201 const size_t Ny = vertices_1d_y.size();
203 umesh->GetMeshOptions().ortho_Nx = Nx - 1;
204 umesh->GetMeshOptions().ortho_Ny = Ny - 1;
205 umesh->GetMeshOptions().ortho_Nz = 1;
206 umesh->GetMeshOptions().boundary_id_map[0] =
"XMAX";
207 umesh->GetMeshOptions().boundary_id_map[1] =
"XMIN";
208 umesh->GetMeshOptions().boundary_id_map[2] =
"YMAX";
209 umesh->GetMeshOptions().boundary_id_map[3] =
"YMIN";
211 typedef std::vector<uint64_t> VecIDs;
212 std::vector<VecIDs> vertex_ij_to_i_map(Ny, VecIDs(Nx));
213 umesh->GetVertices().reserve(Nx * Ny);
216 for (
size_t i = 0; i < Ny; ++i)
218 for (
size_t j = 0; j < Nx; ++j)
220 vertex_ij_to_i_map[i][j] = k++;
221 umesh->GetVertices().emplace_back(
222 vertices_1d_x[j], vertices_1d_y[i], 0.0);
227 std::vector<VecIDs> cells_ij_to_i_map(Ny - 1, VecIDs(Nx - 1));
230 for (
size_t i = 0; i < (Ny - 1); ++i)
231 for (
size_t j = 0; j < (Nx - 1); ++j)
232 cells_ij_to_i_map[i][j] = k++;
236 auto& vmap = vertex_ij_to_i_map;
237 auto& cmap = cells_ij_to_i_map;
238 const size_t max_j = Nx - 2;
239 const size_t max_i = Ny - 2;
240 for (
size_t i = 0; i < (Ny - 1); ++i)
242 for (
size_t j = 0; j < (Nx - 1); ++j)
255 vmap[i][j], vmap[i][j + 1], vmap[i + 1][j + 1], vmap[i + 1][j]};
257 for (
int v = 0; v < 4; ++v)
263 std::vector<uint64_t>{cell->vertex_ids[v], cell->vertex_ids[v + 1]};
266 std::vector<uint64_t>{cell->vertex_ids[v], cell->vertex_ids[0]};
270 if (v == 1 and i != max_j) face.
neighbor = cmap[i][j+1];
271 if (v == 3 and i != 0 ) face.
neighbor = cmap[i][j-1];
272 if (v == 2 and i != max_i) face.
neighbor = cmap[i+1][j];
273 if (v == 0 and i != 0 ) face.
neighbor = cmap[i-1][j];
282 cell->faces.push_back(face);
285 umesh->AddCell(cell);
289 umesh->ComputeCentroidsAndCheckQuality();
290 umesh->BuildMeshConnectivity();
296std::unique_ptr<UnpartitionedMesh>
298 const std::vector<double>& vertices_1d_x,
299 const std::vector<double>& vertices_1d_y,
300 const std::vector<double>& vertices_1d_z)
302 auto umesh = std::make_unique<UnpartitionedMesh>();
307 size_t Nx = vertices_1d_x.size();
308 size_t Ny = vertices_1d_y.size();
309 size_t Nz = vertices_1d_z.size();
311 umesh->GetMeshOptions().ortho_Nx = Nx - 1;
312 umesh->GetMeshOptions().ortho_Ny = Ny - 1;
313 umesh->GetMeshOptions().ortho_Nz = Nz - 1;
314 umesh->GetMeshOptions().boundary_id_map[0] =
"XMAX";
315 umesh->GetMeshOptions().boundary_id_map[1] =
"XMIN";
316 umesh->GetMeshOptions().boundary_id_map[2] =
"YMAX";
317 umesh->GetMeshOptions().boundary_id_map[3] =
"YMIN";
318 umesh->GetMeshOptions().boundary_id_map[4] =
"ZMAX";
319 umesh->GetMeshOptions().boundary_id_map[5] =
"ZMIN";
326 typedef std::vector<uint64_t> VecIDs;
327 typedef std::vector<VecIDs> VecVecIDs;
328 std::vector<VecVecIDs> vertex_ijk_to_i_map(Ny);
329 for (
auto& vec : vertex_ijk_to_i_map)
330 vec.resize(Nx, VecIDs(Nz));
332 umesh->GetVertices().reserve(Nx * Ny * Nz);
335 for (
size_t i = 0; i < Ny; ++i)
337 for (
size_t j = 0; j < Nx; ++j)
339 for (
size_t k = 0; k < Nz; ++k)
341 vertex_ijk_to_i_map[i][j][k] = c++;
342 umesh->GetVertices().emplace_back(
343 vertices_1d_x[j], vertices_1d_y[i], vertices_1d_z[k]);
349 std::vector<VecVecIDs> cells_ijk_to_i_map(Ny - 1);
350 for (
auto& vec : cells_ijk_to_i_map)
351 vec.resize(Nx - 1, VecIDs(Nz - 1));
355 for (
size_t i = 0; i < (Ny - 1); ++i)
356 for (
size_t j = 0; j < (Nx - 1); ++j)
357 for (
size_t k = 0; k < (Nz - 1); ++k)
358 cells_ijk_to_i_map[i][j][k] = c++;
362 auto& vmap = vertex_ijk_to_i_map;
363 auto& cmap = cells_ijk_to_i_map;
364 const size_t max_j = Nx - 2;
365 const size_t max_i = Ny - 2;
366 const size_t max_k = Nz - 2;
367 for (
size_t i = 0; i < (Ny - 1); ++i)
369 for (
size_t j = 0; j < (Nx - 1); ++j)
371 for (
size_t k = 0; k < (Nz - 1); ++k)
376 cell->vertex_ids = std::vector<uint64_t>{vmap[i][j][k],
378 vmap[i + 1][j + 1][k],
382 vmap[i][j + 1][k + 1],
383 vmap[i + 1][j + 1][k + 1],
384 vmap[i + 1][j][k + 1]};
390 face.
vertex_ids = std::vector<uint64_t>{vmap[i][j + 1][k],
391 vmap[i + 1][j + 1][k],
392 vmap[i + 1][j + 1][k + 1],
393 vmap[i][j + 1][k + 1]};
394 face.
neighbor = (j == max_j) ? 0 : cmap[i][j + 1][k];
396 cell->faces.push_back(face);
402 face.
vertex_ids = std::vector<uint64_t>{vmap[i][j][k],
404 vmap[i + 1][j][k + 1],
406 face.
neighbor = (j == 0) ? 1 : cmap[i][j - 1][k];
408 cell->faces.push_back(face);
414 face.
vertex_ids = std::vector<uint64_t>{vmap[i + 1][j][k],
415 vmap[i + 1][j][k + 1],
416 vmap[i + 1][j + 1][k + 1],
417 vmap[i + 1][j + 1][k]};
418 face.
neighbor = (i == max_i) ? 2 : cmap[i + 1][j][k];
420 cell->faces.push_back(face);
426 face.
vertex_ids = std::vector<uint64_t>{vmap[i][j][k],
428 vmap[i][j + 1][k + 1],
430 face.
neighbor = (i == 0) ? 3 : cmap[i - 1][j][k];
432 cell->faces.push_back(face);
438 face.
vertex_ids = std::vector<uint64_t>{vmap[i][j][k + 1],
439 vmap[i][j + 1][k + 1],
440 vmap[i + 1][j + 1][k + 1],
441 vmap[i + 1][j][k + 1]};
442 face.
neighbor = (k == max_k) ? 4 : cmap[i][j][k + 1];
444 cell->faces.push_back(face);
450 face.
vertex_ids = std::vector<uint64_t>{vmap[i][j][k],
452 vmap[i + 1][j + 1][k],
454 face.
neighbor = (k == 0) ? 5 : cmap[i][j][k - 1];
456 cell->faces.push_back(face);
459 umesh->AddCell(cell);
464 umesh->ComputeCentroidsAndCheckQuality();
465 umesh->BuildMeshConnectivity();
#define ChiInvalidArgumentIf(condition, message)
#define ChiInvalidArgument(message)
void RequireBlockTypeIs(ParameterBlockType type) const
bool Has(const std::string ¶m_name) const
ParameterBlock & GetParam(const std::string ¶m_name)
static chi::InputParameters GetInputParameters()
static std::unique_ptr< UnpartitionedMesh > CreateUnpartitioned1DOrthoMesh(const std::vector< double > &vertices)
std::vector< std::vector< double > > node_sets_
static chi::InputParameters GetInputParameters()
std::unique_ptr< UnpartitionedMesh > GenerateUnpartitionedMesh(std::unique_ptr< UnpartitionedMesh > input_umesh) override
OrthogonalMeshGenerator(const chi::InputParameters ¶ms)
static std::unique_ptr< UnpartitionedMesh > CreateUnpartitioned2DOrthoMesh(const std::vector< double > &vertices_1d_x, const std::vector< double > &vertices_1d_y)
static std::unique_ptr< UnpartitionedMesh > CreateUnpartitioned3DOrthoMesh(const std::vector< double > &vertices_1d_x, const std::vector< double > &vertices_1d_y, const std::vector< double > &vertices_1d_z)
RegisterChiObject(chi_mesh, BooleanLogicalVolume)
std::vector< uint64_t > vertex_ids