24#ifndef DUMUX_FVTRANSPORT2P2C_MULTIPHYSICS_HH
25#define DUMUX_FVTRANSPORT2P2C_MULTIPHYSICS_HH
54template<
class TypeTag>
61 using Indices =
typename GET_PROP_TYPE(TypeTag, ModelTraits)::Indices;
65 using TransportSolutionType =
typename GET_PROP_TYPE(TypeTag, TransportSolutionType);
69 dim = GridView::dimension
73 wPhaseIdx = Indices::wPhaseIdx, nPhaseIdx = Indices::nPhaseIdx,
74 wCompIdx = Indices::wPhaseIdx, nCompIdx = Indices::nPhaseIdx
77 using PhaseVector = Dune::FieldVector<Scalar, 2>;
78 using PrimaryVariables =
typename GET_PROP_TYPE(TypeTag, PrimaryVariables);
87 virtual void update(
const Scalar t, Scalar& dt, TransportSolutionType& updateVec,
bool impet =
false);
118template<
class TypeTag>
124 unsigned int size = problem().gridView().size(0);
136 updateVec[wCompIdx].resize(problem().gridView().size(0));
137 updateVec[nCompIdx].resize(problem().gridView().size(0));
138 updateVec[wCompIdx] = 0;
139 updateVec[nCompIdx] = 0;
142 int restrictingCell = -1;
144 PhaseVector entries(0.), timestepFlux(0.);
146 for (
const auto& element : elements(problem().gridView()))
149 int globalIdxI = problem().variables().index(element);
150 CellData& cellDataI = problem().variables().cellData(globalIdxI);
152 if (impet || cellDataI.subdomain() == 2)
155 double sumfactorin = 0;
156 double sumfactorout = 0;
159 for (
const auto& intersection :
intersections(problem().gridView(), element))
161 int indexInInside = intersection.indexInInside();
164 if (intersection.neighbor())
165 this->
getFlux(entries, timestepFlux, intersection, cellDataI);
168 if (intersection.boundary())
173 LocalTimesteppingData& localData = this->
timeStepData_[globalIdxI];
175 if (localData.faceTargetDt[indexInInside] < this->accumulatedDt_ + this->dtThreshold_)
177 localData.faceFluxes[indexInInside] = entries;
183 updateVec[wCompIdx][globalIdxI] += entries[wCompIdx];
184 updateVec[nCompIdx][globalIdxI] += entries[nCompIdx];
188 sumfactorin += timestepFlux[0];
189 sumfactorout += timestepFlux[1];
195 LocalTimesteppingData& localData = this->
timeStepData_[globalIdxI];
196 for (
int i=0; i < 2*dim; i++)
198 updateVec[wCompIdx][globalIdxI] += localData.faceFluxes[i][wCompIdx];
199 updateVec[nCompIdx][globalIdxI] += localData.faceFluxes[i][nCompIdx];
204 PrimaryVariables q(NAN);
205 problem().source(q, element);
206 updateVec[wCompIdx][globalIdxI] += q[Indices::contiWEqIdx];
207 updateVec[nCompIdx][globalIdxI] += q[Indices::contiNEqIdx];
211 sumfactorin = max(sumfactorin,sumfactorout)
212 / problem().spatialParams().porosity(element);
218 if ( 1./sumfactorin < dt)
221 restrictingCell= globalIdxI;
226 if ( 1./sumfactorin < dt)
229 restrictingCell= globalIdxI;
237 using SolutionTypes =
typename GET_PROP(TypeTag, SolutionTypes);
238 using ElementMapper =
typename SolutionTypes::ElementMapper;
240 for (
int i = 0; i < updateVec.size(); i++)
242 DataHandle dataHandle(problem().variables().elementMapper(), updateVec[i]);
243 problem().gridView().template communicate<DataHandle>(dataHandle,
244 Dune::InteriorBorder_All_Interface,
245 Dune::ForwardCommunication);
247 dt = problem().gridView().comm().min(dt);
252 Dune::dinfo <<
"Timestep restricted by CellIdx " << restrictingCell <<
255 Dune::dinfo <<
" Averageing done for " << this->
averagedFaces_ <<
" faces. "<< std::endl;
#define GET_PROP_VALUE(TypeTag, PropTagName)
Definition propertysystemmacros.hh:282
#define GET_PROP(TypeTag, PropTagName)
Definition propertysystemmacros.hh:281
#define GET_PROP_TYPE(TypeTag, PropTagName)
Definition propertysystemmacros.hh:283
Contains a class to exchange entries of a vector.
Finite volume discretization of the component transport equation.
T getParam(Args &&... args)
A free function to get a parameter from the parameter tree singleton.
Definition parameters.hh:428
Dune::IteratorRange< typename MultiDomainGlue< DomainGridView, TargetGridView, DomainMapper, TargetMapper >::Intersections::const_iterator > intersections(const MultiDomainGlue< DomainGridView, TargetGridView, DomainMapper, TargetMapper > &glue)
Range generator to iterate with range-based for loops over all intersections as follows: for (const a...
Definition glue.hh:62
make the local view function available whenever we use the grid geometry
Definition adapt.hh:29
A data handle class to exchange entries of a vector.
Definition vectorexchange.hh:40
FVTransport2P2C(Problem &problem)
Constructs a FVTransport2P2C object Currently, the compositional transport scheme can not be applied ...
Definition fvtransport.hh:273
Problem & problem_
Definition fvtransport.hh:301
int averagedFaces_
number of faces were flux was restricted
Definition fvtransport.hh:303
bool impet_
indicating if we are in an estimate (false) or real impet (true) step.
Definition fvtransport.hh:302
void getFlux(ComponentVector &fluxEntries, EntryType ×tepFlux, const Intersection &intersection, CellData &cellDataI)
Get flux at an interface between two cells The flux through is calculated according to the underlyin...
Definition fvtransport.hh:579
Problem & problem()
Acess function for the current problem.
Definition fvtransport.hh:122
std::vector< LocalTimesteppingData > timeStepData_
Stores data for sub-time-stepping.
Definition fvtransport.hh:319
void getFluxOnBoundary(ComponentVector &fluxEntries, EntryType ×tepFlux, const Intersection &intersection, const CellData &cellDataI)
Get flux on Boundary.
Definition fvtransport.hh:884
bool enableLocalTimeStepping()
Function to check if local time stepping is activated.
Definition fvtransport.hh:260
Definition fvtransport.hh:113
virtual ~FVTransport2P2CMultiPhysics()
Definition fvtransportmultiphysics.hh:96
FVTransport2P2CMultiPhysics(Problem &problem)
Constructs a FVTransport2P2CMultiPhysics object.
Definition fvtransportmultiphysics.hh:93
virtual void update(const Scalar t, Scalar &dt, TransportSolutionType &updateVec, bool impet=false)
Calculate the update vector and determine timestep size.
Definition fvtransportmultiphysics.hh:119