Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preliminaries for NS component wrapping #23974

Merged
merged 18 commits into from May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -6,6 +6,12 @@

The `CombinerGenerator` allows the user to combine the outputs of multiple `MeshGenerator`s into a single mesh. This is somewhat similar to the [StitchedMeshGenerator.md] with the difference being that `CombinerGenerator` makes no attempt to "heal" / "join" the mesh like [StitchedMeshGenerator.md] does. There `CombinerGenerator` is more suited to creation of disjoint meshes (where the individual pieces are not directly tied together).

!alert note title=Mesh naming precedence
`CombinerGenerator` preserves subdomain names and boundary names (node sets, side sets, and edge sets).
If the corresponding IDs exist in multiple meshes, then the meshes/copies listed
later in [!param](/Mesh/CombinerGenerator/inputs)/[!param](/Mesh/CombinerGenerator/positions)
take precedence.

## Usage

There are three main ways to use the `CombinerGenerator`:
Expand Down
2 changes: 1 addition & 1 deletion framework/include/base/MooseApp.h
Expand Up @@ -713,7 +713,7 @@ class MooseApp : public ConsoleStreamInterface,
const MooseMesh * masterMesh() const { return _master_mesh; }

/**
* Returns a pointer to the master mesh
* Returns a pointer to the master displaced mesh
*/
const MooseMesh * masterDisplacedMesh() const { return _master_displaced_mesh; }

Expand Down
8 changes: 8 additions & 0 deletions framework/include/interfaces/BlockRestrictable.h
Expand Up @@ -107,6 +107,11 @@ class BlockRestrictable
*/
const virtual std::set<SubdomainID> & blockIDs() const;

/**
* Return the largest mesh dimension of the elements in the blocks for this object
*/
unsigned int blocksMaxDimension() const { return _blk_dim; }

/**
* Test if the supplied block name is valid for this object
* @param name A SubdomainName to check
Expand Down Expand Up @@ -248,6 +253,9 @@ class BlockRestrictable

/// Name of the object
const std::string & _blk_name;

/// Largest mesh dimension of the elements in the blocks for this object
unsigned int _blk_dim;
};

template <typename T, bool is_ad>
Expand Down
7 changes: 6 additions & 1 deletion framework/include/mesh/MooseMesh.h
Expand Up @@ -158,7 +158,7 @@ class MooseMesh : public MooseObject, public Restartable, public PerfGraphInterf
virtual void buildMesh() = 0;

/**
* Returns MeshBase::mesh_dimsension(), (not
* Returns MeshBase::mesh_dimension(), (not
* MeshBase::spatial_dimension()!) of the underlying libMesh mesh
* object.
*/
Expand All @@ -171,6 +171,11 @@ class MooseMesh : public MooseObject, public Restartable, public PerfGraphInterf
*/
virtual unsigned int effectiveSpatialDimension() const;

/**
* Returns the maximum element dimension on the given blocks
*/
unsigned int getBlocksMaxDimension(const std::vector<SubdomainName> & blocks) const;

/**
* Returns a vector of boundary IDs for the requested element on the
* requested side.
Expand Down
6 changes: 6 additions & 0 deletions framework/src/interfaces/BlockRestrictable.C
Expand Up @@ -163,6 +163,12 @@ BlockRestrictable::initializeBlockRestrictable(const MooseObject * moose_object)
moose_object->paramError("block", msg.str());
}
}

// Get the mesh dimension for the blocks
if (blockRestricted())
_blk_dim = _blk_mesh->getBlocksMaxDimension(_blocks);
else
_blk_dim = _blk_mesh->dimension();
}

bool
Expand Down
12 changes: 12 additions & 0 deletions framework/src/mesh/MooseMesh.C
Expand Up @@ -2500,6 +2500,18 @@ MooseMesh::effectiveSpatialDimension() const
return 1;
}

unsigned int
MooseMesh::getBlocksMaxDimension(const std::vector<SubdomainName> & blocks) const
{
unsigned short dim = 0;
const auto subdomain_ids = getSubdomainIDs(blocks);
const std::set<SubdomainID> subdomain_ids_set(subdomain_ids.begin(), subdomain_ids.end());
for (const auto & elem : getMesh().active_subdomain_set_elements_ptr_range(subdomain_ids_set))
dim = std::max(dim, elem->dim());

return dim;
}

std::vector<BoundaryID>
MooseMesh::getBoundaryIDs(const Elem * const elem, const unsigned short int side) const
{
Expand Down
9 changes: 9 additions & 0 deletions framework/src/meshgenerators/CombinerGenerator.C
Expand Up @@ -252,6 +252,15 @@ CombinerGenerator::copyIntoMesh(UnstructuredMesh & destination, const Unstructur
for (const auto & t : other_boundary.build_shellface_list())
boundary.add_shellface(std::get<0>(t) + elem_delta, std::get<1>(t), std::get<2>(t));

for (auto elem : source.get_subdomain_name_map())
destination.set_subdomain_name_map().insert(elem);

for (auto elem : other_boundary.get_nodeset_name_map())
boundary.set_nodeset_name_map().insert(elem);

for (auto elem : other_boundary.get_sideset_name_map())
boundary.set_sideset_name_map().insert(elem);

for (auto elem : other_boundary.get_edgeset_name_map())
boundary.set_edgeset_name_map().insert(elem);
}