CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Writing scalarField values into a pointScalarField (http://www.cfd-online.com/Forums/openfoam-programming-development/93375-writing-scalarfield-values-into-pointscalarfield.html)

Arnoldinho October 13, 2011 07:06

Writing scalarField values into a pointScalarField
 
Hi all,

I want to write values of a scalarField sF to the patch boundaryField values of a pointScalarField pSF. The pointScalarField pSF has been created as

pointScalarField pSF
(
IOobject
(
"pSF",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
pMesh,
dimensionedScalar("pSF", dimensionSet(0, 1, 0, 0, 0, 0, 0), 0.0),
"zeroGradient"
);

These are the errors I get:

1. pSF.boundaryField()[patchi] = sF; results in
Quote:

error: no match for ‘operator=’ in ‘((Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh>::GeometricBoundaryField*)hbVolPoi nts.Foam::GeometricField<Type, PatchField, GeoMesh>::boundaryField [with Type = double, PatchField = Foam::pointPatchField, GeoMesh = Foam::pointMesh]())->Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh>::GeometricBoundaryField::<anonymo us>.Foam::FieldField<Foam::pointPatchField, double>::<anonymous>.Foam::PtrList<T>::operator[] [with T = Foam::pointPatchField<double>](patchi) = hbVolPointsPatch’
If pSF was a volScalarField instead of a pointScalarField, it would compile and run (except wrong patch sizes) but thats not what I want.

2. pSF.boundaryField()[patchi].patchInternalField() = sF; compiles but results in
Quote:

--> FOAM FATAL ERROR:
attempted to assign to a const reference to constant object
during runtime. Also, I'm not sure if .patchInternalField() assigns the points on patchi of the boundaryField!?

Do you have any idea?

Arne

Arnoldinho October 13, 2011 07:52

Sorry, patchInternalField() is of course a function to write internalField values to the corresponding boundaryFields. I mixed that.

Hisham October 13, 2011 08:58

Hi Arne,

I hope it helps to recall that a geometricField (e.g. a volScalarField) is defined at cell centroid, whereas pointField values are defined at cell vertices. Refer to figure 2.4 of the programmer's guide.

Best regards,
Hisham

Arnoldinho October 13, 2011 09:05

Hi Hisham,

Quote:

I hope it helps to recall that a geometricField (e.g. a volScalarField) is defined at cell centroid, whereas pointField values are defined at cell vertices.
Thanks, I got that. I'm just wondering why a volScalarField has a boundaryField() option, while a pointScalarField does not seems to have.

Do you have a hint on howto access/replace the points on the specific boundary patch of the pointScalarField? I'm stuck right now...

Arne

Arnoldinho October 13, 2011 09:26

Ok, regarding Figure 2.4, I'm a bit confused. boundaryField values of a volField are on the edes (in 2D), what is the same for a pointField.

So now I'm not sure which points I need: I want to modify a pointDisplacement file as boundary condition for e.g. interDyMFoam during runTime. Modifications in the pointDisplacement file are done in the boundaryField (e.g. SnakeRiverCanyon tutorial). Regarding fig. 2.4, are these now the vertices of the internalField lying on the patch, or the face mid-points of the bundaryField lying on the patch?

Arne

Hisham October 13, 2011 12:21

The following is only my understanding (not to be taken without checking)

The fvMesh is the mesh on which all FV calculations are done and stored. Therefore, it is logically found that a geometricBoundaryField exists, which is a geometricField defined over the patchField.

Checking moveDynamicMesh, what is manipulated is the dynamicFvMesh, which is an fvMesh (again centroid).

Checking the code (I have no experience with moving mesh but interested), the dynamicFvMesh type set, in the dynamicMeshDict dictionary, is the responsible for the mesh.update() function.

Checking this dynamicMotionSolverFvMesh.C for example, it seems that the code does the update of the fvMesh.

In displacementSBRStressFvMotionSolver.C, it seems that there is an interpolation from pre-defined face displacements to cell centroid. Then, the motion solver solves for cellDisplacement, which I believe is at the centroid (as the Doxygen makes it explicitly clear that all FV calculations are at the fvMesh)

I am interested in this topic, would you kindly keep me informed?

Best regards,
Hisham


All times are GMT -4. The time now is 17:25.