1#ifndef DUNE_FEM_H1NORM_HH
2#define DUNE_FEM_H1NORM_HH
4#include <dune/fem/misc/l2norm.hh>
12 template<
class Gr
idPart >
14 :
public IntegralBase< GridPart, H1Norm< GridPart> >
16 typedef H1Norm< GridPart > ThisType;
17 typedef IntegralBase< GridPart, H1Norm< GridPart> > BaseType;
20 typedef GridPart GridPartType;
22 template<
class Function >
23 struct FunctionJacobianSquare;
26 typedef typename BaseType::EntityType EntityType;
28 typedef CachingQuadrature< GridPartType, 0 > QuadratureType;
30 typedef Integrator< QuadratureType > IntegratorType;
33 using BaseType::gridPart;
41 explicit H1Norm (
const GridPartType &gridPart,
42 const unsigned int order = 0,
43 const bool communicate =
true );
46 template<
class DiscreteFunctionType,
class PartitionSet >
47 typename Dune::FieldTraits< typename DiscreteFunctionType::RangeFieldType >::real_type
51 template<
class DiscreteFunctionType >
52 typename Dune::FieldTraits< typename DiscreteFunctionType::RangeFieldType >::real_type
59 template<
class UDiscreteFunctionType,
class VDiscreteFunctionType,
class PartitionSet >
60 typename Dune::FieldTraits< typename UDiscreteFunctionType::RangeFieldType >::real_type
61 distance (
const UDiscreteFunctionType &u,
const VDiscreteFunctionType &v,
const PartitionSet& partitionSet )
const;
64 template<
class UDiscreteFunctionType,
class VDiscreteFunctionType >
65 typename Dune::FieldTraits< typename UDiscreteFunctionType::RangeFieldType >::real_type
66 distance (
const UDiscreteFunctionType &u,
const VDiscreteFunctionType &v )
const
71 template<
class LocalFunctionType,
class ReturnType >
72 void normLocal (
const EntityType &entity,
unsigned int order,
const LocalFunctionType &uLocal, ReturnType &sum )
const;
74 template<
class ULocalFunctionType,
class VLocalFunctionType,
class ReturnType >
75 void distanceLocal (
const EntityType &entity,
unsigned int order,
const ULocalFunctionType &uLocal,
const VLocalFunctionType &vLocal, ReturnType &sum )
const;
77 ThisType operator= (
const ThisType& ) =
delete;
80 const unsigned int order_;
81 const bool communicate_;
89 template<
class Gr
idPart >
90 template<
class Function >
91 struct H1Norm< GridPart >::FunctionJacobianSquare
93 typedef Function FunctionType;
95 typedef typename FunctionType::RangeFieldType RangeFieldType;
96 typedef typename Dune::FieldTraits< typename FunctionType::RangeFieldType >::real_type RealType;
97 typedef FieldVector< RealType, 1 > RangeType;
100 explicit FunctionJacobianSquare (
const FunctionType &function )
101 : function_( function )
104 template<
class Po
int >
105 void evaluate (
const Point &x, RangeType &ret )
const
107 const int dimRange = FunctionType::RangeType::dimension;
109 typename FunctionType::RangeType phi;
110 function_.evaluate( x, phi );
111 ret[ 0 ] = phi.two_norm2();
113 typename FunctionType::JacobianRangeType grad;
114 function_.jacobian( x, grad );
115 for(
int i = 0; i < dimRange; ++i )
116 ret[ 0 ] += grad[ i ].two_norm2();
120 const FunctionType &function_;
128 template<
class Gr
idPart >
129 inline H1Norm< GridPart >::H1Norm (
const GridPartType &gridPart,
const unsigned int order,
const bool communicate )
130 : BaseType( gridPart ),
132 communicate_( communicate )
136 template<
class Gr
idPart >
137 template<
class DiscreteFunctionType,
class PartitionSet >
138 inline typename Dune::FieldTraits< typename DiscreteFunctionType::RangeFieldType >::real_type
142 typedef typename Dune::FieldTraits< RangeFieldType >::real_type RealType;
143 typedef FieldVector< RealType, 1 > ReturnType ;
150 sum = comm().sum( sum[ 0 ] );
154 return sqrt( sum[ 0 ] );
157 template<
class Gr
idPart >
158 template<
class UDiscreteFunctionType,
class VDiscreteFunctionType,
class PartitionSet >
159 inline typename Dune::FieldTraits< typename UDiscreteFunctionType::RangeFieldType >::real_type
160 H1Norm< GridPart >::distance (
const UDiscreteFunctionType &u,
161 const VDiscreteFunctionType &v,
164 typedef typename UDiscreteFunctionType::RangeFieldType RangeFieldType;
165 typedef typename Dune::FieldTraits< RangeFieldType >::real_type RealType;
166 typedef FieldVector< RealType, 1 > ReturnType ;
173 sum = comm().sum( sum[ 0 ] );
177 return sqrt( sum[ 0 ] );
180 template<
class Gr
idPart >
181 template<
class ULocalFunctionType,
class VLocalFunctionType,
class ReturnType >
183 H1Norm< GridPart >::distanceLocal (
const EntityType &entity,
unsigned int order,
const ULocalFunctionType &uLocal,
const VLocalFunctionType &vLocal, ReturnType &sum )
const
185 typedef typename L2Norm< GridPart >::template FunctionDistance< ULocalFunctionType, VLocalFunctionType > LocalDistanceType;
187 IntegratorType integrator( order );
189 LocalDistanceType dist( uLocal, vLocal );
190 FunctionJacobianSquare< LocalDistanceType > dist2( dist );
192 integrator.integrateAdd( entity, dist2, sum );
196 template<
class Gr
idPart >
197 template<
class LocalFunctionType,
class ReturnType >
199 H1Norm< GridPart >::normLocal (
const EntityType &entity,
unsigned int order,
const LocalFunctionType &uLocal, ReturnType &sum )
const
202 IntegratorType integrator( order );
204 FunctionJacobianSquare< LocalFunctionType > uLocal2( uLocal );
206 integrator.integrateAdd( entity, uLocal2, sum );
DiscreteFunctionSpaceType::RangeFieldType RangeFieldType
type of range field (usually a float type)
Definition: discretefunction.hh:623
forward declaration
Definition: discretefunction.hh:51
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition: hybridutilities.hh:256
constexpr Interior interior
PartitionSet for the interior partition.
Definition: partitionset.hh:271
Dune namespace.
Definition: alignedallocator.hh:13