Dune Core Modules (2.9.0)

bndprojection.hh
1#ifndef DUNE_ALU_BNDPROJECTION_HH
2#define DUNE_ALU_BNDPROJECTION_HH
3
4#include <memory>
5
7
8namespace Dune {
9
12 template < class GridImp, class ctype = double >
13 class ALUGridBoundaryProjection : public GridImp :: ALUGridVertexProjectionType
14 {
15 typedef typename GridImp :: ALUGridVertexProjectionType BaseType;
17
18 typedef GridImp GridType;
19 // type of double coordinate vector
20 typedef ctype coord_t[ 3 ];
21
22 typedef typename BaseType::BufferType BufferType;
23
24 public:
26 typedef typename GridType :: DuneBoundaryProjectionType DuneBoundaryProjectionType;
27
28 typedef std::unique_ptr< const DuneBoundaryProjectionType > DuneBoundaryProjectionPointerType;
29
30
31 // type of projection (i.e. integer identifier)
32 typedef typename BaseType :: ProjectionType ProjectionType;
33
34 using BaseType :: none;
35 using BaseType :: global;
36 using BaseType :: surface;
37 using BaseType :: segment;
38
39 protected:
40 DuneBoundaryProjectionPointerType projection_;
41 ProjectionType projectionType_;
42
43 public:
44
46 typedef typename DuneBoundaryProjectionType :: CoordinateType CoordinateType;
47
50 : projection_( ptr ), projectionType_( (projection_) ? pt : BaseType::none )
51 {
52 }
53
54 ProjectionType projectionType() const { return projectionType_; }
55
57 int operator () (const coord_t &orig,
58 coord_t &prj) const
59 {
60 return this->operator()( orig, 0, prj);
61 }
62
64 int operator () (const coord_t &orig,
65 const int segmentId,
66 coord_t &prj) const
67 {
68 // if pointer is zero we do nothing, i.e. identity mapping
69 if( projection_ )
70 {
71 // call projection operator
72 reinterpret_cast<CoordinateType &> (* (&prj[0])) =
73 (*projection_)( reinterpret_cast<const CoordinateType &> (* (&orig[0])) );
74 }
75
76 // return 1 for success
77 return 1;
78 }
79
80 void backup( BufferType& os ) const
81 {
82 assert( !projection_ ? (projectionType() == BaseType::none) : true );
83
84 // store whether projection is global (i.e. exists one on all cores)
85 if( !projection_ )
86 DUNE_THROW(InvalidStateException,"ALUGridBoundaryProjection::backup: pointer to projection is invalid");
87
88 projection_->toBuffer( os );
89 }
90
91 static void registerFactory()
92 {
93 BaseType :: setFactoryMethod( &factory );
94 }
95
96 static BaseType* factory( BufferType& os )
97 {
98 return new ThisType( DuneBoundaryProjectionType::restoreFromBuffer( os ).release(), segment );
99 }
100 };
101
102} // end namespace Dune
103#endif
ALUGrid boundary projection implementation DuneBndProjection has to fulfil the DuneBoundaryProjection...
Definition: bndprojection.hh:14
int operator()(const coord_t &orig, coord_t &prj) const
(old) method projection vertices defaults to segment 0
Definition: bndprojection.hh:57
ALUGridBoundaryProjection(const DuneBoundaryProjectionType *ptr, const ProjectionType pt=BaseType::none)
constructor storing reference to boundary projection implementation
Definition: bndprojection.hh:49
GridType::DuneBoundaryProjectionType DuneBoundaryProjectionType
type of boundary projection
Definition: bndprojection.hh:26
DuneBoundaryProjectionType::CoordinateType CoordinateType
type of coordinate vector
Definition: bndprojection.hh:46
Default exception if a function was called while the object is not in a valid state for that function...
Definition: exceptions.hh:281
A few common exception classes.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
constexpr GeometryType none(unsigned int dim)
Returns a GeometryType representing a singular of dimension dim.
Definition: type.hh:481
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)