https://mooseframework.inl.gov
Public Types | Public Member Functions | Public Attributes | Protected Attributes | Static Private Member Functions | Private Attributes | List of all members
FunctionPeriodicBoundary Class Reference

Periodic boundary for calculation periodic BC on domains where the translation is given by Function objects. More...

#include <FunctionPeriodicBoundary.h>

Inheritance diagram for FunctionPeriodicBoundary:
[legend]

Public Types

enum  TransformationType
 

Public Member Functions

 FunctionPeriodicBoundary (FEProblemBase &subproblem, const std::vector< std::string > &fn_names, const std::vector< std::string > &inv_fn_names)
 Initialize the periodic with the functions and inverse functions, one for each dimension needed. More...
 
 FunctionPeriodicBoundary (const FunctionPeriodicBoundary &o, TransformationType t=FORWARD)
 Copy constructor for creating the periodic boundary and inverse periodic boundary. More...
 
virtual libMesh::Point get_corresponding_pos (const libMesh::Point &pt) const override
 Get the translation based on point 'pt'. More...
 
virtual std::unique_ptr< libMesh::PeriodicBoundaryBaseclone (TransformationType t) const override
 
void set_variable (unsigned int var)
 
void merge (const PeriodicBoundaryBase &pb)
 
bool is_my_variable (unsigned int var_num) const
 
bool has_transformation_matrix () const
 
const DenseMatrix< Real > & get_transformation_matrix () const
 
void set_transformation_matrix (const DenseMatrix< Real > &matrix)
 
const std::set< unsigned int > & get_variables () const
 

Public Attributes

 FORWARD
 
 INVERSE
 
boundary_id_type myboundary
 
boundary_id_type pairedboundary
 

Protected Attributes

std::set< unsigned intvariables
 
std::unique_ptr< DenseMatrix< Real > > _transformation_matrix
 

Static Private Member Functions

static std::array< const Function *, 3 > getFunctions (FEProblemBase &problem, const std::vector< std::string > &names)
 

Private Attributes

const unsigned int _dim
 The dimension of the problem (says which of _tr and _inv_tr are active) More...
 
const std::array< const Function *, 3 > _tr
 Pointers to translation functions in each dimension. More...
 
const std::array< const Function *, 3 > _inv_tr
 Pointers to inverse translation functions in each dimension. More...
 

Detailed Description

Periodic boundary for calculation periodic BC on domains where the translation is given by Function objects.

Definition at line 27 of file FunctionPeriodicBoundary.h.

Constructor & Destructor Documentation

◆ FunctionPeriodicBoundary() [1/2]

FunctionPeriodicBoundary::FunctionPeriodicBoundary ( FEProblemBase subproblem,
const std::vector< std::string > &  fn_names,
const std::vector< std::string > &  inv_fn_names 
)

Initialize the periodic with the functions and inverse functions, one for each dimension needed.

Definition at line 21 of file FunctionPeriodicBoundary.C.

25  _dim(fn_names.size()),
26  _tr(getFunctions(feproblem, fn_names)),
27  _inv_tr(getFunctions(feproblem, inv_fn_names))
28 {
29  mooseAssert(fn_names.size() == inv_fn_names.size(), "Size mismatch");
30 
31  // Make certain the the dimensions agree
32  if (_dim != feproblem.mesh().dimension())
33  mooseError("Transform function has to have the same dimension as the problem being solved.");
34 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
const std::array< const Function *, 3 > _tr
Pointers to translation functions in each dimension.
const unsigned int _dim
The dimension of the problem (says which of _tr and _inv_tr are active)
static std::array< const Function *, 3 > getFunctions(FEProblemBase &problem, const std::vector< std::string > &names)
const std::array< const Function *, 3 > _inv_tr
Pointers to inverse translation functions in each dimension.

◆ FunctionPeriodicBoundary() [2/2]

FunctionPeriodicBoundary::FunctionPeriodicBoundary ( const FunctionPeriodicBoundary o,
TransformationType  t = FORWARD 
)

Copy constructor for creating the periodic boundary and inverse periodic boundary.

Parameters
o- Periodic boundary being copied
t- Transformation direction

Definition at line 36 of file FunctionPeriodicBoundary.C.

39  _dim(o._dim),
40  _tr(t == INVERSE ? o._inv_tr : o._tr),
41  _inv_tr(t == INVERSE ? o._tr : o._inv_tr)
42 {
43  if (t == INVERSE)
45 }
const std::array< const Function *, 3 > _tr
Pointers to translation functions in each dimension.
void swap(std::vector< T > &data, const std::size_t idx0, const std::size_t idx1, const libMesh::Parallel::Communicator &comm)
Swap function for serial or distributed vector of data.
Definition: Shuffle.h:495
boundary_id_type pairedboundary
const unsigned int _dim
The dimension of the problem (says which of _tr and _inv_tr are active)
const std::array< const Function *, 3 > _inv_tr
Pointers to inverse translation functions in each dimension.

Member Function Documentation

◆ clone()

std::unique_ptr< libMesh::PeriodicBoundaryBase > FunctionPeriodicBoundary::clone ( TransformationType  t) const
overridevirtual

Implements libMesh::PeriodicBoundaryBase.

Definition at line 63 of file FunctionPeriodicBoundary.C.

64 {
65  return std::make_unique<FunctionPeriodicBoundary>(*this, t);
66 }

◆ get_corresponding_pos()

Point FunctionPeriodicBoundary::get_corresponding_pos ( const libMesh::Point pt) const
overridevirtual

Get the translation based on point 'pt'.

Parameters
pt- point on the 'source' boundary
Returns
point on the paired boundary

Implements libMesh::PeriodicBoundaryBase.

Definition at line 48 of file FunctionPeriodicBoundary.C.

49 {
50  // Force thread-safe evaluation of what could be ParsedFunctions.
51  Threads::spin_mutex::scoped_lock lock(parsed_function_mutex);
52 
53  Point p;
54  for (const auto i : make_range(_dim))
55  {
56  mooseAssert(_tr[i], "Function not provided");
57  p(i) = _tr[i]->value(0.0, pt);
58  }
59  return p;
60 }
const std::array< const Function *, 3 > _tr
Pointers to translation functions in each dimension.
const unsigned int _dim
The dimension of the problem (says which of _tr and _inv_tr are active)
Threads::spin_mutex parsed_function_mutex
IntRange< T > make_range(T beg, T end)

◆ getFunctions()

std::array< const Function *, 3 > FunctionPeriodicBoundary::getFunctions ( FEProblemBase problem,
const std::vector< std::string > &  names 
)
staticprivate

Definition at line 69 of file FunctionPeriodicBoundary.C.

71 {
72  std::array<const Function *, 3> functions;
73  for (const auto i : index_range(functions))
74  if (names.size() > i)
75  {
76  functions[i] = &problem.getFunction(names[i]);
77  const_cast<Function *>(functions[i])->initialSetup();
78  }
79  return functions;
80 }
Base class for function objects.
Definition: Function.h:29
virtual Function & getFunction(const std::string &name, const THREAD_ID tid=0)
auto index_range(const T &sizable)

Member Data Documentation

◆ _dim

const unsigned int FunctionPeriodicBoundary::_dim
private

The dimension of the problem (says which of _tr and _inv_tr are active)

Definition at line 60 of file FunctionPeriodicBoundary.h.

Referenced by FunctionPeriodicBoundary(), and get_corresponding_pos().

◆ _inv_tr

const std::array<const Function *, 3> FunctionPeriodicBoundary::_inv_tr
private

Pointers to inverse translation functions in each dimension.

Definition at line 65 of file FunctionPeriodicBoundary.h.

◆ _tr

const std::array<const Function *, 3> FunctionPeriodicBoundary::_tr
private

Pointers to translation functions in each dimension.

Definition at line 63 of file FunctionPeriodicBoundary.h.

Referenced by get_corresponding_pos().


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