Dear Jonas,
Thanks very much for your reply.
Yes, I noticed that after I read some stuff about data processor and wrote another code with BoxProcessingFunctional3D_LL and applyProcessingFunctional. I used iniCellAtEquilibrium(cell, density, velocity) after I exchanged the density and velocity. The code can be compiled and run without error. However, the results (density and velocity fields) are incorrect and the same as simulation without this boundary condition. In other words, data processor doesn’t work.
Moreover, I considered your suggestion and used cell.getDynamics().computeEquilibria. There is no change.
The code I have tried are:
[code=“cpp”]
template<typename T, template class Descriptor>
class PeriodicBCInletProcessor3D : public BoxProcessingFunctional3D_LL<T,Descriptor,T,Descriptor>
{
virtual void process(Box3D domain, BlockLattice3D<T,Descriptor>& lattice,
BlockLattice3D<T,Descriptor>& latticeOutlet1)
{
//typedef Descriptor D;
Dot3D absoluteOffset = lattice.getLocation();
for (plint iX=domain.x0; iX<=domain.x1; ++iX)
{
plint absoluteX = absoluteOffset.x + iX;
for (plint iY=domain.y0; iY<=domain.y1; ++iY)
{
plint absoluteY = absoluteOffset.y + iY;
for (plint iZ=domain.z0; iZ<=domain.z1; ++iZ)
{
plint absoluteZ = absoluteOffset.z + iZ;
Cell<T, Descriptor>& cell = lattice.get(iX,iY,iZ);
Cell<T, Descriptor>& cell1 = latticeOutlet1.get(absoluteY,absoluteX+1,absoluteZ);
T density = cell1.computeDensity();
Array<T, 3> velocity;
cell1.computeVelocity(velocity);
cell.defineDensity(density);
cell.defineVelocity(velocity);
iniCellAtEquilibrium(cell, density, velocity);
//T rhoBar;
//Array<T,3> j;
//Array<T,D::q> fEq;
//cell1.getDynamics().computeRhoBarJ(cell, rhoBar, j);
//T jSqr = normSqr(j);
//cell.getDynamics().computeEquilibria(fEq, rhoBar, j, jSqr);
//for (plint iPop=0; iPop<D::q; ++iPop)
//{
// cell[iPop] = fEq[iPop];
//}
}
}
}
}
virtual PeriodicBCInletProcessor3D<T,Descriptor>* clone() const
{
return new PeriodicBCInletProcessor3D<T,Descriptor>(*this);
}
virtual void getModificationPattern(std::vector<bool>& isWritten) const
{
isWritten[0] = true;
isWritten[1] = false;
}
virtual void getTypeOfModification(std::vector<modif::ModifT>& modified) const
{
modified[0] = modif::staticVariables;
}
virtual BlockDomain::DomainT appliesTo() const
{
return BlockDomain::bulkAndEnvelope;
}
};
and call it by
[code="cpp"]
void setPeriodicBC (MultiBlockLattice3D<T,DESCRIPTOR>& lattice,
MultiBlockLattice3D<T,DESCRIPTOR>& latticeInlet1,
MultiBlockLattice3D<T,DESCRIPTOR>& latticeOutlet1,
Box3D inletPlane, Box3D outletPlane)
{
applyProcessingFunctional(
new PeriodicBCInletProcessor3D<T,DESCRIPTOR>,
inletPlane, lattice, latticeOutlet1);
//applyProcessingFunctional(
// new PeriodicBCOutletProcessor3D<T,DESCRIPTOR>,
// outletPlane, lattice, latticeInlet1);
}
Thanks.