3#ifndef DUNE_GRID_COMMON_BOUNDARY_SEGMENT_HH
4#define DUNE_GRID_COMMON_BOUNDARY_SEGMENT_HH
9#include <dune/common/singleton.hh>
10#include <dune/common/parameterizedobject.hh>
11#include <dune/common/fvector.hh>
34 template<
int dim,
int dimworld = dim,
class ctype =
double >
35 struct BoundarySegment;
37 template <
class BndSeg>
38 class BoundarySegmentBackupRestore
42 typedef std::stringstream ObjectStreamType ;
46 typedef BndSeg BoundarySegment;
49 typedef Dune::ParameterizedObjectFactory< std::unique_ptr< BoundarySegment > ( ObjectStreamType& ),
int > FactoryType;
57 static std::unique_ptr< BoundarySegment > restore( ObjectStreamType& in )
61 in.read( (
char *) &key,
sizeof(
int ) );
64 return factory().create( key, in );
67 template <
class DerivedType>
68 static int registerFactory()
70 const int key = createKey();
72 factory().template define< DerivedType >( key );
78 static int createKey()
84 static FactoryType& factory()
86 return Dune::Singleton< FactoryType > :: instance();
90 template<
int dim,
int dimworld,
class ctype >
91 struct BoundarySegment :
public BoundarySegmentBackupRestore< BoundarySegment< dim, dimworld, ctype > >
93 typedef BoundarySegment< dim, dimworld, ctype > ThisType;
94 typedef BoundarySegmentBackupRestore< BoundarySegment< dim, dimworld, ctype > > BaseType;
96 typedef typename BaseType :: ObjectStreamType ObjectStreamType;
98 using BaseType :: restore;
99 using BaseType :: registerFactory;
106 virtual FieldVector< ctype, dimworld >
107 operator() (
const FieldVector< ctype, dim-1> &local )
const = 0;
112 virtual void backup( [[maybe_unused]] ObjectStreamType& buffer )
const
114 DUNE_THROW(NotImplemented,
"BoundarySegment::backup needs to be overloaded!");
Include standard header files.
Definition: agrid.hh:58
virtual void backup(ObjectStreamType &buffer) const
write BoundarySegment's data to stream buffer
Definition: boundarysegment.hh:112
virtual FieldVector< ctype, dimworld > operator()(const FieldVector< ctype, dim-1 > &local) const =0
A function mapping local coordinates on a boundary segment to world coordinates.
virtual ~BoundarySegment()
Dummy virtual destructor.
Definition: boundarysegment.hh:102