dune-grid
2.11
Toggle main menu visibility
Loading...
Searching...
No Matches
dune
grid
common
boundarysegment.hh
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4
// vi: set et ts=4 sw=2 sts=2:
5
#ifndef DUNE_GRID_COMMON_BOUNDARY_SEGMENT_HH
6
#define DUNE_GRID_COMMON_BOUNDARY_SEGMENT_HH
7
8
#include <map>
9
#include <sstream>
10
11
#include <dune/common/singleton.hh>
12
#include <dune/common/parameterizedobject.hh>
13
#include <dune/common/fvector.hh>
14
18
19
namespace
Dune
{
20
36
template
<
int
dim,
int
dimworld = dim,
class
ctype =
double
>
37
struct
BoundarySegment
;
38
39
template
<
class
BndSeg>
40
class
BoundarySegmentBackupRestore
41
{
42
public
:
43
// type of object stream used for storing boundary segment information
44
typedef
std::stringstream
ObjectStreamType
;
45
46
protected
:
48
typedef
BndSeg
BoundarySegment
;
49
51
typedef
Dune::ParameterizedObjectFactory< std::unique_ptr< BoundarySegment > (
ObjectStreamType
& ),
int
>
FactoryType
;
52
59
static
std::unique_ptr< BoundarySegment >
restore
(
ObjectStreamType
& in )
60
{
61
int
key = -1;
62
// read class key for restore
63
in.read( (
char
*) &key,
sizeof
(
int
) );
64
65
// factory creates a unique_ptr which can be released later on
66
return
factory().create( key, in );
67
}
68
69
template
<
class
DerivedType>
70
static
int
registerFactory
()
71
{
72
const
int
key = createKey();
73
// create factory method that produces unique_ptr
74
factory().template define< DerivedType >( key );
75
// return key for storage in derived class
76
return
key;
77
}
78
79
private
:
80
static
int
createKey()
81
{
82
static
int
key = 0;
83
return
key++;
84
}
85
86
static
FactoryType
& factory()
87
{
88
return
Dune::Singleton< FactoryType > :: instance();
89
}
90
};
91
92
template
<
int
dim,
int
dimworld,
class
ctype >
93
struct
BoundarySegment
:
public
BoundarySegmentBackupRestore
< BoundarySegment< dim, dimworld, ctype > >
94
{
95
typedef
BoundarySegment< dim, dimworld, ctype >
ThisType
;
96
typedef
BoundarySegmentBackupRestore< BoundarySegment< dim, dimworld, ctype >
>
BaseType
;
97
98
typedef
typename
BaseType :: ObjectStreamType
ObjectStreamType
;
99
100
using
BaseType
:: restore
;
101
using
BaseType
:: registerFactory
;
102
104
virtual
~BoundarySegment
() {}
105
108
virtual
FieldVector< ctype, dimworld >
109
operator()
(
const
FieldVector< ctype, dim-1> &local )
const
= 0;
110
114
virtual
void
backup
( [[maybe_unused]]
ObjectStreamType
& buffer )
const
115
{
116
DUNE_THROW(NotImplemented,
"BoundarySegment::backup needs to be overloaded!"
);
117
}
118
};
119
120
121
}
// end namespace Dune
122
123
#endif
Dune
Include standard header files.
Definition
agrid.hh:60
Dune::BoundarySegment
Base class for classes implementing geometries of boundary segments.
Definition
boundarysegment.hh:94
Dune::BoundarySegment< dimension, dimensionworld >::ObjectStreamType
BaseType::ObjectStreamType ObjectStreamType
Definition
boundarysegment.hh:98
Dune::BoundarySegment< dimension, dimensionworld >::ThisType
BoundarySegment< dim, dimworld, ctype > ThisType
Definition
boundarysegment.hh:95
Dune::BoundarySegment::backup
virtual void backup(ObjectStreamType &buffer) const
write BoundarySegment's data to stream buffer
Definition
boundarysegment.hh:114
Dune::BoundarySegment< dimension, dimensionworld >::BaseType
BoundarySegmentBackupRestore< BoundarySegment< dim, dimworld, ctype > > BaseType
Definition
boundarysegment.hh:96
Dune::BoundarySegment::operator()
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.
Dune::BoundarySegment::~BoundarySegment
virtual ~BoundarySegment()
Dummy virtual destructor.
Definition
boundarysegment.hh:104
Dune::BoundarySegmentBackupRestore
Definition
boundarysegment.hh:41
Dune::BoundarySegmentBackupRestore::restore
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
Dune::BoundarySegmentBackupRestore< DuneBoundaryProjection< dimworld > >::FactoryType
Dune::ParameterizedObjectFactory< std::unique_ptr< BoundarySegment >(ObjectStreamType &), int > FactoryType
Definition
boundarysegment.hh:51
Dune::BoundarySegmentBackupRestore< DuneBoundaryProjection< dimworld > >::BoundarySegment
DuneBoundaryProjection< dimworld > BoundarySegment
Definition
boundarysegment.hh:48
Dune::BoundarySegmentBackupRestore< DuneBoundaryProjection< dimworld > >::ObjectStreamType
std::stringstream ObjectStreamType
Definition
boundarysegment.hh:44
Dune::BoundarySegmentBackupRestore::registerFactory
static int registerFactory()
Definition
boundarysegment.hh:70
Generated by
1.17.0