dirichlet_boundary.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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 
21 
22 #ifdef LIBMESH_ENABLE_DIRICHLET
23 
24 // Local Includes
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 {
44  libmesh_assert(f);
45  f->init();
46  if (g)
47  g->init();
48 }
49 
50 
52 DirichletBoundary(const std::set<boundary_id_type> & b_in,
53  const std::vector<unsigned int> & variables_in,
54  const FunctionBase<Number> & f_in,
55  VariableIndexing type) :
56  b(b_in),
57  variables(variables_in),
58  f_system(nullptr)
59 {
60  if (type == LOCAL_VARIABLE_ORDER)
61  {
62  auto c = libmesh_make_unique<CompositeFunction<Number>>();
63  c->attach_subfunction(f_in, variables_in);
64  f = std::move(c);
65  }
66  else
67  f = f_in.clone();
68 
69  f->init();
70 }
71 
72 
74 DirichletBoundary(const std::set<boundary_id_type> & b_in,
75  const std::vector<unsigned int> & variables_in,
76  const FunctionBase<Number> & f_in,
77  const FunctionBase<Gradient> & g_in,
78  VariableIndexing type) :
79  b(b_in),
80  variables(variables_in),
81  f_system(nullptr)
82 {
83  if (type == LOCAL_VARIABLE_ORDER)
84  {
85  auto cf = libmesh_make_unique<CompositeFunction<Number>>();
86  cf->attach_subfunction(f_in, variables_in);
87  f = std::move(cf);
88 
89  auto cg = libmesh_make_unique<CompositeFunction<Gradient>>();
90  cg->attach_subfunction(g_in, variables_in);
91  g = std::move(cg);
92  }
93  else
94  {
95  f = f_in.clone();
96  g = g_in.clone();
97  }
98 
99  f->init();
100  g->init();
101 }
102 
103 
105 DirichletBoundary(const std::set<boundary_id_type> & b_in,
106  const std::vector<unsigned int> & variables_in,
107  const System & f_sys_in,
108  const FEMFunctionBase<Number> * f_in,
109  const FEMFunctionBase<Gradient> * g_in) :
110  b(b_in),
111  variables(variables_in),
112  f_fem(f_in ? f_in->clone() : nullptr),
113  g_fem(g_in ? g_in->clone() : nullptr),
114  f_system(&f_sys_in)
115 {
116  libmesh_assert(f_fem);
117 }
118 
119 
121 DirichletBoundary(const std::set<boundary_id_type> & b_in,
122  const std::vector<unsigned int> & variables_in,
123  const System & f_sys_in,
124  const FEMFunctionBase<Number> & f_in,
125  VariableIndexing type) :
126  b(b_in),
127  variables(variables_in),
128  f_system(&f_sys_in)
129 {
130  if (type == LOCAL_VARIABLE_ORDER)
131  {
132  auto c = libmesh_make_unique<CompositeFEMFunction<Number>>();
133  c->attach_subfunction(f_in, variables_in);
134  f_fem = std::move(c);
135  }
136  else
137  f_fem = f_in.clone();
138 }
139 
140 
142 DirichletBoundary(const std::set<boundary_id_type> & b_in,
143  const std::vector<unsigned int> & variables_in,
144  const System & f_sys_in,
145  const FEMFunctionBase<Number> & f_in,
146  const FEMFunctionBase<Gradient> & g_in,
147  VariableIndexing type) :
148  b(b_in),
149  variables(variables_in),
150  f_system(&f_sys_in)
151 {
152  if (type == LOCAL_VARIABLE_ORDER)
153  {
154  auto cf = libmesh_make_unique<CompositeFEMFunction<Number>>();
155  cf->attach_subfunction(f_in, variables_in);
156  f_fem = std::move(cf);
157 
158  auto cg = libmesh_make_unique<CompositeFEMFunction<Gradient>>();
159  cg->attach_subfunction(g_in, variables_in);
160  g_fem = std::move(cg);
161  }
162  else
163  {
164  f_fem = f_in.clone();
165  g_fem = g_in.clone();
166  }
167 }
168 
169 
172  b(d_in.b),
173  variables(d_in.variables),
174  f(d_in.f ? d_in.f->clone() : nullptr),
175  g(d_in.g ? d_in.g->clone() : nullptr),
176  f_fem(d_in.f_fem ? d_in.f_fem->clone() : nullptr),
177  g_fem(d_in.g_fem ? d_in.g_fem->clone() : nullptr),
178  f_system(d_in.f_system)
179 {
180  libmesh_assert(f || f_fem);
181  libmesh_assert(!(f && f_fem));
182  libmesh_assert(!(f && g_fem));
183  libmesh_assert(!(f_fem && g));
184  libmesh_assert(!(f_fem && !f_system));
185  if (f)
186  f->init();
187  if (g)
188  g->init();
189 }
190 
191 
193 
194 } // namespace libMesh
195 
196 #endif // LIBMESH_ENABLE_DIRICHLET
std::unique_ptr< FEMFunctionBase< Gradient > > g_fem
std::unique_ptr< FunctionBase< Number > > f
Class for specifying Dirichlet boundary conditions as constraints.
std::unique_ptr< FEMFunctionBase< Number > > f_fem
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:92
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)
std::unique_ptr< FunctionBase< Gradient > > g
virtual std::unique_ptr< FunctionBase< Output > > clone() const =0
virtual std::unique_ptr< FEMFunctionBase< Output > > clone() const =0