CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Calculate surfaceScalarField in parallel (boundary processor) (https://www.cfd-online.com/Forums/openfoam-programming-development/238781-calculate-surfacescalarfield-parallel-boundary-processor.html)

 fedez91 October 2, 2021 20:42

Calculate surfaceScalarField in parallel (boundary processor)

1 Attachment(s)
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_READ,         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! :confused::confused:

 fedez91 October 2, 2021 22:39

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;}     } }```

 All times are GMT -4. The time now is 21:31.