24#ifndef DUMUX_FV3DPRESSURE2P2C_ADAPTIVE_HH
25#define DUMUX_FV3DPRESSURE2P2C_ADAPTIVE_HH
28#include <dune/istl/bvector.hh>
29#include <dune/istl/operators.hh>
30#include <dune/istl/solvers.hh>
31#include <dune/istl/preconditioners.hh>
86 using SolutionTypes =
typename GET_PROP(TypeTag, SolutionTypes);
89 using SpatialParams =
typename GET_PROP_TYPE(TypeTag, SpatialParams);
90 using MaterialLaw =
typename SpatialParams::MaterialLaw;
92 using Indices =
typename GET_PROP_TYPE(TypeTag, ModelTraits)::Indices;
93 using BoundaryTypes =
typename GET_PROP_TYPE(TypeTag, BoundaryTypes);
95 using FluidSystem =
typename GET_PROP_TYPE(TypeTag, FluidSystem);
96 using FluidState =
typename GET_PROP_TYPE(TypeTag, FluidState);
101 dim = GridView::dimension, dimWorld = GridView::dimensionworld,
106 pw = Indices::pressureW,
107 pn = Indices::pressureN,
108 pGlobal = Indices::pressureGlobal,
109 Sw = Indices::saturationW,
110 Sn = Indices::saturationN
114 wPhaseIdx = Indices::wPhaseIdx, nPhaseIdx = Indices::nPhaseIdx,
115 wCompIdx = Indices::wPhaseIdx, nCompIdx = Indices::nPhaseIdx,
116 contiWEqIdx = Indices::contiWEqIdx, contiNEqIdx = Indices::contiNEqIdx
124 using Vertex =
typename GridView::Traits::template Codim<dim>::Entity;
125 using Element =
typename GridView::Traits::template Codim<0>::Entity;
126 using ReferenceElementContainer = Dune::ReferenceElements<Scalar, dim>;
128 using Grid =
typename GridView::Grid;
129 using Intersection =
typename GridView::Intersection;
130 using IntersectionIterator =
typename GridView::IntersectionIterator;
133 using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>;
134 using TransmissivityMatrix = Dune::FieldVector<Scalar,dim+1>;
135 using DimMatrix = Dune::FieldMatrix<Scalar, dim, dim>;
136 using PhaseVector = Dune::FieldVector<Scalar,
GET_PROP_VALUE(TypeTag, NumPhases)>;
137 using ComponentVector = Dune::FieldVector<Scalar,
GET_PROP_VALUE(TypeTag, NumComponents)>;
138 using PrimaryVariables =
typename GET_PROP_TYPE(TypeTag, PrimaryVariables);
146 using InteractionVolume =
typename InteractionVolumeContainer::InteractionVolume;
154 const Problem& problem()
const
169 new InteractionVolumeContainer(problem());
173 asImp_().initializeMatrix();
186 new InteractionVolumeContainer(problem());
196 void getMpfaFlux(
const IntersectionIterator&,
const CellData&);
198 void get1pMpfaFlux(
const IntersectionIterator&,
const CellData&);
205 TransmissivityMatrix&,
214 int gridSize = problem().gridView().size(0);
217 for (
const auto& element : elements(problem().gridView()))
220 int eIdxGlobalI = problem().variables().index(element);
223 if (element.partitionType() == Dune::InteriorEntity)
226 = problem().variables().cellData(eIdxGlobalI).pressure(this->
pressureType);
231 using SolutionTypes =
typename GET_PROP(TypeTag, SolutionTypes);
237 problem().gridView().template communicate<DataHandle>(dataHandle,
238 Dune::InteriorBorder_All_Interface,
239 Dune::ForwardCommunication);
252 enableMPFA = getParam<bool>(
"GridAdapt.EnableMultiPointFluxApproximation");
259 Implementation &asImp_()
260 {
return *
static_cast<Implementation *
>(
this);}
263 const Implementation &asImp_()
const
264 {
return *
static_cast<const Implementation *
>(
this);}
266 int searchCommonVertex_(
const Intersection& is, Vertex& vertex)
270 int localIdxLarge = 0;
271 for(localIdxLarge = 0; localIdxLarge < is.inside().subEntities(dim); ++localIdxLarge)
273 auto vLarge = is.inside().template subEntity<dim>(localIdxLarge);
276 for(
int verticeSmall = 0; verticeSmall<is.outside().subEntities(dim); ++verticeSmall)
278 auto vSmall = is.outside().template subEntity<dim>(verticeSmall);
280 if(problem().variables().index(vSmall) == problem().variables().index(vLarge) )
283 return localIdxLarge;
292 InteractionVolume& interactionVolume,
293 const int& subVolumeFaceIdx,
294 bool properFluxDirection,
295 Element& additional2,
296 Element& additional3,
297 TransmissivityMatrix& additionalT);
311template<
class TypeTag>
314 int gridSize_ = problem().gridView().size(0);
316 this->A_.setSize (gridSize_,gridSize_);
317 this->f_.resize(gridSize_);
318 irregularCellMap_.clear();
320 this->initializeMatrixRowSize();
321 this->A_.endrowsizes();
322 this->initializeMatrixIndices();
323 this->A_.endindices();
327template<
class TypeTag>
331 for (
const auto& element : elements(problem().gridView()))
334 int eIdxGlobalI = problem().variables().index(element);
335 CellData& cellDataI = problem().variables().cellData(eIdxGlobalI);
341 cellDataI.perimeter() = 0;
344 std::vector<int> foundAdditionals;
346 int numberOfIntersections = 0;
348 for (
const auto& intersection :
intersections(problem().gridView(), element))
350 cellDataI.perimeter() += intersection.geometry().volume();
351 numberOfIntersections++;
352 if (intersection.neighbor())
357 if (enableMPFA && (element.level() < intersection.outside().level()))
361 int intersectionID = problem().grid().localIdSet().subId(element,
362 intersection.indexInInside(), 1);
364 int eIdxGlobalJ = problem().variables().index(intersection.outside());
367 irregularCellMap_[intersectionID].push_back(eIdxGlobalJ);
371 cellDataI.fluxData().resize(numberOfIntersections);
372 this->A_.incrementrowsize(eIdxGlobalI, rowSize);
376 if(enableMPFA && maxInteractionVolumes>1)
379 std::multimap<int, int> addionalRelations;
380 using IntPair = std::pair<int,int>;
381 std::pair<std::multimap<int,int>::iterator,std::multimap<int,int>::iterator> range;
382 std::multimap<int,int>::iterator rangeIt;
385 for (
const auto& element : elements(problem().gridView()))
388 int eIdxGlobalI = problem().variables().index(element);
390 const auto isEndIt = problem().gridView().iend(element);
391 for (
auto isIt = problem().gridView().ibegin(element); isIt != isEndIt; ++isIt)
393 const auto& intersection = *isIt;
395 if (intersection.neighbor())
398 int eIdxGlobalJ = problem().variables().index(intersection.outside());
401 if (intersection.outside().level() > element.level())
405 GlobalPosition globalPos3(0.);
407 GlobalPosition globalPos4(0.);
409 TransmissivityMatrix T(0.);
411 int interactionRegions
412 = problem().variables().getMpfaData3D(intersection, T,
413 globalPos3, eIdxGlobal3, globalPos4, eIdxGlobal4 );
414 if (interactionRegions == 0)
415 interactionRegions = problem().pressureModel().computeTransmissibilities(isIt,T,
416 globalPos3, eIdxGlobal3, globalPos4, eIdxGlobal4 );
417 if(!interactionRegions)
418 Dune::dgrave <<
"something went wrong getting mpfa data on cell " << eIdxGlobalI << std::endl;
419 if (interactionRegions == 1)
423 for (
int cocumber=1; cocumber<interactionRegions; cocumber++ )
425 problem().variables().getMpfaData3D(intersection, T,
426 globalPos3, eIdxGlobal3, globalPos4, eIdxGlobal4, cocumber);
428 int additionalIdx2 = eIdxGlobal3;
429 int additionalIdx3 = eIdxGlobal4;
431 bool addIndex =
true;
434 bool additional2isNeighbor(
false), additional3isNeighbor(
false);
436 for (
const auto& checkIntersection
439 if (checkIntersection.neighbor())
441 if(additionalIdx2==problem().variables().index(checkIntersection.outside()))
442 additional2isNeighbor =
true;
443 if(additionalIdx3 == problem().variables().index(checkIntersection.outside()))
444 additional3isNeighbor =
true;
449 if(!additional2isNeighbor)
452 IntPair intPair(eIdxGlobalI,additionalIdx2);
453 if(eIdxGlobalI > additionalIdx2)
456 swap(intPair.first, intPair.second);
458 range = addionalRelations.equal_range(intPair.first);
459 for (rangeIt=range.first; range.first!=range.second
460 && rangeIt!=range.second; ++rangeIt)
461 if((*rangeIt).second == intPair.second)
465 this->A_.incrementrowsize(eIdxGlobalI);
467 this->A_.incrementrowsize(additionalIdx2);
469 addionalRelations.insert(intPair);
474 if(!additional3isNeighbor)
478 IntPair intPair(eIdxGlobalI,additionalIdx3);
479 if(eIdxGlobalI > additionalIdx3)
482 swap(intPair.first, intPair.second);
484 range = addionalRelations.equal_range(intPair.first);
485 for (rangeIt=range.first; range.first!=range.second
486 && rangeIt!=range.second; ++rangeIt)
487 if((*rangeIt).second == intPair.second)
491 this->A_.incrementrowsize(eIdxGlobalI);
493 this->A_.incrementrowsize(additionalIdx3);
495 addionalRelations.insert(intPair);
500 additional2isNeighbor = additional3isNeighbor =
false;
502 for (
const auto& checkIntersection
503 :
intersections(problem().gridView(), intersection.outside()))
505 if (checkIntersection.neighbor())
507 if(additionalIdx2 == problem().variables().index(checkIntersection.outside()))
508 additional2isNeighbor =
true;
509 if(additionalIdx3 == problem().variables().index(checkIntersection.outside()))
510 additional3isNeighbor =
true;
515 if(!additional2isNeighbor)
519 IntPair intPair(eIdxGlobalJ,additionalIdx2);
520 if(eIdxGlobalJ > additionalIdx2)
523 swap(intPair.first, intPair.second);
525 range = addionalRelations.equal_range(intPair.first);
526 for (rangeIt=range.first; range.first!=range.second
527 && rangeIt!=range.second; ++rangeIt)
528 if((*rangeIt).second == intPair.second)
532 this->A_.incrementrowsize(eIdxGlobalJ);
534 this->A_.incrementrowsize(additionalIdx2);
536 addionalRelations.insert(intPair);
541 if(!additional3isNeighbor)
545 IntPair intPair(eIdxGlobalJ,additionalIdx3);
546 if(eIdxGlobalJ > additionalIdx3)
549 swap(intPair.first, intPair.second);
551 range = addionalRelations.equal_range(intPair.first);
552 for (rangeIt=range.first; range.first!=range.second
553 && rangeIt!=range.second; ++rangeIt)
554 if((*rangeIt).second == intPair.second)
558 this->A_.incrementrowsize(eIdxGlobalJ);
560 this->A_.incrementrowsize(additionalIdx3);
562 addionalRelations.insert(intPair);
576template<
class TypeTag>
580 for (
const auto& element : elements(problem().gridView()))
583 int eIdxGlobalI = problem().variables().index(element);
586 this->A_.addindex(eIdxGlobalI, eIdxGlobalI);
589 const auto isEndIt = problem().gridView().iend(element);
590 for (
auto isIt = problem().gridView().ibegin(element); isIt != isEndIt; ++isIt)
592 const auto& intersection = *isIt;
594 if (intersection.neighbor())
597 int eIdxGlobalJ = problem().variables().index(intersection.outside());
600 this->A_.addindex(eIdxGlobalI, eIdxGlobalJ);
603 if (enableMPFA && (element.level() < intersection.outside().level()))
606 GlobalPosition globalPos3(0.);
608 GlobalPosition globalPos4(0.);
610 TransmissivityMatrix T(0.);
611 TransmissivityMatrix additionalT(0.);
613 int interactionRegions
614 = problem().variables().getMpfaData3D(intersection, T, globalPos3, eIdxGlobal3, globalPos4, eIdxGlobal4 );
615 if (interactionRegions == 0)
616 interactionRegions = problem().pressureModel().computeTransmissibilities(isIt,T,
617 globalPos3, eIdxGlobal3, globalPos4, eIdxGlobal4 );
619 for (
int cocumber=1; cocumber<interactionRegions; cocumber++ )
621 problem().variables().getMpfaData3D(intersection, T,
622 globalPos3, eIdxGlobal3, globalPos4, eIdxGlobal4, cocumber);
625 this->A_.addindex(eIdxGlobalI, eIdxGlobal3);
626 this->A_.addindex(eIdxGlobal3, eIdxGlobalI);
627 this->A_.addindex(eIdxGlobalI, eIdxGlobal4);
628 this->A_.addindex(eIdxGlobal4, eIdxGlobalI);
629 this->A_.addindex(eIdxGlobalJ, eIdxGlobal3);
630 this->A_.addindex(eIdxGlobal3, eIdxGlobalJ);
631 this->A_.addindex(eIdxGlobalJ, eIdxGlobal4);
632 this->A_.addindex(eIdxGlobal4, eIdxGlobalJ);
641template<
class TypeTag>
646 BaseType::assemble(
true);
654 for (
const auto& element : elements(problem().gridView()))
657 int eIdxGlobalI = problem().variables().index(element);
660 if (element.partitionType() == Dune::InteriorEntity)
663 CellData& cellDataI = problem().variables().cellData(eIdxGlobalI);
665 Dune::FieldVector<Scalar, 2> entries(0.);
668#ifndef noMultiphysics
669 if(cellDataI.subdomain() != 2)
670 problem().pressureModel().get1pSource(entries,element, cellDataI);
673 problem().pressureModel().getSource(entries,element, cellDataI, first);
675 this->f_[eIdxGlobalI] += entries[rhs];
679 const auto isEndIt = problem().gridView().iend(element);
680 for (
auto isIt = problem().gridView().ibegin(element); isIt != isEndIt; ++isIt)
682 const auto& intersection = *isIt;
685 if (intersection.neighbor())
687 auto neighbor = intersection.outside();
688 int eIdxGlobalJ = problem().variables().index(neighbor);
691 bool haveSameLevel = (element.level() == neighbor.level());
696 && (eIdxGlobalI > eIdxGlobalJ) && haveSameLevel
697 && neighbor.partitionType() == Dune::InteriorEntity)
702 if(!haveSameLevel && enableMPFA)
704 if (cellDataI.subdomain() != 2
705 || problem().variables().cellData(eIdxGlobalJ).subdomain() != 2)
707 asImp_().get1pMpfaFlux(isIt, cellDataI);
711 asImp_().getMpfaFlux(isIt, cellDataI);
716 CellData cellDataJ = problem().variables().cellData(eIdxGlobalJ);
717 if (cellDataI.subdomain() != 2
718 || problem().variables().cellData(eIdxGlobalJ).subdomain() != 2)
720 asImp_().get1pFlux(entries, intersection, cellDataI);
724 asImp_().getFlux(entries, intersection, cellDataI, first);
728 this->f_[eIdxGlobalI] -= entries[rhs];
731 this->A_[eIdxGlobalI][eIdxGlobalI] += entries[matrix];
734 this->A_[eIdxGlobalI][eIdxGlobalJ] -= entries[matrix];
738 && neighbor.partitionType() == Dune::InteriorEntity)
740 this->f_[eIdxGlobalJ] += entries[rhs];
741 this->A_[eIdxGlobalJ][eIdxGlobalJ] += entries[matrix];
742 this->A_[eIdxGlobalJ][eIdxGlobalI] -= entries[matrix];
751 if (cellDataI.subdomain() != 2)
752 asImp_().get1pFluxOnBoundary(entries, intersection, cellDataI);
754 asImp_().getFluxOnBoundary(entries, intersection, cellDataI, first);
757 this->f_[eIdxGlobalI] += entries[rhs];
759 this->A_[eIdxGlobalI][eIdxGlobalI] += entries[matrix];
764 if (cellDataI.subdomain() != 2)
765 asImp_().get1pStorage(entries, element, cellDataI);
767 asImp_().getStorage(entries, element, cellDataI, first);
769 this->f_[eIdxGlobalI] += entries[rhs];
771 this->A_[eIdxGlobalI][eIdxGlobalI] += entries[matrix];
776 this->A_[eIdxGlobalI] = 0.0;
777 this->A_[eIdxGlobalI][eIdxGlobalI] = 1.0;
778 this->f_[eIdxGlobalI] = this->
pressure()[eIdxGlobalI];
802template<
class TypeTag>
804 const CellData& cellDataI)
806 const auto& intersection = *isIt;
809 auto elementI = intersection.inside();
810 int eIdxGlobalI = problem().variables().index(elementI);
813 const GlobalPosition& globalPos = elementI.geometry().center();
816 Scalar volume = elementI.geometry().volume();
817 Scalar perimeter = cellDataI.perimeter();
820 DimMatrix permeabilityI(problem().spatialParams().intrinsicPermeability(elementI));
823 auto neighbor = intersection.outside();
824 int eIdxGlobalJ = problem().variables().index(neighbor);
825 CellData& cellDataJ = problem().variables().cellData(eIdxGlobalJ);
828 const GlobalPosition& globalPosNeighbor = neighbor.geometry().center();
831 GlobalPosition distVec = globalPosNeighbor - globalPos;
834 Scalar dist = distVec.two_norm();
836 GlobalPosition unitDistVec(distVec);
839 DimMatrix permeabilityJ
840 = problem().spatialParams().intrinsicPermeability(neighbor);
843 DimMatrix meanPermeability(0);
850 PhaseVector rhoMean(0.);
851 for (
int phaseIdx=0; phaseIdx<
NumPhases; phaseIdx++)
852 rhoMean[phaseIdx] =0.5 * (cellDataI.density(phaseIdx)+cellDataJ.density(phaseIdx));
855 Dune::FieldVector<Scalar,2> potential(0.);
858 if (!cellDataJ.hasVolumeDerivatives())
859 asImp_().volumeDerivatives(globalPosNeighbor, neighbor);
861 ComponentVector dv_dC(0.), graddv_dC(0.);
864 dv_dC[compIdx]= (cellDataJ.dv(compIdx)
865 + cellDataI.dv(compIdx)) * 0.5;
866 graddv_dC[compIdx] = (cellDataJ.dv(compIdx)
867 - cellDataI.dv(compIdx)) / dist;
881 GlobalPosition globalPos3(0.);
883 GlobalPosition globalPos4(0.);
885 TransmissivityMatrix T(0.);
888 GlobalPosition globalPosAdditional3(0.);
889 int eIdxGlobalAdditional3=-1;
890 GlobalPosition globalPosAdditional4(0.);
891 int eIdxGlobalAdditional4=-1;
893 TransmissivityMatrix additionalT(0.);
895 int interactionRegions
896 = problem().variables().getMpfaData3D(intersection, T,
897 globalPos3, eIdxGlobal3, globalPos4, eIdxGlobal4 );
898 if (interactionRegions == 0)
899 interactionRegions = problem().pressureModel().computeTransmissibilities(isIt,T,
900 globalPos3, eIdxGlobal3, globalPos4, eIdxGlobal4 );
901 if(!interactionRegions)
902 Dune::dgrave <<
"something went wrong getting mpfa data on cell " << eIdxGlobalI << std::endl;
905 CellData& cellData3 = problem().variables().cellData(eIdxGlobal3);
906 CellData& cellData4 = problem().variables().cellData(eIdxGlobal4);
907 Scalar temp1 = globalPos * this->gravity_;
908 Scalar temp2 = globalPosNeighbor * this->gravity_;
909 Scalar temp3 = globalPos3 * this->gravity_;
910 Scalar temp4 = globalPos4 * this->gravity_;
912 for (
int phaseIdx = 0; phaseIdx <
NumPhases; ++phaseIdx)
914 potential[phaseIdx] = (cellDataI.pressure(phaseIdx)-temp1*rhoMean[phaseIdx]) * T[0]
915 + (cellDataJ.pressure(phaseIdx)-temp2*rhoMean[phaseIdx]) * T[1]
916 + (cellData3.pressure(phaseIdx)-temp3*rhoMean[phaseIdx]) * T[2]
917 + (cellData4.pressure(phaseIdx)-temp4*rhoMean[phaseIdx]) * T[3];
921 if(interactionRegions != 1)
923 for(
int banana = 1; banana < interactionRegions; banana ++)
926 problem().variables().getMpfaData3D(intersection, additionalT,
927 globalPosAdditional3, eIdxGlobalAdditional3,
928 globalPosAdditional4, eIdxGlobalAdditional4 ,
931 Scalar gravityContributionAdditonal
932 = temp1 * additionalT[0] + temp2 * additionalT[1]
933 + globalPosAdditional3*this->gravity_ * additionalT[2]
934 + globalPosAdditional4*this->gravity_ * additionalT[3];
935 CellData& cellDataA3 = problem().variables().cellData(eIdxGlobalAdditional3);
936 CellData& cellDataA4 = problem().variables().cellData(eIdxGlobalAdditional4);
938 for (
int phaseIdx = 0; phaseIdx <
NumPhases; ++phaseIdx)
940 potential[phaseIdx] += cellDataI.pressure(phaseIdx) * additionalT[0]
941 + cellDataJ.pressure(phaseIdx) * additionalT[1]
942 + cellDataA3.pressure(phaseIdx) * additionalT[2]
943 + cellDataA4.pressure(phaseIdx) * additionalT[3];
944 potential[phaseIdx] -= gravityContributionAdditonal * rhoMean[phaseIdx];
950 PhaseVector lambda(0.), dV(0.), gV(0.);
953 std::vector<const CellData*> upwindCellData(
NumPhases);
955 for (
int phaseIdx = 0; phaseIdx <
NumPhases; ++phaseIdx)
957 int eqIdx = phaseIdx + 1;
958 if (potential[phaseIdx] > 0.)
959 upwindCellData[phaseIdx] = &cellDataI;
960 else if (potential[phaseIdx] < 0.)
961 upwindCellData[phaseIdx] = &cellDataJ;
964 if(cellDataI.isUpwindCell(intersection.indexInInside(), eqIdx))
965 upwindCellData[phaseIdx] = &cellDataI;
966 else if(cellDataJ.isUpwindCell(intersection.indexInOutside(), eqIdx))
967 upwindCellData[phaseIdx] = &cellDataJ;
973 if(!upwindCellData[phaseIdx])
977 averagedMassFraction[compIdx]
978 =
harmonicMean(cellDataI.massFraction(phaseIdx, compIdx), cellDataJ.massFraction(phaseIdx, compIdx));
979 Scalar averageDensity =
harmonicMean(cellDataI.density(phaseIdx), cellDataJ.density(phaseIdx));
983 dV[phaseIdx] += dv_dC[compIdx] * averagedMassFraction[compIdx];
984 gV[phaseIdx] += graddv_dC[compIdx] * averagedMassFraction[compIdx];
986 dV[phaseIdx] *= averageDensity;
987 gV[phaseIdx] *= averageDensity;
988 lambda[phaseIdx] =
harmonicMean(cellDataI.mobility(phaseIdx), cellDataJ.mobility(phaseIdx));
994 dV[phaseIdx] += dv_dC[compIdx] * upwindCellData[phaseIdx]->massFraction(phaseIdx, compIdx);
995 gV[phaseIdx] += graddv_dC[compIdx] * upwindCellData[phaseIdx]->massFraction(phaseIdx, compIdx);
997 lambda[phaseIdx] = upwindCellData[phaseIdx]->mobility(phaseIdx);
998 dV[phaseIdx] *= upwindCellData[phaseIdx]->density(phaseIdx);
999 gV[phaseIdx] *= upwindCellData[phaseIdx]->density(phaseIdx);
1005 this->A_[eIdxGlobalI][eIdxGlobalI] += (lambda[wPhaseIdx] * dV[wPhaseIdx] + lambda[nPhaseIdx] * dV[nPhaseIdx]) * T[0];
1006 this->A_[eIdxGlobalI][eIdxGlobalJ] += (lambda[wPhaseIdx] * dV[wPhaseIdx] + lambda[nPhaseIdx] * dV[nPhaseIdx]) * T[1];
1007 this->A_[eIdxGlobalI][eIdxGlobal3] += (lambda[wPhaseIdx] * dV[wPhaseIdx] + lambda[nPhaseIdx] * dV[nPhaseIdx]) * T[2];
1008 this->A_[eIdxGlobalI][eIdxGlobal4] += (lambda[wPhaseIdx] * dV[wPhaseIdx] + lambda[nPhaseIdx] * dV[nPhaseIdx]) * T[3];
1012 Scalar gravityContribution = temp1 * T[0] + temp2 * T[1] + temp3 * T[2] + temp4 * T[3];
1013 this->f_[eIdxGlobalI] += (rhoMean[wPhaseIdx] * lambda[wPhaseIdx] * dV[wPhaseIdx]
1014 + rhoMean[nPhaseIdx] * lambda[nPhaseIdx] * dV[nPhaseIdx]) * gravityContribution;
1017 Scalar weightingFactor = volume / perimeter;
1018 if(enableVolumeIntegral_)
1021 this->A_[eIdxGlobalI][eIdxGlobalI] -=
1022 weightingFactor * (lambda[wPhaseIdx] * gV[wPhaseIdx] + lambda[nPhaseIdx] * gV[nPhaseIdx]) * T[0];
1023 this->A_[eIdxGlobalI][eIdxGlobalJ] -=
1024 weightingFactor * (lambda[wPhaseIdx] * gV[wPhaseIdx] + lambda[nPhaseIdx] * gV[nPhaseIdx]) * T[1];
1025 this->A_[eIdxGlobalI][eIdxGlobal3] -=
1026 weightingFactor * (lambda[wPhaseIdx] * gV[wPhaseIdx] + lambda[nPhaseIdx] * gV[nPhaseIdx]) * T[2];
1027 this->A_[eIdxGlobalI][eIdxGlobal4] -=
1028 weightingFactor * (lambda[wPhaseIdx] * gV[wPhaseIdx] + lambda[nPhaseIdx] * gV[nPhaseIdx]) * T[3];
1031 this->f_[eIdxGlobalI] -= weightingFactor * gravityContribution *
1032 (rhoMean[wPhaseIdx] * lambda[wPhaseIdx] * gV[wPhaseIdx] + rhoMean[nPhaseIdx] * lambda[nPhaseIdx] * gV[nPhaseIdx]);
1036 Scalar pcGradient = cellDataI.capillaryPressure() * T[0]
1037 + cellDataJ.capillaryPressure() * T[1]
1038 + cellData3.capillaryPressure() * T[2]
1039 + cellData4.capillaryPressure() * T[3];
1041 if (this->pressureType == pw)
1042 pcGradient *= + lambda[nPhaseIdx] * dV[nPhaseIdx]
1043 - enableVolumeIntegral_ * weightingFactor * lambda[nPhaseIdx] * gV[nPhaseIdx];
1044 else if (this->pressureType == pn)
1045 pcGradient *= - lambda[wPhaseIdx] * dV[wPhaseIdx]
1046 + enableVolumeIntegral_ * weightingFactor * lambda[wPhaseIdx] * gV[wPhaseIdx];
1048 this->f_[eIdxGlobalI] += pcGradient;
1051 if(interactionRegions != 1)
1053 for(
int banana = 1; banana < interactionRegions; banana ++)
1056 problem().variables().getMpfaData3D(intersection, additionalT,
1057 globalPosAdditional3, eIdxGlobalAdditional3,
1058 globalPosAdditional4, eIdxGlobalAdditional4 ,
1061 Scalar gravityContributionAdditonal
1062 = temp1 * additionalT[0] + temp2 * additionalT[1]
1063 + globalPosAdditional3*this->gravity_ * additionalT[2]
1064 + globalPosAdditional4*this->gravity_ * additionalT[3];
1065 CellData& cellDataA3 = problem().variables().cellData(eIdxGlobalAdditional3);
1066 CellData& cellDataA4 = problem().variables().cellData(eIdxGlobalAdditional4);
1070 this->A_[eIdxGlobalI][eIdxGlobalI] +=
1071 (lambda[wPhaseIdx] * dV[wPhaseIdx] + lambda[nPhaseIdx] * dV[nPhaseIdx]) * additionalT[0];
1072 this->A_[eIdxGlobalI][eIdxGlobalJ] +=
1073 (lambda[wPhaseIdx] * dV[wPhaseIdx] + lambda[nPhaseIdx] * dV[nPhaseIdx]) * additionalT[1];
1074 this->A_[eIdxGlobalI][eIdxGlobalAdditional3] +=
1075 (lambda[wPhaseIdx] * dV[wPhaseIdx] + lambda[nPhaseIdx] * dV[nPhaseIdx]) * additionalT[2];
1076 this->A_[eIdxGlobalI][eIdxGlobalAdditional4] +=
1077 (lambda[wPhaseIdx] * dV[wPhaseIdx] + lambda[nPhaseIdx] * dV[nPhaseIdx]) * additionalT[3];
1081 this->f_[eIdxGlobalI] += (rhoMean[wPhaseIdx] * lambda[wPhaseIdx] * dV[wPhaseIdx]
1082 + rhoMean[nPhaseIdx] * lambda[nPhaseIdx] * dV[nPhaseIdx]) * gravityContributionAdditonal;
1085 if(enableVolumeIntegral_)
1088 this->A_[eIdxGlobalI][eIdxGlobalI] -=
1089 weightingFactor * (lambda[wPhaseIdx] * gV[wPhaseIdx] + lambda[nPhaseIdx] * gV[nPhaseIdx]) * additionalT[0];
1090 this->A_[eIdxGlobalI][eIdxGlobalJ] -=
1091 weightingFactor * (lambda[wPhaseIdx] * gV[wPhaseIdx] + lambda[nPhaseIdx] * gV[nPhaseIdx]) * additionalT[1];
1092 this->A_[eIdxGlobalI][eIdxGlobalAdditional3] -=
1093 weightingFactor * (lambda[wPhaseIdx] * gV[wPhaseIdx] + lambda[nPhaseIdx] * gV[nPhaseIdx]) * additionalT[2];
1094 this->A_[eIdxGlobalI][eIdxGlobalAdditional4] -=
1095 weightingFactor * (lambda[wPhaseIdx] * gV[wPhaseIdx] + lambda[nPhaseIdx] * gV[nPhaseIdx]) * additionalT[3];
1098 this->f_[eIdxGlobalI] -= weightingFactor * gravityContribution *
1099 (rhoMean[wPhaseIdx] * lambda[wPhaseIdx] * gV[wPhaseIdx] + rhoMean[nPhaseIdx] * lambda[nPhaseIdx] * gV[nPhaseIdx]);
1103 Scalar addPcGradient = cellDataI.capillaryPressure() * additionalT[0]
1104 + cellDataJ.capillaryPressure() * additionalT[1]
1105 + cellDataA3.capillaryPressure() * additionalT[2]
1106 + cellDataA4.capillaryPressure() * additionalT[3];
1108 if (this->pressureType == pw)
1109 addPcGradient *= + lambda[nPhaseIdx] * dV[nPhaseIdx]
1110 - enableVolumeIntegral_ * weightingFactor * lambda[nPhaseIdx] * gV[nPhaseIdx];
1111 else if (this->pressureType == pn)
1112 addPcGradient *= - lambda[wPhaseIdx] * dV[wPhaseIdx]
1113 + enableVolumeIntegral_ * weightingFactor * lambda[wPhaseIdx] * gV[wPhaseIdx];
1115 this->f_[eIdxGlobalI] += addPcGradient;
1139template<
class TypeTag>
1141 const CellData& cellDataI)
1143 const auto& intersection = *isIt;
1146 auto elementI = intersection.inside();
1147 int eIdxGlobalI = problem().variables().index(elementI);
1150 const GlobalPosition& globalPos = elementI.geometry().center();
1153 auto neighbor = intersection.outside();
1154 int eIdxGlobalJ = problem().variables().index(neighbor);
1155 CellData& cellDataJ = problem().variables().cellData(eIdxGlobalJ);
1158 const GlobalPosition& globalPosNeighbor = neighbor.geometry().center();
1163 int phaseIdx = min(cellDataI.subdomain(), cellDataJ.subdomain());
1166 Scalar rhoMean = 0.5 * (cellDataI.density(phaseIdx) + cellDataJ.density(phaseIdx));
1169 Scalar potential = 0.;
1173 GlobalPosition globalPos3(0.);
1175 GlobalPosition globalPos4(0.);
1177 TransmissivityMatrix T(0.);
1180 GlobalPosition globalPosAdditional3(0.);
1181 int eIdxGlobalAdditional3=-1;
1182 GlobalPosition globalPosAdditional4(0.);
1183 int eIdxGlobalAdditional4=-1;
1185 TransmissivityMatrix additionalT(0.);
1187 int interactionRegions
1188 = problem().variables().getMpfaData3D(intersection, T,
1189 globalPos3, eIdxGlobal3, globalPos4, eIdxGlobal4 );
1190 if (interactionRegions == 0)
1191 interactionRegions = problem().pressureModel().computeTransmissibilities(isIt,T,
1192 globalPos3, eIdxGlobal3, globalPos4, eIdxGlobal4 );
1193 if(!interactionRegions)
1194 Dune::dgrave <<
"something went wrong getting mpfa data on cell " << eIdxGlobalI << std::endl;
1197 CellData& cellData3 = problem().variables().cellData(eIdxGlobal3);
1198 CellData& cellData4 = problem().variables().cellData(eIdxGlobal4);
1199 Scalar temp1 = globalPos * this->gravity_;
1200 Scalar temp2 = globalPosNeighbor * this->gravity_;
1201 Scalar temp3 = globalPos3 * this->gravity_;
1202 Scalar temp4 = globalPos4 * this->gravity_;
1204 potential = (cellDataI.pressure(phaseIdx)-temp1*rhoMean) * T[0]
1205 + (cellDataJ.pressure(phaseIdx)-temp2*rhoMean) * T[1]
1206 + (cellData3.pressure(phaseIdx)-temp3*rhoMean) * T[2]
1207 + (cellData4.pressure(phaseIdx)-temp4*rhoMean) * T[3];
1210 if(interactionRegions != 1)
1212 for(
int banana = 1; banana < interactionRegions; banana ++)
1215 problem().variables().getMpfaData3D(intersection, additionalT,
1216 globalPosAdditional3, eIdxGlobalAdditional3,
1217 globalPosAdditional4, eIdxGlobalAdditional4 ,
1220 Scalar gravityContributionAdditonal
1221 = temp1 * additionalT[0] + temp2 * additionalT[1]
1222 + globalPosAdditional3*this->gravity_ * additionalT[2]
1223 + globalPosAdditional4*this->gravity_ * additionalT[3];
1224 CellData& cellDataA3 = problem().variables().cellData(eIdxGlobalAdditional3);
1225 CellData& cellDataA4 = problem().variables().cellData(eIdxGlobalAdditional4);
1227 potential += cellDataI.pressure(phaseIdx) * additionalT[0]
1228 + cellDataJ.pressure(phaseIdx) * additionalT[1]
1229 + cellDataA3.pressure(phaseIdx) * additionalT[2]
1230 + cellDataA4.pressure(phaseIdx) * additionalT[3];
1231 potential -= gravityContributionAdditonal * rhoMean;
1239 if (potential >= 0.)
1240 lambda = cellDataI.mobility(phaseIdx);
1242 lambda = cellDataJ.mobility(phaseIdx);
1246 this->A_[eIdxGlobalI][eIdxGlobalI] += lambda * T[0];
1247 this->A_[eIdxGlobalI][eIdxGlobalJ] += lambda * T[1];
1248 this->A_[eIdxGlobalI][eIdxGlobal3] += lambda * T[2];
1249 this->A_[eIdxGlobalI][eIdxGlobal4] += lambda * T[3];
1252 Scalar gravityContribution = temp1 * T[0] + temp2 * T[1] + temp3 * T[2] + temp4 * T[3];
1253 this->f_[eIdxGlobalI] += lambda * rhoMean * gravityContribution;
1256 if(interactionRegions != 1)
1258 for(
int banana = 1; banana < interactionRegions; banana ++)
1261 problem().variables().getMpfaData3D(intersection, additionalT,
1262 globalPosAdditional3, eIdxGlobalAdditional3,
1263 globalPosAdditional4, eIdxGlobalAdditional4 ,
1266 Scalar gravityContributionAdditonal
1267 = temp1 * additionalT[0] + temp2 * additionalT[1]
1268 + globalPosAdditional3*this->gravity_ * additionalT[2]
1269 + globalPosAdditional4*this->gravity_ * additionalT[3];
1273 this->A_[eIdxGlobalI][eIdxGlobalI] += lambda * additionalT[0];
1274 this->A_[eIdxGlobalI][eIdxGlobalJ] += lambda * additionalT[1];
1275 this->A_[eIdxGlobalI][eIdxGlobalAdditional3] += lambda * additionalT[2];
1276 this->A_[eIdxGlobalI][eIdxGlobalAdditional4] += lambda * additionalT[3];
1279 this->f_[eIdxGlobalI] += lambda * rhoMean* gravityContributionAdditonal;
1292template<
class TypeTag>
1296#ifdef noMultiphysics
1301 if(!fromPostTimestep)
1303 Scalar maxError = 0.;
1305 for (
const auto& element : elements(problem().gridView()))
1307 int eIdxGlobal = problem().variables().index(element);
1308 CellData& cellData = problem().variables().cellData(eIdxGlobal);
1310 if(cellData.fluidStateType() == 0)
1311 problem().pressureModel().updateMaterialLawsInElement(element, fromPostTimestep);
1313 problem().pressureModel().update1pMaterialLawsInElement(element, cellData, fromPostTimestep);
1315 maxError = max(maxError, fabs(cellData.volumeError()));
1317 this->maxError_ = maxError/problem().timeManager().timeStepSize();
1346template <
class TypeTag>
1348 TransmissivityMatrix& T,
1349 GlobalPosition& globalPos4,
1351 GlobalPosition& globalPos6,
1354 const auto& intersection = *isIt;
1357 auto element = intersection.inside();
1358 auto neighbor = intersection.outside();
1359 GlobalPosition globalPos1 = element.geometry().center();
1360 GlobalPosition globalPos2 = neighbor.geometry().center();
1361 DimMatrix K1(problem().spatialParams().intrinsicPermeability(element));
1362 DimMatrix K2(problem().spatialParams().intrinsicPermeability(neighbor));
1365 int intersectionID = 0;
1366 if(intersection.inside().level() < intersection.outside().level())
1367 intersectionID = problem().grid().localIdSet().subId(element,
1368 intersection.indexInInside(), 1);
1370 DUNE_THROW(Dune::NotImplemented,
" ABORT, transmiss calculated from wrong side!!");
1372 std::vector<int> localIrregularCells = irregularCellMap_[intersectionID];
1376 GlobalPosition globalPosFace12 = intersection.geometry().center();
1377 GlobalPosition outerNormaln12 = intersection.centerUnitOuterNormal();
1383 const auto isEndIt = problem().gridView().iend(neighbor);
1384 for (
auto isIt2 = problem().gridView().ibegin(neighbor); isIt2 != isEndIt; ++isIt2)
1386 const auto& intersection2 = *isIt2;
1389 if(!(intersection2.neighbor()) || intersection2.outside() == element)
1392 int currentNeighbor = problem().variables().index(intersection2.outside());
1395 if (find(localIrregularCells.begin(), localIrregularCells.end(),
1396 currentNeighbor) != localIrregularCells.end() && face24==isIt)
1398 else if (find(localIrregularCells.begin(), localIrregularCells.end(),
1399 currentNeighbor) != localIrregularCells.end() && face26==isIt)
1403 GlobalPosition vectorProduct =
crossProduct(face24->centerUnitOuterNormal(), intersection2.centerUnitOuterNormal());
1406 if((vectorProduct * outerNormaln12) > 0.)
1418 globalPos4 = face24->outside().geometry().center();
1419 eIdxGlobal4 = problem().variables().index(face24->outside());
1420 GlobalPosition outerNormaln24 = face24->centerUnitOuterNormal();
1422 DimMatrix K4(problem().spatialParams().intrinsicPermeability(face24->outside()));
1425 globalPos6 = face26->outside().geometry().center();
1426 eIdxGlobal6 = problem().variables().index(face26->outside());
1427 GlobalPosition outerNormaln26 = face26->centerUnitOuterNormal();
1429 DimMatrix K6(problem().spatialParams().intrinsicPermeability(face26->outside()));
1432 int localFace12 = intersection.indexInOutside();
1433 int localFace24 = face24->indexInInside();
1434 int localFace26 = face26->indexInInside();
1436 const auto referenceElement = ReferenceElementContainer::general(neighbor.type());
1441 for(
int nectarine=0; nectarine < referenceElement.size(localFace12, 1, dim-1); nectarine++)
1444 int localEdgeOn12 = referenceElement.subEntity(localFace12, 1, nectarine, dim-1);
1446 for(
int plum = 0; plum < referenceElement.size(localFace26, 1,dim-1); plum++)
1449 if(referenceElement.subEntity(localFace12, 1, nectarine, dim-1)
1450 == referenceElement.subEntity(localFace26, 1, plum, dim-1))
1452 edge1226 = localEdgeOn12;
1457 GlobalPosition edgeCoord1226 =
1458 neighbor.geometry().global(referenceElement.position(edge1226, dim-1));
1463 for(
int nectarine=0; nectarine < referenceElement.size(localFace12, 1, dim-1); nectarine++)
1466 int localEdgeOn12 = referenceElement.subEntity(localFace12, 1, nectarine, dim-1);
1468 for(
int plum = 0; plum < referenceElement.size(localFace24, 1, dim-1); plum++)
1470 int localEdge24 = referenceElement.subEntity(localFace24, 1, plum, dim-1);
1471 if(localEdgeOn12 == localEdge24)
1473 edge1224 = localEdgeOn12;
1478 GlobalPosition edgeCoord1224 =
1479 neighbor.geometry().global(referenceElement.position(edge1224, dim-1));
1484 for(
int nectarine=0; nectarine < referenceElement.size(localFace24, 1, dim-1); nectarine++)
1487 int localEdgeOn24 = referenceElement.subEntity(localFace24, 1, nectarine, dim-1);
1489 for(
int plum = 0; plum < referenceElement.size(localFace26, 1, dim-1); plum++)
1491 int localEdge26 = referenceElement.subEntity(localFace26, 1, plum, dim-1);
1492 if(localEdgeOn24 == localEdge26)
1494 edge2426 = localEdgeOn24;
1499 GlobalPosition edgeCoord2426 =
1500 neighbor.geometry().global(referenceElement.position(edge2426, dim-1));
1504 GlobalPosition globalPosFace24 = face24->geometry().center();
1505 GlobalPosition globalPosFace26 = face26->geometry().center();
1509 Scalar subFaceArea12 =
crossProduct(edgeCoord1226-globalPosFace12, edgeCoord1224-globalPosFace12).two_norm();
1512 Scalar subFaceArea24 =
crossProduct(edgeCoord1224-globalPosFace24, edgeCoord2426-globalPosFace24).two_norm();
1515 Scalar subFaceArea26 =
crossProduct(edgeCoord1226-globalPosFace26, edgeCoord2426-globalPosFace26).two_norm();
1518 GlobalPosition nu11C2 =
crossProduct(edgeCoord1226-globalPos1, globalPosFace12-globalPos1);
1519 GlobalPosition nu12C2 =
crossProduct(edgeCoord1224-globalPos1, edgeCoord1226-globalPos1);
1520 GlobalPosition nu13C2 =
crossProduct(globalPosFace12-globalPos1, edgeCoord1224-globalPos1);
1522 GlobalPosition nu21C2 =
crossProduct(globalPosFace26-globalPos2, globalPosFace24-globalPos2);
1523 GlobalPosition nu22C2 =
crossProduct(globalPosFace12-globalPos2, globalPosFace26-globalPos2);
1524 GlobalPosition nu23C2 =
crossProduct(globalPosFace24-globalPos2, globalPosFace12-globalPos2);
1526 GlobalPosition nu41C2 =
crossProduct(edgeCoord2426-globalPos4, edgeCoord1224-globalPos4);
1527 GlobalPosition nu42C2 =
crossProduct(globalPosFace24-globalPos4, edgeCoord2426-globalPos4);
1528 GlobalPosition nu43C2 =
crossProduct(edgeCoord1224-globalPos4, globalPosFace24-globalPos4);
1530 GlobalPosition nu61C2 =
crossProduct(globalPosFace26-globalPos6, edgeCoord1226-globalPos6);
1531 GlobalPosition nu62C2 =
crossProduct(edgeCoord2426-globalPos6, globalPosFace26-globalPos6);
1532 GlobalPosition nu63C2 =
crossProduct(edgeCoord1226-globalPos6, edgeCoord2426-globalPos6);
1535 Scalar T1C2 = (globalPosFace12-globalPos1) *
crossProduct(edgeCoord1224-globalPos1, edgeCoord1226-globalPos1);
1536 Scalar T2C2 = (globalPosFace12-globalPos2) *
crossProduct(globalPosFace26-globalPos2, globalPosFace24-globalPos2);
1537 Scalar T4C2 = (globalPosFace24-globalPos4) *
crossProduct(edgeCoord2426-globalPos4, edgeCoord1224-globalPos4);
1538 Scalar T6C2 = (globalPosFace26-globalPos6) *
crossProduct(edgeCoord1226-globalPos6, edgeCoord2426-globalPos6);
1541 GlobalPosition K1nu11C2(0);
1542 K1.mv(nu11C2, K1nu11C2);
1543 GlobalPosition K1nu12C2(0);
1544 K1.mv(nu12C2, K1nu12C2);
1545 GlobalPosition K1nu13C2(0);
1546 K1.mv(nu13C2, K1nu13C2);
1548 GlobalPosition K2nu21C2(0);
1549 K2.mv(nu21C2, K2nu21C2);
1550 GlobalPosition K2nu22C2(0);
1551 K2.mv(nu22C2, K2nu22C2);
1552 GlobalPosition K2nu23C2(0);
1553 K2.mv(nu23C2, K2nu23C2);
1555 GlobalPosition K4nu41C2(0);
1556 K4.mv(nu41C2, K4nu41C2);
1557 GlobalPosition K4nu42C2(0);
1558 K4.mv(nu42C2, K4nu42C2);
1559 GlobalPosition K4nu43C2(0);
1560 K4.mv(nu43C2, K4nu43C2);
1562 GlobalPosition K6nu61C2(0);
1563 K6.mv(nu61C2, K6nu61C2);
1564 GlobalPosition K6nu62C2(0);
1565 K6.mv(nu62C2, K6nu62C2);
1566 GlobalPosition K6nu63C2(0);
1567 K6.mv(nu63C2, K6nu63C2);
1571 Scalar omega111C2 = (outerNormaln12 * K1nu11C2) * subFaceArea12/T1C2;
1572 Scalar omega112C2 = (outerNormaln12 * K1nu12C2) * subFaceArea12/T1C2;
1573 Scalar omega113C2 = (outerNormaln12 * K1nu13C2) * subFaceArea12/T1C2;
1575 Scalar omega121C2 = (outerNormaln12 * K2nu21C2) * subFaceArea12/T2C2;
1576 Scalar omega122C2 = (outerNormaln12 * K2nu22C2) * subFaceArea12/T2C2;
1577 Scalar omega123C2 = (outerNormaln12 * K2nu23C2) * subFaceArea12/T2C2;
1579 Scalar omega221C2 = (outerNormaln24 * K2nu21C2) * subFaceArea24/T2C2;
1580 Scalar omega222C2 = (outerNormaln24 * K2nu22C2) * subFaceArea24/T2C2;
1581 Scalar omega223C2 = (outerNormaln24 * K2nu23C2) * subFaceArea24/T2C2;
1583 Scalar omega241C2 = (outerNormaln24 * K4nu41C2) * subFaceArea24/T4C2;
1584 Scalar omega242C2 = (outerNormaln24 * K4nu42C2) * subFaceArea24/T4C2;
1585 Scalar omega243C2 = (outerNormaln24 * K4nu43C2) * subFaceArea24/T4C2;
1587 Scalar omega321C2 = (outerNormaln26 * K2nu21C2) * subFaceArea26/T2C2;
1588 Scalar omega322C2 = (outerNormaln26 * K2nu22C2) * subFaceArea26/T2C2;
1589 Scalar omega323C2 = (outerNormaln26 * K2nu23C2) * subFaceArea26/T2C2;
1591 Scalar omega361C2 = (outerNormaln26 * K6nu61C2) * subFaceArea26/T6C2;
1592 Scalar omega362C2 = (outerNormaln26 * K6nu62C2) * subFaceArea26/T6C2;
1593 Scalar omega363C2 = (outerNormaln26 * K6nu63C2) * subFaceArea26/T6C2;
1595 Scalar r211C2 = (nu21C2 * (edgeCoord1224-globalPos2))/T2C2;
1596 Scalar r212C2 = (nu21C2 * (edgeCoord1226-globalPos2))/T2C2;
1597 Scalar r213C2 = (nu21C2 * (edgeCoord2426-globalPos2))/T2C2;
1599 Scalar r221C2 = (nu22C2 * (edgeCoord1224-globalPos2))/T2C2;
1600 Scalar r222C2 = (nu22C2 * (edgeCoord1226-globalPos2))/T2C2;
1601 Scalar r223C2 = (nu22C2 * (edgeCoord2426-globalPos2))/T2C2;
1603 Scalar r231C2 = (nu23C2 * (edgeCoord1224-globalPos2))/T2C2;
1604 Scalar r232C2 = (nu23C2 * (edgeCoord1226-globalPos2))/T2C2;
1605 Scalar r233C2 = (nu23C2 * (edgeCoord2426-globalPos2))/T2C2;
1610 DimMatrix C(0), A(0);
1611 Dune::FieldMatrix<Scalar,dim,dim+1> D(0), B(0);
1614 C[0][0] = -omega121C2;
1615 C[0][1] = -omega122C2;
1616 C[0][2] = -omega123C2;
1617 C[1][0] = -omega221C2;
1618 C[1][1] = -omega222C2;
1619 C[1][2] = -omega223C2;
1620 C[2][0] = -omega321C2;
1621 C[2][1] = -omega322C2;
1622 C[2][2] = -omega323C2;
1624 D[0][1] = omega121C2 + omega122C2 + omega123C2;
1625 D[1][1] = omega221C2 + omega222C2 + omega223C2;
1626 D[2][1] = omega321C2 + omega322C2 + omega323C2;
1628 A[0][0] = omega121C2 - omega112C2 - omega111C2*r211C2 - omega113C2*r212C2;
1629 A[0][1] = omega122C2 - omega111C2*r221C2 - omega113C2*r222C2;
1630 A[0][2] = omega123C2 - omega111C2*r231C2 - omega113C2*r232C2;
1631 A[1][0] = omega221C2 - omega242C2*r211C2 - omega243C2*r213C2;
1632 A[1][1] = omega222C2 - omega241C2 - omega242C2*r221C2 - omega243C2*r223C2;
1633 A[1][2] = omega223C2 - omega242C2*r231C2 - omega243C2*r233C2;
1634 A[2][0] = omega321C2 - omega361C2*r213C2 - omega362C2*r212C2;
1635 A[2][1] = omega322C2 - omega361C2*r223C2 - omega362C2*r222C2;
1636 A[2][2] = omega323C2 - omega363C2 - omega361C2*r233C2 - omega362C2*r232C2;
1638 B[0][0] = -omega111C2 - omega112C2 - omega113C2;
1639 B[0][1] = omega121C2 + omega122C2 + omega123C2 + omega111C2*(1.0 - r211C2 - r221C2 -r231C2)
1640 + omega113C2*(1.0 - r212C2 - r222C2 - r232C2);
1641 B[1][1] = omega221C2 + omega222C2 + omega223C2 + omega242C2*(1.0 - r211C2 - r221C2 - r231C2)
1642 + omega243C2*(1.0 - r213C2 - r223C2 - r233C2);
1643 B[1][2] = -omega241C2 - omega242C2 - omega243C2;
1644 B[2][1] = omega321C2 + omega322C2 + omega323C2 + omega361C2*(1.0 - r213C2 - r223C2 - r233C2)
1645 + omega362C2*(1.0 - r212C2 -r222C2 -r232C2);
1646 B[2][3] = -omega361C2 - omega362C2 -omega363C2;
1655 D += B.leftmultiply(C.rightmultiply(A));
1659 if(maxInteractionVolumes ==1)
1661 T *= intersection.geometry().volume()/subFaceArea12 ;
1664 problem().variables().storeMpfaData3D(intersection, T, globalPos4, eIdxGlobal4, globalPos6, eIdxGlobal6);
1669 int countInteractionRegions = 1;
1671 TransmissivityMatrix additionalT(0.);
1673 auto outerCorner = intersection.inside().template subEntity<dim>(0);
1675 auto additional2 = intersection.inside();
1676 auto additional3 = intersection.inside();
1681 int localIdxLarge = searchCommonVertex_(intersection, outerCorner);
1685 if (problem().gridView().comm().size() > 1)
1686 if(outerCorner.partitionType() != Dune::InteriorEntity)
1691 int vIdxGlobal = problem().variables().index(outerCorner);
1692 InteractionVolume& interactionVolume
1693 = interactionVolumesContainer_->interactionVolume(vIdxGlobal);
1696 if(interactionVolume.isBoundaryInteractionVolume())
1700 int subVolumeFaceIdx = -1;
1701 bool properFluxDirection =
true;
1705 int hangingNodeType = interactionVolume.getHangingNodeType();
1707 if(hangingNodeType == InteractionVolume::noHangingNode)
1708 subVolumeFaceIdx = interactionVolumesContainer_->getMpfaCase8cells(isIt, localIdxLarge, interactionVolume, properFluxDirection);
1709 else if(hangingNodeType == InteractionVolume::sixSmallCells)
1710 subVolumeFaceIdx = interactionVolumesContainer_->getMpfaCase6cells(isIt, interactionVolume, properFluxDirection);
1712 Dune::dgrave <<
"HangingType " << hangingNodeType <<
" not implemented " << std::endl;
1714 caseL = this->transmissibilityAdapter_(isIt, interactionVolume, subVolumeFaceIdx,
1715 properFluxDirection, additional2, additional3, additionalT);
1721 problem().variables().storeMpfaData3D(intersection, additionalT,
1722 additional2.geometry().center(), problem().variables().index(additional2),
1723 additional3.geometry().center(), problem().variables().index(additional3),
1725 countInteractionRegions++;
1729 if(maxInteractionVolumes>2)
1732 std::vector<int> diagonal;
1733 for(
int verticeSmall = 0; verticeSmall < intersection.outside().subEntities(dim); ++verticeSmall)
1735 auto vSmall = intersection.outside().template subEntity<dim>(verticeSmall);
1739 if (problem().gridView().comm().size() > 1)
1740 if(vSmall.partitionType() != Dune::InteriorEntity)
1745 GlobalPosition vertexOnElement
1746 = referenceElement.position(verticeSmall, dim);
1748 for (
int indexOnFace = 0; indexOnFace < 4; indexOnFace++)
1751 GlobalPosition vertexOnInterface
1752 = intersection.geometryInOutside().corner(indexOnFace);
1754 if(vSmall != outerCorner
1755 && ((vertexOnInterface - vertexOnElement).two_norm()<1e-5))
1757 int vIdxGlobal2 = problem().variables().index(vSmall);
1759 InteractionVolume& interactionVolume2
1760 = interactionVolumesContainer_->interactionVolume(vIdxGlobal2);
1761 if(interactionVolume2.isBoundaryInteractionVolume())
1764 int hangingNodeType = interactionVolume2.getHangingNodeType();
1766 properFluxDirection =
true;
1768 if(hangingNodeType != InteractionVolume::fourSmallCellsFace)
1770 diagonal.push_back(problem().variables().index(vSmall));
1772 if(hangingNodeType == InteractionVolume::noHangingNode)
1775 Dune::dgrave <<
" args, noHangingNode on additional interaction region";
1778 else if(hangingNodeType == InteractionVolume::sixSmallCells)
1779 subVolumeFaceIdx = interactionVolumesContainer_->getMpfaCase6cells(isIt,
1780 interactionVolume2, properFluxDirection);
1782 subVolumeFaceIdx = interactionVolumesContainer_->getMpfaCase2or4cells(isIt,
1783 interactionVolume2, properFluxDirection);
1786 caseL = this->transmissibilityAdapter_(isIt, interactionVolume2, subVolumeFaceIdx,
1787 properFluxDirection, additional2, additional3, additionalT);
1793 problem().variables().storeMpfaData3D(intersection, additionalT,
1794 additional2.geometry().center(), problem().variables().index(additional2),
1795 additional3.geometry().center(), problem().variables().index(additional3),
1796 countInteractionRegions);
1797 countInteractionRegions++;
1807 problem().variables().storeMpfaData3D(intersection, T, globalPos4, eIdxGlobal4, globalPos6, eIdxGlobal6);
1810 Scalar weight = intersection.geometry().volume()/subFaceArea12;
1811 weight /=
static_cast<Scalar
>(countInteractionRegions);
1814 problem().variables().performTransmissitivityWeighting(intersection, weight);
1816 return countInteractionRegions;
1839template<
class TypeTag>
1841 InteractionVolume& interactionVolume,
1842 const int& subVolumeFaceIdx,
1843 bool properFluxDirection,
1844 Element& additional2,
1845 Element& additional3,
1846 TransmissivityMatrix& additionalT)
1849 if(interactionVolume.isBoundaryInteractionVolume())
1853 int hangingNodeType = interactionVolume.getHangingNodeType();
1856 Dune::FieldMatrix<Scalar, dim, 2 * dim - dim + 1> T(0);
1858 Dune::FieldVector<Scalar, dim> unity(1.);
1859 std::vector<Dune::FieldVector<Scalar, dim> > lambda
1860 = {unity, unity, unity, unity, unity, unity, unity, unity};
1861 Dune::FieldVector<bool, 4> useCases(
false);
1864 switch(subVolumeFaceIdx)
1867 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
1868 lambda, 0, 1, 2, 3, 4, 5);
1876 additional2 = interactionVolume.getSubVolumeElement(2);
1877 additional3 = interactionVolume.getSubVolumeElement(4);
1880 additional2 = interactionVolume.getSubVolumeElement(3);
1881 additional3 = interactionVolume.getSubVolumeElement(5);
1884 additional2 = interactionVolume.getSubVolumeElement(3);
1885 additional3 = interactionVolume.getSubVolumeElement(4);
1888 additional2 = interactionVolume.getSubVolumeElement(2);
1889 additional3 = interactionVolume.getSubVolumeElement(5);
1896 if (hangingNodeType == InteractionVolume::twoSmallCells
1897 || hangingNodeType == InteractionVolume::fourSmallCellsDiag )
1900 useCases[1] =
false;
1901 useCases[2] =
false;
1902 if(hangingNodeType != InteractionVolume::twoSmallCells)
1904 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
1905 lambda, 1, 3, 0, 2, 5, 7, useCases);
1908 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
1909 lambda, 1, 3, 0, 2, 5, 7);
1918 additional2 = interactionVolume.getSubVolumeElement(0);
1919 additional3 = interactionVolume.getSubVolumeElement(5);
1923 additional2 = interactionVolume.getSubVolumeElement(2);
1924 additional3 = interactionVolume.getSubVolumeElement(7);
1928 additional2 = interactionVolume.getSubVolumeElement(2);
1929 additional3 = interactionVolume.getSubVolumeElement(5);
1933 additional2 = interactionVolume.getSubVolumeElement(0);
1934 additional3 = interactionVolume.getSubVolumeElement(7);
1942 assert (hangingNodeType != InteractionVolume::twoSmallCells
1943 && hangingNodeType != InteractionVolume::fourSmallCellsDiag);
1945 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
1946 lambda, 3, 2, 1, 0, 7, 6);
1955 additional2 = interactionVolume.getSubVolumeElement(1);
1956 additional3 = interactionVolume.getSubVolumeElement(7);
1960 additional2 = interactionVolume.getSubVolumeElement(0);
1961 additional3 = interactionVolume.getSubVolumeElement(6);
1965 additional2 = interactionVolume.getSubVolumeElement(0);
1966 additional3 = interactionVolume.getSubVolumeElement(7);
1970 additional2 = interactionVolume.getSubVolumeElement(1);
1971 additional3 = interactionVolume.getSubVolumeElement(6);
1978 if (hangingNodeType == InteractionVolume::twoSmallCells
1979 || hangingNodeType == InteractionVolume::fourSmallCellsDiag)
1981 useCases[0] =
false;
1983 if(hangingNodeType != InteractionVolume::twoSmallCells)
1985 useCases[3] =
false;
1986 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T,
1987 interactionVolume, lambda, 2, 0, 3, 1, 6, 4, useCases);
1990 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
1991 lambda, 2, 0, 3, 1, 6, 4);
2000 additional2 = interactionVolume.getSubVolumeElement(3);
2001 additional3 = interactionVolume.getSubVolumeElement(6);
2005 additional2 = interactionVolume.getSubVolumeElement(1);
2006 additional3 = interactionVolume.getSubVolumeElement(4);
2010 additional2 = interactionVolume.getSubVolumeElement(1);
2011 additional3 = interactionVolume.getSubVolumeElement(6);
2015 additional2 = interactionVolume.getSubVolumeElement(3);
2016 additional3 = interactionVolume.getSubVolumeElement(4);
2023 if (hangingNodeType == InteractionVolume::fourSmallCellsEdge)
2025 assert(problem().variables().index(interactionVolume.getSubVolumeElement(4))
2026 != problem().variables().index(interactionVolume.getSubVolumeElement(5)));
2027 Dune::dgrave <<
" SubVolumeFace4 in hanging node type 3 should be modelled by"
2028 <<
" Tpfa!!" <<std::endl;
2032 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2033 lambda, 5, 4, 7, 6, 1, 0);
2041 additional2 = interactionVolume.getSubVolumeElement(7);
2042 additional3 = interactionVolume.getSubVolumeElement(1);
2045 additional2 = interactionVolume.getSubVolumeElement(6);
2046 additional3 = interactionVolume.getSubVolumeElement(0);
2049 additional2 = interactionVolume.getSubVolumeElement(6);
2050 additional3 = interactionVolume.getSubVolumeElement(1);
2053 additional2 = interactionVolume.getSubVolumeElement(7);
2054 additional3 = interactionVolume.getSubVolumeElement(0);
2061 if (hangingNodeType == InteractionVolume::fourSmallCellsEdge)
2063 assert (problem().variables().index(interactionVolume.getSubVolumeElement(4))
2064 != problem().variables().index(interactionVolume.getSubVolumeElement(6)));
2065 Dune::dgrave <<
" SubVolumeFace5 in hanging node type 3 should be modelled by"
2066 <<
" Tpfa!!" <<std::endl;
2069 else if (hangingNodeType == InteractionVolume::sixSmallCells)
2071 useCases[0] =
false;
2074 useCases[3] =
false;
2076 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2077 lambda, 7, 5, 6, 4, 3, 1, useCases);
2079 else if (hangingNodeType == InteractionVolume::fourSmallCellsDiag)
2082 useCases[1] =
false;
2083 useCases[2] =
false;
2085 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2086 lambda, 7, 5, 6, 4, 3, 1, useCases);
2089 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2090 lambda, 7, 5, 6, 4, 3, 1);
2099 additional2 = interactionVolume.getSubVolumeElement(6);
2100 additional3 = interactionVolume.getSubVolumeElement(3);
2104 additional2 = interactionVolume.getSubVolumeElement(4);
2105 additional3 = interactionVolume.getSubVolumeElement(1);
2109 additional2 = interactionVolume.getSubVolumeElement(4);
2110 additional3 = interactionVolume.getSubVolumeElement(3);
2114 additional2 = interactionVolume.getSubVolumeElement(6);
2115 additional3 = interactionVolume.getSubVolumeElement(1);
2122 if (hangingNodeType == InteractionVolume::fourSmallCellsEdge)
2124 assert (problem().variables().index(interactionVolume.getSubVolumeElement(4))
2125 != problem().variables().index(interactionVolume.getSubVolumeElement(5)));
2126 Dune::dgrave <<
" SubVolumeFace6 in hanging node type 3 should be modelled by"
2127 <<
" Tpfa!!" <<std::endl;
2131 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2132 lambda, 6, 7, 4, 5, 2, 3);
2141 additional2 = interactionVolume.getSubVolumeElement(4);
2142 additional3 = interactionVolume.getSubVolumeElement(2);
2146 additional2 = interactionVolume.getSubVolumeElement(5);
2147 additional3 = interactionVolume.getSubVolumeElement(3);
2151 additional2 = interactionVolume.getSubVolumeElement(5);
2152 additional3 = interactionVolume.getSubVolumeElement(2);
2156 additional2 = interactionVolume.getSubVolumeElement(4);
2157 additional3 = interactionVolume.getSubVolumeElement(3);
2165 if (hangingNodeType == InteractionVolume::fourSmallCellsEdge)
2167 assert (problem().variables().index(interactionVolume.getSubVolumeElement(4))
2168 != problem().variables().index(interactionVolume.getSubVolumeElement(6)));
2169 Dune::dgrave <<
" SubVolumeFace5 in hanging node type 3 should be modelled by"
2170 <<
" Tpfa!!" <<std::endl;
2173 else if (hangingNodeType == InteractionVolume::sixSmallCells)
2176 useCases[1] =
false;
2177 useCases[2] =
false;
2180 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2181 lambda, 4, 6, 5, 7, 0, 2, useCases);
2183 else if (hangingNodeType == InteractionVolume::fourSmallCellsDiag)
2185 useCases[0] =
false;
2188 useCases[3] =
false;
2189 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2190 lambda, 4, 6, 5, 7, 0, 2, useCases);
2193 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2194 lambda, 4, 6, 5, 7, 0, 2);
2203 additional2 = interactionVolume.getSubVolumeElement(5);
2204 additional3 = interactionVolume.getSubVolumeElement(0);
2208 additional2 = interactionVolume.getSubVolumeElement(7);
2209 additional3 = interactionVolume.getSubVolumeElement(2);
2213 additional2 = interactionVolume.getSubVolumeElement(7);
2214 additional3 = interactionVolume.getSubVolumeElement(0);
2218 additional2 = interactionVolume.getSubVolumeElement(5);
2219 additional3 = interactionVolume.getSubVolumeElement(2);
2227 if(hangingNodeType == InteractionVolume::noHangingNode
2228 || hangingNodeType == InteractionVolume::sixSmallCells)
2230 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2231 lambda, 4, 0, 6, 2, 5, 1);
2233 else if (hangingNodeType == InteractionVolume::twoSmallCells
2234 || hangingNodeType == InteractionVolume::fourSmallCellsFace)
2236 caseL = mpfal3DTransmissibilityCalculator_.transmissibilityCaseTwo(T, interactionVolume,
2237 lambda, 4, 0, 2, 1);
2239 else if (hangingNodeType == InteractionVolume::fourSmallCellsDiag
2240 || (hangingNodeType == InteractionVolume::fourSmallCellsEdge
2241 && (problem().variables().index(interactionVolume.getSubVolumeElement(4))
2242 != problem().variables().index(interactionVolume.getSubVolumeElement(6)))) )
2244 useCases[0] =
false;
2246 useCases[2] =
false;
2249 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2250 lambda, 4, 0, 6, 2, 5, 1, useCases);
2252 else if (hangingNodeType == InteractionVolume::fourSmallCellsEdge)
2254 useCases[0] =
false;
2257 useCases[3] =
false;
2259 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2260 lambda, 4, 0, 6, 2, 5, 1, useCases);
2270 additional2 = interactionVolume.getSubVolumeElement(6);
2271 additional3 = interactionVolume.getSubVolumeElement(5);
2275 additional2 = interactionVolume.getSubVolumeElement(2);
2276 additional3 = interactionVolume.getSubVolumeElement(1);
2280 additional2 = interactionVolume.getSubVolumeElement(2);
2281 additional3 = interactionVolume.getSubVolumeElement(5);
2285 additional2 = interactionVolume.getSubVolumeElement(6);
2286 additional3 = interactionVolume.getSubVolumeElement(1);
2294 if(hangingNodeType == InteractionVolume::noHangingNode
2295 || hangingNodeType == InteractionVolume::sixSmallCells)
2297 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2298 lambda, 1, 5, 3, 7, 0, 4);
2300 else if (hangingNodeType == InteractionVolume::twoSmallCells || hangingNodeType == InteractionVolume::fourSmallCellsFace)
2302 caseL = mpfal3DTransmissibilityCalculator_.transmissibilityCaseOne(T, interactionVolume,
2303 lambda, 1, 5, 3, 0);
2305 else if (hangingNodeType == InteractionVolume::fourSmallCellsDiag
2306 || (hangingNodeType == InteractionVolume::fourSmallCellsEdge
2307 &&(problem().variables().index(interactionVolume.getSubVolumeElement(4))
2308 != problem().variables().index(interactionVolume.getSubVolumeElement(6))) ))
2311 useCases[1] =
false;
2313 useCases[3] =
false;
2315 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2316 lambda, 1, 5, 3, 7, 0, 4, useCases);
2318 else if (hangingNodeType == InteractionVolume::fourSmallCellsEdge
2319 &&(problem().variables().index(interactionVolume.getSubVolumeElement(4))
2320 != problem().variables().index(interactionVolume.getSubVolumeElement(5))) )
2323 useCases[1] =
false;
2324 useCases[2] =
false;
2327 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2328 lambda, 1, 5, 3, 7, 0, 4, useCases);
2331 Dune::dgrave <<
" Missing case for subVolFaceIdx 9!!" <<std::endl;
2340 additional2 = interactionVolume.getSubVolumeElement(3);
2341 additional3 = interactionVolume.getSubVolumeElement(0);
2345 additional2 = interactionVolume.getSubVolumeElement(7);
2346 additional3 = interactionVolume.getSubVolumeElement(4);
2350 additional2 = interactionVolume.getSubVolumeElement(7);
2351 additional3 = interactionVolume.getSubVolumeElement(0);
2355 additional2 = interactionVolume.getSubVolumeElement(3);
2356 additional3 = interactionVolume.getSubVolumeElement(4);
2364 if (hangingNodeType == InteractionVolume::fourSmallCellsFace)
2365 caseL = mpfal3DTransmissibilityCalculator_.transmissibilityCaseTwo(T, interactionVolume,
2366 lambda, 7, 3, 1, 2);
2367 else if ((hangingNodeType == InteractionVolume::fourSmallCellsEdge
2368 &&(problem().variables().index(interactionVolume.getSubVolumeElement(4))
2369 != problem().variables().index(interactionVolume.getSubVolumeElement(6))) )
2370 || hangingNodeType == InteractionVolume::sixSmallCells)
2372 useCases[0] =
false;
2374 useCases[2] =
false;
2377 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2378 lambda, 7, 3, 5, 1, 6, 2, useCases);
2380 else if (hangingNodeType == InteractionVolume::fourSmallCellsEdge)
2382 useCases[0] =
false;
2385 useCases[3] =
false;
2387 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2388 lambda, 7, 3, 5, 1, 6, 2, useCases);
2390 else if (hangingNodeType == InteractionVolume::fourSmallCellsDiag)
2393 useCases[1] =
false;
2395 useCases[3] =
false;
2397 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2398 lambda, 7, 3, 5, 1, 6, 2, useCases);
2401 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2402 lambda, 7, 3, 5, 1, 6, 2);
2411 additional2 = interactionVolume.getSubVolumeElement(5);
2412 additional3 = interactionVolume.getSubVolumeElement(6);
2416 additional2 = interactionVolume.getSubVolumeElement(1);
2417 additional3 = interactionVolume.getSubVolumeElement(2);
2421 additional2 = interactionVolume.getSubVolumeElement(1);
2422 additional3 = interactionVolume.getSubVolumeElement(6);
2426 additional2 = interactionVolume.getSubVolumeElement(5);
2427 additional3 = interactionVolume.getSubVolumeElement(2);
2435 if(!interactionVolume.isHangingNodeVolume())
2436 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2437 lambda, 2, 6, 0, 4, 3, 7);
2438 else if (hangingNodeType == InteractionVolume::fourSmallCellsFace)
2439 caseL = mpfal3DTransmissibilityCalculator_.transmissibilityCaseOne(T, interactionVolume,
2440 lambda, 2, 6, 0, 3);
2441 else if ((hangingNodeType == InteractionVolume::fourSmallCellsEdge
2442 && (problem().variables().index(interactionVolume.getSubVolumeElement(4))
2443 != problem().variables().index(interactionVolume.getSubVolumeElement(6))))
2444 || hangingNodeType == InteractionVolume::sixSmallCells)
2447 useCases[1] =
false;
2449 useCases[3] =
false;
2451 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2452 lambda, 2, 6, 0, 4, 3, 7, useCases);
2454 else if (hangingNodeType == InteractionVolume::fourSmallCellsEdge
2455 && (problem().variables().index(interactionVolume.getSubVolumeElement(4))
2456 != problem().variables().index(interactionVolume.getSubVolumeElement(5))) )
2459 useCases[1] =
false;
2460 useCases[2] =
false;
2463 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2464 lambda, 2, 6, 0, 4, 3, 7, useCases);
2466 else if (hangingNodeType == InteractionVolume::fourSmallCellsDiag)
2468 useCases[0] =
false;
2470 useCases[2] =
false;
2473 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2474 lambda, 2, 6, 0, 4, 3, 7, useCases);
2484 additional2 = interactionVolume.getSubVolumeElement(0);
2485 additional3 = interactionVolume.getSubVolumeElement(3);
2489 additional2 = interactionVolume.getSubVolumeElement(4);
2490 additional3 = interactionVolume.getSubVolumeElement(7);
2494 additional2 = interactionVolume.getSubVolumeElement(4);
2495 additional3 = interactionVolume.getSubVolumeElement(3);
2499 additional2 = interactionVolume.getSubVolumeElement(0);
2500 additional3 = interactionVolume.getSubVolumeElement(7);
2507 if(!properFluxDirection)
2514 swap(additionalT[0], additionalT[1]);
#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
Define some often used mathematical functions.
Simplifies writing multi-file VTK datasets.
Provides methods for transmissibility calculation in 3-d.
Defines the properties required for the adaptive sequential 2p2c models.
Interaction volume container for compositional adaptive 3-d (using MPFA L-method).
Finite volume 2p2c pressure model with multi-physics.
constexpr Scalar harmonicMean(Scalar x, Scalar y, Scalar wx=1.0, Scalar wy=1.0) noexcept
Calculate the (weighted) harmonic mean of two scalar values.
Definition: math.hh:68
void harmonicMeanMatrix(Dune::FieldMatrix< Scalar, m, n > &K, const Dune::FieldMatrix< Scalar, m, n > &Ki, const Dune::FieldMatrix< Scalar, m, n > &Kj)
Calculate the harmonic mean of a fixed-size matrix.
Definition: math.hh:108
Dune::FieldVector< Scalar, 3 > crossProduct(const Dune::FieldVector< Scalar, 3 > &vec1, const Dune::FieldVector< Scalar, 3 > &vec2)
Cross product of two vectors in three-dimensional Euclidean space.
Definition: math.hh:631
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
Property tag PressureRHSVector
Type of the right hand side vector given to the linear solver.
Definition: sequential/pressureproperties.hh:60
Property tag VisitFacesOnlyOnce
Type of solution vector or pressure system.
Definition: sequential/pressureproperties.hh:62
Property tag PressureSolutionVector
Definition: sequential/pressureproperties.hh:61
SET_TYPE_PROP(FVPressureOneP, Velocity, FVVelocity1P< TypeTag >)
Set velocity reconstruction implementation standard cell centered finite volume schemes as default.
Property tag NumComponents
Number of components in the system.
Definition: porousmediumflow/sequential/properties.hh:70
Property tag MPFAInteractionVolumeContainer
Type of the data container for one interaction volume.
Definition: porousmediumflow/sequential/cellcentered/mpfa/properties.hh:97
Property tag NumPhases
Number of phases in the system.
Definition: porousmediumflow/sequential/properties.hh:69
Property tag PressureCoefficientMatrix
Gives maximum number of intersections of an element and neighboring elements.
Definition: porousmediumflow/sequential/properties.hh:74
Property tag MPFAInteractionVolume
Type of the data container for one interaction volume.
Definition: porousmediumflow/sequential/cellcentered/mpfa/properties.hh:96
Property tag PressureModel
The type of the discretization of a pressure model.
Definition: porousmediumflow/sequential/properties.hh:65
std::string permeability() noexcept
I/O name of permeability.
Definition: name.hh:143
std::string pressure(int phaseIdx) noexcept
I/O name of pressure for multiphase systems.
Definition: name.hh:34
A data handle class to exchange entries of a vector.
Definition: vectorexchange.hh:40
Provides methods for transmissibility calculation in 3-d.
Definition: 3dtransmissibilitycalculator.hh:51
The finite volume model for the solution of the compositional pressure equation.
Definition: fv3dpressureadaptive.hh:78
void update()
Definition: fv3dpressureadaptive.hh:161
void adaptPressure()
Adapt primary variables vector after adapting the grid.
Definition: fv3dpressureadaptive.hh:212
bool enableMPFA
Enables mpfa on hanging nodes (on by default)
Definition: fv3dpressureadaptive.hh:301
int transmissibilityAdapter_(const IntersectionIterator &isIt, InteractionVolume &interactionVolume, const int &subVolumeFaceIdx, bool properFluxDirection, Element &additional2, Element &additional3, TransmissivityMatrix &additionalT)
Adapter to use the general implementation of the mpfa-l for the compositional models.
Definition: fv3dpressureadaptive.hh:1840
void initializeMatrix()
initializes the matrix to store the system of equations
Definition: fv3dpressureadaptive.hh:312
void initializeMatrixRowSize()
Initialize the row sizes of the sparse global matrix.
Definition: fv3dpressureadaptive.hh:328
FvMpfaL3dTransmissibilityCalculator< TypeTag > mpfal3DTransmissibilityCalculator_
The common implementation to calculate the Transmissibility with the mpfa-L-method.
Definition: fv3dpressureadaptive.hh:307
bool enableVolumeIntegral_
Calculates the volume integral (on by default)
Definition: fv3dpressureadaptive.hh:300
void initializeMatrixIndices()
Determine position of matrix entries.
Definition: fv3dpressureadaptive.hh:577
int computeTransmissibilities(const IntersectionIterator &, TransmissivityMatrix &, GlobalPosition &, int &, GlobalPosition &, int &)
Computes the transmissibility coefficients for the MPFA-l method in 3D.
Definition: fv3dpressureadaptive.hh:1347
void getMpfaFlux(const IntersectionIterator &, const CellData &)
Compute flux through an irregular interface using a mpfa method.
Definition: fv3dpressureadaptive.hh:803
void assemble(bool first)
function which assembles the system of equations to be solved
Definition: fv3dpressureadaptive.hh:642
FV3dPressure2P2CAdaptive(Problem &problem)
Constructs a FVPressure2P2C object.
Definition: fv3dpressureadaptive.hh:247
std::map< int, std::vector< int > > irregularCellMap_
Container to store all cell's Indice with a hanging node.
Definition: fv3dpressureadaptive.hh:299
void initialize(bool solveTwice=false)
Definition: fv3dpressureadaptive.hh:181
void get1pMpfaFlux(const IntersectionIterator &, const CellData &)
Compute single-phase flux through an irregular interface using a mpfa method.
Definition: fv3dpressureadaptive.hh:1140
InteractionVolumeContainer * interactionVolumesContainer_
A pointer to the adaptive interaction volumes container.
Definition: fv3dpressureadaptive.hh:305
void updateMaterialLaws(bool fromPostTimestep=false)
Definition: fv3dpressureadaptive.hh:1293
int maxInteractionVolumes
Maximum number of interaction volumes considered (4 by default)
Definition: fv3dpressureadaptive.hh:302
Interaction volume container for compositional adaptive 3-d (using MPFA L-method) Model.
Definition: fvmpfal3dinteractionvolumecontaineradaptive.hh:47
bool enableVolumeIntegral
Enables the volume integral of the pressure equation.
Definition: fvpressure.hh:183
Problem & problem_
Definition: fvpressure.hh:182
void updateMaterialLaws(bool postTimeStep=false)
Updates secondary variables.
Definition: fvpressurecompositional.hh:711
void update()
Compositional pressure solution routine: update estimate for secants, assemble, solve.
Definition: fvpressurecompositional.hh:131
The finite volume model for the solution of the compositional pressure equation.
Definition: fvpressuremultiphysics.hh:70
void updateMaterialLaws(bool postTimeStep=false)
constitutive functions are updated once if new concentrations are calculated and stored in the variab...
Definition: fvpressuremultiphysics.hh:792
static constexpr int pressureType
gives kind of pressure used ( , , )
Definition: fvpressuremultiphysics.hh:233
typename SolutionTypes::ElementMapper ElementMapper
Definition: fvpressuremultiphysics.hh:225
Class including the information of a 3d interaction volume of an adaptive MPFA L-method that does not...
Definition: linteractionvolume3dadaptive.hh:192
The finite volume base class for the solution of a pressure equation.
Definition: sequential/cellcentered/pressure.hh:48
void initialize()
Initialize pressure model.
Definition: sequential/cellcentered/pressure.hh:212
PressureSolution & pressure()
Returns the vector containing the pressure solution.
Definition: sequential/cellcentered/pressure.hh:119
@ rhs
index for the right hand side entry
Definition: sequential/cellcentered/pressure.hh:87
@ matrix
index for the global matrix entry
Definition: sequential/cellcentered/pressure.hh:88
Properties for a MPFA method.