2 #ifndef DUNE_PDELAB_CONVECTIONDIFFUSION_HH
3 #define DUNE_PDELAB_CONVECTIONDIFFUSION_HH
7 #include<dune/common/exceptions.hh>
8 #include<dune/common/fvector.hh>
9 #include<dune/common/static_assert.hh>
10 #include<dune/geometry/type.hh>
12 #include<dune/geometry/referenceelements.hh>
13 #include<dune/geometry/quadraturerules.hh>
39 template<
typename GV,
typename RF>
56 typedef Dune::FieldVector<DomainFieldType,dimDomain>
DomainType;
65 typedef Dune::FieldVector<RF,GV::dimensionworld>
RangeType;
68 typedef Dune::FieldMatrix<RangeFieldType,dimDomain,dimDomain>
PermTensorType;
71 typedef typename GV::Traits::template Codim<0>::Entity
ElementType;
76 template<
class T,
class Imp>
83 typename Traits::RangeFieldType
84 f (
const typename Traits::ElementType&
e,
const typename Traits::DomainType& x,
85 typename Traits::RangeFieldType u)
const
87 return asImp().f(e,x,u);
91 typename Traits::RangeFieldType
92 w (
const typename Traits::ElementType&
e,
const typename Traits::DomainType& x,
93 typename Traits::RangeFieldType u)
const
95 return asImp().w(e,x,u);
99 typename Traits::RangeFieldType
100 v (
const typename Traits::ElementType&
e,
const typename Traits::DomainType& x,
101 typename Traits::RangeFieldType u)
const
103 return asImp().v(e,x,u);
107 typename Traits::PermTensorType
108 D (
const typename Traits::ElementType&
e,
const typename Traits::DomainType& x)
const
110 return asImp().D(e,x);
114 typename Traits::RangeType
115 q (
const typename Traits::ElementType&
e,
const typename Traits::DomainType& x,
116 typename Traits::RangeFieldType u)
const
118 return asImp().q(e,x,u);
123 const I & intersection,
124 const Dune::FieldVector<typename I::ctype, I::dimension-1> & coord
127 return asImp().isDirichlet( intersection, coord );
131 typename Traits::RangeFieldType
132 g (
const typename Traits::ElementType&
e,
const typename Traits::DomainType& x)
const
134 return asImp().g(e,x);
140 typename Traits::RangeFieldType
141 j (
const typename Traits::ElementType&
e,
const typename Traits::DomainType& x,
142 typename Traits::RangeFieldType u)
const
144 return asImp().j(e,x);
148 Imp& asImp () {
return static_cast<Imp &
> (*this);}
149 const Imp& asImp ()
const {
return static_cast<const Imp &
>(*this);}
161 const typename T::Traits::GridViewType gv;
172 const I & intersection,
173 const Dune::FieldVector<typename I::ctype, I::dimension-1> & coord
176 return t.isDirichlet( intersection, coord );
187 :
public GridFunctionBase<Dune::PDELab::GridFunctionTraits<typename T::Traits::GridViewType,
188 typename T::Traits::RangeFieldType,
189 1,Dune::FieldVector<typename T::Traits::RangeFieldType,1> >
190 ,DirichletBoundaryCondition_CD<T> >
194 typename T::Traits::RangeFieldType,
195 1,Dune::FieldVector<typename T::Traits::RangeFieldType,1> >
Traits;
243 : param(param_), intorder(intorder_)
247 template<
typename EG,
typename LFSU,
typename X,
typename LFSV,
typename R>
248 void alpha_volume (
const EG&
eg,
const LFSU& lfsu,
const X& x,
const LFSV& lfsv, R& r)
const
251 typedef typename LFSU::Traits::FiniteElementType::
252 Traits::LocalBasisType::Traits::DomainFieldType DF;
253 typedef typename LFSU::Traits::FiniteElementType::
254 Traits::LocalBasisType::Traits::RangeFieldType RF;
255 typedef typename LFSU::Traits::FiniteElementType::
256 Traits::LocalBasisType::Traits::JacobianType JacobianType;
257 typedef typename LFSU::Traits::FiniteElementType::
258 Traits::LocalBasisType::Traits::RangeType RangeType;
260 typedef typename LFSU::Traits::SizeType size_type;
263 const int dim = EG::Geometry::dimension;
266 Dune::GeometryType gt = eg.geometry().type();
267 const Dune::QuadratureRule<DF,dim>& rule = Dune::QuadratureRules<DF,dim>::rule(gt,intorder);
270 typename T::Traits::PermTensorType tensor;
271 Dune::FieldVector<DF,dim> localcenter = Dune::ReferenceElements<DF,dim>::general(gt).position(0,0);
272 tensor = param.D(eg.entity(),localcenter);
275 std::vector<typename T::Traits::RangeFieldType>
w(lfsu.size());
276 for (size_type i=0; i<lfsu.size(); i++)
277 w[i] = param.w(eg.entity(),localcenter,x(lfsu,i));
280 for (
typename Dune::QuadratureRule<DF,dim>::const_iterator it=rule.begin(); it!=rule.end(); ++it)
283 std::vector<RangeType> phi(lfsu.size());
284 lfsu.finiteElement().localBasis().evaluateFunction(it->position(),phi);
288 for (size_type i=0; i<lfsu.size(); i++)
292 typename T::Traits::RangeFieldType
f = param.f(eg.entity(),it->position(),u);
295 typename T::Traits::RangeType q = param.q(eg.entity(),it->position(),u);
298 std::vector<JacobianType> js(lfsu.size());
299 lfsu.finiteElement().localBasis().evaluateJacobian(it->position(),js);
302 const typename EG::Geometry::JacobianInverseTransposed jac
303 = eg.geometry().jacobianInverseTransposed(it->position());
304 std::vector<Dune::FieldVector<RF,dim> > gradphi(lfsu.size());
305 for (size_type i=0; i<lfsu.size(); i++)
308 jac.umv(js[i][0],gradphi[i]);
312 Dune::FieldVector<RF,dim> vgradu(0.0);
313 for (size_type i=0; i<lfsu.size(); i++)
314 vgradu.axpy(
w[i],gradphi[i]);
315 vgradu *= param.v(eg.entity(),it->position(),u);
318 Dune::FieldVector<RF,dim> Dvgradu(0.0);
319 tensor.umv(vgradu,Dvgradu);
322 RF factor = it->weight() * eg.geometry().integrationElement(it->position());
323 for (size_type i=0; i<lfsu.size(); i++)
324 r.accumulate(lfsu,i,( Dvgradu*gradphi[i] - q*gradphi[i] - f*phi[i] )*factor);
329 template<
typename IG,
typename LFSU,
typename X,
typename LFSV,
typename R>
331 const LFSU& lfsu_s,
const X& x_s,
const LFSV& lfsv_s,
335 typedef typename LFSV::Traits::FiniteElementType::
336 Traits::LocalBasisType::Traits::DomainFieldType DF;
337 typedef typename LFSV::Traits::FiniteElementType::
338 Traits::LocalBasisType::Traits::RangeFieldType RF;
339 typedef typename LFSV::Traits::FiniteElementType::
340 Traits::LocalBasisType::Traits::RangeType RangeType;
342 typedef typename LFSV::Traits::SizeType size_type;
345 const int dim = IG::dimension;
348 Dune::GeometryType gtface = ig.geometryInInside().type();
349 const Dune::QuadratureRule<DF,dim-1>& rule = Dune::QuadratureRules<DF,dim-1>::rule(gtface,intorder);
352 Dune::FieldVector<DF,dim-1> facecenterlocal = Dune::ReferenceElements<DF,dim-1>::general(gtface).position(0,0);
353 Dune::FieldVector<DF,dim> facecenterinelement = ig.geometryInInside().global( facecenterlocal );
354 std::vector<typename T::Traits::RangeFieldType>
w(lfsu_s.size());
355 for (size_type i=0; i<lfsu_s.size(); i++)
356 w[i] = param.w(*(ig.inside()),facecenterinelement,x_s(lfsu_s,i));
359 for (
typename Dune::QuadratureRule<DF,dim-1>::const_iterator it=rule.begin(); it!=rule.end(); ++it)
363 if( param.isDirichlet( ig.intersection(), it->position() ) )
367 Dune::FieldVector<DF,dim> local = ig.geometryInInside().global(it->position());
370 std::vector<RangeType> phi(lfsv_s.size());
371 lfsv_s.finiteElement().localBasis().evaluateFunction(local,phi);
375 for (size_type i=0; i<lfsu_s.size(); i++)
379 typename T::Traits::RangeFieldType j;
380 j = param.j(*(ig.inside()),local,u);
383 RF factor = it->weight()*ig.geometry().integrationElement(it->position());
384 for (size_type i=0; i<lfsv_s.size(); i++)
385 r_s.accumulate(lfsu_s,i,j*phi[i]*factor);
Dune::FieldVector< RF, GV::dimensionworld > RangeType
range type
Definition: convectiondiffusion.hh:65
traits class for two phase parameter class
Definition: convectiondiffusion.hh:41
Traits::PermTensorType D(const typename Traits::ElementType &e, const typename Traits::DomainType &x) const
tensor diffusion coefficient
Definition: convectiondiffusion.hh:108
GV::Traits::template Codim< 0 >::Entity ElementType
grid types
Definition: convectiondiffusion.hh:71
Traits::RangeFieldType g(const typename Traits::ElementType &e, const typename Traits::DomainType &x) const
Dirichlet boundary condition value.
Definition: convectiondiffusion.hh:132
Definition: convectiondiffusion.hh:236
T Traits
Definition: convectiondiffusion.hh:80
void alpha_volume(const EG &eg, const LFSU &lfsu, const X &x, const LFSV &lfsv, R &r) const
Definition: convectiondiffusion.hh:248
Default flags for all local operators.
Definition: flags.hh:18
Implement jacobian_boundary() based on alpha_boundary()
Definition: defaultimp.hh:251
Dune::FieldVector< DomainFieldType, dimDomain > DomainType
domain type
Definition: convectiondiffusion.hh:56
GV::Traits::template Codim< 0 >::Entity ElementType
codim 0 entity
Definition: function.hh:118
GV GridViewType
the grid view
Definition: convectiondiffusion.hh:44
VTKWriter & w
Definition: function.hh:1102
Traits::RangeFieldType w(const typename Traits::ElementType &e, const typename Traits::DomainType &x, typename Traits::RangeFieldType u) const
nonlinearity under gradient
Definition: convectiondiffusion.hh:92
Definition: common/constraintsparameters.hh:24
Implement jacobian_apply_boundary() based on alpha_boundary()
Definition: defaultimp.hh:538
dimension of the domain
Definition: convectiondiffusion.hh:49
static const int dim
Definition: adaptivity.hh:82
RF RangeFieldType
Export type for range field.
Definition: convectiondiffusion.hh:62
Dune::FieldVector< GV::Grid::ctype, GV::dimension > DomainType
domain type in dim-size coordinates
Definition: function.hh:49
Definition: convectiondiffusion.hh:240
Traits::RangeFieldType v(const typename Traits::ElementType &e, const typename Traits::DomainType &x, typename Traits::RangeFieldType u) const
scalar nonlinearity in diffusion coefficient
Definition: convectiondiffusion.hh:100
base class for parameter class
Definition: convectiondiffusion.hh:77
Dune::FieldMatrix< RangeFieldType, dimDomain, dimDomain > PermTensorType
permeability tensor type
Definition: convectiondiffusion.hh:68
Implement jacobian_volume() based on alpha_volume()
Definition: defaultimp.hh:32
Traits::RangeFieldType j(const typename Traits::ElementType &e, const typename Traits::DomainType &x, typename Traits::RangeFieldType u) const
Neumann boundary condition.
Definition: convectiondiffusion.hh:141
Dune::PDELab::GridFunctionTraits< typename T::Traits::GridViewType, typename T::Traits::RangeFieldType, 1, Dune::FieldVector< typename T::Traits::RangeFieldType, 1 > > Traits
Definition: convectiondiffusion.hh:195
GV::Grid::ctype DomainFieldType
Export type for domain field.
Definition: convectiondiffusion.hh:53
R RangeType
range type
Definition: function.hh:61
GV::Intersection IntersectionType
Definition: convectiondiffusion.hh:72
const IG & ig
Definition: common/constraints.hh:146
leaf of a function tree
Definition: function.hh:577
void setTime(double t)
set time in parameter class
Definition: convectiondiffusion.hh:390
bool isDirichlet(const I &intersection, const Dune::FieldVector< typename I::ctype, I::dimension-1 > &coord) const
Definition: convectiondiffusion.hh:122
DirichletBoundaryCondition_CD(const typename Traits::GridViewType &g_, const T &t_)
constructor
Definition: convectiondiffusion.hh:198
Definition: convectiondiffusion.hh:225
BCTypeParam_CD(const typename T::Traits::GridViewType &gv_, const T &t_)
Definition: convectiondiffusion.hh:165
Default class for additional methods in instationary local operators.
Definition: idefault.hh:89
const F & f
Definition: common/constraints.hh:145
traits class holding the function signature, same as in local function
Definition: function.hh:176
Dune::FieldVector< DomainFieldType, dimDomain-1 > IntersectionDomainType
domain type
Definition: convectiondiffusion.hh:59
sparsity pattern generator
Definition: pattern.hh:14
void evaluate(const typename Traits::ElementType &e, const typename Traits::DomainType &x, typename Traits::RangeType &y) const
Evaluate the GridFunction at given position.
Definition: convectiondiffusion.hh:201
Implement jacobian_apply_volume() based on alpha_volume()
Definition: defaultimp.hh:321
Definition: convectiondiffusion.hh:158
GV GridViewType
The type of the grid view the function lives on.
Definition: function.hh:115
const EG & eg
Definition: common/constraints.hh:277
void alpha_boundary(const IG &ig, const LFSU &lfsu_s, const X &x_s, const LFSV &lfsv_s, R &r_s) const
Definition: convectiondiffusion.hh:330
ConvectionDiffusion(T ¶m_, int intorder_=2)
Definition: convectiondiffusion.hh:242
Definition: convectiondiffusion.hh:239
Traits::RangeFieldType f(const typename Traits::ElementType &e, const typename Traits::DomainType &x, typename Traits::RangeFieldType u) const
source/reaction term
Definition: convectiondiffusion.hh:84
bool isDirichlet(const I &intersection, const Dune::FieldVector< typename I::ctype, I::dimension-1 > &coord) const
Definition: convectiondiffusion.hh:171
Definition: convectiondiffusion.hh:186
Traits::RangeType q(const typename Traits::ElementType &e, const typename Traits::DomainType &x, typename Traits::RangeFieldType u) const
nonlinear flux vector
Definition: convectiondiffusion.hh:115
const E & e
Definition: interpolate.hh:172
const Traits::GridViewType & getGridView() const
Definition: convectiondiffusion.hh:208