111 if (subcycles == 0) {
112 cerr <<
"Field solver subcycles cannot be 0." << endl;
116 const auto* localSize = &
fsgrid.getLocalSize()[0];
118 fsgrid.parallel_for([](
int timerId) -> phiprof::Timer {
return phiprof::Timer{timerId}; },
119 phiprof::initializeTimer(
"Initialize technical.maxFsDt"), technical,
120 [=](
const fsgrid::Coordinates &coordinates,
const fsgrid::FsStencil& stencil,
cuint sysBoundaryFlag,
cuint sysBoundaryLayer) {
121 technical[stencil.ooo()].maxFsDt = std::numeric_limits<Real>::max();
124 if (subcycles == 1) {
125#ifdef FS_1ST_ORDER_TIME
262 uint subcycleCount = 0;
263 uint maxSubcycleCount = std::numeric_limits<uint>::max();
266 while (subcycleCount < maxSubcycleCount) {
364 phiprof::Timer subcyclingTimer{
"FS subcycle stuff"};
365 subcycleT += subcycleDt;
368 if (subcycleT >= targetT || subcycleCount >= maxSubcycleCount) {
370 if (subcycleT > targetT) {
372 std::cerr <<
"subcycleT > targetT, should not happen! (values: subcycleT " << subcycleT <<
", subcycleDt " << subcycleDt <<
", targetT " << targetT <<
")" << std::endl;
378 Real dtMaxGlobal = 0.0;
379 Real dtMaxLocal =
fsgrid.parallel_reduction([](
int timerId) -> phiprof::Timer {
return phiprof::Timer{timerId}; },
380 phiprof::initializeTimer(
"compute-subcycle-dt-reduction-loop"), technical,
381 [](
Real a,
Real b) {
return std::min<Real>(a, b); },
382 std::numeric_limits<Real>::max(),
383 [=](
const fsgrid::Coordinates &coordinates,
const fsgrid::FsStencil& stencil,
cuint sysBoundaryFlag,
cuint sysBoundaryLayer,
creal maximum) {
386 return technical[stencil.ooo()].maxFsDt;
392 phiprof::Timer allreduceTimer{
"MPI_Allreduce"};
394 allreduceTimer.stop();
399 subcycleDt = meanFieldsCFL * dtMaxGlobal;
401 logFile <<
"(TIMESTEP) New field solver subcycle dt = " << subcycleDt <<
" computed on step " <<
P::tstep <<
" and substep " << subcycleCount <<
" at " <<
P::t <<
" s" << std::endl;
407 if (subcycleT + 1.5 * subcycleDt > targetT) {
408 subcycleDt = targetT - subcycleT;
409 maxSubcycleCount = subcycleCount + 1;
412 subcycleDt = (targetT - subcycleT) / 2;
413 maxSubcycleCount = subcycleCount + 2;
417 subcyclingTimer.stop();
428 fsgrid.updateGhostCells(vol);
void calculateUpwindedElectricFieldSimple(fsgrids::perbspan perb, fsgrids::perbspan perbdt2, fsgrids::efieldspan e, fsgrids::efieldspan edt2, fsgrids::ehallspan ehall, fsgrids::egradpespan egradpe, fsgrids::egradpespan egradpedt2, fsgrids::momentsspan moments, fsgrids::momentsspan momentsdt2, fsgrids::dperbspan dperb, fsgrids::dmomentsspan dmoments, fsgrids::dmomentsspan dmomentsdt2, fsgrids::bgbspan bgb, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid, SysBoundary &sysBoundaries, int32_t RKCase, const bool communicateEGradPeOrMomentsDerivatives)
High-level electric field computation function.
void calculateHallTermSimple(fsgrids::perbspan perb, fsgrids::perbspan perbdt2, fsgrids::ehallspan ehall, fsgrids::momentsspan moments, fsgrids::momentsspan momentsdt2, fsgrids::dperbspan dperb, fsgrids::dmomentsspan dmoments, fsgrids::dmomentsspan dmomentsdt2, fsgrids::bgbspan bgb, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid, SysBoundary &sysBoundaries, int32_t RKCase, const bool communicateMomentsDerivatives)
High-level function computing the Hall term.
bool propagateFields(fsgrids::perbspan perb, fsgrids::perbspan perbdt2, fsgrids::efieldspan e, fsgrids::efieldspan edt2, fsgrids::ehallspan ehall, fsgrids::egradpespan egradpe, fsgrids::egradpespan egradpedt2, fsgrids::momentsspan moments, fsgrids::momentsspan momentsdt2, fsgrids::dperbspan dperb, fsgrids::dmomentsspan dmoments, fsgrids::dmomentsspan dmomentsdt2, fsgrids::bgbspan bgb, fsgrids::volspan vol, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid, SysBoundary &sysBoundaries, creal &dt, cuint subcycles)
Top-level field propagation function.