18 #include "libmesh/periodic_boundary.h" 19 #include "libmesh/ghost_point_neighbors.h" 32 "If using a generated mesh, the dimension(s) you want to mark as periodic.");
34 params.addParam<BoundaryName>(
"primary",
"Boundary associated with the primary boundary.");
35 params.addParam<BoundaryName>(
"secondary",
"Boundary associated with the secondary boundary.");
37 "Vector that translates coordinates on the primary boundary to " 38 "coordinates on the secondary boundary.");
39 params.addParam<std::vector<std::string>>(
"transform_func",
40 "Functions that specify the transformation");
41 params.addParam<std::vector<std::string>>(
"inv_transform_func",
42 "Functions that specify the inverse transformation");
53 for (
const auto & param :
54 {
"primary",
"secondary",
"translation",
"transform_func",
"inv_transform_func"})
60 "Either 'auto_direction' or both 'primary' and 'secondary' must be specified");
79 const auto add_ghosting = [
this](
auto & problem)
82 auto functor = std::make_shared<libMesh::GhostPointNeighbors>(
mesh);
84 mesh.add_ghosting_functor(functor);
87 add_ghosting(problem);
106 if (
mesh.isDistributedMesh() && !
mesh.detectOrthogonalDimRanges())
107 _action.
mooseError(
"Could not detect orthogonal dimension ranges for DistributedMesh.");
111 const int component = dir.id();
112 if (component > (cast_int<int>(
mesh.dimension()) - 1))
115 "-dimension component not valid for ",
119 const auto boundary_ids =
mesh.getPairedBoundaryMapping(component);
122 "Couldn't auto-detect a paired boundary in the ",
127 v(component) =
mesh.dimensionWidth(component);
129 auto p = std::make_unique<libMesh::PeriodicBoundary>(v);
130 p->myboundary = boundary_ids->first;
131 p->pairedboundary = boundary_ids->second;
141 std::unique_ptr<libMesh::PeriodicBoundaryBase> p;
144 p = std::make_unique<libMesh::PeriodicBoundary>(*translation_ptr);
145 else if (
const auto fn_names_ptr =
_params.
queryParam<std::vector<std::string>>(
"transform_func"))
147 const auto inv_fn_names_ptr =
149 if (!inv_fn_names_ptr)
151 if (fn_names_ptr->size() !=
mesh.dimension())
153 "transform_func",
"Must be the size of the mesh dimension ",
mesh.dimension());
154 if (inv_fn_names_ptr->size() !=
mesh.dimension())
156 "inv_transform_func",
"Must be the size of the mesh dimension ",
mesh.dimension());
158 p = std::make_unique<FunctionPeriodicBoundary>(problem, *fn_names_ptr, *inv_fn_names_ptr);
162 "You need to specify either 'auto_direction', 'translation', or 'transform_func'");
164 const auto get_boundary = [
this, &
mesh](
const auto & param) ->
BoundaryID 171 _params.
paramError(param,
"Boundary '", *name_ptr,
"' does not exist in the mesh");
173 _action.
mooseError(
"Parameter '", param,
"' is required when 'auto_direction' is not set");
175 p->myboundary = get_boundary(
"primary");
176 p->pairedboundary = get_boundary(
"secondary");
184 if (
const auto moa = dynamic_cast<const MooseObjectAction *>(&
_action))
185 return moa->getObjectParams();
void setupPeriodicBoundaries(FEProblemBase &problem)
Sets up the periodic boundaries.
bool hasDetectedPairedSidesets() const
Whether or not detectedPairedSidesets() has been called.
std::shared_ptr< DisplacedProblem > displaced_problem
const BoundaryID INVALID_BOUNDARY_ID
void setupManualPeriodicBoundaries(FEProblemBase &problem)
Internal method for setting up manual periodic boundaries via the "translation" and "transform_func" ...
const InputParameters & parameters() const
Get the parameters of the object.
void addPeriodicBoundary(std::unique_ptr< libMesh::PeriodicBoundaryBase >)
Internal helper for adding a periodic boundary.
void detectPairedSidesets()
This routine detects paired sidesets of a regular orthogonal mesh (.i.e.
PeriodicBCHelper(const Action &action)
const libMesh::PeriodicBoundaries & getPeriodicBoundaries() const
Get the PeriodicBoundaries map produced in setupPeriodicBoundaries().
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
BoundaryID getBoundaryID(const BoundaryName &boundary_name, const MeshBase &mesh)
Gets the boundary ID associated with the given BoundaryName.
void checkPeriodicParams() const
Checks the validity of the periodic boundary condition parameters.
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
boundary_id_type BoundaryID
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
void setupAutoPeriodicBoundaries(MooseMesh &mesh)
Internal method for setting up periodic boundaries via the "auto_direction" param.
std::string toLower(std::string name)
Convert supplied string to lower case.
static InputParameters validParams()
const InputParameters & _params
The parameters used to create the periodic boundary.
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
const InputParameters & getParams() const
Internal method for getting the parameters by the owned action.
virtual MooseMesh & mesh() override
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
libMesh::PeriodicBoundaries _periodic_boundaries
The PeriodicBoundaries map, filled in setupPeriodicBoundaries()
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type...
virtual void onSetupPeriodicBoundary(libMesh::PeriodicBoundaryBase &)
Entry-point for derived actions to extend the addition of a periodic boundary.
const Action & _action
The owning Action.