dune-alugrid 2.8.0
Loading...
Searching...
No Matches
bndprojection.hh
Go to the documentation of this file.
1#ifndef DUNE_ALU_BNDPROJECTION_HH
2#define DUNE_ALU_BNDPROJECTION_HH
3
4#include <memory>
5
6#include <dune/common/exceptions.hh>
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:
42
43 public:
44
46 typedef typename DuneBoundaryProjectionType :: CoordinateType CoordinateType;
47
50 : projection_( ptr ), projectionType_( (projection_) ? pt : BaseType::none )
51 {
52 }
53
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
Definition: alu3dinclude.hh:63
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
static void registerFactory()
Definition: bndprojection.hh:91
GridType::DuneBoundaryProjectionType DuneBoundaryProjectionType
type of boundary projection
Definition: bndprojection.hh:26
DuneBoundaryProjectionPointerType projection_
Definition: bndprojection.hh:40
ProjectionType projectionType_
Definition: bndprojection.hh:41
ProjectionType projectionType() const
Definition: bndprojection.hh:54
BaseType::ProjectionType ProjectionType
Definition: bndprojection.hh:32
static BaseType * factory(BufferType &os)
Definition: bndprojection.hh:96
void backup(BufferType &os) const
Definition: bndprojection.hh:80
DuneBoundaryProjectionType::CoordinateType CoordinateType
type of coordinate vector
Definition: bndprojection.hh:46
std::unique_ptr< const DuneBoundaryProjectionType > DuneBoundaryProjectionPointerType
Definition: bndprojection.hh:28