1#ifndef DUNE_SPGRID_NORMAL_HH
2#define DUNE_SPGRID_NORMAL_HH
6#include <dune/grid/spgrid/multiindex.hh>
14 template<
class ct,
int dim >
17 typedef SPNormalVector< ct, dim > This;
20 static const int dimension = dim;
22 typedef ct field_type;
23 typedef ct value_type;
25 typedef std::size_t size_type;
29 SPNormalVector ( size_type i,
const field_type &p ) : i_( i ), p_( p ) {}
31 operator FieldVector ()
const
33 FieldVector v( field_type( 0 ) );
38 This &operator*= (
const field_type &s );
39 This &operator/= (
const field_type &s );
44 field_type operator* (
const This &other )
const;
45 field_type operator* (
const FieldVector &other )
const;
47 field_type one_norm ()
const;
48 field_type two_norm ()
const;
49 field_type two_norm2 ()
const;
50 field_type infinity_norm ()
const;
65 typedef SPNormalId< dim > This;
68 static const int dimension = dim;
70 SPNormalId () : face_( 2*dimension ) {}
72 explicit SPNormalId (
int face ) : face_( face ) {}
75 operator SPNormalVector< ct, dimension > ()
const
77 return SPNormalVector< ct, dimension >( axis(),
sign() );
80 This operator- ()
const {
return This( face_ ^ 1 ); }
82 int face ()
const {
return face_; }
84 int axis ()
const {
return (face() >> 1); }
86 int sign ()
const {
return 2*(face() & 1) - 1; }
97 template<
class ct,
int dim >
104 template<
class ct,
int dim >
105 inline SPNormalVector< ct, dim > operator* (
const ct &a,
const SPNormalVector< ct, dim > &b )
107 SPNormalVector< ct, dim > c( b );
113 template<
class ct,
int dim >
114 inline SPNormalVector< ct, dim > operator* (
const SPNormalVector< ct, dim > &a,
const ct &b )
120 template<
class ct,
int dim >
127 template<
class ct,
int dim >
134 template<
class ct,
int dim >
141 template<
class ct,
int dim >
152 template<
class ct,
int dim >
153 inline typename SPNormalVector< ct, dim >::This &
154 SPNormalVector< ct, dim >::operator*= (
const field_type &s )
161 template<
class ct,
int dim >
162 inline typename SPNormalVector< ct, dim >::This &
163 SPNormalVector< ct, dim >::operator/= (
const field_type &s )
170 template<
class ct,
int dim >
173 return (i_ == other.i_) && (p_ == other.p_);
177 template<
class ct,
int dim >
180 return (i_ != other.i_) || (p_ != other.p_);
184 template<
class ct,
int dim >
185 inline typename SPNormalVector< ct, dim >::field_type
186 SPNormalVector< ct, dim >::operator* (
const This &other )
const
188 return (i_ == other.i_ ? p_ * other.p_ : field_type( 0 ));
192 template<
class ct,
int dim >
193 inline typename SPNormalVector< ct, dim >::field_type
194 SPNormalVector< ct, dim >::operator* (
const FieldVector &other )
const
196 return p_ * other[ i_ ];
200 template<
class ct,
int dim >
201 inline typename SPNormalVector< ct, dim >::field_type
202 SPNormalVector< ct, dim >::one_norm ()
const
204 return std::abs( p_ );
208 template<
class ct,
int dim >
209 inline typename SPNormalVector< ct, dim >::field_type
210 SPNormalVector< ct, dim >::two_norm ()
const
212 return std::abs( p_ );
216 template<
class ct,
int dim >
217 inline typename SPNormalVector< ct, dim >::field_type
218 SPNormalVector< ct, dim >::two_norm2 ()
const
224 template<
class ct,
int dim >
225 inline typename SPNormalVector< ct, dim >::field_type
226 SPNormalVector< ct, dim >::infinity_norm ()
const
228 return std::abs( p_ );
237 inline SPMultiIndex< dim > operator+ (
const SPMultiIndex< dim > &idA,
const SPNormalId< dim > &idB )
239 SPMultiIndex< dim > idC( idA );
240 idC[ idB.axis()] += idB.sign();
246 inline SPMultiIndex< dim > operator+ (
const SPNormalId< dim > &idA,
const SPMultiIndex< dim > &idB )
248 SPMultiIndex< dim > idC( idB );
249 idC[ idA.axis() ] += idA.sign();
255 inline SPMultiIndex< dim > operator- (
const SPMultiIndex< dim > &idA,
const SPNormalId< dim > &idB )
257 SPMultiIndex< dim > idC( idA );
258 idC[ idB.axis() ] -= idB.sign();
264 inline SPMultiIndex< dim > operator- (
const SPNormalId< dim > &idA,
const SPMultiIndex< dim > &idB )
266 SPMultiIndex< dim > idC( -idB );
267 idC[ idA.axis() ] += idA.sign();
273 inline int operator* (
const SPMultiIndex< dim > &idA,
const SPNormalId< dim > &idB )
275 return idB.sign() * idA[ idB.axis() ];
279 inline int operator* (
const SPNormalId< dim > &idA,
const SPMultiIndex< dim > &idB )
281 return idA.sign() * idB[ idA.axis() ];
vector space out of a tensor product of fields.
Definition: fvector.hh:95
Implements a vector constructed from a given type representing a field and a compile-time given size.
EnableIfInterOperable< T1, T2, bool >::type operator==(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for equality.
Definition: iteratorfacades.hh:237
EnableIfInterOperable< T1, T2, bool >::type operator!=(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for inequality.
Definition: iteratorfacades.hh:259
Dune namespace.
Definition: alignedallocator.hh:13
int sign(const T &val)
Return the sign of the value.
Definition: math.hh:180