BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
piecewise_linear_discontinuous_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_linear_discontinuous_scalar_space_barycentric_hpp
22 #define piecewise_linear_discontinuous_scalar_space_barycentric_hpp
23 
24 
25 #include "../common/common.hpp"
26 #include "scalar_space.hpp"
27 
28 #include "../grid/grid_segment.hpp"
29 #include "../grid/grid_view.hpp"
30 #include "../common/types.hpp"
31 #include "../fiber/piecewise_constant_scalar_basis.hpp"
32 #include "../fiber/linear_scalar_shapeset_barycentric.hpp"
33 
34 #include <map>
35 #include <memory>
36 #include <tbb/mutex.h>
37 
38 namespace Bempp
39 {
40 
42 class GridView;
47 template <typename BasisFunctionType>
49 {
50 public:
51  typedef typename Space<BasisFunctionType>::CoordinateType CoordinateType;
52  typedef typename Space<BasisFunctionType>::ComplexType ComplexType;
53 
62  const shared_ptr<const Grid>& grid);
63 
79  const shared_ptr<const Grid>& grid,
80  const GridSegment& segment,
81  bool strictlyOnSegment = false);
82 
84 
85  virtual shared_ptr<const Space<BasisFunctionType> > discontinuousSpace(
86  const shared_ptr<const Space<BasisFunctionType> >& self) const;
87  virtual bool isDiscontinuous() const;
88 
89  virtual int domainDimension() const;
90  virtual int codomainDimension() const;
91 
92  virtual bool isBarycentric() const {
93  return true;
94  }
95 
96  virtual shared_ptr<const Space<BasisFunctionType> > barycentricSpace(
97  const shared_ptr<const Space<BasisFunctionType> >& self) const;
98 
105  virtual ElementVariant elementVariant(const Entity<0>& element) const;
106  virtual void setElementVariant(const Entity<0>& element,
107  ElementVariant variant);
108 
109  virtual const Fiber::Shapeset<BasisFunctionType>& shapeset(const Entity<0>& element) const;
110 
111  virtual bool spaceIsCompatible(const Space<BasisFunctionType>& other) const;
112 
113  virtual SpaceIdentifier spaceIdentifier() const {
114  return PIECEWISE_LINEAR_DISCONTINUOUS_SCALAR_BARYCENTRIC;
115  }
116 
117  virtual size_t globalDofCount() const;
118  virtual size_t flatLocalDofCount() const;
119  virtual void getGlobalDofs(const Entity<0>& element,
120  std::vector<GlobalDofIndex>& dofs) const;
121  virtual void global2localDofs(
122  const std::vector<GlobalDofIndex>& globalDofs,
123  std::vector<std::vector<LocalDof> >& localDofs) const;
124  virtual void flatLocal2localDofs(
125  const std::vector<FlatLocalDofIndex>& flatLocalDofs,
126  std::vector<LocalDof>& localDofs) const;
127 
128  virtual void getGlobalDofPositions(
129  std::vector<Point3D<CoordinateType> >& positions) const;
130  virtual void getFlatLocalDofPositions(
131  std::vector<Point3D<CoordinateType> >& positions) const;
132 
133  virtual void getGlobalDofBoundingBoxes(
134  std::vector<BoundingBox<CoordinateType> >& bboxes) const;
135  virtual void getFlatLocalDofBoundingBoxes(
136  std::vector<BoundingBox<CoordinateType> >& bboxes) const;
137 
138  virtual void getGlobalDofNormals(
139  std::vector<Point3D<CoordinateType> >& normals) const;
140  virtual void getFlatLocalDofNormals(
141  std::vector<Point3D<CoordinateType> >& normals) const;
142 
143  virtual void dumpClusterIds(
144  const char* fileName,
145  const std::vector<unsigned int>& clusterIdsOfGlobalDofs) const;
146  virtual void dumpClusterIdsEx(
147  const char* fileName,
148  const std::vector<unsigned int>& clusterIdsOfGlobalDofs,
149  DofType dofType) const;
150 
151 private:
152  void initialize();
153  void assignDofsImpl();
154 
155 private:
156 
159  GridSegment m_segment;
160  bool m_strictlyOnSegment;
161  std::vector<std::vector<GlobalDofIndex> > m_local2globalDofs;
162  std::vector<std::vector<LocalDof> > m_global2localDofs;
163  std::vector<LocalDof> m_flatLocal2localDofs;
164 
165 
166  Shapeset m_linearBasisType1;
167  Shapeset m_linearBasisType2;
168 
169  std::vector<typename Shapeset::BasisType> m_elementIndex2Type;
170 
171  mutable shared_ptr<Space<BasisFunctionType> > m_discontinuousSpace;
172  mutable tbb::mutex m_discontinuousSpaceMutex;
174 };
175 
176 } // namespace Bempp
177 
178 #endif
179 
virtual SpaceIdentifier spaceIdentifier() const
Return the identifier of the space.
Definition: piecewise_linear_discontinuous_scalar_space_barycentric.hpp:113
Definition: linear_scalar_shapeset_barycentric.hpp:33
Fiber::ScalarTraits< BasisFunctionType >::ComplexType ComplexType
Equivalent to std::complex&lt;CoordinateType&gt;.
Definition: space.hpp:93
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_linear_discontinuous_scalar_space_barycentric.cpp:363
Base class for spaces of scalar-valued functions.
Definition: scalar_space.hpp:36
Function space.
Definition: assembled_potential_operator.hpp:35
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_linear_discontinuous_scalar_space_barycentric.cpp:344
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_linear_discontinuous_scalar_space_barycentric.cpp:167
virtual ElementVariant elementVariant(const Entity< 0 > &element) const
Return the variant of element element.
Definition: piecewise_linear_discontinuous_scalar_space_barycentric.cpp:105
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_linear_discontinuous_scalar_space_barycentric.cpp:508
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_linear_discontinuous_scalar_space_barycentric.cpp:353
PiecewiseLinearDiscontinuousScalarSpaceBarycentric(const shared_ptr< const Grid > &grid)
Constructor.
Definition: piecewise_linear_discontinuous_scalar_space_barycentric.cpp:47
Bounding box with a reference point.
Definition: bounding_box.hpp:13
virtual bool isDiscontinuous() const
Return true if each basis function of this space extends over only a single element, false otherwise.
Definition: piecewise_linear_discontinuous_scalar_space_barycentric.cpp:179
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_linear_discontinuous_scalar_space_barycentric.cpp:385
Fiber::ScalarTraits< BasisFunctionType >::RealType CoordinateType
Type used to represent coordinates.
Definition: space.hpp:91
virtual size_t flatLocalDofCount() const
Total number of local degrees of freedom on all elements.
Definition: piecewise_linear_discontinuous_scalar_space_barycentric.cpp:338
Space of piecewise constant functions define on the dual grid.
Definition: piecewise_linear_discontinuous_scalar_space_barycentric.hpp:48
Collection of shape functions defined on a reference element.
Definition: default_local_assembler_for_operators_on_surfaces_utilities.hpp:34
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_linear_discontinuous_scalar_space_barycentric.cpp:550
virtual int domainDimension() const
Dimension of the grid on which functions from this space are defined.
Definition: piecewise_linear_discontinuous_scalar_space_barycentric.cpp:78
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 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_linear_discontinuous_scalar_space_barycentric.cpp:143
Segment of a grid.
Definition: grid_segment.hpp:46
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_linear_discontinuous_scalar_space_barycentric.cpp:558
virtual int codomainDimension() const
Dimension of the codomain of the functions.
Definition: piecewise_linear_discontinuous_scalar_space_barycentric.cpp:84
virtual void setElementVariant(const Entity< 0 > &element, ElementVariant variant)
Set the variant of element element to variant.
Definition: piecewise_linear_discontinuous_scalar_space_barycentric.cpp:118
virtual bool isBarycentric() const
Return true if space is based on a barycentric refinement.
Definition: piecewise_linear_discontinuous_scalar_space_barycentric.hpp:92
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: piecewise_linear_discontinuous_scalar_space_barycentric.cpp:455
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_linear_discontinuous_scalar_space_barycentric.cpp:130
virtual void getGlobalDofPositions(std::vector< Point3D< CoordinateType > > &positions) const
Retrieve the reference positions of global degrees of freedom.
Definition: piecewise_linear_discontinuous_scalar_space_barycentric.cpp:373
virtual void getFlatLocalDofBoundingBoxes(std::vector< BoundingBox< CoordinateType > > &bboxes) const
Retrieve bounding boxes of local degrees of freedom ordered by their flat index.
Definition: piecewise_linear_discontinuous_scalar_space_barycentric.cpp:407
virtual void getGlobalDofBoundingBoxes(std::vector< BoundingBox< CoordinateType > > &bboxes) const
Retrieve bounding boxes of global degrees of freedom.
Definition: piecewise_linear_discontinuous_scalar_space_barycentric.cpp:397
virtual const Fiber::Shapeset< BasisFunctionType > & shapeset(const Entity< 0 > &element) const
Reference to the shapeset attached to the specified element.
Definition: piecewise_linear_discontinuous_scalar_space_barycentric.cpp:91
virtual size_t globalDofCount() const
Number of global degrees of freedom.
Definition: piecewise_linear_discontinuous_scalar_space_barycentric.cpp:332