28 #ifndef EWOMS_FV_BASE_DISCRETIZATION_FEMADAPT_HH 29 #define EWOMS_FV_BASE_DISCRETIZATION_FEMADAPT_HH 31 #include <dune/fem/function/blockvectorfunction.hh> 32 #include <dune/fem/misc/capabilities.hh> 33 #include <dune/fem/space/common/adaptationmanager.hh> 34 #include <dune/fem/space/common/restrictprolongtuple.hh> 43 template<
class TypeTag>
46 namespace Properties {
48 template<
class TypeTag>
52 template<
class TypeTag>
57 using type = Dune::Fem::ISTLBlockVectorDiscreteFunction<DiscreteFunctionSpace, PrimaryVariables>;
68 template <
class TypeTag>
69 class FvBaseDiscretizationFemAdapt :
public FvBaseDiscretization<TypeTag>
71 using Grid = GetPropType<TypeTag, Properties::Grid>;
72 using ParentType = FvBaseDiscretization<TypeTag>;
73 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
74 using Problem = GetPropType<TypeTag, Properties::Problem>;
75 using Simulator = GetPropType<TypeTag, Properties::Simulator>;
77 static constexpr
unsigned historySize = getPropValue<TypeTag, Properties::TimeDiscHistorySize>();
79 using DiscreteFunctionSpace = GetPropType<TypeTag, Properties::DiscreteFunctionSpace>;
81 using DiscreteFunction = Dune::Fem::ISTLBlockVectorDiscreteFunction<DiscreteFunctionSpace, PrimaryVariables>;
84 using ProblemRestrictProlongOperator =
typename Problem::RestrictProlongOperator;
87 using DiscreteFunctionRestrictProlong = Dune::Fem::RestrictProlongDefault<DiscreteFunction>;
89 = Dune::Fem::RestrictProlongTuple<DiscreteFunctionRestrictProlong, ProblemRestrictProlongOperator>;
92 using AdaptationManager = Dune::Fem::AdaptationManager<Grid, RestrictProlong>;
95 template<
class Serializer>
98 template<
class SolutionType>
99 static void serializeOp(Serializer& serializer,
103 serializer(sol->blockVector());
110 , space_(simulator.vanguard().gridPart())
112 if (this->enableGridAdaptation_ && !Dune::Fem::Capabilities::isLocallyAdaptive<Grid>::v) {
113 throw std::invalid_argument(
"Grid adaptation enabled, but chosen Grid is not capable" 117 for (
unsigned timeIdx = 0; timeIdx < historySize; ++timeIdx) {
118 this->solution_[timeIdx] = std::make_unique<DiscreteFunction>(
"solution", space_);
126 if (this->enableGridAdaptation_) {
128 if (this->simulator_.problem().markForGridAdaptation()) {
130 adaptationManager().adapt();
134 this->elementMapper_.update(this->gridView_);
135 this->vertexMapper_.update(this->gridView_);
147 this->simulator_.problem().gridChanged();
150 for (
auto& module : this->outputModules_) {
151 module->allocBuffers();
157 AdaptationManager& adaptationManager()
159 if (!adaptationManager_) {
163 std::make_unique<RestrictProlong>(DiscreteFunctionRestrictProlong(*(this->solution_[0])),
164 this->simulator_.problem().restrictProlongOperator());
166 std::make_unique<AdaptationManager>(this->simulator_.vanguard().grid(), *restrictProlong_);
168 return *adaptationManager_;
172 DiscreteFunctionSpace space_;
173 std::unique_ptr<RestrictProlong> restrictProlong_;
174 std::unique_ptr<AdaptationManager> adaptationManager_;
void finishInit()
Apply the initial conditions to the model.
Definition: fvbasediscretization.hh:457
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
The base class for the finite volume discretization schemes.
Definition: fvbasediscretization.hh:87
const SolutionVector & solution(unsigned timeIdx) const
Reference to the solution at a given history index as a block vector.
Definition: fvbasediscretization.hh:1219
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: blackoilbioeffectsmodules.hh:45
The base class for the finite volume discretization schemes.
void resetLinearizer()
Resets the Jacobian matrix linearizer, so that the boundary types can be altered. ...
Definition: fvbasediscretization.hh:1615
Definition: fvbasediscretizationfemadapt.hh:96
The base class for the finite volume discretization schemes.
Definition: fvbasediscretizationfemadapt.hh:44