# Calculate surfaceScalarField in parallel (boundary processor)

 Register Blogs Members List Search Today's Posts Mark Forums Read

October 2, 2021, 20:42
Calculate surfaceScalarField in parallel (boundary processor)
#1
Member

Federico Zabaleta
Join Date: May 2016
Posts: 47
Rep Power: 8
Hi everyone,

I have a diffusivity "D" calculated in the faces of the cell. I want to limit D on some faces (make it zero), when a parameter "P" (also defined in the faces) is smaller than "epsilon". The code I use works well, EXCEPT ON THE BOUNDARIES BETWEEN PROCESSORS. Attached is a figure of D calculated in series, and D calculated in parallel with 32 processors. You'll see that they are different ONLY in the boundaries between processors (indicated with the glyphs)

Following the implementation of flux limiters on MULES, I do the following (simplified code):

Code:
```surfaceScalarField D(fvc::interpolate(D_cell));
scalarField allLambda(mesh.nFaces(), 1.0);

slicedSurfaceScalarField lambda
(
IOobject
(
"lambda",
mesh.time().timeName(),
mesh,
IOobject::NO_WRITE,
false
),
mesh,
dimless,
allLambda,
false   // Use slices for the couples
);

scalarField& lambdaIf = lambda;
surfaceScalarField::Boundary& lambdaBf = lambda.boundaryFieldRef();

forAll(lambdaIf, facei)
{
if(P[facei] < epsilon) {lambdaIf[facei] = 0;}
}

forAll(lambdaBf, patchi)
{
scalarField& lambdaPf = lambdaBf[patchi];
forAll(lambdaPf, pFacei)
{
if(P[pFacei] < epsilon) {lambdaIf[pFacei] = 0;}
}
}

syncTools::syncFaceList(mesh,allLambda,minEqOp<scalar>());

D*=lambda;```
I really don't understand where is my error or what I'm missing! I've been struggling a lot with this. Pleas HELP!
Attached Images
 Screenshot from 2021-10-02 17-37-49.jpg (30.6 KB, 10 views)

 October 2, 2021, 22:39 #2 Member   Federico Zabaleta Join Date: May 2016 Posts: 47 Rep Power: 8 Found the error. It was a stupid typo. It should have said lambdaPf and not lambdaIf on the boundary fields. Code: ```forAll(lambdaBf, patchi) { scalarField& lambdaPf = lambdaBf[patchi]; forAll(lambdaPf, pFacei) { if(P[pFacei] < epsilon) {lambdaPf[pFacei] = 0;} } }``` CorbinMG likes this.