From 8951cc0073f449f8c24d5d00c98e1c4982236fd8 Mon Sep 17 00:00:00 2001 From: Klaus Mosthaf <klmos@env.dtu.dk> Date: Wed, 29 Jan 2014 09:07:19 +0000 Subject: [PATCH] added 2cnistokes2p2cnilocaloperator and 2cnistokes2p2cni subfolder in dumux/multidomain. Adapted makefiles and configure. git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@12379 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- configure.ac | 1 + .../2cnistokes2p2cnilocaloperator.hh | 202 ++++++++++++++++++ .../multidomain/2cnistokes2p2cni/Makefile.am | 4 + .../2cstokes2p2cnewtoncontroller.hh | 4 +- dumux/multidomain/Makefile.am | 3 +- 5 files changed, 210 insertions(+), 4 deletions(-) create mode 100644 dumux/multidomain/2cnistokes2p2cni/2cnistokes2p2cnilocaloperator.hh create mode 100644 dumux/multidomain/2cnistokes2p2cni/Makefile.am diff --git a/configure.ac b/configure.ac index 39272660ee..e311465a31 100644 --- a/configure.ac +++ b/configure.ac @@ -83,6 +83,7 @@ AC_CONFIG_FILES([dumux.pc dumux/material/eos/Makefile dumux/multidomain/Makefile dumux/multidomain/2cstokes2p2c/Makefile + dumux/multidomain/2cnistokes2p2cni/Makefile dumux/multidomain/common/Makefile dumux/multidomain/couplinglocalresiduals/Makefile dumux/nonlinear/Makefile diff --git a/dumux/multidomain/2cnistokes2p2cni/2cnistokes2p2cnilocaloperator.hh b/dumux/multidomain/2cnistokes2p2cni/2cnistokes2p2cnilocaloperator.hh new file mode 100644 index 0000000000..bdc7153fc4 --- /dev/null +++ b/dumux/multidomain/2cnistokes2p2cni/2cnistokes2p2cnilocaloperator.hh @@ -0,0 +1,202 @@ +// -*- 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 local operator extends the 2cstokes2p2clocaloperator + * by non-isothermal conditions. + */ +#ifndef DUMUX_TWOCNISTOKES2P2CNILOCALOPERATOR_HH +#define DUMUX_TWOCNISTOKES2P2CNILOCALOPERATOR_HH + +#include <dumux/multidomain/2cstokes2p2c/2cstokes2p2clocaloperator.hh> + +#include <dumux/freeflow/stokesncni/stokesncnimodel.hh> +#include <dumux/implicit/2p2cnicoupling/2p2cnicouplingmodel.hh> + +namespace Dumux { + +/*! + * \brief The extension of the local operator for the coupling of a two-component Stokes model + * and a two-phase two-component Darcy model for non-isothermal conditions. + */ +template<class TypeTag> +class TwoCNIStokesTwoPTwoCNILocalOperator : + public TwoCStokesTwoPTwoCLocalOperator<TypeTag> +{ +public: + typedef typename GET_PROP_TYPE(TypeTag, Problem) GlobalProblem; + + // Get the TypeTags of the subproblems + typedef typename GET_PROP_TYPE(TypeTag, SubDomain1TypeTag) Stokes2cniTypeTag; + typedef typename GET_PROP_TYPE(TypeTag, SubDomain2TypeTag) TwoPTwoCNITypeTag; + + typedef typename GET_PROP_TYPE(Stokes2cniTypeTag, FluxVariables) BoundaryVariables1; + typedef typename GET_PROP_TYPE(TwoPTwoCNITypeTag, FluxVariables) BoundaryVariables2; + + // Multidomain Grid and Subgrid types + typedef typename GET_PROP_TYPE(TypeTag, MultiDomainGrid) MDGrid; + typedef typename GET_PROP_TYPE(Stokes2cniTypeTag, GridView) Stokes2cniGridView; + typedef typename GET_PROP_TYPE(TwoPTwoCNITypeTag, GridView) TwoPTwoCNIGridView; + + typedef typename Stokes2cniGridView::template Codim<0>::Entity SDElement1; + typedef typename TwoPTwoCNIGridView::template Codim<0>::Entity SDElement2; + + typedef typename GET_PROP_TYPE(Stokes2cniTypeTag, Indices) Stokes2cniIndices; + typedef typename GET_PROP_TYPE(TwoPTwoCNITypeTag, Indices) TwoPTwoCNIIndices; + + enum { dim = MDGrid::dimension }; + enum { + energyEqIdx1 = Stokes2cniIndices::energyEqIdx //!< Index of the energy balance equation + }; + enum { // indices in the Darcy domain + numPhases2 = GET_PROP_VALUE(TwoPTwoCNITypeTag, NumPhases), + + // equation index + energyEqIdx2 = TwoPTwoCNIIndices::energyEqIdx, //!< Index of the energy balance equation + + wPhaseIdx2 = TwoPTwoCNIIndices::wPhaseIdx, //!< Index for the liquid phase + nPhaseIdx2 = TwoPTwoCNIIndices::nPhaseIdx //!< Index for the gas phase + }; + + typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar; + typedef Dune::FieldVector<Scalar, dim> DimVector; //!< A field vector with dim entries + + typedef TwoCStokesTwoPTwoCLocalOperator<TypeTag> ParentType; + + TwoCNIStokesTwoPTwoCNILocalOperator(GlobalProblem& globalProblem) + : ParentType(globalProblem) + { } + + static const bool doAlphaCoupling = true; + static const bool doPatternCoupling = true; + + //! \copydoc Dumux::TwoCStokesTwoPTwoCLocalOperator::evalCoupling12() + template<typename LFSU1, typename LFSU2, typename RES1, typename RES2, typename CParams> + void evalCoupling12(const LFSU1& lfsu_s, const LFSU2& lfsu_n, + const int vertInElem1, const int vertInElem2, + const SDElement1& sdElement1, const SDElement2& sdElement2, + const BoundaryVariables1& boundaryVars1, const BoundaryVariables2& boundaryVars2, + const CParams &cParams, + RES1& couplingRes1, RES2& couplingRes2) const + { + const DimVector& globalPos1 = cParams.fvGeometry1.subContVol[vertInElem1].global; + const DimVector& bfNormal1 = boundaryVars1.face().normal; + const Scalar normalMassFlux1 = boundaryVars1.normalVelocity() * + cParams.elemVolVarsCur1[vertInElem1].density(); + GlobalProblem& globalProblem = this->globalProblem(); + + // evaluate coupling of mass and momentum balances + ParentType::evalCoupling12(lfsu_s, lfsu_n, + vertInElem1, vertInElem2, + sdElement1, sdElement2, + boundaryVars1, boundaryVars2, + cParams, + couplingRes1, couplingRes2); + + if (cParams.boundaryTypes2.isCouplingInflow(energyEqIdx2)) + { + if (globalProblem.sdProblem1().isCornerPoint(globalPos1)) + { + const Scalar convectiveFlux = + normalMassFlux1 * + cParams.elemVolVarsCur1[vertInElem1].enthalpy(); + const Scalar conductiveFlux = + bfNormal1 * + boundaryVars1.temperatureGrad() * + boundaryVars1.thermalConductivity(); + + couplingRes2.accumulate(lfsu_n.child(energyEqIdx2), vertInElem2, + -(convectiveFlux - conductiveFlux)); + } + else + { + // the energy flux from the stokes domain + couplingRes2.accumulate(lfsu_n.child(energyEqIdx2), vertInElem2, + globalProblem.localResidual1().residual(vertInElem1)[energyEqIdx1]); + } + } + if (cParams.boundaryTypes2.isCouplingOutflow(energyEqIdx2)) + { + // set residualDarcy[energyEqIdx2] = T in 2p2cnilocalresidual.hh + couplingRes2.accumulate(lfsu_n.child(energyEqIdx2), vertInElem2, + -cParams.elemVolVarsCur1[vertInElem1].temperature()); + } + } + + //! \copydoc Dumux::TwoCStokesTwoPTwoCLocalOperator::evalCoupling21() + template<typename LFSU1, typename LFSU2, typename RES1, typename RES2, typename CParams> + void evalCoupling21(const LFSU1& lfsu_s, const LFSU2& lfsu_n, + const int vertInElem1, const int vertInElem2, + const SDElement1& sdElement1, const SDElement2& sdElement2, + const BoundaryVariables1& boundaryVars1, const BoundaryVariables2& boundaryVars2, + const CParams &cParams, + RES1& couplingRes1, RES2& couplingRes2) const + { + GlobalProblem& globalProblem = this->globalProblem(); + + // evaluate coupling of mass and momentum balances + ParentType::evalCoupling21(lfsu_s, lfsu_n, + vertInElem1, vertInElem2, + sdElement1, sdElement2, + boundaryVars1, boundaryVars2, + cParams, + couplingRes1, couplingRes2); + + // TODO: this should be done only once + const DimVector& globalPos2 = cParams.fvGeometry2.subContVol[vertInElem2].global; + // const DimVector& bfNormal2 = boundaryVars2.face().normal; + DimVector normalMassFlux2(0.); + + // velocity*normal*area*rho + for (int phaseIdx=0; phaseIdx<numPhases2; ++phaseIdx) + normalMassFlux2[phaseIdx] = -boundaryVars2.volumeFlux(phaseIdx)* + cParams.elemVolVarsCur2[vertInElem2].density(phaseIdx); + //////////////////////////////////////// + + if (cParams.boundaryTypes1.isCouplingOutflow(energyEqIdx1)) + { + // set residualStokes[energyIdx1] = T in stokes2cnilocalresidual.hh + couplingRes1.accumulate(lfsu_s.child(energyEqIdx1), vertInElem1, + -cParams.elemVolVarsCur2[vertInElem2].temperature()); + } + if (cParams.boundaryTypes1.isCouplingInflow(energyEqIdx1)) + { + if (globalProblem.sdProblem2().isCornerPoint(globalPos2)) + { + const Scalar convectiveFlux = normalMassFlux2[nPhaseIdx2] * + cParams.elemVolVarsCur2[vertInElem2].enthalpy(nPhaseIdx2) + + + normalMassFlux2[wPhaseIdx2] * + cParams.elemVolVarsCur2[vertInElem2].enthalpy(wPhaseIdx2); + const Scalar conductiveFlux = boundaryVars2.normalMatrixHeatFlux(); + + couplingRes1.accumulate(lfsu_s.child(energyEqIdx1), vertInElem1, + -(convectiveFlux - conductiveFlux)); + } + else + { + couplingRes1.accumulate(lfsu_s.child(energyEqIdx1), vertInElem1, + globalProblem.localResidual2().residual(vertInElem2)[energyEqIdx2]); + } + } + } +}; +} // end namespace Dumux + +#endif // DUMUX_TWOCNISTOKES2P2CNILOCALOPERATOR_HH diff --git a/dumux/multidomain/2cnistokes2p2cni/Makefile.am b/dumux/multidomain/2cnistokes2p2cni/Makefile.am new file mode 100644 index 0000000000..3b00952d82 --- /dev/null +++ b/dumux/multidomain/2cnistokes2p2cni/Makefile.am @@ -0,0 +1,4 @@ +2cnistokes2p2cnidir = $(includedir)/dumux/multidomain/2cnistokes2p2cni +2cnistokes2p2cni_HEADERS = *.hh + +include $(top_srcdir)/am/global-rules diff --git a/dumux/multidomain/2cstokes2p2c/2cstokes2p2cnewtoncontroller.hh b/dumux/multidomain/2cstokes2p2c/2cstokes2p2cnewtoncontroller.hh index 612aec729b..4a3ad77aa4 100644 --- a/dumux/multidomain/2cstokes2p2c/2cstokes2p2cnewtoncontroller.hh +++ b/dumux/multidomain/2cstokes2p2c/2cstokes2p2cnewtoncontroller.hh @@ -50,9 +50,7 @@ public: : ParentType(problem) { } - /*! - * \brief Indicates that one Newton iteration was finished. - */ + //! \copydoc Dumux::NewtonController::newtonEndStep() void newtonEndStep(SolutionVector &uCurrentIter, SolutionVector &uLastIter) { ParentType::newtonEndStep(uCurrentIter, uLastIter); diff --git a/dumux/multidomain/Makefile.am b/dumux/multidomain/Makefile.am index 2f533181d0..0b4a1d7a46 100644 --- a/dumux/multidomain/Makefile.am +++ b/dumux/multidomain/Makefile.am @@ -1,7 +1,8 @@ SUBDIRS = \ common \ couplinglocalresiduals \ - 2cstokes2p2c + 2cstokes2p2c \ + 2cnistokes2p2cni multidomaindir = $(includedir)/dumux/multidomain -- GitLab