BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
unit_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_unit_scalar_space_hpp
22 #define bempp_unit_scalar_space_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 
31 #include <map>
32 #include <memory>
33 
34 namespace Bempp
35 {
36 
38 class GridView;
43 template <typename BasisFunctionType>
44 class UnitScalarSpace : public ScalarSpace<BasisFunctionType>
45 {
46 public:
47  typedef typename ScalarSpace<BasisFunctionType>::CoordinateType CoordinateType;
48 
49  explicit UnitScalarSpace(const shared_ptr<const Grid>& grid);
50 
51  virtual int domainDimension() const;
52  virtual int codomainDimension() const;
53 
54  virtual shared_ptr<const Space<BasisFunctionType> > discontinuousSpace(
55  const shared_ptr<const Space<BasisFunctionType> >& self) const;
56  virtual bool isDiscontinuous() const;
57 
58  virtual SpaceIdentifier spaceIdentifier() const {
59  return UNIT_SCALAR;
60  }
61 
68  virtual ElementVariant elementVariant(const Entity<0>& element) const;
69  virtual void setElementVariant(const Entity<0>& element,
70  ElementVariant variant);
71 
72 
74  const Entity<0>& element) const;
75 
76  virtual bool isBarycentric() const {
77  return false;
78  }
79 
80  virtual bool spaceIsCompatible(const Space<BasisFunctionType>& other) const;
81 
82  virtual size_t globalDofCount() const;
83  virtual size_t flatLocalDofCount() const;
84  virtual void getGlobalDofs(const Entity<0>& element,
85  std::vector<GlobalDofIndex>& dofs) const;
86  virtual void global2localDofs(
87  const std::vector<GlobalDofIndex>& globalDofs,
88  std::vector<std::vector<LocalDof> >& localDofs) const;
89  virtual void flatLocal2localDofs(
90  const std::vector<FlatLocalDofIndex>& globalDofs,
91  std::vector<LocalDof>& localDofs) const;
92 
93  virtual void getGlobalDofPositions(
94  std::vector<Point3D<CoordinateType> >& positions) const;
95  virtual void getFlatLocalDofPositions(
96  std::vector<Point3D<CoordinateType> >& positions) const;
97 
98  virtual void getGlobalDofBoundingBoxes(
99  std::vector<BoundingBox<CoordinateType> >& bboxes) const;
100  virtual void getFlatLocalDofBoundingBoxes(
101  std::vector<BoundingBox<CoordinateType> >& bboxes) const;
102 
103  virtual void dumpClusterIds(
104  const char* fileName,
105  const std::vector<unsigned int>& clusterIdsOfGlobalDofs) const;
106  virtual void dumpClusterIdsEx(
107  const char* fileName,
108  const std::vector<unsigned int>& clusterIdsOfGlobalDofs,
109  DofType dofType) const;
110 
111 private:
112  void assignDofsImpl();
113 
114 private:
115  std::auto_ptr<GridView> m_view;
117  std::vector<std::vector<GlobalDofIndex> > m_local2globalDofs;
118  std::vector<std::vector<LocalDof> > m_global2localDofs;
119 };
120 
121 } // namespace Bempp
122 
123 #endif
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: unit_scalar_space.cpp:397
virtual SpaceIdentifier spaceIdentifier() const
Return the identifier of the space.
Definition: unit_scalar_space.hpp:58
virtual void getFlatLocalDofPositions(std::vector< Point3D< CoordinateType > > &positions) const
Retrieve the reference positions of local degrees of freedom ordered by their flat index...
Definition: unit_scalar_space.cpp:228
Space consisting of a single scalar function equal to 1 everywhere.
Definition: unit_scalar_space.hpp:44
virtual void getGlobalDofPositions(std::vector< Point3D< CoordinateType > > &positions) const
Retrieve the reference positions of global degrees of freedom.
Definition: unit_scalar_space.cpp:190
virtual bool isBarycentric() const
Return true if space is based on a barycentric refinement.
Definition: unit_scalar_space.hpp:76
virtual int codomainDimension() const
Dimension of the codomain of the functions.
Definition: unit_scalar_space.cpp:67
Base class for spaces of scalar-valued functions.
Definition: scalar_space.hpp:36
Function space.
Definition: assembled_potential_operator.hpp:35
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: unit_scalar_space.cpp:169
Bounding box with a reference point.
Definition: bounding_box.hpp:13
virtual void setElementVariant(const Entity< 0 > &element, ElementVariant variant)
Set the variant of element element to variant.
Definition: unit_scalar_space.cpp:107
Collection of shape functions defined on a reference element.
Definition: default_local_assembler_for_operators_on_surfaces_utilities.hpp:34
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: unit_scalar_space.cpp:46
virtual void getGlobalDofBoundingBoxes(std::vector< BoundingBox< CoordinateType > > &bboxes) const
Retrieve bounding boxes of global degrees of freedom.
Definition: unit_scalar_space.cpp:259
virtual const Fiber::Shapeset< BasisFunctionType > & shapeset(const Entity< 0 > &element) const
Reference to the shapeset attached to the specified element.
Definition: unit_scalar_space.cpp:74
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: unit_scalar_space.cpp:160
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: unit_scalar_space.cpp:95
virtual size_t globalDofCount() const
Number of global degrees of freedom.
Definition: unit_scalar_space.cpp:148
virtual bool isDiscontinuous() const
Return true if each basis function of this space extends over only a single element, false otherwise.
Definition: unit_scalar_space.cpp:55
virtual void getFlatLocalDofBoundingBoxes(std::vector< BoundingBox< CoordinateType > > &bboxes) const
Retrieve bounding boxes of local degrees of freedom ordered by their flat index.
Definition: unit_scalar_space.cpp:332
virtual int domainDimension() const
Dimension of the grid on which functions from this space are defined.
Definition: unit_scalar_space.cpp:61
virtual ElementVariant elementVariant(const Entity< 0 > &element) const
Return the variant of element element.
Definition: unit_scalar_space.cpp:81
virtual size_t flatLocalDofCount() const
Total number of local degrees of freedom on all elements.
Definition: unit_scalar_space.cpp:154
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: unit_scalar_space.cpp:405
Abstract wrapper of an entity of codimension 0.
Definition: entity.hpp:81
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: unit_scalar_space.cpp:179