FunctionPeriodicBoundary.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14
15 // MOOSE includes
17 #include "FEProblem.h"
18 #include "Function.h"
19 #include "MooseMesh.h"
20
21 // A mutex we can acquire to prevent simultaneous ParsedFunction
22 // evaluation on multiple threads. ParsedFunction evaluation is
25
27  std::vector<std::string> fn_names)
28  : _dim(fn_names.size()),
29  _tr_x(&feproblem.getFunction(fn_names[0])),
30  _tr_y(_dim > 1 ? &feproblem.getFunction(fn_names[1]) : NULL),
31  _tr_z(_dim > 2 ? &feproblem.getFunction(fn_names[2]) : NULL)
32 {
33
34  // Make certain the the dimensions agree
35  if (_dim != feproblem.mesh().dimension())
36  mooseError("Transform function has to have the same dimension as the problem being solved.");
37
38  // Initialize the functions (i.e., call thier initialSetup methods)
39  init();
40 }
41
43  : PeriodicBoundaryBase(o), _dim(o._dim), _tr_x(o._tr_x), _tr_y(o._tr_y), _tr_z(o._tr_z)
44 {
45  // Initialize the functions (i.e., call thier initialSetup methods)
46  init();
47 }
48
49 Point
51 {
52  // Force thread-safe evaluation of what could be ParsedFunctions.
54
55  Real t = 0.;
56  Point p;
57  switch (_dim)
58  {
59  case 1:
60  return Point(_tr_x->value(t, pt));
61
62  case 2:
63  mooseAssert(_tr_y, "Must provide a function to map y in 2D.");
64  return Point(_tr_x->value(t, pt), _tr_y->value(t, pt));
65
66  case 3:
67  mooseAssert(_tr_y, "Must provide a function to map y in 2D.");
68  mooseAssert(_tr_z, "Must provide a function to map z in 3D.");
69  return Point(_tr_x->value(t, pt), _tr_y->value(t, pt), _tr_z->value(t, pt));
70
71  default:
72  mooseError("Unsupported dimension");
73  break;
74  }
75
76  return pt;
77 }
78
79 std::unique_ptr<PeriodicBoundaryBase>
80 FunctionPeriodicBoundary::clone(TransformationType t) const
81 {
82  if (t == INVERSE)
83  mooseError("No way to automatically clone() an inverse FunctionPeriodicBoundary object");
84
85  return libmesh_make_unique<FunctionPeriodicBoundary>(*this);
86 }
87
88 void
90 {
91  switch (_dim)
92  {
93  case 1:
95  break;
96  case 2:
99  break;
100  case 3:
101  _tr_x->initialSetup();
102  _tr_y->initialSetup();
103  _tr_z->initialSetup();
104  break;
105  default:
106  mooseError("Unsupported dimension");
107  break;
108  }
109 }
virtual Real value(Real t, const Point &p)
Override this to evaluate the scalar function at point (t,x,y,z), by default this returns zero...
Definition: Function.C:43
virtual unsigned int dimension() const
Returns MeshBase::mesh_dimsension(), (not MeshBase::spatial_dimension()!) of the underlying libMesh m...
Definition: MooseMesh.C:1945
Periodic boundary for calculation periodic BC on domains where the translation is given by functions...
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
virtual Point get_corresponding_pos(const Point &pt) const override
Get the translation based on point &#39;pt&#39;.
Function * _tr_y
Pointer to Function for y-component of the boundary.
Function * _tr_z
Pointer to Function for z-component of the boundary.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Function * _tr_x
Pointer to Function for x-component of the boundary.
virtual std::unique_ptr< PeriodicBoundaryBase > clone(TransformationType t) const override
Required interface, this class must be able to clone itself.
void init()
An initialization method to make certain that intialSetup() of a function prior to value() ...