14
// forward declaration
15
template <int codim, int dim, class GridImp>
18
/** \brief Unspecialized class. Not used for anything */
19
template<int mydim, int coorddim, class GridImp>
20
class OneDGridGeometry;
22
template<class GridImp>
23
class OneDGridGeometry <0, 1, GridImp> :
24
public GeometryDefaultImplementation <0, 1, GridImp,OneDGridGeometry>
18
// forward declaration
19
template <int codim, int dim, class GridImp>
22
/** \brief Unspecialized class. Not used for anything */
23
template<int mydim, int coorddim, class GridImp>
24
class OneDGridGeometry;
26
template<class GridImp>
27
class OneDGridGeometry <0, 1, GridImp> :
28
public GeometryDefaultImplementation <0, 1, GridImp,OneDGridGeometry>
27
31
template <int codim_, int dim_, class GridImp_>
28
32
friend class OneDGridEntity;
29
33
template <int mydim_, int coorddim_, class GridImp_>
30
34
friend class OneDGridGeometry;
34
38
OneDGridGeometry() : storeCoordsLocally_(false) {}
36
40
//! return the element type identifier (vertex)
37
41
GeometryType type () const {return GeometryType(0);}
39
//! here we have always an affine geometry
43
//! here we have always an affine geometry
40
44
bool affine() const { return true; }
42
46
//! return the number of corners of this element (==1)
43
47
int corners () const {return 1;}
45
//! access to coordinates of corners. Index is the number of the corner
46
const FieldVector<typename GridImp::ctype, 1>& operator[] (int i) const {
47
return (storeCoordsLocally_) ? pos_ : target_->pos_;
50
49
/** \brief access to coordinates of a corner */
51
50
const FieldVector< typename GridImp::ctype, 1 > corner ( const int i ) const
53
52
return (storeCoordsLocally_ ? pos_ : target_->pos_);
56
/** \brief Maps a local coordinate within reference element to
55
/** \brief Maps a local coordinate within reference element to
57
56
* global coordinate in element */
58
57
FieldVector<typename GridImp::ctype, 1> global (const FieldVector<typename GridImp::ctype, 0>& local) const {
59
return (storeCoordsLocally_) ? pos_ : target_->pos_;
58
return (storeCoordsLocally_) ? pos_ : target_->pos_;
62
/** \brief Maps a global coordinate within the element to a
61
/** \brief Maps a global coordinate within the element to a
63
62
* local coordinate in its reference element */
64
63
FieldVector<typename GridImp::ctype, 0> local (const FieldVector<typename GridImp::ctype, 1>& global) const {
65
FieldVector<typename GridImp::ctype, 0> l;
64
FieldVector<typename GridImp::ctype, 0> l;
71
This method really doesn't make much sense for a zero-dimensional
72
object. It always returns '1'.
70
This method really doesn't make much sense for a zero-dimensional
71
object. It always returns '1'.
74
73
typename GridImp::ctype integrationElement (const FieldVector<typename GridImp::ctype, 0>& local) const {
78
77
//! The Jacobian matrix of the mapping from the reference element to this element
99
98
FieldVector<typename GridImp::ctype,1> pos_;
101
100
OneDEntityImp<0>* target_;
103
102
FieldMatrix< typename GridImp::ctype, 0, 1 > jacTransposed_;
104
103
FieldMatrix<typename GridImp::ctype,1,0> jacInverse_;
107
//**********************************************************************
109
// --OneDGridGeometry
110
/** \brief Defines the geometry part of a mesh entity.
106
//**********************************************************************
108
// --OneDGridGeometry
109
/** \brief Defines the geometry part of a mesh entity.
111
110
* \ingroup OneDGrid
113
template<int mydim, int coorddim, class GridImp>
114
class OneDGridGeometry :
115
public GeometryDefaultImplementation <mydim, coorddim, GridImp, OneDGridGeometry>
117
template <int codim_, int dim_, class GridImp_>
118
friend class OneDGridEntity;
120
friend class OneDGrid;
122
template <int cc_, int dim_, class GridImp_>
123
friend class OneDGridSubEntityFactory;
125
template <class GridImp_>
126
friend class OneDGridLevelIntersectionIterator;
127
template <class GridImp_>
128
friend class OneDGridLeafIntersectionIterator;
132
OneDGridGeometry() : storeCoordsLocally_(false) {}
134
//! here we have always an affine geometry
135
bool affine() const { return true; }
137
/** \brief Return the element type identifier
139
* OneDGrid obviously supports only lines
141
GeometryType type () const {return GeometryType(1);}
143
//! return the number of corners of this element. Corners are numbered 0...n-1
144
int corners () const {return 2;}
146
//! access to coordinates of corners. Index is the number of the corner
147
const FieldVector<typename GridImp::ctype, coorddim>& operator[](int i) const {
148
assert(i==0 || i==1);
149
return (storeCoordsLocally_) ? pos_[i] : target_->vertex_[i]->pos_;
152
/** \brief access to coordinates of a corner */
153
const FieldVector< typename GridImp::ctype, coorddim > corner ( const int i ) const
155
assert( (i == 0) || (i == 1) );
156
return (storeCoordsLocally_ ? pos_[ i ] : target_->vertex_[ i ]->pos_);
159
/** \brief Maps a local coordinate within reference element to
160
* global coordinate in element */
161
FieldVector<typename GridImp::ctype, coorddim> global (const FieldVector<typename GridImp::ctype, mydim>& local) const {
162
FieldVector<typename GridImp::ctype, coorddim> g;
163
g[0] = (storeCoordsLocally_)
164
? pos_[0][0] * (1-local[0]) + pos_[1][0] * local[0]
165
: target_->vertex_[0]->pos_[0] * (1-local[0]) + target_->vertex_[1]->pos_[0] * local[0];
169
/** \brief Maps a global coordinate within the element to a
170
* local coordinate in its reference element */
171
FieldVector<typename GridImp::ctype, mydim> local (const FieldVector<typename GridImp::ctype, coorddim>& global) const {
172
FieldVector<typename GridImp::ctype, mydim> l;
173
if (storeCoordsLocally_) {
174
l[0] = (global[0] - pos_[0][0]) / (pos_[1][0] - pos_[0][0]);
176
const typename GridImp::ctype& v0 = target_->vertex_[0]->pos_[0];
177
const typename GridImp::ctype& v1 = target_->vertex_[1]->pos_[0];
178
l[0] = (global[0] - v0) / (v1 - v0);
185
typename GridImp::ctype integrationElement (const FieldVector<typename GridImp::ctype, mydim>& local) const {
186
return (storeCoordsLocally_)
187
? pos_[1][0] - pos_[0][0]
188
: target_->vertex_[1]->pos_[0] - target_->vertex_[0]->pos_[0];
191
//! The Jacobian matrix of the mapping from the reference element to this element
192
const FieldMatrix< typename GridImp::ctype, mydim, mydim > &
193
jacobianTransposed ( const FieldVector< typename GridImp::ctype, mydim > &local ) const
195
if( storeCoordsLocally_ )
196
jacTransposed_[ 0 ][ 0 ] = (pos_[ 1 ][ 0 ] - pos_[ 0 ][ 0 ] );
198
jacTransposed_[ 0 ][ 0 ] = target_->vertex_[ 1 ]->pos_[ 0 ] - target_->vertex_[ 0 ]->pos_[ 0 ];
200
return jacTransposed_;
203
//! The Jacobian matrix of the mapping from the reference element to this element
204
const FieldMatrix<typename GridImp::ctype,mydim,mydim>& jacobianInverseTransposed (const FieldVector<typename GridImp::ctype, mydim>& local) const {
205
if (storeCoordsLocally_)
206
jacInverse_[0][0] = 1 / (pos_[1][0] - pos_[0][0]);
208
jacInverse_[0][0] = 1 / (target_->vertex_[1]->pos_[0] - target_->vertex_[0]->pos_[0]);
213
void setPositions(const typename GridImp::ctype& p1, const typename GridImp::ctype& p2) {
214
storeCoordsLocally_ = true;
220
OneDEntityImp<1>* target_;
222
bool storeCoordsLocally_;
224
// Stores the element corner positions if it is returned as geometryInFather
225
FieldVector<typename GridImp::ctype,coorddim> pos_[2];
227
//! jacobian transposed
228
mutable FieldMatrix< typename GridImp::ctype, coorddim, coorddim > jacTransposed_;
230
mutable FieldMatrix<typename GridImp::ctype,coorddim,coorddim> jacInverse_;
112
template<int mydim, int coorddim, class GridImp>
113
class OneDGridGeometry :
114
public AxisAlignedCubeGeometry<typename GridImp::ctype, mydim, coorddim>
117
OneDGridGeometry(const FieldVector<double,1>& left, const FieldVector<double,1>& right)
118
: AxisAlignedCubeGeometry<typename GridImp::ctype, mydim, coorddim>(left,right)
234
122
namespace FacadeOptions