BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
piecewise_constant_dual_grid_scalar_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_piecewise_constant_dual_grid_scalar_space_hpp
22 #define bempp_piecewise_constant_dual_grid_scalar_space_hpp
23 
24 
25 
26 #include "../common/common.hpp"
27 #include "scalar_space.hpp"
28 
29 #include "../grid/grid_segment.hpp"
30 #include "../grid/grid_view.hpp"
31 #include "../common/types.hpp"
32 #include "../fiber/constant_scalar_shapeset.hpp"
33 #include "../common/shared_ptr.hpp"
34 
35 #include <map>
36 #include <memory>
37 #include <tbb/mutex.h>
38 
39 namespace Bempp
40 {
41 
43 class GridView;
44 class Grid;
49 template <typename BasisFunctionType>
50 class PiecewiseConstantDualGridScalarSpace : public ScalarSpace<BasisFunctionType>
51 {
52 public:
53  typedef typename Space<BasisFunctionType>::CoordinateType CoordinateType;
54  typedef typename Space<BasisFunctionType>::ComplexType ComplexType;
55 
64  const shared_ptr<const Grid>& grid);
65 
67 
68  virtual shared_ptr<const Space<BasisFunctionType> > discontinuousSpace(
69  const shared_ptr<const Space<BasisFunctionType> >& self) const;
70  virtual bool isDiscontinuous() const;
71 
72  virtual bool spaceIsCompatible(const Space<BasisFunctionType>& other) const;
73 
74  virtual SpaceIdentifier spaceIdentifier() const {
75  return PIECEWISE_CONSTANT_DUAL_GRID_SCALAR;
76  }
77 
78  virtual int domainDimension() const;
79  virtual int codomainDimension() const;
80 
81  virtual bool isBarycentric() const {
82  return true;
83  }
84 
85  shared_ptr<const Space<BasisFunctionType> > barycentricSpace(
86  const shared_ptr<const Space<BasisFunctionType> >& self) 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 
102  virtual size_t globalDofCount() const;
103  virtual size_t flatLocalDofCount() const;
104  virtual void getGlobalDofs(const Entity<0>& element,
105  std::vector<GlobalDofIndex>& dofs) const;
106  virtual void global2localDofs(
107  const std::vector<GlobalDofIndex>& globalDofs,
108  std::vector<std::vector<LocalDof> >& localDofs) const;
109  virtual void flatLocal2localDofs(
110  const std::vector<FlatLocalDofIndex>& flatLocalDofs,
111  std::vector<LocalDof>& localDofs) const;
112 
113  virtual void getGlobalDofPositions(
114  std::vector<Point3D<CoordinateType> >& positions) const;
115  virtual void getFlatLocalDofPositions(
116  std::vector<Point3D<CoordinateType> >& positions) const;
117 
118  virtual void getGlobalDofBoundingBoxes(
119  std::vector<BoundingBox<CoordinateType> >& bboxes) const;
120  virtual void getFlatLocalDofBoundingBoxes(
121  std::vector<BoundingBox<CoordinateType> >& bboxes) const;
122 
123  virtual void getGlobalDofNormals(
124  std::vector<Point3D<CoordinateType> >& normals) const;
125  virtual void getFlatLocalDofNormals(
126  std::vector<Point3D<CoordinateType> >& normals) const;
127 
128  virtual void dumpClusterIds(
129  const char* fileName,
130  const std::vector<unsigned int>& clusterIdsOfGlobalDofs) const;
131  virtual void dumpClusterIdsEx(
132  const char* fileName,
133  const std::vector<unsigned int>& clusterIdsOfGlobalDofs,
134  DofType dofType) const;
135 
136 private:
137  void initialize();
138  void assignDofsImpl();
139 
140 private:
142  std::vector<std::vector<GlobalDofIndex> > m_local2globalDofs;
143  std::vector<std::vector<LocalDof> > m_global2localDofs;
144  std::vector<LocalDof> m_flatLocal2localDofs;
146  shared_ptr<const Grid> m_originalGrid;
147  mutable shared_ptr<Space<BasisFunctionType> > m_discontinuousSpace;
148  mutable tbb::mutex m_discontinuousSpaceMutex;
150 };
151 
152 } // namespace Bempp
153 
154 #endif
Space of piecewise constant functions define on the dual grid.
Definition: piecewise_constant_dual_grid_scalar_space.hpp:50
virtual void setElementVariant(const Entity< 0 > &element, ElementVariant variant)
Set the variant of element element to variant.
Definition: piecewise_constant_dual_grid_scalar_space.cpp:96
PiecewiseConstantDualGridScalarSpace(const shared_ptr< const Grid > &grid)
Constructor.
Definition: piecewise_constant_dual_grid_scalar_space.cpp:49
Fiber::ScalarTraits< BasisFunctionType >::ComplexType ComplexType
Equivalent to std::complex&lt;CoordinateType&gt;.
Definition: space.hpp:93
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_dual_grid_scalar_space.cpp:257
virtual size_t globalDofCount() const
Number of global degrees of freedom.
Definition: piecewise_constant_dual_grid_scalar_space.cpp:236
Base class for spaces of scalar-valued functions.
Definition: scalar_space.hpp:36
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_dual_grid_scalar_space.cpp:418
Function space.
Definition: assembled_potential_operator.hpp:35
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_dual_grid_scalar_space.cpp:410
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_dual_grid_scalar_space.cpp:248
virtual bool isBarycentric() const
Return true if space is based on a barycentric refinement.
Definition: piecewise_constant_dual_grid_scalar_space.hpp:81
Bounding box with a reference point.
Definition: bounding_box.hpp:13
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_dual_grid_scalar_space.cpp:359
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 int domainDimension() const
Dimension of the grid on which functions from this space are defined.
Definition: piecewise_constant_dual_grid_scalar_space.cpp:63
virtual SpaceIdentifier spaceIdentifier() const
Return the identifier of the space.
Definition: piecewise_constant_dual_grid_scalar_space.hpp:74
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_dual_grid_scalar_space.cpp:119
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 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_dual_grid_scalar_space.cpp:135
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: piecewise_constant_dual_grid_scalar_space.cpp:267
virtual int codomainDimension() const
Dimension of the codomain of the functions.
Definition: piecewise_constant_dual_grid_scalar_space.cpp:69
virtual bool isDiscontinuous() const
Return true if each basis function of this space extends over only a single element, false otherwise.
Definition: piecewise_constant_dual_grid_scalar_space.cpp:160
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_dual_grid_scalar_space.cpp:311
virtual size_t flatLocalDofCount() const
Total number of local degrees of freedom on all elements.
Definition: piecewise_constant_dual_grid_scalar_space.cpp:242
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_dual_grid_scalar_space.cpp:148
virtual const Fiber::Shapeset< BasisFunctionType > & shapeset(const Entity< 0 > &element) const
Reference to the shapeset attached to the specified element.
Definition: piecewise_constant_dual_grid_scalar_space.cpp:76
Abstract wrapper of an entity of codimension 0.
Definition: entity.hpp:81
virtual void getGlobalDofBoundingBoxes(std::vector< BoundingBox< CoordinateType > > &bboxes) const
Retrieve bounding boxes of global degrees of freedom.
Definition: piecewise_constant_dual_grid_scalar_space.cpp:301
virtual ElementVariant elementVariant(const Entity< 0 > &element) const
Return the variant of element element.
Definition: piecewise_constant_dual_grid_scalar_space.cpp:83
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_dual_grid_scalar_space.cpp:289
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_dual_grid_scalar_space.cpp:368
virtual void getGlobalDofPositions(std::vector< Point3D< CoordinateType > > &positions) const
Retrieve the reference positions of global degrees of freedom.
Definition: piecewise_constant_dual_grid_scalar_space.cpp:277