The way to write your data processor in parallelism

Author: jonas1
From :https://palabos-forum.unige.ch/t/data-processor-for-non-local-operation/1075/2

This example shows how to exchange the density and velocity of two blocklattices.

template<typename T, template class Descriptor>
class SetToLocalEquilibrium3D : public BoxProcessingFunctional3D_L<T,Descriptor>
{
virtual void process(Box3D domain, BlockLattice3D<T,Descriptor>& lattice) {
typedef Descriptor D;
for (plint iX=domain.x0; iX<=domain.x1; ++iX) {
for (plint iY=domain.y0; iY<=domain.y1; ++iY) {
for (plint iZ=domain.z0; iZ<=domain.z1; ++iZ) {
Cell<T,Descriptor>& cell = lattice.get(iX,iY,iZ);
T rhoBar; Array<T,3> j; Array<T,D::q> fEq;
cell.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];
}
}
}
}
}
void getTypeOfModification(std::vectormodif::ModifT& modified) const {
modified[0] = modif::staticVariables;
}
virtual SetToLocalEquilibrium3D<T,Descriptor>* clone() const {
return new SetToLocalEquilibrium3D<T,Descriptor>(*this);
}
};
applyProcessingFunctional(new SetToLocalEquilibrium3D<T,DESCRIPTOR>, domain, lattice);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值