Commit e4a65c56 authored by Ivan Buntic's avatar Ivan Buntic Committed by Timo Koch
Browse files

[disc][dumux] Use discretization tag instead of enum for comparisons.

parent c6ceef74
......@@ -52,7 +52,7 @@ class GridAdaptInitializationIndicator
using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
static constexpr bool isBox = GetPropType<TypeTag, Properties::GridGeometry>::discMethod == DiscretizationMethod::box;
static constexpr bool isBox = GetPropType<TypeTag, Properties::GridGeometry>::discMethod == DiscretizationMethods::box;
public:
......
......@@ -477,7 +477,7 @@ public:
}
// also consider lateral faces outside the own element for face-centered staggered schemes
if constexpr (GridGeometry::discMethod == DiscretizationMethod::fcstaggered)
if constexpr (GridGeometry::discMethod == DiscretizationMethods::fcstaggered)
{
if (scvf.isLateral())
{
......@@ -509,7 +509,7 @@ public:
}
// also consider lateral faces outside the own element for face-centered staggered schemes
if constexpr (GridGeometry::discMethod == DiscretizationMethod::fcstaggered)
if constexpr (GridGeometry::discMethod == DiscretizationMethods::fcstaggered)
{
if (scvf.isLateral())
{
......@@ -549,7 +549,7 @@ public:
}
// also consider lateral faces outside the own element for face-centered staggered schemes
if constexpr (GridGeometry::discMethod == DiscretizationMethod::fcstaggered)
if constexpr (GridGeometry::discMethod == DiscretizationMethods::fcstaggered)
{
// treat normal/parallel scvs for parallel runs TODO description, put in function
if (problem.gridGeometry().gridView().comm().size() > 1 && element.partitionType() == Dune::InteriorEntity)
......
......@@ -423,7 +423,7 @@ public:
//! Compute the derivative of the flux residual
template<class PartialDerivativeMatrices, class T = TypeTag>
std::enable_if_t<GetPropType<T, Properties::GridGeometry>::discMethod != DiscretizationMethod::box, void>
std::enable_if_t<GetPropType<T, Properties::GridGeometry>::discMethod != DiscretizationMethods::box, void>
addFluxDerivatives(PartialDerivativeMatrices& derivativeMatrices,
const Problem& problem,
const Element& element,
......@@ -437,7 +437,7 @@ public:
//! Compute the derivative of the flux residual for the box method
template<class JacobianMatrix, class T = TypeTag>
std::enable_if_t<GetPropType<T, Properties::GridGeometry>::discMethod == DiscretizationMethod::box, void>
std::enable_if_t<GetPropType<T, Properties::GridGeometry>::discMethod == DiscretizationMethods::box, void>
addFluxDerivatives(JacobianMatrix& A,
const Problem& problem,
const Element& element,
......
......@@ -43,7 +43,7 @@ void assembleInitialSolution(SolutionVector& sol, const Problem& problem)
using GridGeometry = std::decay_t<decltype(gg)>;
// box method
if constexpr (GridGeometry::discMethod == DiscretizationMethod::box)
if constexpr (GridGeometry::discMethod == DiscretizationMethods::box)
{
constexpr int dim = GridGeometry::GridView::dimension;
const auto numDofs = gg.vertexMapper().size();
......@@ -79,7 +79,7 @@ void assembleInitialSolution(SolutionVector& sol, const Problem& problem)
}
// staggered methods
else if constexpr (GridGeometry::discMethod == DiscretizationMethod::staggered)
else if constexpr (GridGeometry::discMethod == DiscretizationMethods::staggered)
{
problem.applyInitialSolution(sol);
}
......
......@@ -35,7 +35,7 @@ namespace Dumux {
* \brief Helper function to generate Jacobian pattern for the box method
*/
template<bool isImplicit, class GridGeometry,
typename std::enable_if_t<(GridGeometry::discMethod == DiscretizationMethod::box), int> = 0>
typename std::enable_if_t<(GridGeometry::discMethod == DiscretizationMethods::box), int> = 0>
Dune::MatrixIndexSet getJacobianPattern(const GridGeometry& gridGeometry)
{
const auto numDofs = gridGeometry.numDofs();
......@@ -84,8 +84,8 @@ Dune::MatrixIndexSet getJacobianPattern(const GridGeometry& gridGeometry)
* \brief Helper function to generate Jacobian pattern for cell-centered methods
*/
template<bool isImplicit, class GridGeometry,
typename std::enable_if_t<( (GridGeometry::discMethod == DiscretizationMethod::cctpfa)
|| (GridGeometry::discMethod == DiscretizationMethod::ccmpfa) ), int> = 0>
typename std::enable_if_t<( (GridGeometry::discMethod == DiscretizationMethods::cctpfa)
|| (GridGeometry::discMethod == DiscretizationMethods::ccmpfa) ), int> = 0>
Dune::MatrixIndexSet getJacobianPattern(const GridGeometry& gridGeometry)
{
const auto numDofs = gridGeometry.numDofs();
......@@ -118,7 +118,7 @@ Dune::MatrixIndexSet getJacobianPattern(const GridGeometry& gridGeometry)
* \brief Helper function to generate Jacobian pattern for the staggered method
*/
template<bool isImplicit, class GridGeometry,
typename std::enable_if_t<( (GridGeometry::discMethod == DiscretizationMethod::staggered) ), int> = 0>
typename std::enable_if_t<( (GridGeometry::discMethod == DiscretizationMethods::staggered) ), int> = 0>
auto getJacobianPattern(const GridGeometry& gridGeometry)
{
// resize the jacobian and the residual
......@@ -200,7 +200,7 @@ Dune::MatrixIndexSet getFEJacobianPattern(const FEBasis& feBasis)
* in fem is the same independent of the time discretization scheme.
*/
template<bool isImplicit, class GridGeometry,
typename std::enable_if_t<(GridGeometry::discMethod == DiscretizationMethod::fem), int> = 0>
typename std::enable_if_t<(GridGeometry::discMethod == DiscretizationMethods::fem), int> = 0>
Dune::MatrixIndexSet getJacobianPattern(const GridGeometry& gridGeometry)
{ return getFEJacobianPattern(gridGeometry.feBasis()); }
......@@ -209,7 +209,7 @@ Dune::MatrixIndexSet getJacobianPattern(const GridGeometry& gridGeometry)
* \brief Helper function to generate Jacobian pattern for the face-centered staggered method
*/
template<bool isImplicit, class GridGeometry,
typename std::enable_if_t<( (GridGeometry::discMethod == DiscretizationMethod::fcstaggered) ), int> = 0>
typename std::enable_if_t<( (GridGeometry::discMethod == DiscretizationMethods::fcstaggered) ), int> = 0>
Dune::MatrixIndexSet getJacobianPattern(const GridGeometry& gridGeometry)
{
// resize the jacobian and the residual
......
......@@ -71,8 +71,8 @@ class FVProblem
using PointSourceMap = std::map< std::pair<std::size_t, std::size_t>,
std::vector<PointSource> >;
static constexpr bool isBox = GridGeometry::discMethod == DiscretizationMethod::box;
static constexpr bool isStaggered = GridGeometry::discMethod == DiscretizationMethod::staggered;
static constexpr bool isBox = GridGeometry::discMethod == DiscretizationMethods::box;
static constexpr bool isStaggered = GridGeometry::discMethod == DiscretizationMethods::staggered;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
......
......@@ -301,7 +301,7 @@ public:
// split the source values equally among all concerned entities
source.setEmbeddings(entities.size()*source.embeddings());
if constexpr (GridGeometry::discMethod == DiscretizationMethod::box)
if constexpr (GridGeometry::discMethod == DiscretizationMethods::box)
{
// loop over all concerned elements
auto fvGeometry = localView(gridGeometry);
......
......@@ -116,7 +116,7 @@ private:
*/
template<class Element, class SolutionVector, class GridGeometry>
auto elementSolution(const Element& element, const SolutionVector& sol, const GridGeometry& gg)
-> std::enable_if_t<GridGeometry::discMethod == DiscretizationMethod::box,
-> std::enable_if_t<GridGeometry::discMethod == DiscretizationMethods::box,
BoxElementSolution<typename GridGeometry::LocalView,
std::decay_t<decltype(std::declval<SolutionVector>()[0])>>
>
......@@ -131,7 +131,7 @@ auto elementSolution(const Element& element, const SolutionVector& sol, const Gr
*/
template<class Element, class ElementVolumeVariables, class FVElementGeometry>
auto elementSolution(const Element& element, const ElementVolumeVariables& elemVolVars, const FVElementGeometry& gg)
-> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethod::box,
-> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::box,
BoxElementSolution<FVElementGeometry,
typename ElementVolumeVariables::VolumeVariables::PrimaryVariables>>
{
......
......@@ -44,7 +44,7 @@ public:
void computeBoundaryTypes(const Problem& problem)
{
// only do something for box
if (discMethod == DiscretizationMethod::box)
if (discMethod == DiscretizationMethods::box)
{
const auto& gridGeometry = problem.gridGeometry();
scvBoundaryTypes.resize(gridGeometry.vertexMapper().size());
......@@ -81,7 +81,7 @@ public:
template<class SubControlVolume>
const BoundaryTypes& boundaryTypes(const SubControlVolume& scv) const
{
if (discMethod == DiscretizationMethod::box)
if (discMethod == DiscretizationMethods::box)
return scvBoundaryTypes[scv.dofIndex()];
else
DUNE_THROW(Dune::InvalidStateException, "Only use this for the box discretization!");
......
......@@ -111,8 +111,8 @@ private:
*/
template<class Element, class SolutionVector, class GridGeometry>
auto elementSolution(const Element& element, const SolutionVector& sol, const GridGeometry& gg)
-> std::enable_if_t<GridGeometry::discMethod == DiscretizationMethod::cctpfa ||
GridGeometry::discMethod == DiscretizationMethod::ccmpfa,
-> std::enable_if_t<GridGeometry::discMethod == DiscretizationMethods::cctpfa ||
GridGeometry::discMethod == DiscretizationMethods::ccmpfa,
CCElementSolution<typename GridGeometry::LocalView,
std::decay_t<decltype(std::declval<SolutionVector>()[0])>>
>
......@@ -127,8 +127,8 @@ auto elementSolution(const Element& element, const SolutionVector& sol, const Gr
*/
template<class Element, class ElementVolumeVariables, class FVElementGeometry>
auto elementSolution(const Element& element, const ElementVolumeVariables& elemVolVars, const FVElementGeometry& gg)
-> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethod::cctpfa ||
FVElementGeometry::GridGeometry::discMethod == DiscretizationMethod::ccmpfa,
-> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::cctpfa ||
FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::ccmpfa,
CCElementSolution<FVElementGeometry, typename ElementVolumeVariables::VolumeVariables::PrimaryVariables>>
{
using PrimaryVariables = typename ElementVolumeVariables::VolumeVariables::PrimaryVariables;
......@@ -142,8 +142,8 @@ auto elementSolution(const Element& element, const ElementVolumeVariables& elemV
*/
template<class FVElementGeometry, class PrimaryVariables>
auto elementSolution(PrimaryVariables&& priVars)
-> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethod::cctpfa ||
FVElementGeometry::GridGeometry::discMethod == DiscretizationMethod::ccmpfa,
-> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::cctpfa ||
FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::ccmpfa,
CCElementSolution<FVElementGeometry, PrimaryVariables>>
{
return CCElementSolution<FVElementGeometry, PrimaryVariables>(std::move(priVars));
......@@ -156,8 +156,8 @@ auto elementSolution(PrimaryVariables&& priVars)
*/
template<class FVElementGeometry, class PrimaryVariables>
auto elementSolution(const PrimaryVariables& priVars)
-> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethod::cctpfa ||
FVElementGeometry::GridGeometry::discMethod == DiscretizationMethod::ccmpfa,
-> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::cctpfa ||
FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::ccmpfa,
CCElementSolution<FVElementGeometry, PrimaryVariables>>
{
return CCElementSolution<FVElementGeometry, PrimaryVariables>(priVars);
......
......@@ -129,7 +129,7 @@ private:
template<class Element, class SolutionVector, class GridGeometry>
auto elementSolution(const Element& element, const SolutionVector& sol, const GridGeometry& gg)
-> std::enable_if_t<
GridGeometry::discMethod == DiscretizationMethod::fcstaggered,
GridGeometry::discMethod == DiscretizationMethods::fcstaggered,
FaceCenteredStaggeredElementSolution<
typename GridGeometry::LocalView,
std::decay_t<decltype(std::declval<SolutionVector>()[0])>
......@@ -144,7 +144,7 @@ auto elementSolution(const Element& element, const SolutionVector& sol, const Gr
template<class Element, class ElementVolumeVariables, class FVElementGeometry>
auto elementSolution(const Element& element, const ElementVolumeVariables& elemVolVars, const FVElementGeometry& gg)
-> std::enable_if_t<
FVElementGeometry::GridGeometry::discMethod == DiscretizationMethod::fcstaggered,
FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::fcstaggered,
FaceCenteredStaggeredElementSolution<
FVElementGeometry,
typename ElementVolumeVariables::VolumeVariables::PrimaryVariables
......@@ -160,7 +160,7 @@ auto elementSolution(const Element& element, const ElementVolumeVariables& elemV
template<class FVElementGeometry, class PrimaryVariables>
auto elementSolution(PrimaryVariables&& priVars)
-> std::enable_if_t<
FVElementGeometry::GridGeometry::discMethod == DiscretizationMethod::fcstaggered,
FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::fcstaggered,
FaceCenteredStaggeredElementSolution<
FVElementGeometry,
std::decay_t<PrimaryVariables>
......
......@@ -60,7 +60,7 @@ using StaggeredElementSolution = Dune::BlockVector<PrimaryVariables>;
*/
template<class FVElementGeometry, class PrimaryVariables>
auto elementSolution(PrimaryVariables&& priVars)
-> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethod::staggered,
-> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::staggered,
StaggeredElementSolution<PrimaryVariables>>
{
return StaggeredElementSolution<PrimaryVariables>({std::move(priVars)});
......
......@@ -62,7 +62,7 @@ struct NavierStokesMomentumBoundaryFluxHelper
const bool zeroNormalVelocityGradient = true)
{
// TODO density upwinding?
static_assert(FVElementGeometry::GridGeometry::discMethod == DiscretizationMethod::fcstaggered);
static_assert(FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::fcstaggered);
using NumEqVector = typename Problem::Traits::NumEqVector;
constexpr std::size_t dim = static_cast<std::size_t>(FVElementGeometry::GridGeometry::GridView::dimension);
static_assert(
......@@ -213,7 +213,7 @@ struct NavierStokesMomentumBoundaryFluxHelper
const ElementFluxVariablesCache& elemFluxVarsCache,
const TangentialVelocityGradient& tangentialVelocityGradient = TangentialVelocityGradient(0.0))
{
static_assert(FVElementGeometry::GridGeometry::discMethod == DiscretizationMethod::fcstaggered);
static_assert(FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::fcstaggered);
using NumEqVector = typename Problem::Traits::NumEqVector;
constexpr std::size_t dim = static_cast<std::size_t>(FVElementGeometry::GridGeometry::GridView::dimension);
static_assert(
......
......@@ -211,7 +211,7 @@ public:
const ElementFluxVariablesCache& elemFluxVarsCache,
const SubControlVolumeFace& scvf) const
{
static_assert(FVElementGeometry::GridGeometry::discMethod == DiscretizationMethod::fcstaggered); // TODO overload this method for different discretizations
static_assert(FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::fcstaggered); // TODO overload this method for different discretizations
static_assert(
std::decay_t<decltype(
problem.neumann(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf)
......
......@@ -39,7 +39,7 @@ struct StaggeredVelocityReconstruction
static auto cellCenterVelocity(const VelocityHelper& getFaceVelocity,
const FVElementGeometry& fvGeometry)
{
static_assert(FVElementGeometry::GridGeometry::discMethod == DiscretizationMethod::cctpfa);
static_assert(FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::cctpfa);
using VelocityVector = typename FVElementGeometry::GridGeometry::GlobalCoordinate;
VelocityVector result(0.0);
......
......@@ -414,7 +414,7 @@ private:
void storeWallElementAndDirectionIndex_(const WallData& wallData)
{
// The wall Direction Index is used for flat quadrilateral channel problems only
if (!(GridGeometry::discMethod == DiscretizationMethod::staggered))
if (!(GridGeometry::discMethod == DiscretizationMethods::staggered))
DUNE_THROW(Dune::NotImplemented, "The wall direction Index can only be calculated for quadrilateral structured grids");
// If isFlatWallBounded, the corresonding wall element is stored for each element
......
......@@ -79,11 +79,11 @@ class PoroMechanicsCouplingManager : public virtual CouplingManager< MDTraits >
"The grid types of the two sub-problems have to be equal!");
//! this coupling manager is for cc - box only
static_assert(GridGeometry<PoroMechId>::discMethod == DiscretizationMethod::box,
static_assert(GridGeometry<PoroMechId>::discMethod == DiscretizationMethods::box,
"Poro-mechanical problem must be discretized with the box scheme for this coupling manager!");
static_assert(GridGeometry<PMFlowId>::discMethod == DiscretizationMethod::cctpfa ||
GridGeometry<PMFlowId>::discMethod == DiscretizationMethod::ccmpfa,
static_assert(GridGeometry<PMFlowId>::discMethod == DiscretizationMethods::cctpfa ||
GridGeometry<PMFlowId>::discMethod == DiscretizationMethods::ccmpfa,
"Porous medium flow problem must be discretized with a cell-centered scheme for this coupling manager!");
//! this does not work for enabled grid volume variables caching (update of local view in context has no effect)
......
......@@ -151,7 +151,7 @@ auto loadSolutionFromVtkFile(SolutionVector& sol,
}
}
// for staggered face data (which is written out as VTK point data) we just read in the vector
else if (dataType == VTKReader::DataType::pointData && GridGeometry::discMethod == DiscretizationMethod::staggered)
else if (dataType == VTKReader::DataType::pointData && GridGeometry::discMethod == DiscretizationMethods::staggered)
{
if (sol.size() != vec.size())
DUNE_THROW(Dune::InvalidStateException, "Solution size (" << sol.size() << ") does not match input size (" << vec.size() << ")!");
......@@ -333,19 +333,19 @@ void loadSolution(SolutionVector& sol,
const GridGeometry& gridGeometry)
{
const auto extension = fileName.substr(fileName.find_last_of(".") + 1);
auto dataType = GridGeometry::discMethod == DiscretizationMethod::box ?
auto dataType = GridGeometry::discMethod == DiscretizationMethods::box ?
VTKReader::DataType::pointData : VTKReader::DataType::cellData;
if (extension == "vtu" || extension == "vtp")
{
if (GridGeometry::discMethod == DiscretizationMethod::staggered && extension == "vtp")
if (GridGeometry::discMethod == DiscretizationMethods::staggered && extension == "vtp")
dataType = VTKReader::DataType::pointData;
loadSolutionFromVtkFile(sol, fileName, targetPvNameFunc, gridGeometry, dataType);
}
else if (extension == "pvtu" || extension == "pvtp")
{
if (GridGeometry::discMethod == DiscretizationMethod::staggered)
if (GridGeometry::discMethod == DiscretizationMethods::staggered)
DUNE_THROW(Dune::NotImplemented, "reading staggered solution from a parallel vtk file");
loadSolutionFromVtkFile(sol, fileName, targetPvNameFunc, gridGeometry, dataType);
......
......@@ -321,7 +321,7 @@ class VtkOutputModule : public VtkOutputModuleBase<typename GridVariables::GridG
using Element = typename GridView::template Codim<0>::Entity;
using VolVarsVector = Dune::FieldVector<Scalar, dimWorld>;
static constexpr bool isBox = GridGeometry::discMethod == DiscretizationMethod::box;
static constexpr bool isBox = GridGeometry::discMethod == DiscretizationMethods::box;
static constexpr int dofCodim = isBox ? dim : 0;
struct VolVarScalarDataInfo { std::function<Scalar(const VV&)> get; std::string name; Dumux::Vtk::Precision precision_; };
......
......@@ -75,7 +75,7 @@ class ElectroChemistry
};
using GridView = typename GridGeometry::GridView;
static constexpr bool isBox = GridGeometry::discMethod == DiscretizationMethod::box;
static constexpr bool isBox = GridGeometry::discMethod == DiscretizationMethods::box;
using GlobalPosition = typename Dune::FieldVector<typename GridView::ctype, GridView::dimensionworld>;
public:
......
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