libMesh
dirichlet_boundary.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 
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() : UniquePtr<FunctionBase<Number>>()),
41  g(g_in ? g_in->clone() : UniquePtr<FunctionBase<Gradient>>()),
42  f_fem(UniquePtr<FEMFunctionBase<Number>>()),
44  f_system(libmesh_nullptr)
45 {
46  libmesh_assert(f.get());
47  f->init();
48  if (g.get())
49  g->init();
50 }
51 
52 
54 DirichletBoundary(const std::set<boundary_id_type> & b_in,
55  const std::vector<unsigned int> & variables_in,
56  const FunctionBase<Number> & f_in,
57  VariableIndexing type) :
58  b(b_in),
59  variables(variables_in),
65 {
66  if (type == LOCAL_VARIABLE_ORDER)
67  {
70  c->attach_subfunction(f_in, variables_in);
71  f.reset(c);
72  }
73  else
74  {
75  f.reset(f_in.clone().release());
76  }
77  f->init();
78 }
79 
80 
82 DirichletBoundary(const std::set<boundary_id_type> & b_in,
83  const std::vector<unsigned int> & variables_in,
84  const FunctionBase<Number> & f_in,
85  const FunctionBase<Gradient> & g_in,
86  VariableIndexing type) :
87  b(b_in),
88  variables(variables_in),
94 {
95  if (type == LOCAL_VARIABLE_ORDER)
96  {
99  cf->attach_subfunction(f_in, variables_in);
100  f.reset(cf);
103  cg->attach_subfunction(g_in, variables_in);
104  g.reset(cg);
105  }
106  else
107  {
108  f.reset(f_in.clone().release());
109  g.reset(g_in.clone().release());
110  }
111 
112  f->init();
113  g->init();
114 }
115 
116 
118 DirichletBoundary(const std::set<boundary_id_type> & b_in,
119  const std::vector<unsigned int> & variables_in,
120  const System & f_sys_in,
121  const FEMFunctionBase<Number> * f_in,
122  const FEMFunctionBase<Gradient> * g_in) :
123  b(b_in),
124  variables(variables_in),
127  f_fem(f_in ? f_in->clone() : UniquePtr<FEMFunctionBase<Number>>()),
128  g_fem(g_in ? g_in->clone() : UniquePtr<FEMFunctionBase<Gradient>>()),
129  f_system(&f_sys_in)
130 {
131  libmesh_assert(f_fem.get());
132 }
133 
134 
136 DirichletBoundary(const std::set<boundary_id_type> & b_in,
137  const std::vector<unsigned int> & variables_in,
138  const System & f_sys_in,
139  const FEMFunctionBase<Number> & f_in,
140  VariableIndexing type) :
141  b(b_in),
142  variables(variables_in),
147  f_system(&f_sys_in)
148 {
149  if (type == LOCAL_VARIABLE_ORDER)
150  {
152  c->attach_subfunction(f_in, variables_in);
153  f_fem.reset(c);
154  }
155  else
156  {
157  f_fem.reset(f_in.clone().release());
158  }
159 }
160 
161 
163 DirichletBoundary(const std::set<boundary_id_type> & b_in,
164  const std::vector<unsigned int> & variables_in,
165  const System & f_sys_in,
166  const FEMFunctionBase<Number> & f_in,
167  const FEMFunctionBase<Gradient> & g_in,
168  VariableIndexing type) :
169  b(b_in),
170  variables(variables_in),
175  f_system(&f_sys_in)
176 {
177  if (type == LOCAL_VARIABLE_ORDER)
178  {
181  cf->attach_subfunction(f_in, variables_in);
182  f_fem.reset(cf);
185  cg->attach_subfunction(g_in, variables_in);
186  g_fem.reset(cg);
187  }
188  else
189  {
190  f_fem.reset(f_in.clone().release());
191  g_fem.reset(g_in.clone().release());
192  }
193 }
194 
195 
197 DirichletBoundary(const DirichletBoundary & dirichlet_in) :
198  b(dirichlet_in.b),
199  variables(dirichlet_in.variables),
200  f(dirichlet_in.f.get() ?
201  dirichlet_in.f->clone() : UniquePtr<FunctionBase<Number>>()),
202  g(dirichlet_in.g.get() ?
203  dirichlet_in.g->clone() : UniquePtr<FunctionBase<Gradient>>()),
204  f_fem(dirichlet_in.f_fem.get() ?
205  dirichlet_in.f_fem->clone() : UniquePtr<FEMFunctionBase<Number>>()),
206  g_fem(dirichlet_in.g_fem.get() ?
207  dirichlet_in.g_fem->clone() : UniquePtr<FEMFunctionBase<Gradient>>()),
208  f_system(dirichlet_in.f_system)
209 {
210  libmesh_assert(f.get() || f_fem.get());
211  libmesh_assert(!(f.get() && f_fem.get()));
212  libmesh_assert(!(f.get() && g_fem.get()));
213  libmesh_assert(!(f_fem.get() && g.get()));
214  libmesh_assert(!(f_fem.get() && !f_system));
215  if (f.get())
216  f->init();
217  if (g.get())
218  g->init();
219 }
220 
221 
223 
224 } // namespace libMesh
225 
226 #endif // LIBMESH_ENABLE_DIRICHLET
void attach_subfunction(const FunctionBase< Output > &f, const std::vector< unsigned int > &index_map)
Attach a new subfunction, along with a map from the indices of that subfunction to the indices of the...
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=libmesh_nullptr)
Constructor for a system-variable-order boundary using pointers-to-functors.
void attach_subfunction(const FEMFunctionBase< Output > &f, const std::vector< unsigned int > &index_map)
Attach a new subfunction, along with a map from the indices of that subfunction to the indices of the...
~DirichletBoundary()
Standard destructor.
UniquePtr< FunctionBase< Gradient > > g
const class libmesh_nullptr_t libmesh_nullptr
This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids an...
std::vector< unsigned int > variables
The libMesh namespace provides an interface to certain functionality in the library.
libmesh_assert(j)
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
FEMFunction which is a function of another function.
VariableIndexing
Dirichlet functions may be indexed either by "system variable order" or "local variable order"...
This is the base class for classes which contain information related to any physical process that mig...
Definition: system.h:76
Function which is a function of another function.
UniquePtr< FunctionBase< Number > > f
UniquePtr< FEMFunctionBase< Gradient > > g_fem
virtual UniquePtr< FunctionBase< Output > > clone() const =0
std::set< boundary_id_type > b
virtual UniquePtr< FEMFunctionBase< Output > > clone() const =0
FEMFunctionBase is a base class from which users can derive in order to define "function-like" object...
UniquePtr< FEMFunctionBase< Number > > f_fem
const Elem & get(const ElemType type_in)