libMesh
dirichlet_boundary.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 
19 
20 #include "libmesh/dirichlet_boundaries.h"
21 
22 #ifdef LIBMESH_ENABLE_DIRICHLET
23 
24 // Local Includes
25 #include "libmesh/composite_fem_function.h"
26 #include "libmesh/composite_function.h"
27 #include "libmesh/vector_value.h"
28 #include "libmesh/auto_ptr.h" // libmesh_make_unique
29 
30 namespace libMesh
31 {
32 
34 DirichletBoundary(const std::set<boundary_id_type> & b_in,
35  const std::vector<unsigned int> & variables_in,
36  const FunctionBase<Number> * f_in,
37  const FunctionBase<Gradient> * g_in) :
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),
43  jacobian_tolerance(0.)
44 {
46  f->init();
47  if (g)
48  g->init();
49 }
50 
51 
53 DirichletBoundary(const std::set<boundary_id_type> & b_in,
54  const std::vector<unsigned int> & variables_in,
55  const FunctionBase<Number> & f_in,
56  VariableIndexing type) :
57  b(b_in),
58  variables(variables_in),
59  f_system(nullptr),
60  jacobian_tolerance(0.)
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 }
73 
74 
76 DirichletBoundary(const std::set<boundary_id_type> & b_in,
77  const std::vector<unsigned int> & variables_in,
78  const FunctionBase<Number> & f_in,
79  const FunctionBase<Gradient> & g_in,
80  VariableIndexing type) :
81  b(b_in),
82  variables(variables_in),
83  f_system(nullptr),
84  jacobian_tolerance(0.)
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 }
105 
106 
108 DirichletBoundary(const std::set<boundary_id_type> & b_in,
109  const std::vector<unsigned int> & variables_in,
110  const System & f_sys_in,
111  const FEMFunctionBase<Number> * f_in,
112  const FEMFunctionBase<Gradient> * g_in) :
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),
118  jacobian_tolerance(0.)
119 {
121 }
122 
123 
125 DirichletBoundary(const std::set<boundary_id_type> & b_in,
126  const std::vector<unsigned int> & variables_in,
127  const System & f_sys_in,
128  const FEMFunctionBase<Number> & f_in,
129  VariableIndexing type) :
130  b(b_in),
131  variables(variables_in),
132  f_system(&f_sys_in),
133  jacobian_tolerance(0.)
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 }
144 
145 
147 DirichletBoundary(const std::set<boundary_id_type> & b_in,
148  const std::vector<unsigned int> & variables_in,
149  const System & f_sys_in,
150  const FEMFunctionBase<Number> & f_in,
151  const FEMFunctionBase<Gradient> & g_in,
152  VariableIndexing type) :
153  b(b_in),
154  variables(variables_in),
155  f_system(&f_sys_in),
156  jacobian_tolerance(0.)
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 }
174 
175 
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 }
197 
198 
200 
201 } // namespace libMesh
202 
203 #endif // LIBMESH_ENABLE_DIRICHLET
libMesh::System
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:100
libMesh::FunctionBase< Number >
libMesh::FEMFunctionBase< Number >
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
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::DirichletBoundary::f_system
const System * f_system
Definition: dirichlet_boundaries.h:182
libMesh::DirichletBoundary::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: dirichlet_boundary.C:34
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::VariableIndexing
VariableIndexing
Dirichlet functions may be indexed either by "system variable order" or "local variable order",...
Definition: dirichlet_boundaries.h:61
libMesh::DirichletBoundary::~DirichletBoundary
~DirichletBoundary()
Standard destructor.
Definition: dirichlet_boundary.C:199
libMesh::DirichletBoundary::f
std::unique_ptr< FunctionBase< Number > > f
Definition: dirichlet_boundaries.h:176
libMesh::DirichletBoundary
This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids an...
Definition: dirichlet_boundaries.h:88
libMesh::DirichletBoundary::f_fem
std::unique_ptr< FEMFunctionBase< Number > > f_fem
Definition: dirichlet_boundaries.h:179