2#ifndef DUNE_PDELAB_LOCALOPERATOR_DIFFUSIONMIXED_HH
3#define DUNE_PDELAB_LOCALOPERATOR_DIFFUSIONMIXED_HH
13#include<dune/geometry/referenceelements.hh>
15#include<dune/pdelab/common/quadraturerules.hh>
17#include"defaultimp.hh"
20#include "convectiondiffusionparameter.hh"
36 template<
typename PARAM>
37 class DiffusionMixed :
public NumericalJacobianApplyVolume<DiffusionMixed<PARAM> >,
38 public NumericalJacobianVolume<DiffusionMixed<PARAM> >,
39 public FullVolumePattern,
40 public LocalOperatorDefaultFlags
43 using BCType =
typename ConvectionDiffusionBoundaryConditions::Type;
47 enum { doPatternVolume =
true };
50 enum { doAlphaVolume =
true };
51 enum { doLambdaVolume =
true };
52 enum { doLambdaBoundary =
true };
54 DiffusionMixed (
const PARAM& param_,
64 template<
typename EG,
typename LFSU,
typename X,
typename LFSV,
typename R>
65 void alpha_volume (
const EG& eg,
const LFSU& lfsu,
const X& x,
const LFSV& lfsv, R& r)
const
68 using VelocitySpace =
typename LFSU::template Child<0>::Type;
69 using PressureSpace =
typename LFSU::template Child<1>::Type;
70 using DF =
typename VelocitySpace::Traits::FiniteElementType::
71 Traits::LocalBasisType::Traits::DomainFieldType;
72 using RF =
typename VelocitySpace::Traits::FiniteElementType::
73 Traits::LocalBasisType::Traits::RangeFieldType;
74 using VelocityJacobianType =
typename VelocitySpace::Traits::FiniteElementType::
75 Traits::LocalBasisType::Traits::JacobianType;
76 using VelocityRangeType =
typename VelocitySpace::Traits::FiniteElementType::
77 Traits::LocalBasisType::Traits::RangeType;
78 using PressureRangeType =
typename PressureSpace::Traits::FiniteElementType::
79 Traits::LocalBasisType::Traits::RangeType;
83 const auto& velocityspace =
child(lfsu,
_0);
84 const auto& pressurespace = lfsu.template child<1>();
87 const int dim = EG::Geometry::mydimension;
90 const auto& cell = eg.entity();
93 auto geo = eg.geometry();
98 auto jac = geo.jacobianInverseTransposed(pos);
100 auto det = geo.integrationElement(pos);
104 auto localcenter = ref_el.position(0,0);
105 auto tensor = param.A(cell,localcenter);
109 std::vector<VelocityRangeType> vbasis(velocityspace.size());
110 std::vector<VelocityRangeType> vtransformedbasis(velocityspace.size());
111 VelocityRangeType sigma;
112 VelocityRangeType Kinvsigma;
113 std::vector<VelocityJacobianType> vjacbasis(velocityspace.size());
114 std::vector<PressureRangeType> pbasis(pressurespace.size());
115 std::vector<RF> divergence(velocityspace.size(),0.0);
120 for (
const auto& ip : quadratureRule(geo,qorder_v))
123 velocityspace.finiteElement().localBasis().evaluateFunction(ip.position(),vbasis);
126 for (std::size_t i=0; i<velocityspace.size(); i++)
128 vtransformedbasis[i] = 0.0;
129 jac.umtv(vbasis[i],vtransformedbasis[i]);
134 for (std::size_t i=0; i<velocityspace.size(); i++)
135 sigma.axpy(x(velocityspace,i),vtransformedbasis[i]);
138 tensor.mv(sigma,Kinvsigma);
141 auto factor = ip.weight() / det;
142 for (std::size_t i=0; i<velocityspace.size(); i++)
143 r.accumulate(velocityspace,i,(Kinvsigma*vtransformedbasis[i])*factor);
148 for (
const auto& ip : quadratureRule(geo,qorder_p))
151 velocityspace.finiteElement().localBasis().evaluateJacobian(ip.position(),vjacbasis);
152 pressurespace.finiteElement().localBasis().evaluateFunction(ip.position(),pbasis);
157 for (std::size_t i=0; i<pressurespace.size(); i++)
158 u.axpy(x(pressurespace,i),pbasis[i]);
161 auto a0value = param.c(cell,ip.position());
164 RF factor = ip.weight();
165 for (std::size_t i=0; i<pressurespace.size(); i++)
166 r.accumulate(pressurespace,i,-a0value*u*pbasis[i]*factor);
169 for (std::size_t i=0; i<velocityspace.size(); i++){
171 for (
int j=0; j<dim; j++)
172 divergence[i] += vjacbasis[i][j][j];
176 for (std::size_t i=0; i<velocityspace.size(); i++)
177 r.accumulate(velocityspace,i,-u*divergence[i]*factor);
180 RF divergencesigma = 0.0;
181 for (std::size_t i=0; i<velocityspace.size(); i++)
182 divergencesigma += x(velocityspace,i)*divergence[i];
185 for (std::size_t i=0; i<pressurespace.size(); i++)
186 r.accumulate(pressurespace,i,-divergencesigma*pbasis[i]*factor);
191 template<
typename EG,
typename LFSV,
typename R>
192 void lambda_volume (
const EG& eg,
const LFSV& lfsv, R& r)
const
195 using PressureSpace =
typename LFSV::template Child<1>::Type;
196 using PressureRangeType =
typename PressureSpace::Traits::FiniteElementType::
197 Traits::LocalBasisType::Traits::RangeType;
201 const auto& pressurespace =
child(lfsv,
_1);
204 const auto& cell = eg.entity();
207 auto geo = eg.geometry();
210 std::vector<PressureRangeType> pbasis(pressurespace.size());
213 for (
const auto& ip : quadratureRule(geo,qorder_p))
216 pressurespace.finiteElement().localBasis().evaluateFunction(ip.position(),pbasis);
219 auto y = param.f(cell,ip.position());
222 auto factor = ip.weight() * geo.integrationElement(ip.position());
223 for (std::size_t i=0; i<pressurespace.size(); i++)
224 r.accumulate(pressurespace,i,y*pbasis[i]*factor);
229 template<
typename IG,
typename LFSV,
typename R>
230 void lambda_boundary (
const IG& ig,
const LFSV& lfsv, R& r)
const
233 using VelocitySpace =
typename LFSV::template Child<0>::Type;
234 using DF =
typename VelocitySpace::Traits::FiniteElementType::
235 Traits::LocalBasisType::Traits::DomainFieldType;
236 using VelocityRangeType =
typename VelocitySpace::Traits::FiniteElementType::
237 Traits::LocalBasisType::Traits::RangeType;
241 const auto& velocityspace =
child(lfsv,
_0);
244 const int dim = IG::Entity::dimension;
247 const auto& cell_inside = ig.inside();
250 auto geo = ig.geometry();
251 auto geo_inside = cell_inside.geometry();
254 auto geo_in_inside = ig.geometryInInside();
259 typename IG::Entity::Geometry::JacobianInverseTransposed jac;
260 jac = geo_inside.jacobianInverseTransposed(pos);
262 auto det = geo_inside.integrationElement(pos);
265 std::vector<VelocityRangeType> vbasis(velocityspace.size());
266 std::vector<VelocityRangeType> vtransformedbasis(velocityspace.size());
269 for (
const auto& ip : quadratureRule(geo,qorder_v))
272 auto bctype = param.bctype(ig.intersection(),ip.position());
275 if (bctype == ConvectionDiffusionBoundaryConditions::Neumann)
279 auto local = geo_in_inside.global(ip.position());
282 velocityspace.finiteElement().localBasis().evaluateFunction(local,vbasis);
285 for (std::size_t i=0; i<velocityspace.size(); i++)
287 vtransformedbasis[i] = 0.0;
288 jac.umtv(vbasis[i],vtransformedbasis[i]);
292 auto y = param.g(cell_inside,local);
295 auto factor = ip.weight()*geo.integrationElement(ip.position())/det;
296 for (std::size_t i=0; i<velocityspace.size(); i++)
297 r.accumulate(velocityspace,i,y*(vtransformedbasis[i]*ig.unitOuterNormal(ip.position()))*factor);
vector space out of a tensor product of fields.
Definition: fvector.hh:91
A few common exception classes.
Implements a matrix constructed from a given type representing a field and compile-time given number ...
Implements a vector constructed from a given type representing a field and a compile-time given size.
constexpr index_constant< 0 > _0
Compile time index with value 0.
Definition: indices.hh:52
constexpr index_constant< 1 > _1
Compile time index with value 1.
Definition: indices.hh:55
unspecified value type referenceElement(T &&... t)
Returns a reference element for the objects t....
Namespace with predefined compile time indices for the range [0,19].
Definition: indices.hh:50
Dune namespace.
Definition: alignedallocator.hh:13
A unique label for each type of element that can occur in a grid.