MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
fvmbcartesiansolverxd.h
Go to the documentation of this file.
1// Copyright (C) 2024 The m-AIA AUTHORS
2//
3// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
4//
5// SPDX-License-Identifier: LGPL-3.0-only
6
7#ifndef FVMBCARTESIANSOLVERXD_H
8#define FVMBCARTESIANSOLVERXD_H
9
10#include <algorithm>
11#include <map>
12#include <random>
13#include <set>
14#include <unordered_map>
15#include <utility>
16#include <vector>
19#include "GRID/partition.h"
20#include "UTIL/kdtree.h"
21#include "UTIL/pointbox.h"
23#include "fvcartesiansolverxd.h"
24
25//#include "/pds/opt/fftw-3.3.4-mpi/include/fftw3-mpi.h"
26
27#ifndef MAIA_MS_COMPILER
28#include <netdb.h>
29#include <sys/socket.h>
30#endif
31
32#define FINITE_VOLUME_METHOD
34#undef FINITE_VOLUME_METHOD
35
36#ifndef MB_EXTRA_STUFF_
37#define MB_EXTRA_STUFF_
38//#define DEBUG(a,b) {if((globalTimeStep%100==0)||(globalTimeStep%100==99)){if(b==16)m_log << "in:
39//"<< a<<endl; else if(b==32)m_log << "out: "<< a<<endl;}} #define DEBUG(a,b) {if(b==16)m_log <<
40//"in: "<< a<<endl; else if(b==32)m_log << "out: "<< a<<endl;} #define DEBUG(a,b) {if(b==16){cerr
41//<< "in: "<<g_domainId<<" "<<a<<endl;cerr.flush();}else if(b==32){cerr << "out: "<<g_domainId<<"
42//"<< a<<endl;cerr.flush();}} #define DEBUG_LOG(a) {m_log << a << endl;}
43#define DEBUG_LOG(a)
44
45const MInt m_revDir[6] = {1, 0, 3, 2, 5, 4};
46
47#endif
48
49template <MInt nDim, class SysEqn>
51
52template <MInt nDim, class SysEqn>
53class FvMbCartesianSolverXD : public FvCartesianSolverXD<nDim, SysEqn> {
54 public:
59 using Base::a_bndryId;
66 using Base::a_isHalo;
68 using Base::a_isWindow;
69 using Base::a_level;
71 using Base::a_noCells;
78 using Base::a_slope;
90 using Base::a_variable;
95 using Base::c_childId;
96 using Base::c_globalId;
100 using Base::c_noCells;
101 using Base::c_noChildren;
102 using Base::c_parentId;
108 using Base::CV;
109 using Base::domainId;
110 using Base::entropy;
111 using Base::exchangeData;
114 using Base::findNghbrIds;
115 using Base::FV;
118 using Base::grid;
119 using Base::haloCellId;
122 using Base::isActive;
123 using Base::isMultilevel;
127 using Base::m_adaptation;
130 using Base::m_bndryCells;
137 using Base::m_bodyCenter;
142 using Base::m_cells;
144 using Base::m_cfl;
145 using Base::m_chi;
146 using Base::m_closeGaps;
150 using Base::m_DInfinity;
154 using Base::m_eps;
155 using Base::m_euler;
156 using Base::m_gamma;
157 using Base::m_gapCellId;
158 using Base::m_gapCells;
160 using Base::m_geometry;
162 using Base::m_hInfinity;
167 using Base::m_levelSet;
169 using Base::m_levelSetMb;
173 using Base::m_LsRotate;
174 using Base::m_Ma;
180 using Base::m_noDirs;
186 using Base::m_noRKSteps;
187 using Base::m_noSets;
188 using Base::m_noSpecies;
197 using Base::m_PInfinity;
198 using Base::m_pipeRadius;
199 using Base::m_Pr;
200 using Base::m_Re;
204 using Base::m_restart;
210 using Base::m_rhs0;
211 using Base::m_SInfinity;
215 using Base::m_solverId;
216 using Base::m_splitCells;
225 using Base::m_surfaces;
227 using Base::m_sysEqn;
228 using Base::m_time;
229 using Base::m_timeRef;
231 using Base::m_UInfinity;
233 using Base::m_VInfinity;
237 using Base::m_VVInfinity;
238 using Base::m_wasAdapted;
246 using Base::m_WInfinity;
249 using Base::minLevel;
250 using Base::mpiComm;
251 using Base::noDomains;
252 using Base::noHaloLayers;
255 using Base::PV;
260 using Base::sysEqn;
261 using Base::timeStep;
262
273 using Base::a_wasGapCell;
277 using Base::c_coordinate;
278 using Base::c_level;
279 using Base::checkCells;
286 using Base::computePV;
292 using Base::domainOffset;
293 using Base::exchangeAll;
298 using Base::getVorticity;
305 using Base::m_A;
310 using Base::m_angle;
326 using Base::m_bandWidth;
337 using Base::m_forcing;
338 using Base::m_gridPoints;
349 using Base::m_maxNoSets;
351 using Base::m_multilevel;
355 using Base::m_noCorners;
356 using Base::m_noEdges;
361 using Base::m_noSamples;
364 using Base::m_recalcIds;
378 using Base::m_revDir;
381 using Base::m_RKalpha;
382 using Base::m_RKStep;
439 using Base::m_timerGroup;
440 using Base::m_timers;
441 using Base::m_TInfinity;
457 using Base::maxLevel;
459 using Base::minCell;
461 using Base::noHaloCells;
462 using Base::noMinCells;
463 using Base::noVariables;
465 using Base::outputDir;
467 using Base::reduceData;
469 using Base::restartDir;
473 using Base::setTimeStep;
475 using Base::solverId;
477 using Base::windowCellId;
479
481
485
487 using Base::m_localTS;
490
491 //================================== WMLES ======================================
492 using Base::m_wmDistance;
493 using Base::m_wmDomainId;
495 using Base::m_wmLES;
497 using Base::m_wmOutput;
500
501 using Base::m_wmIterator;
502
503 using Base::m_comm_wm;
504
516 using Base::m_wmSurfaces;
517
521
524
527
528 // zonal method
532 using Base::m_LESValues;
537 using Base::m_RANSValues;
538 using Base::m_zonal;
542
545 std::vector<Point<nDim>> m_bodyCenters;
546 std::vector<Point<nDim>> m_bodyCentersLocal;
547
550 const MPI_Comm comm);
551 ~FvMbCartesianSolverXD() override;
552
553
554 // destructor / constructor
557 void allocateBodyMemory(MInt mode = 0);
558
559 template <class X = void, std::enable_if_t<nDim == 2, X*> = nullptr>
560 static MInt locatenear(const Point<nDim>& /*pt*/, MFloat /*r*/, MInt* /*list*/, MInt /*nmax*/,
561 MBool returnCellId = true) {
562 std::ignore = returnCellId;
563 return 0;
564 }
565
566 template <class X = void, std::enable_if_t<nDim == 3, X*> = nullptr>
567 MInt locatenear(const Point<nDim>& pt, MFloat r, MInt* list, MInt nmax, MBool returnCellId = true) {
568 return m_bodyTree->locatenear(pt, r, &list[0], nmax, returnCellId);
569 }
570
571 std::vector<MFloat> m_oldBodyPosition;
572
573 std::vector<MFloat> m_movingPosDiff;
574
577
578 // settings
622
625
630
631 std::map<MInt, MFloat> m_oldGeomBndryCells;
633
634 // Gap-Handling
635 std::vector<MInt>* m_gapWindowCells = nullptr;
636 std::vector<MInt>* m_gapHaloCells = nullptr;
640 MInt* m_gapState = nullptr;
641
642
643 // offsets & counters
670 // MInt m_noSets{};
673
674 // constants and pseudo constants
675 const clock_t m_t0;
676 static constexpr MFloat FD = nDim;
677 static constexpr MInt m_noCellNodes = IPOW2(nDim);
689 MFloat* m_gravity = nullptr;
690
691 // body properties
695 MFloat* m_bodyRadii = nullptr;
698 MFloat* m_bodyMass = nullptr;
704 MFloat** m_coupling = nullptr;
719 MFloat* m_bodyForce = nullptr;
739
741
742 // Lagrange particles
746 std::vector<MFloat> m_particleCoords;
747 std::vector<MFloat> m_particleCoordsDt1;
748 std::vector<MFloat> m_particleCoordsInitial;
749 std::vector<MFloat> m_particleVelocity;
750 std::vector<MFloat> m_particleTemperature;
751 std::vector<MFloat> m_particleTemperatureDt1;
752 std::vector<MFloat> m_particleHeatFlux;
753 std::vector<MFloat> m_particleVelocityDt1;
754 std::vector<MFloat> m_particleVelocityFluid;
755 std::vector<MFloat> m_particleFluidTemperature;
756 std::vector<MFloat> m_particleAcceleration;
757 std::vector<MFloat> m_particleAccelerationDt1;
758 std::vector<MFloat> m_particleQuaternions;
759 std::vector<MFloat> m_particleQuaternionsDt1;
760 std::vector<MFloat> m_particleAngularVelocity;
761 std::vector<MFloat> m_particleAngularVelocityDt1;
763 std::vector<MFloat> m_particleAngularAcceleration;
765 std::vector<MFloat> m_particleShapeParams;
766 std::vector<MFloat> m_particleRadii;
767 std::vector<MInt> m_particleCellLink;
768 std::vector<MInt> m_particleGlobalId;
769 std::vector<MInt>* m_periodicGhostBodies = nullptr;
770 std::set<MInt> m_bodyWasInCollision;
772
773 // collectors
774 std::vector<MInt> m_bndryCandidates;
775 std::vector<CutCandidate<nDim>> m_cutCandidates;
776 std::vector<MInt> m_bndryCandidateIds;
778 std::vector<MInt> m_azimuthalBndryCandidates;
780 std::vector<MFloat> m_candidateNodeValues;
781 std::vector<MInt> m_candidateNodeSet;
782 std::vector<MInt> m_bndryLayerCells;
791 // MFloat* m_sweptVolume = nullptr;
793 MFloat** m_rhsViscous = nullptr;
794 std::vector<MInt>* m_linkedWindowCells = nullptr;
795 std::vector<MInt>* m_linkedHaloCells = nullptr;
796
808 MFloat* m_bbox = nullptr;
809 MFloat* m_bboxLocal = nullptr;
810 MInt* m_nghbrList = nullptr;
811 // MInt* m_periodicDir;
812 MPI_Request* g_mpiRequestMb = nullptr;
815 std::set<MInt> m_freeSurfaceIndices;
816
817 std::map<MInt, MFloat> m_oldBndryCells;
818 std::map<MInt, std::vector<MFloat>> m_nearBoundaryBackup;
819 std::vector<std::tuple<MInt, MInt, MInt>> m_temporarilyLinkedCells;
820 std::vector<MInt> m_massRedistributionIds;
821 std::vector<MFloat> m_massRedistributionVariables;
822 std::vector<MFloat> m_massRedistributionRhs;
823 std::vector<MFloat> m_massRedistributionVolume;
824 std::vector<MFloat> m_massRedistributionSweptVol;
825 std::vector<MInt> m_refOldBndryCells;
826 std::set<MInt> m_coarseOldBndryCells;
827
828 std::vector<std::vector<MInt>> m_azimuthalLinkedHaloCells;
829 std::vector<std::vector<MInt>> m_azimuthalLinkedWindowCells;
830 std::multimap<MLong, std::pair<std::vector<MFloat>, std::vector<MUlong>>> m_azimuthalNearBoundaryBackup;
831 std::vector<MInt> m_azimuthalWasNearBndryIds;
838 const MFloat m_azimuthalCornerEps = 0.01; // Used to determine if recCoords match
839
840 // array pointers
841 MFloat* m_slope = nullptr;
842 MFloat* m_area = nullptr;
847 MFloat* m_vars = nullptr;
848 MFloat* m_oldVars = nullptr;
849
850 // post processing
852 static constexpr MInt m_noMeanStatistics = 6;
853 static constexpr MFloat m_distThresholdStat[m_noMeanStatistics] = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0};
857 static constexpr MInt m_noAngleSetups = 3;
858 static constexpr MInt m_noDistSetups = 3;
863 std::vector<MInt> m_particleOffsets;
877 std::vector<MFloat> m_slipDataTimeSteps;
878
879 // timw-engine specific:
882 MFloat* m_gapSign = nullptr;
884
885
886 // global functions
888 void writeListOfActiveFlowCells() override;
889 void setTimeStep() override;
890 void initSolver() override;
891 void finalizeInitSolver() override;
892 void initSolutionStep(MInt mode) override;
893 void reInitSolutionStep(const MInt mode);
895 void advanceSolution();
896 void advanceBodies();
897 void advanceTimeStep();
898 void prepareNextTimeStep() override;
900 void applyInitialCondition() override;
901 void applyExternalSource() override;
902 void applyExternalOldSource() override;
903 void advanceExternalSource() override;
904 MBool maxResidual(MInt mode = 0) override;
906
907 // initialisation
908 void initGField();
909 void initBndryLayer();
910
911 void updateGeometry();
912 void constructGField(MBool updateBody = true);
913 MInt constructDistance(const MFloat deltaMax, MIntScratchSpace& nearestBodies, MFloatScratchSpace& nearestDist);
917 void setParticleFluidVelocities(MFloat* = nullptr);
925 void transferBodyState(MInt k, MInt b);
927 template <class X = void, std::enable_if_t<nDim == 3, X*> = nullptr>
928 void createBodyTree();
929 template <class X = void, std::enable_if_t<nDim == 2, X*> = nullptr>
939 void getBodyRotation(const MInt bodyId, MFloat* bodyRotation);
940 void getBodyRotationDt1(const MInt bodyId, MFloat* bodyRotation);
941 void setBodyQuaternions(const MInt bodyId, MFloat* bodyRotation);
942
943 void setGapOpened();
944 void gapHandling();
945 void initGapCellExchange();
946 void gapCellExchange(MInt);
949 void checkGapCells();
952 void setGapCellId();
953
954 // boundary generation
955 void logBoundaryData(const MChar* fileName, MBool forceOutput);
956 void generateBndryCellsMb(const MInt mode);
957 void checkHaloBndryCells(MBool sweptVol);
961
964 void storeAzimuthalPeriodicData(MInt mode = 0);
965 void commAzimuthalPeriodicData(MInt mode = 0);
966 void computeAzimuthalReconstructionConstants(MInt mode = 0) override;
971 void exchangeAzimuthalOuterNodalValues(std::vector<CutCandidate<nDim>>& candidates, std::vector<MInt>& candidateIds);
972
975 template <class X = void, std::enable_if_t<nDim == 2, X*> = nullptr>
976 void createCutFaceMb_MGC();
977 template <class X = void, std::enable_if_t<nDim == 3, X*> = nullptr>
979 template <class X = void, std::enable_if_t<nDim == 3, X*> = nullptr>
980 void checkNormalVectors();
982 void computeGhostCellsMb();
986 void checkBoundaryCells();
987 void linkBndryCells();
988 void redistributeMass();
989 MInt createSplitCell(MInt cellId, MInt noSplitChilds);
994
995 void rebuildKDTreeLocal();
996 void rebuildKDTree();
997
998 // reinitialization routines
999 void resetSolverFull() override;
1000 void resetSolverMb();
1001 void resetSolver() override;
1002 void resetSurfaces() override;
1003 void balance(const MInt* const noCellsToReceiveByDomain, const MInt* const noCellsToSendByDomain,
1004 const MInt* const targetDomainsByCell, const MInt oldNoCells) override;
1005 void balancePre() override;
1006 void balancePost() override;
1007 void finalizeBalance() override;
1008
1009 MBool hasSplitBalancing() const override { return true; }
1010 void localToGlobalIds() override;
1011
1012 MInt noCellDataDlb() const override {
1013 if(grid().isActive()) {
1014 return CellDataDlb::count;
1015 } else {
1016 return 0;
1017 }
1018 };
1019 MInt cellDataTypeDlb(const MInt dataId) const override {
1020 MInt dataType = -1;
1021 if(dataId < CellDataDlb::count) {
1022 dataType = s_cellDataTypeDlb[dataId];
1023 } else {
1024 TERMM(1, "solverCelldataType: invalid data id " + std::to_string(dataId));
1025 }
1026 return dataType;
1027 };
1028 MInt cellDataSizeDlb(const MInt dataId, const MInt gridCellId) override;
1029
1031 void getCellDataDlb(const MInt dataId, const MInt oldNoCells, const MInt* const bufferIdToCellId,
1032 MFloat* const data) override;
1033 void getCellDataDlb(const MInt dataId, const MInt oldNoCells, const MInt* const bufferIdToCellId, MLong* const data);
1035 void setCellDataDlb(const MInt dataId, const MFloat* const data) override;
1036 void setCellDataDlb(const MInt dataId, const MLong* const data);
1037
1038 MBool adaptationTrigger() override;
1039 void resetMbBoundaryCells();
1040 void deleteNeighbourLinks();
1041 void restoreNeighbourLinks();
1043 void initEmergingGapCells();
1049 void computeVolumeFraction();
1050 void computeReconstructionConstants() override;
1051
1052 void prepareAdaptation() override;
1053 void setSensors(std::vector<std::vector<MFloat>>& sensors,
1054 std::vector<MFloat>& sensorWeight,
1055 std::vector<std::bitset<64>>& sensorCellFlag,
1056 std::vector<MInt>& sensorSolverId) override;
1057 void postAdaptation() override;
1058 void finalizeAdaptation() override;
1059 void sensorPatch(std::vector<std::vector<MFloat>>&, std::vector<std::bitset<64>>&, std::vector<MFloat>&, MInt,
1060 MInt) override;
1061
1062 void removeChilds(const MInt) override;
1063 void refineCell(const MInt) override;
1064 void setCellWeights(MFloat*) override;
1065 void descendLevelSetValue(const MInt cellId, const MInt* const bodyIds, const MInt bodyCnt);
1066 void descendDistance(const MInt cellId, const MInt* const bodyIds, const MInt bodyCnt,
1067 MIntScratchSpace& nearestBodies, MFloatScratchSpace& nearestDist);
1069 void swapCells(const MInt, const MInt) override;
1070 void moveSurface(const MInt toSrfcId, const MInt fromSrfcId);
1071 void compactSurfaces();
1073 void restoreSurfaces(const MInt cellId);
1074 void resetSurfaces(MInt cellId);
1075 void removeSurfaces(MInt cellId);
1076 void deleteSurface(MInt srfcId);
1077 void createSurface(MInt srfcId, MInt nghbrId0, MInt nghbrId1, MInt orientation);
1078 void createSurfaceSplit(MInt srfcId, MInt cellId, MInt splitChildId, MInt direction);
1081 void setCellProperties() override;
1082 static void setAdditionalCellProperties();
1085
1086 // surface generation
1087 void createInitialSrfcs();
1088 void correctSrfcsMb();
1089 void addBoundarySurfacesMb();
1090
1091 // MUSCL
1092 void Muscl(MInt timerId = -1) override;
1093 ATTRIBUTES1(ATTRIBUTE_HOT) void LSReconstructCellCenter() override;
1094 ATTRIBUTES1(ATTRIBUTE_HOT) void computeSurfaceValues(MInt timerId = -1) override;
1095 ATTRIBUTES1(ATTRIBUTE_HOT) void computeSurfaceValuesLimited(MInt timerId = -1) override;
1096
1097 // base solver
1098 ATTRIBUTES1(ATTRIBUTE_HOT) void Ausm() override;
1099 ATTRIBUTES1(ATTRIBUTE_HOT) void viscousFlux() override;
1100 ATTRIBUTES1(ATTRIBUTE_HOT) void resetRHS() override;
1101 ATTRIBUTES1(ATTRIBUTE_HOT) void distributeFluxToCells() override;
1102 void initializeRungeKutta() override;
1104 MBool rungeKuttaStep() override;
1106 template <MInt timeStepMethod>
1107 ATTRIBUTES1(ATTRIBUTE_HOT)
1108 MBool rungeKuttaStepStandard();
1109 template <MInt timeStepMethod>
1110 ATTRIBUTES1(ATTRIBUTE_HOT)
1111 MBool rungeKuttaStepNew();
1112 ATTRIBUTES1(ATTRIBUTE_HOT) MBool rungeKuttaStepNewLocalTimeStepping();
1114 void adaptTimeStep();
1115 void updateSplitParentVariables() override;
1116 void updateSpongeLayer() override;
1117 virtual void generateBndryCells();
1118 ATTRIBUTES1(ATTRIBUTE_HOT) void exchange() override;
1119 void initializeMaxLevelExchange() override;
1120 void updateMultiSolverInformation(MBool fullReset = false) override;
1121 void exchangeLevelSetData();
1122 void applyALECorrection();
1123 void resetRHSCutOffCells() override;
1124
1125 // boundary conditions
1126 void applyBoundaryCondition() override;
1132 void applyNeumannCondition();
1133 void setBoundaryVelocity();
1134 void copyVarsToSmallCells() override;
1136 void computeBodySurfaceData(MFloat* pressureForce = nullptr);
1137 void resetRHSNonInternalCells() override;
1138 void updateLinkedCells();
1139
1140 // input/output functions
1141 void saveSolverSolution(const MBool forceOutput = false, const MBool finalTimeStep = false) override;
1142 void recordBodyData(const MBool& firstRun);
1144 void writeStencil(const MInt bndryId);
1146 template <class X = void, std::enable_if_t<nDim == 2, X*> = nullptr>
1147 MInt writeGeometryToVtkXmlFile(const MString& fileName);
1148 template <class X = void, std::enable_if_t<nDim == 3, X*> = nullptr>
1149 static MInt writeGeometryToVtkXmlFile(const MString& fileName);
1150 void saveRestartFile(const MBool) override;
1151 void loadRestartFile() override;
1154 void saveBodyRestartFile(const MBool backup);
1155 void saveBodySamples();
1156 void saveParticleSamples();
1157 void writeVtkDebug(const MString suffix);
1158 template <class X = void, std::enable_if_t<nDim == 2, X*> = nullptr>
1159 void writeVtkXmlOutput(const MString& fileName, MBool debugOutput = false);
1160 template <class X = void, std::enable_if_t<nDim == 3, X*> = nullptr>
1161 void writeVtkXmlOutput(const MString& fileName, MBool debugOutput = false);
1162 template <class X = void, std::enable_if_t<nDim == 2, X*> = nullptr>
1163 void writeVtkXmlOutput_MGC(const MString& fileName);
1164 void writeVtkXmlFiles(const MString fileName, const MString GFileName, MBool regularOutput, MBool diverged) override;
1165 void writeVtkErrorFile();
1166 void printDynamicCoefficients(MBool firstRun, MFloat* pressureForce);
1167 std::vector<MInt> m_forceFVMBStatistics;
1168 void computeFlowStatistics(MBool force);
1169 void saveParticleSlipData();
1170 void computeSlipStatistics(const MIntScratchSpace& nearestBodies, const MFloatScratchSpace& nearestDist,
1171 const MFloat maxDistConstructed);
1172 void computeNearBodyFluidVelocity(const MIntScratchSpace& nearestBodies, const MFloatScratchSpace& nearestDist,
1173 MFloat* vel, MFloat* velGrad, MFloat* rotation,
1174 const std::vector<MFloat>& setup = std::vector<MFloat>(),
1175 MInt* skipBodies = nullptr, MFloat* meanBodyState = nullptr,
1176 MFloat* pressure = nullptr, MFloat* velDt = nullptr, MFloat* rotationDt = nullptr,
1177 MFloat* nearestFac = nullptr);
1179 void saveInitCorrData(const std::vector<MInt>& saveInitCorrDataTimeSteps, const MFloatScratchSpace& bodyVelocityInit,
1180 const MFloatScratchSpace& bodyAngularVelocityInit, const MFloatScratchSpace& bodyQuaternionInit,
1181 const MFloatScratchSpace& velMeanInit, const MFloatScratchSpace& velGradMeanInit,
1182 const MFloatScratchSpace& particleFluidRotationMeanInit, const MIntScratchSpace& corrBodies,
1183 const MFloatScratchSpace& bodyForceInit, const MFloatScratchSpace& bodyTorqueInit,
1184 const MIntScratchSpace& bodyOffsets);
1185 MInt loadInitCorrData(const std::vector<MInt>& saveInitCorrDataTimeSteps, MFloatScratchSpace& bodyVelocityInit,
1186 MFloatScratchSpace& bodyAngularVelocityInit, MFloatScratchSpace& bodyQuaternionInit,
1187 MFloatScratchSpace& velMeanInit, MFloatScratchSpace& velGradMeanInit,
1188 MFloatScratchSpace& particleFluidRotationMeanInit, MIntScratchSpace& corrBodies,
1189 MFloatScratchSpace& bodyForceInit, MFloatScratchSpace& bodyTorqueInit,
1190 const MIntScratchSpace& bodyOffsets);
1192 void writeCenterLineVel(const MChar* fileName);
1193 void readStlFile(const MChar* fileName, MBool readNormals);
1194 MBool prepareRestart(MBool, MBool&) override;
1195 void reIntAfterRestart(MBool) override;
1196
1197 // time-step and solution Step functions:
1198 void preTimeStep() override;
1199 void preSolutionStep(const MInt = -1) override;
1200 MBool solutionStep() override;
1201 MBool postSolutionStep() override;
1202 void postTimeStep() override;
1203 // postTimeStep is not overloaded from fv-cartesian-solver
1204
1205 // help functions
1206 void logOutput();
1207 void resetSlopes();
1208 void logData();
1209 MInt createBndryCellMb(MInt cellId);
1210 MInt getAdjacentCells(MInt cellId, MInt* adjacentCells);
1211 MInt getAdjacentGridCells(MInt cellId, MInt* adjacentCells);
1212 MInt getAdjacentCellsAllLevels(MInt cellId, MInt* adjacentCells);
1213 MInt getAdjacentCellsExtended(MInt cellId, MInt* adjacentCells);
1214 MInt getEqualLevelNeighbors(MInt cellId, MInt (&nghbrs)[27]);
1215 MInt broadcastSignal(const MInt sender, const MInt signal);
1216 inline MInt getFacingNghbrs(const MInt cellId, const MBool includeAllChilds);
1217 inline MFloat temperature(MInt cellId);
1218 static inline void crossProduct(MFloat* c, MFloat* a, MFloat* b);
1219 inline MFloat filterFloat(MFloat number);
1220 static inline MFloat CdLaw(MFloat Re) { return 24.0 * (F1 + (0.15 * pow(Re, 0.687))) / Re; }
1221 MBool gridPointIsInside(MInt, MInt) override;
1224 MInt inverseGJ();
1225 template <typename T>
1226 MBool isNan(T val);
1227
1228 MFloat getDistance(const MFloat* const, const MInt);
1229 MFloat getDistance(const MInt, const MInt);
1230 MFloat getDistanceSphere(const MFloat* const, const MInt);
1231 MFloat getDistanceSphere(const MInt, const MInt);
1232 MFloat getDistancePiston(const MFloat* const, const MInt);
1233 MFloat getDistancePiston(const MInt, const MInt);
1234 MFloat getDistanceEllipsoid(const MFloat* const, const MInt);
1235 MFloat getDistanceEllipsoid(const MInt, const MInt);
1236 MFloat getDistanceNaca00XX(const MInt, const MInt);
1238 MFloat getDistanceTetrahedron(const MFloat* const, const MInt);
1239 void getNormal(const MInt, const MInt, MFloat[]);
1240 void getNormalSphere(const MInt, const MInt, MFloat[]);
1241 void getNormalEllipsoid(const MInt, const MInt, MFloat[]);
1243 MFloat distancePointEllipsoidSpecial(const MFloat e[3], const MFloat y[3], MFloat x[3]);
1244 MFloat distancePointEllipsoidSpecial2(const MFloat e[3], const MFloat y[3], MFloat x[3]);
1245 MFloat distancePointEllipsoid(const MFloat e[3], const MFloat y[3], MFloat x[3]);
1246 static MFloat distancePointEllipseSpecial(const MFloat e[2], const MFloat y[2], MFloat x[2]);
1247 MFloat distEllipsoidEllipsoid(const MInt k0, const MInt k1, MFloat* xc0, MFloat* xc1);
1248
1249 void checkCellState(); // claudia
1250 inline MBool inside(MFloat x, MFloat a, MFloat b);
1251 MString printTime(const MFloat t);
1252 MBool fileExists(const MChar* fileName);
1253 MInt copyFile(const MChar* fromName, const MChar* toName);
1254 void checkHaloCells(MInt mode = 0);
1255
1259
1260 private:
1261 static inline MFloat sgn(MFloat val) { return (val < F0) ? -F1 : F1; }
1262 void checkDiv() override;
1263
1264 class surfBase {
1265 public:
1270 surfBase() = default;
1271 explicit surfBase(MInt _bodyId) : bodyId(_bodyId) {}
1272 };
1273
1275 public:
1278 MInt pointType{}; // 0: corner point; 1: cut points; 2: additional MC vertex; 3: additional
1279 // polyhedron clipping vertex
1281 std::vector<MInt> edges;
1283 polyVertex(MInt pId, MInt pType) : pointId(pId), pointType(pType), cartSrfcId(-1) {}
1284 polyVertex(MFloat* coords, MInt pId, MInt pType) : polyVertex(pId, pType) {
1285 std::copy(coords, coords + nDim, coordinates);
1286 }
1287 };
1288
1290 public:
1292 MInt edgeType; // 0: Cartesian uncut, 1: Cartesian cut, 2: cut line on face, 3: cut line in cell
1293 MInt edgeId; // for edgeType 0/1: Cartesian edge, for edgeType 2/3: cartesian face or -1 if
1294 // pure body line
1295 polyEdgeBase(MInt v0, MInt v1, MInt eId, MInt eType) : vertices{v0, v1}, edgeType(eType), edgeId(eId) {}
1296 };
1297
1298 class polyEdge2D : public surfBase, public polyEdgeBase {
1299 public:
1302 polyEdge2D(MInt v0, MInt v1, MInt eId, MInt eType, MInt _bodyId)
1303 : surfBase(_bodyId), polyEdgeBase(v0, v1, eId, eType), cutCell(-1) {}
1304 };
1305
1306 class polyEdge3D : public polyEdgeBase {
1307 public:
1309 polyEdge3D(MInt v0, MInt v1, MInt eId, MInt eType) : polyEdgeBase(v0, v1, eId, eType), face{-1, -1} {}
1310 };
1311
1312 class polyFace : public surfBase {
1313 public:
1314 std::vector<std::pair<MInt, MInt>>
1315 edges; // contains 1. the edge and 2. the direction of the edge (1: as is, -1: reversed)
1318 MInt faceType{}; // 0: cartesian face; 1: body face
1322 polyFace(MInt fId, MInt fType, MInt _bodyId)
1323 : surfBase(_bodyId), cutCell(-1), faceId(fId), faceType(fType), tmpSetIndex(-1), isLine(false) {}
1324
1325 private:
1326 polyFace() : surfBase(-1), cutCell(-1), tmpSetIndex(-1), isLine(false) {}
1327 };
1328
1329 // 3D
1330 class polyMultiFace : public surfBase {
1331 public:
1332 std::vector<MInt> faces;
1333 std::list<std::pair<MInt, MInt>>
1334 edges; // contains 1. the edge and 2. the direction of the edge (1: as is, -1: reversed)
1335 };
1336
1338 public:
1342 polyCutCellBase(MInt cartCell, MFloat* _center) : cartesianCell(cartCell) {
1343 std::copy(_center, _center + nDim, center);
1344 }
1345 };
1346
1348 public:
1349 // The following naming is sick, but I don't care: in 2D these are edges and 3D faces
1350 std::vector<MInt> faces_edges;
1351 polyCutCell(MInt cartCell, MFloat* _center) : polyCutCellBase(cartCell, _center) {}
1352 };
1353
1354 // 3D
1356 public:
1358 std::vector<MInt> srfcIds;
1359 explicit splitCartesianFace(MInt dir) : direction(dir) {}
1360 };
1361
1362 // 3D
1364 public:
1366 std::vector<splitCartesianFace> splitFaces;
1367 explicit cellWithSplitFace(MInt id) : cellId(id) {}
1368 };
1369
1370
1372 template <class X = void, std::enable_if_t<nDim == 2, X*> = nullptr>
1373 void writeVTKFileOfCell(MInt, const std::vector<polyEdge2D>*, const std::vector<polyVertex>*, MInt);
1374 template <class X = void, std::enable_if_t<nDim == 2, X*> = nullptr>
1375 void writeVTKFileOfCutCell(MInt, std::vector<polyCutCell>*, const std::vector<polyEdge2D>*,
1376 const std::vector<polyVertex>*, MInt);
1377 template <class X = void, std::enable_if_t<nDim == 2, X*> = nullptr>
1378 void outputPolyData(const MInt, const std::vector<polyCutCell>*, const std::vector<polyEdge2D>*,
1379 const std::vector<polyVertex>*, MInt);
1380 template <class X = void, std::enable_if_t<nDim == 3, X*> = nullptr>
1381 void outputPolyData(const MInt, const std::vector<polyCutCell>*, const std::vector<polyFace>*,
1382 const std::vector<polyEdge3D>*, const std::vector<polyVertex>*, MInt);
1383 template <class X = void, std::enable_if_t<nDim == 2, X*> = nullptr>
1384 void compVolumeIntegrals(std::vector<polyCutCell>*, std::vector<polyEdge2D>*, const std::vector<polyVertex>*);
1385 template <class X = void, std::enable_if_t<nDim == 2, X*> = nullptr>
1386 void compFaceIntegrals(polyCutCell*, std::vector<polyEdge2D>*, const std::vector<polyVertex>*, MInt, MInt);
1387 template <class X = void, std::enable_if_t<nDim == 2, X*> = nullptr>
1388 void compProjectionIntegrals(polyCutCell*, std::vector<polyEdge2D>*, const std::vector<polyVertex>*, MInt, MInt,
1389 MFloat*);
1390
1391
1396 template <class X = void, std::enable_if_t<nDim == 2, X*> = nullptr>
1397 static inline void computeNormal(const MFloat* p0, const MFloat* p1, MFloat* res, MFloat& w) {
1398 const MFloat dx = p1[0] - p0[0];
1399 const MFloat dy = p1[1] - p0[1];
1400 res[0] = -dy;
1401 res[1] = dx;
1402 const MFloat abs = sqrt(res[0] * res[0] + res[1] * res[1]);
1403 res[0] /= abs;
1404 res[1] /= abs;
1405 w = -res[0] * p0[0] - res[1] * p0[1];
1406 }
1407
1408
1413 template <class X = void, std::enable_if_t<nDim == 3, X*> = nullptr>
1414 static inline MFloat computeNormal(const MFloat* p0, const MFloat* p1, const MFloat* p2, MFloat* res, MFloat& w) {
1415 const MFloat a0 = p1[0] - p0[0], a1 = p1[1] - p0[1], a2 = p1[2] - p0[2], b0 = p2[0] - p0[0], b1 = p2[1] - p0[1],
1416 b2 = p2[2] - p0[2];
1417 res[0] = a1 * b2 - a2 * b1;
1418 res[1] = a2 * b0 - a0 * b2;
1419 res[2] = a0 * b1 - a1 * b0;
1420 const MFloat abs = sqrt(res[0] * res[0] + res[1] * res[1] + res[2] * res[2]);
1421 res[0] /= abs;
1422 res[1] /= abs;
1423 res[2] /= abs;
1424 w = -res[0] * p0[0] - res[1] * p0[1] - res[2] * p0[2];
1425 return abs;
1426 }
1427
1428 inline MFloat checkCentroidDiff(MInt srfcId1, MInt srfcId2);
1429 inline MFloat checkAreaDiff(MInt srfcId1, MInt srfcId2);
1430
1431
1433 public:
1434 MFloat xx[3] = {F0, F0, F0};
1435 CsgVector() { std::fill(xx, xx + nDim, F0); }
1436 explicit CsgVector(const MFloat* X) { std::copy(X, X + nDim, xx); }
1437 CsgVector(const CsgVector& Y) { std::copy(Y.xx, Y.xx + nDim, xx); }
1438 CsgVector(CsgVector&&) noexcept = default;
1439 CsgVector& operator=(const CsgVector&) = default;
1440 CsgVector& operator=(CsgVector&&) = default;
1441
1442 inline CsgVector clone() const {
1443 CsgVector tmp;
1444 std::copy(this->xx, this->xx + nDim, tmp.xx);
1445 return tmp;
1446 }
1447 inline CsgVector plus(const CsgVector& a) const {
1448 CsgVector tmp;
1449 for(MInt i = 0; i < nDim; i++)
1450 tmp.xx[i] = this->xx[i] + a.xx[i];
1451 return tmp;
1452 }
1453 inline CsgVector minus(const CsgVector& a) const {
1454 CsgVector tmp;
1455 for(MInt i = 0; i < nDim; i++)
1456 tmp.xx[i] = this->xx[i] - a.xx[i];
1457 return tmp;
1458 }
1459 inline CsgVector times(const MFloat a) const {
1460 CsgVector tmp;
1461 for(MInt i = 0; i < nDim; i++)
1462 tmp.xx[i] = this->xx[i] * a;
1463 return tmp;
1464 }
1465 inline CsgVector dividedBy(const MFloat a) const {
1466 CsgVector tmp;
1467 for(MInt i = 0; i < nDim; i++)
1468 tmp.xx[i] = this->xx[i] / a;
1469 return tmp;
1470 }
1471 inline MFloat dot(const CsgVector& a) const {
1472 MFloat dotp = F0;
1473 for(MInt i = 0; i < nDim; i++)
1474 dotp += this->xx[i] * a.xx[i];
1475 return dotp;
1476 }
1477 inline CsgVector lerp(const CsgVector& a, const MFloat t) const { return this->plus((a.minus(*this)).times(t)); }
1478 inline MFloat length() const { return sqrt(this->dot(*this)); }
1479 inline CsgVector unit() const { return this->dividedBy(this->length()); }
1480 template <class X = void, std::enable_if_t<nDim == 3, X*> = nullptr>
1481 inline CsgVector cross(const CsgVector& a) const {
1482 CsgVector tmp;
1483 tmp.xx[0] = this->xx[1] * a.xx[2] - this->xx[2] * a.xx[1];
1484 tmp.xx[1] = this->xx[2] * a.xx[0] - this->xx[0] * a.xx[2];
1485 tmp.xx[2] = this->xx[0] * a.xx[1] - this->xx[1] * a.xx[0];
1486 return tmp;
1487 }
1488 template <class X = void, std::enable_if_t<nDim == 2, X*> = nullptr>
1489 inline CsgVector cross(const CsgVector&) const {
1490 TERMM(1, "Get your ass out of this function. This is 3D code!");
1491 }
1492 inline void negate() {
1493 for(MInt i = 0; i < nDim; i++)
1494 this->xx[i] = -this->xx[i];
1495 }
1496 };
1497
1498
1500 public:
1504 CsgVertex(const CsgVector& _pos, MInt _vertexId, MInt _setIndex) : pos(_pos) {
1505 vertexId = _vertexId;
1506 setIndex = _setIndex;
1507 }
1509 CsgVertex tmp(this->pos.clone(), vertexId, setIndex);
1510 return tmp;
1511 }
1512 CsgVertex interpolate(CsgVertex* other, MFloat t) const { return CsgVertex(this->pos.lerp(other->pos, t), -1, -1); }
1513 };
1514
1515 class CsgPolygon;
1516
1517 class CsgPlane {
1518 public:
1519 static constexpr MFloat eps = (nDim == 3) ? 10000 * MFloatEps : 1000 * MFloatEps;
1522
1523 CsgPlane() = default;
1524 CsgPlane(CsgVector* _normal, MFloat _w) {
1525 std::copy(_normal->xx, _normal->xx + nDim, normal.xx);
1526 w = _w;
1527 }
1528 explicit CsgPlane(CsgVector abc[nDim]) {
1529 IF_CONSTEXPR(nDim == 3) {
1530 CsgVector tmp = abc[1].minus(abc[0]).cross(abc[nDim - 1 /*2*/].minus(abc[0])).unit();
1531 normal = tmp;
1532 w = normal.dot(abc[0]);
1533 }
1534 else IF_CONSTEXPR(nDim == 2) {
1535 CsgVector tmp = abc[1].minus(abc[0]).unit();
1536 normal.xx[0] = -tmp.xx[1];
1537 normal.xx[1] = tmp.xx[0];
1538 w = normal.dot(abc[0]);
1539 }
1540 }
1541 ~CsgPlane() = default;
1543 CsgPlane tmp(&this->normal, this->w);
1544 return tmp;
1545 }
1546 void flip() {
1547 this->normal.negate();
1548 this->w = -this->w;
1549 }
1550 void splitPolygon(CsgPolygon* polygon,
1551 std::vector<CsgPolygon>* coplanarFront,
1552 std::vector<CsgPolygon>* coplanarBack,
1553 std::vector<CsgPolygon>* front,
1554 std::vector<CsgPolygon>* back) const;
1555 void insertCoplanarPolygon(CsgPolygon* polygon,
1556 std::vector<CsgPolygon>* coplanarFront,
1557 std::vector<CsgPolygon>* coplanarBack) const;
1558 };
1559
1561 public:
1562 std::vector<CsgVertex> vertices;
1563 // helpers: edgeType[0] corresponds to edge between vertices[0] and vertices[1],...
1568 MInt faceType{}; // 0: cartesian face; 1: body face
1569
1570 CsgPolygon(std::vector<CsgVertex> _vertices, MInt _setIndex, MInt _faceId, MInt _faceType, MInt _bodyId) {
1571 for(MInt i = 0; (unsigned)i < _vertices.size(); i++) {
1572 vertices.push_back(_vertices[i].clone());
1573 }
1574 setIndex = _setIndex;
1575 faceId = _faceId;
1576 faceType = _faceType;
1577 bodyId = _bodyId;
1578 CsgVector abc[nDim];
1579 for(MInt i = 0; i < nDim; i++)
1580 abc[i] = vertices[i].pos;
1581 CsgPlane tmp = CsgPlane(abc);
1582 plane = tmp;
1583 }
1584
1585 CsgPolygon(std::vector<CsgVertex> _vertices, MInt _setIndex, MInt _faceId, MInt _faceType, MInt _bodyId,
1586 CsgPlane _plane) {
1587 for(MInt i = 0; (unsigned)i < _vertices.size(); i++) {
1588 vertices.push_back(_vertices[i].clone());
1589 }
1590 setIndex = _setIndex;
1591 faceId = _faceId;
1592 faceType = _faceType;
1593 bodyId = _bodyId;
1594 plane = _plane.clone();
1595 }
1596
1597 ~CsgPolygon() = default;
1598
1601 return tmp;
1602 }
1603
1604 void flip() {
1605 this->plane.flip();
1606 std::vector<CsgVertex> tmp;
1607 for(auto rit = vertices.rbegin(); rit != vertices.rend(); ++rit) {
1608 tmp.push_back((*rit));
1609 }
1610 vertices.swap(tmp);
1611 }
1612
1613 private:
1614 CsgPolygon() = default;
1615 };
1616
1617 class CsgNode {
1618 public:
1623 std::vector<CsgPolygon> polygons;
1624
1625 explicit CsgNode(std::vector<CsgPolygon> _polygons) {
1626 planeValid = false;
1627 front = nullptr;
1628 back = nullptr;
1629 polygons.clear();
1630 this->build(std::move(_polygons));
1631 }
1632
1634 planeValid = false;
1635 front = nullptr;
1636 back = nullptr;
1637 polygons.clear();
1638 }
1639
1641 this->polygons.clear();
1642 delete this->front;
1643 delete this->back;
1644 }
1645
1646 void invert() {
1647 for(MInt i = 0; (unsigned)i < this->polygons.size(); i++) {
1648 this->polygons[i].flip();
1649 }
1650 this->plane.flip();
1651 if(this->front) this->front->invert();
1652 if(this->back) this->back->invert();
1653 CsgNode* temp = this->front;
1654 this->front = this->back;
1655 this->back = temp;
1656 }
1657
1658 std::vector<CsgPolygon> clipPolygons(std::vector<CsgPolygon> _polygons) {
1659 if(!planeValid) {
1660 return _polygons;
1661 }
1662 std::vector<CsgPolygon> _front;
1663 std::vector<CsgPolygon> _back;
1664 for(MInt i = 0; (unsigned)i < _polygons.size(); i++) {
1665 this->plane.splitPolygon(&_polygons[i], &_front, &_back, &_front, &_back);
1666 }
1667 if(this->front) _front = this->front->clipPolygons(_front);
1668 if(this->back)
1669 _back = this->back->clipPolygons(_back);
1670 else
1671 _back.clear();
1672 for(MInt i = 0; (unsigned)i < _back.size(); i++)
1673 _front.push_back(_back[i]);
1674 return _front;
1675 }
1676
1677 void clipTo(CsgNode& bsp) {
1678 this->polygons = bsp.clipPolygons(this->polygons);
1679 if(this->front) this->front->clipTo(bsp);
1680 if(this->back) this->back->clipTo(bsp);
1681 }
1682
1683 std::vector<CsgPolygon> allPolygons() {
1684 std::vector<CsgPolygon> _polygons(this->polygons);
1685 if(this->front) {
1686 std::vector<CsgPolygon> _polygons_front = this->front->allPolygons();
1687 for(MInt i = 0; (unsigned)i < _polygons_front.size(); i++)
1688 _polygons.push_back(_polygons_front[i]);
1689 }
1690 if(this->back) {
1691 std::vector<CsgPolygon> _polygons_back = this->back->allPolygons();
1692 for(MInt i = 0; (unsigned)i < _polygons_back.size(); i++)
1693 _polygons.push_back(_polygons_back[i]);
1694 }
1695 return _polygons;
1696 }
1697
1698 void build(std::vector<CsgPolygon> _polygons);
1699
1700 // This function originally only existed in 3D
1701 void plot(MInt tabCounter, const MChar* fileName) {
1702 std::ofstream ofl;
1703 if(tabCounter == 0) {
1704 ofl.open(fileName);
1705 ofl.close();
1706 }
1707
1708 if(this->front) this->front->plot(tabCounter + 1, fileName);
1709
1710 ofl.open(fileName, std::ofstream::app);
1711
1712 if(ofl) {
1713 for(MInt count = 0; count < tabCounter; count++)
1714 ofl << " ";
1715 ofl << "node plane normal, w:";
1716 for(MInt dim = 0; dim < nDim; ++dim)
1717 ofl << " " << this->plane.normal.xx[dim];
1718 ofl << ", " << this->plane.w << std::endl;
1719
1720 for(MInt p = 0; (unsigned)p < this->polygons.size(); p++) {
1721 for(MInt count = 0; count < tabCounter; count++)
1722 ofl << " ";
1723 ofl << "polygon " << p << " plane normal, w:";
1724 for(MInt dim = 0; dim < nDim; ++dim)
1725 ofl << " " << this->polygons[p].plane.normal.xx[dim];
1726 ofl << ", " << this->polygons[p].plane.w << std::endl;
1727
1728 for(MInt count = 0; count < tabCounter; count++)
1729 ofl << " ";
1730 ofl << "polygon setIndex: " << this->polygons[p].setIndex << ", bodyId: " << this->polygons[p].bodyId
1731 << ", faceId: " << this->polygons[p].faceId << ", faceType: " << this->polygons[p].faceType << std::endl;
1732 }
1733 ofl << std::endl << std::endl;
1734 ofl.close();
1735 }
1736
1737 if(this->back) this->back->plot(tabCounter + 1, fileName);
1738 }
1739 };
1740
1741 class Csg {
1742 public:
1743 std::vector<CsgPolygon> polygons;
1744
1745 Csg() { polygons.clear(); }
1746
1747 explicit Csg(std::vector<CsgPolygon> _polygons) {
1748 for(MInt i = 0; (unsigned)i < _polygons.size(); i++) {
1749 polygons.push_back(_polygons[i].clone());
1750 }
1751 }
1752
1753 ~Csg() = default;
1754
1755 std::vector<CsgPolygon> intersect(const Csg& csg) const {
1756 CsgNode a(this->polygons);
1757 CsgNode b(csg.polygons);
1758
1759 b.invert();
1760 b.clipTo(a);
1761 b.invert();
1762 a.clipTo(b);
1763 b.clipTo(a);
1764 a.build(b.allPolygons());
1765
1766 return a.allPolygons();
1767 }
1768
1769 void inverse() {
1770 for(MInt i = 0; (unsigned)i < this->polygons.size(); i++) {
1771 this->polygons[i].flip();
1772 }
1773 }
1774 };
1775
1776
1777 // Data members used to replace local static variables
1783
1784 private:
1785 struct CellDataDlb;
1786 static const std::array<MInt, CellDataDlb::count> s_cellDataTypeDlb;
1787};
1788
1789
1790// Struct to differentiate cell (element) data
1791template <MInt nDim_, class SysEqn>
1792struct FvMbCartesianSolverXD<nDim_, SysEqn>::CellDataDlb {
1793 static constexpr const MInt count = 8;
1794
1795 static constexpr const MInt ELEM_AVARIABLE = 0;
1796 static constexpr const MInt ELEM_CELLVOLUMES = 1;
1797 static constexpr const MInt ELEM_RIGHTHANDSIDE = 2;
1798 static constexpr const MInt ELEM_CELLVOLUMESDT1 = 3;
1799 static constexpr const MInt ELEM_SWEPTVOLUMES = 4;
1800 static constexpr const MInt ELEM_PROPERTIES = 5;
1801 static constexpr const MInt ELEM_AZIMUTHAL_LONG = 6;
1802 static constexpr const MInt ELEM_AZIMUTHAL_FLOAT = 7;
1803 static constexpr const MInt ELEM_LESAVERAGE = 8;
1804};
1805
1806
1807// Data types of cell data
1808template <MInt nDim, class SysEqn>
1809const std::array<MInt, FvMbCartesianSolverXD<nDim, SysEqn>::CellDataDlb::count>
1812
1814template <MInt nDim_, class SysEqn>
1816 // Inactive ranks do not have any data to communicate
1817 if(!isActive()) {
1818 return 0;
1819 }
1820
1821 // Convert to solver cell id and check
1822 const MInt cellId = grid().tree().grid2solver(gridCellId);
1823 if(cellId < 0 || cellId >= noInternalCells()) {
1824 return 0;
1825 }
1826
1827 MInt dataSize = 1;
1828
1829 switch(dataId) {
1830 case CellDataDlb::ELEM_AVARIABLE: {
1831 dataSize = m_noCVars;
1832 break;
1833 }
1834 case CellDataDlb::ELEM_CELLVOLUMES: {
1835 dataSize = 1;
1836 break;
1837 }
1838 case CellDataDlb::ELEM_RIGHTHANDSIDE: {
1839 dataSize = m_noFVars;
1840 break;
1841 }
1842 case CellDataDlb::ELEM_CELLVOLUMESDT1: {
1843 dataSize = 1;
1844 break;
1845 }
1846 case CellDataDlb::ELEM_SWEPTVOLUMES: {
1847 dataSize = 1;
1848 break;
1849 }
1850 case CellDataDlb::ELEM_PROPERTIES: {
1851 dataSize = 1;
1852 break;
1853 }
1854 case CellDataDlb::ELEM_AZIMUTHAL_LONG: {
1855 if(grid().azimuthalPeriodicity()) {
1856 dataSize = m_azimuthalNearBoundaryBackupMaxCount * m_noLongDataBalance;
1857 } else {
1858 dataSize = 0;
1859 }
1860 break;
1861 }
1862 case CellDataDlb::ELEM_AZIMUTHAL_FLOAT: {
1863 if(grid().azimuthalPeriodicity()) {
1864 dataSize = m_azimuthalNearBoundaryBackupMaxCount * (nDim_ + m_noFloatDataBalance);
1865 } else {
1866 dataSize = 0;
1867 }
1868 break;
1869 }
1870 default: {
1871 TERMM(1, "Unknown data id.");
1872 break;
1873 }
1874 }
1875
1876 return dataSize;
1877}
1878
1879
1881template <MInt nDim_, class SysEqn_>
1883 const MInt* const bufferIdToCellId, MFloat* const data) {
1884 TRACE();
1885
1886 MInt localBufferId = 0;
1887 for(MInt i = 0; i < oldNoCells; i++) {
1888 const MInt gridCellId = bufferIdToCellId[i];
1889
1890 if(gridCellId < 0) continue;
1891
1892 const MInt cellId = grid().tree().grid2solver(gridCellId);
1893 if(cellId < 0 || cellId >= noInternalCells()) {
1894 continue;
1895 }
1896
1897 switch(dataId) {
1898 case CellDataDlb::ELEM_AVARIABLE: {
1899 std::copy_n(&a_variable(cellId, 0), m_noCVars, &data[localBufferId * m_noCVars]);
1900 break;
1901 }
1902 case CellDataDlb::ELEM_CELLVOLUMES: {
1903 std::copy_n(&a_cellVolume(cellId), 1, &data[localBufferId]);
1904 break;
1905 }
1906 case CellDataDlb::ELEM_RIGHTHANDSIDE: {
1907 std::copy_n(&a_rightHandSide(cellId, 0), m_noFVars, &data[localBufferId * m_noFVars]);
1908 break;
1909 }
1910 case CellDataDlb::ELEM_CELLVOLUMESDT1: {
1911 std::copy_n(&m_cellVolumesDt1[cellId], 1, &data[localBufferId]);
1912 break;
1913 }
1914 case CellDataDlb::ELEM_SWEPTVOLUMES: {
1915 MInt bndryId_ = a_bndryId(cellId);
1916 if(bndryId_ > -1) {
1917 data[localBufferId] = m_sweptVolume[bndryId_];
1918 } else {
1919 data[localBufferId] = -1;
1920 }
1921 break;
1922 }
1923 case CellDataDlb::ELEM_AZIMUTHAL_FLOAT: {
1924 if(grid().azimuthalPeriodicity()) {
1925 MInt noFloatData = m_azimuthalNearBoundaryBackupMaxCount * (nDim_ + m_noFloatDataBalance);
1926 std::copy_n(&m_azimuthalNearBoundaryBackupBalFloat[cellId * noFloatData], noFloatData,
1927 &data[localBufferId * noFloatData]);
1928 }
1929 break;
1930 }
1931 default:
1932 TERMM(1, "Unknown data id.");
1933 break;
1934 }
1935 localBufferId++;
1936 }
1937}
1938
1939
1941template <MInt nDim_, class SysEqn_>
1943 const MInt* const bufferIdToCellId, MLong* const data) {
1944 TRACE();
1945
1946 MInt localBufferId = 0;
1947 for(MInt i = 0; i < oldNoCells; i++) {
1948 const MInt gridCellId = bufferIdToCellId[i];
1949
1950 if(gridCellId < 0) continue;
1951
1952 const MInt cellId = grid().tree().grid2solver(gridCellId);
1953 if(cellId < 0 || cellId >= noInternalCells()) {
1954 continue;
1955 }
1956
1957 switch(dataId) {
1958 case CellDataDlb::ELEM_PROPERTIES: {
1959 data[localBufferId] = (MLong)a_properties(cellId).to_ulong();
1960 break;
1961 }
1962 case CellDataDlb::ELEM_AZIMUTHAL_LONG: {
1963 if(grid().azimuthalPeriodicity()) {
1964 MInt noLongData = m_azimuthalNearBoundaryBackupMaxCount * m_noLongDataBalance;
1965 std::copy_n(&m_azimuthalNearBoundaryBackupBalLong[cellId * noLongData], noLongData,
1966 &data[localBufferId * noLongData]);
1967 }
1968 break;
1969 }
1970 default:
1971 TERMM(1, "Unknown data id.");
1972 break;
1973 }
1974 localBufferId++;
1975 }
1976}
1977
1978
1980template <MInt nDim_, class SysEqn_>
1982 TRACE();
1983
1984 // Nothing to do if solver is not active
1985 if(!isActive()) {
1986 return;
1987 }
1988
1989 // Set the variables if this is the correct reinitialization stage
1990 if(m_loadBalancingReinitStage == 0) {
1991 switch(dataId) {
1992 case CellDataDlb::ELEM_AVARIABLE: {
1993 std::copy_n(data, noInternalCells() * m_noCVars, &a_variable(0, 0));
1994 break;
1995 }
1996 case CellDataDlb::ELEM_CELLVOLUMES: {
1997 std::copy_n(data, noInternalCells(), &a_cellVolume(0));
1998 break;
1999 }
2000 case CellDataDlb::ELEM_RIGHTHANDSIDE: {
2001 std::copy_n(data, noInternalCells() * m_noFVars, &a_rightHandSide(0, 0));
2002 break;
2003 }
2004 case CellDataDlb::ELEM_CELLVOLUMESDT1: {
2005 std::copy_n(data, noInternalCells(), &m_cellVolumesDt1[0]);
2006 break;
2007 }
2008 case CellDataDlb::ELEM_SWEPTVOLUMES: {
2009 std::copy_n(data, noInternalCells(), &m_sweptVolumeBal[0]);
2010 break;
2011 }
2012 case CellDataDlb::ELEM_AZIMUTHAL_FLOAT: {
2013 if(grid().azimuthalPeriodicity()) {
2014 MInt noFloatData = m_azimuthalNearBoundaryBackupMaxCount * (nDim_ + m_noFloatDataBalance);
2015 std::copy_n(data, noInternalCells() * noFloatData, &m_azimuthalNearBoundaryBackupBalFloat[0]);
2016 }
2017 break;
2018 }
2019 default:
2020 TERMM(1, "Unknown data id.");
2021 }
2022 }
2023}
2024
2025
2027template <MInt nDim_, class SysEqn_>
2029 TRACE();
2030
2031 // Nothing to do if solver is not active
2032 if(!isActive()) {
2033 return;
2034 }
2035
2036 // Set the variables if this is the correct reinitialization stage
2037 if(m_loadBalancingReinitStage == 0) {
2038 switch(dataId) {
2039 case CellDataDlb::ELEM_PROPERTIES: {
2040 for(MInt i = 0; i < noInternalCells(); i++) {
2041 a_properties(i) = maia::fv::cell::BitsetType((MUlong)data[i]);
2042 }
2043 break;
2044 }
2045 case CellDataDlb::ELEM_AZIMUTHAL_LONG: {
2046 if(grid().azimuthalPeriodicity()) {
2047 MInt noLongData = m_azimuthalNearBoundaryBackupMaxCount * m_noLongDataBalance;
2048 std::copy_n(data, noInternalCells() * noLongData, &m_azimuthalNearBoundaryBackupBalLong[0]);
2049 }
2050 break;
2051 }
2052 default:
2053 TERMM(1, "Unknown data id.");
2054 }
2055 }
2056}
2057
2058#endif
GridCell
Grid cell Property Labels.
MFloat m_static_logData_ic45301_freqFactor[s_logData_ic45301_maxNoEmbeddedBodies]
void(FvCartesianSolverXD::* m_reconstructSurfaceData)(MInt)
std::vector< std::vector< MInt > > m_splitChilds
virtual void computeConservativeVariables()
Dispatches the computation of the conservative variables for different number of species.
MInt c_level(const MInt cellId) const
Returns the grid level of the cell cellId.
std::vector< std::vector< MInt > > m_azimuthalMaxLevelWindowCells
virtual void LSReconstructCellCenter()
Dispatch the reconstruction computation to the appropiate loop.
MLong c_neighborId(const MInt cellId, const MInt dir, const MBool assertNeighborState=true) const
Returns the grid neighbor id of the grid cell cellId dir.
MInt a_noSurfaces()
Returns the number of surfaces.
static constexpr const MInt m_noCorners
virtual void initNearBoundaryExchange(const MInt mode=0, const MInt offset=0)
Setup the near-boundary communicator needed for the flux-redistribution method.
MBool a_isPeriodic(const MInt cellId) const
Returns IsPeriodic of the cell cellId.
MFloat m_static_logData_ic45301_pressurePoints[s_logData_ic45301_maxNoPressurePoints *nDim]
void exchangeFloatDataAzimuthal(MFloat *data, MInt noVars, const std::vector< MInt > &rotIndices)
MFloat m_static_logData_ic45299_amplitude[s_logData_ic45299_maxNoEmbeddedBodies]
Collector< FvBndryCell< nDim, SysEqn > > * m_bndryCells
MFloat reduceData(const MInt cellId, MFloat *data, const MInt dataBlockSize=1, const MBool average=true)
determines the value of 'data' in the given cell by recusively volumetric averaging among all its off...
MLong c_childId(const MInt cellId, const MInt pos) const
Returns the grid child id of the grid cell cellId at position pos.
std::vector< std::vector< MInt > > m_azimuthalRemappedWindowCells
MFloat & a_rightHandSide(const MInt cellId, MInt const varId)
Returns the right hand side of the cell cellId for the variable varId.
void reInitActiveCellIdsMemory()
Allocate memory to arrays according to the current number of cells.
MFloat c_cellLengthAtCell(const MInt cellId) const
Returns the length of the cell for level.
MFloat c_cellLengthAtLevel(const MInt level) const
Returns the length of the cell for level.
virtual void setConservativeVariables(MInt cellId)
computes conservative from primitive variables for given cell id
MFloat & a_slope(const MInt cellId, MInt const varId, const MInt dir) override
Returns the slope of the cell cellId for the variable varId in direction dir.
MFloat & a_oldVariable(const MInt cellId, const MInt varId)
Returns oldVariablesv of the cell cellId variables varId.
void a_copyPropertiesSolver(const MInt fromCellId, const MInt toCellId)
Returns property p of the cell cellId.
std::vector< std::vector< MInt > > m_wmImgCellIds
MFloat & a_surfaceVariable(const MInt srfcId, const MInt dir, const MInt varId)
Returns the variable varId of surface srfcId in direction dir.
std::vector< MFloat > * m_LESVarAverageBal
MFloat & a_externalSource(MInt cellId, MInt var)
Return external source.
std::map< MInt, MInt > m_splitChildToSplitCell
MInt & a_surfaceOrientation(const MInt srfcId)
Returns the orientation of surface srfcId.
MBool a_isBndryCell(const MInt cellId) const override
Returns isBndryCell of the cell cellId.
maia::fv::collector::FvCellCollector< nDim > m_cells
Collector for FV cells.
MInt m_static_logData_ic45301_containingCellIds[s_logData_ic45301_maxNoPressurePoints]
MBool a_isHalo(const MInt cellId) const
Returns IsHalo of the cell cellId.
maia::fv::cell::BitsetType & a_properties(const MInt cellId)
Returns properties of the cell cellId.
MFloat & a_surfaceArea(const MInt srfcId)
Returns the area of surface srfcId.
void buildLeastSquaresStencilSimple()
Determine the least squares stencil.
MInt a_cutCellLevel(const MInt cellId) const
Returns the level for cutCells, this can either be the maxRefinementLevel or the level of the current...
MFloat & a_variable(const MInt cellId, const MInt varId)
Returns conservative variable v of the cell cellId for variables varId.
constexpr MBool isMultilevelLowestSecondary() const
void a_resetPropertiesSolver(const MInt cellId)
Returns property p of the cell cellId.
void assertValidGridCellId(const MInt cellId) const
Cecks wether the cell cellId is an actual grid-cell.
MLong c_parentId(const MInt cellId) const
Returns the grid parent id of the cell cellId.
Collector< CartesianGridPoint< nDim > > * m_gridPoints
std::vector< std::vector< MInt > > m_wmImgWMSrfcIds
MFloat m_static_logData_ic45299_freqFactor[s_logData_ic45299_maxNoEmbeddedBodies]
std::vector< std::vector< MInt > > m_azimuthalMaxLevelHaloCells
MFloat & a_levelSetValuesMb(const MInt cellId, const MInt set)
Returns the levelSetMb-value for fv-CellId cellId and set.
SysEqn::ConservativeVariables * CV
void(FvCartesianSolverXD::* m_computeViscousFlux)()
MFloat & a_surfaceCoordinate(const MInt srfcId, const MInt dir)
Returns the coordinate of surface srfcId in direction dir.
void computeDomainAndSpongeDimensions()
Extracts the minimum and maximum coordinates of all cells in the grid.
MBool a_isGapCell(const MInt cellId) const
Returns isGapCell of the cell cellId.
void saveGridFlowVarsPar(const MChar *fileName, MInt noTotalCells, MLong noInternalCells, MFloatScratchSpace &variables, std::vector< MString > &dbVariablesName, MInt, MIntScratchSpace &idVariables, std::vector< MString > &idVariablesName, MInt, MFloatScratchSpace &dbParameters, std::vector< MString > &dbParametersName, MIntScratchSpace &idParameters, std::vector< MString > &idParametersName, const MInt *recalcIds)
This function stores the massivley parallel flow information of the cells.
virtual void Ausm()
Dispatches the AUSM flux computation for different number of species.
MInt & a_associatedBodyIds(const MInt cellId, const MInt set)
Returns the associatedBodyIds for fv-CellId cellId and set.
MFloat & a_surfaceUpwindCoefficient(const MInt srfcId)
Returns the upwind coefficient of surface srfcId.
MInt a_noCells() const
Returns the number of cells.
MBool m_multilevel
Stores whether this solver is part of a multilevel computation.
std::vector< FvWMSurface< nDim > > m_wmSurfaces
void createBoundaryCells()
identifies bndry cells (Sets a_isInterface for the solver!)
MFloat & a_surfaceFlux(const MInt srfcId, const MInt fVarId)
Returns the flux fVarId for surface srfcId.
MBool a_isBndryGhostCell(const MInt cellId) const
Returns isBndryGhostCell of the cell cellId.
MFloat & a_surfaceDeltaX(const MInt srfcId, const MInt varId)
Returns the delta X of surface srfcId for variable varId.
MInt getAdjacentLeafCells(const MInt, const MInt, MIntScratchSpace &, MIntScratchSpace &)
retrieves the first 'noLayers' layers of direct and(or diagonal neighbors to the given cell
MFloat & a_dt1Variable(const MInt cellId, const MInt varId)
Returns dt1Variables of the cell CellId variables varId.
MBool calcSlopesAfterStep()
Return if slopes should be calculated at after each step (not before)
MBool a_hasProperty(const MInt cellId, const Cell p) const
Returns grid cell property p of the cell cellId.
MFloat & a_surfaceFactor(const MInt srfcId, const MInt varId)
Returns the factor of surface srfcId for variable varId.
MFloat & a_dt2Variable(const MInt cellId, const MInt varId)
Returns dt2Variables of the cell CellId variables varId.
static constexpr MFloat m_volumeThreshold
std::vector< std::vector< MInt > > m_azimuthalMaxLevelWindowMap
MBool c_isToDelete(const MInt cellId) const
Returns the delete of the cell cellId.
MFloat & a_localTimeStep(const MInt cellId)
Returns the local time-step of the cell cellId.
static constexpr const MInt m_noDirs
void exchangeGapInfo()
exchanges the Gap-Information with the solver-own communicators!
MInt c_noChildren(const MInt cellId) const
Returns the number of children of the cell cellId.
MFloat c_coordinate(const MInt cellId, const MInt dir) const
Returns the coordinate of the cell from the grid().tree() cellId for dimension dir.
void forceTimeStep(const MFloat dt)
Force time step externally.
MInt & a_reconstructionData(const MInt cellId)
Returns reconstruction data offset i of the cell cellId.
MFloat & a_coordinate(const MInt cellId, const MInt dir)
Returns the coordinate of the cell from the fvcellcollector cellId for dimension dir.
virtual void getVorticity(MFloat *const vorticity)
wrapper for vorticity computation
virtual void applyInitialCondition()
Initializes the entire flow field.
MLong c_globalId(const MInt cellId) const
Returns the global grid id of the grid cell cellId.
MInt & a_surfaceNghbrCellId(const MInt srfcId, const MInt dir)
Returns the neighbor cell id of surface srfcId in direction dir.
MFloat computeTimeStepEulerDirectional(MInt cellId) const noexcept
virtual void computePrimitiveVariables()
Dispatches the computation of the primitive variables for different number of species.
virtual void distributeFluxToCells()
Distributes the surface fluxes to the cell RHS.
MFloat & a_spongeFactor(const MInt cellId)
Returns the spongeFactor of the cell cellId.
constexpr MBool isMultilevel() const
Return true if solver is part of a multilevel computation.
MInt noVariables() const override
Return the number of primitive variables.
maia::fv::cell::BitsetType::reference a_wasGapCell(const MInt cellId)
Returns wasGapCell of the cell cellId.
MInt & a_surfaceBndryCndId(const MInt srfcId)
Returns the boundary condition of surface srfcId.
virtual void resetZonalLESAverage()
Initializes zonal exchange arrays.
MBool c_isLeafCell(const MInt cellId) const
void setInfinityState()
Computes/defines the infinity values/state once and for all Ideally the infinity variables should not...
MFloat & a_cellVolume(const MInt cellId)
Returns the cell volume of the cell from the fvcellcollector cellId.
void setPrimitiveVariables(MInt cellId)
computes primitive from primitive variables for given cell id. This is the version for all SysEqn.
virtual MFloat entropy(MInt cellId)
static constexpr const MInt m_noEdges
MInt & a_reconstructionNeighborId(const MInt cellId, const MInt nghbrNo)
Returns reconstruction neighbor n of the cell cellId.
Collector< PointBasedCell< nDim > > * m_extractedCells
void exchangeDataFV(T *data, const MInt blockSize=1, MBool cartesian=true, const std::vector< MInt > &rotIndex=std::vector< MInt >())
std::vector< std::vector< MFloat > > m_wmImgCoords
MBool a_isWindow(const MInt cellId) const
Returns IsWindow of the cell cellId.
void setActiveFlag(MIntScratchSpace &, const MInt mode, const MInt offset)
Set the flag for the cells needed for near bndry exchange.
void allocateCommunicationMemory()
Allocates and initializes send/receive buffers for multiSolver computations.
MInt & a_level(const MInt cellId)
Returns the level of the cell from the fvcellcollector cellId.
void initAzimuthalNearBoundaryExchange(MIntScratchSpace &activeFlag)
MInt a_hasNeighbor(const MInt cellId, const MInt dir, const MBool assertNeighborState=true) const
Returns noNeighborIds of the cell CellId for direction dir.
void resetCutOffCells()
resets all Cut-Off Information should only be called before the adaptation and balance!
std::vector< MFloat > m_reconstructionConstants
MFloat timeStep(MBool canSolver=false) noexcept
MInt & a_bndryId(const MInt cellId)
Returns the bndryId of the cell cellId.
void rebuildAzimuthalReconstructionConstants(MInt cellId, MInt offset, MFloat *recCoord, MInt mode=0)
constexpr MBool isMultilevelPrimary() const
Return true if solver is primary solver in multilevel computation.
void reduceVariables()
Check whether any of the extracted cells lie below the halo cell level and interpolate their variable...
MFloat computeDomainLength(MInt direction)
std::array< MInt, Timers::_count > m_timers
MInt & a_noReconstructionNeighbors(const MInt cellId)
Returns the noRcnstrctnNghbrIds of the cell cellId.
std::vector< MInt > m_azimuthalRemappedNeighborDomains
MFloat & a_pvariable(const MInt cellId, const MInt varId)
Returns primitive variable v of the cell cellId for variables varId.
MFloat computeRecConstSVD(const MInt cellId, const MInt offset, MFloatScratchSpace &tmpA, MFloatScratchSpace &tmpC, MFloatScratchSpace &weights, const MInt recDim, const MInt, const MInt, const std::array< MBool, nDim > dirs={}, const MBool relocateCenter=false)
compute the reconstruction constants of the given cell by a weighted least-squares approach via singu...
MBool checkNeighborActive(const MInt cellId, const MInt dir) const
Cecks wether the cell cellId has a valid neighbor in direction dir.
MFloat & a_FcellVolume(const MInt cellId) override
Returns the inverse cell volume of the cell from the fvcellcollector cellId.
const MInt & getAssociatedInternalCell(const MInt &cellId) const
Returns the Id of the split cell, if cellId is a split child.
std::vector< CsgPolygon > polygons
Csg(std::vector< CsgPolygon > _polygons)
std::vector< CsgPolygon > intersect(const Csg &csg) const
CsgNode(std::vector< CsgPolygon > _polygons)
void plot(MInt tabCounter, const MChar *fileName)
std::vector< CsgPolygon > clipPolygons(std::vector< CsgPolygon > _polygons)
void build(std::vector< CsgPolygon > _polygons)
std::vector< CsgPolygon > allPolygons()
std::vector< CsgPolygon > polygons
CsgPlane(CsgVector *_normal, MFloat _w)
void splitPolygon(CsgPolygon *polygon, std::vector< CsgPolygon > *coplanarFront, std::vector< CsgPolygon > *coplanarBack, std::vector< CsgPolygon > *front, std::vector< CsgPolygon > *back) const
void insertCoplanarPolygon(CsgPolygon *polygon, std::vector< CsgPolygon > *coplanarFront, std::vector< CsgPolygon > *coplanarBack) const
CsgPolygon(std::vector< CsgVertex > _vertices, MInt _setIndex, MInt _faceId, MInt _faceType, MInt _bodyId, CsgPlane _plane)
CsgPolygon(std::vector< CsgVertex > _vertices, MInt _setIndex, MInt _faceId, MInt _faceType, MInt _bodyId)
CsgVector cross(const CsgVector &a) const
CsgVector times(const MFloat a) const
CsgVector minus(const CsgVector &a) const
CsgVector lerp(const CsgVector &a, const MFloat t) const
CsgVector(CsgVector &&) noexcept=default
MFloat dot(const CsgVector &a) const
CsgVector dividedBy(const MFloat a) const
CsgVector cross(const CsgVector &) const
CsgVector plus(const CsgVector &a) const
CsgVertex interpolate(CsgVertex *other, MFloat t) const
CsgVertex(const CsgVector &_pos, MInt _vertexId, MInt _setIndex)
std::vector< splitCartesianFace > splitFaces
polyCutCellBase(MInt cartCell, MFloat *_center)
polyCutCell(MInt cartCell, MFloat *_center)
polyEdge2D(MInt v0, MInt v1, MInt eId, MInt eType, MInt _bodyId)
polyEdge3D(MInt v0, MInt v1, MInt eId, MInt eType)
polyEdgeBase(MInt v0, MInt v1, MInt eId, MInt eType)
std::vector< std::pair< MInt, MInt > > edges
polyFace(MInt fId, MInt fType, MInt _bodyId)
std::list< std::pair< MInt, MInt > > edges
polyVertex(MFloat *coords, MInt pId, MInt pType)
void logBoundaryData(const MChar *fileName, MBool forceOutput)
logs several boundary values to the given output file
void resetMbBoundaryCells()
resets all moving boundary cells - STL boundary remains intact
void printDynamicCoefficients(MBool firstRun, MFloat *pressureForce)
void reInitSolutionStep(const MInt mode)
Re-initializes the solver.
MBool(FvMbCartesianSolverXD::* execRungeKuttaStep)()
std::vector< MInt > m_massRedistributionIds
MInt returnNoActiveCorners(MInt)
returns the numer of active Corners for an arbitrary cell (the cell is not a bndryCandidate yet and t...
void copyVarsToSmallCells() override
calls m_fvBndryCnd->copyVarsToSmallCells()
std::vector< MFloat > m_particleQuaternions
void sensorPatch(std::vector< std::vector< MFloat > > &, std::vector< std::bitset< 64 > > &, std::vector< MFloat > &, MInt, MInt) override
MFloat getLevelSetValueNaca00XX(const MFloat *const, const MFloat sign)
void initPointParticleProperties()
void initGField()
initializes the level-set data at startup
std::map< MInt, MFloat > m_oldGeomBndryCells
static void computeNormal(const MFloat *p0, const MFloat *p1, MFloat *res, MFloat &w)
returns the normal corresponding to the triangle abc and returns the result in res
std::vector< MFloat > m_particleVelocityDt1
void leastSquaresReconstruction()
Least squares reconstruction.
MInt getAdjacentGridCells(MInt cellId, MInt *adjacentCells)
retrieves all direct and diagonal fluid cell neighbours of the given cell
static constexpr MFloat m_distThresholdStat[m_noMeanStatistics]
void storeAzimuthalPeriodicData(MInt mode=0)
Stored azimuthal periodic data from halo rank on window rank.
void checkCellState()
checks the cell state of the inactive cells based on the nodal ls values if a cell is inactive (level...
MInt broadcastSignal(const MInt sender, const MInt signal)
hijacked function to compute gradients in intial condition 122 for pressure poisson equation
static MInt writeGeometryToVtkXmlFile(const MString &fileName)
std::vector< std::tuple< MInt, MInt, MInt > > m_temporarilyLinkedCells
std::vector< MFloat > m_slipDataTimeSteps
std::vector< MFloat > m_particleAngularAcceleration
static void matrixProduct(MFloatScratchSpace &C, MFloatScratchSpace &A, MFloatScratchSpace &B)
C=A*B.
MInt writeGeometryToVtkXmlFile(const MString &fileName)
Writes VTK file for the embedded geometry.
void loadRestartFile() override
Loads the restart files.
void computeFlowStatistics(MBool force)
MFloat updateCellVolumeGCL(MInt bndryId)
static MInt locatenear(const Point< nDim > &, MFloat, MInt *, MInt, MBool returnCellId=true)
static void matrixProductTranspose(MFloatScratchSpace &C, MFloatScratchSpace &A, MFloatScratchSpace &B)
C=A*B^t.
std::map< MInt, std::vector< MFloat > > m_nearBoundaryBackup
void transferLevelSetFieldValues(MBool)
void initAzimuthalLinkedHaloExc()
Create exchange for all window/halo cells which are used for the azimuthal periodic interpolation.
std::vector< MInt > * m_linkedWindowCells
ATTRIBUTES1(ATTRIBUTE_HOT) void distributeFluxToCells() override
static void computeRotationMatrix(MFloatScratchSpace &, MFloat *q)
rotation matrix co-rotating(~inertial) frame -> body-fixed frame
static const std::array< MInt, CellDataDlb::count > s_cellDataTypeDlb
void computeSlipStatistics(const MIntScratchSpace &nearestBodies, const MFloatScratchSpace &nearestDist, const MFloat maxDistConstructed)
void gapCellExchange(MInt)
exchanges variables and wasInactive for gapCells
std::vector< std::vector< MInt > > m_azimuthalLinkedWindowCells
void setBoundaryVelocity()
Sets the boundry velocity at the moving cut-cells. sets: m_primVars[PV->VV[i]] to m_bodyVelocity[i] f...
void buildAdditionalAzimuthalReconstructionStencil(MInt mode=0)
Rebuild azimuthal reconstruction constants for moving boundary cells.
std::vector< MInt > m_refOldBndryCells
ATTRIBUTES1(ATTRIBUTE_HOT) void computeSurfaceValues(MInt timerId
void computeBodySurfaceData(MFloat *pressureForce=nullptr)
computes relevant variables at the moving boundary surface and determines the resulting body force
void recordBodyData(const MBool &firstRun)
void saveRestartFile(const MBool) override
Saves the restart file.
ATTRIBUTES1(ATTRIBUTE_HOT) void computeSurfaceValuesLimited(MInt timerId
void finalizeInitSolver() override
Initializes the solver afer the initialRefinement!
std::vector< MFloat > m_particleCoords
static constexpr MInt m_noMeanStatistics
void updateInfinityVariables()
update infinity state for certain testcases with constructed level-set field!
void writeVtkDebug(const MString suffix)
MString getConservativeVarName(MInt i)
returns the name of the conservative variable at the given index i
MFloat filterFloat(MFloat number)
filter nan's
void applyExternalOldSource() override
remove external sources from tho old RHS for new-RungeKutta-scheme for moving boundaries
std::vector< MFloat > m_particleCoordsDt1
MFloat * m_azimuthalNearBoundaryBackupBalFloat
void initSolutionStep(MInt mode) override
Initializes the solver.
MFloat getDistanceSplitSphere(const MInt, const MInt)
determines the level-set value for the given cell provided that the embedded body is spherical
void correctRefinedBndryCell()
correct old-BndryCells which are no-longer leaf-Cells after the adaptation NOTE: mas-conservative upd...
void updateViscousFluxComputation()
corrects the cell-surface distances at the boundary needed for the viscous flux computation
void updateAzimuthalNearBoundaryExchange()
Reset former azimuthal nearBoundaryCells.
void Muscl(MInt timerId=-1) override
Reconstructs the flux on the surfaces.
void setupBoundaryCandidatesAnalytical()
determine all possible fluid boundary cells for a spherical embedded body
ATTRIBUTES1(ATTRIBUTE_HOT) MBool rungeKuttaStepNew()
void swapCells(const MInt, const MInt) override
MInt getFacingNghbrs(const MInt cellId, const MBool includeAllChilds)
determines the neighbors sharing a face with the given cell
void setCellDataDlb(const MInt dataId, const MFloat *const data) override
Set solver data for DLB.
void computeGhostCellsMb()
creates a ghost cell for all cells near(!) the moving boundary
void saveSolverSolution(const MBool forceOutput=false, const MBool finalTimeStep=false) override
Manages solver-specific output.
std::multimap< MLong, std::pair< std::vector< MFloat >, std::vector< MUlong > > > m_azimuthalNearBoundaryBackup
void initSolver() override
Initializes the solution.
void getBodyRotationDt1(const MInt bodyId, MFloat *bodyRotation)
void setSensors(std::vector< std::vector< MFloat > > &sensors, std::vector< MFloat > &sensorWeight, std::vector< std::bitset< 64 > > &sensorCellFlag, std::vector< MInt > &sensorSolverId) override
MInt loadInitCorrData(const std::vector< MInt > &saveInitCorrDataTimeSteps, MFloatScratchSpace &bodyVelocityInit, MFloatScratchSpace &bodyAngularVelocityInit, MFloatScratchSpace &bodyQuaternionInit, MFloatScratchSpace &velMeanInit, MFloatScratchSpace &velGradMeanInit, MFloatScratchSpace &particleFluidRotationMeanInit, MIntScratchSpace &corrBodies, MFloatScratchSpace &bodyForceInit, MFloatScratchSpace &bodyTorqueInit, const MIntScratchSpace &bodyOffsets)
MInt inverseGJ()
computes the Gauss Jordan matrix inversion of the first DxD-solver of m_A. The inverse A^-1 is stored...
std::vector< MInt > m_bndryCandidateIds
std::vector< MFloat > m_particleAccelerationDt1
void linkBndryCells()
Links bndryCells.
void correctSrfcsMb()
correct surfaces intersected by the moving boundary
void correctMasterSlaveSurfaces()
Removes surfaces between master-slave pairs and reassigns slave cell surfaces required in order to ma...
ATTRIBUTES1(ATTRIBUTE_HOT) MBool rungeKuttaStepStandard()
std::set< MInt > m_bodyWasActuallyInCollision
void setParticleFluidVelocities(MFloat *=nullptr)
void restoreNeighbourLinks()
restores previously deleted neighbour information and reactivates cells
void saveBodyRestartFile(const MBool backup)
save restart body file
ATTRIBUTES1(ATTRIBUTE_HOT) void viscousFlux() override
void setAdditionalActiveFlag(MIntScratchSpace &) override
void generateBndryCellsMb(const MInt mode)
call all routines necessary for the generation of boundary cells mode = -1: default argument,...
std::set< MInt > m_freeSurfaceIndices
void computeAzimuthalReconstructionConstants(MInt mode=0) override
Compute the reconstruction constants for azimuthal periodic exchange using a weighted least squares a...
void preSolutionStep(const MInt=-1) override
step before the solver solution Step
std::vector< MInt > * m_gapHaloCells
void transferBodyState(MInt k, MInt b)
static MFloat sgn(MFloat val)
void commAzimuthalPeriodicData(MInt mode=0)
Send stored azimuthal periodic data from window to halo.
void removeSurfaces(MInt cellId)
removes the surfaces of the given cell
std::vector< MFloat > m_particleAngularVelocityDt1
void resetRHSNonInternalCells() override
std::vector< CutCandidate< nDim > > m_cutCandidates
void initializeMb()
called by the constructor 1) read additional fvmb properties 2) allocate fvmb specific memory 3) init...
void updateMultiSolverInformation(MBool fullReset=false) override
void buildAdditionalReconstructionStencil()
correct reconstruction stencil for all cells near moving boundaries
MFloat getDistance(const MFloat *const, const MInt)
void allocateBodyMemory(MInt mode=0)
void exchangeAzimuthalOuterNodalValues(std::vector< CutCandidate< nDim > > &candidates, std::vector< MInt > &candidateIds)
Exchange of nodal values of azimuthal periodic halo cells.
void correctCoarsenedBndryCellVolume()
correct BndryCells volume of bndryCells which were a bndryCell on a coarser level before
MInt cellDataTypeDlb(const MInt dataId) const override
void saveInitCorrData(const std::vector< MInt > &saveInitCorrDataTimeSteps, const MFloatScratchSpace &bodyVelocityInit, const MFloatScratchSpace &bodyAngularVelocityInit, const MFloatScratchSpace &bodyQuaternionInit, const MFloatScratchSpace &velMeanInit, const MFloatScratchSpace &velGradMeanInit, const MFloatScratchSpace &particleFluidRotationMeanInit, const MIntScratchSpace &corrBodies, const MFloatScratchSpace &bodyForceInit, const MFloatScratchSpace &bodyTorqueInit, const MIntScratchSpace &bodyOffsets)
void deleteNeighbourLinks()
deletes links to neighbours tagged inactive
void updateSpongeLayer() override
computes the additional rhs of all cells lying inside the sponge layer to dissipate outgoing waves.
void initBndryLayer()
initializes the bndryLayer data and is/was inactive at solver initialisation
GeometryIntersection< nDim > * m_geometryIntersection
MBool hasSplitBalancing() const override
Return if load balancing for solver is split into multiple methods or implemented in balance()
void createCutFaceMb_MGC()
determines the geometric cut-cell data
MInt getAdjacentCellsAllLevels(MInt cellId, MInt *adjacentCells)
retrieves all direct and diagonal fluid cell neighbours of the given cell
void moveSurface(const MInt toSrfcId, const MInt fromSrfcId)
std::vector< MFloat > m_particleHeatFlux
void updateBodyProperties()
update properties of the embedded body (mainly forced structural motion)
void initializeRungeKutta() override
This function loads all terms used by Runge Kutta.
void getCellDataDlb(const MInt dataId, const MInt oldNoCells, const MInt *const bufferIdToCellId, MFloat *const data) override
Return solver data for DLB.
std::vector< MFloat > m_particleTemperature
void writeListOfActiveFlowCells() override
stores all cells and surfaces needed for the flux computation
void writeVTKFileOfCell(MInt, const std::vector< polyEdge2D > *, const std::vector< polyVertex > *, MInt)
void computeNearBodyFluidVelocity(const MIntScratchSpace &nearestBodies, const MFloatScratchSpace &nearestDist, MFloat *vel, MFloat *velGrad, MFloat *rotation, const std::vector< MFloat > &setup=std::vector< MFloat >(), MInt *skipBodies=nullptr, MFloat *meanBodyState=nullptr, MFloat *pressure=nullptr, MFloat *velDt=nullptr, MFloat *rotationDt=nullptr, MFloat *nearestFac=nullptr)
Mean parameters: near body data estimated by weighted filtering procedure All parameters after "setup...
void setGapCellId()
set the gapCellId for gapInitMethod = 0, otherwise handeled in gapHandling!
MFloat temperature(MInt cellId)
temperature
MInt locatenear(const Point< nDim > &pt, MFloat r, MInt *list, MInt nmax, MBool returnCellId=true)
MInt cellDataSizeDlb(const MInt dataId, const MInt gridCellId) override
Return data size to be communicated during DLB for a grid cell and given data id.
void initializeMaxLevelExchange() override
update window/halo cell collectors
FvBndryCndXD< nDim, SysEqn > * m_fvBndryCnd
void compVolumeIntegrals(std::vector< polyCutCell > *, std::vector< polyEdge2D > *, const std::vector< polyVertex > *)
void getBodyRotation(const MInt bodyId, MFloat *bodyRotation)
void writeVtkXmlFiles(const MString fileName, const MString GFileName, MBool regularOutput, MBool diverged) override
write flow variables as XML VTK files
void resetSolver() override
Reset the solver prior to load balancing.
void writeVtkXmlOutput(const MString &fileName, MBool debugOutput=false)
write flow variables as XML VTK
void determineNearBndryCells()
determines cells at the boundary (i.e. boundary cells and their direct neighbors)
MBool rungeKuttaStep() override
calls a Runge Kutta substep
std::vector< MInt > m_azimuthalBndryCandidates
void updateCellSurfaceDistanceVectors()
correct the cell-surface distance vectors for cells near the moving boundary
static constexpr MFloat FD
void balancePre() override
Reinitialize solver for DLB prior to setting solution data.
void readStlFile(const MChar *fileName, MBool readNormals)
read specified STL file
void balancePost() override
Reinitialize solver after setting solution data in DLB.
void computeBodyVolume(MFloatScratchSpace &partVol)
void loadBodyRestartFile(MInt)
load restart body file readMode = 0 : do not read the cellVolume from file (read only bodyData) readM...
ATTRIBUTES1(ATTRIBUTE_HOT) MBool rungeKuttaStepNewLocalTimeStepping()
void adaptTimeStep()
computes the time step
void createSurfaceSplit(MInt srfcId, MInt cellId, MInt splitChildId, MInt direction)
restores the surfaces of the given cell
void restoreSurfaces(const MInt cellId)
restores the surfaces of the given cell
void applyExternalSource() override
Add external sources to the RHS for new-RungeKutta-scheme for moving boundaries differs from the base...
void checkBoundaryCells()
performs an integrety check of the boundary cells
MBool test_face(MInt, MInt, MInt)
Test a face (MarchingCubes helper routine) receives MAIA face if face>0 return true if the face conta...
static MFloat distancePointEllipseSpecial(const MFloat e[2], const MFloat y[2], MFloat x[2])
MInt getEqualLevelNeighbors(MInt cellId, MInt(&nghbrs)[27])
retrieves all direct and diagonal fluid cell neighbours of the given cell
void checkGapCells()
determines Gap-state, and organises GapCells
std::vector< MInt > m_particleGlobalId
void getNormalSphere(const MInt, const MInt, MFloat[])
MBool constructGFieldCorrector()
determine the displacement of the embedded body – corrector step
std::set< MInt > m_bodyWasInCollision
void initGapCellExchange()
creates the gap-cell exchange communicators based on initializeMaxLevelExchange
static void setAdditionalCellProperties()
set the properties of cells and determines the state of halo cells
void initEmergingGapCells()
initializes variables of cells which occur in a freshly opened gap (valve gap etc....
void updateSplitParentVariables() override
void localToGlobalIds() override
Change local into global ids.
void advanceBodies()
advances the time and stores the flow variables
void resetSolverFull() override
resets the solver
void initializeEmergedCells()
initializes variables of cells which recently became active and therefore have no up-to-date history ...
std::vector< MFloat > m_massRedistributionRhs
std::vector< MFloat > m_particleRadii
void finalizeBalance() override
Reinitialize solver after all data structures have been recreated.
MBool solutionStep() override
Performs the solutionStep of the FVMB solver the loop over the different RK-steps is done in the exec...
void resetSolverMb()
resets the solver to an empty domain without moving boundary
MFloat checkAreaDiff(MInt srfcId1, MInt srfcId2)
std::vector< MFloat > m_massRedistributionSweptVol
std::vector< MFloat > m_massRedistributionVolume
void setCellWeights(MFloat *) override
set static cell weights for solver cells, which are used for the domain decomposition
void getNormalEllipsoid(const MInt, const MInt, MFloat[])
void setOldGeomBndryCellVolume()
set bndryCell volume from m_oldGeomBndryCells which is read from bodyRestartFile at initSolver and th...
static MFloat computeNormal(const MFloat *p0, const MFloat *p1, const MFloat *p2, MFloat *res, MFloat &w)
returns the normal corresponding to the triangle abc and returns the result in res
void setGapOpened()
sets the global-Trigger m_gapOpened, to determine if Gap-Cells are opened! old and incorrect version!...
std::vector< MFloat > m_particleTemperatureDt1
MInt getAdjacentCellsExtended(MInt cellId, MInt *adjacentCells)
retrieves the first two layers of direct and diagonal fluid cell neighbours of the given cell
static void crossProduct(MFloat *c, MFloat *a, MFloat *b)
computes the cross product c <- (a x b) for a, b, c in R^3
void checkHaloBndryCells(MBool sweptVol)
void compFaceIntegrals(polyCutCell *, std::vector< polyEdge2D > *, const std::vector< polyVertex > *, MInt, MInt)
void computeNodalLSValues()
compute the level-set values at the mesh vertices
void constructGField(MBool updateBody=true)
manually constructs the level-set field after each time step
MFloat getDistanceEllipsoid(const MFloat *const, const MInt)
void correctRefinedBndryCellVolume()
correct BndryCells volume of bndryCells which were a bndryCell on a coarser level before
void compProjectionIntegrals(polyCutCell *, std::vector< polyEdge2D > *, const std::vector< polyVertex > *, MInt, MInt, MFloat *)
compute various integrations over projection of face
MFloat getDistancePiston(const MFloat *const, const MInt)
void setTimeStep() override
calls sets() and stores the time step for all cells
void advanceExternalSource() override
advance external sources
void addBoundarySurfacesMb()
adds a surface for the ghost-boundary cell intersections
MString getPrimitiveVarName(MInt i)
returns the name of the primitive variable at the given index i
std::vector< MInt > m_particleCellLink
void updateGeometry()
Updates the member-variables in the geometry-intersection class.
MInt createSplitCell(MInt cellId, MInt noSplitChilds)
MLong getNumberOfCells(MInt mode)
mode=0: total mode=1: min mode=2: max mode=3: average
MBool fileExists(const MChar *fileName)
MBool gridPointIsInside(MInt, MInt) override
std::vector< MFloat > m_particleAngularAccelerationDt1
void getBoundaryDistance(MFloatScratchSpace &) override
ATTRIBUTES1(ATTRIBUTE_HOT) void LSReconstructCellCenter() override
std::vector< MFloat > m_particleVelocityFluid
MBool maxResidual(MInt mode=0) override
Computes the maxResiduum for all cells.
typename maia::grid::tree::Tree< nDim >::Cell Cell
static constexpr MInt m_noCellNodes
std::vector< MFloat > m_particleQuaternionsDt1
void writeVtkXmlOutput_MGC(const MString &fileName)
write flow variables as XML VTK
void applyBoundaryCondition() override
dummy, since applyBoundaryCondition() it is placed wrong for moving boundary problems,...
std::vector< MFloat > m_particleVelocity
std::vector< MFloat > m_particleAngularVelocity
std::vector< MFloat > m_massRedistributionVariables
MInt createBndryCellMb(MInt cellId)
creates a moving boundary cell for the given cell
void descendDistance(const MInt cellId, const MInt *const bodyIds, const MInt bodyCnt, MIntScratchSpace &nearestBodies, MFloatScratchSpace &nearestDist)
void computeReconstructionConstants() override
computes the reconstruction constants using inverse distance weighted least squares
std::vector< MFloat > m_movingPosDiff
MFloat CalculateLSV(MInt, MIntScratchSpace &)
Calculate LevelSetValue with an Approximation of the Neighbours for a grid in the NarrowBand.
MInt constructDistance(const MFloat deltaMax, MIntScratchSpace &nearestBodies, MFloatScratchSpace &nearestDist)
void crankAngleSolutionOutput()
save a full solutionOutput at timeSteps closesed to a specified crankAngle Interval save a solution s...
void deleteSurface(MInt srfcId)
removes the surfaces of the given cell
std::set< MInt > m_coarseOldBndryCells
void logOutput()
logs several collector sizes
std::vector< MFloat > m_particleVelocityGradientFluid
void advanceSolution()
advances the time and stores the flow variables
MFloat interpolateLevelSet(MInt *, MFloat *, MInt)
interpolates levelset function to a given coordinate
MFloat distancePointEllipsoidSpecial(const MFloat e[3], const MFloat y[3], MFloat x[3])
MInt checkNeighborActivity(MInt)
ckecks that a new bndry-Cell has at least one neighbor which was active before if this is not the cas...
void setRungeKuttaFunctionPointer()
This function sets the function pointers for rungeKutta (also used in splitBalance)
ATTRIBUTES1(ATTRIBUTE_HOT) void resetRHS() override
void writeVTKFileOfCutCell(MInt, std::vector< polyCutCell > *, const std::vector< polyEdge2D > *, const std::vector< polyVertex > *, MInt)
std::vector< MInt > * m_linkedHaloCells
void getNormal(const MInt, const MInt, MFloat[])
static MFloat CdLaw(MFloat Re)
void refineCell(const MInt) override
void computeCutPointsMb_MGC()
Computes cutpoints of zero level-set with grid edges and creates boundary cells for cut-cells.
MFloat getDistanceTetrahedron(const MFloat *const, const MInt)
void checkDiv() override
Check for divergence in case we use MB_DEBUG or debug.
MBool prepareRestart(MBool, MBool &) override
Prepare the solvers for a grid-restart.
void updateCellSurfaceDistanceVector(MInt srfcId)
correct the cell-surface distance vectors for cells near the moving boundary
std::vector< MFloat > m_oldBodyPosition
void updateLinkedCells()
update the temporarly-linked cells
std::vector< std::vector< MInt > > m_azimuthalLinkedHaloCells
static void matrixProductTranspose2(MFloatScratchSpace &C, MFloatScratchSpace &A, MFloatScratchSpace &B)
C=A^t*B.
void constructGFieldPredictor()
determine the displacement of the embedded body – predictor step
void descendLevelSetValue(const MInt cellId, const MInt *const bodyIds, const MInt bodyCnt)
MFloat getDistanceSphere(const MFloat *const, const MInt)
MFloat m_oldMeanState[m_noMeanStatistics][4]
void computeAzimuthalHaloNodalValues()
init exchange of nodal values of azimuthal periodic halo cells
MInt copyFile(const MChar *fromName, const MChar *toName)
std::vector< MFloat > m_particleCoordsInitial
void determineBndryCandidates()
determine all possible fluid boundary cells for a generic embedded body
void setLevelSetMbCellProperties()
determines relevant cell properties
std::vector< MFloat > m_candidateNodeValues
void balance(const MInt *const noCellsToReceiveByDomain, const MInt *const noCellsToSendByDomain, const MInt *const targetDomainsByCell, const MInt oldNoCells) override
Balance the solver.
std::map< MInt, MFloat > m_oldBndryCells
std::vector< MInt > m_particleOffsets
std::vector< Point< nDim > > m_bodyCentersLocal
void gapHandling()
determines Gap-state, and organises GapCells
MString printTime(const MFloat t)
MFloat determineCoupling(MFloatScratchSpace &coupling)
void reIntAfterRestart(MBool) override
void updateGapBoundaryCells()
set the velocity at gap-Boundary-Cells due to the irregular movement of the gap-surface during wideni...
MFloat getDistanceNaca00XX(const MInt, const MInt)
static void matrixVectorProduct(MFloat *c, MFloatScratchSpace &A, MFloat *b)
c=A*b
void computeForceCoefficients(MFloat *&)
dummy
std::vector< MInt > m_azimuthalWasNearBndryIds
MInt getAdjacentCells(MInt cellId, MInt *adjacentCells)
retrieves all direct and diagonal fluid cell neighbours of the given cell
void rebuildReconstructionConstants(MInt cellId)
computes the reconstruction constants using inverse distance weighted least squares
std::vector< MInt > m_azimuthalBndryCandidateIds
std::vector< Point< nDim > > m_bodyCenters
MFloat distEllipsoidEllipsoid(const MInt k0, const MInt k1, MFloat *xc0, MFloat *xc1)
Compute the distance between two ellipsoids by iteratively searching the nearest point on the respect...
std::vector< MFloat > m_particleFluidTemperature
void setBodyQuaternions(const MInt bodyId, MFloat *bodyRotation)
MInt getNewSurfaceId()
returns a new surface id
std::vector< MFloat > m_particleShapeParams
std::vector< MInt > * m_periodicGhostBodies
void initAnalyticalLevelSet()
This function creats the bodyTree for analytical LevelSets.
void interpolateGapBodyVelocity()
sets the interpolated velocity for a bndryCell NOTE: all neighbors need to be available for levelset-...
std::vector< MInt > m_bndryLayerCells
void initBodyProperties()
initialize properties of the embedded body at startup
std::vector< MFloat > m_particleAcceleration
void createSurface(MInt srfcId, MInt nghbrId0, MInt nghbrId1, MInt orientation)
restores the surfaces of the given cell
KDtree< nDim > * m_bodyTreeLocal
void applyBoundaryConditionMb()
applies the boundary condition at all boundaries
ATTRIBUTES1(ATTRIBUTE_HOT) void exchange() override
static constexpr MInt m_noAngleSetups
MBool inside(MFloat x, MFloat a, MFloat b)
void writeStencil(const MInt bndryId)
void updateLevelSetOutsideBand()
computes an approximate level set value for cells outside the level-set computing band
void preTimeStep() override
Performs the preTimeStep of the FVMB solver.
MBool postSolutionStep() override
step after the solver solution Step
std::vector< MInt > * m_gapWindowCells
std::vector< MInt > m_forceFVMBStatistics
std::vector< MInt > m_bndryCandidates
MFloat distancePointEllipsoid(const MFloat e[3], const MFloat y[3], MFloat x[3])
ATTRIBUTES1(ATTRIBUTE_HOT) void Ausm() override
void resetSlopes()
does what it says
void prepareNextTimeStep() override
Updates the old Variables, the body positions and the increases the time.
void checkHaloCells(MInt mode=0)
Checks a couple of important properties and variables of halo-cells.
MFloat checkCentroidDiff(MInt srfcId1, MInt srfcId2)
void writeVtkErrorFile()
write flow variables as XML VTK files
void createInitialSrfcs()
computes initial set of internal grid surfaces
MFloat distancePointEllipsoidSpecial2(const MFloat e[3], const MFloat y[3], MFloat x[3])
void outputPolyData(const MInt, const std::vector< polyCutCell > *, const std::vector< polyEdge2D > *, const std::vector< polyVertex > *, MInt)
void postTimeStep() override
Performs the postTimeStep of the FVMB solver.
void setCellProperties() override
set the properties of cells and determines the state of halo cells
void removeChilds(const MInt) override
static constexpr MInt m_noDistSetups
void computeVolumeFraction()
computes the volume fraction V/h^d and the level-set value in the volumetric center of all boundary c...
void correctBoundarySurfaceVariablesMb()
sets boundary surface variables to their correct values
std::vector< MInt > m_candidateNodeSet
MInt noCellDataDlb() const override
Methods to inquire solver data information.
void exchangeLinkedHaloCellsForAzimuthalReconstruction()
Create exchange for all window/halo cells which are used for the azimuthal periodic interpolation.
void updateAzimuthalMaxLevelRecCoords()
Update reconstruction coordinate for azimuthal halo cells on max level This is done because of moving...
static void matrixVectorProductTranspose(MFloat *c, MFloatScratchSpace &A, MFloat *b)
c=A^t*b
This class is a ScratchSpace.
Definition: scratch.h:758
MInt m_restartTimeStep
Definition: solver.h:80
MString outputDir() const
Return the directory for output files.
Definition: solver.h:407
MInt * m_bandWidth
Definition: solver.h:94
MBool m_restart
Definition: solver.h:97
std::set< MInt > m_solutionTimeSteps
Definition: solver.h:76
virtual MInt domainId() const
Return the domainId (rank)
Definition: solver.h:383
virtual MBool isActive() const
Definition: solver.h:391
MPI_Comm mpiComm() const
Return the MPI communicator used by this solver.
Definition: solver.h:380
MFloat * m_outerBandWidth
Definition: solver.h:92
MInt solverId() const
Return the solverId.
Definition: solver.h:425
MBool m_useNonSpecifiedRestartFile
Definition: solver.h:83
MString m_solutionOutput
Definition: solver.h:82
MInt m_restartInterval
The number of timesteps before writing the next restart file.
Definition: solver.h:79
MString getIdentifier(const MBool useSolverId=false, const MString preString="", const MString postString="_")
Definition: solver.cpp:188
MInt m_residualInterval
The number of timesteps before writing the next residual.
Definition: solver.h:87
MInt m_solutionOffset
Definition: solver.h:75
MBool m_singleAdaptation
Definition: solver.h:103
MInt m_restartOffset
Definition: solver.h:81
const MInt m_solverId
a unique solver identifier
Definition: solver.h:90
virtual MInt noDomains() const
Definition: solver.h:387
MBool m_restartFile
Definition: solver.h:98
MInt m_solutionInterval
The number of timesteps before writing the next solution file.
Definition: solver.h:74
MString restartDir() const
Return the directory for restart files.
Definition: solver.h:410
MFloat m_Re
the Reynolds number
Definition: solver.h:68
MFloat m_Ma
the Mach number
Definition: solver.h:71
MInt minLevel() const
Read-only accessors for grid data.
void collectVariables(T *variablesIn, ScratchSpace< T > &variablesOut, const std::vector< MString > &variablesNameIn, std::vector< MString > &variablesNameOut, const MInt noVars, const MInt noCells, const MBool reverseOrder=false)
generalised helper function for writing restart files! This is necessary for example if the minLevel ...
void extractPointIdsFromGrid(Collector< PointBasedCell< nDim > > *&, Collector< CartesianGridPoint< nDim > > *&, const MBool, const std::map< MInt, MInt > &, MInt levelThreshold=999999, MFloat *bBox=nullptr, MBool levelSetMb=false) const
Creates a list of unique corner points for all cells using a hash map levelThreshold optionally speci...
void collectParameters(T, ScratchSpace< T > &, const MChar *, std::vector< MString > &)
This function collects a single parameters for the massivley parallel IO functions.
MInt windowCellId(const MInt domainId, const MInt cellId) const
MInt haloCellId(const MInt domainId, const MInt cellId) const
void exchangeData(T *data, const MInt dataBlockSize=1)
Exchange memory in 'data' assuming a solver size of 'dataBlockSize' per cell.
SolverType
Definition: enums.h:22
@ MFLOAT
Definition: enums.h:269
@ MLONG
Definition: enums.h:269
FvCell
FV cell Property Labels.
const MInt m_revDir[6]
constexpr MLong IPOW2(MInt x)
int32_t MInt
Definition: maiatypes.h:62
std::basic_string< char > MString
Definition: maiatypes.h:55
double MFloat
Definition: maiatypes.h:52
int64_t MLong
Definition: maiatypes.h:64
bool MBool
Definition: maiatypes.h:58
char MChar
Definition: maiatypes.h:56
MInt id
Definition: maiatypes.h:71
uint64_t MUlong
Definition: maiatypes.h:65
std::bitset< p(FvCell::NumProperties)> BitsetType
Definition: kdtree.h:73
MInt locatenear(Point< DIM > pt, MFloat r, MInt *list, MInt nmax, MBool returnCellId=true)
Definition: kdtree.h:320
Definition: pointbox.h:20
Definition: contexttypes.h:19
define array structures