Commit b8e5ebbe authored by Timo Koch's avatar Timo Koch

Merge branch 'feature/multidomain-on-3.0' into 'master'

Feature/multidomain on 3.0

Closes #447

See merge request !980
parents 3a648102 d9d14beb
......@@ -8,6 +8,7 @@ find_package(GLPK)
find_package(Gnuplot)
set(HAVE_GNUPLOT ${GNUPLOT_FOUND})
find_package(Gstat)
find_package(Gmsh)
find_package(NLOPT)
find_package(PTScotch)
find_package(PVPython)
......
# .. cmake_module::
#
# Find the Gmsh meshing tool
#
# You may set the following variables to modify the
# behaviour of this module:
#
# :ref:`GMSH_ROOT`
# Path list to search for gmsh.
#
# Sets the following variables:
#
# :code:`gmsh_FOUND`
# True if the gmsh library was found.
#
# :code:`GMSH_EXECUTABLE`
# Path to gmsh executable
#
# .. cmake_variable:: GMSH_ROOT
#
# You may set this variable to have :ref:`FindGmsh` look
# for the gmsh library in the given path before inspecting
# system paths.
#
# look for header files, only at positions given by the user
find_program(GMSH_EXECUTABLE
NAMES gmsh
PATHS "${GMSH_ROOT}"
"${CMAKE_SOURCE_DIR}/../"
"/usr/bin/"
PATH_SUFFIXES "src" "external/gmsh/src" "gmsh/src" "gmsh"
NO_DEFAULT_PATH
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
"gmsh"
DEFAULT_MSG
GMSH_EXECUTABLE
)
# set macros for config.h
set(HAVE_GMSH ${gmsh_FOUND})
set(GMSH_EXECUTABLE ${GMSH_EXECUTABLE})
# text for feature summary
set_package_properties("Gmsh" PROPERTIES
DESCRIPTION "Meshing tool"
PURPOSE "Generate structured and unstructured grids")
......@@ -28,7 +28,7 @@ find_program(GSTAT_EXECUTABLE
NAMES gstat
PATHS "${GSTAT_ROOT}"
"${CMAKE_SOURCE_DIR}/../"
"usr/bin/"
"/usr/bin/"
PATH_SUFFIXES "src" "external/gstat/src" "gstat/src" "gstat"
NO_DEFAULT_PATH
)
......
......@@ -58,6 +58,12 @@
/* Define path to gstat executable */
#cmakedefine GSTAT_EXECUTABLE "@GSTAT_EXECUTABLE@"
/* Define to 1 if gmsh was found */
#cmakedefine HAVE_GMSH 1
/* Define path to gmsh executable */
#cmakedefine GMSH_EXECUTABLE "@GMSH_EXECUTABLE@"
/* Defines whether pvpython has been found */
#cmakedefine HAVE_PVPYTHON 1
......
This diff is collapsed.
......@@ -7,6 +7,7 @@ add_subdirectory(geomechanics)
add_subdirectory(io)
add_subdirectory(linear)
add_subdirectory(material)
add_subdirectory(multidomain)
add_subdirectory(nonlinear)
add_subdirectory(parallel)
add_subdirectory(porousmediumflow)
......@@ -12,6 +12,5 @@ jacobianpattern.hh
numericepsilon.hh
partialreassembler.hh
staggeredfvassembler.hh
staggeredlocalassembler.hh
staggeredlocalresidual.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/assembly)
......@@ -105,6 +105,52 @@ Dune::MatrixIndexSet getJacobianPattern(const GridGeometry& gridGeometry)
return pattern;
}
/*!
* \ingroup Assembly
* \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>
auto getJacobianPattern(const GridGeometry& gridGeometry)
{
// resize the jacobian and the residual
const auto numDofs = gridGeometry.numDofs();
Dune::MatrixIndexSet pattern(numDofs, numDofs);
const auto& connectivityMap = gridGeometry.connectivityMap();
// evaluate the acutal pattern
for (const auto& element : elements(gridGeometry.gridView()))
{
if(gridGeometry.isCellCenter())
{
// the global index of the element at hand
static constexpr auto cellCenterIdx = GridGeometry::cellCenterIdx();
const auto ccGlobalI = gridGeometry.elementMapper().index(element);
for (auto&& ccGlobalJ : connectivityMap(cellCenterIdx, cellCenterIdx, ccGlobalI))
pattern.add(ccGlobalI, ccGlobalJ);
}
else
{
static constexpr auto faceIdx = GridGeometry::faceIdx();
auto fvGeometry = localView(gridGeometry);
fvGeometry.bindElement(element);
// loop over sub control faces
for (auto&& scvf : scvfs(fvGeometry))
{
const auto faceGlobalI = scvf.dofIndex();
for (auto&& faceGlobalJ : connectivityMap(faceIdx, faceIdx, scvf.index()))
pattern.add(faceGlobalI, faceGlobalJ);
}
}
}
return pattern;
}
} // namespace Dumux
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -192,6 +192,11 @@ NEW_PROP_TAG(SherwoodFormulation);
NEW_PROP_TAG(EnableInertiaTerms); //!< Returns whether to include inertia terms in the momentum balance eq or not (Stokes / Navier-Stokes)
NEW_PROP_TAG(NormalizePressure); //!< Returns whether to normalize the pressure term in the momentum balance or not
/////////////////////////////////////////////////////////////
// Properties used by multidomain simulations
/////////////////////////////////////////////////////////////
NEW_PROP_TAG(CouplingManager);
} // end namespace Properties
} // end namespace Dumux
......
......@@ -2,5 +2,6 @@ install(FILES
isvalid.hh
matrix.hh
typetraits.hh
utility.hh
vector.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/common/typetraits)
// -*- 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
* \ingroup Common
* \ingroup TypeTraits
* \brief Utilities for template meta programming
*/
#ifndef DUMUX_COMMON_TYPETRAITS_UTILITY_HH
#define DUMUX_COMMON_TYPETRAITS_UTILITY_HH
namespace Dumux {
/*
* \ingroup TypeTraits
* \brief create a variadic template from indexed types
* \tparam V a variadic template that we want to create
* \tparam T an indexed type (type that gets an index as template parameter)
* \tparam U the list of indices
*/
template <template<typename... Args> class Variadic, template<std::size_t> class Indexed, class U>
struct makeFromIndexedType;
template <template<typename... Args> class Variadic, template<std::size_t> class Indexed, std::size_t... IndexSeq>
struct makeFromIndexedType<Variadic, Indexed, std::index_sequence<IndexSeq...>>
{
using type = Variadic<Indexed<IndexSeq>...>;
};
namespace Detail {
template <class Seq1, std::size_t offset, class Seq2> struct ConcatSeq;
template <std::size_t ... Is1, std::size_t offset, std::size_t ... Is2>
struct ConcatSeq<std::index_sequence<Is1...>, offset, std::index_sequence<Is2...>>
{
using type = std::index_sequence<Is1..., (offset + Is2)...>;
};
}
/*
* \ingroup TypeTraits
* \brief create an integer sequence from 0 to n-1, omitting one specific number e
* \tparam n number of integers in complete sequence before omitting
* \tparam e value of integer to be omitted
*
* example: makeIncompleteIntegerSequence<3, 1> = [0, 2]
* example: makeIncompleteIntegerSequence<4, 4> = [0, 1, 2, 3]
*
* see https://stackoverflow.com/questions/27124920/compile-time-generate-integer-sequence-with-one-left-out for details
*/
template <std::size_t n, std::size_t e>
using makeIncompleteIntegerSequence =
typename Detail::ConcatSeq<decltype(std::make_index_sequence<e>{}), e + 1, decltype(std::make_index_sequence<(n > e) ? (n - e - 1) : 0>{})>::type;
} // end namespace Dumux
#endif
......@@ -41,7 +41,7 @@ class StaggeredFreeFlowConnectivityMap
using SubControlVolumeFace = typename FVGridGeometry::SubControlVolumeFace;
using Element = typename GridView::template Codim<0>::Entity;
using IndexType = typename GridView::IndexSet::IndexType;
using IndexType = std::size_t;
using CellCenterIdxType = typename FVGridGeometry::DofTypeIndices::CellCenterIdx;
using FaceIdxType = typename FVGridGeometry::DofTypeIndices::FaceIdx;
......
......@@ -70,6 +70,12 @@ public:
StaggeredFVElementGeometry(const FVGridGeometry& fvGridGeometry)
: fvGridGeometryPtr_(&fvGridGeometry) {}
//! Constructor getting a auxiliary cell center of face specific FvGridGeometry type.
//! Needed for the multi-domain framework.
template<class CellCenterOrFaceFVGridGeometry>
StaggeredFVElementGeometry(const CellCenterOrFaceFVGridGeometry& fvGridGeometry)
: fvGridGeometryPtr_(&fvGridGeometry.actualfvGridGeometry()) {}
//! Get an elment sub control volume with a global scv index
//! We separate element and neighbor scvs to speed up mapping
const SubControlVolume& scv(IndexType scvIdx) const
......
......@@ -30,6 +30,134 @@
namespace Dumux {
/*!
* \ingroup StaggeredDiscretization
* \brief Base class for cell center of face specific auxiliary FvGridGeometry classes.
* Provides a common interface and a pointer to the actual fvGridGeometry.
*/
template<class ActualFVGridGeometry>
class GridGeometryView
{
public:
explicit GridGeometryView(const ActualFVGridGeometry* actualFVGridGeometry)
: fvGridGeometry_(actualFVGridGeometry) {}
//! export the GridView type and the discretization method
using GridView = typename ActualFVGridGeometry::GridView;
static constexpr DiscretizationMethod discMethod = DiscretizationMethod::staggered;
using LocalView = typename ActualFVGridGeometry::LocalView;
/*!
* \brief Returns true if this view if related to cell centered dofs
*/
static constexpr bool isCellCenter() { return false; }
/*!
* \brief Returns true if this view if related to face dofs
*/
static constexpr bool isFace() {return false; }
/*!
* \brief Return an integral constant index for cell centered dofs
*/
static constexpr auto cellCenterIdx()
{ return typename ActualFVGridGeometry::DofTypeIndices::CellCenterIdx{}; }
/*!
* \brief Return an integral constant index for face dofs
*/
static constexpr auto faceIdx()
{ return typename ActualFVGridGeometry::DofTypeIndices::FaceIdx{}; }
/*!
* \brief Return the gridView this grid geometry object lives on
*/
const auto& gridView() const
{ return fvGridGeometry_->gridView(); }
/*!
* \brief Returns the connectivity map of which dofs have derivatives with respect
* to a given dof.
*/
const auto& connectivityMap() const // TODO return correct map
{ return fvGridGeometry_->connectivityMap(); }
/*!
* \brief Returns the mapper for vertices to indices for possibly adaptive grids.
*/
const auto& vertexMapper() const
{ return fvGridGeometry_->vertexMapper(); }
/*!
* \brief Returns the mapper for elements to indices for constant grids.
*/
const auto& elementMapper() const
{ return fvGridGeometry_->elementMapper(); }
/*!
* \brief Returns the actual fvGridGeometry we are a restriction of
*/
const ActualFVGridGeometry& actualfvGridGeometry() const
{ return *fvGridGeometry_; }
protected:
const ActualFVGridGeometry* fvGridGeometry_;
};
/*!
* \ingroup StaggeredDiscretization
* \brief Cell center specific auxiliary FvGridGeometry classes.
* Required for the Dumux multi-domain framework.
*/
template <class ActualFVGridGeometry>
class CellCenterFVGridGeometry : public GridGeometryView<ActualFVGridGeometry>
{
using ParentType = GridGeometryView<ActualFVGridGeometry>;
public:
using ParentType::ParentType;
/*!
* \brief Returns true because this view is related to cell centered dofs
*/
static constexpr bool isCellCenter() { return true; }
/*!
* \brief The total number of cell centered dofs
*/
std::size_t numDofs() const
{ return this->fvGridGeometry_->numCellCenterDofs(); }
};
/*!
* \ingroup StaggeredDiscretization
* \brief Face specific auxiliary FvGridGeometry classes.
* Required for the Dumux multi-domain framework.
*/
template <class ActualFVGridGeometry>
class FaceFVGridGeometry : public GridGeometryView<ActualFVGridGeometry>
{
using ParentType = GridGeometryView<ActualFVGridGeometry>;
public:
using ParentType::ParentType;
/*!
* \brief Returns true because this view is related to face dofs
*/
static constexpr bool isFace() {return true; }
/*!
* \brief The total number of cell centered dofs
*/
std::size_t numDofs() const
{ return this->fvGridGeometry_->numFaceDofs(); }
};
/*!
* \ingroup StaggeredDiscretization
* \brief Base class for the finite volume geometry vector for staggered models
......@@ -83,6 +211,11 @@ public:
static constexpr auto faceIdx()
{ return typename DofTypeIndices::FaceIdx{}; }
using CellCenterFVGridGeometryType = CellCenterFVGridGeometry<ThisType>;
using FaceFVGridGeometryType = FaceFVGridGeometry<ThisType>;
using FVGridGeometryTuple = std::tuple< CellCenterFVGridGeometry<ThisType>, FaceFVGridGeometry<ThisType> >;
//! Constructor
StaggeredFVGridGeometry(const GridView& gridView)
: ParentType(gridView)
......@@ -243,6 +376,29 @@ public:
const ConnectivityMap &connectivityMap() const
{ return connectivityMap_; }
//! Returns a pointer the cell center specific auxiliary class. Required for the multi-domain FVAssembler's ctor.
std::unique_ptr<CellCenterFVGridGeometry<ThisType>> cellCenterFVGridGeometryPtr() const
{
return std::make_unique<CellCenterFVGridGeometry<ThisType>>(this);
}
//! Returns a pointer the face specific auxiliary class. Required for the multi-domain FVAssembler's ctor.
std::unique_ptr<FaceFVGridGeometry<ThisType>> faceFVGridGeometryPtr() const
{
return std::make_unique<FaceFVGridGeometry<ThisType>>(this);
}
//! Return a copy of the cell center specific auxiliary class.
CellCenterFVGridGeometry<ThisType> cellCenterFVGridGeometry() const
{
return CellCenterFVGridGeometry<ThisType>(this);
}
//! Return a copy of the face specific auxiliary class.
FaceFVGridGeometry<ThisType> faceFVGridGeometry() const
{
return FaceFVGridGeometry<ThisType>(this);
}
private:
......
......@@ -28,6 +28,175 @@
namespace Dumux {
/*!
* \ingroup StaggeredDiscretization
* \brief Base class for cell center of face specific auxiliary GridVariables classes.
* Provides a common interface and a pointer to the actual grid variables.
*/
template<class ActualGridVariables>
class StaggeredGridVariablesView
{
public:
using GridVolumeVariables = typename ActualGridVariables::GridVolumeVariables;
using GridFaceVariables = typename ActualGridVariables::GridFaceVariables;
using GridFluxVariablesCache = typename ActualGridVariables::GridFluxVariablesCache;
//! export type of the volume variables
using VolumeVariables = typename GridVolumeVariables::VolumeVariables;
//! export primary variable type
using PrimaryVariables = typename VolumeVariables::PrimaryVariables;
using FVGridGeometry = typename ActualGridVariables::FVGridGeometry;
explicit StaggeredGridVariablesView(ActualGridVariables* gridVariables)
: gridVariables_(gridVariables) {}
//! return the flux variables cache
const GridFluxVariablesCache& gridFluxVarsCache() const
{ return gridVariables_->gridFluxVarsCache(); }
//! return the flux variables cache
GridFluxVariablesCache& gridFluxVarsCache()
{ return gridVariables_->gridFluxVarsCache(); }
//! return the current volume variables
const GridVolumeVariables& curGridVolVars() const
{ return gridVariables_->curGridVolVars(); }
//! return the current volume variables
GridVolumeVariables& curGridVolVars()
{ return gridVariables_->curGridVolVars(); }
//! return the volume variables of the previous time step (for instationary problems)
const GridVolumeVariables& prevGridVolVars() const
{ return gridVariables_->prevGridVolVars(); }
//! return the volume variables of the previous time step (for instationary problems)
GridVolumeVariables& prevGridVolVars()
{ return gridVariables_->prevGridVolVars(); }
//! return the current face variables
const GridFaceVariables& curGridFaceVars() const
{ return gridVariables_->curGridFaceVars(); }
//! return the previous face variables
const GridFaceVariables& prevGridFaceVars() const
{ return gridVariables_->prevGridFaceVars(); }
//! return the current face variables
GridFaceVariables& curGridFaceVars()
{ return gridVariables_->curGridFaceVars(); }
//! return the previous face variables
GridFaceVariables& prevGridFaceVars()
{ return gridVariables_->prevGridFaceVars(); }
//! return the fv grid geometry
const FVGridGeometry& fvGridGeometry() const
{ return (*gridVariables_->fvGridGeometry_); }
// return the actual grid variables
const ActualGridVariables& gridVariables() const
{ return *gridVariables_; }
// return the actual grid variables
ActualGridVariables& gridVariables()
{ return *gridVariables_; }
protected:
ActualGridVariables* gridVariables_;
};
/*!
* \ingroup StaggeredDiscretization
* \brief Cell center specific auxiliary GridVariables classes.
* Required for the Dumux multi-domain framework.
*/
template<class ActualGridVariables>
class CellCenterGridVariablesView : public StaggeredGridVariablesView<ActualGridVariables>
{
using ParentType = StaggeredGridVariablesView<ActualGridVariables>;
public:
using ParentType::ParentType;
//! initialize all variables (stationary case)
template<class SolVector>
void init(const SolVector& curSol)
{
this->curGridVolVars().update(this->fvGridGeometry(), curSol);
this->gridFluxVarsCache().update(this->fvGridGeometry(), this->curGridVolVars(), curSol, true);
}
//! initialize all variables (instationary case)
template<class SolVector>
void init(const SolVector& curSol, const SolVector& initSol)
{
this->curGridVolVars().update(this->fvGridGeometry(), curSol);
this->gridFluxVarsCache().update(this->fvGridGeometry(), this->curGridVolVars(), curSol, true);
this->prevGridVolVars().update(this->fvGridGeometry(), initSol);
}
//! update the volume variables and the flux variables cache
template<class SolVector>
void update(const SolVector& curSol)
{
this->curGridVolVars().update(this->fvGridGeometry(), curSol);
this->gridFluxVarsCache().update(this->fvGridGeometry(), this->curGridVolVars(), curSol);
}
//! resets state to the one before time integration
template<class SolVector>
void resetTimeStep(const SolVector& sol)
{
this->curGridVolVars() = this->prevGridVolVars();
this->gridFluxVarsCache().update(this->fvGridGeometry(), this->curGridVolVars(), sol);
}
};
/*!
* \ingroup StaggeredDiscretization
* \brief Face specific auxiliary GridVariables classes.
* Required for the Dumux multi-domain framework.
*/
template<class ActualGridVariables>
class FaceGridVariablesView : public StaggeredGridVariablesView<ActualGridVariables>
{
using ParentType = StaggeredGridVariablesView<ActualGridVariables>;
public:
using ParentType::ParentType;
//! initialize all variables (stationary case)
template<class SolVector>
void init(const SolVector& curSol)
{
this->curGridFaceVars().update(this->fvGridGeometry(), curSol);
}