CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Averaging due to parallel running - cuttingPlane (https://www.cfd-online.com/Forums/openfoam-programming-development/82878-averaging-due-parallel-running-cuttingplane.html)

woody December 8, 2010 07:42

Averaging due to parallel running - cuttingPlane
 
Dear All,

I am actually implementing a boundary condition that accesses some Field values like p, U, rho from cutting planes inside the mesh. As only the average of the cut Field is of interest, I have to create some kind of weighting factor for each processor part.

So far the Code looks like this:

Code:

  // Create the cutting Planes
  point planeLocation = planeLocations[planeI];
  plane extPlane(planeLocation,orientPatch);
  cuttingPlane cuttedPlane(extPlane,this->dimensionedInternalField().mesh());
   
  vector averageUPRho(0.0,0.0,0.0);

  scalar weigthPatch;

  // Compute the the cut of each processor
  if (cuttedPlane.cut()== 1)
  {
   
    averageUPRho.component(0)= (average(cuttedPlane.sample(Ufield)) & orientPatch); // The mean Velocity in normal Direction
    averageUPRho.component(1)= average(cuttedPlane.sample(pfield));// The mean Pressure
    averageUPRho.component(2)=average(cuttedPlane.sample(rhofield));// The mean Density
    weigthPatch= cuttedPlane.size(); // The weighting factor
    }
    else
    {
    weigthPatch=0;
    }

Now I forward the averageUPRho and the weigthPatch to the Master and do the averaging with

rhoMean=sum(averageUPRho*weigthPatch)/sum(weigthPatch);

unfortunately I weight by the number of faces and not by their Area (magSf for patches works ... not for planes?).

How can I acces them??

Any hints?

l_r_mcglashan December 8, 2010 10:35

I notice that sampledPlane inherits from sampledSurface and cuttingPlane. sampledSurface has an area() function. Would that help you? Could you create a sampledPlane from your plane?

woody December 8, 2010 10:54

It worked...

just adding / editing 2 lines...

Code:

...

cuttingPlane cuttedPlane(extPlane,this->dimensionedInternalField().mesh());
sampledPlane smpPl("smpPl",this->dimensionedInternalField().mesh(),extPlane);
....
averageUPRho.component(2)=average(cuttedPlane.sample(rhofield));
weigthPlane= sum(smpPl.magSf());
}
...


l_r_mcglashan December 8, 2010 11:58

You can replace weightPlane with smpPI.area()

Also because samplePlane inherits from cuttingPlane, you probably don't need cuttedPlane and can just use smpPI?

woody December 9, 2010 03:33

Hi Laurence,

Thanks for the reply...

Quote:

Originally Posted by l_r_mcglashan (Post 286564)
You can replace weightPlane with smpPI.area()

area() unfortunately passes the total plane magnitude, not only the part a processor contains ....:mad:

Quote:

Originally Posted by l_r_mcglashan (Post 286564)
Also because samplePlane inherits from cuttingPlane, you probably don't need cuttedPlane and can just use smpPI?

...this works fine...:)

Thanks so far...


All times are GMT -4. The time now is 03:39.