5#ifndef DUNE_GRID_COMMON_BOUNDARYPROJECTION_HH
6#define DUNE_GRID_COMMON_BOUNDARYPROJECTION_HH
13#include <dune/common/fvector.hh>
15#include <dune/geometry/multilineargeometry.hh>
24 template <
int dimworld>
29 template <
int dimworld>
53 DUNE_THROW(NotImplemented,
"DuneBoundaryProjection::backup not overloaded!");
56 template <
class BufferImp>
63 template <
class BufferImp>
69 std::string data = str.str();
70 const size_t size = data.size();
72 for(
size_t i=0; i<size; ++i )
73 buffer.
write( data[ i ] );
76 template <
class BufferImp>
83 template <
class BufferImp>
90 for(
size_t i=0; i<size; ++i )
91 buffer.
read( data[ i ] );
94 str.write( data.c_str(), size );
99 template <
int dimworld >
121 return proj_( global );
129 template<
int dim,
int dimworld >
136 typedef typename Base :: ObjectStreamType ObjectStreamType;
138 typedef MultiLinearGeometry<
typename Base::CoordinateType::value_type,dim-1,dimworld> FaceMapping;
153 const std::vector< CoordinateType > &
vertices,
155 : faceMapping_( FaceMapping( type,
vertices ) ),
172 return *boundarySegment_;
175 void backup( ObjectStreamType& buffer )
const
178 buffer.write( (
const char *) &
key(),
sizeof(
int));
180 GeometryType type = faceMapping_.type();
181 buffer.write( (
const char *) &type,
sizeof(GeometryType) );
183 int corners = faceMapping_.corners() ;
184 buffer.write( (
const char *) &corners,
sizeof(
int) );
187 for(
int i=0; i<corners; ++i )
189 corner = faceMapping_.corner( i );
190 buffer.write( (
const char *) &corner[ 0 ],
sizeof(
double)*CoordinateType::dimension );
193 boundarySegment_->backup( buffer );
214 buffer.read( (
char *) &type,
sizeof(GeometryType) );
216 buffer.read( (
char *) &corners,
sizeof(
int) );
218 for(
int i=0; i<corners; ++i )
220 buffer.read( (
char *) &
vertices[ i ][ 0 ],
sizeof(
double)*CoordinateType::dimension );
222 return FaceMapping( type,
vertices );
226 FaceMapping faceMapping_;
227 const std::shared_ptr< BoundarySegment > boundarySegment_;
237 template <
int dimworld>
255 const double factor =
radius_ / global.two_norm();
Base class for grid boundary segments of arbitrary geometry.
Describes the parallel communication interface class for MessageBuffers and DataHandles.
IteratorRange<... > vertices(const GV &gv)
Iterates over all vertices (entities with dimension 0) of a GridView.
Include standard header files.
Definition agrid.hh:60
Interface class for vertex projection at the boundary.
Definition boundaryprojection.hh:32
DuneBoundaryProjection< dimworld > ThisType
Definition boundaryprojection.hh:33
virtual void backup(ObjectStreamType &buffer) const
write DuneBoundaryProjection's data to stream buffer
Definition boundaryprojection.hh:51
static std::unique_ptr< ThisType > restoreFromBuffer(MessageBufferIF< BufferImp > &buffer)
Definition boundaryprojection.hh:84
virtual CoordinateType operator()(const CoordinateType &global) const =0
projection operator projection a global coordinate
void toBuffer(BufferImp &buffer) const
Definition boundaryprojection.hh:57
BaseType::ObjectStreamType ObjectStreamType
Definition boundaryprojection.hh:35
virtual ~DuneBoundaryProjection()
destructor
Definition boundaryprojection.hh:43
static std::unique_ptr< ThisType > restoreFromBuffer(BufferImp &buffer)
Definition boundaryprojection.hh:77
FieldVector< double, dimworld > CoordinateType
Definition boundaryprojection.hh:41
void toBuffer(MessageBufferIF< BufferImp > &buffer) const
Definition boundaryprojection.hh:64
BoundarySegmentBackupRestore< DuneBoundaryProjection< dimworld > > BaseType
Definition boundaryprojection.hh:34
BaseType::CoordinateType CoordinateType
type of coordinate vector
Definition boundaryprojection.hh:108
BoundaryProjectionWrapper(const BaseType &proje)
Definition boundaryprojection.hh:111
const BaseType & proj_
Definition boundaryprojection.hh:105
DuneBoundaryProjection< dimworld > BaseType
Definition boundaryprojection.hh:104
CoordinateType operator()(const CoordinateType &global) const
projection operator projection a global coordinate
Definition boundaryprojection.hh:119
~BoundaryProjectionWrapper()
destructor
Definition boundaryprojection.hh:116
CoordinateType operator()(const CoordinateType &global) const
projection operator projection a global coordinate
Definition boundaryprojection.hh:165
void backup(ObjectStreamType &buffer) const
write DuneBoundaryProjection's data to stream buffer
Definition boundaryprojection.hh:175
static int & key()
Definition boundaryprojection.hh:205
const BoundarySegment & boundarySegment() const
Definition boundaryprojection.hh:170
BoundarySegmentWrapper(const GeometryType &type, const std::vector< CoordinateType > &vertices, const std::shared_ptr< BoundarySegment > &boundarySegment)
Definition boundaryprojection.hh:152
BoundarySegmentWrapper(ObjectStreamType &buffer)
Definition boundaryprojection.hh:159
Dune::BoundarySegment< dim, dimworld > BoundarySegment
Definition boundaryprojection.hh:142
static void registerFactory()
Definition boundaryprojection.hh:196
FaceMapping readFaceMapping(ObjectStreamType &buffer)
Definition boundaryprojection.hh:211
Base::CoordinateType CoordinateType
Definition boundaryprojection.hh:141
FieldVector< double, dimworld > CoordinateType
type of coordinate vector
Definition boundaryprojection.hh:241
CircleBoundaryProjection(const double radius=std::sqrt((double) dimworld))
constructor taking radius of circle (default = sqrt( dimworld ) )
Definition boundaryprojection.hh:244
virtual CoordinateType operator()(const CoordinateType &global) const
projection operator projection a global coordinate
Definition boundaryprojection.hh:251
virtual ~CircleBoundaryProjection()
destructor
Definition boundaryprojection.hh:248
const double radius_
radius of circ
Definition boundaryprojection.hh:263
Definition boundarysegment.hh:41
static std::unique_ptr< BoundarySegment > restore(ObjectStreamType &in)
Definition boundarysegment.hh:59
static int registerFactory()
Definition boundarysegment.hh:70
Communication message buffer interface. This class describes the interface for reading and writing da...
Definition datahandleif.hh:33
void write(const T &val)
just wraps the call of the internal buffer method write which writes the data of type T from the buff...
Definition datahandleif.hh:45
void read(T &val)
just wraps the call of the internal buffer method read which reads the data of type T from the buffer...
Definition datahandleif.hh:59