From 50d418029dabe8f69d90b334b66a93bc91893371 Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Thu, 24 Nov 2016 11:13:55 +0100 Subject: [PATCH] [tpfa] Stencil computation optimization makes 2p2c test 20% faster --- .../cellcentered/tpfa/darcyslaw.hh | 10 ++----- .../cellcentered/tpfa/fickslaw.hh | 10 ++----- .../cellcentered/tpfa/fourierslaw.hh | 10 ++----- .../implicit/fluxvariables.hh | 27 ++++++++++++++++--- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/dumux/discretization/cellcentered/tpfa/darcyslaw.hh b/dumux/discretization/cellcentered/tpfa/darcyslaw.hh index 3ef2c5c172..646baedb56 100644 --- a/dumux/discretization/cellcentered/tpfa/darcyslaw.hh +++ b/dumux/discretization/cellcentered/tpfa/darcyslaw.hh @@ -130,16 +130,10 @@ public: const FVElementGeometry& fvGeometry, const SubControlVolumeFace& scvFace) { - Stencil stencil; if (!scvFace.boundary()) - { - stencil.push_back(scvFace.insideScvIdx()); - stencil.push_back(scvFace.outsideScvIdx()); - } + return Stencil({scvFace.insideScvIdx(), scvFace.outsideScvIdx()}); else - stencil.push_back(scvFace.insideScvIdx()); - - return stencil; + return Stencil({scvFace.insideScvIdx()}); } // The flux variables cache has to be bound to an element prior to flux calculations diff --git a/dumux/discretization/cellcentered/tpfa/fickslaw.hh b/dumux/discretization/cellcentered/tpfa/fickslaw.hh index 0279b9916f..163164cc39 100644 --- a/dumux/discretization/cellcentered/tpfa/fickslaw.hh +++ b/dumux/discretization/cellcentered/tpfa/fickslaw.hh @@ -117,16 +117,10 @@ public: const FVElementGeometry& fvGeometry, const SubControlVolumeFace& scvFace) { - std::vector<IndexType> stencil; if (!scvFace.boundary()) - { - stencil.push_back(scvFace.insideScvIdx()); - stencil.push_back(scvFace.outsideScvIdx()); - } + return Stencil({scvFace.insideScvIdx(), scvFace.outsideScvIdx()}); else - stencil.push_back(scvFace.insideScvIdx()); - - return stencil; + return Stencil({scvFace.insideScvIdx()}); } private: diff --git a/dumux/discretization/cellcentered/tpfa/fourierslaw.hh b/dumux/discretization/cellcentered/tpfa/fourierslaw.hh index e00fca3417..a1cb183736 100644 --- a/dumux/discretization/cellcentered/tpfa/fourierslaw.hh +++ b/dumux/discretization/cellcentered/tpfa/fourierslaw.hh @@ -102,16 +102,10 @@ public: const FVElementGeometry& fvGeometry, const SubControlVolumeFace& scvFace) { - std::vector<IndexType> stencil; if (!scvFace.boundary()) - { - stencil.push_back(scvFace.insideScvIdx()); - stencil.push_back(scvFace.outsideScvIdx()); - } + return Stencil({scvFace.insideScvIdx(), scvFace.outsideScvIdx()}); else - stencil.push_back(scvFace.insideScvIdx()); - - return stencil; + return Stencil({scvFace.insideScvIdx()}); } private: diff --git a/dumux/porousmediumflow/implicit/fluxvariables.hh b/dumux/porousmediumflow/implicit/fluxvariables.hh index 4e86db4e30..d37d1c24cf 100644 --- a/dumux/porousmediumflow/implicit/fluxvariables.hh +++ b/dumux/porousmediumflow/implicit/fluxvariables.hh @@ -216,7 +216,14 @@ public: const FVElementGeometry& fvGeometry, const SubControlVolumeFace& scvFace) { - // unifiy advective and diffusive stencil + // In the case of cctpfa or box the stencils for all laws are the same... + if (GET_PROP_VALUE(TypeTag, DiscretizationMethod) == DiscretizationMethods::CCTpfa + || GET_PROP_VALUE(TypeTag, DiscretizationMethod) == DiscretizationMethods::Box) + { + return AdvectionType::stencil(problem, element, fvGeometry, scvFace); + } + + // ...in general: unifiy advective and diffusive stencil Stencil stencil = AdvectionType::stencil(problem, element, fvGeometry, scvFace); Stencil diffusionStencil = MolecularDiffusionType::stencil(problem, element, fvGeometry, scvFace); @@ -311,7 +318,14 @@ public: const FVElementGeometry& fvGeometry, const SubControlVolumeFace& scvFace) { - // unifiy advective and diffusive stencil + // In the case of cctpfa or box the stencils for all laws are the same... + if (GET_PROP_VALUE(TypeTag, DiscretizationMethod) == DiscretizationMethods::CCTpfa + || GET_PROP_VALUE(TypeTag, DiscretizationMethod) == DiscretizationMethods::Box) + { + return AdvectionType::stencil(problem, element, fvGeometry, scvFace); + } + + // ...in general: unifiy advective and heat conduction stencil Stencil stencil = AdvectionType::stencil(problem, element, fvGeometry, scvFace); Stencil energyStencil = HeatConductionType::stencil(problem, element, fvGeometry, scvFace); @@ -420,7 +434,14 @@ public: const FVElementGeometry& fvGeometry, const SubControlVolumeFace& scvFace) { - // unifiy advective and diffusive stencil + // In the case of cctpfa or box the stencils for all laws are the same... + if (GET_PROP_VALUE(TypeTag, DiscretizationMethod) == DiscretizationMethods::CCTpfa + || GET_PROP_VALUE(TypeTag, DiscretizationMethod) == DiscretizationMethods::Box) + { + return AdvectionType::stencil(problem, element, fvGeometry, scvFace); + } + + // ...in general: unifiy advective, diffusive and heat conduction stencil Stencil stencil = AdvectionType::stencil(problem, element, fvGeometry, scvFace); Stencil diffusionStencil = MolecularDiffusionType::stencil(problem, element, fvGeometry, scvFace); Stencil energyStencil = HeatConductionType::stencil(problem, element, fvGeometry, scvFace); -- GitLab