BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
raviart_thomas_0_vector_space.hpp
1 // Copyright (C) 2011-2012 by the BEM++ Authors
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 // THE SOFTWARE.
20 
21 #ifndef bempp_raviart_thomas_0_vector_space_hpp
22 #define bempp_raviart_thomas_0_vector_space_hpp
23 
24 #include "../common/common.hpp"
25 
26 #include "space.hpp"
27 
28 #include "dof_assignment_mode.hpp"
29 
30 #include "../grid/grid_segment.hpp"
31 #include "../grid/grid_view.hpp"
32 #include "../common/types.hpp"
33 #include "../fiber/raviart_thomas_0_shapeset.hpp"
34 
35 #include <boost/scoped_ptr.hpp>
36 #include <map>
37 #include <memory>
38 #include <tbb/mutex.h>
39 
40 namespace Bempp
41 {
42 
44 class GridView;
53 template <typename BasisFunctionType>
54 class RaviartThomas0VectorSpace : public Space<BasisFunctionType>
55 {
57 public:
58  typedef typename Space<BasisFunctionType>::CoordinateType CoordinateType;
59  typedef typename Space<BasisFunctionType>::ComplexType ComplexType;
64 
78  const shared_ptr<const Grid>& grid,
79  bool putDofsOnBoundaries = false);
80 
104  const shared_ptr<const Grid>& grid,
105  const GridSegment& segment,
106  bool putDofsOnBoundaries = false,
107  int dofMode = EDGE_ON_SEGMENT);
108  virtual ~RaviartThomas0VectorSpace();
109 
110  virtual shared_ptr<const Space<BasisFunctionType> > discontinuousSpace(
111  const shared_ptr<const Space<BasisFunctionType> >& self) const;
112  virtual bool isDiscontinuous() const;
113 
115 
116  virtual int domainDimension() const;
117  virtual int codomainDimension() const;
118 
119  virtual bool isBarycentric() const {
120  return false;
121  }
122 
123  virtual bool spaceIsCompatible(const Space<BasisFunctionType>& other) const;
124 
125  virtual SpaceIdentifier spaceIdentifier() const {
126  return RAVIART_THOMAS_0_VECTOR;
127  }
128 
134  virtual ElementVariant elementVariant(const Entity<0>& element) const;
135  virtual void setElementVariant(const Entity<0>& element,
136  ElementVariant variant);
137 
139  const Entity<0>& element) const;
140 
141  virtual size_t globalDofCount() const;
142  virtual size_t flatLocalDofCount() const;
143  virtual void getGlobalDofs(const Entity<0>& element,
144  std::vector<GlobalDofIndex>& dofs,
145  std::vector<BasisFunctionType>& dofWeights) const;
146  virtual void global2localDofs(
147  const std::vector<GlobalDofIndex>& globalDofs,
148  std::vector<std::vector<LocalDof> >& localDofs,
149  std::vector<std::vector<BasisFunctionType> >& localDofWeights) const;
150  virtual void flatLocal2localDofs(
151  const std::vector<FlatLocalDofIndex>& flatLocalDofs,
152  std::vector<LocalDof>& localDofs) const;
153 
154  virtual void getGlobalDofPositions(
155  std::vector<Point3D<CoordinateType> >& positions) const;
156  virtual void getFlatLocalDofPositions(
157  std::vector<Point3D<CoordinateType> >& positions) const;
158 
159  virtual void getGlobalDofBoundingBoxes(
160  std::vector<BoundingBox<CoordinateType> >& bboxes) const;
161  virtual void getFlatLocalDofBoundingBoxes(
162  std::vector<BoundingBox<CoordinateType> >& bboxes) const;
163 
164  virtual void getGlobalDofNormals(
165  std::vector<Point3D<CoordinateType> >& normals) const;
166  virtual void getFlatLocalDofNormals(
167  std::vector<Point3D<CoordinateType> >& normals) const;
168 
169  virtual void dumpClusterIds(
170  const char* fileName,
171  const std::vector<unsigned int>& clusterIdsOfGlobalDofs) const;
172  virtual void dumpClusterIdsEx(
173  const char* fileName,
174  const std::vector<unsigned int>& clusterIdsOfGlobalDofs,
175  DofType dofType) const;
176 
177 private:
178  void initialize();
179  void assignDofsImpl();
180 
181 private:
183  struct Impl;
184  boost::scoped_ptr<Impl> m_impl;
185  GridSegment m_segment;
186  bool m_putDofsOnBoundaries;
187  int m_dofMode;
188  std::auto_ptr<GridView> m_view;
190  std::vector<std::vector<GlobalDofIndex> > m_local2globalDofs;
191  std::vector<std::vector<BasisFunctionType> > m_local2globalDofWeights;
192  std::vector<std::vector<LocalDof> > m_global2localDofs;
193  std::vector<LocalDof> m_flatLocal2localDofs;
194  std::vector<BoundingBox<CoordinateType> > m_globalDofBoundingBoxes;
195  mutable shared_ptr<Space<BasisFunctionType> > m_discontinuousSpace;
196  mutable tbb::mutex m_discontinuousSpaceMutex;
198 };
199 
200 } // namespace Bempp
201 
202 #endif
Shapeset composed of the lowest-order Raviart-Thomas functions.
Definition: raviart_thomas_0_shapeset.hpp:60
virtual void getGlobalDofBoundingBoxes(std::vector< BoundingBox< CoordinateType > > &bboxes) const
Retrieve bounding boxes of global degrees of freedom.
Definition: raviart_thomas_0_vector_space.cpp:499
virtual shared_ptr< const Space< BasisFunctionType > > discontinuousSpace(const shared_ptr< const Space< BasisFunctionType > > &self) const
Return a shared pointer to an appropriate counterpart to this space, with basis functions extending o...
Definition: raviart_thomas_0_vector_space.cpp:123
virtual size_t flatLocalDofCount() const
Total number of local degrees of freedom on all elements.
Definition: raviart_thomas_0_vector_space.cpp:430
Fiber::ScalarTraits< BasisFunctionType >::ComplexType ComplexType
Equivalent to std::complex&lt;CoordinateType&gt;.
Definition: space.hpp:93
virtual int codomainDimension() const
Dimension of the codomain of the functions.
Definition: raviart_thomas_0_vector_space.cpp:158
virtual void getGlobalDofs(const Entity< 0 > &element, std::vector< GlobalDofIndex > &dofs, std::vector< BasisFunctionType > &dofWeights) const
Map local degrees of freedom residing on an element to global degrees of freedom. ...
Definition: raviart_thomas_0_vector_space.cpp:436
virtual bool spaceIsCompatible(const Space< BasisFunctionType > &other) const
Return true if other is compatible to this space, i.e. the global dofs of the two spaces agree with e...
Definition: raviart_thomas_0_vector_space.cpp:93
Function space.
Definition: assembled_potential_operator.hpp:35
RaviartThomas0VectorSpace(const shared_ptr< const Grid > &grid, bool putDofsOnBoundaries=false)
Constructor.
Definition: raviart_thomas_0_vector_space.cpp:65
Bounding box with a reference point.
Definition: bounding_box.hpp:13
virtual size_t globalDofCount() const
Number of global degrees of freedom.
Definition: raviart_thomas_0_vector_space.cpp:424
Fiber::ScalarTraits< BasisFunctionType >::RealType CoordinateType
Type used to represent coordinates.
Definition: space.hpp:91
Collection of shape functions defined on a reference element.
Definition: default_local_assembler_for_operators_on_surfaces_utilities.hpp:34
virtual const CollectionOfShapesetTransformations & basisFunctionValue() const
Transformation mapping shape functions to basis functions.
Definition: raviart_thomas_0_vector_space.cpp:146
virtual void flatLocal2localDofs(const std::vector< FlatLocalDofIndex > &flatLocalDofs, std::vector< LocalDof > &localDofs) const
Map flat indices of local degrees of freedom to local degrees of freedom.
Definition: raviart_thomas_0_vector_space.cpp:469
shared_ptr< const Grid > grid() const
Shared pointer to the grid on which the functions from this space are defined.
Definition: space.hpp:183
virtual void getFlatLocalDofPositions(std::vector< Point3D< CoordinateType > > &positions) const
Retrieve the reference positions of local degrees of freedom ordered by their flat index...
Definition: raviart_thomas_0_vector_space.cpp:488
virtual void getGlobalDofPositions(std::vector< Point3D< CoordinateType > > &positions) const
Retrieve the reference positions of global degrees of freedom.
Definition: raviart_thomas_0_vector_space.cpp:479
Segment of a grid.
Definition: grid_segment.hpp:46
virtual void dumpClusterIds(const char *fileName, const std::vector< unsigned int > &clusterIdsOfGlobalDofs) const
Write a VTK file showing the distribution of global or flat local degrees of freedom into clusters...
Definition: raviart_thomas_0_vector_space.cpp:641
virtual ElementVariant elementVariant(const Entity< 0 > &element) const
Return the variant of element element.
Definition: raviart_thomas_0_vector_space.cpp:182
virtual void getFlatLocalDofBoundingBoxes(std::vector< BoundingBox< CoordinateType > > &bboxes) const
Retrieve bounding boxes of local degrees of freedom ordered by their flat index.
Definition: raviart_thomas_0_vector_space.cpp:506
Collection of shape function transformations.
Definition: collection_of_basis_transformations.hpp:36
virtual bool isDiscontinuous() const
Return true if each basis function of this space extends over only a single element, false otherwise.
Definition: raviart_thomas_0_vector_space.cpp:138
virtual void dumpClusterIdsEx(const char *fileName, const std::vector< unsigned int > &clusterIdsOfGlobalDofs, DofType dofType) const
Write a VTK file showing the distribution of global or flat local degrees of freedom into clusters...
Definition: raviart_thomas_0_vector_space.cpp:649
Space spanned by the lowest order Raviart-Thomas functions.
Definition: raviart_thomas_0_vector_space.hpp:54
virtual void getFlatLocalDofNormals(std::vector< Point3D< CoordinateType > > &normals) const
Retrieve the unit vectors normal to the grid at the positions of global degrees of freedom...
Definition: raviart_thomas_0_vector_space.cpp:601
virtual bool isBarycentric() const
Return true if space is based on a barycentric refinement.
Definition: raviart_thomas_0_vector_space.hpp:119
Abstract wrapper of an entity of codimension 0.
Definition: entity.hpp:81
virtual void getGlobalDofNormals(std::vector< Point3D< CoordinateType > > &normals) const
Retrieve the unit vectors normal to the grid at the positions of global degrees of freedom...
Definition: raviart_thomas_0_vector_space.cpp:558
virtual int domainDimension() const
Dimension of the grid on which functions from this space are defined.
Definition: raviart_thomas_0_vector_space.cpp:152
virtual SpaceIdentifier spaceIdentifier() const
Return the identifier of the space.
Definition: raviart_thomas_0_vector_space.hpp:125
virtual void setElementVariant(const Entity< 0 > &element, ElementVariant variant)
Set the variant of element element to variant.
Definition: raviart_thomas_0_vector_space.cpp:197
virtual const Fiber::Shapeset< BasisFunctionType > & shapeset(const Entity< 0 > &element) const
Reference to the shapeset attached to the specified element.
Definition: raviart_thomas_0_vector_space.cpp:165