Loading...
Searching...
No Matches
fvbaseprimaryvariables.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_FV_BASE_PRIMARY_VARIABLES_HH
#define EWOMS_FV_BASE_PRIMARY_VARIABLES_HH
#include <dune/common/fvector.hh>
#include <opm/material/common/MathToolbox.hpp>
#include <opm/material/common/Valgrind.hpp>
#include <opm/models/discretization/common/fvbaseproperties.hh>
#include <opm/models/discretization/common/linearizationtype.hh>
#include <stdexcept>
#include <type_traits>
namespace Opm {
template <class TypeTag>
class FvBasePrimaryVariables
: public Dune::FieldVector<GetPropType<TypeTag, Properties::Scalar>,
getPropValue<TypeTag, Properties::NumEq>()>
{
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using Evaluation = GetPropType<TypeTag, Properties::Evaluation>;
enum { numEq = getPropValue<TypeTag, Properties::NumEq>() };
using Toolbox = MathToolbox<Evaluation>;
using ParentType = Dune::FieldVector<Scalar, numEq>;
public:
FvBasePrimaryVariables()
: ParentType()
{ Valgrind::SetUndefined(*this); }
FvBasePrimaryVariables(const FvBasePrimaryVariables& value) = default;
FvBasePrimaryVariables& operator=(const FvBasePrimaryVariables& value) = default;
using ParentType::operator=;
static void init()
{
// Nothing required by default.
}
static void registerParameters()
{
// No parameters to register by default.
}
Evaluation makeEvaluation(unsigned varIdx, unsigned timeIdx,
LinearizationType linearizationType = LinearizationType()) const
{
if constexpr (std::is_same_v<Evaluation, Scalar>) {
return (*this)[varIdx]; // finite differences
}
else {
// automatic differentiation
if (timeIdx == linearizationType.time) {
return Toolbox::createVariable((*this)[varIdx], varIdx);
}
else {
return Toolbox::createConstant((*this)[varIdx]);
}
}
}
template <class FluidState>
void assignNaive(const FluidState&)
{
throw std::runtime_error("The PrimaryVariables class does not define "
"an assignNaive() method");
}
void checkDefined() const
{
Valgrind::CheckDefined(*static_cast<const ParentType*>(this));
}
};
} // namespace Opm
namespace Dune {
template<class TypeTag, bool>
struct FieldTraitsImpl;
template<class TypeTag>
struct FieldTraitsImpl<TypeTag, true>
: public FieldTraits<FieldVector<Opm::GetPropType<TypeTag, Opm::Properties::Scalar>,
Opm::getPropValue<TypeTag, Opm::Properties::NumEq>()>>
{
};
template<class T>
struct FieldTraitsImpl<T, false>
: public FieldTraits<T>
{
};
template<class TypeTag, template <class> class EwomsPrimaryVariable>
struct FieldTraits<EwomsPrimaryVariable<TypeTag>>
: public FieldTraitsImpl<TypeTag,
std::is_base_of_v<Opm::FvBasePrimaryVariables<TypeTag>,
EwomsPrimaryVariable<TypeTag>>>
{
};
} // namespace Dune
#endif
Opm::FvBasePrimaryVariables::init
static void init()
< Import base class assignment operators.
Definition fvbaseprimaryvariables.hh:79
Opm::FvBasePrimaryVariables::FvBasePrimaryVariables
FvBasePrimaryVariables(const FvBasePrimaryVariables &value)=default
Assignment from another primary variables object.
Opm::FvBasePrimaryVariables::operator=
FvBasePrimaryVariables & operator=(const FvBasePrimaryVariables &value)=default
Assignment from another primary variables object.
Opm::FvBasePrimaryVariables::checkDefined
void checkDefined() const
Instruct valgrind to check the definedness of all attributes of this class.
Definition fvbaseprimaryvariables.hh:133
Opm::FvBasePrimaryVariables::assignNaive
void assignNaive(const FluidState &)
Assign the primary variables "somehow" from a fluid state.
Definition fvbaseprimaryvariables.hh:124
Opm::FvBasePrimaryVariables::makeEvaluation
Evaluation makeEvaluation(unsigned varIdx, unsigned timeIdx, LinearizationType linearizationType=LinearizationType()) const
Return a primary variable intensive evaluation.
Definition fvbaseprimaryvariables.hh:96
fvbaseproperties.hh
Declare the properties used by the infrastructure code of the finite volume discretizations.
linearizationtype.hh
The common code for the linearizers of non-linear systems of equations.
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
Dune::FieldTraitsImpl
Compatibility traits class for DenseVector and DenseMatrix.
Definition fvbaseprimaryvariables.hh:146
Opm::LinearizationType
Definition linearizationtype.hh:34