Hello,
The simplest way of varying the relaxation parameter omega is to tell the Shan/Chen data processor that omega is not constant; the data processor will then read the value of omega from the dynamics object, on every cell, when it is needed. To do this, you need (as you pointed out) to construct the Shan/Chen data processor through the standard constructor:
new ShanChenMultiComponentProcessor2D(G);
After this, you can change omega as often as needed by accessing the cells of the lattice directly. A data processor which does this for you will be provided in the next Palabos release, but is not implemented in the current release. In the mean time, you can copy-paste the following code into your program:
namespace plb {
template<typename T, template<typename U> class Descriptor>
class AssignOmegaFunctional2D : public BoxProcessingFunctional2D_L<T,Descriptor>
{
public:
AssignOmegaFunctional2D(T omega);
virtual void process(Box2D domain, BlockLattice2D<T,Descriptor>& lattice);
virtual AssignOmegaFunctional2D<T,Descriptor>* clone() const;
virtual BlockDomain::DomainT appliesTo() const;
virtual void getModificationPattern(std::vector<bool>& isWritten) const;
private:
T omega;
};
/* ************* Class AssignOmegaFunctional2D ******************* */
template<typename T, template<typename U> class Descriptor>
AssignOmegaFunctional2D<T,Descriptor>::AssignOmegaFunctional2D(T omega_)
: omega(omega_)
{ }
template<typename T, template<typename U> class Descriptor>
void AssignOmegaFunctional2D<T,Descriptor>::process (
Box2D domain, BlockLattice2D<T,Descriptor>& lattice )
{
for (plint iX=domain.x0; iX<=domain.x1; ++iX) {
for (plint iY=domain.y0; iY<=domain.y1; ++iY) {
lattice.get(iX,iY).getDynamics().setOmega(omega);
}
}
}
template<typename T, template<typename U> class Descriptor>
AssignOmegaFunctional2D<T,Descriptor>*
AssignOmegaFunctional2D<T,Descriptor>::clone() const
{
return new AssignOmegaFunctional2D<T,Descriptor>(*this);
}
template<typename T, template<typename U> class Descriptor>
BlockDomain::DomainT AssignOmegaFunctional2D<T,Descriptor>::appliesTo() const
{
// Omega needs to be set on envelope nodes as well, because the dynamics object
// is being modified.
return BlockDomain::bulkAndEnvelope;
}
template<typename T, template<typename U> class Descriptor>
void AssignOmegaFunctional2D<T,Descriptor>::getModificationPattern (
std::vector<bool>& isWritten) const
{
isWritten[0] = true;
}
template<typename T, template<class U> class Descriptor>
void setOmega(MultiBlockLattice2D<T,Descriptor>& lattice, Box2D domain, T omega) {
applyProcessingFunctional(new AssignOmegaFunctional2D<T,Descriptor>(omega), domain, lattice);
}
}
Then, you can modify the relaxation parameter at any time by invoking something like
setOmega(lattice, lattice.getBoundingBox(), omega);
Hope this works. If not, just let us know.