2#ifndef DUNE_PDELAB_LOCALOPERATOR_CONVECTIONDIFFUSIONFEM_HH
3#define DUNE_PDELAB_LOCALOPERATOR_CONVECTIONDIFFUSIONFEM_HH
10#include<dune/geometry/referenceelements.hh>
12#include<dune/pdelab/common/quadraturerules.hh>
13#include<dune/pdelab/localoperator/pattern.hh>
14#include<dune/pdelab/localoperator/flags.hh>
15#include<dune/pdelab/localoperator/idefault.hh>
16#include<dune/pdelab/localoperator/defaultimp.hh>
17#include<dune/pdelab/finiteelement/localbasiscache.hh>
19#include"convectiondiffusionparameter.hh"
38 template<
typename T,
typename FiniteElementMap>
50 enum { doPatternVolume =
true };
53 enum { doAlphaVolume =
true };
54 enum { doAlphaBoundary =
true };
57 : param(param_), intorderadd(intorderadd_)
62 template<
typename EG,
typename LFSU,
typename X,
typename LFSV,
typename R>
63 void alpha_volume (
const EG& eg,
const LFSU& lfsu,
const X& x,
const LFSV& lfsv, R& r)
const
66 using RF =
typename LFSU::Traits::FiniteElementType::
67 Traits::LocalBasisType::Traits::RangeFieldType;
68 using size_type =
typename LFSU::Traits::SizeType;
71 const int dim = EG::Entity::dimension;
74 const auto& cell = eg.entity();
77 auto geo = eg.geometry();
81 auto localcenter = ref_el.position(0,0);
82 auto tensor = param.A(cell,localcenter);
85 std::vector<Dune::FieldVector<RF,dim> > gradphi(lfsu.size());
90 typename EG::Geometry::JacobianInverseTransposed jac;
93 auto intorder = intorderadd+2*lfsu.finiteElement().localBasis().order();
94 for (
const auto& ip : quadratureRule(geo,intorder))
97 if (!Impl::permeabilityIsConstantPerCell<T>(param))
99 tensor = param.A(cell, ip.position());
103 auto& phi = cache.evaluateFunction(ip.position(),lfsu.finiteElement().localBasis());
107 for (size_type i=0; i<lfsu.size(); i++)
108 u += x(lfsu,i)*phi[i];
111 auto& js = cache.evaluateJacobian(ip.position(),lfsu.finiteElement().localBasis());
114 jac = geo.jacobianInverseTransposed(ip.position());
115 for (size_type i=0; i<lfsu.size(); i++)
116 jac.mv(js[i][0],gradphi[i]);
120 for (size_type i=0; i<lfsu.size(); i++)
121 gradu.
axpy(x(lfsu,i),gradphi[i]);
124 tensor.mv(gradu,Agradu);
127 auto b = param.b(cell,ip.position());
128 auto c = param.c(cell,ip.position());
129 auto f = param.f(cell,ip.position());
132 RF factor = ip.weight() * geo.integrationElement(ip.position());
133 for (size_type i=0; i<lfsu.size(); i++)
134 r.accumulate(lfsu,i,( Agradu*gradphi[i] - u*(b*gradphi[i]) + (c*u-f)*phi[i] )*factor);
139 template<
typename EG,
typename LFSU,
typename X,
typename LFSV,
typename M>
140 void jacobian_volume (
const EG& eg,
const LFSU& lfsu,
const X& x,
const LFSV& lfsv,
144 using RF =
typename LFSU::Traits::FiniteElementType::
145 Traits::LocalBasisType::Traits::RangeFieldType;
146 using size_type =
typename LFSU::Traits::SizeType;
149 const int dim = EG::Entity::dimension;
152 const auto& cell = eg.entity();
155 auto geo = eg.geometry();
159 auto localcenter = ref_el.position(0,0);
160 auto tensor = param.A(cell,localcenter);
163 std::vector<Dune::FieldVector<RF,dim> > gradphi(lfsu.size());
164 std::vector<Dune::FieldVector<RF,dim> > Agradphi(lfsu.size());
167 typename EG::Geometry::JacobianInverseTransposed jac;
170 auto intorder = intorderadd+2*lfsu.finiteElement().localBasis().order();
171 for (
const auto& ip : quadratureRule(geo,intorder))
174 if (!Impl::permeabilityIsConstantPerCell<T>(param))
176 tensor = param.A(cell, ip.position());
180 auto& js = cache.evaluateJacobian(ip.position(),lfsu.finiteElement().localBasis());
183 jac = geo.jacobianInverseTransposed(ip.position());
184 for (size_type i=0; i<lfsu.size(); i++)
186 jac.mv(js[i][0],gradphi[i]);
187 tensor.mv(gradphi[i],Agradphi[i]);
191 auto& phi = cache.evaluateFunction(ip.position(),lfsu.finiteElement().localBasis());
194 auto b = param.b(cell,ip.position());
195 auto c = param.c(cell,ip.position());
198 RF factor = ip.weight() * geo.integrationElement(ip.position());
199 for (size_type j=0; j<lfsu.size(); j++)
200 for (size_type i=0; i<lfsu.size(); i++)
201 mat.accumulate(lfsu,i,lfsu,j,( Agradphi[j]*gradphi[i]-phi[j]*(b*gradphi[i])+c*phi[j]*phi[i] )*factor);
206 template<
typename IG,
typename LFSU,
typename X,
typename LFSV,
typename R>
207 void alpha_boundary (
const IG& ig,
208 const LFSU& lfsu_s,
const X& x_s,
const LFSV& lfsv_s,
212 using RF =
typename LFSV::Traits::FiniteElementType::
213 Traits::LocalBasisType::Traits::RangeFieldType;
214 using size_type =
typename LFSV::Traits::SizeType;
217 const auto& cell_inside = ig.inside();
220 auto geo = ig.geometry();
223 auto geo_in_inside = ig.geometryInInside();
227 auto local_face_center = ref_el.position(0,0);
228 auto intersection = ig.intersection();
229 auto bctype = param.bctype(intersection,local_face_center);
232 if (bctype==ConvectionDiffusionBoundaryConditions::Dirichlet)
return;
235 auto intorder = intorderadd+2*lfsu_s.finiteElement().localBasis().order();
236 for (
const auto& ip : quadratureRule(geo,intorder))
239 auto local = geo_in_inside.global(ip.position());
242 auto& phi = cache.evaluateFunction(local,lfsu_s.finiteElement().localBasis());
244 if (bctype==ConvectionDiffusionBoundaryConditions::Neumann)
247 auto j = param.j(intersection,ip.position());
250 auto factor = ip.weight()*geo.integrationElement(ip.position());
251 for (size_type i=0; i<lfsu_s.size(); i++)
252 r_s.accumulate(lfsu_s,i,j*phi[i]*factor);
255 if (bctype==ConvectionDiffusionBoundaryConditions::Outflow)
259 for (size_type i=0; i<lfsu_s.size(); i++)
260 u += x_s(lfsu_s,i)*phi[i];
263 auto b = param.b(cell_inside,local);
264 auto n = ig.unitOuterNormal(ip.position());
267 auto o = param.o(intersection,ip.position());
270 auto factor = ip.weight()*geo.integrationElement(ip.position());
271 for (size_type i=0; i<lfsu_s.size(); i++)
272 r_s.accumulate(lfsu_s,i,( (b*n)*u + o)*phi[i]*factor);
278 template<
typename IG,
typename LFSU,
typename X,
typename LFSV,
typename M>
279 void jacobian_boundary (
const IG& ig,
280 const LFSU& lfsu_s,
const X& x_s,
const LFSV& lfsv_s,
284 using size_type =
typename LFSV::Traits::SizeType;
287 const auto& cell_inside = ig.inside();
290 auto geo = ig.geometry();
293 auto geo_in_inside = ig.geometryInInside();
297 auto local_face_center = ref_el.position(0,0);
298 auto intersection = ig.intersection();
299 auto bctype = param.bctype(intersection,local_face_center);
302 if (bctype==ConvectionDiffusionBoundaryConditions::Dirichlet)
return;
303 if (bctype==ConvectionDiffusionBoundaryConditions::Neumann)
return;
306 auto intorder = intorderadd+2*lfsu_s.finiteElement().localBasis().order();
307 for (
const auto& ip : quadratureRule(geo,intorder))
310 auto local = geo_in_inside.global(ip.position());
313 auto& phi = cache.evaluateFunction(local,lfsu_s.finiteElement().localBasis());
316 auto b = param.b(cell_inside,local);
317 auto n = ig.unitOuterNormal(ip.position());
320 auto factor = ip.weight()*geo.integrationElement(ip.position());
321 for (size_type j=0; j<lfsu_s.size(); j++)
322 for (size_type i=0; i<lfsu_s.size(); i++)
323 mat_s.accumulate(lfsu_s,i,lfsu_s,j,(b*n)*phi[j]*phi[i]*factor);
337 using LocalBasisType =
typename FiniteElementMap::Traits::FiniteElementType::Traits::LocalBasisType;
362 enum { dim = T::Traits::GridViewType::dimension };
364 using Real =
typename T::Traits::RangeFieldType;
365 using BCType =
typename ConvectionDiffusionBoundaryConditions::Type;
369 enum { doPatternVolume =
false };
370 enum { doPatternSkeleton =
false };
373 enum { doAlphaVolume =
true };
374 enum { doAlphaSkeleton =
true };
375 enum { doAlphaBoundary =
true };
383 template<
typename EG,
typename LFSU,
typename X,
typename LFSV,
typename R>
384 void alpha_volume (
const EG& eg,
const LFSU& lfsu,
const X& x,
const LFSV& lfsv, R& r)
const
387 using RF =
typename LFSU::Traits::FiniteElementType::
388 Traits::LocalBasisType::Traits::RangeFieldType;
389 using RangeType =
typename LFSU::Traits::FiniteElementType::
390 Traits::LocalBasisType::Traits::RangeType;
391 using size_type =
typename LFSU::Traits::SizeType;
394 const auto& cell = eg.entity();
397 auto geo = eg.geometry();
400 std::vector<RangeType> phi(lfsu.size());
404 auto intorder = 2*lfsu.finiteElement().localBasis().order();
405 for (
const auto& ip : quadratureRule(geo,intorder))
408 lfsu.finiteElement().localBasis().evaluateFunction(ip.position(),phi);
412 for (size_type i=0; i<lfsu.size(); i++)
413 u += x(lfsu,i)*phi[i];
416 auto c = param.c(cell,ip.position());
419 auto f = param.f(cell,ip.position());
422 auto factor = ip.weight() * geo.integrationElement(ip.position());
423 sum += (f*f-c*c*u*u)*factor;
427 auto h_T = diameter(geo);
428 r.accumulate(lfsv,0,h_T*h_T*sum);
434 template<
typename IG,
typename LFSU,
typename X,
typename LFSV,
typename R>
435 void alpha_skeleton (
const IG& ig,
436 const LFSU& lfsu_s,
const X& x_s,
const LFSV& lfsv_s,
437 const LFSU& lfsu_n,
const X& x_n,
const LFSV& lfsv_n,
438 R& r_s, R& r_n)
const
441 using RF =
typename LFSU::Traits::FiniteElementType::
442 Traits::LocalBasisType::Traits::RangeFieldType;
443 using JacobianType =
typename LFSU::Traits::FiniteElementType::
444 Traits::LocalBasisType::Traits::JacobianType;
445 using size_type =
typename LFSU::Traits::SizeType;
448 const int dim = IG::Entity::dimension;
451 const auto& cell_inside = ig.inside();
452 const auto& cell_outside = ig.outside();
455 auto geo = ig.geometry();
456 auto geo_inside = cell_inside.geometry();
457 auto geo_outside = cell_outside.geometry();
460 auto geo_in_inside = ig.geometryInInside();
461 auto geo_in_outside = ig.geometryInOutside();
466 auto local_inside = ref_el_inside.position(0,0);
467 auto local_outside = ref_el_outside.position(0,0);
468 auto A_s = param.A(cell_inside,local_inside);
469 auto A_n = param.A(cell_outside,local_outside);
472 auto n_F = ig.centerUnitOuterNormal();
479 std::vector<JacobianType> gradphi_s(lfsu_s.size());
480 std::vector<JacobianType> gradphi_n(lfsu_n.size());
481 std::vector<Dune::FieldVector<RF,dim> > tgradphi_s(lfsu_s.size());
482 std::vector<Dune::FieldVector<RF,dim> > tgradphi_n(lfsu_n.size());
487 typename IG::Entity::Geometry::JacobianInverseTransposed jac;
491 auto intorder = 2*lfsu_s.finiteElement().localBasis().order();
492 for (
const auto& ip : quadratureRule(geo,intorder))
495 if (!Impl::permeabilityIsConstantPerCell<T>(param))
498 auto n_F_local = ig.unitOuterNormal(ip.position());
500 A_s = param.A(cell_inside,geo_in_inside.global(ip.position()));
501 A_n = param.A(cell_outside,geo_in_outside.global(ip.position()));
502 A_s.mv(n_F_local,An_F_s);
503 A_n.mv(n_F_local,An_F_n);
507 auto iplocal_s = geo_in_inside.global(ip.position());
508 auto iplocal_n = geo_in_outside.global(ip.position());
511 lfsu_s.finiteElement().localBasis().evaluateJacobian(iplocal_s,gradphi_s);
512 lfsu_n.finiteElement().localBasis().evaluateJacobian(iplocal_n,gradphi_n);
515 jac = geo_inside.jacobianInverseTransposed(iplocal_s);
516 for (size_type i=0; i<lfsu_s.size(); i++) jac.mv(gradphi_s[i][0],tgradphi_s[i]);
517 jac = geo_outside.jacobianInverseTransposed(iplocal_n);
518 for (size_type i=0; i<lfsu_n.size(); i++) jac.mv(gradphi_n[i][0],tgradphi_n[i]);
522 for (size_type i=0; i<lfsu_s.size(); i++)
523 gradu_s.axpy(x_s(lfsu_s,i),tgradphi_s[i]);
525 for (size_type i=0; i<lfsu_n.size(); i++)
526 gradu_n.axpy(x_n(lfsu_n,i),tgradphi_n[i]);
529 auto factor = ip.weight() * geo.integrationElement(ip.position());
530 auto jump = (An_F_s*gradu_s)-(An_F_n*gradu_n);
531 sum += 0.25*jump*jump*factor;
536 auto h_T =
std::max(diameter(geo_inside),diameter(geo_outside));
537 r_s.accumulate(lfsv_s,0,h_T*sum);
538 r_n.accumulate(lfsv_n,0,h_T*sum);
544 template<
typename IG,
typename LFSU,
typename X,
typename LFSV,
typename R>
545 void alpha_boundary (
const IG& ig,
546 const LFSU& lfsu_s,
const X& x_s,
const LFSV& lfsv_s,
550 using RF =
typename LFSU::Traits::FiniteElementType::
551 Traits::LocalBasisType::Traits::RangeFieldType;
552 using JacobianType =
typename LFSU::Traits::FiniteElementType::
553 Traits::LocalBasisType::Traits::JacobianType;
554 using size_type =
typename LFSU::Traits::SizeType;
557 const int dim = IG::Entity::dimension;
560 const auto& cell_inside = ig.inside();
563 auto geo = ig.geometry();
564 auto geo_inside = cell_inside.geometry();
568 auto local_inside = ref_el_inside.position(0,0);
569 auto A_s = param.A(cell_inside,local_inside);
572 auto n_F = ig.centerUnitOuterNormal();
577 auto geo_in_inside = ig.geometryInInside();
581 auto face_local = ref_el_in_inside.position(0,0);
582 auto bctype = param.bctype(ig.intersection(),face_local);
583 if (bctype != ConvectionDiffusionBoundaryConditions::Neumann)
587 std::vector<JacobianType> gradphi_s(lfsu_s.size());
588 std::vector<Dune::FieldVector<RF,dim> > tgradphi_s(lfsu_s.size());
592 typename IG::Entity::Geometry::JacobianInverseTransposed jac;
596 auto intorder = 2*lfsu_s.finiteElement().localBasis().order();
597 for (
const auto& ip : quadratureRule(geo,intorder))
600 if (!Impl::permeabilityIsConstantPerCell<T>(param))
603 auto n_F_local = ig.unitOuterNormal(ip.position());
605 A_s = param.A(cell_inside,geo_in_inside.global(ip.position()));
606 A_s.mv(n_F_local,An_F_s);
610 auto iplocal_s = geo_in_inside.global(ip.position());
613 lfsu_s.finiteElement().localBasis().evaluateJacobian(iplocal_s,gradphi_s);
616 jac = geo_inside.jacobianInverseTransposed(iplocal_s);
617 for (size_type i=0; i<lfsu_s.size(); i++) jac.mv(gradphi_s[i][0],tgradphi_s[i]);
621 for (size_type i=0; i<lfsu_s.size(); i++)
622 gradu_s.axpy(x_s(lfsu_s,i),tgradphi_s[i]);
625 auto j = param.j(ig.intersection(),ip.position());
628 auto factor = ip.weight() * geo.integrationElement(ip.position());
629 auto jump = j+(An_F_s*gradu_s);
630 sum += jump*jump*factor;
635 auto h_T = diameter(geo_inside);
636 r_s.accumulate(lfsv_s,0,h_T*sum);
643 typename GEO::ctype diameter (
const GEO& geo)
const
645 using DF =
typename GEO::ctype;
647 const int dim = GEO::coorddimension;
648 for (
int i=0; i<geo.corners(); i++)
651 for (
int j=i+1; j<geo.corners(); j++)
684 enum { dim = T::Traits::GridViewType::dimension };
686 using Real =
typename T::Traits::RangeFieldType;
687 using BCType =
typename ConvectionDiffusionBoundaryConditions::Type;
691 enum { doPatternVolume =
false };
692 enum { doPatternSkeleton =
false };
695 enum { doAlphaVolume =
true };
700 : param(param_), time(time_), dt(dt_), cmax(0)
704 template<
typename EG,
typename LFSU,
typename X,
typename LFSV,
typename R>
705 void alpha_volume (
const EG& eg,
const LFSU& lfsu,
const X& x,
const LFSV& lfsv, R& r)
const
708 using RF =
typename LFSU::Traits::FiniteElementType::
709 Traits::LocalBasisType::Traits::RangeFieldType;
710 using RangeType =
typename LFSU::Traits::FiniteElementType::
711 Traits::LocalBasisType::Traits::RangeType;
712 using size_type =
typename LFSU::Traits::SizeType;
715 const auto& cell = eg.entity();
718 auto geo = eg.geometry();
721 std::vector<RangeType> phi(lfsu.size());
728 auto intorder = 2*lfsu.finiteElement().localBasis().order();
729 for (
const auto& ip : quadratureRule(geo,intorder))
732 lfsu.finiteElement().localBasis().evaluateFunction(ip.position(),phi);
736 for (size_type i=0; i<lfsu.size(); i++)
737 u += x(lfsu,i)*phi[i];
740 auto factor = ip.weight() * geo.integrationElement(ip.position());
745 auto f_down = param.f(cell,ip.position());
746 param.setTime(time+0.5*dt);
747 auto f_mid = param.f(cell,ip.position());
748 param.setTime(time+dt);
749 auto f_up = param.f(cell,ip.position());
750 auto f_average = (1.0/6.0)*f_down + (2.0/3.0)*f_mid + (1.0/6.0)*f_up;
753 fsum_down += (f_down-f_average)*(f_down-f_average)*factor;
754 fsum_mid += (f_mid-f_average)*(f_mid-f_average)*factor;
755 fsum_up += (f_up-f_average)*(f_up-f_average)*factor;
759 auto h_T = diameter(geo);
760 r.accumulate(lfsv,0,(h_T*h_T/dt)*sum);
761 r.accumulate(lfsv,0,h_T*h_T * dt*((1.0/6.0)*fsum_down+(2.0/3.0)*fsum_mid+(1.0/6.0)*fsum_up) );
769 double getCmax ()
const
781 typename GEO::ctype diameter (
const GEO& geo)
const
783 using DF =
typename GEO::ctype;
785 const int dim = GEO::coorddimension;
786 for (
int i=0; i<geo.corners(); i++)
789 for (
int j=i+1; j<geo.corners(); j++)
802 template<
typename T,
typename EG>
803 class CD_RHS_LocalAdapter
806 CD_RHS_LocalAdapter (
const T& t_,
const EG& eg_) : t(t_), eg(eg_)
809 template<
typename X,
typename Y>
810 inline void evaluate (
const X& x, Y& y)
const
812 y[0] = t.f(eg.entity(),x);
840 enum { dim = T::Traits::GridViewType::dimension };
842 using Real =
typename T::Traits::RangeFieldType;
843 using BCType =
typename ConvectionDiffusionBoundaryConditions::Type;
847 enum { doPatternVolume =
false };
848 enum { doPatternSkeleton =
false };
851 enum { doAlphaVolume =
true };
852 enum { doAlphaBoundary =
true };
857 : param(param_), time(time_), dt(dt_)
861 template<
typename EG,
typename LFSU,
typename X,
typename LFSV,
typename R>
862 void alpha_volume (
const EG& eg,
const LFSU& lfsu,
const X& x,
const LFSV& lfsv, R& r)
const
865 using RF =
typename LFSU::Traits::FiniteElementType::
866 Traits::LocalBasisType::Traits::RangeFieldType;
867 using RangeType =
typename LFSU::Traits::FiniteElementType::
868 Traits::LocalBasisType::Traits::RangeType;
869 using size_type =
typename LFSU::Traits::SizeType;
870 using JacobianType =
typename LFSU::Traits::FiniteElementType::
871 Traits::LocalBasisType::Traits::JacobianType;
874 const int dim = EG::Geometry::mydimension;
877 auto geo = eg.geometry();
880 CD_RHS_LocalAdapter<T,EG> f_adapter(param,eg);
881 std::vector<RF> f_up, f_down, f_mid;
883 lfsu.finiteElement().localInterpolation().interpolate(f_adapter,f_down);
884 param.setTime(time+0.5*dt);
885 lfsu.finiteElement().localInterpolation().interpolate(f_adapter,f_mid);
886 param.setTime(time+dt);
887 lfsu.finiteElement().localInterpolation().interpolate(f_adapter,f_up);
890 std::vector<JacobianType> js(lfsu.size());
891 std::vector<Dune::FieldVector<RF,dim> > gradphi(lfsu.size());
899 typename EG::Geometry::JacobianInverseTransposed jac;
904 RF fsum_grad_up(0.0);
905 RF fsum_grad_mid(0.0);
906 RF fsum_grad_down(0.0);
907 auto intorder = 2*lfsu.finiteElement().localBasis().order();
908 for (
const auto& ip : quadratureRule(geo,intorder))
911 std::vector<RangeType> phi(lfsu.size());
912 lfsu.finiteElement().localBasis().evaluateFunction(ip.position(),phi);
916 for (size_type i=0; i<lfsu.size(); i++)
917 u += x(lfsu,i)*phi[i];
920 auto factor = ip.weight() * geo.integrationElement(ip.position());
924 lfsu.finiteElement().localBasis().evaluateJacobian(ip.position(),js);
927 jac = geo.jacobianInverseTransposed(ip.position());
928 for (size_type i=0; i<lfsu.size(); i++)
929 jac.mv(js[i][0],gradphi[i]);
933 for (size_type i=0; i<lfsu.size(); i++)
934 gradu.axpy(x(lfsu,i),gradphi[i]);
937 sum_grad += (gradu*gradu)*factor;
941 for (size_type i=0; i<lfsu.size(); i++) gradf_down.axpy(f_down[i],gradphi[i]);
943 for (size_type i=0; i<lfsu.size(); i++) gradf_mid.axpy(f_mid[i],gradphi[i]);
945 for (size_type i=0; i<lfsu.size(); i++) gradf_up.axpy(f_up[i],gradphi[i]);
947 for (size_type i=0; i<lfsu.size(); i++)
948 gradf_average.axpy((1.0/6.0)*f_down[i]+(2.0/3.0)*f_mid[i]+(1.0/6.0)*f_up[i],gradphi[i]);
951 gradf_down -= gradf_average;
952 fsum_grad_down += (gradf_down*gradf_down)*factor;
953 gradf_mid -= gradf_average;
954 fsum_grad_mid += (gradf_mid*gradf_mid)*factor;
955 gradf_up -= gradf_average;
956 fsum_grad_up += (gradf_up*gradf_up)*factor;
960 auto h_T = diameter(geo);
961 r.accumulate(lfsv,0,dt * sum_grad);
962 r.accumulate(lfsv,0,dt*dt * dt*((1.0/6.0)*fsum_grad_down+(2.0/3.0)*fsum_grad_mid+(1.0/6.0)*fsum_grad_up));
967 template<
typename IG,
typename LFSU,
typename X,
typename LFSV,
typename R>
968 void alpha_boundary (
const IG& ig,
969 const LFSU& lfsu_s,
const X& x_s,
const LFSV& lfsv_s,
973 using RF =
typename LFSU::Traits::FiniteElementType::
974 Traits::LocalBasisType::Traits::RangeFieldType;
977 const auto& cell_inside = ig.inside();
980 auto geo = ig.geometry();
981 auto geo_inside = cell_inside.geometry();
984 auto geo_in_inside = ig.geometryInInside();
988 auto face_local = ref_el_in_inside.position(0,0);
989 auto bctype = param.bctype(ig.intersection(),face_local);
990 if (bctype != ConvectionDiffusionBoundaryConditions::Neumann)
996 const int intorder = 2*lfsu_s.finiteElement().localBasis().order();
997 for (
const auto& ip : quadratureRule(geo,intorder))
1000 param.setTime(time);
1001 auto j_down = param.j(ig.intersection(),ip.position());
1002 param.setTime(time+0.5*dt);
1003 auto j_mid = param.j(ig.intersection(),ip.position());
1004 param.setTime(time+dt);
1005 auto j_up = param.j(ig.intersection(),ip.position());
1008 auto factor = ip.weight() * geo.integrationElement(ip.position());
1009 sum_down += (j_down-j_mid)*(j_down-j_mid)*factor;
1010 sum_up += (j_up-j_mid)*(j_up-j_mid)*factor;
1015 auto h_T = diameter(geo_inside);
1016 r_s.accumulate(lfsv_s,0,(h_T+dt*dt/h_T)*dt*0.5*(sum_down+sum_up));
1025 typename GEO::ctype diameter (
const GEO& geo)
const
1027 using DF =
typename GEO::ctype;
1029 const int dim = GEO::coorddimension;
1030 for (
int i=0; i<geo.corners(); i++)
1033 for (
int j=i+1; j<geo.corners(); j++)
FieldTraits< value_type >::real_type two_norm() const
two norm sqrt(sum over squared values of entries)
Definition: densevector.hh:641
derived_type & axpy(const field_type &a, const DenseVector< Other > &x)
vector space axpy operation ( *this += a x )
Definition: densevector.hh:575
vector space out of a tensor product of fields.
Definition: fvector.hh:91
Definition: convectiondiffusionfem.hh:361
ConvectionDiffusionFEMResidualEstimator(T ¶m_)
constructor: pass parameter object
Definition: convectiondiffusionfem.hh:378
Definition: convectiondiffusionfem.hh:47
void setTime(double t)
set time in parameter class
Definition: convectiondiffusionfem.hh:329
Definition: convectiondiffusionfem.hh:683
ConvectionDiffusionTemporalResidualEstimator1(T ¶m_, double time_, double dt_)
constructor: pass parameter object
Definition: convectiondiffusionfem.hh:699
Definition: convectiondiffusionfem.hh:839
ConvectionDiffusionTemporalResidualEstimator(T ¶m_, double time_, double dt_)
constructor: pass parameter object
Definition: convectiondiffusionfem.hh:856
sparsity pattern generator
Definition: pattern.hh:14
Default class for additional methods in instationary local operators.
Definition: idefault.hh:90
store values of basis functions and gradients in a cache
Definition: localbasiscache.hh:18
Default flags for all local operators.
Definition: flags.hh:19
Implements linear and nonlinear versions of jacobian_apply_boundary() based on alpha_boundary()
Definition: numericaljacobianapply.hh:287
Implements linear and nonlinear versions of jacobian_apply_volume() based on alpha_volume()
Definition: numericaljacobianapply.hh:34
Implement jacobian_boundary() based on alpha_boundary()
Definition: numericaljacobian.hh:251
Implement jacobian_volume() based on alpha_volume()
Definition: numericaljacobian.hh:32
Definition of the DUNE_NO_DEPRECATED_* macros.
unspecified value type referenceElement(T &&... t)
Returns a reference element for the objects t....
constexpr auto max
Function object that returns the greater of the given values.
Definition: hybridutilities.hh:484
Dune namespace.
Definition: alignedallocator.hh:13