MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
CouplerFvMbZonal< nDim, SysEqn > Class Template Referencefinal

#include <fvmbzonal.h>

Inheritance diagram for CouplerFvMbZonal< nDim, SysEqn >:
[legend]
Collaboration diagram for CouplerFvMbZonal< nDim, SysEqn >:
[legend]

Public Types

using FvMbSolver = FvMbCartesianSolverXD< nDim, SysEqn >
 
using FVBndryCnd = FvBndryCndXD< nDim, SysEqn >
 
- Public Types inherited from CouplingFvMb< nDim, SysEqn >
using solverType = FvMbCartesianSolverXD< nDim, SysEqn >
 

Public Member Functions

 CouplerFvMbZonal (const MInt couplingId, FvMbSolver *upStream, FvMbSolver *downStream)
 
 ~CouplerFvMbZonal ()
 
void init () override
 
void finalizeSubCoupleInit (MInt)
 
void postCouple (MInt) override
 unify the time-Step More...
 
void cleanUp ()
 
void checkProperties () override
 
void readProperties () override
 
void finalizeCouplerInit ()
 create first zonal mapping for the zonal exchange More...
 
void finalizeBalance (const MInt) override
 update zonal mapping after balance More...
 
void finalizeAdaptation (const MInt) override
 update zonal mapping after adaptation More...
 
void subCouple (MInt, MInt, std::vector< MBool > &)
 exchange zonal variables each runge-Kutta Step More...
 
void preCouple (MInt) override
 exchange zonal variables before each runge-Kutta Step More...
 
- Public Member Functions inherited from CouplingFvMb< nDim, SysEqn >
 CouplingFvMb (const MInt couplingId, solverType *b)
 
solverTypefvMbSolver () const
 
MInt a_noFvCells () const
 
MInt a_noFvGridCells () const
 
MInt a_noLevelSetsMb () const
 
- Public Member Functions inherited from Coupling
 Coupling (const MInt couplingId)
 
virtual ~Coupling ()=default
 
 Coupling (const Coupling &)=delete
 
Couplingoperator= (const Coupling &)=delete
 
MInt couplerId () const
 
virtual void init ()=0
 
virtual void finalizeSubCoupleInit (MInt solverId)=0
 
virtual void finalizeCouplerInit ()=0
 
virtual void preCouple (MInt recipeStep)=0
 
virtual void subCouple (MInt recipeStep, MInt solverId, std::vector< MBool > &solverCompleted)=0
 
virtual void postCouple (MInt recipeStep)=0
 
virtual void cleanUp ()=0
 
virtual void balancePre ()
 Load balancing. More...
 
virtual void balancePost ()
 
virtual void reinitAfterBalance ()
 
virtual void prepareAdaptation ()
 
virtual void postAdaptation ()
 
virtual void finalizeAdaptation (const MInt)
 
virtual void writeRestartFile (const MInt)
 
virtual MInt noCellDataDlb () const
 Methods to inquire coupler data during balancing. More...
 
virtual MInt cellDataTypeDlb (const MInt NotUsed(dataId)) const
 
virtual MInt cellDataSizeDlb (const MInt NotUsed(dataId), const MInt NotUsed(cellId))
 
virtual void getCellDataDlb (const MInt NotUsed(dataId), const MInt NotUsed(oldNoCells), const MInt *const NotUsed(bufferIdToCellId), MInt *const NotUsed(data))
 
virtual void getCellDataDlb (const MInt NotUsed(dataId), const MInt NotUsed(oldNoCells), const MInt *const NotUsed(bufferIdToCellId), MLong *const NotUsed(data))
 
virtual void getCellDataDlb (const MInt NotUsed(dataId), const MInt NotUsed(oldNoCells), const MInt *const NotUsed(bufferIdToCellId), MFloat *const NotUsed(data))
 
virtual void setCellDataDlb (const MInt NotUsed(dataId), const MInt *const NotUsed(data))
 
virtual void setCellDataDlb (const MInt NotUsed(dataId), const MLong *const NotUsed(data))
 
virtual void setCellDataDlb (const MInt NotUsed(dataId), const MFloat *const NotUsed(data))
 
virtual void finalizeBalance (const MInt)
 
virtual MInt noCouplingTimers (const MBool NotUsed(allTimings)) const
 Number of coupling timers. More...
 
virtual void getCouplingTimings (std::vector< std::pair< MString, MFloat > > &NotUsed(timings), const MBool NotUsed(allTimings))
 Return coupling timings. More...
 
virtual void getDomainDecompositionInformation (std::vector< std::pair< MString, MInt > > &NotUsed(domainInfo))
 Return information on current domain decomposition (e.g. number of coupled cells/elements/...) More...
 
void setDlbTimer (const MInt timerId)
 
void startLoadTimer (const MString &name) const
 Start the load timer of the coupler. More...
 
void stopLoadTimer (const MString &name) const
 Stop the load timer of the coupler. More...
 

Private Member Functions

FvMbSolverupStream () const
 
FvMbSolverdownStream () const
 
MInt couplerId () const
 
void createZonalMapping ()
 create the cell mapping which allows for a faster exchange during each RK-Step. This requires little additional memory. More...
 
void updateZonalMapping ()
 update the zonal mapping before the FVMb-timeStep as the bndryCell order might have changed! NOTE: currently unused, as its not necessary, the bndry-ghostCell values are updated inside the solutionStep. More...
 
void exchangeZonalValues (const MInt)
 exchange zonal variables around the zonal coordinate from upstream to downstream solver and the other way around! More...
 
void unifyTimeStep ()
 set the same timeStep both FvMb-solvers More...
 
MInt up2downId (MInt, const MBool)
 conversion from upStream solverId to the downStream solverId NOTE: also handles bndry-ghost cell conversion! More...
 
MInt down2upId (MInt, const MBool)
 conversion from downStream to upStream cellId NOTE: also handles bndry-ghost cells More...
 

Private Attributes

FvMbSolverm_solverUp
 
FvMbSolverm_solverDown
 
MInt m_upStreamId {}
 
MInt m_downStreamId {}
 
MInt m_couplingId {}
 
MString m_zonalMethod {}
 
MInt m_zonalDir {}
 
MFloat m_zonalCoordinate {}
 
MBool m_zonalDualTimeStepping = false
 
std::vector< std::pair< MInt, MInt > > m_upDown
 
std::vector< std::pair< MInt, MInt > > m_downUp
 
MInt m_upStreamOffset = 0
 
MInt m_downStreamOffset = 0
 
MInt m_RKStep = 0
 
MInt m_noRKSteps = -1
 

Additional Inherited Members

- Protected Member Functions inherited from Coupling
MFloat returnLoadRecord () const
 
MFloat returnIdleRecord () const
 

Detailed Description

template<MInt nDim, class SysEqn>
class CouplerFvMbZonal< nDim, SysEqn >

Definition at line 31 of file fvmbzonal.h.

Member Typedef Documentation

◆ FVBndryCnd

template<MInt nDim, class SysEqn >
using CouplerFvMbZonal< nDim, SysEqn >::FVBndryCnd = FvBndryCndXD<nDim, SysEqn>

Definition at line 34 of file fvmbzonal.h.

◆ FvMbSolver

template<MInt nDim, class SysEqn >
using CouplerFvMbZonal< nDim, SysEqn >::FvMbSolver = FvMbCartesianSolverXD<nDim, SysEqn>

Definition at line 33 of file fvmbzonal.h.

Constructor & Destructor Documentation

◆ CouplerFvMbZonal()

template<MInt nDim, class SysEqn >
CouplerFvMbZonal< nDim, SysEqn >::CouplerFvMbZonal ( const MInt  couplingId,
FvMbSolver upStream,
FvMbSolver downStream 
)

Definition at line 23 of file fvmbzonal.cpp.

24 : Coupling(couplingId), CouplingFvMb<nDim, SysEqn>(couplingId, upStream_) {
25 TRACE();
26
27 // set solver pointer and ids
28 m_solverUp = upStream_;
29 m_solverDown = downStream_;
30 m_couplingId = couplingId;
31
34
36}
MInt m_downStreamId
Definition: fvmbzonal.h:66
void readProperties() override
FvMbSolver & upStream() const
Definition: fvmbzonal.h:58
FvMbSolver * m_solverUp
Definition: fvmbzonal.h:62
FvMbSolver * m_solverDown
Definition: fvmbzonal.h:63
FvMbSolver & downStream() const
Definition: fvmbzonal.h:59
const MInt m_solverId
a unique solver identifier
Definition: solver.h:90

◆ ~CouplerFvMbZonal()

template<MInt nDim, class SysEqn >
CouplerFvMbZonal< nDim, SysEqn >::~CouplerFvMbZonal ( )
inline

Definition at line 38 of file fvmbzonal.h.

38{};

Member Function Documentation

◆ checkProperties()

template<MInt nDim, class SysEqn >
void CouplerFvMbZonal< nDim, SysEqn >::checkProperties ( )
inlineoverridevirtual

Implements Coupling.

Definition at line 45 of file fvmbzonal.h.

45{};

◆ cleanUp()

template<MInt nDim, class SysEqn >
void CouplerFvMbZonal< nDim, SysEqn >::cleanUp ( )
inlinevirtual

Reimplemented from CouplingFvMb< nDim, SysEqn >.

Definition at line 44 of file fvmbzonal.h.

44{};

◆ couplerId()

template<MInt nDim, class SysEqn >
MInt CouplerFvMbZonal< nDim, SysEqn >::couplerId ( ) const
inlineprivate

Definition at line 60 of file fvmbzonal.h.

60{ return m_couplingId; }

◆ createZonalMapping()

template<MInt nDim, class SysEqn >
void CouplerFvMbZonal< nDim, SysEqn >::createZonalMapping
private
Author
Tim Wegmann

Definition at line 201 of file fvmbzonal.cpp.

201 {
202 TRACE();
203
204 m_upDown.clear();
205 m_downUp.clear();
206
209
210 if(upStream().isActive()) {
211 if(m_zonalMethod == "P") {
212 // first create mapping for valid grid cells
213 // this mapping will only change duing adaptation or balance
214 for(MInt upId = 0; upId < upStream().c_noCells(); upId++) {
216 MBool lastLayer = false;
217 if(!upStream().a_hasNeighbor(upId, m_zonalDir * 2 + 1, false) && !upStream().a_isHalo(upId)) {
218 const MInt parentId = upStream().c_parentId(upId);
219 if(parentId > -1 && !upStream().a_hasNeighbor(parentId, m_zonalDir * 2 + 1, false)) {
220 lastLayer = true;
221 }
222 }
223 const MInt downId = up2downId(upId, lastLayer);
224 if(downId > -1) {
225 m_downUp.push_back(make_pair(downId, upId));
226 }
227 }
228 }
229 } else if(m_zonalMethod == "B") {
230 }
232 }
233
234 if(downStream().isActive()) {
235 if(m_zonalMethod == "P") {
236 // first create mapping for valid grid cells
237 // this mapping will only change duing adaptation or balance
238 for(MInt downId = 0; downId < downStream().c_noCells(); downId++) {
240 MBool lastLayer = false;
241 if(!downStream().a_hasNeighbor(downId, m_zonalDir * 2, false) && !downStream().a_isHalo(downId)) {
242 const MInt parentId = downStream().c_parentId(downId);
243 if(parentId > -1 && !downStream().a_hasNeighbor(parentId, m_zonalDir * 2, false)) {
244 lastLayer = true;
245 }
246 }
247 const MInt upId = down2upId(downId, lastLayer);
248 if(upId > -1) {
249 m_upDown.push_back(make_pair(upId, downId));
250 }
251 }
252 }
253 } else if(m_zonalMethod == "B") {
254 }
255 m_upStreamOffset = m_upDown.size();
256 }
257}
MString m_zonalMethod
Definition: fvmbzonal.h:69
MFloat m_zonalCoordinate
Definition: fvmbzonal.h:71
MInt m_downStreamOffset
Definition: fvmbzonal.h:79
MInt m_upStreamOffset
Definition: fvmbzonal.h:78
std::vector< std::pair< MInt, MInt > > m_downUp
Definition: fvmbzonal.h:76
MInt up2downId(MInt, const MBool)
conversion from upStream solverId to the downStream solverId NOTE: also handles bndry-ghost cell conv...
Definition: fvmbzonal.cpp:367
std::vector< std::pair< MInt, MInt > > m_upDown
Definition: fvmbzonal.h:75
MInt down2upId(MInt, const MBool)
conversion from downStream to upStream cellId NOTE: also handles bndry-ghost cells
Definition: fvmbzonal.cpp:438
MBool a_isHalo(const MInt cellId) const
Returns IsHalo of the cell cellId.
MLong c_parentId(const MInt cellId) const
Returns the grid parent id 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.
MInt a_hasNeighbor(const MInt cellId, const MInt dir, const MBool assertNeighborState=true) const
Returns noNeighborIds of the cell CellId for direction dir.
int32_t MInt
Definition: maiatypes.h:62
bool MBool
Definition: maiatypes.h:58

◆ down2upId()

template<MInt nDim, class SysEqn >
MInt CouplerFvMbZonal< nDim, SysEqn >::down2upId ( MInt  downCell,
const  MBool 
)
private
Author
Tim Wegmann

Definition at line 438 of file fvmbzonal.cpp.

438 {
439 TRACE();
440
441 if(!upStream().isActive()) return -1;
442
443 // to hanlde bndry ghostCells and others as well
444 // 1: regular grid cell
445 // < 1: bndry-ghost cell (index represents matching surface)
446 MInt cellType = 1;
447 if(downCell >= downStream().c_noCells()) {
448 const MInt gridCell = downStream().getAssociatedInternalCell(downCell);
449 if(downStream().a_isBndryGhostCell(downCell)) {
450 // find the matching surface of the grid cell to which the upCell is the bndry-ghostcell
451 const MInt bndryId = downStream().a_bndryId(gridCell);
452 MInt srfc = -1;
453 for(MInt surf = 0; surf < downStream().m_bndryCells->a[bndryId].m_noSrfcs; surf++) {
454 if(downStream().m_bndryCells->a[bndryId].m_srfcVariables[surf]->m_ghostCellId == downCell) {
455 srfc = surf;
456 break;
457 }
458 }
459 ASSERT(srfc >= 0, "");
460 cellType = -srfc;
461 } else if(downStream().a_hasProperty(downCell, FvCell::IsSplitChild)
462 || downStream().a_hasProperty(downCell, FvCell::IsSplitClone)) {
463 cellType = 2;
464 }
465 downCell = gridCell;
466 }
467
469
470 const MInt gridId = downStream().grid().tree().solver2grid(downCell);
471 ASSERT(downStream().grid().solverFlag(gridId, m_downStreamId), "");
472
473 if(!upStream().grid().solverFlag(gridId, m_upStreamId)) return -1;
474
475 MInt upCell = upStream().grid().tree().grid2solver(gridId);
476
477 if(upCell > 0) {
478 ASSERT(downStream().a_level(downCell) == upStream().a_level(upCell), "");
479 }
480
481 if(cellType == 1 || upCell < 0) return upCell;
482
483 if(!lastLayer) {
484 ASSERT(upStream().a_isBndryCell(upCell), "");
485 } else {
486 return -1;
487 }
488
489 if(cellType < 1) {
490 // bndry-ghost cell
491 const MInt srfc = -cellType;
492 const MInt bndryId = upStream().a_bndryId(upCell);
493 upCell = upStream().m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
494 return upCell;
495
496 } else {
497 // split child
498 mTerm(1, AT_, "Not yet implemented for splitchilds");
499 }
500
501 return -1;
502}
Collector< FvBndryCell< nDim, SysEqn > > * m_bndryCells
void assertValidGridCellId(const MInt cellId) const
Cecks wether the cell cellId is an actual grid-cell.
MInt & a_bndryId(const MInt cellId)
Returns the bndryId of the cell cellId.
const MInt & getAssociatedInternalCell(const MInt &cellId) const
Returns the Id of the split cell, if cellId is a split child.
constexpr GridProxy & grid() const
void mTerm(const MInt errorCode, const MString &location, const MString &message)
Definition: functions.cpp:29

◆ downStream()

template<MInt nDim, class SysEqn >
FvMbSolver & CouplerFvMbZonal< nDim, SysEqn >::downStream ( ) const
inlineprivate

Definition at line 59 of file fvmbzonal.h.

59{ return *m_solverDown; }

◆ exchangeZonalValues()

template<MInt nDim, class SysEqn >
void CouplerFvMbZonal< nDim, SysEqn >::exchangeZonalValues ( const MInt  solverId)
private
Author
Tim Wegmann

Definition at line 326 of file fvmbzonal.cpp.

326 {
327 TRACE();
328
329 if(m_upDown.empty()) {
330 ASSERT(m_downUp.empty(), "");
331 return;
332 }
333
334 // transfer data from up-stream to down-stream
335 if(solverId == m_upStreamId || solverId == -1) {
336 for(auto it = m_upDown.begin(); it != m_upDown.end(); it++) {
337 const MInt upId = it->first;
338 const MInt downId = it->second;
339
340 for(MInt var = 0; var < upStream().m_sysEqn.CV->noVariables; var++) {
341 downStream().a_variable(downId, var) = upStream().a_variable(upId, var);
342 downStream().a_pvariable(downId, var) = upStream().a_pvariable(upId, var);
343 }
344 }
345 }
346
347 // transfer data from down-stream to up-stream
348 if(solverId == m_downStreamId || solverId == -1) {
349 for(auto it = m_downUp.begin(); it != m_downUp.end(); it++) {
350 const MInt downId = it->first;
351 const MInt upId = it->second;
352
353 for(MInt var = 0; var < downStream().m_sysEqn.CV->noVariables; var++) {
354 upStream().a_variable(upId, var) = downStream().a_variable(downId, var);
355 upStream().a_pvariable(upId, var) = downStream().a_pvariable(downId, var);
356 }
357 }
358 }
359}
MFloat & a_variable(const MInt cellId, const MInt varId)
Returns conservative variable v of the cell cellId for variables varId.
MFloat & a_pvariable(const MInt cellId, const MInt varId)
Returns primitive variable v of the cell cellId for variables varId.

◆ finalizeAdaptation()

template<MInt nDim, class SysEqn >
void CouplerFvMbZonal< nDim, SysEqn >::finalizeAdaptation ( const  MInt)
overridevirtual
Author
Tim Wegmann

Reimplemented from Coupling.

Definition at line 123 of file fvmbzonal.cpp.

123 {
124 if(solverLoopId >= m_upStreamId && solverLoopId >= m_downStreamId) {
127 }
128}
void unifyTimeStep()
set the same timeStep both FvMb-solvers
Definition: fvmbzonal.cpp:509
void createZonalMapping()
create the cell mapping which allows for a faster exchange during each RK-Step. This requires little ...
Definition: fvmbzonal.cpp:201

◆ finalizeBalance()

template<MInt nDim, class SysEqn >
void CouplerFvMbZonal< nDim, SysEqn >::finalizeBalance ( const  MInt)
overridevirtual
Author
Tim Wegmann

Reimplemented from Coupling.

Definition at line 134 of file fvmbzonal.cpp.

134 {
135 if(solverLoopId >= m_upStreamId && solverLoopId >= m_downStreamId) {
137 }
138}

◆ finalizeCouplerInit()

template<MInt nDim, class SysEqn >
void CouplerFvMbZonal< nDim, SysEqn >::finalizeCouplerInit
virtual
Author
Tim Wegmann

Implements Coupling.

Definition at line 113 of file fvmbzonal.cpp.

113 {
115
116 ASSERT(upStream().a_timeStepComputationInterval() == downStream().a_timeStepComputationInterval(), "");
117}

◆ finalizeSubCoupleInit()

template<MInt nDim, class SysEqn >
void CouplerFvMbZonal< nDim, SysEqn >::finalizeSubCoupleInit ( MInt  )
inlinevirtual

Implements Coupling.

Definition at line 42 of file fvmbzonal.h.

42{};

◆ init()

template<MInt nDim, class SysEqn >
void CouplerFvMbZonal< nDim, SysEqn >::init ( )
inlineoverridevirtual

Implements Coupling.

Definition at line 41 of file fvmbzonal.h.

41{};

◆ postCouple()

template<MInt nDim, class SysEqn >
void CouplerFvMbZonal< nDim, SysEqn >::postCouple ( MInt  solverStep)
overridevirtual
Author
Tim Wegmann

Implements Coupling.

Definition at line 185 of file fvmbzonal.cpp.

185 {
186 if(solverStep == 1) {
187 if(upStream().isActive() && downStream().isActive()
188 && fabs(upStream().timeStep() - downStream().timeStep()) > upStream().m_eps) {
189 cerr << setprecision(16) << "UpStream-TimeStep " << upStream().timeStep() << " DownStream-TimeStep "
190 << upStream().timeStep() << endl;
191 mTerm(1, AT_, "Time in Fv-Mb-Solvers differs!.");
192 }
193 }
194}
MFloat timeStep(MBool canSolver=false) noexcept

◆ preCouple()

template<MInt nDim, class SysEqn >
void CouplerFvMbZonal< nDim, SysEqn >::preCouple ( MInt  solverStep)
overridevirtual
Author
Tim Wegmann

Implements Coupling.

Definition at line 171 of file fvmbzonal.cpp.

171 {
172 // past the LS-solver
173 // before the FvMb-solver
174 if(solverStep == 1) {
175 // updateZonalMapping();
177 m_RKStep = 0;
178 }
179}
void exchangeZonalValues(const MInt)
exchange zonal variables around the zonal coordinate from upstream to downstream solver and the other...
Definition: fvmbzonal.cpp:326

◆ readProperties()

template<MInt nDim, class SysEqn >
void CouplerFvMbZonal< nDim, SysEqn >::readProperties ( )
overridevirtual

Implements Coupling.

◆ subCouple()

template<MInt nDim, class SysEqn >
void CouplerFvMbZonal< nDim, SysEqn >::subCouple ( MInt  recipeStep,
MInt  solverId,
std::vector< MBool > &   
)
virtual
Author
Tim Wegmann

Implements Coupling.

Definition at line 144 of file fvmbzonal.cpp.

145 {
146 // only during FVMb computation
147 if(recipeStep == 1 && (solverId == m_upStreamId || solverId == m_downStreamId)) {
148 m_RKStep++;
149
150 if(m_RKStep == 2 * m_noRKSteps) {
151 // complete exchange during the last runge-Kutta Step
153 } else {
154 // only update from the solver who just made its timeStep!
155 exchangeZonalValues(solverId);
156 }
157
158 // check the timeStep contraint at the last-RK-step of both solvers
159 // if the timeStep might have changed!
160 if(m_RKStep == 2 * m_noRKSteps && upStream().a_timeStepComputationInterval() > 0
161 && globalTimeStep % upStream().a_timeStepComputationInterval() == 0) {
163 }
164 }
165}
MInt globalTimeStep

◆ unifyTimeStep()

template<MInt nDim, class SysEqn >
void CouplerFvMbZonal< nDim, SysEqn >::unifyTimeStep
private
Author
Tim Wegmann

Definition at line 509 of file fvmbzonal.cpp.

509 {
510 const MFloat invalidTimeStep = std::numeric_limits<MFloat>::max();
511 MFloat timeUp = invalidTimeStep;
512 MFloat timeDown = invalidTimeStep;
513 MInt maxLevelUp = -1;
514 MInt maxLevelDown = -1;
515 MFloat newTimeUp = invalidTimeStep;
516 MFloat newTimeDown = invalidTimeStep;
517
518 // determine the new timeStep on ranks which have both up-Stream and downStream solvers!
519 if(upStream().isActive() && downStream().isActive()) {
520 timeUp = upStream().timeStep(true);
521 maxLevelUp = upStream().maxLevel();
522 timeDown = downStream().timeStep(true);
523 maxLevelDown = downStream().maxLevel();
524
525 MInt levelDiff = maxLevelDown - maxLevelUp;
526 if(levelDiff == 0) {
527 newTimeUp = mMin(timeUp, timeDown);
528 newTimeDown = newTimeUp;
529 } else {
530 ASSERT(m_zonalDualTimeStepping, "");
531 if(levelDiff == 1) {
532 // downStream has higher level => lower timeStep!
533 newTimeDown = mMin(newTimeDown, newTimeUp / 2.0);
534 newTimeUp = 2.0 * newTimeDown;
535 } else if(levelDiff == -1) {
536 // upStream has the higher level => lower timeStep!
537 newTimeUp = mMin(newTimeUp, newTimeDown / 2.0);
538 newTimeDown = 2.0 * newTimeUp;
539 } else {
540 mTerm(1, AT_, "Zonal dual-timeStepping currently only implemented for 1 level difference!");
541 }
542 }
543 }
544
545 if(downStream().isActive()) {
546 MPI_Allreduce(MPI_IN_PLACE, &newTimeDown, 1, MPI_DOUBLE, MPI_MIN, downStream().mpiComm(), AT_, "MPI_IN_PLACE",
547 "newTimeDown");
548 }
549 if(upStream().isActive()) {
550 MPI_Allreduce(MPI_IN_PLACE, &newTimeUp, 1, MPI_DOUBLE, MPI_MIN, upStream().mpiComm(), AT_, "MPI_IN_PLACE",
551 "newTimeUp");
552 }
553
554 if(upStream().isActive()) {
555 upStream().forceTimeStep(newTimeUp);
556 }
557 if(downStream().isActive()) {
558 downStream().forceTimeStep(newTimeDown);
559 }
560}
MBool m_zonalDualTimeStepping
Definition: fvmbzonal.h:73
void forceTimeStep(const MFloat dt)
Force time step externally.
constexpr T mMin(const T &x, const T &y)
Definition: functions.h:90
double MFloat
Definition: maiatypes.h:52
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

◆ up2downId()

template<MInt nDim, class SysEqn >
MInt CouplerFvMbZonal< nDim, SysEqn >::up2downId ( MInt  upCell,
const  MBool 
)
private
Author
Tim Wegmann

Definition at line 367 of file fvmbzonal.cpp.

367 {
368 TRACE();
369
370 if(!downStream().isActive()) return -1;
371
372 // to hanlde bndry ghostCells and others as well
373 // 1: regular grid cell
374 // < 1: bndry-ghost cell (index represents matching surface)
375 MInt cellType = 1;
376 if(upCell >= upStream().c_noCells()) {
377 const MInt gridCell = upStream().getAssociatedInternalCell(upCell);
378 if(upStream().a_isBndryGhostCell(upCell)) {
379 // find the matching surface of the grid cell to which the upCell is the bndry-ghostcell
380 const MInt bndryId = upStream().a_bndryId(gridCell);
381 MInt srfc = -1;
382 for(MInt surf = 0; surf < upStream().m_bndryCells->a[bndryId].m_noSrfcs; surf++) {
383 if(upStream().m_bndryCells->a[bndryId].m_srfcVariables[surf]->m_ghostCellId == upCell) {
384 srfc = surf;
385 break;
386 }
387 }
388 ASSERT(srfc >= 0, "");
389 cellType = -srfc;
390 } else if(upStream().a_hasProperty(upCell, FvCell::IsSplitChild)
391 || upStream().a_hasProperty(upCell, FvCell::IsSplitClone)) {
392 cellType = 2;
393 }
394 upCell = gridCell;
395 }
396
398
399 const MInt gridId = upStream().grid().tree().solver2grid(upCell);
400 ASSERT(upStream().grid().solverFlag(gridId, m_upStreamId), "");
401
402 if(!downStream().grid().solverFlag(gridId, m_downStreamId)) return -1;
403
404 MInt downId = downStream().grid().tree().grid2solver(gridId);
405
406 if(downId > 0) {
407 ASSERT(downStream().a_level(downId) == upStream().a_level(upCell), "");
408 }
409
410 if(cellType == 1 || downId < 0) return downId;
411
412 if(!lastLayer) {
413 ASSERT(downStream().a_isBndryCell(upCell), "");
414 } else {
415 return -1;
416 }
417
418 if(cellType < 1) {
419 // bndry-ghost cell
420 const MInt srfc = -cellType;
421 const MInt bndryId = downStream().a_bndryId(downId);
422 downId = downStream().m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
423 return downId;
424
425 } else {
426 // split child
427 mTerm(1, AT_, "Not yet implemented for splitchilds");
428 }
429
430 return -1;
431}

◆ updateZonalMapping()

template<MInt nDim, class SysEqn >
void CouplerFvMbZonal< nDim, SysEqn >::updateZonalMapping
private
Author
Tim Wegmann

Definition at line 266 of file fvmbzonal.cpp.

266 {
267 TRACE();
268
269 // resize to grid-cell offset
272
273 // re-build bndryCell mapping
274 if(upStream().isActive()) {
275 if(m_zonalMethod == "P") {
276 for(MInt upId = upStream().c_noCells(); upId < upStream().a_noCells(); upId++) {
278 MBool lastLayer = false;
279 const MInt associatedId = upStream().getAssociatedInternalCell(upId);
280 if(!upStream().a_hasNeighbor(associatedId, m_zonalDir * 2 + 1, false) && !upStream().a_isHalo(associatedId)) {
281 const MInt parentId = upStream().c_parentId(associatedId);
282 if(parentId > -1 && !upStream().a_hasNeighbor(parentId, m_zonalDir * 2 + 1, false)) {
283 lastLayer = true;
284 }
285 }
286 const MInt downId = up2downId(upId, lastLayer);
287 if(downId > -1) {
288 m_upDown.push_back(make_pair(upId, downId));
289 }
290 }
291 }
292 } else if(m_zonalMethod == "B") {
293 }
294 }
295
296
297 if(downStream().isActive()) {
298 if(m_zonalMethod == "P") {
299 for(MInt downId = downStream().c_noCells(); downId < downStream().a_noCells(); downId++) {
301 MBool lastLayer = false;
302 const MInt associatedId = downStream().getAssociatedInternalCell(downId);
303 if(!downStream().a_hasNeighbor(associatedId, m_zonalDir * 2, false) && !downStream().a_isHalo(associatedId)) {
304 const MInt parentId = downStream().c_parentId(associatedId);
305 if(parentId > -1 && !downStream().a_hasNeighbor(parentId, m_zonalDir * 2, false)) {
306 lastLayer = true;
307 }
308 }
309 const MInt upId = down2upId(downId, lastLayer);
310 if(upId > -1) {
311 m_upDown.push_back(make_pair(downId, upId));
312 }
313 }
314 }
315 } else if(m_zonalMethod == "B") {
316 }
317 }
318}
MInt a_noCells() const
Returns the number of cells.

◆ upStream()

template<MInt nDim, class SysEqn >
FvMbSolver & CouplerFvMbZonal< nDim, SysEqn >::upStream ( ) const
inlineprivate

Definition at line 58 of file fvmbzonal.h.

58{ return *m_solverUp; }

Member Data Documentation

◆ m_couplingId

template<MInt nDim, class SysEqn >
MInt CouplerFvMbZonal< nDim, SysEqn >::m_couplingId {}
private

Definition at line 67 of file fvmbzonal.h.

◆ m_downStreamId

template<MInt nDim, class SysEqn >
MInt CouplerFvMbZonal< nDim, SysEqn >::m_downStreamId {}
private

Definition at line 66 of file fvmbzonal.h.

◆ m_downStreamOffset

template<MInt nDim, class SysEqn >
MInt CouplerFvMbZonal< nDim, SysEqn >::m_downStreamOffset = 0
private

Definition at line 79 of file fvmbzonal.h.

◆ m_downUp

template<MInt nDim, class SysEqn >
std::vector<std::pair<MInt, MInt> > CouplerFvMbZonal< nDim, SysEqn >::m_downUp
private

Definition at line 76 of file fvmbzonal.h.

◆ m_noRKSteps

template<MInt nDim, class SysEqn >
MInt CouplerFvMbZonal< nDim, SysEqn >::m_noRKSteps = -1
private

Definition at line 81 of file fvmbzonal.h.

◆ m_RKStep

template<MInt nDim, class SysEqn >
MInt CouplerFvMbZonal< nDim, SysEqn >::m_RKStep = 0
private

Definition at line 80 of file fvmbzonal.h.

◆ m_solverDown

template<MInt nDim, class SysEqn >
FvMbSolver* CouplerFvMbZonal< nDim, SysEqn >::m_solverDown
private

Definition at line 63 of file fvmbzonal.h.

◆ m_solverUp

template<MInt nDim, class SysEqn >
FvMbSolver* CouplerFvMbZonal< nDim, SysEqn >::m_solverUp
private

Definition at line 62 of file fvmbzonal.h.

◆ m_upDown

template<MInt nDim, class SysEqn >
std::vector<std::pair<MInt, MInt> > CouplerFvMbZonal< nDim, SysEqn >::m_upDown
private

Definition at line 75 of file fvmbzonal.h.

◆ m_upStreamId

template<MInt nDim, class SysEqn >
MInt CouplerFvMbZonal< nDim, SysEqn >::m_upStreamId {}
private

Definition at line 65 of file fvmbzonal.h.

◆ m_upStreamOffset

template<MInt nDim, class SysEqn >
MInt CouplerFvMbZonal< nDim, SysEqn >::m_upStreamOffset = 0
private

Definition at line 78 of file fvmbzonal.h.

◆ m_zonalCoordinate

template<MInt nDim, class SysEqn >
MFloat CouplerFvMbZonal< nDim, SysEqn >::m_zonalCoordinate {}
private

Definition at line 71 of file fvmbzonal.h.

◆ m_zonalDir

template<MInt nDim, class SysEqn >
MInt CouplerFvMbZonal< nDim, SysEqn >::m_zonalDir {}
private

Definition at line 70 of file fvmbzonal.h.

◆ m_zonalDualTimeStepping

template<MInt nDim, class SysEqn >
MBool CouplerFvMbZonal< nDim, SysEqn >::m_zonalDualTimeStepping = false
private

Definition at line 73 of file fvmbzonal.h.

◆ m_zonalMethod

template<MInt nDim, class SysEqn >
MString CouplerFvMbZonal< nDim, SysEqn >::m_zonalMethod {}
private

Definition at line 69 of file fvmbzonal.h.


The documentation for this class was generated from the following files: