Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dumux-repositories
dumux
Commits
a21f484d
Commit
a21f484d
authored
Jul 15, 2016
by
Timo Koch
Browse files
[fluxvar cache] Implement local-global concept for the flux var cache
parent
35c3b1f6
Changes
22
Hide whitespace changes
Inline
Side-by-side
dumux/discretization/box/boxgeometryhelper.hh
View file @
a21f484d
...
...
@@ -45,8 +45,8 @@ private:
using
Scalar
=
typename
GridView
::
ctype
;
static
const
int
dim
=
GridView
::
dimension
;
static
const
int
dimWorld
=
GridView
::
dimensionworld
;
using
ScvGeometry
=
Dune
::
MultiLinearGeometry
<
Scalar
,
dim
,
dimWorld
>
;
using
ScvfGeometry
=
Dune
::
MultiLinearGeometry
<
Scalar
,
dim
-
1
,
dimWorld
>
;
using
ScvGeometry
=
Dune
::
Cached
MultiLinearGeometry
<
Scalar
,
dim
,
dimWorld
>
;
using
ScvfGeometry
=
Dune
::
Cached
MultiLinearGeometry
<
Scalar
,
dim
-
1
,
dimWorld
>
;
using
GlobalPosition
=
typename
ScvGeometry
::
GlobalCoordinate
;
using
CornerList
=
std
::
vector
<
GlobalPosition
>
;
...
...
dumux/discretization/box/darcyslaw.hh
View file @
a21f484d
...
...
@@ -55,7 +55,7 @@ class DarcysLaw<TypeTag, typename std::enable_if<GET_PROP_VALUE(TypeTag, Discret
using
Problem
=
typename
GET_PROP_TYPE
(
TypeTag
,
Problem
);
using
SubControlVolume
=
typename
GET_PROP_TYPE
(
TypeTag
,
SubControlVolume
);
using
SubControlVolumeFace
=
typename
GET_PROP_TYPE
(
TypeTag
,
SubControlVolumeFace
);
using
FluxVar
iables
Cache
=
typename
GET_PROP_TYPE
(
TypeTag
,
FluxVariablesCache
);
using
FluxVarCache
=
typename
GET_PROP_TYPE
(
TypeTag
,
FluxVariablesCache
);
using
FVElementGeometry
=
typename
GET_PROP_TYPE
(
TypeTag
,
FVElementGeometry
);
using
ElementVolumeVariables
=
typename
GET_PROP_TYPE
(
TypeTag
,
ElementVolumeVariables
);
using
GridView
=
typename
GET_PROP_TYPE
(
TypeTag
,
GridView
);
...
...
@@ -70,7 +70,6 @@ class DarcysLaw<TypeTag, typename std::enable_if<GET_PROP_VALUE(TypeTag, Discret
using
DimWorldMatrix
=
Dune
::
FieldMatrix
<
Scalar
,
dimWorld
,
dimWorld
>
;
using
DimVector
=
Dune
::
FieldVector
<
Scalar
,
dimWorld
>
;
using
FaceData
=
typename
FluxVariablesCache
::
FaceData
;
public:
...
...
@@ -79,23 +78,23 @@ public:
const
FVElementGeometry
&
fvGeometry
,
const
ElementVolumeVariables
&
elemVolVars
,
const
SubControlVolumeFace
&
scvf
,
const
IndexType
phaseIdx
)
const
IndexType
phaseIdx
,
const
FluxVarCache
&
fluxVarCache
)
{
// get the precalculated local jacobian and shape values at the integration point
const
auto
&
faceData
=
problem
.
model
().
fluxVarsCache
()[
scvf
].
faceData
();
const
auto
&
insideScv
=
fvGeometry
.
scv
(
scvf
.
insideScvIdx
());
const
auto
&
insideVolVars
=
elemVolVars
[
insideScv
];
const
auto
extrusionFactor
=
insideVolVars
.
extrusionFactor
();
const
auto
K
=
problem
.
spatialParams
().
intrinsicPermeability
(
insideScv
);
const
auto
&
jacInvT
=
fluxVarCache
.
jacInvT
();
const
auto
&
shapeJacobian
=
fluxVarCache
.
shapeJacobian
();
// evaluate gradP - rho*g at integration point
DimVector
gradP
(
0.0
);
for
(
auto
&&
scv
:
scvs
(
fvGeometry
))
{
// the global shape function gradient
DimVector
gradI
;
faceData
.
jacInvT
.
mv
(
faceData
.
shapeJacobian
[
scv
.
index
()][
0
],
gradI
);
jacInvT
.
mv
(
shapeJacobian
[
scv
.
index
()][
0
],
gradI
);
gradI
*=
elemVolVars
[
scv
].
pressure
(
phaseIdx
);
gradP
+=
gradI
;
...
...
@@ -145,24 +144,6 @@ public:
{
return
Stencil
(
0
);
}
static
FaceData
calculateFaceData
(
const
Problem
&
problem
,
const
Element
&
element
,
const
FVElementGeometry
&
fvGeometry
,
const
SubControlVolumeFace
&
scvf
)
{
FaceData
faceData
;
const
auto
geometry
=
element
.
geometry
();
const
auto
&
localBasis
=
fvGeometry
.
feLocalBasis
();
// evaluate shape functions and gradients at the integration point
const
auto
ipLocal
=
geometry
.
local
(
scvf
.
center
());
faceData
.
jacInvT
=
geometry
.
jacobianInverseTransposed
(
ipLocal
);
localBasis
.
evaluateJacobian
(
ipLocal
,
faceData
.
shapeJacobian
);
localBasis
.
evaluateFunction
(
ipLocal
,
faceData
.
shapeValue
);
return
faceData
;
}
};
}
// end namespace
...
...
dumux/discretization/box/fluxvariablescache
vector
.hh
→
dumux/discretization/box/
element
fluxvariablescache.hh
View file @
a21f484d
...
...
@@ -18,10 +18,10 @@
*****************************************************************************/
/*!
* \file
* \brief
Base class for the volume
variable
s vector
* \brief
Global flux
variable
cache
*/
#ifndef DUMUX_DISCRETIZATION_BOX_FLUXVARSCACHE
VECTOR
_HH
#define DUMUX_DISCRETIZATION_BOX_FLUXVARSCACHE
VECTOR
_HH
#ifndef DUMUX_DISCRETIZATION_BOX_
ELEMENT_
FLUXVARSCACHE_HH
#define DUMUX_DISCRETIZATION_BOX_
ELEMENT_
FLUXVARSCACHE_HH
#include
<dumux/implicit/properties.hh>
...
...
@@ -30,12 +30,10 @@ namespace Dumux
/*!
* \ingroup ImplicitModel
* \brief Base class for the finite volume geometry vector for box models
* This builds up the sub control volumes and sub control volume faces
* for each element.
* \brief Base class for the flux variables cache vector, we store one cache per face
*/
template
<
class
TypeTag
,
bool
EnableGlobalFluxVariablesCache
>
class
BoxFluxVariablesCache
Vector
class
Box
Element
FluxVariablesCache
{};
/*!
...
...
@@ -43,7 +41,7 @@ class BoxFluxVariablesCacheVector
* \brief Base class for the flux variables cache vector, we store one cache per face
*/
template
<
class
TypeTag
>
class
BoxFluxVariablesCache
Vector
<
TypeTag
,
true
>
class
Box
Element
FluxVariablesCache
<
TypeTag
,
true
>
{
using
Problem
=
typename
GET_PROP_TYPE
(
TypeTag
,
Problem
);
using
GridView
=
typename
GET_PROP_TYPE
(
TypeTag
,
GridView
);
...
...
@@ -52,28 +50,12 @@ class BoxFluxVariablesCacheVector<TypeTag, true>
using
FluxVariablesCache
=
typename
GET_PROP_TYPE
(
TypeTag
,
FluxVariablesCache
);
using
SubControlVolumeFace
=
typename
GET_PROP_TYPE
(
TypeTag
,
SubControlVolumeFace
);
using
ElementVolumeVariables
=
typename
GET_PROP_TYPE
(
TypeTag
,
ElementVolumeVariables
);
using
GlobalFluxVariablesCache
=
typename
GET_PROP_TYPE
(
TypeTag
,
GlobalFluxVariablesCache
);
using
FVElementGeometry
=
typename
GET_PROP_TYPE
(
TypeTag
,
FVElementGeometry
);
public:
void
update
(
Problem
&
problem
)
{
problemPtr_
=
&
problem
;
fluxVarsCache_
.
resize
(
problem
.
gridView
.
size
(
0
));
for
(
const
auto
&
element
:
elements
(
problem
.
gridView
()))
{
eIdx_
=
problem
.
elementMapper
().
index
(
element
);
// bind the geometries and volume variables to the element (all the elements in stencil)
auto
fvGeometry
=
localView
(
problem
.
model
().
globalFvGeometries
());
fvGeometry
.
bind
(
element
);
const
auto
&
localBasis
=
fvGeometry
.
feLocalBasis
();
fluxVarsCache_
[
eIdx_
].
resize
(
fvGeometry
.
numScvf
());
for
(
auto
&&
scvf
:
scvfs
(
fvGeometry
))
{
(
*
this
)[
scvf
].
update
(
problem
,
element
,
localBasis
,
scvf
);
}
}
}
BoxElementFluxVariablesCache
(
const
GlobalFluxVariablesCache
&
global
)
:
globalFluxVarsCachePtr_
(
&
global
)
{}
// Function is called by the BoxLocalJacobian prior to flux calculations on the element.
// We assume the FVGeometries to be bound at this point
...
...
@@ -87,24 +69,26 @@ public:
void
bindElement
(
const
Element
&
element
,
const
FVElementGeometry
&
fvGeometry
,
const
ElementVolumeVariables
&
elemVolVars
)
{
eIdx_
=
problem_
().
elementMapper
().
index
(
element
);
}
{
eIdx_
=
globalFluxVarsCache
().
problem_
().
elementMapper
().
index
(
element
);
}
// access operator
const
FluxVariablesCache
&
operator
[](
const
SubControlVolumeFace
&
scvf
)
const
{
return
f
luxVarsCache
_
[
eIdx_
][
scvf
.
index
()
]
;
}
{
return
globalF
luxVarsCache
().
get
(
eIdx_
,
scvf
.
index
()
)
;
}
// access operator
FluxVariablesCache
&
operator
[](
const
SubControlVolumeFace
&
scvf
)
{
return
f
luxVarsCache
_
[
eIdx_
][
scvf
.
index
()
]
;
}
{
return
globalF
luxVarsCache
().
get
(
eIdx_
,
scvf
.
index
()
)
;
}
private:
const
Problem
&
problem_
()
const
{
return
*
problem
Ptr_
;
}
//! The global object we are a restriction of
const
GlobalFluxVariablesCache
&
globalFluxVarsCache
()
const
{
return
*
globalFluxVarsCache
Ptr_
;
}
private:
const
GlobalFluxVariablesCache
*
globalFluxVarsCachePtr_
;
// currently bound element
IndexType
eIdx_
;
const
Problem
*
problemPtr_
;
std
::
vector
<
std
::
vector
<
FluxVariablesCache
>>
fluxVarsCache_
;
};
/*!
...
...
@@ -112,7 +96,7 @@ private:
* \brief Base class for the flux variables cache vector, we store one cache per face
*/
template
<
class
TypeTag
>
class
BoxFluxVariablesCache
Vector
<
TypeTag
,
false
>
class
Box
Element
FluxVariablesCache
<
TypeTag
,
false
>
{
using
Problem
=
typename
GET_PROP_TYPE
(
TypeTag
,
Problem
);
using
GridView
=
typename
GET_PROP_TYPE
(
TypeTag
,
GridView
);
...
...
@@ -122,13 +106,11 @@ class BoxFluxVariablesCacheVector<TypeTag, false>
using
ElementVolumeVariables
=
typename
GET_PROP_TYPE
(
TypeTag
,
ElementVolumeVariables
);
using
SubControlVolumeFace
=
typename
GET_PROP_TYPE
(
TypeTag
,
SubControlVolumeFace
);
using
FVElementGeometry
=
typename
GET_PROP_TYPE
(
TypeTag
,
FVElementGeometry
);
using
GlobalFluxVariablesCache
=
typename
GET_PROP_TYPE
(
TypeTag
,
GlobalFluxVariablesCache
);
public:
void
update
(
Problem
&
problem
)
{
problemPtr_
=
&
problem
;
}
BoxElementFluxVariablesCache
(
const
GlobalFluxVariablesCache
&
global
)
:
globalFluxVarsCachePtr_
(
&
global
)
{}
// Function is called by the BoxLocalJacobian prior to flux calculations on the element.
// We assume the FVGeometries to be bound at this point
...
...
@@ -146,7 +128,7 @@ public:
// temporary resizing of the cache
fluxVarsCache_
.
resize
(
fvGeometry
.
numScvf
());
for
(
auto
&&
scvf
:
scvfs
(
fvGeometry
))
(
*
this
)[
scvf
].
update
(
problem_
(),
element
,
fvGeometry
,
scvf
);
(
*
this
)[
scvf
].
update
(
globalFluxVarsCache
().
problem_
(),
element
,
fvGeometry
,
scvf
);
}
// access operator
...
...
@@ -157,12 +139,12 @@ public:
FluxVariablesCache
&
operator
[](
const
SubControlVolumeFace
&
scvf
)
{
return
fluxVarsCache_
[
scvf
.
index
()];
}
private:
const
Problem
&
problem_
()
const
{
return
*
problem
Ptr_
;
}
//! The global object we are a restriction of
const
GlobalFluxVariablesCache
&
globalFluxVarsCache
()
const
{
return
*
globalFluxVarsCache
Ptr_
;
}
// currently bound element
const
Problem
*
problem
Ptr_
;
private:
const
GlobalFluxVariablesCache
*
globalFluxVarsCache
Ptr_
;
std
::
vector
<
FluxVariablesCache
>
fluxVarsCache_
;
};
...
...
dumux/discretization/box/globalfluxvariablescache.hh
0 → 100644
View file @
a21f484d
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \brief Global flux variable cache
*/
#ifndef DUMUX_DISCRETIZATION_BOX_GLOBAL_FLUXVARSCACHE_HH
#define DUMUX_DISCRETIZATION_BOX_GLOBAL_FLUXVARSCACHE_HH
#include
<dumux/implicit/properties.hh>
#include
<dumux/discretization/box/elementfluxvariablescache.hh>
namespace
Dumux
{
/*!
* \ingroup ImplicitModel
* \brief Base class for the flux variables cache vector, we store one cache per face
*/
template
<
class
TypeTag
,
bool
EnableGlobalFluxVariablesCache
>
class
BoxGlobalFluxVariablesCache
{};
/*!
* \ingroup ImplicitModel
* \brief Base class for the flux variables cache vector, we store one cache per face
*/
template
<
class
TypeTag
>
class
BoxGlobalFluxVariablesCache
<
TypeTag
,
true
>
{
// the local class needs access to the problem
friend
BoxElementFluxVariablesCache
<
TypeTag
,
true
>
;
using
Problem
=
typename
GET_PROP_TYPE
(
TypeTag
,
Problem
);
using
GridView
=
typename
GET_PROP_TYPE
(
TypeTag
,
GridView
);
using
IndexType
=
typename
GridView
::
IndexSet
::
IndexType
;
using
Element
=
typename
GridView
::
template
Codim
<
0
>
::
Entity
;
using
FluxVariablesCache
=
typename
GET_PROP_TYPE
(
TypeTag
,
FluxVariablesCache
);
using
ElementFluxVariablesCache
=
typename
GET_PROP_TYPE
(
TypeTag
,
ElementFluxVariablesCache
);
using
SubControlVolumeFace
=
typename
GET_PROP_TYPE
(
TypeTag
,
SubControlVolumeFace
);
using
ElementVolumeVariables
=
typename
GET_PROP_TYPE
(
TypeTag
,
ElementVolumeVariables
);
using
FVElementGeometry
=
typename
GET_PROP_TYPE
(
TypeTag
,
FVElementGeometry
);
public:
void
update
(
Problem
&
problem
)
{
problemPtr_
=
&
problem
;
fluxVarsCache_
.
resize
(
problem
.
gridView
.
size
(
0
));
for
(
const
auto
&
element
:
elements
(
problem
.
gridView
()))
{
auto
eIdx
=
problem
.
elementMapper
().
index
(
element
);
// bind the geometries and volume variables to the element (all the elements in stencil)
auto
fvGeometry
=
localView
(
problem
.
model
().
globalFvGeometries
());
fvGeometry
.
bind
(
element
);
const
auto
&
localBasis
=
fvGeometry
.
feLocalBasis
();
fluxVarsCache_
[
eIdx
].
resize
(
fvGeometry
.
numScvf
());
for
(
auto
&&
scvf
:
scvfs
(
fvGeometry
))
{
(
*
this
)[
scvf
].
update
(
problem
,
element
,
localBasis
,
scvf
);
}
}
}
/*!
* \brief Return a local restriction of this global object
* The local object is only functional after calling its bind/bindElement method
* This is a free function that will be found by means of ADL
*/
friend
inline
ElementFluxVariablesCache
localView
(
const
BoxGlobalFluxVariablesCache
&
global
)
{
return
ElementFluxVariablesCache
(
global
);
}
private:
const
Problem
&
problem_
()
const
{
return
*
problemPtr_
;
}
// access operator
const
FluxVariablesCache
&
get
(
IndexType
eIdx
,
IndexType
scvfIdx
)
const
{
return
fluxVarsCache_
[
eIdx
][
scvfIdx
];
}
// access operator
FluxVariablesCache
&
get
(
IndexType
eIdx
,
IndexType
scvfIdx
)
{
return
fluxVarsCache_
[
eIdx
][
scvfIdx
];
}
// currently bound element
const
Problem
*
problemPtr_
;
std
::
vector
<
std
::
vector
<
FluxVariablesCache
>>
fluxVarsCache_
;
};
/*!
* \ingroup ImplicitModel
* \brief Base class for the flux variables cache vector, we store one cache per face
*/
template
<
class
TypeTag
>
class
BoxGlobalFluxVariablesCache
<
TypeTag
,
false
>
{
// the local class needs access to the problem
friend
BoxElementFluxVariablesCache
<
TypeTag
,
false
>
;
using
Problem
=
typename
GET_PROP_TYPE
(
TypeTag
,
Problem
);
using
GridView
=
typename
GET_PROP_TYPE
(
TypeTag
,
GridView
);
using
IndexType
=
typename
GridView
::
IndexSet
::
IndexType
;
using
Element
=
typename
GridView
::
template
Codim
<
0
>
::
Entity
;
using
FluxVariablesCache
=
typename
GET_PROP_TYPE
(
TypeTag
,
FluxVariablesCache
);
using
ElementVolumeVariables
=
typename
GET_PROP_TYPE
(
TypeTag
,
ElementVolumeVariables
);
using
ElementFluxVariablesCache
=
typename
GET_PROP_TYPE
(
TypeTag
,
ElementFluxVariablesCache
);
using
SubControlVolumeFace
=
typename
GET_PROP_TYPE
(
TypeTag
,
SubControlVolumeFace
);
using
FVElementGeometry
=
typename
GET_PROP_TYPE
(
TypeTag
,
FVElementGeometry
);
public:
void
update
(
Problem
&
problem
)
{
problemPtr_
=
&
problem
;
}
/*!
* \brief Return a local restriction of this global object
* The local object is only functional after calling its bind/bindElement method
* This is a free function that will be found by means of ADL
*/
friend
inline
ElementFluxVariablesCache
localView
(
const
BoxGlobalFluxVariablesCache
&
global
)
{
return
ElementFluxVariablesCache
(
global
);
}
private:
const
Problem
&
problem_
()
const
{
return
*
problemPtr_
;
}
// currently bound element
const
Problem
*
problemPtr_
;
};
}
// end namespace
#endif
dumux/discretization/cellcentered/fluxvariablescache
vector
.hh
→
dumux/discretization/cellcentered/
element
fluxvariablescache.hh
View file @
a21f484d
...
...
@@ -18,10 +18,10 @@
*****************************************************************************/
/*!
* \file
* \brief
Base class for the volume variables vector
* \brief
The global object of flux var caches
*/
#ifndef DUMUX_DISCRETIZATION_CC_FLUXVARSCACHE
VECTOR
_HH
#define DUMUX_DISCRETIZATION_CC_FLUXVARSCACHE
VECTOR
_HH
#ifndef DUMUX_DISCRETIZATION_CC_
ELEMENT_
FLUXVARSCACHE_HH
#define DUMUX_DISCRETIZATION_CC_
ELEMENT_
FLUXVARSCACHE_HH
#include
<dumux/implicit/properties.hh>
...
...
@@ -30,10 +30,17 @@ namespace Dumux
/*!
* \ingroup ImplicitModel
* \brief Base class for the flux variables cache vector, we store one cache per face
* \brief Base class for the stencil local flux variables cache
*/
template
<
class
TypeTag
,
bool
EnableGlobalFluxVariablesCache
>
class
CCElementFluxVariablesCache
;
/*!
* \ingroup ImplicitModel
* \brief Spezialization when caching globally
*/
template
<
class
TypeTag
>
class
CCFluxVariablesCache
Vector
class
CC
Element
FluxVariablesCache
<
TypeTag
,
true
>
{
using
Problem
=
typename
GET_PROP_TYPE
(
TypeTag
,
Problem
);
using
GridView
=
typename
GET_PROP_TYPE
(
TypeTag
,
GridView
);
...
...
@@ -42,45 +49,64 @@ class CCFluxVariablesCacheVector
using
FVElementGeometry
=
typename
GET_PROP_TYPE
(
TypeTag
,
FVElementGeometry
);
using
ElementVolumeVariables
=
typename
GET_PROP_TYPE
(
TypeTag
,
ElementVolumeVariables
);
using
FluxVariablesCache
=
typename
GET_PROP_TYPE
(
TypeTag
,
FluxVariablesCache
);
using
GlobalFluxVariablesCache
=
typename
GET_PROP_TYPE
(
TypeTag
,
GlobalFluxVariablesCache
);
using
SubControlVolumeFace
=
typename
GET_PROP_TYPE
(
TypeTag
,
SubControlVolumeFace
);
public:
// When global caching is enabled, precompute transmissibilities and stencils for all the scv faces
template
<
typename
T
=
TypeTag
>
typename
std
::
enable_if
<
GET_PROP_VALUE
(
T
,
EnableGlobalFluxVariablesCache
)
>::
type
update
(
Problem
&
problem
)
{
problemPtr_
=
&
problem
;
const
auto
&
globalFvGeometry
=
problem
.
model
().
globalFvGeometry
();
fluxVarsCache_
.
resize
(
globalFvGeometry
.
numScvf
());
for
(
const
auto
&
element
:
elements
(
problem
.
gridView
()))
{
// Prepare the geometries within the elements of the stencil
auto
fvGeometry
=
localView
(
globalFvGeometry
);
fvGeometry
.
bind
(
element
);
CCElementFluxVariablesCache
(
GlobalFluxVariablesCache
&
global
)
:
globalFluxVarsCachePtr_
(
&
global
)
{}
for
(
auto
&&
scvf
:
scvfs
(
fvGeometry
))
{
(
*
this
)[
scvf
].
update
(
problem
,
element
,
scvf
);
}
}
}
// Specialization for the global caching being enabled - do nothing here
void
bindElement
(
const
Element
&
element
,
const
FVElementGeometry
&
fvGeometry
,
const
ElementVolumeVariables
&
elemVolVars
)
{}
// When global flux variables caching is disabled, we don't need to update the cache
template
<
typename
T
=
TypeTag
>
typename
std
::
enable_if
<!
GET_PROP_VALUE
(
T
,
EnableGlobalFluxVariablesCache
)
>::
type
update
(
Problem
&
problem
)
{
problemPtr_
=
&
problem
;
}
// Specialization for the global caching being enabled - do nothing here
void
bind
(
const
Element
&
element
,
const
FVElementGeometry
&
fvGeometry
,
const
ElementVolumeVariables
&
elemVolVars
)
{}
// access operators in the case of caching
const
FluxVariablesCache
&
operator
[](
const
SubControlVolumeFace
&
scvf
)
const
{
return
(
*
globalFluxVarsCachePtr_
)[
scvf
.
index
()];
}
FluxVariablesCache
&
operator
[](
const
SubControlVolumeFace
&
scvf
)
{
return
(
*
globalFluxVarsCachePtr_
)[
scvf
.
index
()];
}
//! The global object we are a restriction of
const
GlobalFluxVariablesCache
&
globalFluxVarsCache
()
const
{
return
*
globalFluxVarsCachePtr_
;
}
private:
GlobalFluxVariablesCache
*
globalFluxVarsCachePtr_
;
};
/*!
* \ingroup ImplicitModel
* \brief Spezialization when not using global caching
*/
template
<
class
TypeTag
>
class
CCElementFluxVariablesCache
<
TypeTag
,
false
>
{
using
Problem
=
typename
GET_PROP_TYPE
(
TypeTag
,
Problem
);
using
GridView
=
typename
GET_PROP_TYPE
(
TypeTag
,
GridView
);
using
IndexType
=
typename
GridView
::
IndexSet
::
IndexType
;
using
Element
=
typename
GridView
::
template
Codim
<
0
>
::
Entity
;
using
FVElementGeometry
=
typename
GET_PROP_TYPE
(
TypeTag
,
FVElementGeometry
);
using
ElementVolumeVariables
=
typename
GET_PROP_TYPE
(
TypeTag
,
ElementVolumeVariables
);
using
FluxVariablesCache
=
typename
GET_PROP_TYPE
(
TypeTag
,
FluxVariablesCache
);
using
GlobalFluxVariablesCache
=
typename
GET_PROP_TYPE
(
TypeTag
,
GlobalFluxVariablesCache
);
using
SubControlVolumeFace
=
typename
GET_PROP_TYPE
(
TypeTag
,
SubControlVolumeFace
);
public:
CCElementFluxVariablesCache
(
const
GlobalFluxVariablesCache
&
global
)
:
globalFluxVarsCachePtr_
(
&
global
)
{}
// This function has to be called prior to flux calculations on the element.
// Prepares the transmissibilities of the scv faces in an element. The FvGeometry is assumed to be bound.
template
<
typename
T
=
TypeTag
>
typename
std
::
enable_if
<!
GET_PROP_VALUE
(
T
,
EnableGlobalFluxVariablesCache
)
>::
type
bindElement
(
const
Element
&
element
,
const
FVElementGeometry
&
fvGeometry
,
const
ElementVolumeVariables
&
elemVolVars
)
void
bindElement
(
const
Element
&
element
,
const
FVElementGeometry
&
fvGeometry
,
const
ElementVolumeVariables
&
elemVolVars
)
{
// resizing of the cache
const
auto
numScvf
=
fvGeometry
.
numScvf
();
...
...
@@ -91,37 +117,27 @@ public:
// fill the containers
for
(
auto
&&
scvf
:
scvfs
(
fvGeometry
))
{
fluxVarsCache_
[
localScvfIdx
].
update
(
problem_
(),
element
,
fvGeometry
,
elemVolVars
,
scvf
);
fluxVarsCache_
[
localScvfIdx
].
update
(
globalFluxVarsCache
().
problem_
(),
element
,
fvGeometry
,
elemVolVars
,
scvf
);
globalScvfIndices_
[
localScvfIdx
]
=
scvf
.
index
();
localScvfIdx
++
;
}
}
// Specialization for the global caching being enabled - do nothing here
template
<
typename
T
=
TypeTag
>
typename
std
::
enable_if
<
GET_PROP_VALUE
(
T
,
EnableGlobalFluxVariablesCache
)
>::
type
bindElement
(
const
Element
&
element
,
const
FVElementGeometry
&
fvGeometry
,
const
ElementVolumeVariables
&
elemVolVars
)
{}
// This function is called by the CCLocalResidual before flux calculations during assembly.
// Prepares the transmissibilities of the scv faces in the stencil. The FvGeometries are assumed to be bound.
template
<
typename
T
=
TypeTag
>
typename
std
::
enable_if
<!
GET_PROP_VALUE
(
T
,
EnableGlobalFluxVariablesCache
)
>::
type
bind
(
const
Element
&
element
,
const
FVElementGeometry
&
fvGeometry
,
const
ElementVolumeVariables
&
elemVolVars
)
void
bind
(
const
Element
&
element
,
const
FVElementGeometry
&
fvGeometry
,
const
ElementVolumeVariables
&
elemVolVars
)
{
const
auto
globalI
=
problem_
().
elementMapper
().
index
(
element
);
const
auto
&
neighborStencil
=
problem_
().
model
().
stencils
(
element
).
neighborStencil
();
const
auto
globalI
=
globalFluxVarsCache
().
problem_
().
elementMapper
().
index
(
element
);
const
auto
&
neighborStencil
=
globalFluxVarsCache
().
problem_
().
model
().
stencils
(
element
).
neighborStencil
();
const
auto
numNeighbors
=
neighborStencil
.
size
();
// find the number of scv faces that need to be prepared
auto
numScvf
=
fvGeometry
.
numScvf
();
for
(
IndexType
localIdxJ
=
0
;
localIdxJ
<
numNeighbors
;
++
localIdxJ
)
{
const
auto
&
fluxVarIndicesJ
=
problem_
().
model
().
localJacobian
().
assemblyMap
()[
globalI
][
localIdxJ
];
const
auto
&
fluxVarIndicesJ
=
globalFluxVarsCache
().
problem_
().
model
().
localJacobian
().
assemblyMap
()[
globalI
][
localIdxJ
];
numScvf
+=
fluxVarIndicesJ
.
size
();
}
...
...
@@ -131,7 +147,7 @@ public:
IndexType
localScvfIdx
=
0
;
for
(
auto
&&
scvf
:
scvfs
(
fvGeometry
))
{
fluxVarsCache_
[
localScvfIdx
].
update
(
problem_
(),
element
,
fvGeometry
,
elemVolVars
,
scvf
);
fluxVarsCache_
[
localScvfIdx
].
update
(
globalFluxVarsCache
().
problem_
(),
element
,
fvGeometry
,
elemVolVars
,
scvf
);
globalScvfIndices_
[
localScvfIdx
]
=
scvf
.
index
();
localScvfIdx
++
;
}
...
...
@@ -139,64 +155,41 @@ public:
// add required data on the scv faces in the neighboring elements
for
(
IndexType
localIdxJ
=
0
;
localIdxJ
<
numNeighbors
;
++
localIdxJ
)
{
const
auto
&
fluxVarIndicesJ
=
problem_
().
model
().
localJacobian
().
assemblyMap
()[
globalI
][
localIdxJ
];
const
auto
&
fluxVarIndicesJ
=
globalFluxVarsCache
().
problem_
().
model
().
localJacobian
().
assemblyMap
()[
globalI
][
localIdxJ
];
const
auto
elementJ
=
fvGeometry
.
globalFvGeometry
().
element
(
neighborStencil
[
localIdxJ
]);
for
(
auto
fluxVarIdx
:
fluxVarIndicesJ
)
{
auto
&&
scvfJ
=
fvGeometry
.
scvf
(
fluxVarIdx
);
fluxVarsCache_
[
localScvfIdx
].
update
(
problem_
(),
elementJ
,
fvGeometry
,
elemVolVars
,
scvfJ
);
fluxVarsCache_
[
localScvfIdx
].
update
(
globalFluxVarsCache
().
problem_
(),
elementJ
,
fvGeometry
,
elemVolVars
,
scvfJ
);
globalScvfIndices_
[
localScvfIdx
]
=
scvfJ
.
index
();
localScvfIdx
++
;
}
}
}