Skip to content

Reply To: Modifying field values for neighboring cells inside a postprocessor

OpenLB – Open Source Lattice Boltzmann Code Forums on OpenLB General Topics Modifying field values for neighboring cells inside a postprocessor Reply To: Modifying field values for neighboring cells inside a postprocessor

#9620
Danial.Khazaeipoul
Participant

Yes, exactly (this is of course quite ugly but it will work).

FYI, I implemented a cleaner method to replace this and now one can check whether a cell is a padding or not directly from the Cell interface. However, this required me to modify the src/core files to introduce a new function inside the BlockStructureD class that retrieves a local LatticR<D> from a linearized CellID.

FYI, I implemented a more streamlined method to replace this, allowing direct checks on whether a cell is padding via the Cell interface. To achieve this, I updated the src/core files to include a new function in the BlockStructureD class, which retrieves a local LatticeR<D> from a linearized CellID.

  /// Get D-dimensional LatticeR from 1D cell ID
  LatticeR<D> getLatticeR(CellID iCell) const
  {
    if constexpr (D == 3) {
      std::int32_t iX = iCell / _projection[0];
      std::int32_t remainder = iCell % _projection[0];
      std::int32_t iY = remainder / _projection[1];
      std::int32_t iZ = remainder % _projection[1];
      return LatticeR<D>(iX - _padding, iY - _padding, iZ - _padding);
    }
    else {
      std::int32_t iX = iCell / _projection[0];
      std::int32_t iY = iCell % _projection[0];
      return LatticeR<D>(iX - _padding, iY - _padding);
    }
  };
  /// Return whether iCell is valid
  bool isPadding(CellID iCell) const
  {
    return isPadding(getLatticeR(iCell));
  };

For more details, please refer to the “feature-CCL” branch in my repository, specifically commits 2ce2d4fc and b28e5305.