libMesh
periodic_boundary_base.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 // Local Includes
19 #include "libmesh/libmesh_config.h"
20 
21 #ifdef LIBMESH_ENABLE_PERIODIC
22 
23 #include "libmesh/periodic_boundary_base.h"
24 
25 #include "libmesh/auto_ptr.h" // libmesh_make_unique
26 #include "libmesh/boundary_info.h" // BoundaryInfo::invalid_id
27 
28 namespace libMesh
29 {
30 
32  myboundary(BoundaryInfo::invalid_id),
33  pairedboundary(BoundaryInfo::invalid_id)
34 {
35 }
36 
37 
38 
40  myboundary(o.myboundary),
41  pairedboundary(o.pairedboundary),
42  variables(o.variables)
43 {
44  // Make a deep copy of _transformation_matrix, if it's not null
46  {
47  this->_transformation_matrix = libmesh_make_unique<DenseMatrix<Real>>();
49  }
50 }
51 
52 
53 
54 void PeriodicBoundaryBase::set_variable(unsigned int var)
55 {
56  variables.insert(var);
57 }
58 
59 
60 
62 {
63  variables.insert(pb.variables.begin(), pb.variables.end());
64 }
65 
66 
67 
68 bool PeriodicBoundaryBase::is_my_variable(unsigned int var_num) const
69 {
70  bool a = variables.empty() || (!variables.empty() && variables.find(var_num) != variables.end());
71  return a;
72 }
73 
74 
75 
77 {
78  return bool(_transformation_matrix);
79 }
80 
81 
82 
84 {
86  {
87  libmesh_error_msg("Transformation matrix is not defined");
88  }
89 
90  return *_transformation_matrix;
91 }
92 
93 
94 
96 {
97  // Make a deep copy of matrix
98  this->_transformation_matrix = libmesh_make_unique<DenseMatrix<Real>>();
99  *(this->_transformation_matrix) = matrix;
100 
101  // if _transformation_matrix is defined then it must be the same sie as variables.
102  libmesh_assert_equal_to(_transformation_matrix->m(), variables.size());
103  libmesh_assert_equal_to(_transformation_matrix->n(), variables.size());
104 }
105 
106 
107 
108 const std::set<unsigned int> & PeriodicBoundaryBase::get_variables() const
109 {
110  return variables;
111 }
112 
113 } // namespace libMesh
114 
115 #endif // LIBMESH_ENABLE_PERIODIC
libMesh::BoundaryInfo
The BoundaryInfo class contains information relevant to boundary conditions including storing faces,...
Definition: boundary_info.h:57
libMesh::PeriodicBoundaryBase::has_transformation_matrix
bool has_transformation_matrix() const
Definition: periodic_boundary_base.C:76
libMesh::PeriodicBoundaryBase::set_variable
void set_variable(unsigned int var)
Definition: periodic_boundary_base.C:54
libMesh::PeriodicBoundaryBase
The base class for defining periodic boundaries.
Definition: periodic_boundary_base.h:48
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::DenseMatrix< Real >
libMesh::PeriodicBoundaryBase::variables
std::set< unsigned int > variables
Set of variables for this periodic boundary, empty means all variables possible.
Definition: periodic_boundary_base.h:134
libMesh::PeriodicBoundaryBase::is_my_variable
bool is_my_variable(unsigned int var_num) const
Definition: periodic_boundary_base.C:68
libMesh::PeriodicBoundaryBase::get_transformation_matrix
const DenseMatrix< Real > & get_transformation_matrix() const
Get the transformation matrix, if it is defined.
Definition: periodic_boundary_base.C:83
libMesh::PeriodicBoundaryBase::merge
void merge(const PeriodicBoundaryBase &pb)
Definition: periodic_boundary_base.C:61
libMesh::PeriodicBoundaryBase::get_variables
const std::set< unsigned int > & get_variables() const
Get the set of variables for this periodic boundary condition.
Definition: periodic_boundary_base.C:108
libMesh::PeriodicBoundaryBase::PeriodicBoundaryBase
PeriodicBoundaryBase()
Constructor.
Definition: periodic_boundary_base.C:31
libMesh::PeriodicBoundaryBase::_transformation_matrix
std::unique_ptr< DenseMatrix< Real > > _transformation_matrix
A DenseMatrix that defines the mapping of variables on this boundary and the counterpart boundary.
Definition: periodic_boundary_base.h:146
libMesh::PeriodicBoundaryBase::set_transformation_matrix
void set_transformation_matrix(const DenseMatrix< Real > &matrix)
Set the transformation matrix.
Definition: periodic_boundary_base.C:95