Skip to content
GitLab
Menu
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
1ef2642a
Commit
1ef2642a
authored
Mar 09, 2021
by
Dennis Gläser
Browse files
[io][vtk] introduce compatibility layer with new/old grid vars
parent
b99fbb08
Changes
3
Hide whitespace changes
Inline
Side-by-side
dumux/io/vtkoutputmodule.hh
View file @
1ef2642a
...
...
@@ -43,7 +43,9 @@
#include <dumux/common/parameters.hh>
#include <dumux/io/format.hh>
#include <dumux/discretization/method.hh>
#include <dumux/discretization/fvgridvariables.hh>
#include "vtkfunction.hh"
#include "velocityoutput.hh"
...
...
@@ -378,8 +380,18 @@ public:
}
protected:
// extract the grid volume variables from the grid variables (experimental interface)
template
<
bool
isExperimental
=
Experimental
::
areExperimentalGridVars
<
GridVariables
>,
std
::
enable_if_t
<
isExperimental
,
int
>
=
0
>
decltype
(
auto
)
gridVolVars
()
const
{
return
gridVariables_
.
gridVolVars
();
}
// extract the grid volume variables from the grid variables (experimental interface)
template
<
bool
isExperimental
=
Experimental
::
areExperimentalGridVars
<
GridVariables
>,
std
::
enable_if_t
<!
isExperimental
,
int
>
=
0
>
decltype
(
auto
)
gridVolVars
()
const
{
return
gridVariables_
.
curGridVolVars
();
}
// some return functions for differing implementations to use
const
auto
&
problem
()
const
{
return
gridV
ariables_
.
curGridV
olVars
().
problem
();
}
const
auto
&
problem
()
const
{
return
gridVolVars
().
problem
();
}
const
GridVariables
&
gridVariables
()
const
{
return
gridVariables_
;
}
const
GridGeometry
&
gridGeometry
()
const
{
return
gridVariables_
.
gridGeometry
();
}
const
SolutionVector
&
sol
()
const
{
return
sol_
;
}
...
...
@@ -447,7 +459,7 @@ private:
const
auto
eIdxGlobal
=
gridGeometry
().
elementMapper
().
index
(
element
);
auto
fvGeometry
=
localView
(
gridGeometry
());
auto
elemVolVars
=
localView
(
gridV
ariables_
.
curGridV
olVars
());
auto
elemVolVars
=
localView
(
gridVolVars
());
// If velocity output is enabled we need to bind to the whole stencil
// otherwise element-local data is sufficient
...
...
@@ -634,7 +646,7 @@ private:
const
auto
numCorners
=
element
.
subEntities
(
dim
);
auto
fvGeometry
=
localView
(
gridGeometry
());
auto
elemVolVars
=
localView
(
gridV
ariables_
.
curGridV
olVars
());
auto
elemVolVars
=
localView
(
gridVolVars
());
// resize element-local data containers
for
(
std
::
size_t
i
=
0
;
i
<
volVarScalarDataInfo_
.
size
();
++
i
)
...
...
dumux/porousmediumflow/velocity.hh
View file @
1ef2642a
...
...
@@ -36,6 +36,7 @@
#include <dumux/common/parameters.hh>
#include <dumux/discretization/method.hh>
#include <dumux/discretization/elementsolution.hh>
#include <dumux/discretization/fvgridvariables.hh>
#include <dumux/flux/traits.hh>
namespace
Dumux
{
...
...
@@ -108,7 +109,7 @@ public:
* \param gridVariables The grid variables
*/
PorousMediumFlowVelocity
(
const
GridVariables
&
gridVariables
)
:
problem_
(
g
ridVariables
.
curGridVolVars
().
pro
ble
m
(
))
:
problem_
(
g
etProblem_
(
gridVaria
ble
s
))
,
gridGeometry_
(
gridVariables
.
gridGeometry
())
,
gridVariables_
(
gridVariables
)
{
...
...
@@ -460,6 +461,15 @@ private:
}
private:
// extract problem from grid vars (experimental interface)
template
<
class
GV
,
std
::
enable_if_t
<
Experimental
::
areExperimentalGridVars
<
GV
>,
int
>
=
0
>
const
Problem
&
getProblem_
(
const
GV
&
gv
)
{
return
gv
.
gridVolVars
().
problem
();
}
// extract problem from grid vars (standards interface)
template
<
class
GV
,
std
::
enable_if_t
<!
Experimental
::
areExperimentalGridVars
<
GV
>,
int
>
=
0
>
const
Problem
&
getProblem_
(
const
GV
&
gv
)
{
return
gv
.
curGridVolVars
().
problem
();
}
const
Problem
&
problem_
;
const
GridGeometry
&
gridGeometry_
;
const
GridVariables
&
gridVariables_
;
...
...
dumux/porousmediumflow/velocityoutput.hh
View file @
1ef2642a
...
...
@@ -29,9 +29,11 @@
#include <dune/common/float_cmp.hh>
#include <dumux/common/parameters.hh>
#include <dumux/io/velocityoutput.hh>
#include <dumux/discretization/method.hh>
#include <dumux/discretization/elementsolution.hh>
#include <dumux/discretization/fvgridvariables.hh>
#include <dumux/porousmediumflow/velocity.hh>
namespace
Dumux
{
...
...
@@ -67,6 +69,15 @@ class PorousMediumFlowVelocityOutput : public VelocityOutput<GridVariables>
using
Problem
=
typename
GridVolumeVariables
::
Problem
;
using
VelocityBackend
=
PorousMediumFlowVelocity
<
GridVariables
,
FluxVariables
>
;
struct
hasCurGridVolVars
{
template
<
class
GV
>
auto
operator
()(
const
GV
&
gv
)
->
decltype
(
gv
.
curGridVolVars
())
{}
};
static
constexpr
auto
isOldGVInterface
=
decltype
(
isValid
(
hasCurGridVolVars
())(
std
::
declval
<
GridVariables
>
()))
::
value
;
public:
using
VelocityVector
=
typename
ParentType
::
VelocityVector
;
...
...
@@ -78,7 +89,12 @@ public:
PorousMediumFlowVelocityOutput
(
const
GridVariables
&
gridVariables
)
{
// check, if velocity output can be used (works only for cubes so far)
enableOutput_
=
getParamFromGroup
<
bool
>
(
gridVariables
.
curGridVolVars
().
problem
().
paramGroup
(),
"Vtk.AddVelocity"
);
// compatibility layer with new and old-style grid variables
if
constexpr
(
Experimental
::
areExperimentalGridVars
<
GridVariables
>
)
enableOutput_
=
getParamFromGroup
<
bool
>
(
gridVariables
.
gridVolVars
().
problem
().
paramGroup
(),
"Vtk.AddVelocity"
);
else
enableOutput_
=
getParamFromGroup
<
bool
>
(
gridVariables
.
curGridVolVars
().
problem
().
paramGroup
(),
"Vtk.AddVelocity"
);
if
(
enableOutput_
)
velocityBackend
=
std
::
make_unique
<
VelocityBackend
>
(
gridVariables
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment