Commit b1f04df8 authored by Timo Koch's avatar Timo Koch
Browse files

Merge branch 'feature/deduce-boundarytypes' into 'master'

Feature/deduce boundarytypes

See merge request !1981
parents e9624324 6d2d3eb4
......@@ -25,9 +25,11 @@
#define DUMUX_GRIDADAPTINITIALIZATIONINDICATOR_HH
#include <memory>
#include <dune/geometry/type.hh>
#include <dumux/common/properties.hh>
#include <dumux/common/parameters.hh>
#include <dumux/common/typetraits/problem.hh>
#include <dumux/discretization/method.hh>
namespace Dumux {
......@@ -49,7 +51,6 @@ class GridAdaptInitializationIndicator
using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
using BoundaryTypes = GetPropType<TypeTag, Properties::BoundaryTypes>;
static constexpr bool isBox = GetPropType<TypeTag, Properties::GridGeometry>::discMethod == DiscretizationMethod::box;
......@@ -225,6 +226,7 @@ public:
else
{
// container to store bcTypes
using BoundaryTypes = typename ProblemTraits<Problem>::BoundaryTypes;
std::vector<BoundaryTypes> bcTypes(fvGeometry.numScv());
// Get bcTypes and maybe mark for refinement on Dirichlet boundaries
......
......@@ -32,6 +32,7 @@
#include <dumux/common/properties.hh>
#include <dumux/common/parameters.hh>
#include <dumux/common/boundarytypes.hh>
#include <dumux/discretization/method.hh>
#include <dumux/assembly/initialsolution.hh>
......@@ -73,7 +74,7 @@ class FVProblem
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
using NumEqVector = GetPropType<TypeTag, Properties::NumEqVector>;
using BoundaryTypes = GetPropType<TypeTag, Properties::BoundaryTypes>;
using BoundaryTypes = Dumux::BoundaryTypes<PrimaryVariables::size()>;
public:
//! export traits of this problem
......@@ -82,7 +83,6 @@ public:
using Scalar = FVProblem::Scalar;
using PrimaryVariables = FVProblem::PrimaryVariables;
using NumEqVector = FVProblem::NumEqVector;
using BoundaryTypes = FVProblem::BoundaryTypes;
};
/*!
......@@ -136,8 +136,8 @@ public:
* \param element The finite element
* \param scv The sub control volume
*/
BoundaryTypes boundaryTypes(const Element &element,
const SubControlVolume &scv) const
auto boundaryTypes(const Element &element,
const SubControlVolume &scv) const
{
if (!isBox)
DUNE_THROW(Dune::InvalidStateException,
......@@ -154,8 +154,8 @@ public:
* \param element The finite element
* \param scvf The sub control volume face
*/
BoundaryTypes boundaryTypes(const Element &element,
const SubControlVolumeFace &scvf) const
auto boundaryTypes(const Element &element,
const SubControlVolumeFace &scvf) const
{
if (isBox)
DUNE_THROW(Dune::InvalidStateException,
......
......@@ -67,8 +67,9 @@ template<class TypeTag, class MyTypeTag>
struct JacobianMatrix { using type = UndefinedProperty; }; //!< Type of the global jacobian matrix
template<class TypeTag, class MyTypeTag>
struct SolutionVector { using type = UndefinedProperty; }; //!< Vector containing all primary variable vector of the grid
template<class TypeTag, class MyTypeTag>
struct BoundaryTypes { using type = UndefinedProperty; }; //!< Stores the boundary types of a single degree of freedom
struct [[deprecated("BoundaryTypes will be removed after 3.3. Deduce boundary types from Problem.")]] BoundaryTypes { using type = UndefinedProperty; }; //!< Stores the boundary types of a single degree of freedom
//! The type of the local residual function, i.e. the equation to be solved. Must inherit
//! from the BaseLocalResidual property and fulfill its interfaces.
......
// -*- 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 3 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
* \ingroup Typetraits
* \brief Type traits for problem classes
*/
#ifndef DUMUX_TYPETRAITS_PROBLEM_HH
#define DUMUX_TYPETRAITS_PROBLEM_HH
#include <type_traits>
#include <dumux/discretization/method.hh>
namespace Dumux {
// forward declare
namespace Impl {
template<class Problem, DiscretizationMethod dm>
struct ProblemTraits;
} // end namespace Impl
/*!
* \ingroup Common
* \brief Type traits for problem classes.
*/
template<class Problem>
struct ProblemTraits
{
using GridGeometry = std::decay_t<decltype(std::declval<Problem>().gridGeometry())>;
using BoundaryTypes = typename Impl::template ProblemTraits<Problem, GridGeometry::discMethod>::BoundaryTypes;
};
} // end namespace Dumux
#endif
......@@ -25,11 +25,14 @@
#ifndef DUMUX_DISCRETIZTAION_BOX_HH
#define DUMUX_DISCRETIZTAION_BOX_HH
#include <type_traits>
#include <dune/common/fvector.hh>
#include <dune/geometry/multilineargeometry.hh>
#include <dumux/common/properties.hh>
#include <dumux/common/boundaryflag.hh>
#include <dumux/common/typetraits/problem.hh>
#include <dumux/assembly/boxlocalresidual.hh>
......@@ -89,13 +92,38 @@ public:
//! Set the default for the ElementBoundaryTypes
template<class TypeTag>
struct ElementBoundaryTypes<TypeTag, TTag::BoxModel> { using type = BoxElementBoundaryTypes<GetPropType<TypeTag, Properties::BoundaryTypes>>; };
struct ElementBoundaryTypes<TypeTag, TTag::BoxModel>
{
private:
using Problem = GetPropType<TypeTag, Properties::Problem>;
using BoundaryTypes = typename ProblemTraits<Problem>::BoundaryTypes;
public:
using type = BoxElementBoundaryTypes<BoundaryTypes>;
};
//! Set the BaseLocalResidual to BoxLocalResidual
template<class TypeTag>
struct BaseLocalResidual<TypeTag, TTag::BoxModel> { using type = BoxLocalResidual<TypeTag>; };
} // namespace Properties
namespace Impl {
template<class Problem>
struct ProblemTraits<Problem, DiscretizationMethod::box>
{
private:
using GG = std::decay_t<decltype(std::declval<Problem>().gridGeometry())>;
using Element = typename GG::GridView::template Codim<0>::Entity;
using SubControlVolume = typename GG::SubControlVolume;
public:
using GridGeometry = GG;
// BoundaryTypes is whatever the problem returns from boundaryTypes(element, scv)
using BoundaryTypes = std::decay_t<decltype(std::declval<Problem>().boundaryTypes(std::declval<Element>(), std::declval<SubControlVolume>()))>;
};
} // end namespace Impl
} // namespace Dumux
#endif
......@@ -29,6 +29,7 @@
#include <dumux/common/properties.hh>
#include <dumux/common/defaultmappertraits.hh>
#include <dumux/common/typetraits/problem.hh>
#include <dumux/assembly/cclocalresidual.hh>
......@@ -158,6 +159,24 @@ struct ElementBoundaryTypes<TypeTag, TTag::CCMpfaModel> { using type = CCElement
template<class TypeTag>
struct BaseLocalResidual<TypeTag, TTag::CCMpfaModel> { using type = CCLocalResidual<TypeTag>; };
} // namespace Properties
namespace Impl {
template<class Problem>
struct ProblemTraits<Problem, DiscretizationMethod::ccmpfa>
{
private:
using GG = std::decay_t<decltype(std::declval<Problem>().gridGeometry())>;
using Element = typename GG::GridView::template Codim<0>::Entity;
using SubControlVolumeFace = typename GG::SubControlVolumeFace;
public:
using GridGeometry = GG;
// BoundaryTypes is whatever the problem returns from boundaryTypes(element, scvf)
using BoundaryTypes = std::decay_t<decltype(std::declval<Problem>().boundaryTypes(std::declval<Element>(), std::declval<SubControlVolumeFace>()))>;
};
} // end namespace Impl
} // namespace Dumux
#endif
......@@ -28,6 +28,7 @@
#include <dumux/common/properties.hh>
#include <dumux/common/boundaryflag.hh>
#include <dumux/common/typetraits/problem.hh>
#include <dumux/assembly/cclocalresidual.hh>
......@@ -94,6 +95,24 @@ struct ElementBoundaryTypes<TypeTag, TTag::CCTpfaModel> { using type = CCElement
template<class TypeTag>
struct BaseLocalResidual<TypeTag, TTag::CCTpfaModel> { using type = CCLocalResidual<TypeTag>; };
} // namespace Properties
namespace Impl {
template<class Problem>
struct ProblemTraits<Problem, DiscretizationMethod::cctpfa>
{
private:
using GG = std::decay_t<decltype(std::declval<Problem>().gridGeometry())>;
using Element = typename GG::GridView::template Codim<0>::Entity;
using SubControlVolumeFace = typename GG::SubControlVolumeFace;
public:
using GridGeometry = GG;
// BoundaryTypes is whatever the problem returns from boundaryTypes(element, scvf)
using BoundaryTypes = std::decay_t<decltype(std::declval<Problem>().boundaryTypes(std::declval<Element>(), std::declval<SubControlVolumeFace>()))>;
};
} // end namespace Impl
} // namespace Dumux
#endif
......@@ -28,6 +28,7 @@
#include <dune/istl/bvector.hh>
#include <dune/istl/bcrsmatrix.hh>
#include <dumux/common/deprecated.hh>
#include <dumux/common/properties.hh>
#include <dumux/common/properties/grid.hh>
#include <dumux/common/boundarytypes.hh>
......@@ -67,10 +68,12 @@ struct EnableGridVolumeVariablesCache<TypeTag, TTag::FiniteVolumeModel> { static
template<class TypeTag>
struct EnableGridFluxVariablesCache<TypeTag, TTag::FiniteVolumeModel> { static constexpr bool value = false; };
DUNE_NO_DEPRECATED_BEGIN
//! Boundary types at a single degree of freedom
template<class TypeTag>
struct BoundaryTypes<TypeTag, TTag::FiniteVolumeModel> { using type = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>; };
struct BoundaryTypes<TypeTag, TTag::FiniteVolumeModel>
{ using type = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>; };
DUNE_NO_DEPRECATED_END
// TODO: bundle SolutionVector, JacobianMatrix
// in LinearAlgebra traits
......
......@@ -28,6 +28,7 @@
#define DUMUX_DISCRETIZATION_STAGGERD_HH
#include <dumux/common/properties.hh>
#include <dumux/common/typetraits/problem.hh>
#include <dumux/discretization/method.hh>
#include <dumux/discretization/fvproperties.hh>
......@@ -46,6 +47,7 @@
#include <dune/istl/multitypeblockvector.hh>
#include <dune/istl/multitypeblockmatrix.hh>
#include <dumux/common/deprecated.hh>
namespace Dumux {
......@@ -137,10 +139,11 @@ struct FacePrimaryVariables<TypeTag, TTag::StaggeredModel>
getPropValue<TypeTag, Properties::NumEqFace>()>;
};
DUNE_NO_DEPRECATED_BEGIN
//! Boundary types at a single degree of freedom
template<class TypeTag>
struct BoundaryTypes<TypeTag, TTag::StaggeredModel> { using type = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>; };
DUNE_NO_DEPRECATED_END
// TODO: bundle SolutionVector, JacobianMatrix
// in LinearAlgebra traits
......@@ -199,6 +202,24 @@ public:
};
} // namespace Properties
namespace Impl {
template<class Problem>
struct ProblemTraits<Problem, DiscretizationMethod::staggered>
{
private:
using GG = std::decay_t<decltype(std::declval<Problem>().gridGeometry())>;
using Element = typename GG::GridView::template Codim<0>::Entity;
using SubControlVolumeFace = typename GG::SubControlVolumeFace;
public:
using GridGeometry = GG;
// BoundaryTypes is whatever the problem returns from boundaryTypes(element, scvf)
using BoundaryTypes = std::decay_t<decltype(std::declval<Problem>().boundaryTypes(std::declval<Element>(), std::declval<SubControlVolumeFace>()))>;
};
} // end namespace Impl
} // namespace Dumux
#endif
......@@ -24,118 +24,14 @@
#ifndef STAGGERED_FREEFLOW_BOUNDARY_TYPES_HH
#define STAGGERED_FREEFLOW_BOUNDARY_TYPES_HH
#include <dumux/common/boundarytypes.hh>
#include <dumux/common/typetraits/typetraits.hh>
#warning "This header is deprecated. Use dumux/freeflow/navierstokes/boundarytypes.hh"
#include <dumux/freeflow/navierstokes/boundarytypes.hh>
namespace Dumux {
/*!
* \ingroup StaggeredDiscretization
* \brief Class to specify the type of a boundary condition for the staggered Navier-Stokes model.
*/
template <int numEq>
class StaggeredFreeFlowBoundaryTypes : public Dumux::BoundaryTypes<numEq>
{
using ParentType = Dumux::BoundaryTypes<numEq>;
public:
StaggeredFreeFlowBoundaryTypes()
{
for (int eqIdx=0; eqIdx < numEq; ++eqIdx)
resetEq(eqIdx);
}
/*!
* \brief Reset the boundary types for one equation.
*/
void resetEq(int eqIdx)
{
ParentType::resetEq(eqIdx);
boundaryInfo_[eqIdx].visited = false;
boundaryInfo_[eqIdx].isSymmetry = false;
boundaryInfo_[eqIdx].isBeaversJoseph = false;
}
/*!
* \brief Sets a symmetry boundary condition for all equations
*/
void setAllSymmetry()
{
for (int eqIdx=0; eqIdx < numEq; ++eqIdx)
{
resetEq(eqIdx);
boundaryInfo_[eqIdx].visited = true;
boundaryInfo_[eqIdx].isSymmetry = true;
}
}
/*!
* \brief Returns true if the there is a symmetry boundary condition
*/
bool isSymmetry() const
{ return boundaryInfo_[0].isSymmetry; }
/*!
* \brief Prevent setting all boundary conditions to Dirichlet.
*/
template<class T = void>
void setAllDirichlet()
{
static_assert(AlwaysFalse<T>::value, "Setting all boundary types to Dirichlet not permitted!");
}
/*!
* \brief Prevent setting all boundary conditions to Neumann.
*/
template<class T = void>
void setAllNeumann()
{
static_assert(AlwaysFalse<T>::value, "Setting all boundary types to Neumann not permitted!");
}
/*!
* \brief Set a boundary condition for a single equation to
* Beavers-Joseph(-Saffmann) (special case of Dirichlet b.c.).
*/
void setBeaversJoseph(unsigned eqIdx)
{
resetEq(eqIdx);
boundaryInfo_[eqIdx].visited = true;
boundaryInfo_[eqIdx].isBeaversJoseph = true;
}
/*!
* \brief Returns true if an equation is used to specify a
* Beavers-Joseph(-Saffman) boundary condition.
*
* \param eqIdx The index of the equation
*/
bool isBeaversJoseph(unsigned eqIdx) const
{ return boundaryInfo_[eqIdx].isBeaversJoseph; }
/*!
* \brief Returns true if some equation is used to specify a
* Beavers-Joseph(-Saffman) boundary condition.
*/
bool hasBeaversJoseph() const
{
for (int i = 0; i < numEq; ++i)
if (boundaryInfo_[i].isBeaversJoseph)
return true;
return false;
}
protected:
struct StaggeredFreeFlowBoundaryInfo
{
bool visited;
bool isSymmetry;
bool isBeaversJoseph;
};
std::array<StaggeredFreeFlowBoundaryInfo, numEq> boundaryInfo_;
};
using StaggeredFreeFlowBoundaryTypes [[deprecated("Use NavierStokesBoundaryTypes instead. Will be removed after 3.3")]] = NavierStokesBoundaryTypes<numEq>;
} // end namespace Dumux
......
......@@ -35,13 +35,15 @@
#include <dumux/discretization/staggered.hh>
#include <dumux/discretization/staggered/fvgridgeometry.hh>
#include <dumux/freeflow/properties.hh>
#include <dumux/freeflow/navierstokes/boundarytypes.hh>
#include "facevariables.hh"
#include "boundarytypes.hh"
#include "velocityoutput.hh"
#include "fvgridgeometrytraits.hh"
#include "gridvolumevariables.hh"
#include <dumux/common/deprecated.hh>
namespace Dumux {
namespace Properties {
......@@ -114,13 +116,14 @@ public:
using type = StaggeredGridVolumeVariables<Traits, enableCache>;
};
DUNE_NO_DEPRECATED_BEGIN
//! Boundary types at a single degree of freedom
template<class TypeTag>
struct BoundaryTypes<TypeTag, TTag::StaggeredFreeFlowModel>
{
using type = StaggeredFreeFlowBoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
using type = NavierStokesBoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
};
DUNE_NO_DEPRECATED_END
//! The velocity output
template<class TypeTag>
......
add_subdirectory(staggered)
install(FILES
boundarytypes.hh
fluxvariables.hh
indices.hh
iofields.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 3 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
* \ingroup NavierStokesModel
* \copydoc Dumux::NavierStokesBoundaryTypes
*/
#ifndef FREEFLOW_NAVIERSTOKES_BOUNDARY_TYPES_HH
#define FREEFLOW_NAVIERSTOKES_BOUNDARY_TYPES_HH
#include <dumux/common/boundarytypes.hh>
#include <dumux/common/typetraits/typetraits.hh>
namespace Dumux {
/*!
* \ingroup NavierStokesModel
* \brief Class to specify the type of a boundary condition for the Navier-Stokes model.
*/
template <int numEq>
class NavierStokesBoundaryTypes : public BoundaryTypes<numEq>
{
using ParentType = BoundaryTypes<numEq>;
public:
NavierStokesBoundaryTypes()
{
for (int eqIdx=0; eqIdx < numEq; ++eqIdx)
resetEq(eqIdx);
}
/*!
* \brief Reset the boundary types for one equation.
*/
void resetEq(const int eqIdx)
{
ParentType::resetEq(eqIdx);
boundaryInfo_[eqIdx].isSymmetry = false;
boundaryInfo_[eqIdx].isBeaversJoseph = false;
}
/*!
* \brief Sets a symmetry boundary condition for all equations
*/
void setAllSymmetry()
{
for (int eqIdx=0; eqIdx < numEq; ++eqIdx)
{
resetEq(eqIdx);
boundaryInfo_[eqIdx].isSymmetry = true;
}
}
/*!
* \brief Returns true if the there is a symmetry boundary condition
*/
bool isSymmetry() const
{ return boundaryInfo_[0].isSymmetry; }
/*!
* \brief Prevent setting all boundary conditions to Dirichlet.
*/
template<class T = void>
void setAllDirichlet()
{
static_assert(AlwaysFalse<T>::value, "Setting all boundary types to Dirichlet not permitted!");
}
/*!
* \brief Prevent setting all boundary conditions to Neumann.
*/
template<class T = void>
void setAllNeumann()
{
static_assert(AlwaysFalse<T>::value, "Setting all boundary types to Neumann not permitted!");
}
/*!
* \brief Set a boundary condition for a single equation to
* Beavers-Joseph(-Saffmann) (special case of Dirichlet b.c.).
*/
void setBeaversJoseph(const int eqIdx)
{
resetEq(eqIdx);
boundaryInfo_[eqIdx].isBeaversJoseph = true;
}
/*!
* \brief Returns true if an equation is used to specify a
* Beavers-Joseph(-Saffman) boundary condition.
*
* \param eqIdx The index of the equation
*/