Manipulating MultiTensorFields

I have just started using palabos, and I’m thoroughly confused with the multiblock structure and multitensorfield class.

Specifically, I have 2 vector fields stored as MultiTensorField <float, 2> objects, and I wanted to subtract them: calling them u and v, conceptually I would like to do "w(x)=u(x)-v(x) " for every x on the lattice, and store w as a new MultiTensorField <float, 2> type object.

The function reference appendix at palabos user’s guide ( has the following method in its description:

subtract(A, B, domain)
Return C=A-B, applied to every element of the domain.

Which is precisely what I need. However if I try to compile this piece of code: [code=“cpp”]
MultiTensorField2D<T,2> analyticalVelocity(lattice); //Define U
setToFunction( analyticalVelocity, analyticalVelocity.getBoundingBox(),
PoiseuilleVelocity(parameters) );
MultiTensorField2D<T,2> numericalVelocity(lattice); //Define V
computeVelocity(lattice, numericalVelocity, lattice.getBoundingBox());

std::auto_ptr<MultiTensorField2D<T,2> > subtract(analyticalVelocity, numericalVelocity, lattice);      //Subtract!

The code won't compile. What would be the correct synthax for this case?
Do I need to write a data processor for this operation? If so, how would write that? Would I need to call [code="cpp"]
subtract(A, B, domain)

inside the process method?

Thanks in advance

Dear Asasuser,

there is no need to write a data processor for this task, because there are several ways to perform such a subtraction already implemented in palabos.
One way to do it, could look like this (stand-alone minimal example)

#include “palabos2D.h”
#include “palabos2D.hh”

using namespace plb ;
using namespace std ;

typedef double T ;

int main(int argc, char* argv[]) {
plbInit(&argc, &argv);

// Define size
const plint nx = 3 ;
const plint ny = 3 ;

// Create a MultiTensorField A, which is initialized with a
// vector (7,3) at every location
Array<T,2> initialValuesA ( 7., 3.) ;
MultiTensorField2D<T,2> A (nx,ny,initialValuesA) ;

pcout << "A:\t" << A << endl ;

// Create a second MultiTensorField called B, which is initialized with a
// vector (4,1) at every location
Array<T,2> initialValuesB ( 4., 1.) ;
MultiTensorField2D<T,2> B (nx,ny,initialValuesB) ;

pcout << "B:\t" << B << endl ;

// Create a third MultiTensorField for the solution of the subtraction
MultiTensorField2D<T,2> C (nx,ny) ;

// Define Box inside which the subtraction is performed.
// Here, throughout the whole domain
Box2D domain (0,nx-1,0,ny-1) ;

subtract(A,B,C,domain) ;

pcout << "C=A-B:\t" << C << endl ;


In this way, the subtraction is performed for both dimensions for each entry of the tensorfields.

I hope this helps.



PS. If something does not compile it is helpful to include the error message in your post