libMesh
Public Types | Public Member Functions | Public Attributes | Protected Attributes | Private Attributes | List of all members
AzimuthalPeriodicBoundary Class Reference
Inheritance diagram for AzimuthalPeriodicBoundary:
[legend]

Public Types

enum  TransformationType { FORWARD =0, INVERSE =1 }
 

Public Member Functions

 AzimuthalPeriodicBoundary (Point center, Point axis, Real angle)
 Constructor. More...
 
 AzimuthalPeriodicBoundary (const AzimuthalPeriodicBoundary &o, TransformationType t=FORWARD)
 Copy constructor, with option for the copy to represent an inverse transformation. More...
 
virtual ~AzimuthalPeriodicBoundary ()=default
 Destructor. More...
 
void set_up_rotation_matrix ()
 Computes and stores the rotation matrix for this transformation, and then calls the base class API to store it. More...
 
virtual Point get_corresponding_pos (const Point &pt) const override
 This function should be overridden by derived classes to define how one finds corresponding nodes on the periodic boundary pair. More...
 
virtual std::unique_ptr< PeriodicBoundaryBaseclone (TransformationType t=FORWARD) const override
 If we want the DofMap to be able to make copies of references and store them in the underlying map, this class must be clone'able, i.e. More...
 
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
 Get the transformation matrix, if it is defined. More...
 
void set_transformation_matrix (const DenseMatrix< Real > &matrix)
 Set the transformation matrix. More...
 
const std::set< unsigned int > & get_variables () const
 Get the set of variables for this periodic boundary condition. More...
 

Public Attributes

boundary_id_type myboundary
 The boundary ID of this boundary and its counterpart. More...
 
boundary_id_type pairedboundary
 

Protected Attributes

std::set< unsigned intvariables
 Set of variables for this periodic boundary, empty means all variables possible. More...
 
std::unique_ptr< DenseMatrix< Real > > _transformation_matrix
 A DenseMatrix that defines the mapping of variables on this boundary and the counterpart boundary. More...
 

Private Attributes

Point _center
 
Point _axis
 
Real _theta
 
RealTensorValue _R
 

Detailed Description

Definition at line 78 of file systems_of_equations_ex9.C.

Member Enumeration Documentation

◆ TransformationType

Constructor & Destructor Documentation

◆ AzimuthalPeriodicBoundary() [1/2]

AzimuthalPeriodicBoundary::AzimuthalPeriodicBoundary ( Point  center,
Point  axis,
Real  angle 
)
inline

Constructor.

Definition at line 84 of file systems_of_equations_ex9.C.

88  :
90  _center(center),
91  _axis(axis),
92  _theta(angle)
93  {
94  set_variable(0);
95  set_variable(1);
96  set_variable(2);
98  }
void set_variable(unsigned int var)
void set_up_rotation_matrix()
Computes and stores the rotation matrix for this transformation, and then calls the base class API to...

◆ AzimuthalPeriodicBoundary() [2/2]

AzimuthalPeriodicBoundary::AzimuthalPeriodicBoundary ( const AzimuthalPeriodicBoundary o,
TransformationType  t = FORWARD 
)
inline

Copy constructor, with option for the copy to represent an inverse transformation.

Definition at line 103 of file systems_of_equations_ex9.C.

104  :
106  _center(o._center),
107  _axis(o._axis),
108  _theta(o._theta)
109  {
110  if (t == INVERSE)
111  {
112  std::swap(myboundary, pairedboundary);
113  _theta *= -1.0;
114  }
115 
116  set_variable(0);
117  set_variable(1);
118  set_variable(2);
120  }
void set_variable(unsigned int var)
boundary_id_type myboundary
The boundary ID of this boundary and its counterpart.
void set_up_rotation_matrix()
Computes and stores the rotation matrix for this transformation, and then calls the base class API to...

◆ ~AzimuthalPeriodicBoundary()

virtual AzimuthalPeriodicBoundary::~AzimuthalPeriodicBoundary ( )
virtualdefault

Destructor.

Member Function Documentation

◆ clone()

virtual std::unique_ptr<PeriodicBoundaryBase> AzimuthalPeriodicBoundary::clone ( TransformationType  t = FORWARD) const
inlineoverridevirtual

If we want the DofMap to be able to make copies of references and store them in the underlying map, this class must be clone'able, i.e.

have a kind of virtual construction mechanism.

Implements libMesh::PeriodicBoundaryBase.

Definition at line 176 of file systems_of_equations_ex9.C.

177  {
178  return std::make_unique<AzimuthalPeriodicBoundary>(*this, t);
179  }

◆ get_corresponding_pos()

virtual Point AzimuthalPeriodicBoundary::get_corresponding_pos ( const Point pt) const
inlineoverridevirtual

This function should be overridden by derived classes to define how one finds corresponding nodes on the periodic boundary pair.

Implements libMesh::PeriodicBoundaryBase.

Definition at line 163 of file systems_of_equations_ex9.C.

164  {
165  // Note that since _theta defines the angle from "paired boundary" to
166  // "my boundary", and we want the inverse of that here, we multiply
167  // by the transpose of the transformation matrix below.
168  return _R.left_multiply(pt - _center) + _center;
169  }
TypeVector< typename CompareTypes< T, T2 >::supertype > left_multiply(const TypeVector< T2 > &p) const
Left-multiply this tensor by a vector, i.e.
Definition: type_tensor.h:1211

◆ get_transformation_matrix()

const DenseMatrix< Real > & libMesh::PeriodicBoundaryBase::get_transformation_matrix ( ) const
inherited

Get the transformation matrix, if it is defined.

Throw an error if it is not defined.

Definition at line 86 of file periodic_boundary_base.C.

References libMesh::PeriodicBoundaryBase::_transformation_matrix, and libMesh::PeriodicBoundaryBase::has_transformation_matrix().

Referenced by libMesh::FEGenericBase< FEOutputType< T >::type >::compute_periodic_constraints().

87 {
88  libmesh_error_msg_if(!has_transformation_matrix(),
89  "Transformation matrix is not defined");
90 
91  return *_transformation_matrix;
92 }
std::unique_ptr< DenseMatrix< Real > > _transformation_matrix
A DenseMatrix that defines the mapping of variables on this boundary and the counterpart boundary...

◆ get_variables()

const std::set< unsigned int > & libMesh::PeriodicBoundaryBase::get_variables ( ) const
inherited

Get the set of variables for this periodic boundary condition.

Definition at line 109 of file periodic_boundary_base.C.

References libMesh::PeriodicBoundaryBase::variables.

Referenced by libMesh::FEGenericBase< FEOutputType< T >::type >::compute_periodic_constraints().

110 {
111  return variables;
112 }
std::set< unsigned int > variables
Set of variables for this periodic boundary, empty means all variables possible.

◆ has_transformation_matrix()

bool libMesh::PeriodicBoundaryBase::has_transformation_matrix ( ) const
inherited
Returns
true if _transformation_matrix is not null.

Definition at line 79 of file periodic_boundary_base.C.

References libMesh::PeriodicBoundaryBase::_transformation_matrix.

Referenced by libMesh::FEGenericBase< FEOutputType< T >::type >::compute_periodic_constraints(), and libMesh::PeriodicBoundaryBase::get_transformation_matrix().

80 {
81  return bool(_transformation_matrix);
82 }
std::unique_ptr< DenseMatrix< Real > > _transformation_matrix
A DenseMatrix that defines the mapping of variables on this boundary and the counterpart boundary...

◆ is_my_variable()

bool libMesh::PeriodicBoundaryBase::is_my_variable ( unsigned int  var_num) const
inherited

Definition at line 71 of file periodic_boundary_base.C.

References libMesh::PeriodicBoundaryBase::variables.

Referenced by libMesh::FEGenericBase< FEOutputType< T >::type >::compute_periodic_constraints().

72 {
73  bool a = variables.empty() || (!variables.empty() && variables.find(var_num) != variables.end());
74  return a;
75 }
std::set< unsigned int > variables
Set of variables for this periodic boundary, empty means all variables possible.

◆ merge()

void libMesh::PeriodicBoundaryBase::merge ( const PeriodicBoundaryBase pb)
inherited

Definition at line 64 of file periodic_boundary_base.C.

References libMesh::PeriodicBoundaryBase::variables.

Referenced by libMesh::DofMap::add_periodic_boundary().

65 {
66  variables.insert(pb.variables.begin(), pb.variables.end());
67 }
std::set< unsigned int > variables
Set of variables for this periodic boundary, empty means all variables possible.

◆ set_transformation_matrix()

void libMesh::PeriodicBoundaryBase::set_transformation_matrix ( const DenseMatrix< Real > &  matrix)
inherited

Set the transformation matrix.

When calling this method we require the following conditions: 1) matrix is square with size that matches this->variables.size() 2) the list of variables in this->variables set must all have the same FE type Both of these conditions are asserted in DBG mode.

Definition at line 96 of file periodic_boundary_base.C.

References libMesh::PeriodicBoundaryBase::_transformation_matrix, and libMesh::PeriodicBoundaryBase::variables.

97 {
98  // Make a deep copy of matrix
99  this->_transformation_matrix = std::make_unique<DenseMatrix<Real>>();
100  *(this->_transformation_matrix) = matrix;
101 
102  // if _transformation_matrix is defined then it must be the same sie as variables.
103  libmesh_assert_equal_to(_transformation_matrix->m(), variables.size());
104  libmesh_assert_equal_to(_transformation_matrix->n(), variables.size());
105 }
std::set< unsigned int > variables
Set of variables for this periodic boundary, empty means all variables possible.
std::unique_ptr< DenseMatrix< Real > > _transformation_matrix
A DenseMatrix that defines the mapping of variables on this boundary and the counterpart boundary...

◆ set_up_rotation_matrix()

void AzimuthalPeriodicBoundary::set_up_rotation_matrix ( )
inline

Computes and stores the rotation matrix for this transformation, and then calls the base class API to store it.

This should only be done once, since the direction and angle do not change once the class is constructed.

Definition at line 133 of file systems_of_equations_ex9.C.

References libMesh::Real, and libMesh::TypeVector< T >::unit().

134  {
135  // Formula for rotation matrix about an axis is given on wikipedia:
136  // en.wikipedia.org/wiki/Rotation_matrix
137  // We rotate by angle theta about the axis defined by u, which is a
138  // unit vector in the direction of _axis.
139  // Note: this example already requires LIBMESH_DIM==3 so we don't
140  // explicitly check for that here.
141  Point u = _axis.unit();
142  Real u_x = u(0);
143  Real u_y = u(1);
144  Real u_z = u(2);
145  Real cost = std::cos(_theta);
146  Real sint = std::sin(_theta);
148  (cost + u_x*u_x*(1.0 - cost), u_x*u_y*(1.0 - cost) - u_z*sint, u_x*u_z*(1.0 - cost) + u_y*sint,
149  u_y*u_x*(1.0 - cost) + u_z*sint, cost + u_y*u_y*(1.0 - cost), u_y*u_z*(1.0 - cost) - u_x*sint,
150  u_z*u_x*(1.0 - cost) - u_y*sint, u_z*u_y*(1.0 - cost) + u_x*sint, cost + u_z*u_z*(1.0 - cost));
151 
152  // For generality, PeriodicBoundaryBase::set_transformation_matrix() takes an
153  // (n_vars * n_vars) DenseMatrix which we construct on the fly.
155  (DenseMatrix<Real> (3, 3, {_R(0,0), _R(0,1), _R(0,2), _R(1,0), _R(1,1), _R(1,2), _R(2,0), _R(2,1), _R(2,2)}));
156  }
TensorValue< Real > RealTensorValue
Useful typedefs to allow transparent switching between Real and Complex data types.
TypeVector< T > unit() const
Definition: type_vector.h:1120
void set_transformation_matrix(const DenseMatrix< Real > &matrix)
Set the transformation matrix.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39

◆ set_variable()

void libMesh::PeriodicBoundaryBase::set_variable ( unsigned int  var)
inherited

Definition at line 57 of file periodic_boundary_base.C.

References libMesh::PeriodicBoundaryBase::variables.

58 {
59  variables.insert(var);
60 }
std::set< unsigned int > variables
Set of variables for this periodic boundary, empty means all variables possible.

Member Data Documentation

◆ _axis

Point AzimuthalPeriodicBoundary::_axis
private

Definition at line 187 of file systems_of_equations_ex9.C.

◆ _center

Point AzimuthalPeriodicBoundary::_center
private

Definition at line 186 of file systems_of_equations_ex9.C.

◆ _R

RealTensorValue AzimuthalPeriodicBoundary::_R
private

Definition at line 189 of file systems_of_equations_ex9.C.

◆ _theta

Real AzimuthalPeriodicBoundary::_theta
private

Definition at line 188 of file systems_of_equations_ex9.C.

◆ _transformation_matrix

std::unique_ptr<DenseMatrix<Real> > libMesh::PeriodicBoundaryBase::_transformation_matrix
protectedinherited

A DenseMatrix that defines the mapping of variables on this boundary and the counterpart boundary.

This is necessary for periodic-boundaries with vector-valued quantities (e.g. velocity or displacement) on a sector of a circular domain, for example, since in that case we must map each variable to a corresponding linear combination of all the variables. We store the DenseMatrix via a unique_ptr, and an uninitialized pointer is treated as equivalent to the identity matrix.

Definition at line 146 of file periodic_boundary_base.h.

Referenced by libMesh::PeriodicBoundaryBase::get_transformation_matrix(), libMesh::PeriodicBoundaryBase::has_transformation_matrix(), libMesh::PeriodicBoundaryBase::PeriodicBoundaryBase(), and libMesh::PeriodicBoundaryBase::set_transformation_matrix().

◆ myboundary

boundary_id_type libMesh::PeriodicBoundaryBase::myboundary
inherited

The boundary ID of this boundary and its counterpart.

Definition at line 58 of file periodic_boundary_base.h.

Referenced by libMesh::DofMap::add_periodic_boundary(), Biharmonic::JR::JR(), main(), libMesh::PeriodicBoundary::PeriodicBoundary(), and PeriodicBCTest::testPeriodicBC().

◆ pairedboundary

boundary_id_type libMesh::PeriodicBoundaryBase::pairedboundary
inherited

◆ variables

std::set<unsigned int> libMesh::PeriodicBoundaryBase::variables
protectedinherited

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