2 #ifndef DUNE_PDELAB_TRANSPORTCCFV_HH 3 #define DUNE_PDELAB_TRANSPORTCCFV_HH 4 #warning This file is deprecated and will be removed after the Dune-PDELab 2.4 release! Use the local operators from dune/pdelab/localoperator/convectiondiffusionccfv.hh instead! 6 #include<dune/common/fvector.hh> 7 #include<dune/geometry/referenceelements.hh> 11 #include"../common/function.hh" 20 template<
typename GV,
typename RF>
36 typedef Dune::FieldVector<DomainFieldType,dimDomain>
DomainType;
45 typedef Dune::FieldVector<RF,GV::dimensionworld>
RangeType;
48 typedef typename GV::Traits::template Codim<0>::Entity
ElementType;
53 template<
class T,
class Imp>
60 typename Traits::RangeType
61 v (
const typename Traits::ElementType&
e,
const typename Traits::DomainType& x)
const 63 return asImp().v(e,x);
67 typename Traits::RangeFieldType
68 D (
const typename Traits::ElementType&
e,
const typename Traits::DomainType& x)
const 70 return asImp().D(e,x);
74 typename Traits::RangeFieldType
75 q (
const typename Traits::ElementType&
e,
const typename Traits::DomainType& x)
const 77 return asImp().q(e,x);
89 return asImp().bc(is,x);
93 typename Traits::RangeFieldType
94 g (
const typename Traits::ElementType&
e,
const typename Traits::DomainType& x)
const 96 return asImp().g(e,x);
100 typename Traits::RangeFieldType
101 j (
const typename Traits::ElementType&
e,
const typename Traits::DomainType& x)
const 103 return asImp().j(e,x);
107 Imp& asImp () {
return static_cast<Imp &
> (*this);}
108 const Imp& asImp ()
const {
return static_cast<const Imp &
>(*this);}
119 BoundaryGridFunctionTraits<typename T::Traits::GridViewType,int,1,
120 Dune::FieldVector<int,1> >,
121 BoundaryConditionType_Transport<T> >
123 typename T::Traits::GridViewType gv;
155 :
public GridFunctionBase<Dune::PDELab::GridFunctionTraits<typename T::Traits::GridViewType,
156 typename T::Traits::RangeFieldType,
157 1,Dune::FieldVector<typename T::Traits::RangeFieldType,1> >
158 ,DirichletBoundaryCondition_Transport<T> >
162 typename T::Traits::RangeFieldType,
163 1,Dune::FieldVector<typename T::Traits::RangeFieldType,1> >
Traits;
182 typename Traits::GridViewType g;
199 template<
typename TP>
212 enum {
dim = TP::Traits::GridViewType::dimension };
216 enum { doPatternVolume =
true };
217 enum { doPatternSkeleton =
true };
220 enum { doAlphaVolume =
true };
221 enum { doAlphaSkeleton =
true };
222 enum { doAlphaVolumePostSkeleton =
true };
223 enum { doAlphaBoundary =
true };
224 enum { doLambdaVolume =
true };
226 enum { doSkeletonTwoSided =
true };
228 DUNE_DEPRECATED_MSG(
"Deprecated in Dune-PDELab 2.4, use the local operator ConvectionDiffusionCCFV instead!")
235 template<
typename EG,
typename LFSU,
typename X,
typename LFSV,
typename R>
236 void alpha_volume (
const EG& eg,
const LFSU& lfsu,
const X& x,
const LFSV& lfsv, R& r)
const 242 template<
typename EG,
typename LFSU,
typename X,
typename LFSV,
typename M>
251 template<
typename IG,
typename LFSU,
typename X,
typename LFSV,
typename R>
253 const LFSU& lfsu_s,
const X& x_s,
const LFSV& lfsv_s,
254 const LFSU& lfsu_n,
const X& x_n,
const LFSV& lfsv_n,
255 R& r_s, R& r_n)
const 258 typedef typename LFSU::Traits::FiniteElementType::
259 Traits::LocalBasisType::Traits::DomainFieldType DF;
260 typedef typename LFSU::Traits::FiniteElementType::
261 Traits::LocalBasisType::Traits::RangeFieldType RF;
264 const Dune::FieldVector<DF,IG::dimension-1>&
265 face_local = Dune::ReferenceElements<DF,IG::dimension-1>::general(ig.geometry().type()).position(0,0);
266 RF face_volume = ig.geometry().volume();
269 Dune::FieldVector<DF,IG::dimension> face_center_in_element = ig.geometryInInside().global(face_local);
272 typename TP::Traits::RangeType v(tp.v(*(ig.inside()),face_center_in_element));
275 RF vn = v*ig.centerUnitOuterNormal();
279 if (vn>=0) u_upwind = x_s(lfsu_s,0);
else u_upwind = x_n(lfsu_n,0);
280 r_s.accumulate(lfsu_s,0,(u_upwind*vn)*face_volume);
282 cellinflux += vn*face_volume;
285 const Dune::FieldVector<DF,IG::dimension>&
286 inside_local = Dune::ReferenceElements<DF,IG::dimension>::general(ig.inside()->type()).position(0,0);
287 const Dune::FieldVector<DF,IG::dimension>&
288 outside_local = Dune::ReferenceElements<DF,IG::dimension>::general(ig.outside()->type()).position(0,0);
289 typename TP::Traits::RangeFieldType D_inside = tp.D(*(ig.inside()),inside_local);
290 typename TP::Traits::RangeFieldType D_outside = tp.D(*(ig.outside()),outside_local);
291 typename TP::Traits::RangeFieldType D_avg = 2.0/(1.0/(D_inside+1E-30) + 1.0/(D_outside+1E-30));
294 Dune::FieldVector<DF,IG::dimension>
295 inside_global = ig.inside()->geometry().center();
296 Dune::FieldVector<DF,IG::dimension>
297 outside_global = ig.outside()->geometry().center();
298 inside_global -= outside_global;
299 RF distance = inside_global.two_norm();
303 r_s.accumulate(lfsu_s,0,-(D_avg*(x_n(lfsu_n,0)-x_s(lfsu_s,0))/distance)*face_volume);
307 template<
typename EG,
typename LFSU,
typename X,
typename LFSV,
typename R>
309 const LFSV& lfsv, R& r)
const 312 typedef typename LFSU::Traits::FiniteElementType::
313 Traits::LocalBasisType::Traits::DomainFieldType DF;
314 const int dim = EG::Geometry::dimension;
316 if (!first_stage)
return;
319 const Dune::FieldVector<DF,dim>&
320 inside_local = Dune::ReferenceElements<DF,dim>::general(eg.entity().type()).position(0,0);
323 typename TP::Traits::RangeFieldType cellcapacity = tp.c(eg.entity(),inside_local)*eg.geometry().volume();
324 typename TP::Traits::RangeFieldType celldt = cellcapacity/(cellinflux+1E-30);
325 dtmin = std::min(dtmin,celldt);
330 template<
typename IG,
typename LFSU,
typename X,
typename LFSV,
typename R>
332 const LFSU& lfsu_s,
const X& x_s,
const LFSV& lfsv_s,
336 typedef typename LFSU::Traits::FiniteElementType::
337 Traits::LocalBasisType::Traits::DomainFieldType DF;
338 typedef typename LFSU::Traits::FiniteElementType::
339 Traits::LocalBasisType::Traits::RangeFieldType RF;
342 const Dune::FieldVector<DF,IG::dimension-1>&
343 face_local = Dune::ReferenceElements<DF,IG::dimension-1>::general(ig.geometry().type()).position(0,0);
344 RF face_volume = ig.geometry().volume();
345 Dune::FieldVector<DF,dim> face_center_in_element = ig.geometryInInside().global(face_local);
348 int bc = tp.bc(ig.intersection(),face_local);
353 typename TP::Traits::RangeFieldType j = tp.j(*(ig.inside()),face_center_in_element);
354 r_s.accumulate(lfsu_s,0,j*face_volume);
359 typename TP::Traits::RangeType v(tp.v(*(ig.inside()),face_center_in_element));
362 RF vn = v*ig.centerUnitOuterNormal();
364 cellinflux += vn*face_volume;
368 r_s.accumulate(lfsu_s,0,vn*x_s(lfsu_s,0)*face_volume);
374 typename TP::Traits::RangeFieldType g;
375 if (vn>=0) g=x_s(lfsu_s,0);
else g=tp.g(*(ig.inside()),face_center_in_element);
376 const Dune::FieldVector<DF,IG::dimension>&
377 inside_local = Dune::ReferenceElements<DF,IG::dimension>::general(ig.inside()->type()).position(0,0);
378 typename TP::Traits::RangeFieldType D_inside = tp.D(*(ig.inside()),inside_local);
379 Dune::FieldVector<DF,IG::dimension>
380 inside_global = ig.inside()->geometry().center();
381 Dune::FieldVector<DF,IG::dimension>
382 outside_global = ig.geometry().center();
383 inside_global -= outside_global;
384 RF distance = inside_global.two_norm();
385 r_s.accumulate(lfsu_s,0,(g*vn - D_inside*(g-x_s(lfsu_s,0))/distance)*face_volume);
391 template<
typename EG,
typename LFSV,
typename R>
395 typedef typename LFSV::Traits::FiniteElementType::
396 Traits::LocalBasisType::Traits::DomainFieldType DF;
397 const int dim = EG::Geometry::dimension;
400 const Dune::FieldVector<DF,dim>&
401 inside_local = Dune::ReferenceElements<DF,dim>::general(eg.entity().type()).position(0,0);
404 typename TP::Traits::RangeFieldType q = tp.q(eg.entity(),inside_local);
406 r.accumulate(lfsv,0,-q*eg.geometry().volume());
410 void setTime (
typename TP::Traits::RangeFieldType t)
415 void preStep (
typename TP::Traits::RangeFieldType time,
typename TP::Traits::RangeFieldType dt,
421 void preStage (
typename TP::Traits::RangeFieldType time,
int r)
428 else first_stage =
false;
437 typename TP::Traits::RangeFieldType
suggestTimestep (
typename TP::Traits::RangeFieldType dt)
const 445 mutable typename TP::Traits::RangeFieldType dtmin;
446 mutable typename TP::Traits::RangeFieldType cellinflux;
451 template<
class T,
class Imp>
458 typename Traits::RangeFieldType
459 c (
const typename Traits::ElementType&
e,
const typename Traits::DomainType& x)
const 461 return asImp().c(e,x);
465 Imp& asImp () {
return static_cast<Imp &
> (*this);}
466 const Imp& asImp ()
const {
return static_cast<const Imp &
>(*this);}
483 enum { doPatternVolume =
true };
486 enum { doAlphaVolume =
true };
488 DUNE_DEPRECATED_MSG(
"Deprecated in Dune-PDELab 2.4, use the local operator ConvectionDiffusionCCFVTemporalOperator instead!")
495 template<
typename EG,
typename LFSU,
typename X,
typename LFSV,
typename R>
496 void alpha_volume (
const EG& eg,
const LFSU& lfsu,
const X& x,
const LFSV& lfsv, R& r)
const 499 typedef typename LFSU::Traits::FiniteElementType::
500 Traits::LocalBasisType::Traits::DomainFieldType DF;
503 const int dim = EG::Geometry::dimension;
506 const Dune::FieldVector<DF,dim>&
507 inside_local = Dune::ReferenceElements<DF,dim>::general(eg.entity().type()).position(0,0);
510 typename TP::Traits::RangeFieldType c = tp.c(eg.entity(),inside_local);
513 r.accumulate(lfsu,0,c*x(lfsu,0)*eg.geometry().volume());
517 template<
typename EG,
typename LFSU,
typename X,
typename LFSV,
typename M>
522 typedef typename LFSU::Traits::FiniteElementType::
523 Traits::LocalBasisType::Traits::DomainFieldType DF;
526 const int dim = EG::Geometry::dimension;
529 const Dune::FieldVector<DF,dim>&
530 inside_local = Dune::ReferenceElements<DF,dim>::general(eg.entity().type()).position(0,0);
533 typename TP::Traits::RangeFieldType c = tp.c(eg.entity(),inside_local);
536 mat.accumulate(lfsu,0,lfsu,0,c*eg.geometry().volume());
void evaluate(const Dune::PDELab::IntersectionGeometry< I > &ig, const typename Traits::DomainType &x, typename Traits::RangeType &y) const
Definition: transportccfv.hh:134
base class for parameter class
Definition: transportccfv.hh:452
traits class for two phase parameter class
Definition: transportccfv.hh:21
void preStep(typename TP::Traits::RangeFieldType time, typename TP::Traits::RangeFieldType dt, int stages)
to be called once before each time step
Definition: transportccfv.hh:415
BoundaryConditionType_Transport(const typename T::Traits::GridViewType &gv_, const T &t_)
Definition: transportccfv.hh:131
traits class holding function signature, same as in local function
Definition: function.hh:230
const I & intersection() const
Definition: geometrywrapper.hh:268
int bc(const typename Traits::IntersectionType &is, const typename Traits::IntersectionDomainType &x) const
boundary condition type function
Definition: transportccfv.hh:87
sparsity pattern generator
Definition: pattern.hh:13
Implements linear and nonlinear versions of jacobian_apply_skeleton() based on alpha_skeleton() ...
Definition: numericaljacobianapply.hh:180
Definition: transportccfv.hh:476
void alpha_boundary(const IG &ig, const LFSU &lfsu_s, const X &x_s, const LFSV &lfsv_s, R &r_s) const
Definition: transportccfv.hh:331
const IG & ig
Definition: constraints.hh:148
base class for parameter class
Definition: transportccfv.hh:54
static const int dim
Definition: adaptivity.hh:83
T Traits
Definition: transportccfv.hh:57
Implement jacobian_boundary() based on alpha_boundary()
Definition: numericaljacobian.hh:250
T Traits
Definition: transportccfv.hh:455
DirichletBoundaryCondition_Transport(const typename Traits::GridViewType &g_, const T &t_)
constructor
Definition: transportccfv.hh:166
GV::Traits::template Codim< 0 >::Entity ElementType
grid types
Definition: transportccfv.hh:48
void jacobian_volume(const EG &eg, const LFSU &lfsu, const X &x, const LFSV &lfsv, M &mat) const
Definition: transportccfv.hh:518
Definition: adaptivity.hh:27
void jacobian_volume(const EG &eg, const LFSU &lfsu, const X &x, const LFSV &lfsv, M &mat) const
Definition: transportccfv.hh:243
GV::Traits::template Codim< 0 >::Entity ElementType
codim 0 entity
Definition: function.hh:117
Definition: numericaljacobian.hh:95
Dune::FieldVector< DomainFieldType, dimDomain > DomainType
domain type
Definition: transportccfv.hh:36
Dune::PDELab::BoundaryGridFunctionBase< Traits, BoundaryConditionType_Transport< T > > BaseT
Definition: transportccfv.hh:129
sparsity pattern generator
Definition: pattern.hh:29
Implements linear and nonlinear versions of jacobian_apply_boundary() based on alpha_boundary() ...
Definition: numericaljacobianapply.hh:285
A local operator for a cell-centered finite volume scheme for the transport equation.
Definition: transportccfv.hh:200
const Traits::GridViewType & getGridView() const
Definition: transportccfv.hh:176
Traits::RangeFieldType j(const typename Traits::ElementType &e, const typename Traits::DomainType &x) const
Neumann boundary condition.
Definition: transportccfv.hh:101
Default flags for all local operators.
Definition: flags.hh:18
const Entity & e
Definition: localfunctionspace.hh:111
Traits::RangeFieldType c(const typename Traits::ElementType &e, const typename Traits::DomainType &x) const
source term
Definition: transportccfv.hh:459
Dune::FieldVector< RF, GV::dimensionworld > RangeType
range type
Definition: transportccfv.hh:45
Traits::RangeType v(const typename Traits::ElementType &e, const typename Traits::DomainType &x) const
velocity field
Definition: transportccfv.hh:61
Dune::FieldVector< GV::Grid::ctype, GV::dimension-1 > DomainType
domain type in dim-size coordinates
Definition: function.hh:48
Definition: transportccfv.hh:154
Dune::FieldVector< DomainFieldType, dimDomain-1 > IntersectionDomainType
domain type
Definition: transportccfv.hh:39
Default class for additional methods in instationary local operators.
Definition: idefault.hh:89
Traits::RangeFieldType g(const typename Traits::ElementType &e, const typename Traits::DomainType &x) const
Dirichlet boundary condition on inflow.
Definition: transportccfv.hh:94
GV::Grid::ctype DomainFieldType
Export type for domain field.
Definition: transportccfv.hh:33
void preStage(typename TP::Traits::RangeFieldType time, int r)
to be called once before each stage
Definition: transportccfv.hh:421
Traits::RangeFieldType D(const typename Traits::ElementType &e, const typename Traits::DomainType &x) const
scalar diffusion coefficient
Definition: transportccfv.hh:68
void alpha_skeleton(const IG &ig, const LFSU &lfsu_s, const X &x_s, const LFSV &lfsv_s, const LFSU &lfsu_n, const X &x_n, const LFSV &lfsv_n, R &r_s, R &r_n) const
Definition: transportccfv.hh:252
R RangeType
range type
Definition: function.hh:60
Definition: numericaljacobianapply.hh:107
TP::Traits::RangeFieldType suggestTimestep(typename TP::Traits::RangeFieldType dt) const
to be called once before each stage
Definition: transportccfv.hh:437
GV::Intersection IntersectionType
Definition: transportccfv.hh:49
Definition: transportccfv.hh:117
Wrap intersection.
Definition: geometrywrapper.hh:56
Dune::PDELab::GridFunctionTraits< typename T::Traits::GridViewType, typename T::Traits::RangeFieldType, 1, Dune::FieldVector< typename T::Traits::RangeFieldType, 1 > > Traits
Definition: transportccfv.hh:163
void postStage()
to be called once at the end of each stage
Definition: transportccfv.hh:432
dimension of the domain
Definition: transportccfv.hh:29
Implements linear and nonlinear versions of jacobian_apply_volume() based on alpha_volume() ...
Definition: numericaljacobianapply.hh:32
GV GridViewType
the grid view
Definition: transportccfv.hh:24
RF RangeFieldType
Export type for range field.
Definition: transportccfv.hh:42
leaf of a function tree
Definition: function.hh:596
void alpha_volume(const EG &eg, const LFSU &lfsu, const X &x, const LFSV &lfsv, R &r) const
Definition: transportccfv.hh:236
IntersectionType
Enum describing the type of an intersection.
Definition: intersectiontype.hh:14
void alpha_volume(const EG &eg, const LFSU &lfsu, const X &x, const LFSV &lfsv, R &r) const
Definition: transportccfv.hh:496
Implement jacobian_skeleton() based on alpha_skeleton()
Definition: numericaljacobian.hh:156
const T::Traits::GridViewType & getGridView()
get a reference to the GridView
Definition: transportccfv.hh:142
void alpha_volume_post_skeleton(const EG &eg, const LFSU &lfsu, const X &x, const LFSV &lfsv, R &r) const
Definition: transportccfv.hh:308
leaf of a function tree
Definition: function.hh:576
void lambda_volume(const EG &eg, const LFSV &lfsv, R &r) const
Definition: transportccfv.hh:392
void setTime(typename TP::Traits::RangeFieldType t)
set time in parameter class
Definition: transportccfv.hh:410
void evaluate(const typename Traits::ElementType &e, const typename Traits::DomainType &x, typename Traits::RangeType &y) const
Evaluate the GridFunction at given position.
Definition: transportccfv.hh:169
Dune::PDELab::BoundaryGridFunctionTraits< typename T::Traits::GridViewType, int, 1, Dune::FieldVector< int, 1 > > Traits
Definition: transportccfv.hh:128
Traits::RangeFieldType q(const typename Traits::ElementType &e, const typename Traits::DomainType &x) const
source term
Definition: transportccfv.hh:75
traits class holding the function signature, same as in local function
Definition: function.hh:175