Commit 216bf79b authored by Dennis Gläser's avatar Dennis Gläser Committed by Timo Koch
Browse files

[mpfa] mpfa methods get own global vol vars object

Boundary volume variables are now existent also for neumann boundaries.
parent 3284cee4
......@@ -78,15 +78,9 @@ public:
const auto& volVarsPositions = fluxVarsCache.advectionVolVarsPositions(phaseIdx);
const auto& tij = fluxVarsCache.advectionTij(phaseIdx);
Scalar rho;
if (!scvf.boundary())
{
rho = elemVolVars[scvf.outsideScvIdx()].density(phaseIdx);
rho += elemVolVars[scvf.insideScvIdx()].density(phaseIdx);
rho /= 2.0;
}
else
rho = elemVolVars[scvf.outsideScvIdx()].density(phaseIdx);
Scalar rho = elemVolVars[scvf.outsideScvIdx()].density(phaseIdx);
rho += elemVolVars[scvf.insideScvIdx()].density(phaseIdx);
rho /= 2.0;
// calculate Tij*pj
Scalar flux(0.0);
......
// -*- 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 The global volume variables class for cell centered models
*/
#ifndef DUMUX_DISCRETIZATION_CC_MPFA_GLOBAL_VOLUMEVARIABLES_HH
#define DUMUX_DISCRETIZATION_CC_MPFA_GLOBAL_VOLUMEVARIABLES_HH
#include <dumux/implicit/properties.hh>
namespace Dumux
{
/*!
* \ingroup ImplicitModel
* \brief Base class for the volume variables vector
*/
template<class TypeTag, bool enableGlobalVolVarsCache>
class CCMpfaGlobalVolumeVariables
{};
//! specialization in case of storing the volume variables
template<class TypeTag>
class CCMpfaGlobalVolumeVariables<TypeTag, /*enableGlobalVolVarsCache*/true>
{
// The local class needs to access and change volVars
friend typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables);
// The local jacobian needs to access and change volVars for derivative calculation
friend typename GET_PROP_TYPE(TypeTag, LocalJacobian);
// as does the primary variable switch
friend class PrimaryVariableSwitch<TypeTag>;
friend typename GET_PROP_TYPE(TypeTag, PrimaryVariableSwitch);
using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector);
using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables);
using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables);
using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume);
using IndexType = typename GridView::IndexSet::IndexType;
static const int dim = GridView::dimension;
using Element = typename GridView::template Codim<0>::Entity;
public:
void update(Problem& problem, const SolutionVector& sol)
{
problemPtr_ = &problem;
auto numScv = problem.model().globalFvGeometry().numScv();
auto numBoundaryScvf = problem.model().globalFvGeometry().numBoundaryScvf();
volumeVariables_.resize(numScv + numBoundaryScvf);
for (const auto& element : elements(problem.gridView()))
{
auto fvGeometry = localView(problem.model().globalFvGeometry());
fvGeometry.bindElement(element);
for (auto&& scv : scvs(fvGeometry))
volumeVariables_[scv.index()].update(sol[scv.dofIndex()], problem, element, scv);
// handle the boundary volume variables
for (auto&& scvf : scvfs(fvGeometry))
{
// if we are not on a boundary, skip the rest
if (!scvf.boundary())
continue;
// check if boundary is a pure dirichlet boundary
const auto bcTypes = problem.boundaryTypes(element, scvf);
if (bcTypes.hasOnlyDirichlet())
{
const auto insideScvIdx = scvf.insideScvIdx();
const auto& insideScv = fvGeometry.scv(insideScvIdx);
const auto dirichletPriVars = problem.dirichlet(element, scvf);
volumeVariables_[scvf.outsideScvIdx()].update(dirichletPriVars, problem, element, insideScv);
}
else
volumeVariables_[scvf.outsideScvIdx()] = volumeVariables_[scvf.insideScvIdx()];
}
}
}
/*!
* \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 ElementVolumeVariables localView(const CCMpfaGlobalVolumeVariables& global)
{ return ElementVolumeVariables(global); }
const VolumeVariables& volVars(const IndexType scvIdx) const
{ return volumeVariables_[scvIdx]; }
VolumeVariables& volVars(const IndexType scvIdx)
{ return volumeVariables_[scvIdx]; }
private:
const Problem& problem_() const
{ return *problemPtr_; }
const Problem* problemPtr_;
std::vector<VolumeVariables> volumeVariables_;
};
//! Specialization when the current volume variables are not stored globally
template<class TypeTag>
class CCMpfaGlobalVolumeVariables<TypeTag, /*enableGlobalVolVarsCache*/false>
{
// local class needs access to the problem
friend typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables);
using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector);
using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables);
public:
void update(Problem& problem, const SolutionVector& sol)
{ 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 ElementVolumeVariables localView(const CCMpfaGlobalVolumeVariables& global)
{ return ElementVolumeVariables(global); }
private:
Problem& problem_() const
{ return *problemPtr_;}
Problem* problemPtr_;
};
} // end namespace
#endif
......@@ -32,6 +32,7 @@
#include <dumux/discretization/methods.hh>
#include <dumux/discretization/cellcentered/mpfa/methods.hh>
#include <dumux/discretization/cellcentered/mpfa/globalfvgeometry.hh>
#include <dumux/discretization/cellcentered/mpfa/globalvolumevariables.hh>
#include <dumux/discretization/cellcentered/mpfa/globalfluxvariablescache.hh>
#include <dumux/discretization/cellcentered/mpfa/fvelementgeometry.hh>
#include <dumux/discretization/cellcentered/mpfa/elementvolumevariables.hh>
......@@ -75,6 +76,9 @@ SET_TYPE_PROP(CCMpfaModel, GlobalInteractionVolumeSeeds, CCMpfaGlobalInteraction
//! Set the default for the global finite volume geometry
SET_TYPE_PROP(CCMpfaModel, GlobalFVGeometry, CCMpfaGlobalFVGeometry<TypeTag, GET_PROP_VALUE(TypeTag, EnableGlobalFVGeometryCache)>);
//! The global current volume variables vector class
SET_TYPE_PROP(CCMpfaModel, GlobalVolumeVariables, Dumux::CCMpfaGlobalVolumeVariables<TypeTag, GET_PROP_VALUE(TypeTag, EnableGlobalVolumeVariablesCache)>);
//! The global flux variables cache vector class
SET_TYPE_PROP(CCMpfaModel, GlobalFluxVariablesCache, CCMpfaGlobalFluxVariablesCache<TypeTag, GET_PROP_VALUE(TypeTag, EnableGlobalFluxVariablesCache)>);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment