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 >
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_;
178 buffer.write( (
const char *) &
key(),
sizeof(
int));
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 );
200 key() = Base::template registerFactory< ThisType >();
216 buffer.read( (
char *) &corners,
sizeof(
int) );
217 std::vector< CoordinateType > vertices( corners,
CoordinateType(0) );
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();
268 #endif // #ifndef DUNE_GRID_COMMON_BOUNDARYPROJECTION_HH Base class for classes implementing geometries of boundary segments.
Definition: boundarysegment.hh:37
Definition: boundaryprojection.hh:100
Base class for grid boundary segments of arbitrary geometry.
BoundarySegmentWrapper(const GeometryType &type, const std::vector< CoordinateType > &vertices, const std::shared_ptr< BoundarySegment > &boundarySegment)
Definition: boundaryprojection.hh:152
Dune::BoundarySegment< dim, dimworld > BoundarySegment
Definition: boundaryprojection.hh:142
const BaseType & proj_
Definition: boundaryprojection.hh:105
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
FieldVector< double, dimworld > CoordinateType
type of coordinate vector
Definition: boundaryprojection.hh:241
static std::unique_ptr< ThisType > restoreFromBuffer(BufferImp &buffer)
Definition: boundaryprojection.hh:77
Base::CoordinateType CoordinateType
Definition: boundaryprojection.hh:141
virtual void backup([[maybe_unused]] ObjectStreamType &buffer) const
write DuneBoundaryProjection's data to stream buffer
Definition: boundaryprojection.hh:51
virtual CoordinateType operator()(const CoordinateType &global) const
projection operator projection a global coordinate
Definition: boundaryprojection.hh:251
~BoundaryProjectionWrapper()
destructor
Definition: boundaryprojection.hh:116
static std::unique_ptr< ThisType > restoreFromBuffer(MessageBufferIF< BufferImp > &buffer)
Definition: boundaryprojection.hh:84
std::stringstream ObjectStreamType
Definition: boundarysegment.hh:44
static int & key()
Definition: boundaryprojection.hh:205
void toBuffer(BufferImp &buffer) const
Definition: boundaryprojection.hh:57
virtual ~DuneBoundaryProjection()
destructor
Definition: boundaryprojection.hh:43
DuneBoundaryProjection< dimworld > BaseType
Definition: boundaryprojection.hh:104
static void registerFactory()
Definition: boundaryprojection.hh:196
virtual ~CircleBoundaryProjection()
destructor
Definition: boundaryprojection.hh:248
CoordinateType operator()(const CoordinateType &global) const
projection operator projection a global coordinate
Definition: boundaryprojection.hh:119
BoundarySegmentBackupRestore< DuneBoundaryProjection< dimworld > > BaseType
Definition: boundaryprojection.hh:34
virtual CoordinateType operator()(const CoordinateType &global) const =0
projection operator projection a global coordinate
CircleBoundaryProjection(const double radius=std::sqrt((double) dimworld))
constructor taking radius of circle (default = sqrt( dimworld ) )
Definition: boundaryprojection.hh:244
Include standard header files.
Definition: agrid.hh:59
BoundarySegmentWrapper(ObjectStreamType &buffer)
Definition: boundaryprojection.hh:159
BoundaryProjectionWrapper(const BaseType &proje)
Definition: boundaryprojection.hh:111
Definition: boundaryprojection.hh:238
FieldVector< double, dimworld > CoordinateType
type of coordinate vector
Definition: boundaryprojection.hh:41
CoordinateType operator()(const CoordinateType &global) const
projection operator projection a global coordinate
Definition: boundaryprojection.hh:165
BaseType ::ObjectStreamType ObjectStreamType
Definition: boundaryprojection.hh:35
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
static int registerFactory()
Definition: boundarysegment.hh:70
FaceMapping readFaceMapping(ObjectStreamType &buffer)
Definition: boundaryprojection.hh:211
Describes the parallel communication interface class for MessageBuffers and DataHandles.
DuneBoundaryProjection< dimworld > ThisType
Definition: boundaryprojection.hh:33
const BoundarySegment & boundarySegment() const
Definition: boundaryprojection.hh:170
const double radius_
radius of circ
Definition: boundaryprojection.hh:263
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
Interface class for vertex projection at the boundary.
Definition: boundaryprojection.hh:25
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
BaseType ::CoordinateType CoordinateType
type of coordinate vector
Definition: boundaryprojection.hh:108
Definition: boundarysegment.hh:40
Communication message buffer interface. This class describes the interface for reading and writing da...
Definition: datahandleif.hh:32
Definition: boundaryprojection.hh:130
void toBuffer(MessageBufferIF< BufferImp > &buffer) const
Definition: boundaryprojection.hh:64
void backup(ObjectStreamType &buffer) const
Definition: boundaryprojection.hh:175