www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
MortarPeriodicAction Class Reference

Set up Mortar based periodicity in an input file with a MortarPeriodicMesh. More...

#include <MortarPeriodicAction.h>

Inheritance diagram for MortarPeriodicAction:
[legend]

Public Member Functions

 MortarPeriodicAction (const InputParameters &parameters)
 
virtual void act ()
 

Protected Attributes

std::vector< VariableName > _variables
 
const unsigned int _periodicity
 

Detailed Description

Set up Mortar based periodicity in an input file with a MortarPeriodicMesh.

Definition at line 23 of file MortarPeriodicAction.h.

Constructor & Destructor Documentation

◆ MortarPeriodicAction()

MortarPeriodicAction::MortarPeriodicAction ( const InputParameters &  parameters)

Definition at line 38 of file MortarPeriodicAction.C.

39  : Action(parameters),
40  _variables(getParam<std::vector<VariableName>>("variable")),
41  _periodicity(getParam<MooseEnum>("periodicity"))
42 {
43 }
std::vector< VariableName > _variables
const unsigned int _periodicity

Member Function Documentation

◆ act()

void MortarPeriodicAction::act ( )
virtual

Definition at line 46 of file MortarPeriodicAction.C.

47 {
48  // get the mesh
49  MooseSharedPointer<MortarPeriodicMesh> mesh =
50  MooseSharedNamespace::dynamic_pointer_cast<MortarPeriodicMesh>(_mesh);
51  if (!mesh)
52  mooseError("Please use a MortarPeriodicMesh in your simulation.");
53 
54  // mesh dimension
55  const unsigned short dim = mesh->dimension();
56 
57  // periodicity subblock name
58  std::string periodicity_name = name();
59 
60  // axis names
61  const std::vector<BoundaryName> axis = {"x", "y", "z"};
62 
63  // boundaries
64  const std::vector<BoundaryName> boundary_names = {"left", "bottom", "back"};
65  // opposite boundaries
66  const std::vector<BoundaryName> opposite_boundary_names = {"right", "top", "front"};
67 
68  // mortar subdomains
69  const std::vector<SubdomainID> & mortar_subdomains = mesh->getMortarSubdomains();
70 
71  // iterate over the periodic directions
72  for (unsigned short i = 0; i < dim; ++i)
73  if (mesh->getPeriodicDirections().contains(i))
74  {
75  // initialize subdomain restriction set
76  std::set<SubdomainID> subdomain_restriction = {mortar_subdomains[i]};
77 
78  // Lagrange multiplier variable base name
79  const std::string lm_base = "lm_" + periodicity_name + "_" + boundary_names[i];
80 
81  // mortar interface name
82  const std::string mi_name =
83  "mi_" + periodicity_name + "_" + boundary_names[i] + '_' + opposite_boundary_names[i];
84 
85  //
86  // Add Lagrange multiplier variables
87  //
88 
89  if (_current_task == "add_variable")
90  {
91  for (auto & var : _variables)
92  {
93  switch (_periodicity)
94  {
95  case 0: // gradient
96  for (unsigned short j = 0; j < dim; ++j)
97  _problem->addVariable(lm_base + "_" + var + "_d" + axis[j],
98  FEType(Utility::string_to_enum<Order>("FIRST"),
99  Utility::string_to_enum<FEFamily>("LAGRANGE")),
100  1.0,
101  &subdomain_restriction);
102  break;
103 
104  case 1: // value
105  _problem->addVariable(lm_base + "_" + var,
106  FEType(Utility::string_to_enum<Order>("FIRST"),
107  Utility::string_to_enum<FEFamily>("LAGRANGE")),
108  1.0,
109  &subdomain_restriction);
110  break;
111 
112  default:
113  paramError("periodicity", "Periodicity type not implemented");
114  }
115  }
116  }
117 
118  //
119  // Add Mortar interfaces
120  //
121 
122  if (_current_task == "add_mortar_interface")
123  {
124  _mesh->addMortarInterface(mi_name,
125  boundary_names[i],
126  opposite_boundary_names[i],
127  Moose::stringify(mortar_subdomains[i]));
128  if (_displaced_mesh)
129  _displaced_mesh->addMortarInterface(mi_name,
130  boundary_names[i],
131  opposite_boundary_names[i],
132  Moose::stringify(mortar_subdomains[i]));
133  }
134 
135  //
136  // Add Constraints
137  //
138 
139  if (_current_task == "add_constraint")
140  {
141  for (auto & var : _variables)
142  {
143  const std::string ct_base =
144  "ct_" + periodicity_name + "_" + boundary_names[i] + "_" + var;
145  switch (_periodicity)
146  {
147  case 0: // gradient
148  for (unsigned short j = 0; j < dim; ++j)
149  {
150  InputParameters params = _factory.getValidParams("EqualGradientConstraint");
151  params.set<NonlinearVariableName>("variable") =
152  lm_base + "_" + var + "_d" + axis[j];
153  params.set<VariableName>("master_variable") = var;
154  params.set<std::string>("interface") = mi_name;
155  params.set<unsigned int>("component") = j;
156  _problem->addConstraint(
157  "EqualGradientConstraint", ct_base + "_d" + axis[j], params);
158  }
159  break;
160 
161  case 1: // value
162  {
163  InputParameters params = _factory.getValidParams("EqualValueConstraint");
164  params.set<NonlinearVariableName>("variable") = lm_base + "_" + var;
165  params.set<VariableName>("master_variable") = var;
166  params.set<std::string>("interface") = mi_name;
167  _problem->addConstraint("EqualValueConstraint", ct_base, params);
168  }
169  break;
170 
171  default:
172  mooseError("Periodicity type not implemented");
173  }
174  }
175  }
176  }
177 }
std::vector< VariableName > _variables
Mesh generated from parameters with additional subdomains for mortar interfaces to enforce periodicit...
const std::string name
Definition: Setup.h:22
const unsigned int _periodicity

Member Data Documentation

◆ _periodicity

const unsigned int MortarPeriodicAction::_periodicity
protected

Definition at line 35 of file MortarPeriodicAction.h.

Referenced by act().

◆ _variables

std::vector<VariableName> MortarPeriodicAction::_variables
protected

Definition at line 32 of file MortarPeriodicAction.h.

Referenced by act().


The documentation for this class was generated from the following files: