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>
25 template <
int dimworld>
26 struct DuneBoundaryProjection;
30 template <
int dimworld>
54 DUNE_THROW(NotImplemented,
"DuneBoundaryProjection::backup not overloaded!");
57 template <
class BufferImp>
64 template <
class BufferImp>
70 std::string data = str.str();
71 const size_t size = data.size();
73 for(
size_t i=0; i<size; ++i )
74 buffer.
write( data[ i ] );
77 template <
class BufferImp>
84 template <
class BufferImp>
91 for(
size_t i=0; i<size; ++i )
92 buffer.
read( data[ i ] );
95 str.write( data.c_str(), size );
100 template <
int dimworld >
122 return proj_( global );
130 template<
int dim,
int dimworld >
139 typedef MultiLinearGeometry<
typename Base::CoordinateType::value_type,dim-1,dimworld> FaceMapping;
154 const std::vector< CoordinateType > &vertices,
156 : faceMapping_( FaceMapping( type, vertices ) ),
173 return *boundarySegment_;
179 buffer.write( (
const char *) &
key(),
sizeof(
int));
182 buffer.write( (
const char *) &type,
sizeof(
GeometryType) );
184 int corners = faceMapping_.corners() ;
185 buffer.write( (
const char *) &corners,
sizeof(
int) );
188 for(
int i=0; i<corners; ++i )
190 corner = faceMapping_.corner( i );
191 buffer.write( (
const char *) &corner[ 0 ],
sizeof(
double)*CoordinateType::dimension );
194 boundarySegment_->backup( buffer );
201 key() = Base::template registerFactory< ThisType >();
217 buffer.read( (
char *) &corners,
sizeof(
int) );
218 std::vector< CoordinateType > vertices( corners,
CoordinateType(0) );
219 for(
int i=0; i<corners; ++i )
221 buffer.read( (
char *) &vertices[ i ][ 0 ],
sizeof(
double)*CoordinateType::dimension );
223 return FaceMapping( type, vertices );
227 FaceMapping faceMapping_;
228 const std::shared_ptr< BoundarySegment > boundarySegment_;
238 template <
int dimworld>
256 const double factor =
radius_ / global.two_norm();
Describes the parallel communication interface class for MessageBuffers and DataHandles.
Base class for grid boundary segments of arbitrary geometry.
Include standard header files.
Definition: agrid.hh:60
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
Interface class for vertex projection at the boundary.
Definition: boundaryprojection.hh:33
DuneBoundaryProjection< dimworld > ThisType
Definition: boundaryprojection.hh:34
virtual void backup(ObjectStreamType &buffer) const
write DuneBoundaryProjection's data to stream buffer
Definition: boundaryprojection.hh:52
static std::unique_ptr< ThisType > restoreFromBuffer(MessageBufferIF< BufferImp > &buffer)
Definition: boundaryprojection.hh:85
virtual CoordinateType operator()(const CoordinateType &global) const =0
projection operator projection a global coordinate
void toBuffer(BufferImp &buffer) const
Definition: boundaryprojection.hh:58
BaseType::ObjectStreamType ObjectStreamType
Definition: boundaryprojection.hh:36
virtual ~DuneBoundaryProjection()
destructor
Definition: boundaryprojection.hh:44
static std::unique_ptr< ThisType > restoreFromBuffer(BufferImp &buffer)
Definition: boundaryprojection.hh:78
FieldVector< double, dimworld > CoordinateType
type of coordinate vector
Definition: boundaryprojection.hh:42
void toBuffer(MessageBufferIF< BufferImp > &buffer) const
Definition: boundaryprojection.hh:65
BoundarySegmentBackupRestore< DuneBoundaryProjection< dimworld > > BaseType
Definition: boundaryprojection.hh:35
Definition: boundaryprojection.hh:103
BaseType::CoordinateType CoordinateType
type of coordinate vector
Definition: boundaryprojection.hh:109
BoundaryProjectionWrapper(const BaseType &proje)
Definition: boundaryprojection.hh:112
const BaseType & proj_
Definition: boundaryprojection.hh:106
DuneBoundaryProjection< dimworld > BaseType
Definition: boundaryprojection.hh:105
CoordinateType operator()(const CoordinateType &global) const
projection operator projection a global coordinate
Definition: boundaryprojection.hh:120
~BoundaryProjectionWrapper()
destructor
Definition: boundaryprojection.hh:117
Definition: boundaryprojection.hh:133
CoordinateType operator()(const CoordinateType &global) const
projection operator projection a global coordinate
Definition: boundaryprojection.hh:166
void backup(ObjectStreamType &buffer) const
write DuneBoundaryProjection's data to stream buffer
Definition: boundaryprojection.hh:176
static int & key()
Definition: boundaryprojection.hh:206
const BoundarySegment & boundarySegment() const
Definition: boundaryprojection.hh:171
BoundarySegmentWrapper(const GeometryType &type, const std::vector< CoordinateType > &vertices, const std::shared_ptr< BoundarySegment > &boundarySegment)
Definition: boundaryprojection.hh:153
BoundarySegmentWrapper(ObjectStreamType &buffer)
Definition: boundaryprojection.hh:160
Dune::BoundarySegment< dim, dimworld > BoundarySegment
Definition: boundaryprojection.hh:143
static void registerFactory()
Definition: boundaryprojection.hh:197
FaceMapping readFaceMapping(ObjectStreamType &buffer)
Definition: boundaryprojection.hh:212
Base::CoordinateType CoordinateType
Definition: boundaryprojection.hh:142
Definition: boundaryprojection.hh:240
FieldVector< double, dimworld > CoordinateType
type of coordinate vector
Definition: boundaryprojection.hh:242
CircleBoundaryProjection(const double radius=std::sqrt((double) dimworld))
constructor taking radius of circle (default = sqrt( dimworld ) )
Definition: boundaryprojection.hh:245
virtual CoordinateType operator()(const CoordinateType &global) const
projection operator projection a global coordinate
Definition: boundaryprojection.hh:252
virtual ~CircleBoundaryProjection()
destructor
Definition: boundaryprojection.hh:249
const double radius_
radius of circ
Definition: boundaryprojection.hh:264
Base class for classes implementing geometries of boundary segments.
Definition: boundarysegment.hh:94
Definition: boundarysegment.hh:41
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:59
std::stringstream ObjectStreamType
Definition: boundarysegment.hh:44
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