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 (const std::set< boundary_id_type > &b_in, const 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 (const std::set< boundary_id_type > &b_in, const 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 (const std::set< boundary_id_type > &b_in, const 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 (const std::set< boundary_id_type > &b_in, const 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 (const std::set< boundary_id_type > &b_in, const 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 (const std::set< boundary_id_type > &b_in, const 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 constructor. More...
 
 ~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/7]

libMesh::DirichletBoundary::DirichletBoundary ( const std::set< boundary_id_type > &  b_in,
const 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 34 of file dirichlet_boundary.C.

37  :
38  b(b_in),
39  variables(variables_in),
40  f(f_in ? f_in->clone() : nullptr),
41  g(g_in ? g_in->clone() : nullptr),
42  f_system(nullptr),
44 {
46  f->init();
47  if (g)
48  g->init();
49 }

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

◆ DirichletBoundary() [2/7]

libMesh::DirichletBoundary::DirichletBoundary ( const std::set< boundary_id_type > &  b_in,
const 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 53 of file dirichlet_boundary.C.

56  :
57  b(b_in),
58  variables(variables_in),
59  f_system(nullptr),
61 {
62  if (type == LOCAL_VARIABLE_ORDER)
63  {
64  auto c = libmesh_make_unique<CompositeFunction<Number>>();
65  c->attach_subfunction(f_in, variables_in);
66  f = std::move(c);
67  }
68  else
69  f = f_in.clone();
70 
71  f->init();
72 }

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

◆ DirichletBoundary() [3/7]

libMesh::DirichletBoundary::DirichletBoundary ( const std::set< boundary_id_type > &  b_in,
const 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 76 of file dirichlet_boundary.C.

80  :
81  b(b_in),
82  variables(variables_in),
83  f_system(nullptr),
85 {
86  if (type == LOCAL_VARIABLE_ORDER)
87  {
88  auto cf = libmesh_make_unique<CompositeFunction<Number>>();
89  cf->attach_subfunction(f_in, variables_in);
90  f = std::move(cf);
91 
92  auto cg = libmesh_make_unique<CompositeFunction<Gradient>>();
93  cg->attach_subfunction(g_in, variables_in);
94  g = std::move(cg);
95  }
96  else
97  {
98  f = f_in.clone();
99  g = g_in.clone();
100  }
101 
102  f->init();
103  g->init();
104 }

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

◆ DirichletBoundary() [4/7]

libMesh::DirichletBoundary::DirichletBoundary ( const std::set< boundary_id_type > &  b_in,
const 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 108 of file dirichlet_boundary.C.

112  :
113  b(b_in),
114  variables(variables_in),
115  f_fem(f_in ? f_in->clone() : nullptr),
116  g_fem(g_in ? g_in->clone() : nullptr),
117  f_system(&f_sys_in),
119 {
121 }

References f_fem, and libMesh::libmesh_assert().

◆ DirichletBoundary() [5/7]

libMesh::DirichletBoundary::DirichletBoundary ( const std::set< boundary_id_type > &  b_in,
const 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 125 of file dirichlet_boundary.C.

129  :
130  b(b_in),
131  variables(variables_in),
132  f_system(&f_sys_in),
134 {
135  if (type == LOCAL_VARIABLE_ORDER)
136  {
137  auto c = libmesh_make_unique<CompositeFEMFunction<Number>>();
138  c->attach_subfunction(f_in, variables_in);
139  f_fem = std::move(c);
140  }
141  else
142  f_fem = f_in.clone();
143 }

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

◆ DirichletBoundary() [6/7]

libMesh::DirichletBoundary::DirichletBoundary ( const std::set< boundary_id_type > &  b_in,
const 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 147 of file dirichlet_boundary.C.

152  :
153  b(b_in),
154  variables(variables_in),
155  f_system(&f_sys_in),
157 {
158  if (type == LOCAL_VARIABLE_ORDER)
159  {
160  auto cf = libmesh_make_unique<CompositeFEMFunction<Number>>();
161  cf->attach_subfunction(f_in, variables_in);
162  f_fem = std::move(cf);
163 
164  auto cg = libmesh_make_unique<CompositeFEMFunction<Gradient>>();
165  cg->attach_subfunction(g_in, variables_in);
166  g_fem = std::move(cg);
167  }
168  else
169  {
170  f_fem = f_in.clone();
171  g_fem = g_in.clone();
172  }
173 }

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

◆ DirichletBoundary() [7/7]

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

Copy constructor.

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

Definition at line 177 of file dirichlet_boundary.C.

177  :
178  b(d_in.b),
179  variables(d_in.variables),
180  f(d_in.f ? d_in.f->clone() : nullptr),
181  g(d_in.g ? d_in.g->clone() : nullptr),
182  f_fem(d_in.f_fem ? d_in.f_fem->clone() : nullptr),
183  g_fem(d_in.g_fem ? d_in.g_fem->clone() : nullptr),
184  f_system(d_in.f_system),
185  jacobian_tolerance(d_in.jacobian_tolerance)
186 {
187  libmesh_assert(f || f_fem);
188  libmesh_assert(!(f && f_fem));
189  libmesh_assert(!(f && g_fem));
190  libmesh_assert(!(f_fem && g));
191  libmesh_assert(!(f_fem && !f_system));
192  if (f)
193  f->init();
194  if (g)
195  g->init();
196 }

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

◆ ~DirichletBoundary()

libMesh::DirichletBoundary::~DirichletBoundary ( )

Standard destructor.

Definition at line 199 of file dirichlet_boundary.C.

199 {}

Member Data Documentation

◆ b

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

◆ f

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

Definition at line 176 of file dirichlet_boundaries.h.

Referenced by DirichletBoundary().

◆ f_fem

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

Definition at line 179 of file dirichlet_boundaries.h.

Referenced by DirichletBoundary().

◆ f_system

const System* libMesh::DirichletBoundary::f_system

Definition at line 182 of file dirichlet_boundaries.h.

Referenced by DirichletBoundary().

◆ g

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

Definition at line 177 of file dirichlet_boundaries.h.

Referenced by DirichletBoundary().

◆ g_fem

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

Definition at line 180 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 196 of file dirichlet_boundaries.h.

◆ variables

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

The documentation for this class was generated from the following files:
libMesh::DirichletBoundary::g
std::unique_ptr< FunctionBase< Gradient > > g
Definition: dirichlet_boundaries.h:177
libMesh::FEMFunctionBase::clone
virtual std::unique_ptr< FEMFunctionBase< Output > > clone() const =0
libMesh::FunctionBase::clone
virtual std::unique_ptr< FunctionBase< Output > > clone() const =0
libMesh::DirichletBoundary::f_system
const System * f_system
Definition: dirichlet_boundaries.h:182
libMesh::DirichletBoundary::b
std::set< boundary_id_type > b
Definition: dirichlet_boundaries.h:173
libMesh::libmesh_assert
libmesh_assert(ctx)
libMesh::LOCAL_VARIABLE_ORDER
Definition: dirichlet_boundaries.h:62
libMesh::DirichletBoundary::g_fem
std::unique_ptr< FEMFunctionBase< Gradient > > g_fem
Definition: dirichlet_boundaries.h:180
libMesh::DirichletBoundary::jacobian_tolerance
Real jacobian_tolerance
Defaults to zero, but can be set to a custom small negative value to try and avoid spurious zero (or ...
Definition: dirichlet_boundaries.h:196
libMesh::DirichletBoundary::f
std::unique_ptr< FunctionBase< Number > > f
Definition: dirichlet_boundaries.h:176
libMesh::DirichletBoundary::variables
std::vector< unsigned int > variables
Definition: dirichlet_boundaries.h:174
libMesh::DirichletBoundary::f_fem
std::unique_ptr< FEMFunctionBase< Number > > f_fem
Definition: dirichlet_boundaries.h:179