BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
piecewise_constant_scalar_space_barycentric.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 piecewise_constant_scalar_space_barycentric_hpp
22 #define piecewise_constant_scalar_space_barycentric_hpp
23 
24 #include "../common/common.hpp"
25 
26 #include "../grid/grid_view.hpp"
27 #include "scalar_space.hpp"
28 #include "../common/types.hpp"
29 #include "../fiber/constant_scalar_shapeset.hpp"
30 #include "../grid/grid_segment.hpp"
31 
32 #include <tbb/mutex.h>
33 
34 
35 #include <map>
36 #include <memory>
37 
38 namespace Bempp
39 {
40 
42 class GridView;
47 template <typename BasisFunctionType>
48 class PiecewiseConstantScalarSpaceBarycentric : public ScalarSpace<BasisFunctionType>
49 {
50 public:
51  typedef typename ScalarSpace<BasisFunctionType>::CoordinateType CoordinateType;
52 
60  explicit PiecewiseConstantScalarSpaceBarycentric(const shared_ptr<const Grid>& grid);
61 
69  PiecewiseConstantScalarSpaceBarycentric(const shared_ptr<const Grid>& grid,
70  const GridSegment& segment);
71 
72  virtual shared_ptr<const Space<BasisFunctionType> > discontinuousSpace(
73  const shared_ptr<const Space<BasisFunctionType> >& self) const;
74  virtual bool isDiscontinuous() const;
75 
76  virtual bool isBarycentric() const {
77  return true;
78  }
79 
80  shared_ptr<const Space<BasisFunctionType> > barycentricSpace(
81  const shared_ptr<const Space<BasisFunctionType> >& self) const;
82 
83 
84 
85  virtual int domainDimension() const;
86  virtual int codomainDimension() const;
87 
94  virtual ElementVariant elementVariant(const Entity<0>& element) const;
95  virtual void setElementVariant(const Entity<0>& element,
96  ElementVariant variant);
97 
99  const Entity<0>& element) const;
100 
101  virtual bool spaceIsCompatible(const Space<BasisFunctionType>& other) const;
102 
103  virtual SpaceIdentifier spaceIdentifier() const {
104  return PIECEWISE_CONSTANT_SCALAR_BARYCENTRIC;
105  }
106 
107  virtual size_t globalDofCount() const;
108  virtual size_t flatLocalDofCount() const;
109  virtual void getGlobalDofs(const Entity<0>& element,
110  std::vector<GlobalDofIndex>& dofs) const;
111  virtual void global2localDofs(
112  const std::vector<GlobalDofIndex>& globalDofs,
113  std::vector<std::vector<LocalDof> >& localDofs) const;
114  virtual void flatLocal2localDofs(
115  const std::vector<FlatLocalDofIndex>& globalDofs,
116  std::vector<LocalDof>& localDofs) const;
117 
118  virtual void getGlobalDofInterpolationPoints(
119  arma::Mat<CoordinateType>& points) const;
121  arma::Mat<CoordinateType>& normals) const;
122 
123  virtual void getGlobalDofPositions(
124  std::vector<Point3D<CoordinateType> >& positions) const;
125  virtual void getFlatLocalDofPositions(
126  std::vector<Point3D<CoordinateType> >& positions) const;
127 
128  virtual void getGlobalDofBoundingBoxes(
129  std::vector<BoundingBox<CoordinateType> >& bboxes) const;
130  virtual void getFlatLocalDofBoundingBoxes(
131  std::vector<BoundingBox<CoordinateType> >& bboxes) const;
132 
133  virtual void getGlobalDofNormals(
134  std::vector<Point3D<CoordinateType> >& normals) const;
135  virtual void getFlatLocalDofNormals(
136  std::vector<Point3D<CoordinateType> >& normals) const;
137 
138  virtual void dumpClusterIds(
139  const char* fileName,
140  const std::vector<unsigned int>& clusterIdsOfGlobalDofs) const;
141  virtual void dumpClusterIdsEx(
142  const char* fileName,
143  const std::vector<unsigned int>& clusterIdsOfGlobalDofs,
144  DofType dofType) const;
145 
146 private:
147  void assignDofsImpl(const GridSegment& segment);
148 
149 private:
151  std::vector<std::vector<GlobalDofIndex> > m_local2globalDofs;
152  std::vector<std::vector<LocalDof> > m_global2localDofs;
153  std::vector<LocalDof> m_flatLocal2localDofs;
154  GridSegment m_segment;
155  shared_ptr<const Grid> m_originalGrid;
156  mutable shared_ptr<Space<BasisFunctionType> > m_discontinuousSpace;
157  mutable tbb::mutex m_discontinuousSpaceMutex;
158 
159 
160 };
161 
162 } // namespace Bempp
163 
164 #endif
virtual void global2localDofs(const std::vector< GlobalDofIndex > &globalDofs, std::vector< std::vector< LocalDof > > &localDofs) const
Map global degrees of freedom to local degrees of freedom.
Definition: piecewise_constant_scalar_space_barycentric.cpp:250
virtual bool isDiscontinuous() const
Return true if each basis function of this space extends over only a single element, false otherwise.
Definition: piecewise_constant_scalar_space_barycentric.cpp:81
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: piecewise_constant_scalar_space_barycentric.cpp:387
virtual void getFlatLocalDofBoundingBoxes(std::vector< BoundingBox< CoordinateType > > &bboxes) const
Retrieve bounding boxes of local degrees of freedom ordered by their flat index.
Definition: piecewise_constant_scalar_space_barycentric.cpp:321
Base class for spaces of scalar-valued functions.
Definition: scalar_space.hpp:36
Function space.
Definition: assembled_potential_operator.hpp:35
virtual void getGlobalDofPositions(std::vector< Point3D< CoordinateType > > &positions) const
Retrieve the reference positions of global degrees of freedom.
Definition: piecewise_constant_scalar_space_barycentric.cpp:288
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: piecewise_constant_scalar_space_barycentric.cpp:379
Bounding box with a reference point.
Definition: bounding_box.hpp:13
virtual void getGlobalDofInterpolationPoints(arma::Mat< CoordinateType > &points) const
Retrieve the interpolation points of the global degrees of freedom.
Definition: piecewise_constant_scalar_space_barycentric.cpp:271
virtual void flatLocal2localDofs(const std::vector< FlatLocalDofIndex > &globalDofs, std::vector< LocalDof > &localDofs) const
Map flat indices of local degrees of freedom to local degrees of freedom.
Definition: piecewise_constant_scalar_space_barycentric.cpp:260
Collection of shape functions defined on a reference element.
Definition: default_local_assembler_for_operators_on_surfaces_utilities.hpp:34
virtual void getNormalsAtGlobalDofInterpolationPoints(arma::Mat< CoordinateType > &normals) const
Retrieve the unit vectors normal to the grid at the interpolation points of the global degrees of fre...
Definition: piecewise_constant_scalar_space_barycentric.cpp:280
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: piecewise_constant_scalar_space_barycentric.cpp:337
shared_ptr< const Grid > grid() const
Shared pointer to the grid on which the functions from this space are defined.
Definition: space.hpp:183
Space of piecewise constant scalar functions.
Definition: piecewise_constant_scalar_space_barycentric.hpp:48
virtual int domainDimension() const
Dimension of the grid on which functions from this space are defined.
Definition: piecewise_constant_scalar_space_barycentric.cpp:87
Segment of a grid.
Definition: grid_segment.hpp:46
virtual void setElementVariant(const Entity< 0 > &element, ElementVariant variant)
Set the variant of element element to variant.
Definition: piecewise_constant_scalar_space_barycentric.cpp:154
virtual size_t flatLocalDofCount() const
Total number of local degrees of freedom on all elements.
Definition: piecewise_constant_scalar_space_barycentric.cpp:235
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: piecewise_constant_scalar_space_barycentric.cpp:121
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: piecewise_constant_scalar_space_barycentric.cpp:65
virtual bool isBarycentric() const
Return true if space is based on a barycentric refinement.
Definition: piecewise_constant_scalar_space_barycentric.hpp:76
virtual int codomainDimension() const
Dimension of the codomain of the functions.
Definition: piecewise_constant_scalar_space_barycentric.cpp:93
virtual const Fiber::Shapeset< BasisFunctionType > & shapeset(const Entity< 0 > &element) const
Reference to the shapeset attached to the specified element.
Definition: piecewise_constant_scalar_space_barycentric.cpp:100
virtual void getFlatLocalDofPositions(std::vector< Point3D< CoordinateType > > &positions) const
Retrieve the reference positions of local degrees of freedom ordered by their flat index...
Definition: piecewise_constant_scalar_space_barycentric.cpp:300
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: piecewise_constant_scalar_space_barycentric.cpp:328
PiecewiseConstantScalarSpaceBarycentric(const shared_ptr< const Grid > &grid)
Constructor.
Definition: piecewise_constant_scalar_space_barycentric.cpp:44
Abstract wrapper of an entity of codimension 0.
Definition: entity.hpp:81
virtual void getGlobalDofs(const Entity< 0 > &element, std::vector< GlobalDofIndex > &dofs) const
Map local degrees of freedom residing on an element to global degrees of freedom. ...
Definition: piecewise_constant_scalar_space_barycentric.cpp:241
virtual void getGlobalDofBoundingBoxes(std::vector< BoundingBox< CoordinateType > > &bboxes) const
Retrieve bounding boxes of global degrees of freedom.
Definition: piecewise_constant_scalar_space_barycentric.cpp:312
virtual size_t globalDofCount() const
Number of global degrees of freedom.
Definition: piecewise_constant_scalar_space_barycentric.cpp:229
virtual ElementVariant elementVariant(const Entity< 0 > &element) const
Return the variant of element element.
Definition: piecewise_constant_scalar_space_barycentric.cpp:107
virtual SpaceIdentifier spaceIdentifier() const
Return the identifier of the space.
Definition: piecewise_constant_scalar_space_barycentric.hpp:103
shared_ptr< const Space< BasisFunctionType > > barycentricSpace(const shared_ptr< const Space< BasisFunctionType > > &self) const
Return an equivalent space (in terms of global Dofs), but defined using local dofs on the barycentric...
Definition: piecewise_constant_scalar_space_barycentric.cpp:142