Loading...
Searching...
No Matches
ecfvdiscretization.hh
Go to the documentation of this file.
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
This file is part of the Open Porous Media project (OPM).
OPM 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.
OPM 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 OPM. If not, see <http://www.gnu.org/licenses/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
#ifndef EWOMS_ECFV_DISCRETIZATION_HH
#define EWOMS_ECFV_DISCRETIZATION_HH
#include <opm/material/densead/Math.hpp>
#include <opm/models/discretization/common/fvbasediscretization.hh>
#include <opm/models/discretization/ecfv/ecfvbaseoutputmodule.hh>
#include <opm/models/discretization/ecfv/ecfvgridcommhandlefactory.hh>
#include <opm/models/discretization/ecfv/ecfvproperties.hh>
#include <opm/models/discretization/ecfv/ecfvstencil.hh>
#include <opm/simulators/linalg/elementborderlistfromgrid.hh>
#if HAVE_DUNE_FEM
#include <opm/models/discretization/common/fvbasediscretizationfemadapt.hh>
#include <dune/fem/space/common/functionspace.hh>
#include <dune/fem/space/finitevolume.hh>
#endif
#include <cstddef>
#include <string>
namespace Opm {
template <class TypeTag>
class EcfvDiscretization;
}
namespace Opm::Properties {
template<class TypeTag>
struct Stencil<TypeTag, TTag::EcfvDiscretization>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using GridView = GetPropType<TypeTag, Properties::GridView>;
public:
using type = EcfvStencil<Scalar, GridView>;
};
template<class TypeTag>
struct DofMapper<TypeTag, TTag::EcfvDiscretization>
{ using type = GetPropType<TypeTag, Properties::ElementMapper>; };
template<class TypeTag>
struct Discretization<TypeTag, TTag::EcfvDiscretization>
{ using type = EcfvDiscretization<TypeTag>; };
template<class TypeTag>
struct DiscBaseOutputModule<TypeTag, TTag::EcfvDiscretization>
{ using type = EcfvBaseOutputModule<TypeTag>; };
template<class TypeTag>
struct GridCommHandleFactory<TypeTag, TTag::EcfvDiscretization>
{ using type = EcfvGridCommHandleFactory<TypeTag>; };
#if HAVE_DUNE_FEM
template<class TypeTag>
struct DiscreteFunctionSpace<TypeTag, TTag::EcfvDiscretization>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar> ;
using GridPart = GetPropType<TypeTag, Properties::GridPart>;
enum { numEq = getPropValue<TypeTag, Properties::NumEq>() };
using FunctionSpace = Dune::Fem::FunctionSpace<typename GridPart::GridType::ctype,
Scalar,
GridPart::GridType::dimensionworld,
numEq>;
public:
using type = Dune::Fem::FiniteVolumeSpace< FunctionSpace, GridPart, 0 >;
};
#else
template <class TypeTag>
struct DummySpaceEcfv
{
using DiscreteFunctionSpace = GetPropType<TypeTag, Properties::DiscreteFunctionSpace>;
explicit DummySpaceEcfv(const DiscreteFunctionSpace&) {}
explicit DummySpaceEcfv(const int&) {}
};
template <class TypeTag>
struct DiscreteFunctionSpace<TypeTag, TTag::EcfvDiscretization>
{ using type = DummySpaceEcfv<TypeTag>; };
#endif
template<class TypeTag>
struct BorderListCreator<TypeTag, TTag::EcfvDiscretization>
{
private:
using ElementMapper = GetPropType<TypeTag, Properties::ElementMapper>;
using GridView = GetPropType<TypeTag, Properties::GridView>;
public:
using type = Linear::ElementBorderListFromGrid<GridView, ElementMapper>;
};
template<class TypeTag>
struct LinearizeNonLocalElements<TypeTag, TTag::EcfvDiscretization>
{ static constexpr bool value = true; };
template<class TypeTag>
struct UseLinearizationLock<TypeTag, TTag::EcfvDiscretization>
{ static constexpr bool value = false; };
} // namespace Opm::Properties
namespace Opm {
template<class TypeTag>
class EcfvDiscretization : public GetPropType<TypeTag, Properties::BaseDiscretizationType>
{
using ParentType = GetPropType<TypeTag, Properties::BaseDiscretizationType>;
using Implementation = GetPropType<TypeTag, Properties::Model>;
using DofMapper = GetPropType<TypeTag, Properties::DofMapper>;
using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>;
using GridView = GetPropType<TypeTag, Properties::GridView>;
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
public:
explicit EcfvDiscretization(Simulator& simulator)
: ParentType(simulator)
{}
static std::string discretizationName()
{ return "ecfv"; }
std::size_t numGridDof() const
{ return static_cast<std::size_t>(this->gridView_.size(/*codim=*/0)); }
const DofMapper& dofMapper() const
{ return this->elementMapper(); }
void syncOverlap()
{
// syncronize the solution on the ghost and overlap elements
using GhostSyncHandle = GridCommHandleGhostSync<PrimaryVariables,
SolutionVector,
DofMapper,
/*commCodim=*/0>;
auto ghostSync = GhostSyncHandle(this->solution(/*timeIdx=*/0),
asImp_().dofMapper());
this->gridView().communicate(ghostSync,
Dune::InteriorBorder_All_Interface,
Dune::ForwardCommunication);
}
template <class Restarter>
void serialize(Restarter& res)
{ res.template serializeEntities</*codim=*/0>(asImp_(), this->gridView_); }
template <class Restarter>
void deserialize(Restarter& res)
{
res.template deserializeEntities</*codim=*/0>(asImp_(), this->gridView_);
this->solution(/*timeIdx=*/1) = this->solution(/*timeIdx=*/0);
}
private:
Implementation& asImp_()
{ return *static_cast<Implementation*>(this); }
const Implementation& asImp_() const
{ return *static_cast<const Implementation*>(this); }
};
} // namespace Opm
#endif
Opm::EcfvBaseOutputModule
Implements the discretization specific parts of writing files.
Definition ecfvbaseoutputmodule.hh:41
Opm::EcfvDiscretization
The base class for the element-centered finite-volume discretization scheme.
Definition ecfvdiscretization.hh:160
Opm::EcfvDiscretization::discretizationName
static std::string discretizationName()
Returns a string of discretization's human-readable name.
Definition ecfvdiscretization.hh:177
Opm::EcfvDiscretization::serialize
void serialize(Restarter &res)
Serializes the current state of the model.
Definition ecfvdiscretization.hh:225
Opm::EcfvDiscretization::deserialize
void deserialize(Restarter &res)
Deserializes the state of the model.
Definition ecfvdiscretization.hh:236
Opm::EcfvDiscretization::numGridDof
std::size_t numGridDof() const
Returns the number of global degrees of freedom (DOFs) due to the grid.
Definition ecfvdiscretization.hh:183
Opm::EcfvDiscretization::dofMapper
const DofMapper & dofMapper() const
Mapper to convert the Dune entities of the discretization's degrees of freedoms are to indices.
Definition ecfvdiscretization.hh:190
Opm::EcfvDiscretization::syncOverlap
void syncOverlap()
Syncronize the values of the primary variables on the degrees of freedom that overlap with the neighb...
Definition ecfvdiscretization.hh:202
Opm::EcfvGridCommHandleFactory
A class which provides types for DUNE grid handles for communication.
Definition ecfvgridcommhandlefactory.hh:48
Opm::EcfvStencil
Represents the stencil (finite volume geometry) of a single element in the ECFV discretization.
Definition ecfvstencil.hh:69
Opm::GridCommHandleGhostSync
Data handle for parallel communication which can be used to set the values values of ghost and overla...
Definition gridcommhandles.hh:109
Opm::Linear::ElementBorderListFromGrid
Uses communication on the grid to find the initial seed list of indices for methods which use element...
Definition elementborderlistfromgrid.hh:49
ecfvbaseoutputmodule.hh
Implements the discretization specific parts of writing files.
ecfvgridcommhandlefactory.hh
A class which provides types for DUNE grid handles for communication.
ecfvproperties.hh
Declare the basic properties used by the common infrastructure of the element-centered finite volume ...
ecfvstencil.hh
Represents the stencil (finite volume geometry) of a single element in the ECFV discretization.
elementborderlistfromgrid.hh
Uses communication on the grid to find the initial seed list of indices for methods which use element...
fvbasediscretization.hh
The base class for the finite volume discretization schemes.
fvbasediscretizationfemadapt.hh
The base class for the finite volume discretization schemes.
Opm::Properties::TTag
The generic type tag for problems using the immiscible multi-phase model.
Definition blackoilmodel.hh:81
Opm
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43
Opm::GetPropType
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition propertysystem.hh:233
Opm::getPropValue
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:240
Opm::Properties::BorderListCreator
The class which marks the border indices associated with the degrees of freedom on a process boundary...
Definition basicproperties.hh:125
Opm::Properties::DiscBaseOutputModule
The part of the VTK ouput modules which is specific to the spatial discretization.
Definition fvbaseproperties.hh:164
Opm::Properties::DiscreteFunctionSpace
The class describing the discrete function space when dune-fem is used, otherwise it points to the st...
Definition fvbaseproperties.hh:74
Opm::Properties::Discretization
The type of the spatial discretization used by the model.
Definition fvbaseproperties.hh:88
Opm::Properties::DofMapper
The mapper to find the global index of a degree of freedom.
Definition fvbaseproperties.hh:219
Opm::Properties::DummySpaceEcfv
Definition ecfvdiscretization.hh:112
Opm::Properties::GridCommHandleFactory
The class to create grid communication handles.
Definition fvbaseproperties.hh:168
Opm::Properties::LinearizeNonLocalElements
Specify if elements that do not belong to the local process' grid partition should be skipped.
Definition fvbaseproperties.hh:101
Opm::Properties::Scalar
Property to specify the type of scalar values.
Definition basicproperties.hh:76
Opm::Properties::Stencil
The class describing the stencil of the spatial discretization.
Definition fvbaseproperties.hh:70
Opm::Properties::UseLinearizationLock
use locking to prevent race conditions when linearizing the global system of equations in multi-threa...
Definition fvbaseproperties.hh:181