libMesh
Public Member Functions | Public Attributes | List of all members
libMesh::DirichletBoundary Class Reference

This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids and system variable ids. More...

#include <dirichlet_boundaries.h>

Public Member Functions

 DirichletBoundary (std::set< boundary_id_type > b_in, std::vector< unsigned int > variables_in, const FunctionBase< Number > *f_in, const FunctionBase< Gradient > *g_in=nullptr)
 Constructor for a system-variable-order boundary using pointers-to-functors. More...
 
 DirichletBoundary (std::set< boundary_id_type > b_in, std::vector< unsigned int > variables_in, const FunctionBase< Number > &f_in, VariableIndexing type=SYSTEM_VARIABLE_ORDER)
 Constructor for a boundary from reference-to-functor. More...
 
 DirichletBoundary (std::set< boundary_id_type > b_in, std::vector< unsigned int > variables_in, const FunctionBase< Number > &f_in, const FunctionBase< Gradient > &g_in, VariableIndexing type=SYSTEM_VARIABLE_ORDER)
 Constructor for a system-variable-order boundary from references-to-functors. More...
 
 DirichletBoundary (std::set< boundary_id_type > b_in, std::vector< unsigned int > variables_in, const System &f_sys_in, const FEMFunctionBase< Number > *f_in, const FEMFunctionBase< Gradient > *g_in=nullptr)
 Constructor for a system-variable-order boundary from pointers-to-fem-functors. More...
 
 DirichletBoundary (std::set< boundary_id_type > b_in, std::vector< unsigned int > variables_in, const System &f_sys_in, const FEMFunctionBase< Number > &f_in, VariableIndexing type=SYSTEM_VARIABLE_ORDER)
 Constructor for a system-variable-order boundary from reference-to-fem-functor. More...
 
 DirichletBoundary (std::set< boundary_id_type > b_in, std::vector< unsigned int > variables_in, const System &f_sys_in, const FEMFunctionBase< Number > &f_in, const FEMFunctionBase< Gradient > &g_in, VariableIndexing type=SYSTEM_VARIABLE_ORDER)
 Constructor for a system-variable-order boundary from references-to-fem-functors. More...
 
 DirichletBoundary (const DirichletBoundary &dirichlet_in)
 Copy assignment/constructor. More...
 
DirichletBoundaryoperator= (const DirichletBoundary &)
 
 DirichletBoundary (DirichletBoundary &&)=default
 This class is default move-assignable and move-constructible. More...
 
DirichletBoundaryoperator= (DirichletBoundary &&)=default
 
 ~DirichletBoundary ()
 Standard destructor. More...
 

Public Attributes

std::set< boundary_id_typeb
 
std::vector< unsigned intvariables
 
std::unique_ptr< FunctionBase< Number > > f
 
std::unique_ptr< FunctionBase< Gradient > > g
 
std::unique_ptr< FEMFunctionBase< Number > > f_fem
 
std::unique_ptr< FEMFunctionBase< Gradient > > g_fem
 
const Systemf_system
 
Real jacobian_tolerance
 Defaults to zero, but can be set to a custom small negative value to try and avoid spurious zero (or negative) Jacobian values when applying Dirichlet constraints. More...
 

Detailed Description

This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids and system variable ids.

Dirichlet values must be supplied as the input function "f"; when using some specialized elements, gradient values must be supplied via the input function "g".

Dirichlet functions may be subclasses of FunctionBase or FEMFunctionBase; in the latter case the user must also supply a reference to the System on which the FEMFunctionBase will be evaluated.

Dirichlet functions are allowed to return NaN; if this is encountered, then the degree of freedom values in a patch around the location of the returned NaN will be left unconstrained. E.g. a NaN on a boundary edge in 3D would leave that edge and the two adjoining face interiors unconstrained, but would still permit the other edge and node DoFs around those faces to be constrained.

Author
Roy Stogner
Date
2012 Class for specifying Dirichlet boundary conditions as constraints.

Definition at line 88 of file dirichlet_boundaries.h.

Constructor & Destructor Documentation

◆ DirichletBoundary() [1/8]

libMesh::DirichletBoundary::DirichletBoundary ( std::set< boundary_id_type b_in,
std::vector< unsigned int variables_in,
const FunctionBase< Number > *  f_in,
const FunctionBase< Gradient > *  g_in = nullptr 
)

Constructor for a system-variable-order boundary using pointers-to-functors.

Definition at line 36 of file dirichlet_boundary.C.

References f, g, and libMesh::libmesh_assert().

39  :
40  b(std::move(b_in)),
41  variables(std::move(variables_in)),
42  f(f_in ? f_in->clone() : nullptr),
43  g(g_in ? g_in->clone() : nullptr),
44  f_system(nullptr),
46 {
48  f->init();
49  if (g)
50  g->init();
51 }
std::unique_ptr< FunctionBase< Number > > f
Real jacobian_tolerance
Defaults to zero, but can be set to a custom small negative value to try and avoid spurious zero (or ...
std::vector< unsigned int > variables
libmesh_assert(ctx)
std::unique_ptr< FunctionBase< Gradient > > g
virtual std::unique_ptr< FunctionBase< Output > > clone() const =0
std::set< boundary_id_type > b

◆ DirichletBoundary() [2/8]

libMesh::DirichletBoundary::DirichletBoundary ( std::set< boundary_id_type b_in,
std::vector< unsigned int variables_in,
const FunctionBase< Number > &  f_in,
VariableIndexing  type = SYSTEM_VARIABLE_ORDER 
)

Constructor for a boundary from reference-to-functor.

Defaults to system variable indexing for backwards compatibility, but most users will prefer local indexing.

Definition at line 55 of file dirichlet_boundary.C.

References libMesh::FunctionBase< Output >::clone(), f, libMesh::LOCAL_VARIABLE_ORDER, and variables.

58  :
59  b(std::move(b_in)),
60  variables(std::move(variables_in)),
61  f_system(nullptr),
63 {
64  if (type == LOCAL_VARIABLE_ORDER)
65  {
66  auto c = std::make_unique<CompositeFunction<Number>>();
67  c->attach_subfunction(f_in, variables);
68  f = std::move(c);
69  }
70  else
71  f = f_in.clone();
72 
73  f->init();
74 }
std::unique_ptr< FunctionBase< Number > > f
Real jacobian_tolerance
Defaults to zero, but can be set to a custom small negative value to try and avoid spurious zero (or ...
std::vector< unsigned int > variables
virtual std::unique_ptr< FunctionBase< Output > > clone() const =0
std::set< boundary_id_type > b

◆ DirichletBoundary() [3/8]

libMesh::DirichletBoundary::DirichletBoundary ( std::set< boundary_id_type b_in,
std::vector< unsigned int variables_in,
const FunctionBase< Number > &  f_in,
const FunctionBase< Gradient > &  g_in,
VariableIndexing  type = SYSTEM_VARIABLE_ORDER 
)

Constructor for a system-variable-order boundary from references-to-functors.

Defaults to system variable indexing for backwards compatibility, but most users will prefer local indexing.

Definition at line 78 of file dirichlet_boundary.C.

References libMesh::FunctionBase< Output >::clone(), f, g, libMesh::LOCAL_VARIABLE_ORDER, and variables.

82  :
83  b(std::move(b_in)),
84  variables(std::move(variables_in)),
85  f_system(nullptr),
87 {
88  if (type == LOCAL_VARIABLE_ORDER)
89  {
90  auto cf = std::make_unique<CompositeFunction<Number>>();
91  cf->attach_subfunction(f_in, variables);
92  f = std::move(cf);
93 
94  auto cg = std::make_unique<CompositeFunction<Gradient>>();
95  cg->attach_subfunction(g_in, variables);
96  g = std::move(cg);
97  }
98  else
99  {
100  f = f_in.clone();
101  g = g_in.clone();
102  }
103 
104  f->init();
105  g->init();
106 }
std::unique_ptr< FunctionBase< Number > > f
Real jacobian_tolerance
Defaults to zero, but can be set to a custom small negative value to try and avoid spurious zero (or ...
std::vector< unsigned int > variables
std::unique_ptr< FunctionBase< Gradient > > g
virtual std::unique_ptr< FunctionBase< Output > > clone() const =0
std::set< boundary_id_type > b

◆ DirichletBoundary() [4/8]

libMesh::DirichletBoundary::DirichletBoundary ( std::set< boundary_id_type b_in,
std::vector< unsigned int variables_in,
const System f_sys_in,
const FEMFunctionBase< Number > *  f_in,
const FEMFunctionBase< Gradient > *  g_in = nullptr 
)

Constructor for a system-variable-order boundary from pointers-to-fem-functors.

Definition at line 110 of file dirichlet_boundary.C.

References f_fem, and libMesh::libmesh_assert().

114  :
115  b(std::move(b_in)),
116  variables(std::move(variables_in)),
117  f_fem(f_in ? f_in->clone() : nullptr),
118  g_fem(g_in ? g_in->clone() : nullptr),
119  f_system(&f_sys_in),
121 {
123 }
std::unique_ptr< FEMFunctionBase< Gradient > > g_fem
Real jacobian_tolerance
Defaults to zero, but can be set to a custom small negative value to try and avoid spurious zero (or ...
std::vector< unsigned int > variables
std::unique_ptr< FEMFunctionBase< Number > > f_fem
libmesh_assert(ctx)
std::set< boundary_id_type > b
virtual std::unique_ptr< FEMFunctionBase< Output > > clone() const =0

◆ DirichletBoundary() [5/8]

libMesh::DirichletBoundary::DirichletBoundary ( std::set< boundary_id_type b_in,
std::vector< unsigned int variables_in,
const System f_sys_in,
const FEMFunctionBase< Number > &  f_in,
VariableIndexing  type = SYSTEM_VARIABLE_ORDER 
)

Constructor for a system-variable-order boundary from reference-to-fem-functor.

Defaults to system variable indexing for backwards compatibility, but most users will prefer local indexing.

Definition at line 127 of file dirichlet_boundary.C.

References libMesh::FEMFunctionBase< Output >::clone(), f_fem, libMesh::LOCAL_VARIABLE_ORDER, and variables.

131  :
132  b(std::move(b_in)),
133  variables(std::move(variables_in)),
134  f_system(&f_sys_in),
136 {
137  if (type == LOCAL_VARIABLE_ORDER)
138  {
139  auto c = std::make_unique<CompositeFEMFunction<Number>>();
140  c->attach_subfunction(f_in, variables);
141  f_fem = std::move(c);
142  }
143  else
144  f_fem = f_in.clone();
145 }
Real jacobian_tolerance
Defaults to zero, but can be set to a custom small negative value to try and avoid spurious zero (or ...
std::vector< unsigned int > variables
std::unique_ptr< FEMFunctionBase< Number > > f_fem
std::set< boundary_id_type > b
virtual std::unique_ptr< FEMFunctionBase< Output > > clone() const =0

◆ DirichletBoundary() [6/8]

libMesh::DirichletBoundary::DirichletBoundary ( std::set< boundary_id_type b_in,
std::vector< unsigned int variables_in,
const System f_sys_in,
const FEMFunctionBase< Number > &  f_in,
const FEMFunctionBase< Gradient > &  g_in,
VariableIndexing  type = SYSTEM_VARIABLE_ORDER 
)

Constructor for a system-variable-order boundary from references-to-fem-functors.

Defaults to system variable indexing for backwards compatibility, but most users will prefer local indexing.

Definition at line 149 of file dirichlet_boundary.C.

References libMesh::FEMFunctionBase< Output >::clone(), f_fem, g_fem, libMesh::LOCAL_VARIABLE_ORDER, and variables.

154  :
155  b(std::move(b_in)),
156  variables(std::move(variables_in)),
157  f_system(&f_sys_in),
159 {
160  if (type == LOCAL_VARIABLE_ORDER)
161  {
162  auto cf = std::make_unique<CompositeFEMFunction<Number>>();
163  cf->attach_subfunction(f_in, variables);
164  f_fem = std::move(cf);
165 
166  auto cg = std::make_unique<CompositeFEMFunction<Gradient>>();
167  cg->attach_subfunction(g_in, variables);
168  g_fem = std::move(cg);
169  }
170  else
171  {
172  f_fem = f_in.clone();
173  g_fem = g_in.clone();
174  }
175 }
std::unique_ptr< FEMFunctionBase< Gradient > > g_fem
Real jacobian_tolerance
Defaults to zero, but can be set to a custom small negative value to try and avoid spurious zero (or ...
std::vector< unsigned int > variables
std::unique_ptr< FEMFunctionBase< Number > > f_fem
std::set< boundary_id_type > b
virtual std::unique_ptr< FEMFunctionBase< Output > > clone() const =0

◆ DirichletBoundary() [7/8]

libMesh::DirichletBoundary::DirichletBoundary ( const DirichletBoundary dirichlet_in)

Copy assignment/constructor.

Deep copies (clones) functors; shallow copies any System reference

Definition at line 179 of file dirichlet_boundary.C.

References f, f_fem, f_system, g, g_fem, and libMesh::libmesh_assert().

179  :
180  b(d_in.b),
181  variables(d_in.variables),
182  f(d_in.f ? d_in.f->clone() : nullptr),
183  g(d_in.g ? d_in.g->clone() : nullptr),
184  f_fem(d_in.f_fem ? d_in.f_fem->clone() : nullptr),
185  g_fem(d_in.g_fem ? d_in.g_fem->clone() : nullptr),
186  f_system(d_in.f_system),
187  jacobian_tolerance(d_in.jacobian_tolerance)
188 {
189  libmesh_assert(f || f_fem);
190  libmesh_assert(!(f && f_fem));
191  libmesh_assert(!(f && g_fem));
192  libmesh_assert(!(f_fem && g));
193  libmesh_assert(!(f_fem && !f_system));
194  if (f)
195  f->init();
196  if (g)
197  g->init();
198 }
std::unique_ptr< FEMFunctionBase< Gradient > > g_fem
std::unique_ptr< FunctionBase< Number > > f
Real jacobian_tolerance
Defaults to zero, but can be set to a custom small negative value to try and avoid spurious zero (or ...
std::vector< unsigned int > variables
std::unique_ptr< FEMFunctionBase< Number > > f_fem
libmesh_assert(ctx)
std::unique_ptr< FunctionBase< Gradient > > g
std::set< boundary_id_type > b

◆ DirichletBoundary() [8/8]

libMesh::DirichletBoundary::DirichletBoundary ( DirichletBoundary &&  )
default

This class is default move-assignable and move-constructible.

◆ ~DirichletBoundary()

libMesh::DirichletBoundary::~DirichletBoundary ( )
default

Standard destructor.

Member Function Documentation

◆ operator=() [1/2]

DirichletBoundary & libMesh::DirichletBoundary::operator= ( const DirichletBoundary rhs)

Definition at line 201 of file dirichlet_boundary.C.

202 {
203  // Implementation in terms of the copy constructor to avoid code duplication.
204  DirichletBoundary tmp(rhs);
205  std::swap(tmp, *this); // class must be "MoveAssignable" and "MoveConstructible" for std::swap to work.
206  return *this;
207 }
DirichletBoundary(std::set< boundary_id_type > b_in, std::vector< unsigned int > variables_in, const FunctionBase< Number > *f_in, const FunctionBase< Gradient > *g_in=nullptr)
Constructor for a system-variable-order boundary using pointers-to-functors.

◆ operator=() [2/2]

DirichletBoundary& libMesh::DirichletBoundary::operator= ( DirichletBoundary &&  )
default

Member Data Documentation

◆ b

std::set<boundary_id_type> libMesh::DirichletBoundary::b

◆ f

std::unique_ptr<FunctionBase<Number> > libMesh::DirichletBoundary::f

Definition at line 183 of file dirichlet_boundaries.h.

Referenced by DirichletBoundary().

◆ f_fem

std::unique_ptr<FEMFunctionBase<Number> > libMesh::DirichletBoundary::f_fem

Definition at line 186 of file dirichlet_boundaries.h.

Referenced by DirichletBoundary().

◆ f_system

const System* libMesh::DirichletBoundary::f_system

Definition at line 189 of file dirichlet_boundaries.h.

Referenced by DirichletBoundary().

◆ g

std::unique_ptr<FunctionBase<Gradient> > libMesh::DirichletBoundary::g

Definition at line 184 of file dirichlet_boundaries.h.

Referenced by DirichletBoundary().

◆ g_fem

std::unique_ptr<FEMFunctionBase<Gradient> > libMesh::DirichletBoundary::g_fem

Definition at line 187 of file dirichlet_boundaries.h.

Referenced by DirichletBoundary().

◆ jacobian_tolerance

Real libMesh::DirichletBoundary::jacobian_tolerance

Defaults to zero, but can be set to a custom small negative value to try and avoid spurious zero (or negative) Jacobian values when applying Dirichlet constraints.

This can be useful in various different situations, for example: 1.) When specifying DirichletBCs on poorly-shaped elements. 2.) When degenerate Hexahedra are used in place of Prisms for convenience. 3.) On elements (e.g. Pyramids) which always have a zero Jacobian at the "apex" node. In theory there's nothing preventing someone from specifying DirichletBCs in such cases; setting this tolerance to a small negative value makes this possible in practice.

Definition at line 203 of file dirichlet_boundaries.h.

◆ variables

std::vector<unsigned int> libMesh::DirichletBoundary::variables

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