www.mooseframework.org
MortarPeriodicMesh.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 #include "MortarPeriodicMesh.h"
9 
10 #include "libmesh/mesh_modification.h"
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<GeneratedMesh>();
17  params.addClassDescription("Set up an orthogonal mesh with additional dim-1 dimensional side "
18  "domains for use with the Mortar method.");
19  MultiMooseEnum periodic_dirs("x=0 y=1 z=2");
20  params.addRequiredParam<MultiMooseEnum>(
21  "periodic_directions",
22  periodic_dirs,
23  "Directions along which additional Mortar meshes are generated");
24  return params;
25 }
26 
27 MortarPeriodicMesh::MortarPeriodicMesh(const InputParameters & parameters)
28  : GeneratedMesh(parameters),
29  _periodic_dirs(getParam<MultiMooseEnum>("periodic_directions")),
30  _mortar_subdomains(_dim, Moose::INVALID_BLOCK_ID)
31 {
32 }
33 
35  : GeneratedMesh(other_mesh),
36  _periodic_dirs(other_mesh._periodic_dirs),
38 {
39 }
40 
42 
43 MooseMesh &
45 {
46  return *(new MortarPeriodicMesh(*this));
47 }
48 
49 void
51 {
52  // build the main mesh
53  GeneratedMesh::buildMesh();
54 
55  // boundaries
56  const std::vector<BoundaryName> boundary_names = {"left", "bottom", "back"};
57 
58  buildBndElemList();
59 
60  // build side meshes
61  for (unsigned short i = 0; i < _dim; ++i)
62  if (_periodic_dirs.contains(i))
63  {
64  BoundaryID current_boundary_id = getBoundaryID(boundary_names[i]);
65 
66  for (auto it = bndElemsBegin(); it != bndElemsEnd(); ++it)
67  if ((*it)->_bnd_id == current_boundary_id)
68  {
69  Elem * elem = (*it)->_elem;
70  auto s = (*it)->_side;
71 
72  // build element from the side
73  std::unique_ptr<Elem> side(elem->build_side_ptr(s, false));
74  side->processor_id() = elem->processor_id();
75 
76  // Add the side set subdomain
77  Elem * new_elem = _mesh->add_elem(side.release());
78  _mortar_subdomains[i] = 10 + i;
79  new_elem->subdomain_id() = _mortar_subdomains[i];
80 
81  // TODO: this does not assign unique IDs
82  }
83  }
84 }
InputParameters validParams< MortarPeriodicMesh >()
virtual void buildMesh()
Mesh generated from parameters with additional subdomains for mortar interfaces to enforce periodicit...
virtual MooseMesh & clone() const
MortarPeriodicMesh(const InputParameters &parameters)
MultiMooseEnum _periodic_dirs
periodic directions
std::vector< SubdomainID > _mortar_subdomains