3#ifndef DUNE_GRID_COMMON_BOUNDARYPROJECTION_HH
4#define DUNE_GRID_COMMON_BOUNDARYPROJECTION_HH
11#include <dune/common/fvector.hh>
13#include <dune/geometry/multilineargeometry.hh>
23 template <
int dimworld>
24 struct DuneBoundaryProjection;
28 template <
int dimworld>
52 DUNE_THROW(NotImplemented,
"DuneBoundaryProjection::backup not overloaded!");
55 template <
class BufferImp>
62 template <
class BufferImp>
68 std::string data = str.str();
69 const size_t size = data.size();
71 for(
size_t i=0; i<size; ++i )
72 buffer.
write( data[ i ] );
75 template <
class BufferImp>
82 template <
class BufferImp>
89 for(
size_t i=0; i<size; ++i )
90 buffer.
read( data[ i ] );
93 str.write( data.c_str(), size );
98 template <
int dimworld >
120 return proj_( global );
128 template<
int dim,
int dimworld >
135 typedef typename Base :: ObjectStreamType ObjectStreamType;
137 typedef MultiLinearGeometry<
typename Base::CoordinateType::value_type,dim-1,dimworld> FaceMapping;
152 const std::vector< CoordinateType > &vertices,
154 : faceMapping_( FaceMapping( type, vertices ) ),
171 return *boundarySegment_;
174 void backup( ObjectStreamType& buffer )
const
177 buffer.write( (
const char *) &
key(),
sizeof(
int));
179 GeometryType type = faceMapping_.type();
180 buffer.write( (
const char *) &type,
sizeof(GeometryType) );
182 int corners = faceMapping_.corners() ;
183 buffer.write( (
const char *) &corners,
sizeof(
int) );
186 for(
int i=0; i<corners; ++i )
188 corner = faceMapping_.corner( i );
189 buffer.write( (
const char *) &corner[ 0 ],
sizeof(
double)*CoordinateType::dimension );
192 boundarySegment_->backup( buffer );
199 key() = Base::template registerFactory< ThisType >();
213 buffer.read( (
char *) &type,
sizeof(GeometryType) );
215 buffer.read( (
char *) &corners,
sizeof(
int) );
216 std::vector< CoordinateType > vertices( corners,
CoordinateType(0) );
217 for(
int i=0; i<corners; ++i )
219 buffer.read( (
char *) &vertices[ i ][ 0 ],
sizeof(
double)*CoordinateType::dimension );
221 return FaceMapping( type, vertices );
225 FaceMapping faceMapping_;
226 const std::shared_ptr< BoundarySegment > boundarySegment_;
236 template <
int dimworld>
254 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.
Include standard header files.
Definition: agrid.hh:58
Interface class for vertex projection at the boundary.
Definition: boundaryprojection.hh:31
DuneBoundaryProjection< dimworld > ThisType
Definition: boundaryprojection.hh:32
virtual void backup(ObjectStreamType &buffer) const
write DuneBoundaryProjection's data to stream buffer
Definition: boundaryprojection.hh:50
static std::unique_ptr< ThisType > restoreFromBuffer(MessageBufferIF< BufferImp > &buffer)
Definition: boundaryprojection.hh:83
virtual CoordinateType operator()(const CoordinateType &global) const =0
projection operator projection a global coordinate
void toBuffer(BufferImp &buffer) const
Definition: boundaryprojection.hh:56
BaseType::ObjectStreamType ObjectStreamType
Definition: boundaryprojection.hh:34
virtual ~DuneBoundaryProjection()
destructor
Definition: boundaryprojection.hh:42
static std::unique_ptr< ThisType > restoreFromBuffer(BufferImp &buffer)
Definition: boundaryprojection.hh:76
FieldVector< double, dimworld > CoordinateType
type of coordinate vector
Definition: boundaryprojection.hh:40
void toBuffer(MessageBufferIF< BufferImp > &buffer) const
Definition: boundaryprojection.hh:63
BoundarySegmentBackupRestore< DuneBoundaryProjection< dimworld > > BaseType
Definition: boundaryprojection.hh:33
Definition: boundaryprojection.hh:101
BaseType::CoordinateType CoordinateType
type of coordinate vector
Definition: boundaryprojection.hh:107
BoundaryProjectionWrapper(const BaseType &proje)
Definition: boundaryprojection.hh:110
const BaseType & proj_
Definition: boundaryprojection.hh:104
DuneBoundaryProjection< dimworld > BaseType
Definition: boundaryprojection.hh:103
CoordinateType operator()(const CoordinateType &global) const
projection operator projection a global coordinate
Definition: boundaryprojection.hh:118
~BoundaryProjectionWrapper()
destructor
Definition: boundaryprojection.hh:115
Definition: boundaryprojection.hh:131
CoordinateType operator()(const CoordinateType &global) const
projection operator projection a global coordinate
Definition: boundaryprojection.hh:164
void backup(ObjectStreamType &buffer) const
write DuneBoundaryProjection's data to stream buffer
Definition: boundaryprojection.hh:174
static int & key()
Definition: boundaryprojection.hh:204
const BoundarySegment & boundarySegment() const
Definition: boundaryprojection.hh:169
BoundarySegmentWrapper(const GeometryType &type, const std::vector< CoordinateType > &vertices, const std::shared_ptr< BoundarySegment > &boundarySegment)
Definition: boundaryprojection.hh:151
BoundarySegmentWrapper(ObjectStreamType &buffer)
Definition: boundaryprojection.hh:158
Dune::BoundarySegment< dim, dimworld > BoundarySegment
Definition: boundaryprojection.hh:141
static void registerFactory()
Definition: boundaryprojection.hh:195
FaceMapping readFaceMapping(ObjectStreamType &buffer)
Definition: boundaryprojection.hh:210
Base::CoordinateType CoordinateType
Definition: boundaryprojection.hh:140
Definition: boundaryprojection.hh:238
FieldVector< double, dimworld > CoordinateType
type of coordinate vector
Definition: boundaryprojection.hh:240
CircleBoundaryProjection(const double radius=std::sqrt((double) dimworld))
constructor taking radius of circle (default = sqrt( dimworld ) )
Definition: boundaryprojection.hh:243
virtual CoordinateType operator()(const CoordinateType &global) const
projection operator projection a global coordinate
Definition: boundaryprojection.hh:250
virtual ~CircleBoundaryProjection()
destructor
Definition: boundaryprojection.hh:247
const double radius_
radius of circ
Definition: boundaryprojection.hh:262
Base class for classes implementing geometries of boundary segments.
Definition: boundarysegment.hh:92
Definition: boundarysegment.hh:39
static std::unique_ptr< BoundarySegment > restore(ObjectStreamType &in)
create an object of BoundarySegment type from a previously registered factory linked to key.
Definition: boundarysegment.hh:57
static int registerFactory()
Definition: boundarysegment.hh:68
Communication message buffer interface. This class describes the interface for reading and writing da...
Definition: datahandleif.hh:31
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:43
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:57