31 #ifndef __DIRICHLET_BC_H 32 #define __DIRICHLET_BC_H 38 #include <boost/multi_array.hpp> 40 #include <unordered_map> 42 #include <dolfin/common/types.h> 43 #include <dolfin/common/Hierarchical.h> 44 #include <dolfin/common/MPI.h> 45 #include <dolfin/common/Variable.h> 50 class GenericFunction;
56 template<
typename T>
class MeshFunction;
130 typedef std::unordered_map<std::size_t, double>
Map;
144 DirichletBC(std::shared_ptr<const FunctionSpace> V,
145 std::shared_ptr<const GenericFunction> g,
146 std::shared_ptr<const SubDomain> sub_domain,
147 std::string
method=
"topological",
148 bool check_midpoint=
true);
163 DirichletBC(std::shared_ptr<const FunctionSpace> V,
164 std::shared_ptr<const GenericFunction> g,
166 std::size_t sub_domain,
167 std::string
method=
"topological");
181 DirichletBC(std::shared_ptr<const FunctionSpace> V,
182 std::shared_ptr<const GenericFunction> g,
183 std::size_t sub_domain,
184 std::string
method=
"topological");
198 DirichletBC(std::shared_ptr<const FunctionSpace> V,
199 std::shared_ptr<const GenericFunction> g,
200 const std::vector<std::size_t>&
markers,
201 std::string
method=
"topological");
273 void gather(Map& boundary_values)
const;
293 double diag_val=0)
const;
300 const std::vector<std::size_t>&
markers()
const;
307 {
return _function_space; }
313 std::shared_ptr<const GenericFunction>
value()
const;
325 void set_value(std::shared_ptr<const GenericFunction> g);
335 std::string
method()
const;
342 p.
add(
"use_ident",
true);
343 p.
add(
"check_dofmap_range",
true);
359 void init_facets(
const MPI_Comm mpi_comm)
const;
363 init_from_sub_domain(std::shared_ptr<const SubDomain> sub_domain)
const;
367 std::size_t sub_domain)
const;
370 void init_from_mesh(std::size_t sub_domain)
const;
374 void compute_bc(Map& boundary_values, LocalData& data,
375 std::string method)
const;
378 void compute_bc_topological(Map& boundary_values,
379 LocalData& data)
const;
382 void compute_bc_geometric(Map& boundary_values,
383 LocalData& data)
const;
386 void compute_bc_pointwise(Map& boundary_values,
387 LocalData& data)
const;
390 bool on_facet(
const double* coordinates,
const Facet& facet)
const;
396 std::size_t dim)
const;
399 std::shared_ptr<const FunctionSpace> _function_space;
402 std::shared_ptr<const GenericFunction> _g;
408 static const std::set<std::string> methods;
413 std::shared_ptr<const SubDomain> _user_sub_domain;
418 mutable std::size_t _num_dofs;
421 mutable std::vector<std::size_t> _facets;
425 mutable std::map<std::size_t, std::vector<std::size_t>>
429 std::shared_ptr<const MeshFunction<std::size_t>> _user_mesh_function;
432 std::size_t _user_sub_domain_marker;
435 bool _check_midpoint;
446 std::vector<double> w;
449 std::vector<std::size_t> facet_dofs;
452 boost::multi_array<double, 2> coordinates;
Common base class for DOLFIN variables.
Definition: Variable.h:35
static Parameters default_parameters()
Definition: DirichletBC.h:339
Definition: Hierarchical.h:43
~DirichletBC()
Destructor.
Definition: DirichletBC.cpp:123
void add(std::string key)
Definition: Parameters.h:128
Definition: FunctionSpace.h:53
std::shared_ptr< const GenericFunction > value() const
Definition: DirichletBC.cpp:397
std::shared_ptr< const FunctionSpace > function_space() const
Definition: DirichletBC.h:306
std::unordered_map< std::size_t, double > Map
map type used by DirichletBC
Definition: DirichletBC.h:130
const DirichletBC & operator=(const DirichletBC &bc)
Definition: DirichletBC.cpp:128
DirichletBC(std::shared_ptr< const FunctionSpace > V, std::shared_ptr< const GenericFunction > g, std::shared_ptr< const SubDomain > sub_domain, std::string method="topological", bool check_midpoint=true)
Definition: DirichletBC.cpp:68
const std::vector< std::size_t > & markers() const
Definition: DirichletBC.cpp:392
Definition: Parameters.h:94
void get_boundary_values(Map &boundary_values) const
Definition: DirichletBC.cpp:272
std::shared_ptr< const SubDomain > user_sub_domain() const
Definition: DirichletBC.cpp:402
void set_value(std::shared_ptr< const GenericFunction > g)
Definition: DirichletBC.cpp:433
This class defines a common interface for matrices.
Definition: GenericMatrix.h:46
Interface for setting (strong) Dirichlet boundary conditions.
Definition: DirichletBC.h:124
void zero(GenericMatrix &A) const
Definition: DirichletBC.cpp:282
void apply(GenericMatrix &A) const
Definition: DirichletBC.cpp:148
void homogenize()
Set value to 0.0.
Definition: DirichletBC.cpp:407
std::string method() const
Definition: DirichletBC.cpp:438
A Facet is a MeshEntity of topological codimension 1.
Definition: Facet.h:39
void gather(Map &boundary_values) const
Definition: DirichletBC.cpp:175
This class defines a common interface for vectors.
Definition: GenericVector.h:47
void zero_columns(GenericMatrix &A, GenericVector &b, double diag_val=0) const
Definition: DirichletBC.cpp:310