Loading...
Searching...
No Matches
fvbasenewtonmethod.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_NEWTON_METHOD_HH
#define EWOMS_FV_BASE_NEWTON_METHOD_HH
#include <opm/models/discretization/common/fvbasenewtonconvergencewriter.hh>
#include <opm/models/nonlinear/newtonmethod.hh>
#include <opm/models/utils/propertysystem.hh>
namespace Opm {
template <class TypeTag>
class FvBaseNewtonMethod;
template <class TypeTag>
class FvBaseNewtonConvergenceWriter;
} // namespace Opm
namespace Opm::Properties {
// Create new type tags
namespace TTag {
struct FvBaseNewtonMethod { using InheritsFrom = std::tuple<NewtonMethod>; };
} // end namespace TTag
template<class TypeTag, class MyTypeTag>
struct DiscNewtonMethod { using type = UndefinedProperty; };
// set default values
template<class TypeTag>
struct DiscNewtonMethod<TypeTag, TTag::FvBaseNewtonMethod>
{ using type = FvBaseNewtonMethod<TypeTag>; };
template<class TypeTag>
struct NewtonMethod<TypeTag, TTag::FvBaseNewtonMethod>
{ using type = GetPropType<TypeTag, Properties::DiscNewtonMethod>; };
template<class TypeTag>
struct NewtonConvergenceWriter<TypeTag, TTag::FvBaseNewtonMethod>
{ using type = FvBaseNewtonConvergenceWriter<TypeTag>; };
} // namespace Opm::Properties
namespace Opm {
template <class TypeTag>
class FvBaseNewtonMethod : public NewtonMethod<TypeTag>
{
using ParentType = NewtonMethod<TypeTag>;
using Implementation = GetPropType<TypeTag, Properties::NewtonMethod>;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
using Model = GetPropType<TypeTag, Properties::Model>;
using Linearizer = GetPropType<TypeTag, Properties::Linearizer>;
using GlobalEqVector = GetPropType<TypeTag, Properties::GlobalEqVector>;
using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>;
using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
using EqVector = GetPropType<TypeTag, Properties::EqVector>;
public:
explicit FvBaseNewtonMethod(Simulator& simulator)
: ParentType(simulator)
{}
protected:
friend class NewtonMethod<TypeTag>;
void update_(SolutionVector& nextSolution,
const SolutionVector& currentSolution,
const GlobalEqVector& solutionUpdate,
const GlobalEqVector& currentResidual)
{
ParentType::update_(nextSolution, currentSolution, solutionUpdate, currentResidual);
// make sure that the intensive quantities get recalculated at the next
// linearization
if (model_().storeIntensiveQuantities()) {
for (unsigned dofIdx = 0; dofIdx < model_().numGridDof(); ++dofIdx) {
model_().setIntensiveQuantitiesCacheEntryValidity(dofIdx,
/*timeIdx=*/0,
/*valid=*/false);
}
}
}
void beginIteration_()
{
model_().syncOverlap();
ParentType::beginIteration_();
}
Model& model_()
{ return ParentType::model(); }
const Model& model_() const
{ return ParentType::model(); }
private:
Implementation& asImp_()
{ return *static_cast<Implementation*>(this); }
const Implementation& asImp_() const
{ return *static_cast<const Implementation*>(this); }
};
} // namespace Opm
#endif
Opm::FvBaseNewtonConvergenceWriter
Writes the intermediate solutions during the Newton scheme for models using a finite volume discretiz...
Definition fvbasenewtonconvergencewriter.hh:64
Opm::FvBaseNewtonMethod
A Newton method for models using a finite volume discretization.
Definition fvbasenewtonmethod.hh:84
Opm::FvBaseNewtonMethod::beginIteration_
void beginIteration_()
Indicates the beginning of a Newton iteration.
Definition fvbasenewtonmethod.hh:143
Opm::FvBaseNewtonMethod::model_
Model & model_()
Returns a reference to the model.
Definition fvbasenewtonmethod.hh:153
Opm::FvBaseNewtonMethod::update_
void update_(SolutionVector &nextSolution, const SolutionVector &currentSolution, const GlobalEqVector &solutionUpdate, const GlobalEqVector &currentResidual)
Update the current solution with a delta vector.
Definition fvbasenewtonmethod.hh:122
Opm::FvBaseNewtonMethod::model_
const Model & model_() const
Returns a reference to the model.
Definition fvbasenewtonmethod.hh:159
Opm::NewtonMethod::update_
void update_(SolutionVector &nextSolution, const SolutionVector &currentSolution, const GlobalEqVector &solutionUpdate, const GlobalEqVector &currentResidual)
Update the current solution with a delta vector.
Definition newtonmethod.hh:662
Opm::NewtonMethod::model
Model & model()
Returns a reference to the numeric model.
Definition newtonmethod.hh:173
Opm::NewtonMethod::beginIteration_
void beginIteration_()
Indicates the beginning of a Newton iteration.
Definition newtonmethod.hh:528
fvbasenewtonconvergencewriter.hh
Writes the intermediate solutions during the Newton scheme for models using a finite volume discretiz...
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
newtonmethod.hh
The multi-dimensional Newton method.
propertysystem.hh
The Opm property system, traits with inheritance.
Opm::Properties::DiscNewtonMethod
The discretization specific part of he implementing the Newton algorithm.
Definition fvbasenewtonmethod.hh:55
Opm::Properties::NewtonConvergenceWriter
Specifies the type of the class which writes out the Newton convergence.
Definition newtonmethodproperties.hh:40
Opm::Properties::NewtonMethod
Specifies the type of the actual Newton method.
Definition newtonmethodproperties.hh:32
Opm::Properties::TTag::FvBaseNewtonMethod
Definition fvbasenewtonmethod.hh:50
Opm::Properties::UndefinedProperty
a tag to mark properties as undefined
Definition propertysystem.hh:38