Skip to content

Commit

Permalink
Add serial refinement capability for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiangrimberg committed Jun 10, 2024
1 parent c70f193 commit b2f178a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/src/config/model.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,4 @@ mesh length units.
- `"MaximumImbalance" [1.1]`
- `"SaveAdaptIterations" [true]`
- `"SaveAdaptMesh" [false]`
- `"SerialUniformLevels" [0]`
5 changes: 4 additions & 1 deletion palace/utils/configfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ void RefinementData::SetUp(json &model)

// Options for a priori refinement.
uniform_ref_levels = refinement->value("UniformLevels", uniform_ref_levels);
MFEM_VERIFY(uniform_ref_levels >= 0,
ser_uniform_ref_levels = refinement->value("SerialUniformLevels", ser_uniform_ref_levels);
MFEM_VERIFY(uniform_ref_levels >= 0 && ser_uniform_ref_levels >= 0,
"Number of uniform mesh refinement levels must be non-negative!");
auto boxes = refinement->find("Boxes");
if (boxes != refinement->end())
Expand Down Expand Up @@ -430,6 +431,7 @@ void RefinementData::SetUp(json &model)
refinement->erase("SaveAdaptIterations");
refinement->erase("SaveAdaptMesh");
refinement->erase("UniformLevels");
refinement->erase("SerialUniformLevels");
refinement->erase("Boxes");
refinement->erase("Spheres");
MFEM_VERIFY(refinement->empty(),
Expand All @@ -449,6 +451,7 @@ void RefinementData::SetUp(json &model)
std::cout << "SaveAdaptIterations: " << save_adapt_iterations << '\n';
std::cout << "SaveAdaptMesh: " << save_adapt_mesh << '\n';
std::cout << "UniformLevels: " << uniform_ref_levels << '\n';
std::cout << "SerialUniformLevels: " << ser_uniform_ref_levels << '\n';
}
}

Expand Down
3 changes: 3 additions & 0 deletions palace/utils/configfile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ struct RefinementData
// Parallel uniform mesh refinement levels.
int uniform_ref_levels = 0;

// Serial uniform mesh refinement levels.
int ser_uniform_ref_levels = 0;

private:
// Refinement data for mesh regions.
std::vector<BoxRefinementData> box_list = {};
Expand Down
16 changes: 16 additions & 0 deletions palace/utils/geodata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,22 @@ std::unique_ptr<mfem::ParMesh> ReadMesh(MPI_Comm comm, const IoData &iodata)
ReorderMeshElements(*smesh);
}

// Refine the serial mesh (not typically used, prefer parallel uniform refinement
// instead).
{
int ne = smesh->GetNE();
for (int l = 0; l < iodata.model.refinement.ser_uniform_ref_levels; l++)
{
smesh->UniformRefinement();
}
if (iodata.model.refinement.ser_uniform_ref_levels > 0)
{
Mpi::Print("Serial uniform mesh refinement levels added {:d} elements (initial = "
"{:d}, final = {:d})\n",
smesh->GetNE() - ne, ne, smesh->GetNE());
}
}

// Clean up unused domain elements from the mesh, add new boundary elements for material
// interfaces if not present. Can only clean up conforming meshes, assumes that any
// nonconformal mesh was generated by adaptation and thus does not need checking.
Expand Down
1 change: 1 addition & 0 deletions scripts/schema/config/model.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"SaveAdaptIterations": {"type": "boolean"},
"SaveAdaptMesh": {"type": "boolean"},
"UniformLevels": { "type": "integer", "minimum": 0 },
"SerialUniformLevels": { "type": "integer", "minimum": 0 },
"Boxes":
{
"type": "array",
Expand Down

0 comments on commit b2f178a

Please sign in to comment.