Commit d51e66f6 authored by Kilian Weishaupt's avatar Kilian Weishaupt Committed by Timo Koch
Browse files

[staggered] Remove primary variables class

parent 0d434400
......@@ -33,7 +33,7 @@
#include <dumux/discretization/cellcentered/elementboundarytypes.hh>
#include <dumux/assembly/staggeredlocalresidual.hh>
#include <dumux/implicit/staggered/primaryvariables.hh>
#include <dumux/implicit/staggered/gridvariables.hh>
#include <dumux/discretization/cellcentered/subcontrolvolume.hh>
#include <dumux/discretization/staggered/gridvariables.hh>
......
// -*- 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 Primary Variables for the Staggered Grid models
*/
#ifndef DUMUX_STAGGERED_PRIMARYVARIABLES_HH
#define DUMUX_STAGGERED_PRIMARYVARIABLES_HH
#include <dune/istl/multitypeblockvector.hh>
#include <dumux/common/intrange.hh>
namespace Dumux
{
/*!
* \ingroup NavierStokesModel
* \brief This class inherits from DUNE's MultiTypeBlockVector and provides a specific [] operator for convenience
*/
template<class TypeTag,
class CellCenterPrimaryVariables = typename GET_PROP_TYPE(TypeTag, CellCenterPrimaryVariables),
class FacePrimaryVariables = typename GET_PROP_TYPE(TypeTag, FacePrimaryVariables)>
class StaggeredPrimaryVariables : public Dune::MultiTypeBlockVector<CellCenterPrimaryVariables, FacePrimaryVariables>
{
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
using Indices = typename GET_PROP_TYPE(TypeTag, Indices);
using DofTypeIndices = typename GET_PROP(TypeTag, DofTypeIndices);
typename DofTypeIndices::CellCenterIdx cellCenterIdx;
typename DofTypeIndices::FaceIdx faceIdx;
using ParentType = Dune::MultiTypeBlockVector<CellCenterPrimaryVariables, FacePrimaryVariables>;
static constexpr auto faceOffset = GET_PROP_VALUE(TypeTag, NumEqCellCenter);
public:
StaggeredPrimaryVariables() = default;
// introduce a blocklevel variable so that this class can be used in a Dune::BlockVector
static constexpr int blocklevel = 1;
/*!
* \brief Constructor to initialize all entries with the same value
*
* \param value The value
*/
StaggeredPrimaryVariables(const Scalar value) noexcept
{
(*this)[cellCenterIdx] = value;
(*this)[faceIdx] = value;
}
/*!
* \brief Constructor to initialize the cellcenter and face primary values with given values
*
* \param ccPriVars The cellcenter primary variables used for initialization
* \param facePriVars The face primary variables used for initialization
*/
StaggeredPrimaryVariables(CellCenterPrimaryVariables&& ccPriVars, FacePrimaryVariables&& facePriVars) noexcept
{
(*this)[cellCenterIdx] = std::forward<decltype(ccPriVars)>(ccPriVars);
(*this)[faceIdx] = std::forward<decltype(facePriVars)>(facePriVars);
}
/*!
* \brief Operator overload which allows to automatically access the "right" priVars vector via pvIdx.
* const version
* \note: the ParentType (DUNE multitypeblockvector) [] operator has to be visible (using ...)
*
* \param pvIdx The global index of the primary variable
*/
using ParentType::operator [];
const Scalar& operator [](const unsigned int pvIdx) const
{
if(pvIdx < faceOffset)
return ParentType::operator[](cellCenterIdx)[pvIdx];
else
return ParentType::operator[](faceIdx)[pvIdx - faceOffset];
}
/*!
* \brief Operator overload which allows to automatically access the "right" priVars vector via pvIdx
* non-const version
*
* \param pvIdx The global index of the primary variable
*/
Scalar& operator [](const unsigned int pvIdx)
{
if(pvIdx < faceOffset)
return ParentType::operator[](cellCenterIdx)[pvIdx];
else
return ParentType::operator[](faceIdx)[pvIdx - faceOffset];
}
};
/*!
* \brief Class which provides two ranges of indices (cc and face)
* cc: for(auto i : PriVarIndices(cellCenterIdx)) { ... }
* face: for(auto i : PriVarIndices(faceIdx)) { ... }
*/
template<class TypeTag>
class PriVarIndices : public IntRange
{
using DofTypeIndices = typename GET_PROP(TypeTag, DofTypeIndices);
using cellCenterIdx = typename DofTypeIndices::CellCenterIdx;
using faceIdx = typename DofTypeIndices::FaceIdx;
static constexpr auto numEqCellCenter = GET_PROP_VALUE(TypeTag, NumEqCellCenter);
static constexpr auto numEqFace = GET_PROP_VALUE(TypeTag, NumEqFace);
public:
PriVarIndices(cellCenterIdx) : IntRange(0, numEqCellCenter) {}
PriVarIndices(faceIdx) : IntRange(numEqCellCenter, numEqCellCenter + numEqFace) {}
};
} // namespace Dumux
#endif
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