From 41b0f964305320791c23de5fec35abff633646e7 Mon Sep 17 00:00:00 2001 From: Sina Ackermann <sina.ackermann@iws.uni-stuttgart.de> Date: Thu, 9 Mar 2017 16:11:11 +0100 Subject: [PATCH] [staggeredGrid][nonisothermal] Implement Fourier's law for staggered grid --- dumux/discretization/fourierslaw.hh | 1 + .../staggered/freeflow/fourierslaw.hh | 131 ++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 dumux/discretization/staggered/freeflow/fourierslaw.hh diff --git a/dumux/discretization/fourierslaw.hh b/dumux/discretization/fourierslaw.hh index d71df9aa6c..0518cddcc3 100644 --- a/dumux/discretization/fourierslaw.hh +++ b/dumux/discretization/fourierslaw.hh @@ -45,5 +45,6 @@ using FouriersLaw = FouriersLawImplementation<TypeTag, GET_PROP_VALUE(TypeTag, D #include <dumux/discretization/cellcentered/tpfa/fourierslaw.hh> #include <dumux/discretization/cellcentered/mpfa/fourierslaw.hh> #include <dumux/discretization/box/fourierslaw.hh> +#include <dumux/discretization/staggered/freeflow/fourierslaw.hh> #endif diff --git a/dumux/discretization/staggered/freeflow/fourierslaw.hh b/dumux/discretization/staggered/freeflow/fourierslaw.hh new file mode 100644 index 0000000000..8cb9b1d755 --- /dev/null +++ b/dumux/discretization/staggered/freeflow/fourierslaw.hh @@ -0,0 +1,131 @@ +// -*- 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 This file contains the data which is required to calculate + * diffusive mass fluxes due to molecular diffusion with Fourier's law. + */ +#ifndef DUMUX_DISCRETIZATION_STAGGERED_FOURIERS_LAW_HH +#define DUMUX_DISCRETIZATION_STAGGERED_FOURIERS_LAW_HH + +#include <dune/common/float_cmp.hh> + +#include <dumux/common/math.hh> +#include <dumux/common/parameters.hh> + +#include <dumux/implicit/properties.hh> +#include <dumux/discretization/methods.hh> +#include <dumux/discretization/fluxvariablescaching.hh> + +namespace Dumux +{ + +namespace Properties +{ +// forward declaration of properties +NEW_PROP_TAG(CellCenterPrimaryVariables); +} + +/*! + * \ingroup StaggeredFouriersLaw + * \brief Specialization of Fourier's Law for the staggered free flow method. + */ +template <class TypeTag> +class FouriersLawImplementation<TypeTag, DiscretizationMethods::Staggered > +{ + using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); + using Problem = typename GET_PROP_TYPE(TypeTag, Problem); + using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace); + using GridView = typename GET_PROP_TYPE(TypeTag, GridView); + using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry); + using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables); + using Element = typename GridView::template Codim<0>::Entity; + using CellCenterPrimaryVariables = typename GET_PROP_TYPE(TypeTag, CellCenterPrimaryVariables); + using ThermalConductivityModel = typename GET_PROP_TYPE(TypeTag, ThermalConductivityModel); + using Indices = typename GET_PROP_TYPE(TypeTag, Indices); + + static const int dim = GridView::dimension; + static const int dimWorld = GridView::dimensionworld; + + enum { + energyBalanceIdx = Indices::energyBalanceIdx + }; + +public: + // state the discretization method this implementation belongs to + static const DiscretizationMethods myDiscretizationMethod = DiscretizationMethods::Staggered; + + //! state the type for the corresponding cache and its filler + //! We don't cache anything for this law + using Cache = FluxVariablesCaching::EmptyDiffusionCache; + using CacheFiller = FluxVariablesCaching::EmptyCacheFiller<TypeTag>; + + static CellCenterPrimaryVariables diffusiveFluxForCellCenter(const Problem& problem, + const FVElementGeometry& fvGeometry, + const ElementVolumeVariables& elemVolVars, + const SubControlVolumeFace &scvf) + { + CellCenterPrimaryVariables flux(0.0); + + const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx()); + const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx()); + const auto& insideVolVars = elemVolVars[insideScv]; + const auto& outsideVolVars = scvf.boundary() ? insideVolVars : elemVolVars[scvf.outsideScvIdx()]; + + // effective conductivity tensors + auto insideLambda = ThermalConductivityModel::effectiveThermalConductivity(insideVolVars, problem.spatialParams(), element, fvGeometry, insideScv); + auto outsideLambda = ThermalConductivityModel::effectiveThermalConductivity(outsideVolVars, problem.spatialParams(), element, fvGeometry, outsideScv); + + // scale by extrusion factor + insideLambda *= insideVolVars.extrusionFactor(); + outsideLambda *= outsideVolVars.extrusionFactor(); + + // the resulting averaged conductivity tensor + const auto lambda = problem.spatialParams().harmonicMean(insideLambda, outsideLambda, scvf.unitOuterNormal()); + + const Scalar insideTemp = insideVolVars.temperature(); + Scalar distance(0.0), outsideTemp(insideTemp); + + if(scvf.boundary()) + { + const auto bcTypes = problem.boundaryTypesAtPos(scvf.center()); + if(bcTypes.isOutflow(energyBalanceIdx)) + return flux; // TODO flux = 0?? + else if(bcTypes.isNeumann(energyBalanceIdx)) + return flux; // TODO: implement neumann + else + { + distance = (insideScv.dofPosition() - scvf.ipGlobal()).two_norm(); + outsideTemp = problem.dirichletAtPos(scvf.center())[energyBalanceIdx]); + } + } + else + { + distance = (insideScv.dofPosition() - outsideScv.dofPosition()); + outsideTemp = outsideVolVars.temperature(); + } + + flux[energyBalanceIdx] = (insideTemp - outsideTemp); + flux[energyBalanceIdx] *= lambda / distance; + return -1.0*flux; + } +}; +} // end namespace + +#endif -- GitLab