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>
46template<
class TypeTag>
48template<
class TypeTag>
92 using MaterialLaw =
typename SpatialParams::MaterialLaw;
103 dim = GridView::dimension, dimWorld = GridView::dimensionworld,
104 NumPhases = getPropValue<TypeTag, Properties::NumPhases>(), NumComponents = getPropValue<TypeTag, Properties::NumComponents>()
108 pw = Indices::pressureW,
109 pn = Indices::pressureN,
110 pGlobal = Indices::pressureGlobal,
111 Sw = Indices::saturationW,
112 Sn = Indices::saturationN
116 wPhaseIdx = Indices::wPhaseIdx, nPhaseIdx = Indices::nPhaseIdx,
117 wCompIdx = Indices::wPhaseIdx, nCompIdx = Indices::nPhaseIdx,
118 contiWEqIdx = Indices::contiWEqIdx, contiNEqIdx = Indices::contiNEqIdx
126 using Vertex =
typename GridView::Traits::template Codim<dim>::Entity;
127 using Element =
typename GridView::Traits::template Codim<0>::Entity;
128 using ReferenceElementContainer = Dune::ReferenceElements<Scalar, dim>;
130 using Grid =
typename GridView::Grid;
131 using Intersection =
typename GridView::Intersection;
132 using IntersectionIterator =
typename GridView::IntersectionIterator;
135 using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>;
136 using TransmissivityMatrix = Dune::FieldVector<Scalar,dim+1>;
137 using DimMatrix = Dune::FieldMatrix<Scalar, dim, dim>;
138 using PhaseVector = Dune::FieldVector<Scalar, getPropValue<TypeTag, Properties::NumPhases>()>;
139 using ComponentVector = Dune::FieldVector<Scalar, getPropValue<TypeTag, Properties::NumComponents>()>;
148 using InteractionVolume =
typename InteractionVolumeContainer::InteractionVolume;
156 const Problem& problem()
const
171 new InteractionVolumeContainer(problem());
175 asImp_().initializeMatrix();
188 new InteractionVolumeContainer(problem());
198 void getMpfaFlux(
const IntersectionIterator&,
const CellData&);
200 void get1pMpfaFlux(
const IntersectionIterator&,
const CellData&);
207 TransmissivityMatrix&,
216 int gridSize = problem().gridView().size(0);
219 for (
const auto& element : elements(problem().gridView()))
222 int eIdxGlobalI = problem().variables().index(element);
225 if (element.partitionType() == Dune::InteriorEntity)
228 = problem().variables().cellData(eIdxGlobalI).pressure(this->
pressureType);
239 problem().gridView().template communicate<DataHandle>(dataHandle,
240 Dune::InteriorBorder_All_Interface,
241 Dune::ForwardCommunication);
254 enableMPFA = getParam<bool>(
"GridAdapt.EnableMultiPointFluxApproximation");
261 Implementation &asImp_()
262 {
return *
static_cast<Implementation *
>(
this);}
265 const Implementation &asImp_()
const
266 {
return *
static_cast<const Implementation *
>(
this);}
268 int searchCommonVertex_(
const Intersection& is, Vertex& vertex)
272 int localIdxLarge = 0;
273 for(localIdxLarge = 0; localIdxLarge < is.inside().subEntities(dim); ++localIdxLarge)
275 auto vLarge = is.inside().template subEntity<dim>(localIdxLarge);
278 for(
int verticeSmall = 0; verticeSmall<is.outside().subEntities(dim); ++verticeSmall)
280 auto vSmall = is.outside().template subEntity<dim>(verticeSmall);
282 if(problem().variables().index(vSmall) == problem().variables().index(vLarge) )
285 return localIdxLarge;
294 InteractionVolume& interactionVolume,
295 const int& subVolumeFaceIdx,
296 bool properFluxDirection,
297 Element& additional2,
298 Element& additional3,
299 TransmissivityMatrix& additionalT);
313template<
class TypeTag>
316 int gridSize_ = problem().gridView().size(0);
318 this->A_.setSize (gridSize_,gridSize_);
319 this->f_.resize(gridSize_);
320 irregularCellMap_.clear();
322 this->initializeMatrixRowSize();
323 this->A_.endrowsizes();
324 this->initializeMatrixIndices();
325 this->A_.endindices();
329template<
class TypeTag>
333 for (
const auto& element : elements(problem().gridView()))
336 int eIdxGlobalI = problem().variables().index(element);
337 CellData& cellDataI = problem().variables().cellData(eIdxGlobalI);
343 cellDataI.perimeter() = 0;
346 std::vector<int> foundAdditionals;
348 int numberOfIntersections = 0;
350 for (
const auto& intersection : intersections(problem().gridView(), element))
352 cellDataI.perimeter() += intersection.geometry().volume();
353 numberOfIntersections++;
354 if (intersection.neighbor())
359 if (enableMPFA && (element.level() < intersection.outside().level()))
363 int intersectionID = problem().grid().localIdSet().subId(element,
364 intersection.indexInInside(), 1);
366 int eIdxGlobalJ = problem().variables().index(intersection.outside());
369 irregularCellMap_[intersectionID].push_back(eIdxGlobalJ);
373 cellDataI.fluxData().resize(numberOfIntersections);
374 this->A_.incrementrowsize(eIdxGlobalI, rowSize);
378 if(enableMPFA && maxInteractionVolumes>1)
381 std::multimap<int, int> addionalRelations;
382 using IntPair = std::pair<int,int>;
383 std::pair<std::multimap<int,int>::iterator,std::multimap<int,int>::iterator> range;
384 std::multimap<int,int>::iterator rangeIt;
387 for (
const auto& element : elements(problem().gridView()))
390 int eIdxGlobalI = problem().variables().index(element);
392 const auto isEndIt = problem().gridView().iend(element);
393 for (
auto isIt = problem().gridView().ibegin(element); isIt != isEndIt; ++isIt)
395 const auto& intersection = *isIt;
397 if (intersection.neighbor())
400 int eIdxGlobalJ = problem().variables().index(intersection.outside());
403 if (intersection.outside().level() > element.level())
407 GlobalPosition globalPos3(0.);
409 GlobalPosition globalPos4(0.);
411 TransmissivityMatrix T(0.);
413 int interactionRegions
414 = problem().variables().getMpfaData3D(intersection, T,
415 globalPos3, eIdxGlobal3, globalPos4, eIdxGlobal4 );
416 if (interactionRegions == 0)
417 interactionRegions = problem().pressureModel().computeTransmissibilities(isIt,T,
418 globalPos3, eIdxGlobal3, globalPos4, eIdxGlobal4 );
419 if(!interactionRegions)
420 Dune::dgrave <<
"something went wrong getting mpfa data on cell " << eIdxGlobalI << std::endl;
421 if (interactionRegions == 1)
425 for (
int cocumber=1; cocumber<interactionRegions; cocumber++ )
427 problem().variables().getMpfaData3D(intersection, T,
428 globalPos3, eIdxGlobal3, globalPos4, eIdxGlobal4, cocumber);
430 int additionalIdx2 = eIdxGlobal3;
431 int additionalIdx3 = eIdxGlobal4;
433 bool addIndex =
true;
436 bool additional2isNeighbor(
false), additional3isNeighbor(
false);
438 for (
const auto& checkIntersection
439 : intersections(problem().gridView(), element))
441 if (checkIntersection.neighbor())
443 if(additionalIdx2==problem().variables().index(checkIntersection.outside()))
444 additional2isNeighbor =
true;
445 if(additionalIdx3 == problem().variables().index(checkIntersection.outside()))
446 additional3isNeighbor =
true;
451 if(!additional2isNeighbor)
454 IntPair intPair(eIdxGlobalI,additionalIdx2);
455 if(eIdxGlobalI > additionalIdx2)
458 swap(intPair.first, intPair.second);
460 range = addionalRelations.equal_range(intPair.first);
461 for (rangeIt=range.first; range.first!=range.second
462 && rangeIt!=range.second; ++rangeIt)
463 if((*rangeIt).second == intPair.second)
467 this->A_.incrementrowsize(eIdxGlobalI);
469 this->A_.incrementrowsize(additionalIdx2);
471 addionalRelations.insert(intPair);
476 if(!additional3isNeighbor)
480 IntPair intPair(eIdxGlobalI,additionalIdx3);
481 if(eIdxGlobalI > additionalIdx3)
484 swap(intPair.first, intPair.second);
486 range = addionalRelations.equal_range(intPair.first);
487 for (rangeIt=range.first; range.first!=range.second
488 && rangeIt!=range.second; ++rangeIt)
489 if((*rangeIt).second == intPair.second)
493 this->A_.incrementrowsize(eIdxGlobalI);
495 this->A_.incrementrowsize(additionalIdx3);
497 addionalRelations.insert(intPair);
502 additional2isNeighbor = additional3isNeighbor =
false;
504 for (
const auto& checkIntersection
505 : intersections(problem().gridView(), intersection.outside()))
507 if (checkIntersection.neighbor())
509 if(additionalIdx2 == problem().variables().index(checkIntersection.outside()))
510 additional2isNeighbor =
true;
511 if(additionalIdx3 == problem().variables().index(checkIntersection.outside()))
512 additional3isNeighbor =
true;
517 if(!additional2isNeighbor)
521 IntPair intPair(eIdxGlobalJ,additionalIdx2);
522 if(eIdxGlobalJ > additionalIdx2)
525 swap(intPair.first, intPair.second);
527 range = addionalRelations.equal_range(intPair.first);
528 for (rangeIt=range.first; range.first!=range.second
529 && rangeIt!=range.second; ++rangeIt)
530 if((*rangeIt).second == intPair.second)
534 this->A_.incrementrowsize(eIdxGlobalJ);
536 this->A_.incrementrowsize(additionalIdx2);
538 addionalRelations.insert(intPair);
543 if(!additional3isNeighbor)
547 IntPair intPair(eIdxGlobalJ,additionalIdx3);
548 if(eIdxGlobalJ > additionalIdx3)
551 swap(intPair.first, intPair.second);
553 range = addionalRelations.equal_range(intPair.first);
554 for (rangeIt=range.first; range.first!=range.second
555 && rangeIt!=range.second; ++rangeIt)
556 if((*rangeIt).second == intPair.second)
560 this->A_.incrementrowsize(eIdxGlobalJ);
562 this->A_.incrementrowsize(additionalIdx3);
564 addionalRelations.insert(intPair);
578template<
class TypeTag>
582 for (
const auto& element : elements(problem().gridView()))
585 int eIdxGlobalI = problem().variables().index(element);
588 this->A_.addindex(eIdxGlobalI, eIdxGlobalI);
591 const auto isEndIt = problem().gridView().iend(element);
592 for (
auto isIt = problem().gridView().ibegin(element); isIt != isEndIt; ++isIt)
594 const auto& intersection = *isIt;
596 if (intersection.neighbor())
599 int eIdxGlobalJ = problem().variables().index(intersection.outside());
602 this->A_.addindex(eIdxGlobalI, eIdxGlobalJ);
605 if (enableMPFA && (element.level() < intersection.outside().level()))
608 GlobalPosition globalPos3(0.);
610 GlobalPosition globalPos4(0.);
612 TransmissivityMatrix T(0.);
613 TransmissivityMatrix additionalT(0.);
615 int interactionRegions
616 = problem().variables().getMpfaData3D(intersection, T, globalPos3, eIdxGlobal3, globalPos4, eIdxGlobal4 );
617 if (interactionRegions == 0)
618 interactionRegions = problem().pressureModel().computeTransmissibilities(isIt,T,
619 globalPos3, eIdxGlobal3, globalPos4, eIdxGlobal4 );
621 for (
int cocumber=1; cocumber<interactionRegions; cocumber++ )
623 problem().variables().getMpfaData3D(intersection, T,
624 globalPos3, eIdxGlobal3, globalPos4, eIdxGlobal4, cocumber);
627 this->A_.addindex(eIdxGlobalI, eIdxGlobal3);
628 this->A_.addindex(eIdxGlobal3, eIdxGlobalI);
629 this->A_.addindex(eIdxGlobalI, eIdxGlobal4);
630 this->A_.addindex(eIdxGlobal4, eIdxGlobalI);
631 this->A_.addindex(eIdxGlobalJ, eIdxGlobal3);
632 this->A_.addindex(eIdxGlobal3, eIdxGlobalJ);
633 this->A_.addindex(eIdxGlobalJ, eIdxGlobal4);
634 this->A_.addindex(eIdxGlobal4, eIdxGlobalJ);
643template<
class TypeTag>
648 BaseType::assemble(
true);
656 for (
const auto& element : elements(problem().gridView()))
659 int eIdxGlobalI = problem().variables().index(element);
662 if (element.partitionType() == Dune::InteriorEntity)
665 CellData& cellDataI = problem().variables().cellData(eIdxGlobalI);
667 Dune::FieldVector<Scalar, 2> entries(0.);
670#ifndef noMultiphysics
671 if(cellDataI.subdomain() != 2)
672 problem().pressureModel().get1pSource(entries,element, cellDataI);
675 problem().pressureModel().getSource(entries,element, cellDataI, first);
677 this->f_[eIdxGlobalI] += entries[rhs];
681 const auto isEndIt = problem().gridView().iend(element);
682 for (
auto isIt = problem().gridView().ibegin(element); isIt != isEndIt; ++isIt)
684 const auto& intersection = *isIt;
687 if (intersection.neighbor())
689 auto neighbor = intersection.outside();
690 int eIdxGlobalJ = problem().variables().index(neighbor);
693 bool haveSameLevel = (element.level() == neighbor.level());
697 if (getPropValue<TypeTag, Properties::VisitFacesOnlyOnce>()
698 && (eIdxGlobalI > eIdxGlobalJ) && haveSameLevel
699 && neighbor.partitionType() == Dune::InteriorEntity)
704 if(!haveSameLevel && enableMPFA)
706 if (cellDataI.subdomain() != 2
707 || problem().variables().cellData(eIdxGlobalJ).subdomain() != 2)
709 asImp_().get1pMpfaFlux(isIt, cellDataI);
713 asImp_().getMpfaFlux(isIt, cellDataI);
718 CellData cellDataJ = problem().variables().cellData(eIdxGlobalJ);
719 if (cellDataI.subdomain() != 2
720 || problem().variables().cellData(eIdxGlobalJ).subdomain() != 2)
722 asImp_().get1pFlux(entries, intersection, cellDataI);
726 asImp_().getFlux(entries, intersection, cellDataI, first);
730 this->f_[eIdxGlobalI] -= entries[rhs];
733 this->A_[eIdxGlobalI][eIdxGlobalI] += entries[matrix];
736 this->A_[eIdxGlobalI][eIdxGlobalJ] -= entries[matrix];
739 if (getPropValue<TypeTag, Properties::VisitFacesOnlyOnce>()
740 && neighbor.partitionType() == Dune::InteriorEntity)
742 this->f_[eIdxGlobalJ] += entries[rhs];
743 this->A_[eIdxGlobalJ][eIdxGlobalJ] += entries[matrix];
744 this->A_[eIdxGlobalJ][eIdxGlobalI] -= entries[matrix];
753 if (cellDataI.subdomain() != 2)
754 asImp_().get1pFluxOnBoundary(entries, intersection, cellDataI);
756 asImp_().getFluxOnBoundary(entries, intersection, cellDataI, first);
759 this->f_[eIdxGlobalI] += entries[rhs];
761 this->A_[eIdxGlobalI][eIdxGlobalI] += entries[matrix];
766 if (cellDataI.subdomain() != 2)
767 asImp_().get1pStorage(entries, element, cellDataI);
769 asImp_().getStorage(entries, element, cellDataI, first);
771 this->f_[eIdxGlobalI] += entries[rhs];
773 this->A_[eIdxGlobalI][eIdxGlobalI] += entries[matrix];
778 this->A_[eIdxGlobalI] = 0.0;
779 this->A_[eIdxGlobalI][eIdxGlobalI] = 1.0;
780 this->f_[eIdxGlobalI] = this->
pressure()[eIdxGlobalI];
804template<
class TypeTag>
806 const CellData& cellDataI)
808 const auto& intersection = *isIt;
811 auto elementI = intersection.inside();
812 int eIdxGlobalI = problem().variables().index(elementI);
815 const GlobalPosition& globalPos = elementI.geometry().center();
818 Scalar volume = elementI.geometry().volume();
819 Scalar perimeter = cellDataI.perimeter();
822 DimMatrix permeabilityI(problem().spatialParams().intrinsicPermeability(elementI));
825 auto neighbor = intersection.outside();
826 int eIdxGlobalJ = problem().variables().index(neighbor);
827 CellData& cellDataJ = problem().variables().cellData(eIdxGlobalJ);
830 const GlobalPosition& globalPosNeighbor = neighbor.geometry().center();
833 GlobalPosition distVec = globalPosNeighbor - globalPos;
836 Scalar dist = distVec.two_norm();
838 GlobalPosition unitDistVec(distVec);
841 DimMatrix permeabilityJ
842 = problem().spatialParams().intrinsicPermeability(neighbor);
845 DimMatrix meanPermeability(0);
852 PhaseVector rhoMean(0.);
853 for (
int phaseIdx=0; phaseIdx<NumPhases; phaseIdx++)
854 rhoMean[phaseIdx] =0.5 * (cellDataI.density(phaseIdx)+cellDataJ.density(phaseIdx));
857 Dune::FieldVector<Scalar,2> potential(0.);
860 if (!cellDataJ.hasVolumeDerivatives())
861 asImp_().volumeDerivatives(globalPosNeighbor, neighbor);
863 ComponentVector dv_dC(0.), graddv_dC(0.);
864 for (
int compIdx = 0; compIdx < NumComponents; ++compIdx)
866 dv_dC[compIdx]= (cellDataJ.dv(compIdx)
867 + cellDataI.dv(compIdx)) * 0.5;
868 graddv_dC[compIdx] = (cellDataJ.dv(compIdx)
869 - cellDataI.dv(compIdx)) / dist;
883 GlobalPosition globalPos3(0.);
885 GlobalPosition globalPos4(0.);
887 TransmissivityMatrix T(0.);
890 GlobalPosition globalPosAdditional3(0.);
891 int eIdxGlobalAdditional3=-1;
892 GlobalPosition globalPosAdditional4(0.);
893 int eIdxGlobalAdditional4=-1;
895 TransmissivityMatrix additionalT(0.);
897 int interactionRegions
898 = problem().variables().getMpfaData3D(intersection, T,
899 globalPos3, eIdxGlobal3, globalPos4, eIdxGlobal4 );
900 if (interactionRegions == 0)
901 interactionRegions = problem().pressureModel().computeTransmissibilities(isIt,T,
902 globalPos3, eIdxGlobal3, globalPos4, eIdxGlobal4 );
903 if(!interactionRegions)
904 Dune::dgrave <<
"something went wrong getting mpfa data on cell " << eIdxGlobalI << std::endl;
907 CellData& cellData3 = problem().variables().cellData(eIdxGlobal3);
908 CellData& cellData4 = problem().variables().cellData(eIdxGlobal4);
909 Scalar temp1 = globalPos * this->gravity_;
910 Scalar temp2 = globalPosNeighbor * this->gravity_;
911 Scalar temp3 = globalPos3 * this->gravity_;
912 Scalar temp4 = globalPos4 * this->gravity_;
914 for (
int phaseIdx = 0; phaseIdx < NumPhases; ++phaseIdx)
916 potential[phaseIdx] = (cellDataI.pressure(phaseIdx)-temp1*rhoMean[phaseIdx]) * T[0]
917 + (cellDataJ.pressure(phaseIdx)-temp2*rhoMean[phaseIdx]) * T[1]
918 + (cellData3.pressure(phaseIdx)-temp3*rhoMean[phaseIdx]) * T[2]
919 + (cellData4.pressure(phaseIdx)-temp4*rhoMean[phaseIdx]) * T[3];
923 if(interactionRegions != 1)
925 for(
int banana = 1; banana < interactionRegions; banana ++)
928 problem().variables().getMpfaData3D(intersection, additionalT,
929 globalPosAdditional3, eIdxGlobalAdditional3,
930 globalPosAdditional4, eIdxGlobalAdditional4 ,
933 Scalar gravityContributionAdditonal
934 = temp1 * additionalT[0] + temp2 * additionalT[1]
935 + globalPosAdditional3*this->gravity_ * additionalT[2]
936 + globalPosAdditional4*this->gravity_ * additionalT[3];
937 CellData& cellDataA3 = problem().variables().cellData(eIdxGlobalAdditional3);
938 CellData& cellDataA4 = problem().variables().cellData(eIdxGlobalAdditional4);
940 for (
int phaseIdx = 0; phaseIdx < NumPhases; ++phaseIdx)
942 potential[phaseIdx] += cellDataI.pressure(phaseIdx) * additionalT[0]
943 + cellDataJ.pressure(phaseIdx) * additionalT[1]
944 + cellDataA3.pressure(phaseIdx) * additionalT[2]
945 + cellDataA4.pressure(phaseIdx) * additionalT[3];
946 potential[phaseIdx] -= gravityContributionAdditonal * rhoMean[phaseIdx];
952 PhaseVector lambda(0.), dV(0.), gV(0.);
955 std::vector<const CellData*> upwindCellData(NumPhases);
957 for (
int phaseIdx = 0; phaseIdx < NumPhases; ++phaseIdx)
959 int eqIdx = phaseIdx + 1;
960 if (potential[phaseIdx] > 0.)
961 upwindCellData[phaseIdx] = &cellDataI;
962 else if (potential[phaseIdx] < 0.)
963 upwindCellData[phaseIdx] = &cellDataJ;
966 if(cellDataI.isUpwindCell(intersection.indexInInside(), eqIdx))
967 upwindCellData[phaseIdx] = &cellDataI;
968 else if(cellDataJ.isUpwindCell(intersection.indexInOutside(), eqIdx))
969 upwindCellData[phaseIdx] = &cellDataJ;
975 if(!upwindCellData[phaseIdx])
977 Scalar averagedMassFraction[NumComponents];
978 for (
int compIdx = 0; compIdx < NumComponents; ++compIdx)
979 averagedMassFraction[compIdx]
980 =
harmonicMean(cellDataI.massFraction(phaseIdx, compIdx), cellDataJ.massFraction(phaseIdx, compIdx));
981 Scalar averageDensity =
harmonicMean(cellDataI.density(phaseIdx), cellDataJ.density(phaseIdx));
983 for (
int compIdx = 0; compIdx < NumComponents; ++compIdx)
985 dV[phaseIdx] += dv_dC[compIdx] * averagedMassFraction[compIdx];
986 gV[phaseIdx] += graddv_dC[compIdx] * averagedMassFraction[compIdx];
988 dV[phaseIdx] *= averageDensity;
989 gV[phaseIdx] *= averageDensity;
990 lambda[phaseIdx] =
harmonicMean(cellDataI.mobility(phaseIdx), cellDataJ.mobility(phaseIdx));
994 for (
int compIdx = 0; compIdx < NumComponents; ++compIdx)
996 dV[phaseIdx] += dv_dC[compIdx] * upwindCellData[phaseIdx]->massFraction(phaseIdx, compIdx);
997 gV[phaseIdx] += graddv_dC[compIdx] * upwindCellData[phaseIdx]->massFraction(phaseIdx, compIdx);
999 lambda[phaseIdx] = upwindCellData[phaseIdx]->mobility(phaseIdx);
1000 dV[phaseIdx] *= upwindCellData[phaseIdx]->density(phaseIdx);
1001 gV[phaseIdx] *= upwindCellData[phaseIdx]->density(phaseIdx);
1007 this->A_[eIdxGlobalI][eIdxGlobalI] += (lambda[wPhaseIdx] * dV[wPhaseIdx] + lambda[nPhaseIdx] * dV[nPhaseIdx]) * T[0];
1008 this->A_[eIdxGlobalI][eIdxGlobalJ] += (lambda[wPhaseIdx] * dV[wPhaseIdx] + lambda[nPhaseIdx] * dV[nPhaseIdx]) * T[1];
1009 this->A_[eIdxGlobalI][eIdxGlobal3] += (lambda[wPhaseIdx] * dV[wPhaseIdx] + lambda[nPhaseIdx] * dV[nPhaseIdx]) * T[2];
1010 this->A_[eIdxGlobalI][eIdxGlobal4] += (lambda[wPhaseIdx] * dV[wPhaseIdx] + lambda[nPhaseIdx] * dV[nPhaseIdx]) * T[3];
1014 Scalar gravityContribution = temp1 * T[0] + temp2 * T[1] + temp3 * T[2] + temp4 * T[3];
1015 this->f_[eIdxGlobalI] += (rhoMean[wPhaseIdx] * lambda[wPhaseIdx] * dV[wPhaseIdx]
1016 + rhoMean[nPhaseIdx] * lambda[nPhaseIdx] * dV[nPhaseIdx]) * gravityContribution;
1019 Scalar weightingFactor = volume / perimeter;
1020 if(enableVolumeIntegral_)
1023 this->A_[eIdxGlobalI][eIdxGlobalI] -=
1024 weightingFactor * (lambda[wPhaseIdx] * gV[wPhaseIdx] + lambda[nPhaseIdx] * gV[nPhaseIdx]) * T[0];
1025 this->A_[eIdxGlobalI][eIdxGlobalJ] -=
1026 weightingFactor * (lambda[wPhaseIdx] * gV[wPhaseIdx] + lambda[nPhaseIdx] * gV[nPhaseIdx]) * T[1];
1027 this->A_[eIdxGlobalI][eIdxGlobal3] -=
1028 weightingFactor * (lambda[wPhaseIdx] * gV[wPhaseIdx] + lambda[nPhaseIdx] * gV[nPhaseIdx]) * T[2];
1029 this->A_[eIdxGlobalI][eIdxGlobal4] -=
1030 weightingFactor * (lambda[wPhaseIdx] * gV[wPhaseIdx] + lambda[nPhaseIdx] * gV[nPhaseIdx]) * T[3];
1033 this->f_[eIdxGlobalI] -= weightingFactor * gravityContribution *
1034 (rhoMean[wPhaseIdx] * lambda[wPhaseIdx] * gV[wPhaseIdx] + rhoMean[nPhaseIdx] * lambda[nPhaseIdx] * gV[nPhaseIdx]);
1038 Scalar pcGradient = cellDataI.capillaryPressure() * T[0]
1039 + cellDataJ.capillaryPressure() * T[1]
1040 + cellData3.capillaryPressure() * T[2]
1041 + cellData4.capillaryPressure() * T[3];
1043 if (this->pressureType == pw)
1044 pcGradient *= + lambda[nPhaseIdx] * dV[nPhaseIdx]
1045 - enableVolumeIntegral_ * weightingFactor * lambda[nPhaseIdx] * gV[nPhaseIdx];
1046 else if (this->pressureType == pn)
1047 pcGradient *= - lambda[wPhaseIdx] * dV[wPhaseIdx]
1048 + enableVolumeIntegral_ * weightingFactor * lambda[wPhaseIdx] * gV[wPhaseIdx];
1050 this->f_[eIdxGlobalI] += pcGradient;
1053 if(interactionRegions != 1)
1055 for(
int banana = 1; banana < interactionRegions; banana ++)
1058 problem().variables().getMpfaData3D(intersection, additionalT,
1059 globalPosAdditional3, eIdxGlobalAdditional3,
1060 globalPosAdditional4, eIdxGlobalAdditional4 ,
1063 Scalar gravityContributionAdditonal
1064 = temp1 * additionalT[0] + temp2 * additionalT[1]
1065 + globalPosAdditional3*this->gravity_ * additionalT[2]
1066 + globalPosAdditional4*this->gravity_ * additionalT[3];
1067 CellData& cellDataA3 = problem().variables().cellData(eIdxGlobalAdditional3);
1068 CellData& cellDataA4 = problem().variables().cellData(eIdxGlobalAdditional4);
1072 this->A_[eIdxGlobalI][eIdxGlobalI] +=
1073 (lambda[wPhaseIdx] * dV[wPhaseIdx] + lambda[nPhaseIdx] * dV[nPhaseIdx]) * additionalT[0];
1074 this->A_[eIdxGlobalI][eIdxGlobalJ] +=
1075 (lambda[wPhaseIdx] * dV[wPhaseIdx] + lambda[nPhaseIdx] * dV[nPhaseIdx]) * additionalT[1];
1076 this->A_[eIdxGlobalI][eIdxGlobalAdditional3] +=
1077 (lambda[wPhaseIdx] * dV[wPhaseIdx] + lambda[nPhaseIdx] * dV[nPhaseIdx]) * additionalT[2];
1078 this->A_[eIdxGlobalI][eIdxGlobalAdditional4] +=
1079 (lambda[wPhaseIdx] * dV[wPhaseIdx] + lambda[nPhaseIdx] * dV[nPhaseIdx]) * additionalT[3];
1083 this->f_[eIdxGlobalI] += (rhoMean[wPhaseIdx] * lambda[wPhaseIdx] * dV[wPhaseIdx]
1084 + rhoMean[nPhaseIdx] * lambda[nPhaseIdx] * dV[nPhaseIdx]) * gravityContributionAdditonal;
1087 if(enableVolumeIntegral_)
1090 this->A_[eIdxGlobalI][eIdxGlobalI] -=
1091 weightingFactor * (lambda[wPhaseIdx] * gV[wPhaseIdx] + lambda[nPhaseIdx] * gV[nPhaseIdx]) * additionalT[0];
1092 this->A_[eIdxGlobalI][eIdxGlobalJ] -=
1093 weightingFactor * (lambda[wPhaseIdx] * gV[wPhaseIdx] + lambda[nPhaseIdx] * gV[nPhaseIdx]) * additionalT[1];
1094 this->A_[eIdxGlobalI][eIdxGlobalAdditional3] -=
1095 weightingFactor * (lambda[wPhaseIdx] * gV[wPhaseIdx] + lambda[nPhaseIdx] * gV[nPhaseIdx]) * additionalT[2];
1096 this->A_[eIdxGlobalI][eIdxGlobalAdditional4] -=
1097 weightingFactor * (lambda[wPhaseIdx] * gV[wPhaseIdx] + lambda[nPhaseIdx] * gV[nPhaseIdx]) * additionalT[3];
1100 this->f_[eIdxGlobalI] -= weightingFactor * gravityContribution *
1101 (rhoMean[wPhaseIdx] * lambda[wPhaseIdx] * gV[wPhaseIdx] + rhoMean[nPhaseIdx] * lambda[nPhaseIdx] * gV[nPhaseIdx]);
1105 Scalar addPcGradient = cellDataI.capillaryPressure() * additionalT[0]
1106 + cellDataJ.capillaryPressure() * additionalT[1]
1107 + cellDataA3.capillaryPressure() * additionalT[2]
1108 + cellDataA4.capillaryPressure() * additionalT[3];
1110 if (this->pressureType == pw)
1111 addPcGradient *= + lambda[nPhaseIdx] * dV[nPhaseIdx]
1112 - enableVolumeIntegral_ * weightingFactor * lambda[nPhaseIdx] * gV[nPhaseIdx];
1113 else if (this->pressureType == pn)
1114 addPcGradient *= - lambda[wPhaseIdx] * dV[wPhaseIdx]
1115 + enableVolumeIntegral_ * weightingFactor * lambda[wPhaseIdx] * gV[wPhaseIdx];
1117 this->f_[eIdxGlobalI] += addPcGradient;
1141template<
class TypeTag>
1143 const CellData& cellDataI)
1145 const auto& intersection = *isIt;
1148 auto elementI = intersection.inside();
1149 int eIdxGlobalI = problem().variables().index(elementI);
1152 const GlobalPosition& globalPos = elementI.geometry().center();
1155 auto neighbor = intersection.outside();
1156 int eIdxGlobalJ = problem().variables().index(neighbor);
1157 CellData& cellDataJ = problem().variables().cellData(eIdxGlobalJ);
1160 const GlobalPosition& globalPosNeighbor = neighbor.geometry().center();
1165 int phaseIdx = min(cellDataI.subdomain(), cellDataJ.subdomain());
1168 Scalar rhoMean = 0.5 * (cellDataI.density(phaseIdx) + cellDataJ.density(phaseIdx));
1171 Scalar potential = 0.;
1175 GlobalPosition globalPos3(0.);
1177 GlobalPosition globalPos4(0.);
1179 TransmissivityMatrix T(0.);
1182 GlobalPosition globalPosAdditional3(0.);
1183 int eIdxGlobalAdditional3=-1;
1184 GlobalPosition globalPosAdditional4(0.);
1185 int eIdxGlobalAdditional4=-1;
1187 TransmissivityMatrix additionalT(0.);
1189 int interactionRegions
1190 = problem().variables().getMpfaData3D(intersection, T,
1191 globalPos3, eIdxGlobal3, globalPos4, eIdxGlobal4 );
1192 if (interactionRegions == 0)
1193 interactionRegions = problem().pressureModel().computeTransmissibilities(isIt,T,
1194 globalPos3, eIdxGlobal3, globalPos4, eIdxGlobal4 );
1195 if(!interactionRegions)
1196 Dune::dgrave <<
"something went wrong getting mpfa data on cell " << eIdxGlobalI << std::endl;
1199 CellData& cellData3 = problem().variables().cellData(eIdxGlobal3);
1200 CellData& cellData4 = problem().variables().cellData(eIdxGlobal4);
1201 Scalar temp1 = globalPos * this->gravity_;
1202 Scalar temp2 = globalPosNeighbor * this->gravity_;
1203 Scalar temp3 = globalPos3 * this->gravity_;
1204 Scalar temp4 = globalPos4 * this->gravity_;
1206 potential = (cellDataI.pressure(phaseIdx)-temp1*rhoMean) * T[0]
1207 + (cellDataJ.pressure(phaseIdx)-temp2*rhoMean) * T[1]
1208 + (cellData3.pressure(phaseIdx)-temp3*rhoMean) * T[2]
1209 + (cellData4.pressure(phaseIdx)-temp4*rhoMean) * T[3];
1212 if(interactionRegions != 1)
1214 for(
int banana = 1; banana < interactionRegions; banana ++)
1217 problem().variables().getMpfaData3D(intersection, additionalT,
1218 globalPosAdditional3, eIdxGlobalAdditional3,
1219 globalPosAdditional4, eIdxGlobalAdditional4 ,
1222 Scalar gravityContributionAdditonal
1223 = temp1 * additionalT[0] + temp2 * additionalT[1]
1224 + globalPosAdditional3*this->gravity_ * additionalT[2]
1225 + globalPosAdditional4*this->gravity_ * additionalT[3];
1226 CellData& cellDataA3 = problem().variables().cellData(eIdxGlobalAdditional3);
1227 CellData& cellDataA4 = problem().variables().cellData(eIdxGlobalAdditional4);
1229 potential += cellDataI.pressure(phaseIdx) * additionalT[0]
1230 + cellDataJ.pressure(phaseIdx) * additionalT[1]
1231 + cellDataA3.pressure(phaseIdx) * additionalT[2]
1232 + cellDataA4.pressure(phaseIdx) * additionalT[3];
1233 potential -= gravityContributionAdditonal * rhoMean;
1241 if (potential >= 0.)
1242 lambda = cellDataI.mobility(phaseIdx);
1244 lambda = cellDataJ.mobility(phaseIdx);
1248 this->A_[eIdxGlobalI][eIdxGlobalI] += lambda * T[0];
1249 this->A_[eIdxGlobalI][eIdxGlobalJ] += lambda * T[1];
1250 this->A_[eIdxGlobalI][eIdxGlobal3] += lambda * T[2];
1251 this->A_[eIdxGlobalI][eIdxGlobal4] += lambda * T[3];
1254 Scalar gravityContribution = temp1 * T[0] + temp2 * T[1] + temp3 * T[2] + temp4 * T[3];
1255 this->f_[eIdxGlobalI] += lambda * rhoMean * gravityContribution;
1258 if(interactionRegions != 1)
1260 for(
int banana = 1; banana < interactionRegions; banana ++)
1263 problem().variables().getMpfaData3D(intersection, additionalT,
1264 globalPosAdditional3, eIdxGlobalAdditional3,
1265 globalPosAdditional4, eIdxGlobalAdditional4 ,
1268 Scalar gravityContributionAdditonal
1269 = temp1 * additionalT[0] + temp2 * additionalT[1]
1270 + globalPosAdditional3*this->gravity_ * additionalT[2]
1271 + globalPosAdditional4*this->gravity_ * additionalT[3];
1275 this->A_[eIdxGlobalI][eIdxGlobalI] += lambda * additionalT[0];
1276 this->A_[eIdxGlobalI][eIdxGlobalJ] += lambda * additionalT[1];
1277 this->A_[eIdxGlobalI][eIdxGlobalAdditional3] += lambda * additionalT[2];
1278 this->A_[eIdxGlobalI][eIdxGlobalAdditional4] += lambda * additionalT[3];
1281 this->f_[eIdxGlobalI] += lambda * rhoMean* gravityContributionAdditonal;
1294template<
class TypeTag>
1298#ifdef noMultiphysics
1303 if(!fromPostTimestep)
1305 Scalar maxError = 0.;
1307 for (
const auto& element : elements(problem().gridView()))
1309 int eIdxGlobal = problem().variables().index(element);
1310 CellData& cellData = problem().variables().cellData(eIdxGlobal);
1312 if(cellData.fluidStateType() == 0)
1313 problem().pressureModel().updateMaterialLawsInElement(element, fromPostTimestep);
1315 problem().pressureModel().update1pMaterialLawsInElement(element, cellData, fromPostTimestep);
1317 maxError = max(maxError, fabs(cellData.volumeError()));
1319 this->maxError_ = maxError/problem().timeManager().timeStepSize();
1348template <
class TypeTag>
1350 TransmissivityMatrix& T,
1351 GlobalPosition& globalPos4,
1353 GlobalPosition& globalPos6,
1356 const auto& intersection = *isIt;
1359 auto element = intersection.inside();
1360 auto neighbor = intersection.outside();
1361 GlobalPosition globalPos1 = element.geometry().center();
1362 GlobalPosition globalPos2 = neighbor.geometry().center();
1363 DimMatrix K1(problem().spatialParams().intrinsicPermeability(element));
1364 DimMatrix K2(problem().spatialParams().intrinsicPermeability(neighbor));
1367 int intersectionID = 0;
1368 if(intersection.inside().level() < intersection.outside().level())
1369 intersectionID = problem().grid().localIdSet().subId(element,
1370 intersection.indexInInside(), 1);
1372 DUNE_THROW(Dune::NotImplemented,
" ABORT, transmiss calculated from wrong side!!");
1374 std::vector<int> localIrregularCells = irregularCellMap_[intersectionID];
1378 GlobalPosition globalPosFace12 = intersection.geometry().center();
1379 GlobalPosition outerNormaln12 = intersection.centerUnitOuterNormal();
1385 const auto isEndIt = problem().gridView().iend(neighbor);
1386 for (
auto isIt2 = problem().gridView().ibegin(neighbor); isIt2 != isEndIt; ++isIt2)
1388 const auto& intersection2 = *isIt2;
1391 if(!(intersection2.neighbor()) || intersection2.outside() == element)
1394 int currentNeighbor = problem().variables().index(intersection2.outside());
1397 if (find(localIrregularCells.begin(), localIrregularCells.end(),
1398 currentNeighbor) != localIrregularCells.end() && face24==isIt)
1400 else if (find(localIrregularCells.begin(), localIrregularCells.end(),
1401 currentNeighbor) != localIrregularCells.end() && face26==isIt)
1405 GlobalPosition vectorProduct =
crossProduct(face24->centerUnitOuterNormal(), intersection2.centerUnitOuterNormal());
1408 if((vectorProduct * outerNormaln12) > 0.)
1420 globalPos4 = face24->outside().geometry().center();
1421 eIdxGlobal4 = problem().variables().index(face24->outside());
1422 GlobalPosition outerNormaln24 = face24->centerUnitOuterNormal();
1424 DimMatrix K4(problem().spatialParams().intrinsicPermeability(face24->outside()));
1427 globalPos6 = face26->outside().geometry().center();
1428 eIdxGlobal6 = problem().variables().index(face26->outside());
1429 GlobalPosition outerNormaln26 = face26->centerUnitOuterNormal();
1431 DimMatrix K6(problem().spatialParams().intrinsicPermeability(face26->outside()));
1434 int localFace12 = intersection.indexInOutside();
1435 int localFace24 = face24->indexInInside();
1436 int localFace26 = face26->indexInInside();
1438 const auto referenceElement = ReferenceElementContainer::general(neighbor.type());
1443 for(
int nectarine=0; nectarine < referenceElement.size(localFace12, 1, dim-1); nectarine++)
1446 int localEdgeOn12 = referenceElement.subEntity(localFace12, 1, nectarine, dim-1);
1448 for(
int plum = 0; plum < referenceElement.size(localFace26, 1,dim-1); plum++)
1451 if(referenceElement.subEntity(localFace12, 1, nectarine, dim-1)
1452 == referenceElement.subEntity(localFace26, 1, plum, dim-1))
1454 edge1226 = localEdgeOn12;
1459 GlobalPosition edgeCoord1226 =
1460 neighbor.geometry().global(referenceElement.position(edge1226, dim-1));
1465 for(
int nectarine=0; nectarine < referenceElement.size(localFace12, 1, dim-1); nectarine++)
1468 int localEdgeOn12 = referenceElement.subEntity(localFace12, 1, nectarine, dim-1);
1470 for(
int plum = 0; plum < referenceElement.size(localFace24, 1, dim-1); plum++)
1472 int localEdge24 = referenceElement.subEntity(localFace24, 1, plum, dim-1);
1473 if(localEdgeOn12 == localEdge24)
1475 edge1224 = localEdgeOn12;
1480 GlobalPosition edgeCoord1224 =
1481 neighbor.geometry().global(referenceElement.position(edge1224, dim-1));
1486 for(
int nectarine=0; nectarine < referenceElement.size(localFace24, 1, dim-1); nectarine++)
1489 int localEdgeOn24 = referenceElement.subEntity(localFace24, 1, nectarine, dim-1);
1491 for(
int plum = 0; plum < referenceElement.size(localFace26, 1, dim-1); plum++)
1493 int localEdge26 = referenceElement.subEntity(localFace26, 1, plum, dim-1);
1494 if(localEdgeOn24 == localEdge26)
1496 edge2426 = localEdgeOn24;
1501 GlobalPosition edgeCoord2426 =
1502 neighbor.geometry().global(referenceElement.position(edge2426, dim-1));
1506 GlobalPosition globalPosFace24 = face24->geometry().center();
1507 GlobalPosition globalPosFace26 = face26->geometry().center();
1511 Scalar subFaceArea12 =
crossProduct(edgeCoord1226-globalPosFace12, edgeCoord1224-globalPosFace12).two_norm();
1514 Scalar subFaceArea24 =
crossProduct(edgeCoord1224-globalPosFace24, edgeCoord2426-globalPosFace24).two_norm();
1517 Scalar subFaceArea26 =
crossProduct(edgeCoord1226-globalPosFace26, edgeCoord2426-globalPosFace26).two_norm();
1520 GlobalPosition nu11C2 =
crossProduct(edgeCoord1226-globalPos1, globalPosFace12-globalPos1);
1521 GlobalPosition nu12C2 =
crossProduct(edgeCoord1224-globalPos1, edgeCoord1226-globalPos1);
1522 GlobalPosition nu13C2 =
crossProduct(globalPosFace12-globalPos1, edgeCoord1224-globalPos1);
1524 GlobalPosition nu21C2 =
crossProduct(globalPosFace26-globalPos2, globalPosFace24-globalPos2);
1525 GlobalPosition nu22C2 =
crossProduct(globalPosFace12-globalPos2, globalPosFace26-globalPos2);
1526 GlobalPosition nu23C2 =
crossProduct(globalPosFace24-globalPos2, globalPosFace12-globalPos2);
1528 GlobalPosition nu41C2 =
crossProduct(edgeCoord2426-globalPos4, edgeCoord1224-globalPos4);
1529 GlobalPosition nu42C2 =
crossProduct(globalPosFace24-globalPos4, edgeCoord2426-globalPos4);
1530 GlobalPosition nu43C2 =
crossProduct(edgeCoord1224-globalPos4, globalPosFace24-globalPos4);
1532 GlobalPosition nu61C2 =
crossProduct(globalPosFace26-globalPos6, edgeCoord1226-globalPos6);
1533 GlobalPosition nu62C2 =
crossProduct(edgeCoord2426-globalPos6, globalPosFace26-globalPos6);
1534 GlobalPosition nu63C2 =
crossProduct(edgeCoord1226-globalPos6, edgeCoord2426-globalPos6);
1537 Scalar T1C2 = (globalPosFace12-globalPos1) *
crossProduct(edgeCoord1224-globalPos1, edgeCoord1226-globalPos1);
1538 Scalar T2C2 = (globalPosFace12-globalPos2) *
crossProduct(globalPosFace26-globalPos2, globalPosFace24-globalPos2);
1539 Scalar T4C2 = (globalPosFace24-globalPos4) *
crossProduct(edgeCoord2426-globalPos4, edgeCoord1224-globalPos4);
1540 Scalar T6C2 = (globalPosFace26-globalPos6) *
crossProduct(edgeCoord1226-globalPos6, edgeCoord2426-globalPos6);
1543 GlobalPosition K1nu11C2(0);
1544 K1.mv(nu11C2, K1nu11C2);
1545 GlobalPosition K1nu12C2(0);
1546 K1.mv(nu12C2, K1nu12C2);
1547 GlobalPosition K1nu13C2(0);
1548 K1.mv(nu13C2, K1nu13C2);
1550 GlobalPosition K2nu21C2(0);
1551 K2.mv(nu21C2, K2nu21C2);
1552 GlobalPosition K2nu22C2(0);
1553 K2.mv(nu22C2, K2nu22C2);
1554 GlobalPosition K2nu23C2(0);
1555 K2.mv(nu23C2, K2nu23C2);
1557 GlobalPosition K4nu41C2(0);
1558 K4.mv(nu41C2, K4nu41C2);
1559 GlobalPosition K4nu42C2(0);
1560 K4.mv(nu42C2, K4nu42C2);
1561 GlobalPosition K4nu43C2(0);
1562 K4.mv(nu43C2, K4nu43C2);
1564 GlobalPosition K6nu61C2(0);
1565 K6.mv(nu61C2, K6nu61C2);
1566 GlobalPosition K6nu62C2(0);
1567 K6.mv(nu62C2, K6nu62C2);
1568 GlobalPosition K6nu63C2(0);
1569 K6.mv(nu63C2, K6nu63C2);
1573 Scalar omega111C2 = (outerNormaln12 * K1nu11C2) * subFaceArea12/T1C2;
1574 Scalar omega112C2 = (outerNormaln12 * K1nu12C2) * subFaceArea12/T1C2;
1575 Scalar omega113C2 = (outerNormaln12 * K1nu13C2) * subFaceArea12/T1C2;
1577 Scalar omega121C2 = (outerNormaln12 * K2nu21C2) * subFaceArea12/T2C2;
1578 Scalar omega122C2 = (outerNormaln12 * K2nu22C2) * subFaceArea12/T2C2;
1579 Scalar omega123C2 = (outerNormaln12 * K2nu23C2) * subFaceArea12/T2C2;
1581 Scalar omega221C2 = (outerNormaln24 * K2nu21C2) * subFaceArea24/T2C2;
1582 Scalar omega222C2 = (outerNormaln24 * K2nu22C2) * subFaceArea24/T2C2;
1583 Scalar omega223C2 = (outerNormaln24 * K2nu23C2) * subFaceArea24/T2C2;
1585 Scalar omega241C2 = (outerNormaln24 * K4nu41C2) * subFaceArea24/T4C2;
1586 Scalar omega242C2 = (outerNormaln24 * K4nu42C2) * subFaceArea24/T4C2;
1587 Scalar omega243C2 = (outerNormaln24 * K4nu43C2) * subFaceArea24/T4C2;
1589 Scalar omega321C2 = (outerNormaln26 * K2nu21C2) * subFaceArea26/T2C2;
1590 Scalar omega322C2 = (outerNormaln26 * K2nu22C2) * subFaceArea26/T2C2;
1591 Scalar omega323C2 = (outerNormaln26 * K2nu23C2) * subFaceArea26/T2C2;
1593 Scalar omega361C2 = (outerNormaln26 * K6nu61C2) * subFaceArea26/T6C2;
1594 Scalar omega362C2 = (outerNormaln26 * K6nu62C2) * subFaceArea26/T6C2;
1595 Scalar omega363C2 = (outerNormaln26 * K6nu63C2) * subFaceArea26/T6C2;
1597 Scalar r211C2 = (nu21C2 * (edgeCoord1224-globalPos2))/T2C2;
1598 Scalar r212C2 = (nu21C2 * (edgeCoord1226-globalPos2))/T2C2;
1599 Scalar r213C2 = (nu21C2 * (edgeCoord2426-globalPos2))/T2C2;
1601 Scalar r221C2 = (nu22C2 * (edgeCoord1224-globalPos2))/T2C2;
1602 Scalar r222C2 = (nu22C2 * (edgeCoord1226-globalPos2))/T2C2;
1603 Scalar r223C2 = (nu22C2 * (edgeCoord2426-globalPos2))/T2C2;
1605 Scalar r231C2 = (nu23C2 * (edgeCoord1224-globalPos2))/T2C2;
1606 Scalar r232C2 = (nu23C2 * (edgeCoord1226-globalPos2))/T2C2;
1607 Scalar r233C2 = (nu23C2 * (edgeCoord2426-globalPos2))/T2C2;
1612 DimMatrix C(0), A(0);
1613 Dune::FieldMatrix<Scalar,dim,dim+1> D(0), B(0);
1616 C[0][0] = -omega121C2;
1617 C[0][1] = -omega122C2;
1618 C[0][2] = -omega123C2;
1619 C[1][0] = -omega221C2;
1620 C[1][1] = -omega222C2;
1621 C[1][2] = -omega223C2;
1622 C[2][0] = -omega321C2;
1623 C[2][1] = -omega322C2;
1624 C[2][2] = -omega323C2;
1626 D[0][1] = omega121C2 + omega122C2 + omega123C2;
1627 D[1][1] = omega221C2 + omega222C2 + omega223C2;
1628 D[2][1] = omega321C2 + omega322C2 + omega323C2;
1630 A[0][0] = omega121C2 - omega112C2 - omega111C2*r211C2 - omega113C2*r212C2;
1631 A[0][1] = omega122C2 - omega111C2*r221C2 - omega113C2*r222C2;
1632 A[0][2] = omega123C2 - omega111C2*r231C2 - omega113C2*r232C2;
1633 A[1][0] = omega221C2 - omega242C2*r211C2 - omega243C2*r213C2;
1634 A[1][1] = omega222C2 - omega241C2 - omega242C2*r221C2 - omega243C2*r223C2;
1635 A[1][2] = omega223C2 - omega242C2*r231C2 - omega243C2*r233C2;
1636 A[2][0] = omega321C2 - omega361C2*r213C2 - omega362C2*r212C2;
1637 A[2][1] = omega322C2 - omega361C2*r223C2 - omega362C2*r222C2;
1638 A[2][2] = omega323C2 - omega363C2 - omega361C2*r233C2 - omega362C2*r232C2;
1640 B[0][0] = -omega111C2 - omega112C2 - omega113C2;
1641 B[0][1] = omega121C2 + omega122C2 + omega123C2 + omega111C2*(1.0 - r211C2 - r221C2 -r231C2)
1642 + omega113C2*(1.0 - r212C2 - r222C2 - r232C2);
1643 B[1][1] = omega221C2 + omega222C2 + omega223C2 + omega242C2*(1.0 - r211C2 - r221C2 - r231C2)
1644 + omega243C2*(1.0 - r213C2 - r223C2 - r233C2);
1645 B[1][2] = -omega241C2 - omega242C2 - omega243C2;
1646 B[2][1] = omega321C2 + omega322C2 + omega323C2 + omega361C2*(1.0 - r213C2 - r223C2 - r233C2)
1647 + omega362C2*(1.0 - r212C2 -r222C2 -r232C2);
1648 B[2][3] = -omega361C2 - omega362C2 -omega363C2;
1657 D += B.leftmultiply(C.rightmultiply(A));
1661 if(maxInteractionVolumes ==1)
1663 T *= intersection.geometry().volume()/subFaceArea12 ;
1666 problem().variables().storeMpfaData3D(intersection, T, globalPos4, eIdxGlobal4, globalPos6, eIdxGlobal6);
1671 int countInteractionRegions = 1;
1673 TransmissivityMatrix additionalT(0.);
1675 auto outerCorner = intersection.inside().template subEntity<dim>(0);
1677 auto additional2 = intersection.inside();
1678 auto additional3 = intersection.inside();
1683 int localIdxLarge = searchCommonVertex_(intersection, outerCorner);
1687 if (problem().gridView().comm().size() > 1)
1688 if(outerCorner.partitionType() != Dune::InteriorEntity)
1693 int vIdxGlobal = problem().variables().index(outerCorner);
1694 InteractionVolume& interactionVolume
1695 = interactionVolumesContainer_->interactionVolume(vIdxGlobal);
1698 if(interactionVolume.isBoundaryInteractionVolume())
1702 int subVolumeFaceIdx = -1;
1703 bool properFluxDirection =
true;
1707 int hangingNodeType = interactionVolume.getHangingNodeType();
1709 if(hangingNodeType == InteractionVolume::noHangingNode)
1710 subVolumeFaceIdx = interactionVolumesContainer_->getMpfaCase8cells(isIt, localIdxLarge, interactionVolume, properFluxDirection);
1711 else if(hangingNodeType == InteractionVolume::sixSmallCells)
1712 subVolumeFaceIdx = interactionVolumesContainer_->getMpfaCase6cells(isIt, interactionVolume, properFluxDirection);
1714 Dune::dgrave <<
"HangingType " << hangingNodeType <<
" not implemented " << std::endl;
1716 caseL = this->transmissibilityAdapter_(isIt, interactionVolume, subVolumeFaceIdx,
1717 properFluxDirection, additional2, additional3, additionalT);
1723 problem().variables().storeMpfaData3D(intersection, additionalT,
1724 additional2.geometry().center(), problem().variables().index(additional2),
1725 additional3.geometry().center(), problem().variables().index(additional3),
1727 countInteractionRegions++;
1731 if(maxInteractionVolumes>2)
1734 std::vector<int> diagonal;
1735 for(
int verticeSmall = 0; verticeSmall < intersection.outside().subEntities(dim); ++verticeSmall)
1737 auto vSmall = intersection.outside().template subEntity<dim>(verticeSmall);
1741 if (problem().gridView().comm().size() > 1)
1742 if(vSmall.partitionType() != Dune::InteriorEntity)
1747 GlobalPosition vertexOnElement
1748 = referenceElement.position(verticeSmall, dim);
1750 for (
int indexOnFace = 0; indexOnFace < 4; indexOnFace++)
1753 GlobalPosition vertexOnInterface
1754 = intersection.geometryInOutside().corner(indexOnFace);
1756 if(vSmall != outerCorner
1757 && ((vertexOnInterface - vertexOnElement).two_norm()<1e-5))
1759 int vIdxGlobal2 = problem().variables().index(vSmall);
1761 InteractionVolume& interactionVolume2
1762 = interactionVolumesContainer_->interactionVolume(vIdxGlobal2);
1763 if(interactionVolume2.isBoundaryInteractionVolume())
1766 int hangingNodeType = interactionVolume2.getHangingNodeType();
1768 properFluxDirection =
true;
1770 if(hangingNodeType != InteractionVolume::fourSmallCellsFace)
1772 diagonal.push_back(problem().variables().index(vSmall));
1774 if(hangingNodeType == InteractionVolume::noHangingNode)
1777 Dune::dgrave <<
" args, noHangingNode on additional interaction region";
1780 else if(hangingNodeType == InteractionVolume::sixSmallCells)
1781 subVolumeFaceIdx = interactionVolumesContainer_->getMpfaCase6cells(isIt,
1782 interactionVolume2, properFluxDirection);
1784 subVolumeFaceIdx = interactionVolumesContainer_->getMpfaCase2or4cells(isIt,
1785 interactionVolume2, properFluxDirection);
1788 caseL = this->transmissibilityAdapter_(isIt, interactionVolume2, subVolumeFaceIdx,
1789 properFluxDirection, additional2, additional3, additionalT);
1795 problem().variables().storeMpfaData3D(intersection, additionalT,
1796 additional2.geometry().center(), problem().variables().index(additional2),
1797 additional3.geometry().center(), problem().variables().index(additional3),
1798 countInteractionRegions);
1799 countInteractionRegions++;
1809 problem().variables().storeMpfaData3D(intersection, T, globalPos4, eIdxGlobal4, globalPos6, eIdxGlobal6);
1812 Scalar weight = intersection.geometry().volume()/subFaceArea12;
1813 weight /=
static_cast<Scalar
>(countInteractionRegions);
1816 problem().variables().performTransmissitivityWeighting(intersection, weight);
1818 return countInteractionRegions;
1841template<
class TypeTag>
1843 InteractionVolume& interactionVolume,
1844 const int& subVolumeFaceIdx,
1845 bool properFluxDirection,
1846 Element& additional2,
1847 Element& additional3,
1848 TransmissivityMatrix& additionalT)
1851 if(interactionVolume.isBoundaryInteractionVolume())
1855 int hangingNodeType = interactionVolume.getHangingNodeType();
1858 Dune::FieldMatrix<Scalar, dim, 2 * dim - dim + 1> T(0);
1860 Dune::FieldVector<Scalar, dim> unity(1.);
1861 std::vector<Dune::FieldVector<Scalar, dim> > lambda
1862 = {unity, unity, unity, unity, unity, unity, unity, unity};
1863 Dune::FieldVector<bool, 4> useCases(
false);
1866 switch(subVolumeFaceIdx)
1869 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
1870 lambda, 0, 1, 2, 3, 4, 5);
1878 additional2 = interactionVolume.getSubVolumeElement(2);
1879 additional3 = interactionVolume.getSubVolumeElement(4);
1882 additional2 = interactionVolume.getSubVolumeElement(3);
1883 additional3 = interactionVolume.getSubVolumeElement(5);
1886 additional2 = interactionVolume.getSubVolumeElement(3);
1887 additional3 = interactionVolume.getSubVolumeElement(4);
1890 additional2 = interactionVolume.getSubVolumeElement(2);
1891 additional3 = interactionVolume.getSubVolumeElement(5);
1898 if (hangingNodeType == InteractionVolume::twoSmallCells
1899 || hangingNodeType == InteractionVolume::fourSmallCellsDiag )
1902 useCases[1] =
false;
1903 useCases[2] =
false;
1904 if(hangingNodeType != InteractionVolume::twoSmallCells)
1906 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
1907 lambda, 1, 3, 0, 2, 5, 7, useCases);
1910 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
1911 lambda, 1, 3, 0, 2, 5, 7);
1920 additional2 = interactionVolume.getSubVolumeElement(0);
1921 additional3 = interactionVolume.getSubVolumeElement(5);
1925 additional2 = interactionVolume.getSubVolumeElement(2);
1926 additional3 = interactionVolume.getSubVolumeElement(7);
1930 additional2 = interactionVolume.getSubVolumeElement(2);
1931 additional3 = interactionVolume.getSubVolumeElement(5);
1935 additional2 = interactionVolume.getSubVolumeElement(0);
1936 additional3 = interactionVolume.getSubVolumeElement(7);
1944 assert (hangingNodeType != InteractionVolume::twoSmallCells
1945 && hangingNodeType != InteractionVolume::fourSmallCellsDiag);
1947 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
1948 lambda, 3, 2, 1, 0, 7, 6);
1957 additional2 = interactionVolume.getSubVolumeElement(1);
1958 additional3 = interactionVolume.getSubVolumeElement(7);
1962 additional2 = interactionVolume.getSubVolumeElement(0);
1963 additional3 = interactionVolume.getSubVolumeElement(6);
1967 additional2 = interactionVolume.getSubVolumeElement(0);
1968 additional3 = interactionVolume.getSubVolumeElement(7);
1972 additional2 = interactionVolume.getSubVolumeElement(1);
1973 additional3 = interactionVolume.getSubVolumeElement(6);
1980 if (hangingNodeType == InteractionVolume::twoSmallCells
1981 || hangingNodeType == InteractionVolume::fourSmallCellsDiag)
1983 useCases[0] =
false;
1985 if(hangingNodeType != InteractionVolume::twoSmallCells)
1987 useCases[3] =
false;
1988 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T,
1989 interactionVolume, lambda, 2, 0, 3, 1, 6, 4, useCases);
1992 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
1993 lambda, 2, 0, 3, 1, 6, 4);
2002 additional2 = interactionVolume.getSubVolumeElement(3);
2003 additional3 = interactionVolume.getSubVolumeElement(6);
2007 additional2 = interactionVolume.getSubVolumeElement(1);
2008 additional3 = interactionVolume.getSubVolumeElement(4);
2012 additional2 = interactionVolume.getSubVolumeElement(1);
2013 additional3 = interactionVolume.getSubVolumeElement(6);
2017 additional2 = interactionVolume.getSubVolumeElement(3);
2018 additional3 = interactionVolume.getSubVolumeElement(4);
2025 if (hangingNodeType == InteractionVolume::fourSmallCellsEdge)
2027 assert(problem().variables().index(interactionVolume.getSubVolumeElement(4))
2028 != problem().variables().index(interactionVolume.getSubVolumeElement(5)));
2029 Dune::dgrave <<
" SubVolumeFace4 in hanging node type 3 should be modelled by"
2030 <<
" Tpfa!!" <<std::endl;
2034 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2035 lambda, 5, 4, 7, 6, 1, 0);
2043 additional2 = interactionVolume.getSubVolumeElement(7);
2044 additional3 = interactionVolume.getSubVolumeElement(1);
2047 additional2 = interactionVolume.getSubVolumeElement(6);
2048 additional3 = interactionVolume.getSubVolumeElement(0);
2051 additional2 = interactionVolume.getSubVolumeElement(6);
2052 additional3 = interactionVolume.getSubVolumeElement(1);
2055 additional2 = interactionVolume.getSubVolumeElement(7);
2056 additional3 = interactionVolume.getSubVolumeElement(0);
2063 if (hangingNodeType == InteractionVolume::fourSmallCellsEdge)
2065 assert (problem().variables().index(interactionVolume.getSubVolumeElement(4))
2066 != problem().variables().index(interactionVolume.getSubVolumeElement(6)));
2067 Dune::dgrave <<
" SubVolumeFace5 in hanging node type 3 should be modelled by"
2068 <<
" Tpfa!!" <<std::endl;
2071 else if (hangingNodeType == InteractionVolume::sixSmallCells)
2073 useCases[0] =
false;
2076 useCases[3] =
false;
2078 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2079 lambda, 7, 5, 6, 4, 3, 1, useCases);
2081 else if (hangingNodeType == InteractionVolume::fourSmallCellsDiag)
2084 useCases[1] =
false;
2085 useCases[2] =
false;
2087 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2088 lambda, 7, 5, 6, 4, 3, 1, useCases);
2091 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2092 lambda, 7, 5, 6, 4, 3, 1);
2101 additional2 = interactionVolume.getSubVolumeElement(6);
2102 additional3 = interactionVolume.getSubVolumeElement(3);
2106 additional2 = interactionVolume.getSubVolumeElement(4);
2107 additional3 = interactionVolume.getSubVolumeElement(1);
2111 additional2 = interactionVolume.getSubVolumeElement(4);
2112 additional3 = interactionVolume.getSubVolumeElement(3);
2116 additional2 = interactionVolume.getSubVolumeElement(6);
2117 additional3 = interactionVolume.getSubVolumeElement(1);
2124 if (hangingNodeType == InteractionVolume::fourSmallCellsEdge)
2126 assert (problem().variables().index(interactionVolume.getSubVolumeElement(4))
2127 != problem().variables().index(interactionVolume.getSubVolumeElement(5)));
2128 Dune::dgrave <<
" SubVolumeFace6 in hanging node type 3 should be modelled by"
2129 <<
" Tpfa!!" <<std::endl;
2133 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2134 lambda, 6, 7, 4, 5, 2, 3);
2143 additional2 = interactionVolume.getSubVolumeElement(4);
2144 additional3 = interactionVolume.getSubVolumeElement(2);
2148 additional2 = interactionVolume.getSubVolumeElement(5);
2149 additional3 = interactionVolume.getSubVolumeElement(3);
2153 additional2 = interactionVolume.getSubVolumeElement(5);
2154 additional3 = interactionVolume.getSubVolumeElement(2);
2158 additional2 = interactionVolume.getSubVolumeElement(4);
2159 additional3 = interactionVolume.getSubVolumeElement(3);
2167 if (hangingNodeType == InteractionVolume::fourSmallCellsEdge)
2169 assert (problem().variables().index(interactionVolume.getSubVolumeElement(4))
2170 != problem().variables().index(interactionVolume.getSubVolumeElement(6)));
2171 Dune::dgrave <<
" SubVolumeFace5 in hanging node type 3 should be modelled by"
2172 <<
" Tpfa!!" <<std::endl;
2175 else if (hangingNodeType == InteractionVolume::sixSmallCells)
2178 useCases[1] =
false;
2179 useCases[2] =
false;
2182 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2183 lambda, 4, 6, 5, 7, 0, 2, useCases);
2185 else if (hangingNodeType == InteractionVolume::fourSmallCellsDiag)
2187 useCases[0] =
false;
2190 useCases[3] =
false;
2191 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2192 lambda, 4, 6, 5, 7, 0, 2, useCases);
2195 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2196 lambda, 4, 6, 5, 7, 0, 2);
2205 additional2 = interactionVolume.getSubVolumeElement(5);
2206 additional3 = interactionVolume.getSubVolumeElement(0);
2210 additional2 = interactionVolume.getSubVolumeElement(7);
2211 additional3 = interactionVolume.getSubVolumeElement(2);
2215 additional2 = interactionVolume.getSubVolumeElement(7);
2216 additional3 = interactionVolume.getSubVolumeElement(0);
2220 additional2 = interactionVolume.getSubVolumeElement(5);
2221 additional3 = interactionVolume.getSubVolumeElement(2);
2229 if(hangingNodeType == InteractionVolume::noHangingNode
2230 || hangingNodeType == InteractionVolume::sixSmallCells)
2232 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2233 lambda, 4, 0, 6, 2, 5, 1);
2235 else if (hangingNodeType == InteractionVolume::twoSmallCells
2236 || hangingNodeType == InteractionVolume::fourSmallCellsFace)
2238 caseL = mpfal3DTransmissibilityCalculator_.transmissibilityCaseTwo(T, interactionVolume,
2239 lambda, 4, 0, 2, 1);
2241 else if (hangingNodeType == InteractionVolume::fourSmallCellsDiag
2242 || (hangingNodeType == InteractionVolume::fourSmallCellsEdge
2243 && (problem().variables().index(interactionVolume.getSubVolumeElement(4))
2244 != problem().variables().index(interactionVolume.getSubVolumeElement(6)))) )
2246 useCases[0] =
false;
2248 useCases[2] =
false;
2251 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2252 lambda, 4, 0, 6, 2, 5, 1, useCases);
2254 else if (hangingNodeType == InteractionVolume::fourSmallCellsEdge)
2256 useCases[0] =
false;
2259 useCases[3] =
false;
2261 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2262 lambda, 4, 0, 6, 2, 5, 1, useCases);
2272 additional2 = interactionVolume.getSubVolumeElement(6);
2273 additional3 = interactionVolume.getSubVolumeElement(5);
2277 additional2 = interactionVolume.getSubVolumeElement(2);
2278 additional3 = interactionVolume.getSubVolumeElement(1);
2282 additional2 = interactionVolume.getSubVolumeElement(2);
2283 additional3 = interactionVolume.getSubVolumeElement(5);
2287 additional2 = interactionVolume.getSubVolumeElement(6);
2288 additional3 = interactionVolume.getSubVolumeElement(1);
2296 if(hangingNodeType == InteractionVolume::noHangingNode
2297 || hangingNodeType == InteractionVolume::sixSmallCells)
2299 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2300 lambda, 1, 5, 3, 7, 0, 4);
2302 else if (hangingNodeType == InteractionVolume::twoSmallCells || hangingNodeType == InteractionVolume::fourSmallCellsFace)
2304 caseL = mpfal3DTransmissibilityCalculator_.transmissibilityCaseOne(T, interactionVolume,
2305 lambda, 1, 5, 3, 0);
2307 else if (hangingNodeType == InteractionVolume::fourSmallCellsDiag
2308 || (hangingNodeType == InteractionVolume::fourSmallCellsEdge
2309 &&(problem().variables().index(interactionVolume.getSubVolumeElement(4))
2310 != problem().variables().index(interactionVolume.getSubVolumeElement(6))) ))
2313 useCases[1] =
false;
2315 useCases[3] =
false;
2317 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2318 lambda, 1, 5, 3, 7, 0, 4, useCases);
2320 else if (hangingNodeType == InteractionVolume::fourSmallCellsEdge
2321 &&(problem().variables().index(interactionVolume.getSubVolumeElement(4))
2322 != problem().variables().index(interactionVolume.getSubVolumeElement(5))) )
2325 useCases[1] =
false;
2326 useCases[2] =
false;
2329 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2330 lambda, 1, 5, 3, 7, 0, 4, useCases);
2333 Dune::dgrave <<
" Missing case for subVolFaceIdx 9!!" <<std::endl;
2342 additional2 = interactionVolume.getSubVolumeElement(3);
2343 additional3 = interactionVolume.getSubVolumeElement(0);
2347 additional2 = interactionVolume.getSubVolumeElement(7);
2348 additional3 = interactionVolume.getSubVolumeElement(4);
2352 additional2 = interactionVolume.getSubVolumeElement(7);
2353 additional3 = interactionVolume.getSubVolumeElement(0);
2357 additional2 = interactionVolume.getSubVolumeElement(3);
2358 additional3 = interactionVolume.getSubVolumeElement(4);
2366 if (hangingNodeType == InteractionVolume::fourSmallCellsFace)
2367 caseL = mpfal3DTransmissibilityCalculator_.transmissibilityCaseTwo(T, interactionVolume,
2368 lambda, 7, 3, 1, 2);
2369 else if ((hangingNodeType == InteractionVolume::fourSmallCellsEdge
2370 &&(problem().variables().index(interactionVolume.getSubVolumeElement(4))
2371 != problem().variables().index(interactionVolume.getSubVolumeElement(6))) )
2372 || hangingNodeType == InteractionVolume::sixSmallCells)
2374 useCases[0] =
false;
2376 useCases[2] =
false;
2379 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2380 lambda, 7, 3, 5, 1, 6, 2, useCases);
2382 else if (hangingNodeType == InteractionVolume::fourSmallCellsEdge)
2384 useCases[0] =
false;
2387 useCases[3] =
false;
2389 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2390 lambda, 7, 3, 5, 1, 6, 2, useCases);
2392 else if (hangingNodeType == InteractionVolume::fourSmallCellsDiag)
2395 useCases[1] =
false;
2397 useCases[3] =
false;
2399 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2400 lambda, 7, 3, 5, 1, 6, 2, useCases);
2403 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2404 lambda, 7, 3, 5, 1, 6, 2);
2413 additional2 = interactionVolume.getSubVolumeElement(5);
2414 additional3 = interactionVolume.getSubVolumeElement(6);
2418 additional2 = interactionVolume.getSubVolumeElement(1);
2419 additional3 = interactionVolume.getSubVolumeElement(2);
2423 additional2 = interactionVolume.getSubVolumeElement(1);
2424 additional3 = interactionVolume.getSubVolumeElement(6);
2428 additional2 = interactionVolume.getSubVolumeElement(5);
2429 additional3 = interactionVolume.getSubVolumeElement(2);
2437 if(!interactionVolume.isHangingNodeVolume())
2438 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2439 lambda, 2, 6, 0, 4, 3, 7);
2440 else if (hangingNodeType == InteractionVolume::fourSmallCellsFace)
2441 caseL = mpfal3DTransmissibilityCalculator_.transmissibilityCaseOne(T, interactionVolume,
2442 lambda, 2, 6, 0, 3);
2443 else if ((hangingNodeType == InteractionVolume::fourSmallCellsEdge
2444 && (problem().variables().index(interactionVolume.getSubVolumeElement(4))
2445 != problem().variables().index(interactionVolume.getSubVolumeElement(6))))
2446 || hangingNodeType == InteractionVolume::sixSmallCells)
2449 useCases[1] =
false;
2451 useCases[3] =
false;
2453 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2454 lambda, 2, 6, 0, 4, 3, 7, useCases);
2456 else if (hangingNodeType == InteractionVolume::fourSmallCellsEdge
2457 && (problem().variables().index(interactionVolume.getSubVolumeElement(4))
2458 != problem().variables().index(interactionVolume.getSubVolumeElement(5))) )
2461 useCases[1] =
false;
2462 useCases[2] =
false;
2465 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2466 lambda, 2, 6, 0, 4, 3, 7, useCases);
2468 else if (hangingNodeType == InteractionVolume::fourSmallCellsDiag)
2470 useCases[0] =
false;
2472 useCases[2] =
false;
2475 caseL = mpfal3DTransmissibilityCalculator_.transmissibility(T, interactionVolume,
2476 lambda, 2, 6, 0, 4, 3, 7, useCases);
2486 additional2 = interactionVolume.getSubVolumeElement(0);
2487 additional3 = interactionVolume.getSubVolumeElement(3);
2491 additional2 = interactionVolume.getSubVolumeElement(4);
2492 additional3 = interactionVolume.getSubVolumeElement(7);
2496 additional2 = interactionVolume.getSubVolumeElement(4);
2497 additional3 = interactionVolume.getSubVolumeElement(3);
2501 additional2 = interactionVolume.getSubVolumeElement(0);
2502 additional3 = interactionVolume.getSubVolumeElement(7);
2509 if(!properFluxDirection)
2516 swap(additionalT[0], additionalT[1]);
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
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type GetProp
get the type of a property (equivalent to old macro GET_PROP(...))
Definition: propertysystem.hh:140
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:149
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: vectorcommdatahandle.hh:79
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:80
void update()
Definition: fv3dpressureadaptive.hh:163
void adaptPressure()
Adapt primary variables vector after adapting the grid.
Definition: fv3dpressureadaptive.hh:214
bool enableMPFA
Enables mpfa on hanging nodes (on by default)
Definition: fv3dpressureadaptive.hh:303
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:1842
void initializeMatrix()
initializes the matrix to store the system of equations
Definition: fv3dpressureadaptive.hh:314
void initializeMatrixRowSize()
Initialize the row sizes of the sparse global matrix.
Definition: fv3dpressureadaptive.hh:330
FvMpfaL3dTransmissibilityCalculator< TypeTag > mpfal3DTransmissibilityCalculator_
The common implementation to calculate the Transmissibility with the mpfa-L-method.
Definition: fv3dpressureadaptive.hh:309
bool enableVolumeIntegral_
Calculates the volume integral (on by default)
Definition: fv3dpressureadaptive.hh:302
void initializeMatrixIndices()
Determine position of matrix entries.
Definition: fv3dpressureadaptive.hh:579
int computeTransmissibilities(const IntersectionIterator &, TransmissivityMatrix &, GlobalPosition &, int &, GlobalPosition &, int &)
Computes the transmissibility coefficients for the MPFA-l method in 3D.
Definition: fv3dpressureadaptive.hh:1349
void getMpfaFlux(const IntersectionIterator &, const CellData &)
Compute flux through an irregular interface using a mpfa method.
Definition: fv3dpressureadaptive.hh:805
void assemble(bool first)
function which assembles the system of equations to be solved
Definition: fv3dpressureadaptive.hh:644
FV3dPressure2P2CAdaptive(Problem &problem)
Constructs a FVPressure2P2C object.
Definition: fv3dpressureadaptive.hh:249
std::map< int, std::vector< int > > irregularCellMap_
Container to store all cell's Indice with a hanging node.
Definition: fv3dpressureadaptive.hh:301
void initialize(bool solveTwice=false)
Definition: fv3dpressureadaptive.hh:183
void get1pMpfaFlux(const IntersectionIterator &, const CellData &)
Compute single-phase flux through an irregular interface using a mpfa method.
Definition: fv3dpressureadaptive.hh:1142
InteractionVolumeContainer * interactionVolumesContainer_
A pointer to the adaptive interaction volumes container.
Definition: fv3dpressureadaptive.hh:307
void updateMaterialLaws(bool fromPostTimestep=false)
Definition: fv3dpressureadaptive.hh:1295
int maxInteractionVolumes
Maximum number of interaction volumes considered (4 by default)
Definition: fv3dpressureadaptive.hh:304
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
Type of the data container for one interaction volume.
Definition: porousmediumflow/sequential/cellcentered/mpfa/properties.hh:102
Type of the data container for one interaction volume.
Definition: porousmediumflow/sequential/cellcentered/mpfa/properties.hh:104
The finite volume base class for the solution of a pressure equation.
Definition: sequential/cellcentered/pressure.hh:49
void initialize()
Initialize pressure model.
Definition: sequential/cellcentered/pressure.hh:213
PressureSolution & pressure()
Returns the vector containing the pressure solution.
Definition: sequential/cellcentered/pressure.hh:120
@ rhs
index for the right hand side entry
Definition: sequential/cellcentered/pressure.hh:88
@ matrix
index for the global matrix entry
Definition: sequential/cellcentered/pressure.hh:89
Properties for a MPFA method.