21template <
class SolverType>
23template <
class SolverType>
26template <MInt nDim,
class SysEqn>
30template <MInt nDim, SolverType _>
46template <MInt nDim, SolverType SolverType_>
61template <
class base_iterator,
class SolverType>
87template <
class Derived,
class SolverType_>
170template <
class SolverType>
186 MPI_Comm_rank(commStg, &myrank);
190 m_stgToCellId.assign(sortedBndryCellIds, sortedBndryCellIds + size);
202 const MInt bndryId = solver->a_bndryId(cellId);
208 const MInt ghostCellId =
m_solver->m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
221 using MyMap = std::map<MInt, MInt>;
222 MyMap cellIdToStgId_map;
223 auto cellIdToStgId = [
this, &cellIdToStgId_map](
MInt cellId) ->
MInt {
224 std::pair<MyMap::const_iterator, MBool> res = cellIdToStgId_map.insert(MyMap::value_type(cellId,
m_stgSize));
226 return res.first->second;
229 cellIdToStgId_map.insert(MyMap::value_type(
m_stgToCellId[i], i));
235 const MInt stgId = cellIdToStgId(nghbrId);
241 if(
m_solver->a_isBndryGhostCell(nghbrId)) {
242 std::cout <<
"NOO My rank " << myrank <<
"; " << nghbrId <<
"; " << stgId <<
"; "
243 << solver->a_coordinate(nghbrId, 0) <<
"|" << solver->a_coordinate(nghbrId, 1) <<
"|"
244 << solver->a_coordinate(nghbrId, 2) << std::endl;
283 return m_solver->m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
301 if(
m_solver->a_hasNeighbor(cellId, dir) > 0) {
302 return m_solver->c_neighborId(cellId, dir);
332template <
class SolverType>
350 const MPI_Comm commStg)
536 return {
this, &start_[0], &end_[0]};
545 return {
this, &start_[0], &end_[0]};
551 MInt start_[3] = {0, 0, 0};
591 constexpr static const MInt map_[6][3] = {{-1, 0, 0}, {1, 0, 0}, {0, -1, 0}, {0, 1, 0}, {0, 0, -1}, {0, 0, 1}};
596template <MInt nDim, SolverType SolverTypeR, SolverType SolverTypeL>
598template <MInt nDim, SolverType SolverTypeR, SolverType SolverTypeL>
608template <MInt nDim, SolverType SolverTypeR, SolverType SolverTypeL>
616 friend void saveStg<nDim, SolverTypeR, SolverTypeL>(std::map<MInt, self*>,
SolverTypeL_*);
622 const MPI_Comm commStg,
623 MInt* sortedBndryCellIds,
625 MInt stgFaceNormalDir,
627 MInt stgWallNormalDir,
650 template <
class _ =
void, std::enable_if_t<SolverTypeL == MAIA_STRUCTURED, _*> =
nullptr>
652 template <
class _ =
void, std::enable_if_t<SolverTypeL == MAIA_FINITE_VOLUME, _*> =
nullptr>
654 template <
class _ =
void, std::enable_if_t<SolverTypeL == MAIA_STRUCTURED, _*> =
nullptr>
656 template <
class _ =
void, std::enable_if_t<SolverTypeL == MAIA_FINITE_VOLUME, _*> =
nullptr>
658 template <
class _ =
void, std::enable_if_t<SolverTypeL == MAIA_STRUCTURED, _*> =
nullptr>
660 template <
class _ =
void, std::enable_if_t<SolverTypeL == MAIA_STRUCTURED, _*> =
nullptr>
662 template <
class _ =
void, std::enable_if_t<SolverTypeL == MAIA_FINITE_VOLUME, _*> =
nullptr>
664 template <
class _ =
void, std::enable_if_t<SolverTypeL == MAIA_STRUCTURED, _*> =
nullptr>
666 template <
class _ =
void, std::enable_if_t<SolverTypeL == MAIA_FINITE_VOLUME, _*> =
nullptr>
668 template <
class _ =
void, std::enable_if_t<SolverTypeL == MAIA_STRUCTURED, _*> =
nullptr>
670 template <
class _ =
void, std::enable_if_t<SolverTypeL == MAIA_FINITE_VOLUME, _*> =
nullptr>
672 template <
class _ =
void, std::enable_if_t<SolverTypeL == MAIA_STRUCTURED, _*> =
nullptr>
674 template <
class _ =
void, std::enable_if_t<SolverTypeL == MAIA_FINITE_VOLUME, _*> =
nullptr>
676 template <
class _ =
void, std::enable_if_t<SolverTypeR == MAIA_STRUCTURED, _*> =
nullptr,
677 std::enable_if_t<SolverTypeL == MAIA_FINITE_VOLUME, _*> =
nullptr>
679 template <
class _ =
void, std::enable_if_t<SolverTypeR == MAIA_FINITE_VOLUME, _*> =
nullptr,
680 std::enable_if_t<SolverTypeL == MAIA_FINITE_VOLUME, _*> =
nullptr>
805template <MInt nDim, SolverType SolverTypeR, SolverType SolverTypeL>
806struct MSTG<nDim, SolverTypeR, SolverTypeL>::
STG {
807 static constexpr const MInt AVG_U = 0;
808 static constexpr const MInt AVG_V = 1;
809 static constexpr const MInt AVG_W = 2;
810 static constexpr const MInt AVG_UU[3] = {0, 1, 2};
811 static constexpr const MInt AVG_RHO = nDim;
812 static constexpr const MInt AVG_P = nDim + 1;
813 static constexpr const MInt FLUC_U = nDim + 2;
814 static constexpr const MInt FLUC_V = nDim + 3;
815 static constexpr const MInt FLUC_W = nDim + 4;
816 static constexpr const MInt NU_T = nDim + 5;
817 static constexpr const MInt SIJSIJ = nDim + 6;
818 static constexpr const MInt LENGTH_SCALE = nDim + 7;
819 static constexpr const MInt FLUC_UU = nDim + 8;
820 static constexpr const MInt FLUC_UV = nDim + 9;
821 static constexpr const MInt FLUC_UW = nDim + 10;
822 static constexpr const MInt FLUC_VV = nDim + 11;
823 static constexpr const MInt FLUC_VW = nDim + 12;
824 static constexpr const MInt FLUC_WW = nDim + 13;
825 static constexpr const MInt LENGTH_X = nDim + 14;
826 static constexpr const MInt LENGTH_Y = nDim + 15;
827 static constexpr const MInt LENGTH_Z = nDim + 16;
828 static constexpr const MInt S11 = nDim + 17;
829 static constexpr const MInt S22 = nDim + 18;
830 static constexpr const MInt S33 = nDim + 19;
831 static constexpr const MInt S12 = nDim + 20;
832 static constexpr const MInt S23 = nDim + 21;
833 static constexpr const MInt S13 = nDim + 22;
834 static constexpr const MInt noStgVars = nDim + 23;
838template <MInt nDim, SolverType SolverTypeR, SolverType SolverTypeL>
846template <MInt nDim,
class SysEqn>
850 constexpr const MInt noVars = nDim + 2;
864 zCoord = Context::getSolverProperty<MFloat>(
"zCoordFor2DInterpolation", solver->
solverId(), AT_, &zCoord);
869 std::vector<std::vector<MFloat>> coords(3);
870 for(
MInt d = 0; d < 3; ++d) {
875 for(
MInt d = 0; d < nDim; ++d) {
881 coords[2][
cellId] = zCoord;
887 std::vector<MFloat*> coords_ptr(nDim);
888 for(
auto& c_ptr : coords) {
889 coords_ptr[c++] = c_ptr.data();
894 structuredInterpolation->prepareInterpolationField(&temp[0], coords_ptr.data());
898 std::array<
MString, noVars> pvariableNames;
899 pvariableNames[solver->
PV->U] =
"u";
900 pvariableNames[solver->
PV->V] =
"v";
902 pvariableNames[solver->
PV->W] =
"w";
904 pvariableNames[solver->
PV->P] =
"p";
905 pvariableNames[solver->
PV->RHO] =
"rho";
918 std::vector<MFloat> vars(solver->
a_noCells());
919 for(
MInt var = 0; var < noVars ; var++) {
920 structuredInterpolation->interpolateField(pvariableNames[var], &vars[0]);
925 m_log <<
" ... FINISHED!";
942template <MInt nDim, SolverType SolverTypeR, SolverType SolverTypeL>
952 using myMap = std::map<MInt, myStg*>;
953 const MInt noVars = myStg::STG::noStgVars;
966 MInt stgIOCoordinates = 0;
967 stgIOCoordinates = Context::getSolverProperty<MInt>(
"stgIOCoordinates", solver->solverId(), AT_, &stgIOCoordinates);
970 std::stringstream filename;
971 filename << solver->outputDir() <<
"stgRestart_" <<
globalTimeStep << ParallelIo::fileExt();
973 m_log <<
"Writing restart file " << filename.str() <<
" ..." << std::endl;
977 for(
typename myMap::const_iterator it = stgBC.begin(); it != stgBC.end(); ++it) {
978 stgBC_sorted.insert(
typename myMap::value_type(it->second->m_bcId, it->second));
982 MInt noStgBCs = stgBC_sorted.size();
983 std::vector<MInt> stgBCIds;
984 for(
typename myMap::const_iterator it = stgBC_sorted.begin(); it != stgBC_sorted.end(); ++it) {
985 stgBCIds.push_back(it->first);
988 MPI_Allreduce(MPI_IN_PLACE, &noStgBCs, 1, MPI_INT, MPI_MAX, solver->mpiComm(), AT_,
"MPI_IN_PLACE",
"noStgBCs");
989 std::vector<MInt> stgBCIds_global(noStgBCs * solver->noDomains());
990 stgBCIds.resize(noStgBCs, -1);
991 MPI_Allgather(stgBCIds.data(), noStgBCs, MPI_INT, stgBCIds_global.data(), noStgBCs, MPI_INT, solver->mpiComm(), AT_,
992 "stgBCIds",
"stgBCIds_global");
993 std::sort(stgBCIds_global.begin(), stgBCIds_global.end());
994 stgBCIds_global.erase(std::unique(stgBCIds_global.begin(), stgBCIds_global.end()), stgBCIds_global.end());
995 auto itm1 = std::find(stgBCIds_global.begin(), stgBCIds_global.end(), -1);
996 if(itm1 != stgBCIds_global.end()) stgBCIds_global.erase(itm1);
1006 ParallelIo parallelIo((filename.str()).c_str(), PIO_REPLACE, solver->mpiComm());
1007 parallelIo.setAttribute(
static_cast<MInt>(stgBCIds_global.size()),
"noStgBCs");
1008 parallelIo.setAttributes(&stgBCIds_global[0],
"stgBCIds", stgBCIds_global.size());
1014 for(
auto stgBCId : stgBCIds_global) {
1015 auto it = stgBC_sorted.find(stgBCId);
1016 if(it != stgBC_sorted.end()) {
1019 const MInt bcId = it->first;
1020 myStg* s = it->second;
1021 assert(bcId == s->m_bcId);
1022 if(bcId != s->m_bcId)
1025 std::stringstream stgPrefix_;
1026 stgPrefix_ <<
"stgVar" << s->m_bcId <<
"_";
1027 MString stgPrefix = stgPrefix_.str();
1030 ParallelIo parallelIo((filename.str()).c_str(), PIO_APPEND, s->m_commStg);
1032 parallelIo.setAttributes(&(s->m_stgMaxNoEddies), (stgPrefix +
"stgMaxNoEddies").c_str(), 1);
1033 parallelIo.defineArray(PIO_FLOAT, (stgPrefix +
"FQeddies").c_str(),
1034 s->m_stgMaxNoEddies * s->m_stgNoEddieProperties);
1035 parallelIo.setAttribute(
"FQeddies",
"name", (stgPrefix +
"FQeddies").c_str());
1036 parallelIo.setOffset(s->m_stgMaxNoEddies * s->m_stgNoEddieProperties, 0);
1037 parallelIo.writeArray(&(s->m_stgEddies[0][0]), (stgPrefix +
"FQeddies").c_str());
1050 if(stgIOCoordinates == 0 || stgIOCoordinates == 1) {
1062 std::vector<std::pair<
MInt ,
MInt >> stgGlobalIds;
1063 std::vector<std::pair<
MInt ,
MInt >> stgGlobalIdsGhost;
1067 for(
typename myStg::Accessor::nDim_citerator it_ = s->a->iterateAll();
1068 it_ != s->a->iterateAll_nDim_citerator_end();
1071 const MInt stgId = s->a->getStgId(it_);
1072 if(solver->a_isHalo(cellId)) {
1073 const MInt globalId = solver->c_globalId(cellId);
1074 stgHalo.insert(std::make_pair(globalId, stgId));
1075 }
else if(solver->a_isWindow(cellId)) {
1076 const MInt globalId = solver->c_globalId(cellId);
1077 stgWindow.insert(std::make_pair(cellId, globalId));
1079 if(!solver->a_isBndryGhostCell(cellId)) {
1080 const MInt globalId = solver->c_globalId(cellId);
1081 stgGlobalIds.push_back(std::make_pair(globalId, stgId));
1084 const MInt stgIdInternal = s->a->m_stgGhost2stgBndry[stgId];
1085 const MInt globalId = solver->c_globalId(s->a->m_stgToCellId[stgIdInternal]);
1086 stgGlobalIdsGhost.push_back(std::make_pair(globalId, stgId));
1091 if(std::is_sorted(stgGlobalIds.begin(), stgGlobalIds.end()))
1092 m_log <<
"Non-ghost stg cells already sorted after globalId" << std::endl;
1094 std::sort(stgGlobalIds.begin(), stgGlobalIds.end(),
1095 [](
const std::pair<MInt, MInt>&
a,
const std::pair<MInt, MInt>&
b) { return a.first < b.first; });
1097 if(std::is_sorted(stgGlobalIdsGhost.begin(), stgGlobalIdsGhost.end()))
1098 m_log <<
"Ghost stg cells already sorted after globalId" << std::endl;
1100 std::sort(stgGlobalIdsGhost.begin(), stgGlobalIdsGhost.end(),
1101 [](
const std::pair<MInt, MInt>&
a,
const std::pair<MInt, MInt>&
b) { return a.first < b.first; });
1112 const MInt noNeighborDomains = solver->noNeighborDomains();
1113 std::vector<MInt> snghbrs(noNeighborDomains);
1114 for(
MInt d = 0; d < noNeighborDomains; ++d) {
1115 snghbrs[d] = solver->neighborDomain(d);
1119 std::vector<MInt> sendcounts(noNeighborDomains);
1120 std::vector<MInt> stgWindowGlobalId(stgWindow.size());
1122 for(
MInt domain = 0; domain < noNeighborDomains; ++domain) {
1123 for(
MInt window = 0; window < solver->noWindowCells(domain); ++window) {
1124 auto it_ = stgWindow.find(solver->grid().windowCell(domain, window));
1125 if(it_ != stgWindow.end()) {
1126 stgWindowGlobalId[cnt++] = it_->second;
1127 ++sendcounts[domain];
1131 if(
static_cast<MUint>(cnt) != stgWindow.size()) TERMM(-1,
"Scheisse Alter!!!");
1134 std::vector<MInt> globalIdsOfNghbrWindowCells =
1146 for(
auto globalId : globalIdsOfNghbrWindowCells) {
1147 auto it_ = stgHalo.find(globalId);
1148 if(it_ != stgHalo.end()) {
1156 if(!std::is_sorted(stgHalo.begin(), stgHalo.end(),
1157 [](
const std::pair<MInt, MInt>&
a,
const std::pair<MInt, MInt>&
b) {
1158 return a.first < b.first;
1161 TERMM(-1,
"If you read this message you are stupid!");
1163 std::vector<MInt> haloGlobalIds(stgHalo.size());
1164 std::fill(sendcounts.begin(), sendcounts.end(), 0);
1167 for(
auto& h : stgHalo) {
1168 haloGlobalIds[cnt++] = h.first;
1169 while(!(h.first < solver->domainOffset(domain + 1))) {
1172 ++sendcounts[domain];
1190 std::vector<MFloat> tempStgVarsWS(noVars * stgHalo.size());
1192 for(
auto& globalId_stgId : stgHalo) {
1193 const MInt stgId = globalId_stgId.second;
1194 for(
MInt var = 0; var < myStg::STG::noStgVars; ++var) {
1195 tempStgVarsWS[myStg::STG::noStgVars * cnt + var] = s->m_stgLVariables[var][stgId];
1212 std::map<
MInt ,
MInt > stgGlobalIdsWindow;
1214 for(
auto globalId : stgGlobalIdsWindow_) {
1215 stgGlobalIdsWindow.insert(std::make_pair(globalId, cnt++));
1217 std::vector<std::pair<MInt, MInt>> stgGlobalIdsWindowV(stgGlobalIdsWindow.begin(), stgGlobalIdsWindow.end());
1229 MInt noStgInternalCells = stgGlobalIds.size() + stgGlobalIdsWindowV.size();
1230 MInt noStgGhostCells = stgGlobalIdsGhost.size();
1231 std::vector<MFloat> tempStgVars(noStgInternalCells * noVars);
1232 std::vector<MFloat> tempStgGVars(noStgGhostCells * noVars);
1233 std::vector<MInt> posInSTG(stgGlobalIds.size());
1234 std::vector<MInt> posInSTGWindow(stgGlobalIdsWindowV.size());
1235 MInt cnt1 = 0, cnt2 = 0;
1237 for(
MInt i = 0; i < noStgInternalCells; ++i) {
1238 if(stgGlobalIds[cnt1] < stgGlobalIdsWindowV[cnt2]) {
1239 posInSTG[cnt1++] = i;
1241 posInSTGWindow[cnt2++] = i;
1244 if(
static_cast<MUint>(cnt1) != stgGlobalIds.size() ||
static_cast<MUint>(cnt2) != stgGlobalIdsWindowV.size())
1245 TERMM(-1,
"cnt1 != stgGlobalIds.size() or cnt2 != stgGlobalIds.size()");
1246 for(
MInt var = 0; var < noVars; ++var) {
1247 for(
MUint i = 0; i < posInSTG.size(); ++i) {
1248 const MInt stgId = stgGlobalIds[i].second;
1249 tempStgVars[var * noStgInternalCells + posInSTG[i]] = s->m_stgLVariables[var][stgId];
1251 for(
MUint i = 0; i < posInSTGWindow.size(); ++i) {
1252 const MInt stgId = stgGlobalIdsWindowV[i].second;
1253 tempStgVars[var * noStgInternalCells + posInSTGWindow[i]] = tempStgVarsWR[var + stgId * noVars];
1256 for(std::vector<std::pair<MInt, MInt>>::const_iterator it_ = stgGlobalIdsGhost.begin();
1257 it_ != stgGlobalIdsGhost.end();
1259 const MInt stgId = it_->second;
1260 tempStgGVars[var * noStgInternalCells + cnt] = s->m_stgLVariables[var][stgId];
1266 std::vector<MInt> globalIds(noStgInternalCells);
1267 std::vector<MInt> globalIdsGhost(noStgGhostCells);
1268 for(
MUint i = 0; i < posInSTG.size(); ++i) {
1269 globalIds[posInSTG[i]] = stgGlobalIds[i].first;
1271 for(
MUint i = 0; i < posInSTGWindow.size(); ++i) {
1272 globalIds[posInSTGWindow[i]] = stgGlobalIdsWindowV[i].first;
1274 for(
MInt i = 0; i < noStgGhostCells; ++i) {
1275 globalIdsGhost[i] = stgGlobalIdsGhost[i].first;
1281 MInt noStgInternalCellsGlobal = 0;
1282 MInt noStgGhostCellsGlobal = 0;
1285 MInt noDomains = solver->noDomains();
1286 MInt* noStgInternalCellsPerRank =
new MInt[noDomains];
1287 MInt* noStgGhostCellsPerRank =
new MInt[noDomains];
1288 MPI_Allgather(&noStgInternalCells, 1, MPI_INT, noStgInternalCellsPerRank, 1, MPI_INT, s->m_commStg, AT_,
1289 "noStgInternalCells",
"noStgInternalCellsPerRank");
1290 MPI_Allgather(&noStgGhostCells, 1, MPI_INT, noStgGhostCellsPerRank, 1, MPI_INT, s->m_commStg, AT_,
1291 "noStgGhostCells",
"noStgGhostCellsPerRank");
1293 displ =
new MInt[noDomains];
1294 displG =
new MInt[noDomains];
1297 for(
MInt i = 1; i < noDomains; ++i) {
1298 displ[i] = displ[i - 1] + noStgInternalCellsPerRank[i - 1];
1299 displG[i] = displG[i - 1] + noStgGhostCellsPerRank[i - 1];
1301 noStgInternalCellsGlobal = std::accumulate(noStgInternalCellsPerRank, noStgInternalCellsPerRank + noDomains, 0);
1302 noStgGhostCellsGlobal = std::accumulate(noStgGhostCellsPerRank, noStgGhostCellsPerRank + noDomains, 0);
1305 ScratchSpace<MInt> globalIdsGlobal(noStgInternalCellsGlobal, AT_,
"globalIdsGlobal");
1306 ScratchSpace<MInt> globalIdsGhostGlobal(noStgGhostCellsGlobal, AT_,
"globalIdsGhostGlobal");
1307 MPI_Gatherv(&globalIds[0], noStgInternalCells, MPI_INT, &globalIdsGlobal[0], &noStgInternalCellsPerRank[0],
1308 &displ[0], MPI_INT, 0, s->m_commStg, AT_,
"globalIds[0]",
"globalIdsGlobal[0]");
1309 MPI_Gatherv(&globalIdsGhost[0], noStgGhostCells, MPI_INT, &globalIdsGhostGlobal[0], &noStgGhostCellsPerRank[0],
1310 &displG[0], MPI_INT, 0, s->m_commStg, AT_,
"globalIdsGhost[0]",
"globalIdsGhostGlobal[0]");
1313 if(s->m_stgMyRank == s->m_commStgRoot) {
1321 if(!std::is_sorted(globalIdsGlobal.begin(), globalIdsGlobal.end())) TERMM(-1,
"MAIA sucks");
1322 if(!std::is_sorted(globalIdsGhostGlobal.begin(), globalIdsGhostGlobal.end())) TERMM(-1,
"MAIA sucks");
1324 for(
MInt i = 0; i < noStgInternalCellsGlobal - 1; ++i) {
1325 if(globalIdsGlobal[i] == globalIdsGhost[i + 1]) TERMM(-1,
"MAIA really sucks");
1327 for(
MInt i = 0; i < noStgGhostCellsGlobal - 1; ++i) {
1328 if(globalIdsGhostGlobal[i] == globalIdsGhostGlobal[i + 1]) TERMM(-1,
"MAIA really sucks");
1342 ParallelIo parallelIo((filename.str()).c_str(), PIO_APPEND, solver->mpiComm());
1345 ParallelIo::size_type stgInternalOffset, stgGhostOffset;
1346 ParallelIo::size_type stgGlobalNoInternalCells, stgGlobalNoGhostCells;
1347 parallelIo.calcOffset(noStgInternalCells, &stgInternalOffset, &stgGlobalNoInternalCells, solver->mpiComm());
1348 parallelIo.calcOffset(noStgGhostCells, &stgGhostOffset, &stgGlobalNoGhostCells, solver->mpiComm());
1350 assert(stgGlobalNoInternalCells == noStgInternalCellsGlobal);
1351 assert(stgGlobalNoGhostCells == noStgGhostCellsGlobal);
1354 parallelIo.defineArray(PIO_INT, (stgPrefix +
"globalIdsInternal").c_str(), noStgInternalCells);
1355 parallelIo.defineArray(PIO_INT, (stgPrefix +
"globalIdsGhost").c_str(), noStgGhostCells);
1358 parallelIo.setOffset(noStgInternalCells, stgInternalOffset);
1359 parallelIo.writeArray(&globalIds[0], (stgPrefix +
"globalIdsInternal").c_str());
1360 parallelIo.setOffset(noStgGhostCells, stgGhostOffset);
1361 parallelIo.writeArray(&globalIdsGhost[0], (stgPrefix +
"globalIdsGhost").c_str());
1364 parallelIo.setOffset(noStgInternalCells, stgInternalOffset);
1365 for(
MInt var = 0; var < myStg::STG::noStgVars; ++var) {
1366 std::stringstream varName;
1367 varName << stgPrefix + std::to_string(var);
1368 parallelIo.defineArray(PIO_FLOAT, (varName.str()).c_str(), noStgInternalCells);
1369 parallelIo.writeArray(&tempStgVars[var * noStgInternalCells], (varName.str()).c_str());
1371 parallelIo.setOffset(noStgGhostCells, stgGhostOffset);
1372 for(
MInt var = 0; var < myStg::STG::noStgVars; ++var) {
1373 std::stringstream varName;
1374 varName << stgPrefix +
"G_" + std::to_string(var);
1375 parallelIo.defineArray(PIO_FLOAT, (varName.str()).c_str(), noStgGhostCells);
1376 parallelIo.writeArray(&tempStgGVars[var * noStgGhostCells], (varName.str()).c_str());
1379 if(stgIOCoordinates == 1) {
1383 for(
auto globalId : globalIds) {
1384 const MInt cellId = globalId - solver->domainOffset(solver->domainId());
1385 for(
MInt d = 0; d < nDim; ++d) {
1386 tempStgCoord.p[noStgInternalCells * d + cnt] = s->a->a_coordinate(cellId, d);
1391 for(
auto globalId : globalIds) {
1392 const MInt cellId = globalId - solver->domainOffset(solver->domainId());
1393 const MInt bndryId = solver->a_bndryId(cellId);
1394 if(bndryId < 0) TERMM(-1,
"");
1395 const MInt ghostCellId =
1396 solver->a_bndryGhostCellId(bndryId,
1398 for(
MInt d = 0; d < nDim; ++d) {
1399 tempStgGCoord.p[noStgGhostCells * d + cnt] = s->a->a_coordinate(ghostCellId, d);
1403 parallelIo.setOffset(noStgInternalCells, stgInternalOffset);
1404 for(
MInt d = 0; d < nDim; ++d) {
1405 std::stringstream varName;
1406 varName << stgPrefix +
"x" + std::to_string(d);
1407 parallelIo.defineArray(PIO_FLOAT, (varName.str()).c_str(), noStgInternalCells);
1408 parallelIo.writeArray(&tempStgCoord.p[noStgInternalCells * d], (varName.str()).c_str());
1410 parallelIo.setOffset(noStgGhostCells, stgGhostOffset);
1411 for(
MInt d = 0; d < nDim; ++d) {
1412 std::stringstream varName;
1413 varName << stgPrefix +
"G_" +
"x" + std::to_string(d);
1414 parallelIo.defineArray(PIO_FLOAT, (varName.str()).c_str(), noStgGhostCells);
1415 parallelIo.writeArray(&tempStgGCoord.p[noStgGhostCells * d], (varName.str()).c_str());
1418 }
else if(stgIOCoordinates == 2) {
1432 MPI_Comm_size(s->m_commStg, &comm_size);
1433 std::vector<MInt> local2GlobalRank(comm_size);
1434 const MInt temp = solver->domainId();
1435 MPI_Allgather(&temp, 1, MPI_INT, local2GlobalRank.data(), 1, MPI_INT, s->m_commStg, AT_,
"solver->domainId()",
1436 "local2GlobalRank");
1437 if(!std::is_sorted(local2GlobalRank.begin(), local2GlobalRank.end())) TERMM(1,
"ERROR!");
1440 for(
typename myStg::Accessor::nDim_citerator it_ = s->a->iterateAll();
1441 it_ != s->a->iterateAll_nDim_citerator_end();
1444 if(solver->a_isBndryGhostCell(cellId))
1446 if(solver->a_isWindow(cellId)) {
1447 const MInt globalId = solver->c_globalId(cellId);
1448 stgWindow.insert(std::make_pair(cellId, globalId));
1453 const MInt noNeighborDomains = solver->noNeighborDomains();
1454 std::vector<MInt> snghbrs;
1455 std::vector<MInt> nghbr_commSTG2mpiComm;
1456 for(
MInt d = 0; d < noNeighborDomains; ++d) {
1457 auto it_ = std::find(local2GlobalRank.begin(), local2GlobalRank.end(), solver->neighborDomain(d));
1458 if(it_ != local2GlobalRank.end()) {
1459 snghbrs.push_back(std::distance(local2GlobalRank.begin(), it_));
1460 nghbr_commSTG2mpiComm.push_back(d);
1465 const MInt noNeighborDomainsLocal = snghbrs.size();
1466 std::vector<MInt> sendcounts(noNeighborDomainsLocal);
1467 std::vector<MInt> stgWindowGlobalId;
1469 MInt noDoubleEntries = 0;
1470 for(
MInt domain_ = 0; domain_ < noNeighborDomainsLocal; ++domain_) {
1471 const MInt domain = nghbr_commSTG2mpiComm[domain_];
1472 for(
MInt window = 0; window < solver->noWindowCells(domain); ++window) {
1473 auto it_ = stgWindow.find(solver->grid().windowCell(domain, window));
1474 if(it_ != stgWindow.end()) {
1475 auto it__ = std::find(stgWindowGlobalId.begin(), stgWindowGlobalId.end(), it_->second);
1476 if(it__ != stgWindowGlobalId.end()) {
1480 stgWindowGlobalId.push_back(it_->second);
1482 ++sendcounts[domain_];
1487 if(
static_cast<MUint>(cnt - noDoubleEntries) != stgWindow.size()) {
1488 std::cout <<
"SCHEISSE: RANK=" << solver->domainId() <<
": " << cnt <<
"; " << noDoubleEntries <<
"; "
1489 << stgWindow.size() <<
"; " << stgWindowGlobalId.size() << std::endl;
1490 std::cout << std::endl;
1492 if(
static_cast<MUint>(cnt) != stgWindowGlobalId.size()) TERMM(1,
"NEINNNNN");
1496 MPI_Comm_rank(s->m_commStg, &myrank);
1498 std::vector<MInt> globalIdsOfNghbrWindowCells =
1501 noNeighborDomainsLocal,
1504 noNeighborDomainsLocal,
1510 std::vector<std::pair<
MInt ,
MInt >> stgGlobalIds;
1511 stgGlobalIds.reserve(s->a->sizeStg());
1512 std::vector<std::pair<
MInt ,
MInt >> stgIsGhost;
1513 stgIsGhost.reserve(s->a->sizeStg());
1514 MInt noHaloWithNoWindow = 0;
1515 MInt noHaloTotal = 0;
1516 for(
typename myStg::Accessor::nDim_citerator it_ = s->a->iterateAll();
1517 it_ != s->a->iterateAll_nDim_citerator_end();
1520 const MInt stgId = s->a->getStgId(it_);
1528 if(solver->a_isBndryGhostCell(cellId)) {
1529 const MInt stgIdInternal = s->a->m_stgGhost2stgBndry[stgId];
1530 cellId_ = s->a->m_stgToCellId[stgIdInternal];
1533 if(solver->a_isPeriodic(cellId_))
continue;
1534 if(solver->a_isHalo(cellId_) ) {
1536 const MInt globalId = solver->c_globalId(cellId_);
1541 if(std::find(globalIdsOfNghbrWindowCells.begin(), globalIdsOfNghbrWindowCells.end(), globalId)
1542 != globalIdsOfNghbrWindowCells.end()) {
1545 ++noHaloWithNoWindow;
1549 if(!solver->a_isBndryGhostCell(cellId)) {
1550 const MInt globalId = solver->c_globalId(cellId);
1553 stgGlobalIds.push_back(std::make_pair(globalId, stgId));
1554 stgIsGhost.push_back(std::make_pair(globalId, 0));
1557 if(stgId > 2 * s->a->m_noBcCells) {
1558 std::cout <<
"z) On rank=" << myrank <<
":EOOR " << stgId <<
"; " << s->a->m_noBcCells << std::endl;
1561 const MInt stgIdInternal = s->a->m_stgGhost2stgBndry[stgId];
1562 if(stgIdInternal > s->a->m_noBcCells) {
1563 std::cout <<
"z2) On rank=" << myrank <<
":EOOR " << stgIdInternal <<
"; " << s->a->m_noBcCells <<
"; "
1564 << stgId << std::endl;
1567 const MInt globalId = solver->c_globalId(s->a->m_stgToCellId[stgIdInternal]);
1572 stgGlobalIds.push_back(std::make_pair(globalId, stgId));
1574 stgIsGhost.push_back(std::make_pair(globalId, 1));
1577 std::cout <<
"On domain " << solver->domainId() <<
": " << noHaloWithNoWindow <<
" of "
1578 << noHaloTotal <<
" halo cells have no window cells somewhere else" << std::endl;
1582 if(std::is_sorted(stgGlobalIds.begin(), stgGlobalIds.end()))
1583 m_log <<
"stg cells already sorted after globalId" << std::endl;
1585 std::sort(stgIsGhost.begin(), stgIsGhost.end(),
1586 [](
const std::pair<MInt, MInt>&
a,
const std::pair<MInt, MInt>&
b) { return a.first < b.first; });
1587 std::sort(stgGlobalIds.begin(), stgGlobalIds.end(),
1588 [](
const std::pair<MInt, MInt>&
a,
const std::pair<MInt, MInt>&
b) { return a.first < b.first; });
1593 MInt noStgInternalCells = stgGlobalIds.size();
1594 std::vector<MFloat> tempStgVars(noStgInternalCells * noVars);
1595 for(
MInt var = 0; var < noVars; ++var) {
1597 for(
auto& it_ : stgGlobalIds) {
1598 const MInt stgId = it_.second;
1599 tempStgVars[var * noStgInternalCells + cnt++] = s->m_stgLVariables[var][stgId];
1604 std::vector<MInt> globalIds(noStgInternalCells);
1605 std::vector<MInt> isGhost(noStgInternalCells);
1607 for(
auto itGlobalId = stgGlobalIds.begin(), itIsGhost = stgIsGhost.begin();
1608 itGlobalId != stgGlobalIds.end() ; ++itGlobalId, ++itIsGhost) {
1609 globalIds[cnt] = itGlobalId->first;
1610 isGhost[cnt] = itIsGhost->second;
1618 MInt noInvolvedRanks;
1619 MPI_Comm_size(s->m_commStg, &noInvolvedRanks);
1620 MInt* noStgInternalCellsPerRank =
new MInt[noInvolvedRanks];
1621 MPI_Allgather(&noStgInternalCells, 1, MPI_INT, noStgInternalCellsPerRank, 1, MPI_INT, s->m_commStg, AT_,
1622 "noStgInternalCells",
"noStgInternalCellsPerRank");
1623 displ =
new MInt[noInvolvedRanks];
1625 for(
MInt i = 1; i < noInvolvedRanks; ++i) {
1626 displ[i] = displ[i - 1] + noStgInternalCellsPerRank[i - 1];
1628 MInt noStgInternalCellsGlobal =
1629 std::accumulate(noStgInternalCellsPerRank, noStgInternalCellsPerRank + noInvolvedRanks, 0);
1631 ScratchSpace<MInt> globalIdsGlobal(noStgInternalCellsGlobal, AT_,
"globalIdsGlobal");
1632 MPI_Allgatherv(&globalIds[0], noStgInternalCells, MPI_INT, &globalIdsGlobal[0], &noStgInternalCellsPerRank[0],
1633 &displ[0], MPI_INT, s->m_commStg, AT_,
"globalIds[0]",
"globalIdsGlobal[0]");
1635 MInt* noHaloWithNoWindowGlobal =
new MInt[noInvolvedRanks];
1636 MPI_Allgather(&noHaloWithNoWindow, 1, MPI_INT, &noHaloWithNoWindowGlobal[0], 1, MPI_INT, s->m_commStg, AT_,
1637 "noHaloWithNoWindow",
"noHaloWithNoWindowGlobal");
1645 MInt isGloballySorted = 1;
1646 if(!std::is_sorted(globalIdsGlobal.begin(), globalIdsGlobal.end())) {
1647 isGloballySorted = 0;
1665 ParallelIo parallelIo((filename.str()).c_str(), PIO_APPEND, s->m_commStg);
1667 parallelIo.setAttribute(isGloballySorted, (stgPrefix +
"isGloballySorted").c_str());
1670 ParallelIo::size_type stgInternalOffset;
1671 ParallelIo::size_type stgGlobalNoInternalCells;
1672 parallelIo.calcOffset(noStgInternalCells, &stgInternalOffset, &stgGlobalNoInternalCells, s->m_commStg);
1674 assert(stgGlobalNoInternalCells == noStgInternalCellsGlobal);
1675 if(stgGlobalNoInternalCells != noStgInternalCellsGlobal) {
1676 std::cout <<
"ERROR " << stgGlobalNoInternalCells <<
"; " << noStgInternalCellsGlobal << std::endl;
1677 TERMM(1,
"stgGlobalNoInternalCells != noStgInternalCellsGlobal");
1681 parallelIo.defineArray(PIO_INT, (stgPrefix +
"globalIdsInternal").c_str(), stgGlobalNoInternalCells);
1682 parallelIo.defineArray(PIO_INT, (stgPrefix +
"isGhost").c_str(), stgGlobalNoInternalCells);
1684 for(
MInt var = 0; var < myStg::STG::noStgVars; ++var) {
1685 std::stringstream varName;
1686 varName << stgPrefix + std::to_string(var);
1687 parallelIo.defineArray(PIO_FLOAT, (varName.str()).c_str(), stgGlobalNoInternalCells);
1690 for(
MInt d = 0; d < nDim; ++d) {
1691 std::stringstream varName;
1692 varName << stgPrefix +
"x" + std::to_string(d);
1693 parallelIo.defineArray(PIO_FLOAT, (varName.str()).c_str(), stgGlobalNoInternalCells);
1697 parallelIo.setOffset(noStgInternalCells, stgInternalOffset);
1698 parallelIo.writeArray(&globalIds[0], (stgPrefix +
"globalIdsInternal").c_str());
1699 parallelIo.writeArray(&isGhost[0], (stgPrefix +
"isGhost").c_str());
1702 for(
MInt var = 0; var < myStg::STG::noStgVars; ++var) {
1703 std::stringstream varName;
1704 varName << stgPrefix + std::to_string(var);
1705 parallelIo.writeArray(&tempStgVars[var * noStgInternalCells], (varName.str()).c_str());
1710 for(std::vector<std::pair<MInt, MInt>>::const_iterator it_ = stgGlobalIds.begin(); it_ != stgGlobalIds.end();
1712 const MInt stgId = it_->second;
1713 const MInt cellId = s->a->m_stgToCellId[stgId];
1714 for(
MInt d = 0; d < nDim; ++d) {
1715 tempStgCoord.p[noStgInternalCells * d + cnt] = s->a->a_coordinate(cellId, d);
1720 if(cnt != noStgInternalCells) TERMM(1,
"errror");
1721 for(
MInt d = 0; d < nDim; ++d) {
1722 std::stringstream varName;
1723 varName << stgPrefix +
"x" + std::to_string(d);
1724 parallelIo.writeArray(&(tempStgCoord.p[noStgInternalCells * d]), (varName.str()).c_str());
1728 TERMM(-1,
"Unknown value for property stgIOCoordinates");
1731 m_log <<
"::saveStg: Finished writing stgRestart for " << stgBCId << std::endl;
1736template <MInt nDim, SolverType SolverTypeR, SolverType SolverTypeL>
1740 m_log <<
"Loading stg stuff ..." << std::endl;
1753 MInt stgIOCoordinates = 0;
1754 stgIOCoordinates = Context::getSolverProperty<MInt>(
"stgIOCoordinates", m_solver->solverId(), AT_, &stgIOCoordinates);
1756 std::stringstream filename;
1757 filename << m_solver->restartDir() <<
"stgRestart_" <<
globalTimeStep << ParallelIo::fileExt();
1762 ParallelIo parallelIo((filename.str()).c_str(), PIO_READ, m_commStg );
1765 parallelIo.getAttribute(&noStgBCs,
"noStgBCs");
1766 std::vector<MInt> bcIds(noStgBCs);
1767 parallelIo.getAttribute(&bcIds[0],
"stgBCIds", noStgBCs);
1770 if(std::find(bcIds.begin(), bcIds.end(), m_bcId) == bcIds.end())
1771 TERMM(-1,
"Current bcId not found in stgRestart file!");
1774 std::stringstream stgPrefix_;
1775 stgPrefix_ <<
"stgVar" << m_bcId <<
"_";
1776 MString stgPrefix = stgPrefix_.str();
1780 ParallelIo parallelIo((filename.str()).c_str(), PIO_READ, m_commStg);
1781 MInt stgMaxNoEddies;
1782 parallelIo.getAttribute(&stgMaxNoEddies, (stgPrefix +
"stgMaxNoEddies").c_str());
1783 if(stgMaxNoEddies != m_stgMaxNoEddies && !m_stgCreateNewEddies) TERMM(-1,
"");
1784 ParallelIo::size_type stgMaxNoEddies_ = parallelIo.getArraySize((stgPrefix +
"FQeddies").c_str());
1785 if(stgMaxNoEddies_ != stgMaxNoEddies * m_stgNoEddieProperties) TERMM(-1,
"");
1787 parallelIo.setOffset(stgMaxNoEddies_, 0);
1788 parallelIo.readArray(&(m_stgEddies[0][0]), (stgPrefix +
"FQeddies").c_str());
1792 if(stgIOCoordinates == 0 || stgIOCoordinates == 1) {
1798 ParallelIo parallelIo((filename.str()).c_str(), PIO_READ, m_solver->mpiComm());
1799 ParallelIo::size_type noStgInternalCellsGlobal = parallelIo.getArraySize((stgPrefix +
"globalIdsInternal").c_str());
1800 ParallelIo::size_type noStgGhostCellsGlobal = parallelIo.getArraySize((stgPrefix +
"globalIdsGhost").c_str());
1801 std::vector<MInt> globalIdsInternalGlobal(noStgInternalCellsGlobal);
1802 std::vector<MInt> globalIdsGhostGlobal(noStgGhostCellsGlobal);
1803 parallelIo.setOffset(noStgInternalCellsGlobal, 0);
1804 parallelIo.readArray(globalIdsInternalGlobal.data(), (stgPrefix +
"globalIdsInternal").c_str());
1805 parallelIo.setOffset(noStgGhostCellsGlobal, 0);
1806 parallelIo.readArray(globalIdsGhostGlobal.data(), (stgPrefix +
"globalIdsGhost").c_str());
1808 if(!std::is_sorted(globalIdsInternalGlobal.begin(), globalIdsInternalGlobal.end()))
1809 TERMM(-1,
"globalIdsInternal is not sorted in stgRestart file");
1810 if(!std::is_sorted(globalIdsGhostGlobal.begin(), globalIdsGhostGlobal.end()))
1811 TERMM(-1,
"globalIdsGhost is not sorted in stgRestart file");
1814 auto lower = std::lower_bound(globalIdsInternalGlobal.begin(), globalIdsInternalGlobal.end(),
1815 m_solver->domainOffset(m_solver->domainId()));
1816 auto upper = std::upper_bound(globalIdsInternalGlobal.begin(), globalIdsInternalGlobal.end(),
1817 m_solver->domainOffset(m_solver->domainId() + 1));
1818 std::vector<MInt> offsets(2 * m_solver->noDomains());
1819 const MInt domOff[] = {
static_cast<MInt>(std::distance(globalIdsInternalGlobal.begin(), lower)),
1820 static_cast<MInt>(std::distance(globalIdsInternalGlobal.begin(), upper))};
1821 const MInt noStgRestartCellsLocal = domOff[1] - domOff[0];
1823 if(!m_stgLocal && noStgRestartCellsLocal > 0) {
1824 m_log <<
"Domain " << m_solver->domainId() <<
" has stg data, but is not stg domain" << std::endl;
1826 for(
MInt i = domOff[0]; i < domOff[1]; ++i) {
1827 const MInt cellId = globalIdsInternalGlobal[i] - m_solver->domainOffset(m_solver->domainId());
1828 if(!m_solver->a_isWindow(cellId)) {
1829 TERMM(-1,
"Domain has non-window data, even though it is no stg domain!");
1834 MPI_Gather(&domOff[0], 2, MPI_INT, offsets.data(), 2, MPI_INT, 0, m_commStg, AT_,
"domOff[0]",
"offsets.data()");
1835 if(m_commStgMyRank == m_commStgRoot) {
1836 if(offsets[0] != 0) TERMM(-1,
"offsets[0] != 0");
1837 if(offsets[offsets.size() - 1] != noStgInternalCellsGlobal) TERMM(-1,
"");
1838 for(
MInt rank = 0; rank < m_solver->noDomains() - 1; ++rank) {
1839 if(offsets[rank * 2 + 1] != offsets[(rank + 1) * 2 + 0]) TERMM(-1,
"");
1845 std::map<
MInt ,
MInt > globalIdStgIdRestartMap;
1846 for(
MInt i = domOff[0]; i < domOff[1]; ++i) {
1847 globalIdStgIdRestartMap.insert(globalIdStgIdRestartMap.end(),
1848 std::map<MInt, MInt>::value_type(globalIdsInternalGlobal[i], i - domOff[0]));
1851 auto lowerG = std::lower_bound(globalIdsGhostGlobal.begin(), globalIdsGhostGlobal.end(),
1852 m_solver->domainOffset(m_solver->domainId()));
1853 auto upperG = std::upper_bound(globalIdsGhostGlobal.begin(), globalIdsGhostGlobal.end(),
1854 m_solver->domainOffset(m_solver->domainId() + 1));
1855 if(std::distance(lowerG, upperG) < 1) TERMM(-1,
"");
1856 std::vector<MInt> offsetsG(2 * m_solver->noDomains());
1857 const MInt domOffG[] = {
static_cast<MInt>(std::distance(globalIdsGhostGlobal.begin(), lowerG)),
1858 static_cast<MInt>(std::distance(globalIdsGhostGlobal.begin(), upperG))};
1859 MInt noStgGRestartCellsLocal = domOffG[1] - domOffG[0];
1861 if(!m_stgLocal && noStgGRestartCellsLocal > 0) TERMM(-1,
"");
1862 MPI_Gather(&domOffG[0], 2, MPI_INT, offsetsG.data(), 2, MPI_INT, 0, m_commStg, AT_,
"domOffG[0]",
1864 if(m_commStgMyRank == m_commStgRoot) {
1865 if(offsetsG[0] != 0) TERMM(-1,
"offsetsG[0] != 0");
1866 if(offsetsG[offsetsG.size() - 1] != noStgGhostCellsGlobal) TERMM(-1,
"");
1867 for(
MInt rank = 0; rank < m_solver->noDomains() - 1; ++rank) {
1868 if(offsetsG[rank * 2 + 1] != offsetsG[(rank + 1) * 2 + 0]) TERMM(-1,
"");
1871 std::vector<MInt> globalIdsGhost(lowerG, upperG);
1881 std::map<
MInt ,
MInt > window_cellId_restartStgId;
1883 for(
auto& it : globalIdStgIdRestartMap) {
1886 const MInt cellId = it.first - m_solver->domainOffset(m_solver->domainId());
1887 if(m_solver->a_isWindow(cellId)) {
1888 window_cellId_restartStgId.insert(std::make_pair(cellId, it.second));
1893 const MInt noNeighborDomains = m_solver->noNeighborDomains();
1894 std::vector<MInt> snghbrs(noNeighborDomains);
1895 for(
MInt d = 0; d < noNeighborDomains; ++d) {
1896 snghbrs[d] = m_solver->neighborDomain(d);
1900 std::vector<MInt> sendcounts(noNeighborDomains);
1901 std::vector<MInt> stgWindowSortedGlobalId(window_cellId_restartStgId.size());
1902 std::vector<MInt> stgWindowSortedRestartStgId(window_cellId_restartStgId.size());
1904 for(
MInt domain = 0; domain < noNeighborDomains; ++domain) {
1905 for(
MInt window = 0; window < m_solver->noWindowCells(domain); ++window) {
1906 auto it = window_cellId_restartStgId.find(m_solver->grid().windowCell(domain, window));
1907 if(it != window_cellId_restartStgId.end()) {
1908 stgWindowSortedGlobalId[cnt] = m_solver->c_globalId(it->first);
1909 stgWindowSortedRestartStgId[cnt] = it->second;
1910 ++sendcounts[domain];
1915 if(
static_cast<MUint>(cnt) != window_cellId_restartStgId.size()) TERMM(-1,
"Scheisse Alter!!!");
1922 for(
MInt var = 0; var < STG::noStgVars; ++var) {
1923 parallelIo.setOffset(noStgRestartCellsLocal, domOff[0]);
1924 parallelIo.readArray(tempStgVars.getPointer(), (stgPrefix + std::to_string(var)).c_str());
1925 parallelIo.setOffset(noStgGRestartCellsLocal, domOffG[0]);
1926 parallelIo.readArray(tempStgGVars.getPointer(), (stgPrefix + std::to_string(var)).c_str());
1931 const MInt noVars = STG::noStgVars;
1932 MInt noWindowsToSend = window_cellId_restartStgId.size();
1933 std::vector<MFloat> tempStgVarsWS(noWindowsToSend * noVars);
1934 for(
MInt var = 0; var < noVars; ++var) {
1936 for(
auto stgIdRestart : stgWindowSortedRestartStgId) {
1937 tempStgVarsWS[var * noWindowsToSend + cnt++] = tempStgVars[var * noStgRestartCellsLocal + stgIdRestart];
1942 std::vector<MInt> globalIdsOfNghbrWindowCells =
1949 m_solver->mpiComm(),
1950 m_solver->domainId(),
1959 m_solver->mpiComm(),
1960 m_solver->domainId(),
1966 for(
MInt i = 0; i < noStgRestartCellsLocal; ++i) {
1967 globalIdStgIdRestartMap.insert(std::make_pair(globalIdsInternalGlobal[i + domOff[0]], i));
1969 for(
MUint i = 0; i < globalIdsOfNghbrWindowCells.size(); ++i) {
1970 map2.insert(std::make_pair(globalIdsOfNghbrWindowCells[i], i));
1974 const MInt stgId =
a->getStgId(it);
1977 if(m_solver->a_isHalo(cellId)) {
1978 const MInt globalId = m_solver->c_globalId(cellId);
1979 auto it_ = map2.find(globalId);
1980 if(it_ == map2.end()) TERMM(-1,
"");
1981 const MInt stgIdRestart = it_->second;
1983 for(
MInt var = 0; var < noVars; ++var) {
1984 m_stgLVariables[var][stgId] = tempStgVarsWR[noVars * stgIdRestart + var];
1986 }
else if(m_solver->a_isBndryGhostCell(cellId)) {
1987 const MInt stgBndry =
a->m_stgGhost2stgBndry[stgId];
1988 const MInt globalId = m_solver->c_globalId(
a->m_stgToCellId[stgBndry]);
1989 const MInt stgIdRestart =
1990 std::find(globalIdsGhost.begin(), globalIdsGhost.end(), globalId) - globalIdsGhost.begin();
1991 for(
MInt var = 0; var < noVars; ++var) {
1992 m_stgLVariables[var][stgId] = tempStgGVars[noVars * stgIdRestart + var];
1995 const MInt globalId = m_solver->c_globalId(cellId);
1996 auto it_ = globalIdStgIdRestartMap.find(globalId);
1997 if(it_ == globalIdStgIdRestartMap.end()) TERMM(-1,
"");
1998 const MInt stgIdRestart = it_->second;
1999 for(
MInt var = 0; var < noVars; ++var) {
2000 m_stgLVariables[var][stgId] = tempStgVars[noVars * stgIdRestart + var];
2004 if(globalIdStgIdRestartMap.size() > 0) TERMM(-1,
"");
2005 if(map2.size() > 0) TERMM(-1,
"");
2011 if(stgIOCoordinates == 1) {
2012 if(!parallelIo.hasDataset((stgPrefix +
"x" + std::to_string(0)).c_str()))
2013 TERMM(-1,
"Coordinates check activated, but dataset does not contain coordinates!");
2020 parallelIo.setOffset(noStgInternalCellsGlobal, 0);
2021 for(
MInt d = 0; d < nDim; ++d) {
2022 std::stringstream varName;
2023 varName << stgPrefix +
"x" + std::to_string(d);
2024 parallelIo.readArray(&tempStgCoord[noStgInternalCellsGlobal * d], (varName.str()).c_str());
2026 parallelIo.setOffset(noStgGhostCellsGlobal, 0);
2027 for(
MInt d = 0; d < nDim; ++d) {
2028 std::stringstream varName;
2029 varName << stgPrefix +
"x" + std::to_string(d);
2030 parallelIo.readArray(&tempStgGCoord[noStgGhostCellsGlobal * d], (varName.str()).c_str());
2033 m_log <<
"Building up kd-tree..." << std::endl;
2036 std::vector<Point<3>> donorPoints;
2037 for(
MInt stgRestartId = 0; stgRestartId < noStgInternalCellsGlobal; stgRestartId++) {
2038 Point<3> pt(tempStgCoord[noStgInternalCellsGlobal * 0 + stgRestartId],
2039 tempStgCoord[noStgInternalCellsGlobal * 1 + stgRestartId],
2040 tempStgCoord[noStgInternalCellsGlobal * 2 + stgRestartId], globalIdsInternalGlobal[stgRestartId]);
2041 donorPoints.push_back(pt);
2048 donorPoints.clear();
2049 for(
MInt stgRestartId = 0; stgRestartId < noStgGhostCellsGlobal; stgRestartId++) {
2050 Point<3> pt(tempStgGCoord[noStgGhostCellsGlobal * 0 + stgRestartId],
2051 tempStgGCoord[noStgGhostCellsGlobal * 1 + stgRestartId],
2052 tempStgGCoord[noStgGhostCellsGlobal * 2 + stgRestartId], globalIdsGhostGlobal[stgRestartId]);
2053 donorPoints.push_back(pt);
2059 m_log <<
"Building up kd-tree... FINISHED!" << std::endl;
2061 constexpr MFloat epsDistance = 1e-4;
2063 const MInt stgId =
a->getStgId(it);
2066 MInt globalIdFromRestart = -1;
2068 Point<3> pt(
a->a_coordinate(cellId, 0),
a->a_coordinate(cellId, 1),
a->a_coordinate(cellId, 2));
2070 if(m_solver->a_isBndryGhostCell(cellId)) {
2071 const MInt stgBndry =
a->m_stgGhost2stgBndry[stgId];
2072 globalId = m_solver->c_globalId(
a->m_stgToCellId[stgBndry]);
2073 globalIdFromRestart = donorTreeGhost->
nearest(pt, distance);
2075 globalId = m_solver->c_globalId(cellId);
2076 globalIdFromRestart = donorTreeInternal->
nearest(pt, distance);
2078 if(globalIdFromRestart != globalId) TERMM(-1,
"");
2079 if(distance > epsDistance) TERMM(-1,
"");
2081 m_log <<
"Coordinates check consistent!" << std::endl;
2090 ParallelIo parallelIo(filename, PIO_READ, m_commStg);
2093 ParallelIo::size_type noStgInternalCellsGlobal =
2094 parallelIo.getArraySize((stgPrefix +
"globalIdsInternal").c_str());
2095 ParallelIo::size_type noStgGhostCellsGlobal = parallelIo.getArraySize((stgPrefix +
"globalIdsGhost").c_str());
2096 std::vector<MInt> globalIdsInternalGlobal(noStgInternalCellsGlobal);
2097 std::vector<MInt> globalIdsGhostGlobal(noStgGhostCellsGlobal);
2098 parallelIo.setOffset(noStgInternalCellsGlobal, 0);
2099 parallelIo.readArray(globalIdsInternalGlobal.data(), (stgPrefix +
"globalIdsInternal").c_str());
2100 parallelIo.setOffset(noStgGhostCellsGlobal, 0);
2101 parallelIo.readArray(globalIdsGhostGlobal.data(), (stgPrefix +
"globalIdsGhost").c_str());
2103 if(!std::is_sorted(globalIdsInternalGlobal.begin(), globalIdsInternalGlobal.end()))
2104 TERMM(-1,
"globalIdsInternal is not sorted in stgRestart file");
2105 if(!std::is_sorted(globalIdsGhostGlobal.begin(), globalIdsGhostGlobal.end()))
2106 TERMM(-1,
"globalIdsGhost is not sorted in stgRestart file");
2108 std::map<
MInt ,
MInt > globalId2stgRestartId;
2109 std::map<
MInt ,
MInt > globalId2stgRestartIdG;
2110 for(
MInt i = 0; i < noStgInternalCellsGlobal; ++i) {
2111 globalId2stgRestartId.insert(std::make_pair(globalIdsInternalGlobal[i], i));
2113 for(
MInt i = 0; i < noStgGhostCellsGlobal; ++i) {
2114 globalId2stgRestartIdG.insert(std::make_pair(globalIdsGhostGlobal[i], i));
2119 std::vector<MInt> stgId2stgRestartId.reserve(
a->sizeStg());
2120 std::vector<MInt> stgId2stgRestartIdG;
2121 MInt cnt = 0, cntG = 0;
2123 const MInt stgId =
a->getStgId(it);
2126 if(m_solver->a_isBndryGhostCell(cellId)) {
2127 const MInt stgBndry =
a->m_stgGhost2stgBndry[stgId];
2128 const MInt globalId = m_solver->c_globalId(
a->m_stgToCellId[stgBndry]);
2129 auto it = globalId2stgRestartIdG.find(globalId);
2130 if(it == globalId2stgRestartIdG.end()) TERMM(-1,
"");
2131 stgId2stgRestartIdG[cntG++] = it->second;
2132 globalId2stgRestartIdG.erase(it);
2134 const MInt globalId = m_solver->c_globalId(cellId);
2135 auto it = globalId2stgRestartId.find(globalId);
2136 if(it == globalId2stgRestartId.end()) TERMM(-1,
"");
2137 stgId2stgRestartId[cnt++] = it->second;
2138 globalId2stgRestartId.erase(it);
2145 if(stgIOCoordinates == 1) {
2146 if(!parallelIo.hasDataset((stgPrefix +
"x" + io_string(0)).c_str()))
2147 TERMM(-1,
"Coordinates check activated, but dataset does not contain coordinates!");
2152 parallelIo.setOffset(noStgInternalCellsGlobal, 0);
2153 for(
MInt d = 0; d < nDim; ++d) {
2154 std::stringstream varName;
2155 varName << stgPrefix +
"x" + std::to_string(d);
2156 parallelIo.readArray(&tempStgCoord[noStgInternalCellsGlobal * d], (varName.str()).c_str());
2158 parallelIo.setOffset(noStgGhostCellsGlobal, 0);
2159 for(
MInt d = 0; d < nDim; ++d) {
2160 std::stringstream varName;
2161 varName << stgPrefix +
"x" + std::to_string(d);
2162 parallelIo.readArray(&tempStgGCoord[noStgGhostCellsGlobal * d], (varName.str()).c_str());
2165 m_log <<
"Building up kd-tree..." << std::endl;
2168 std::vector<Point<3>> donorPoints;
2169 for(
MInt stgRestartId = 0; stgRestartId < noStgInternalCellsGlobal; stgRestartId++) {
2170 Point<3> a(tempStgCoord[noStgInternalCellsGlobal * 0 + stgRestartId],
2171 tempStgCoord[noStgInternalCellsGlobal * 1 + stgRestartId],
2172 tempStgCoord[noStgInternalCellsGlobal * 2 + stgRestartId], globalIdsInternalGlobal[stgRestartId]);
2173 donorPoints.push_back(
a);
2177 donorTreeInternal =
new KDtree<3>(donorPoints);
2180 donorPoints.clear();
2181 for(
MInt stgRestartId = 0; stgRestartId < noStgGhostCellsGlobal; stgRestartId++) {
2182 Point<3> a(tempStgGCoord[noStgGhostCellsGlobal * 0 + stgRestartId],
2183 tempStgGCoord[noStgGhostCellsGlobal * 1 + stgRestartId],
2184 tempStgGCoord[noStgGhostCellsGlobal * 2 + stgRestartId], globalIdsGhostGlobal[stgRestartId]);
2185 donorPoints.push_back(
a);
2189 donorTreeGhost =
new KDtree<3>(donorPoints);
2191 m_log <<
"Building up kd-tree... FINISHED!" << std::endl;
2193 constexpr MFloat epsDistance = 1e-4;
2196 const MInt stgId =
a->getStgId(it);
2199 if(m_solver->a_isBndryGhostCell(cellId)) {
2200 const MInt stgRestartId = stgId2stgRestartIdG[cntG++];
2202 for(
MInt d = 0; d < nDim; ++d) {
2203 distance +=
POW2(
a->a_coordinate(cellId, d) - tempStgGCoord[noStgGhostCellsGlobal * d + stgRestartId]);
2205 if(distance > epsDistance) TERMM(-1,
"");
2207 const MInt stgRestartId = stgId2stgRestartIdG[cntG++];
2209 for(
MInt d = 0; d < nDim; ++d) {
2210 distance +=
POW2(
a->a_coordinate(cellId, d) - tempStgGCoord[noStgGhostCellsGlobal * d + stgRestartId]);
2212 if(distance > epsDistance) TERMM(-1,
"");
2221 for(
MInt var = 0; var < STG::noStgVars; ++var) {
2222 parallelIo.setOffset(noStgInternalCellsGlobal, 0);
2223 parallelIo.readArray(tempStgVars.getPointer(), (stgPrefix + std::to_string(var)).c_str());
2224 parallelIo.setOffset(noStgGhostCellsGlobal, 0);
2225 parallelIo.readArray(tempStgGVars.getPointer(), (stgPrefix + std::to_string(var)).c_str());
2228 const MInt stgId =
a->getStgId(it);
2231 if(m_solver->a_isBndryGhostCell(cellId)) {
2232 m_stgLVariables[var][stgId] = tempStgGVars[stgId2stgRestartIdG[stgId]];
2234 m_stgLVariables[var][stgId] = tempStgVars[stgId2stgRestartId[stgId]];
2242 }
else if(stgIOCoordinates == 2) {
2248 ParallelIo parallelIo((filename.str()).c_str(), PIO_READ, m_commStg);
2250 ParallelIo::size_type noStgInternalCellsGlobal =
2251 parallelIo.getArraySize((stgPrefix +
"globalIdsInternal").c_str());
2252 std::vector<MInt> globalIdsInternalGlobal(noStgInternalCellsGlobal);
2253 std::vector<MInt> isGhostGlobal(noStgInternalCellsGlobal);
2254 parallelIo.setOffset(noStgInternalCellsGlobal, 0);
2255 parallelIo.readArray(globalIdsInternalGlobal.data(), (stgPrefix +
"globalIdsInternal").c_str());
2256 parallelIo.readArray(isGhostGlobal.data(), (stgPrefix +
"isGhost").c_str());
2259 for(
MInt d = 0; d < nDim; ++d) {
2260 std::stringstream varName;
2261 varName << stgPrefix +
"x" + std::to_string(d);
2262 parallelIo.readArray(&tempStgCoord[noStgInternalCellsGlobal * d], (varName.str()).c_str());
2266 MPI_Comm_rank(m_commStg, &myrank);
2268 for(
MInt i = 0; i < noStgInternalCellsGlobal; ++i) {
2269 std::cout <<
"Start loadStg:myrank=" << myrank <<
": (" << globalIdsInternalGlobal[i] <<
"/" << isGhostGlobal[i]
2270 <<
") : " << tempStgCoord[noStgInternalCellsGlobal * 0 + i] <<
"|"
2271 << tempStgCoord[noStgInternalCellsGlobal * 1 + i] <<
"|"
2272 << tempStgCoord[noStgInternalCellsGlobal * 2 + i] << std::endl;
2276 m_log <<
"Building up kd-tree..." << std::endl;
2279 std::vector<Point<3>> donorPoints;
2280 for(
MInt stgRestartId = 0; stgRestartId < noStgInternalCellsGlobal; stgRestartId++) {
2281 Point<3> pt(tempStgCoord[noStgInternalCellsGlobal * 0 + stgRestartId],
2282 tempStgCoord[noStgInternalCellsGlobal * 1 + stgRestartId],
2283 tempStgCoord[noStgInternalCellsGlobal * 2 + stgRestartId], stgRestartId);
2284 donorPoints.push_back(pt);
2290 m_log <<
"Building up kd-tree... FINISHED!" << std::endl;
2293 constexpr MFloat epsDistance = 1e-5;
2294 std::vector<MInt> stgId2stgRestartId(
a->sizeStg());
2296 const MInt stgId =
a->getStgId(it);
2301 if(m_solver->a_isPeriodic(cellId)
2302 || (m_solver->a_isBndryGhostCell(cellId)
2303 && m_solver->a_isPeriodic(
a->m_stgToCellId[
a->m_stgGhost2stgBndry[stgId]]))) {
2304 if(m_solver->grid().periodicCartesianDir(0) > 0 || m_solver->grid().periodicCartesianDir(1) > 0)
2305 TERMM(1,
"Periodicity only allowed in z-direction!");
2307 a->a_coordinate(cellId, 1),
2308 a->a_coordinate(cellId, 2) + m_solver->grid().periodicCartesianLength(2));
2309 stgRestartId = donorTree->nearest(pt, distance);
2310 if(distance > epsDistance) {
2311 Point<3> pt2(
a->a_coordinate(cellId, 0),
2312 a->a_coordinate(cellId, 1),
2313 a->a_coordinate(cellId, 2) - m_solver->grid().periodicCartesianLength(2));
2314 stgRestartId = donorTree->nearest(pt2, distance);
2315 if(distance > epsDistance) TERMM(1,
"");
2318 Point<3> pt(
a->a_coordinate(cellId, 0),
a->a_coordinate(cellId, 1),
a->a_coordinate(cellId, 2));
2320 stgRestartId = donorTree->nearest(pt, distance);
2323 if(m_solver->a_isBndryGhostCell(cellId)) {
2324 if(!isGhostGlobal[stgRestartId]) {
2325 TERMM(-1,
"In current computation this cell is a ghost cell, but in restart file it is not!");
2327 const MInt stgBndry =
a->m_stgGhost2stgBndry[stgId];
2328 globalId = m_solver->c_globalId(
a->m_stgToCellId[stgBndry]);
2330 globalId = m_solver->c_globalId(cellId);
2332 if(globalIdsInternalGlobal[stgRestartId] != globalId) {
2333 std::cout <<
"FAILED (" << globalId <<
"/" << m_solver->a_isBndryGhostCell(cellId) <<
"); "
2334 << globalIdsInternalGlobal[stgRestartId] <<
"; " << m_solver->a_isBndryGhostCell(cellId) <<
"; "
2335 << m_solver->a_isPeriodic(cellId) <<
"; " <<
a->a_coordinate(cellId, 0) <<
"|"
2336 <<
a->a_coordinate(cellId, 1) <<
"|" <<
a->a_coordinate(cellId, 2) <<
" || "
2337 << tempStgCoord[noStgInternalCellsGlobal * 0 + stgRestartId] <<
"|"
2338 << tempStgCoord[noStgInternalCellsGlobal * 1 + stgRestartId] <<
"|"
2339 << tempStgCoord[noStgInternalCellsGlobal * 2 + stgRestartId] << std::endl;
2342 if(distance > epsDistance) {
2343 std::cout << myrank <<
":FAILED2 (" << globalId <<
"/" << m_solver->a_isBndryGhostCell(cellId) <<
"); "
2344 <<
distance <<
"; " <<
a->a_coordinate(cellId, 0) <<
"|" <<
a->a_coordinate(cellId, 1) <<
"|"
2345 <<
a->a_coordinate(cellId, 2) <<
" || " << tempStgCoord[noStgInternalCellsGlobal * 0 + stgRestartId]
2346 <<
"|" << tempStgCoord[noStgInternalCellsGlobal * 1 + stgRestartId] <<
"|"
2347 << tempStgCoord[noStgInternalCellsGlobal * 2 + stgRestartId] << std::endl;
2350 stgId2stgRestartId[stgId] = stgRestartId;
2355 for(
MInt var = 0; var < STG::noStgVars; ++var) {
2356 parallelIo.readArray(tempStgVars.getPointer(), (stgPrefix + std::to_string(var)).c_str());
2358 const MInt stgId =
a->getStgId(it);
2359 m_stgLVariables[var][stgId] = tempStgVars[stgId2stgRestartId[stgId]];
void mAlloc(T *&a, const MLong N, const MString &objectName, MString function)
allocates memory for one-dimensional array 'a' of size N
SolverType *const m_solver
MInt getNghbr(const nDim_citerator &it_, MInt dir) const
nDim_iterator_t< std::vector< MInt >::const_iterator, SolverType > nDim_citerator
virtual MInt domainId(MInt, MInt) const =0
virtual MFloat a_coordinate(MInt, MInt) const =0
MInt getStgId(const nDim_citerator &it_) const
nDim_citerator iterateB1_nDim_citerator_end()
std::vector< MInt >::iterator iterator
std::vector< MInt >::const_iterator const_iterator
virtual MFloat & PInfinity() const =0
nDim_citerator iterateB1()
MInt getNghbrStg(const nDim_citerator &it_, MInt dir) const
virtual MFloat & UInfinity() const =0
nDim_citerator iterateSlopes_nDim_citerator_end()
virtual MFloat & a_pvariable(MInt, MInt)=0
nDim_citerator iterateAll_nDim_citerator_end()
std::vector< MInt > Storage
MInt getCellId(const nDim_citerator &it_) const
Accessor(SolverType_ *solver, const MPI_Comm &commStg)
static constexpr const MInt m_nDim
virtual MFloat & rhoInfinity() const =0
nDim_citerator iterateAll()
nDim_citerator iterateSlopes()
nDim_citerator(const AccessorStructured *parent, const MInt *start, const MInt *end)
MBool operator==(const self_type &rhs) const
value_type getCellId() const
const self_type * operator->()
value_type getNghbr(MInt dir) const
self_type operator++(MInt)
std::random_access_iterator_tag iterator_category
value_type getNghbrStg(MInt dir) const
MBool operator!=(const self_type &rhs) const
const MInt *const ijk_end
value_type getijk(MInt dim) const
value_type getStgId() const
const MInt *const ijk_start
const MInt & operator*() const
const AccessorStructured * p
nDim_citerator nDim_citerator_invalid
MFloat a_coordinate(MInt cellId, MInt dim) const override
const MInt m_noGhostLayers
MInt getNghbrStg(const nDim_citerator &it_, MInt dir) const
nDim_citerator iterateSlopes()
Solver specific implementations of the interface defined in base class.
MInt cellIndex(const MInt *const ijk_) const
const MInt *const m_stgBoxSize
MFloat & rhoInfinity() const override
const MInt *const m_nCells
MFloat & a_pvariable(MInt cellId, MInt varId) override
nDim_citerator nDim_citerator_begin() const
MFloat & UInfinity() const override
nDim_citerator iterateB1_nDim_citerator_end()
AccessorStructured(const MInt *const start, const MInt *const end, const MInt *const nCells, const MInt *const stgBoxSize, MInt noGhostLayers, FvStructuredSolver< 3 > *solver, const MPI_Comm commStg)
nDim_citerator iterateAll()
nDim_citerator iterateB1()
MFloat & PInfinity() const override
MInt getStgId(const nDim_citerator &it_) const
MInt getCellId(const nDim_citerator &it_) const
Helper functions for nDim_citerator as declared in base class.
MInt cellIndexBC(const MInt *const ijk_) const
MInt cellIndexBC(const MInt i, const MInt j, const MInt k) const
nDim_citerator nDim_citerator_end() const
const MInt *const m_start
static constexpr const MInt map_[6][3]
MInt domainId(MInt, MInt) const override
MInt getNghbr(const nDim_citerator &it_, MInt dir) const
nDim_citerator nDim_citerator_begin(const MInt *start, const MInt *end) const
nDim_citerator iterateAll_nDim_citerator_end()
nDim_citerator iterateSlopes_nDim_citerator_end()
MInt cellIndex(const MInt i, const MInt j, const MInt k) const
MInt start(MInt dim) const
MInt domainId(MInt, MInt) const override
MInt getCellId(const nDim_citerator &it_) const
Helper functions for the nDim_citerator as declared in base class.
MInt getGhostIdFromStgId(MInt stgId) const
nDim_citerator iterateSlopes()
Solver specific implementation of the interface defined in base class.
nDim_citerator iterateAll_nDim_citerator_end()
MInt getStgId(const nDim_citerator &it_) const
MInt getNghbr(const nDim_citerator &it_, MInt dir) const
AccessorUnstructured(MInt *sortedBndryCellIds, MInt size, SolverType *solver, const MPI_Comm &commStg, MBool cutOff)
nDim_citerator iterateB1()
nDim_citerator iterateAll()
nDim_citerator iterateB1_nDim_citerator_end()
MFloat & UInfinity() const override
std::vector< MInt > m_stgBndry2stgGhost
MFloat a_coordinate(MInt cellId, MInt dim) const override
MFloat & rhoInfinity() const override
nDim_citerator iterateSlopes_nDim_citerator_end()
MFloat & PInfinity() const override
MInt getNghbrMapping(MInt stgId, MInt nghbr) const
MFloat & a_pvariable(MInt cellId, MInt varId) override
std::vector< MInt > m_stgGhost2stgBndry
SysEqn::PrimitiveVariables * PV
MInt a_noCells() const
Returns the number of cells.
MFloat & a_coordinate(const MInt cellId, const MInt dir)
Returns the coordinate of the cell from the fvcellcollector cellId for dimension dir.
MFloat & a_pvariable(const MInt cellId, const MInt varId)
Returns primitive variable v of the cell cellId for variables varId.
Base class of the structured solver.
MFloat m_sutherlandPlusOne
MBool m_stgInitialStartup
MFloat m_stgDelta99Inflow
void getInflowStartEnd(MFloat *, MFloat *)
MFloat ** m_stgEddieCoverage
typename SolverTraits< nDim, SolverTypeL >::SolverType SolverTypeL_
MFloat getCellSize(typename Accessor::nDim_citerator it)
MBool m_preliminaryRans2D
MBool m_cylinderTransformation
void setVb(MFloat *, MFloat *)
void extrapolateToGX(typename Accessor::nDim_citerator)
MInt * m_stgGlobalNoPeriodicLocations
void calcTotalFluctuationCholesky()
std::mt19937_64 & randomEddyPosGenerator()
std::vector< MInt > * m_stgPeriodicCellId
void bc7909()
Reformulated Synthetic Turbulence Generation Synthetic Turbulence Generation Method Computes fluctuat...
MFloat ** m_stgLVariables
void calcReynoldsStressConvVelLengthScale()
MFloat generate_rand_normalDist()
MBool m_freeStreamTurbulence
MFloat m_sutherlandConstant
MFloat * m_stgLengthFactors
MFloat get_angle(MFloat y, MFloat z)
MFloat generate_rand_weighted()
void getBoundaryLayerThickness()
MFloat m_stgEddieDistribution
MInt m_stgNoEddieProperties
void determinePeriodicCells()
void loadStg(SolverTraits< nDim, MAIA_FINITE_VOLUME > *)
std::vector< MFloat > m_stgWallNormalLocations
friend void saveStg(std::map< MInt, self * >, SolverTypeL_ *)
std::vector< MFloat > m_stgGlobalWallNormalLocations
static constexpr const MInt m_nDim
MFloat m_maxStreamwiseLengthscale
std::mt19937_64 m_PRNGEddy
void readRANSProfileStg()
write RANSValues from solver to stgLVariables (fully coupled) /author Jannik Borgelt
MInt m_stgGlobalNoWallNormalLocations
FvSysEqnRANS< nDim, RANSModelConstants< RANS_SA_DV > >::PrimitiveVariables * PV
MFloat * m_stgEddyStrength
MBool m_isotropicTurbulence
MBool m_stgCreateNewEddies
MInt * m_stgPeriodicIndex
MBool m_stgEddieLengthScales
void generateNewEddies(MFloat *, MFloat *)
void init(MInt commStgRoot)
SolverTypeL_ * solver() const
void extrapolateToBoundary(typename Accessor::nDim_citerator)
This class is a ScratchSpace.
MPI_Comm mpiComm() const
Return the MPI communicator used by this solver.
MInt solverId() const
Return the solverId.
value_type getStgId() const
nDim_iterator_t(base_iterator it, const AccessorUnstructured< SolverType > *parent)
nDim_iterator_t()=default
typename base_iterator::value_type value_type
value_type getCellId() const
const AccessorUnstructured< SolverType > * p
value_type getNghbr(MInt dir) const
constexpr Real POW2(const Real x)
void saveStg(std::map< MInt, MSTG< nDim, SolverTypeR, SolverTypeL > * > stgBC, typename SolverTraits< nDim, SolverTypeL >::SolverType *solver)
std::basic_string< char > MString
int MPI_Barrier(MPI_Comm comm, const MString &name)
same as MPI_Barrier
int MPI_Allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int displs[], MPI_Datatype recvtype, MPI_Comm comm, const MString &name, const MString &sndvarname, const MString &rcvvarname)
same as MPI_Allgatherv
int MPI_Gatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int displs[], MPI_Datatype recvtype, int root, MPI_Comm comm, const MString &name, const MString &sndvarname, const MString &rcvvarname)
same as MPI_Gatherv
int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm, const MString &name, const MString &sndvarname, const MString &rcvvarname)
same as MPI_Allreduce
int MPI_Gather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm, const MString &name, const MString &sndvarname, const MString &rcvvarname)
same as MPI_Gather
int MPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm, const MString &name, const MString &sndvarname, const MString &rcvvarname)
same as MPI_Allgather
MFloat distance(const MFloat *a, const MFloat *b)
std::vector< T > mpiExchangePointToPoint(const T *const sendBuffer, const MInt *const snghbrs, const MInt nosnghbrs, const MInt *const sendcounts, const MInt *const rnghbrs, const MInt nornghbrs, const MPI_Comm &mpi_comm, const MInt domainId, const MInt dataBlockSize, MInt *const recvcounts_=nullptr, MInt *const rdispls_=nullptr)
PARALLELIO_DEFAULT_BACKEND ParallelIo
MInt nearest(Point< DIM > pt, MFloat &dist)