CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   interpolate field to sampledPlane (https://www.cfd-online.com/Forums/openfoam/70687-interpolate-field-sampledplane.html)

nikwin December 2, 2009 10:29

interpolate field to sampledPlane
 
Dear All,

I'm trying to average a field, e.g. p, over a plane as,

plane xPl(x, n);
sampledPlane smpPl("smpPl", mesh, xPl,word::null,false);
const scalarField pPl(smpPl.sample(p));
av_p = smpPl.average(pPl);

The problem is that the sampled value is directly taken as the cell center value and not interpolated from cell centers to the plane. Any ideas how to interpolate onto the plane and then average?

I've tried .interpolate(pInt) instead of .sample(p) where pInt is constructed as a volPointInterpolation class. It compiles but gives me the following error when trying to average,

size mismatch: field (384) != surface (377)

Thanks
/NW

nikwin December 9, 2009 11:35

From the forum I've understood that there is a bug in OF-1.5 which should be fixed for OF-1.6. So, I've installed version 1.6 and now trying my code but without success when trying to compile.

I'm getting an error when trying
#include "sampledPlane.H" as follows,

OpenFOAM-1.6/src/sampling/lnInclude/cuttingPlane.H:49:27: error: MeshedSurface.H: No such file or directory
In file included from /scratch/nwinkler/OpenFOAM/OpenFOAM-1.6/src/sampling/lnInclude/sampledPlane.H:40,

And I can not understand from doxygen which other classes to use to obtain a sampledPlane with interpolated values, anyone?

All the Best
/NW

nikwin December 10, 2009 07:49

Ok. I got it to compile after including surfMesh as an EXE_INC = \ in /Make/options and constructing a sampledPlane with 4 arguments, not 5 as in OF-1.5.

The problem is now that my sampledPlane is empty, which it's not in OF-1.5. Is there possibly a bug in the new version of sampledPlane, with a simple fix?

/NW

nikwin January 5, 2010 09:34

Any new ideas of how to obtain averaged data over a plane from interpolated values, OF-1.5 or 1.6?

Thanks
/NW

nikwin January 29, 2010 06:18

Thanks to Mattijs I got it to work!

Info<< "Reading field p\n" << endl;
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
interpolationCellPoint<scalar> pInterp(p);

plane pl(point(0.0,2.5e-4,0.0), vector(0,1,0));
sampledPlane spl("planeY", mesh, pl);
spl.update();

scalarField pInterpPl(spl.interpolate(pInterp));

SubList<face> splFaces(spl.faces(), spl.faces().size());
primitivePatch primitivePtch(splFaces, spl.points());

primitivePatchInterpolation primPatchInterp(primitivePtch);

scalarField pInterpPlFaces(primPatchInterp.pointToFaceInterpol ate(pInterpPl));
Info << "spl.average(pInterpPlFaces) = " << spl.average(pInterpPlFaces) << endl;

aliqasemi October 13, 2011 08:31

Quote:

Originally Posted by nikwin (Post 244199)
Thanks to Mattijs I got it to work!

Info<< "Reading field p\n" << endl;
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
interpolationCellPoint<scalar> pInterp(p);

plane pl(point(0.0,2.5e-4,0.0), vector(0,1,0));
sampledPlane spl("planeY", mesh, pl);
spl.update();

scalarField pInterpPl(spl.interpolate(pInterp));

SubList<face> splFaces(spl.faces(), spl.faces().size());
primitivePatch primitivePtch(splFaces, spl.points());

primitivePatchInterpolation primPatchInterp(primitivePtch);

scalarField pInterpPlFaces(primPatchInterp.pointToFaceInterpol ate(pInterpPl));
Info << "spl.average(pInterpPlFaces) = " << spl.average(pInterpPlFaces) << endl;

This method didn't work for me, complaining that the field pInterpPl does not correspond to the patch primitivePtch at run time. Apparently after the patch is created the points are reordered/reassigned and are not identical to the points provided in the patch constructor. Any workarounds?


All times are GMT -4. The time now is 00:10.