Integral in parallel

Hello,

When computing an integral in parallel, I know one needs to scale things and do a global reduction. There are examples in previous posts (for example here) with the integral of 2 vectors, say:

Vh<complex> scaledVecu = Vecu;
for[i, v : A.D] scaledVecu[] *= v;
complex wrong = int2d(Th)(scaledVecu*AnotherVec);
complex reduce;
mpiAllReduce(wrong, reduce, mpiCommWorld, mpiSUM);
if(mpirank == 0)
        cout << reduce << endl;

My question is: if there are more than 2 vectors in the integral, should the rescaling still apply to only one of them?

Thank you.

This is in fact independent of the number of components. Keep in mind that in FreeFEM, whenever you do u[], it selects all degrees of freedom. So whether u is a function defined on a fespace Vh(Th, [Pk, Qk, Tk, Zk, Wk]) or fespace Vh(Th, Pk), the syntax from your snippet will indeed scale all values of scaledVecu (proper things to do).

Thank you for your reply. Sorry, my question was not clear: I was not talking of the number of components (for instance [ux] vs [ux,uy] vs [ux,uy,uz] etc.), but the number of terms that are multiplied in the integrand: int2d(Th)(u*v) vs int2d(Th)(u*v*w).

I see. Only one of the term has to be scaled.

Great. Thank you very much.