MultiGridLattice2D won't work on BounceBack BC

For somereathon, MultiGridLattice2D won’t work on some dynamics , such as BounceBack. If we want to refine the grid on the boundaris, some pops of MultiGridLattice will be NAN. Finaly, the field will be wrong. Here are the codes changed by me, and it does work well with the dipole. The changs are located in “multiGrid/gridRefinement.hh”

#line 100
template<typename T, template class Descriptor>
void ConvectiveRescaleEngine<T,Descriptor>::scaleCoarseFine (
Cell<T,Descriptor> const& coarseCell, std::vector& decomposedFineValues ) const
{
coarseCell.getDynamics().decompose(coarseCell, decomposedFineValues, order);
// T tauCoarse = 1./coarseCell.getDynamics().getOmega();
// T tauFine = 2.*tauCoarse - (T)1./(T)2.;
T omegaCoarse=coarseCell.getDynamics().getOmega();

if (order == 0){
    for (plint iFneq=0; iFneq<Descriptor<T>::q; ++iFneq) {

// decomposedFineValues[1+Descriptor::d+iPineq] *= tauFine/tauCoarse;
decomposedFineValues[1+Descriptor::d+iFneq] *= T(2.)-(T)1./(T)2.*omegaCoarse;
}
}
else {
for (plint iPineq=0; iPineq < SymmetricTensor<T,Descriptor>::n; ++iPineq) {
// decomposedFineValues[1+Descriptor::d+iPineq] *= tauFine/tauCoarse;
decomposedFineValues[1+Descriptor::d+iPineq] *= T(2.)-(T)1./(T)2.*omegaCoarse;
}
}

coarseCell.getDynamics().rescale( decomposedFineValues, toFine_xDxInv,
                                  toFine_xDt, order );

}
#line 124
template<typename T, template class Descriptor>
void ConvectiveRescaleEngine<T,Descriptor>::scaleFineCoarse (
Cell<T,Descriptor> const& fineCell, std::vector& decomposedCoarseValues ) const
{
// decompose the fine cell populations
fineCell.getDynamics().decompose(fineCell, decomposedCoarseValues, order);

// computation of the factor associated with both tau

// T tauFine = 1./fineCell.getDynamics().getOmega();
// T tauCoarse = (tauFine+(T)1./(T)2.)/(T)2.;
T omegaFine=fineCell.getDynamics().getOmega();

if (order == 0){
    for (plint iFneq=0; iFneq < Descriptor<T>::q; ++iFneq) {

// decomposedCoarseValues[1+Descriptor::d+iFneq] *= tauCoarse/tauFine;
decomposedCoarseValues[1+Descriptor::d+iFneq] *= (T)1./(T)2. + omegaFine/(T)4.;
}
}
else {
for (plint iPineq=0; iPineq < SymmetricTensor<T,Descriptor>::n; ++iPineq) {
// decomposedCoarseValues[1+Descriptor::d+iPineq] *= tauCoarse/tauFine;
decomposedCoarseValues[1+Descriptor::d+iPineq] *= (T)1./(T)2. + omegaFine/(T)4.;
}
}

// rescale and copy the values inside decomposedCoarseValues
fineCell.getDynamics().rescale(decomposedCoarseValues, toCoarse_xDxInv,
                               toCoarse_xDt, order);

}

For more information please ref “Advances in multi-domain lattice Boltzmann grid refinement”, by D. Lagrava.