Skip to content

Index Cheatsheet

Amartya Das Sharma edited this page Feb 23, 2024 · 10 revisions

For the following (default / template configuration):

  • an MD30 domain
  • cell size 2.5 (i.e. linked cell size and macroscopic cell size)
  • outermost-overlap-layer="2"
  • innermost-overlap-layer="3"

you will yield this structure:

0 1 2 3 4 5 6 7 8 9 10 11 12 13
GL M VEL VEL MD2M MD2M MD2M MD2M MD2M MD2M VEL VEL M GL

where the upper row contains the global index of the macroscopic cell (in one of the spatial dimensions, i.e. one of the components of a vector index), and the lower row contains the type of the cell:

  • GL = ghost layer, i.e. macroscopic cell outside the MD domain
  • M = mass transfer, cell where USHER is active, if enabled
  • VEL = velocity transfer cell, macro -> MD
  • MD2M = 'MD -> Macro' domain = i.e. filtering domain = 'inner' MD domain

Lookup for shorthands/types

Alias Idx_T_ID IndexTrait::vector IndexTrait::local IndexTrait::md2macro IndexTrait::noGhost Used in
IdxSGAH I00
IdxVGAH, BaseIndex I01 X
IdxSLAH I02 X MamicoLammpsMDSolverInterface
IdxVLAH I03 X X
IdxSGIH I04 X
IdxVGIH I05 X X
IdxSLIH I06 X X
IdxVLIH I07 X X X
IdxSGAO I08 X
IdxVGAO I09 X X
IdxSLAO I10 X X CouplingCellService
IdxVLAO I11 X X X MDSolverInterface
IdxSGIO I12 X X
IdxVGIO I13 X X X NLM
IdxSLIO I14 X X X FilterInterface
IdxVLIO I15 X X X X NLM

Indexing refactoring cheatsheet

Legacy New System
indexConversion.getThisRank() = > IDXS.getRank()
indexConversion.getLocalNumberCouplingCells() = > I11::numberCellsInDomain
indexConversion.getGlobalNumberCouplingCells() = > I09::numberCellsInDomain
TransferStrategy::getLocalNumberCouplingCells() = > I02::linearNumberCellsInDomain
indexConversion.getCouplingCellSize() = > IDXS.getCouplingCellSize()
_indexConversion->getRanksForCouplingCell() = > IDXS.getRanksForGlobalIndex(idx)
_indexConversion->getUniqueRankForCouplingCell(idx) = > IDXS.getUniqueRankForCouplingCell(idx)
_indexConversion->getGlobalMDDomainOffset() = > IDXS.getGlobalMDDomainOffset()
_indexConversion->getGlobalMDDomainSize() = > IDXS.getGlobalMDDomainSize()

Legacy

const tarch::la::Vector<3, unsigned int> globalIndex(indexConversion.getGlobalVectorCellIndex(_buf.globalCellIndices4RecvBuffer[i]));
tarch::la::Vector<3, double> cellMidPoint(domainOffset - 0.5 * macroscopicCellSize);
for (unsigned int d = 0; d < 3; d++) {
   cellMidPoint[d] = cellMidPoint[d] + ((double)globalIndex[d]) * macroscopicCellSize[d];
}

New System

auto midPoint = _buf.globalCellIndices4RecvBuffer[i].getCellMidPoint();

Legacy

const tarch::la::Vector<3, unsigned int> cells(indexConversion.getGlobalNumberMacroscopicCells() + tarch::la::Vector<3, unsigned int>(2));
const unsigned int num = cells[0] * cells[1] * cells[2];
unsigned int numCellsSent = 0;
for (unsigned int i = 0; i < num; i++) {
  if (couetteSolverInterface.sendMacroscopicQuantityToMDSolver(indexConversion.getGlobalVectorCellIndex(i))) {
    std::vector<unsigned int> ranks = couetteSolverInterface.getSourceRanks(indexConversion.getGlobalVectorCellIndex(i));
    bool containsThisRank = false;
    for (unsigned int k = 0; k < ranks.size(); k++) {
      containsThisRank = containsThisRank || (ranks[k] == (unsigned int)_rank);
    }
    if (containsThisRank) {
      numCellsSent++;
    }
  }
}

New System

for (auto idx : I00())
  if (!I12::contains(idx))
    if (tarch::utils::contains(msi.getSourceRanks(idx), (unsigned int)_rank))
      numCellsSent++;

Legacy

some_function(const unsigned int index) {
  const tarch::la::Vector<dim, unsigned int> globalIndex(
    coupling::transferstrategies::TransferStrategy<LinkedCell, dim>::_indexConversion.convertLocalToGlobalVectorCellIndex(
      coupling::transferstrategies::TransferStrategy<LinkedCell, dim>::_indexConversion.getLocalVectorCellIndex(index)));
  const tarch::la::Vector<dim, unsigned int> globalNumberCells(
    coupling::transferstrategies::TransferStrategy<LinkedCell, dim>::_indexConversion.getGlobalNumberMacroscopicCells());

  const tarch::la::Vector<dim, double> meshsize(coupling::transferstrategies::TransferStrategy<LinkedCell,dim>
    ::_indexConversion.getMacroscopicCellSize());

  if(globalIndex[0] == globalNumberCells[0]) do_sth();
}

New System

some_function(I01 index) {
  const tarch::la::Vector<dim, double> meshsize(IDXS.getCouplingCellSize());

  if(index.get()[0] == I09::numberCellsInDomain[0]) do_sth();
}

Legacy

const tarch::la::Vector<3, unsigned int> start(0);
const tarch::la::Vector<3, unsigned int> end =
  start + coupling::initRange<dim>(indexConversion.getLocalNumberCouplingCells() + tarch::la::Vector<dim, unsigned int>(2));
tarch::la::Vector<3, unsigned int> loop(0);

for (loop[2] = start[2]; loop[2] < end[2]; loop[2]++) {
  for (loop[1] = start[1]; loop[1] < end[1]; loop[1]++) {
    for (loop[0] = start[0]; loop[0] < end[0]; loop[0]++) {
      // determine global vector cell index of this cell
      tarch::la::Vector<dim, unsigned int> globalVectorIndex = coupling::initDimVector<dim>(loop);
      globalVectorIndex = indexConversion.convertLocalToGlobalVectorCellIndex(globalVectorIndex);

      // call allocateReceiveBuffers for this cell
      coupling::sendrecv::SendReceiveBuffer<CouplingCell, dim>::allocateReceiveBuffers(dataExchange, globalVectorIndex);
    }
  }
}

New System

for (auto idx : I02())
  coupling::sendrecv::SendReceiveBuffer<CouplingCell, dim>::allocateReceiveBuffers(dataExchange, idx);