BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
piecewise_linear_discontinuous_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_linear_discontinuous_scalar_space_hpp
22 #define bempp_piecewise_linear_discontinuous_scalar_space_hpp
23 
24 #include "../common/common.hpp"
25 
26 #include "../grid/grid_view.hpp"
27 #include "../grid/grid_segment.hpp"
28 #include "piecewise_linear_scalar_space.hpp"
29 #include "../common/types.hpp"
30 // The name is absurd. Change to linear_scalar_basis.hpp
31 #include "../fiber/piecewise_linear_continuous_scalar_basis.hpp"
32 
33 #include <map>
34 #include <memory>
35 #include <tbb/mutex.h>
36 
37 namespace Bempp
38 {
39 
41 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 
80  const shared_ptr<const Grid>& grid,
81  const GridSegment& segment,
82  bool strictlyOnSegment = false);
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 bool isBarycentric() const {
90  return false;
91  }
92 
93 
94  virtual shared_ptr<const Space<BasisFunctionType> > barycentricSpace(
95  const shared_ptr<const Space<BasisFunctionType> >& self) const;
96 
97 
98 
99  virtual bool spaceIsCompatible(const Space<BasisFunctionType>& other) const;
100 
101  virtual SpaceIdentifier spaceIdentifier() const {
102  return PIECEWISE_LINEAR_DISCONTINUOUS_SCALAR;
103  }
104 
105  virtual size_t globalDofCount() const;
106  virtual size_t flatLocalDofCount() const;
107  virtual void getGlobalDofs(const Entity<0>& element,
108  std::vector<GlobalDofIndex>& dofs) const;
109  virtual void global2localDofs(
110  const std::vector<GlobalDofIndex>& globalDofs,
111  std::vector<std::vector<LocalDof> >& localDofs) const;
112  virtual void flatLocal2localDofs(
113  const std::vector<FlatLocalDofIndex>& flatLocalDofs,
114  std::vector<LocalDof>& localDofs) const;
115 
116  virtual void getGlobalDofPositions(std::vector<Point3D<CoordinateType> >& positions) const;
117  virtual void getFlatLocalDofPositions(std::vector<Point3D<CoordinateType> >& positions) const;
118 
119  virtual void getGlobalDofBoundingBoxes(
120  std::vector<BoundingBox<CoordinateType> >& bboxes) const;
121  virtual void getFlatLocalDofBoundingBoxes(
122  std::vector<BoundingBox<CoordinateType> >& bboxes) const;
123 
124  virtual void getGlobalDofNormals(std::vector<Point3D<CoordinateType> >& normals) const;
125  virtual void getFlatLocalDofNormals(std::vector<Point3D<CoordinateType> >& normals) const;
126 
127  virtual void dumpClusterIds(
128  const char* fileName,
129  const std::vector<unsigned int>& clusterIdsOfGlobalDofs) const;
130  virtual void dumpClusterIdsEx(
131  const char* fileName,
132  const std::vector<unsigned int>& clusterIdsOfGlobalDofs,
133  DofType dofType) const;
134 
135 private:
136  void initialize(const GridSegment& segment, bool strictlyOnSegment = false);
137  void assignDofsImpl(const GridSegment& segment,
138  bool strictlyOnSegment = false);
139 
140 private:
142  GridSegment m_segment;
143  bool m_strictlyOnSegment;
144  std::auto_ptr<GridView> m_view;
148  std::vector<std::vector<GlobalDofIndex> > m_local2globalDofs;
149  std::vector<std::vector<LocalDof> > m_global2localDofs;
150  std::vector<LocalDof> m_flatLocal2localDofs;
151  mutable shared_ptr<Space<BasisFunctionType> > m_barycentricSpace;
152  mutable tbb::mutex m_barycentricSpaceMutex;
154 };
155 
156 } // namespace Bempp
157 
158 #endif
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.cpp:214
Fiber::ScalarTraits< BasisFunctionType >::ComplexType ComplexType
Equivalent to std::complex&lt;CoordinateType&gt;.
Definition: space.hpp:93
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.cpp:282
Function space.
Definition: assembled_potential_operator.hpp:35
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.cpp:115
Space of piecewise linear, not necessarily continuous, scalar functions.
Definition: piecewise_linear_discontinuous_scalar_space.hpp:48
Shapeset composed of the linear nodal functions.
Definition: piecewise_linear_continuous_scalar_basis.hpp:34
Bounding box with a reference point.
Definition: bounding_box.hpp:13
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.cpp:223
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.cpp:136
virtual SpaceIdentifier spaceIdentifier() const
Return the identifier of the space.
Definition: piecewise_linear_discontinuous_scalar_space.hpp:101
Fiber::ScalarTraits< BasisFunctionType >::RealType CoordinateType
Type used to represent coordinates.
Definition: space.hpp:91
Space of continuous, piecewise linear scalar functions.
Definition: piecewise_linear_scalar_space.hpp:45
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.cpp:101
PiecewiseLinearDiscontinuousScalarSpace(const shared_ptr< const Grid > &grid)
Constructor.
Definition: piecewise_linear_discontinuous_scalar_space.cpp:46
virtual bool isBarycentric() const
Return true if space is based on a barycentric refinement.
Definition: piecewise_linear_discontinuous_scalar_space.hpp:89
virtual size_t flatLocalDofCount() const
Total number of local degrees of freedom on all elements.
Definition: piecewise_linear_discontinuous_scalar_space.cpp:208
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.cpp:306
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 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.cpp:275
Segment of a grid.
Definition: grid_segment.hpp:46
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.cpp:257
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.cpp:88
virtual void getGlobalDofPositions(std::vector< Point3D< CoordinateType > > &positions) const
Retrieve the reference positions of global degrees of freedom.
Definition: piecewise_linear_discontinuous_scalar_space.cpp:245
Abstract wrapper of an entity of codimension 0.
Definition: entity.hpp:81
virtual size_t globalDofCount() const
Number of global degrees of freedom.
Definition: piecewise_linear_discontinuous_scalar_space.cpp:202
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.cpp:291
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.cpp:235
virtual void getGlobalDofBoundingBoxes(std::vector< BoundingBox< CoordinateType > > &bboxes) const
Retrieve bounding boxes of global degrees of freedom.
Definition: piecewise_linear_discontinuous_scalar_space.cpp:265
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.cpp:298