CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Writing scalarField values into a pointScalarField

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Hisham
  • 1 Post By BSengupta

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 13, 2011, 08:06
Default Writing scalarField values into a pointScalarField
  #1
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 18
Arnoldinho is on a distinguished road
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:ointPatchField, Foam:ointMesh>::GeometricBoundaryField*)hbVolPoi nts.Foam::GeometricField<Type, PatchField, GeoMesh>::boundaryField [with Type = double, PatchField = Foam:ointPatchField, GeoMesh = Foam:ointMesh]())->Foam::GeometricField<double, Foam:ointPatchField, Foam:ointMesh>::GeometricBoundaryField::<anonymo us>.Foam::FieldField<Foam:ointPatchField, double>::<anonymous>.Foam::PtrList<T>:perator[] [with T = Foam:ointPatchField<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 is offline   Reply With Quote

Old   October 13, 2011, 08:52
Default
  #2
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 18
Arnoldinho is on a distinguished road
Sorry, patchInternalField() is of course a function to write internalField values to the corresponding boundaryFields. I mixed that.

Last edited by Arnoldinho; October 13, 2011 at 08:58. Reason: typo
Arnoldinho is offline   Reply With Quote

Old   October 13, 2011, 09:58
Default
  #3
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
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
rajibroy likes this.
Hisham is offline   Reply With Quote

Old   October 13, 2011, 10:05
Default
  #4
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 18
Arnoldinho is on a distinguished road
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

Last edited by Arnoldinho; October 13, 2011 at 10:26.
Arnoldinho is offline   Reply With Quote

Old   October 13, 2011, 10:26
Default
  #5
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 18
Arnoldinho is on a distinguished road
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
Arnoldinho is offline   Reply With Quote

Old   October 13, 2011, 13:21
Default
  #6
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
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
Hisham is offline   Reply With Quote

Old   October 22, 2019, 04:38
Default
  #7
Member
 
Bidesh Sengupta
Join Date: Sep 2018
Location: Sngapore
Posts: 76
Rep Power: 8
BSengupta is on a distinguished road
Sorry for bumping into an old post. But my problem seems very similar.


I wish to write a scalarField. My code is the following:


scalarField CE = (pUx*normal_x + pUy*normal_y + pUz*normal_z)/(mag(U_Air) * rho_Air);

volScalarField bCE
(
IOobject
(
"CE",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("CE", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0)
);


It is getting compiled. I could print the values on the terminal and those were non zero. But it is always writing the values as 0.


"
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0.75364000004";
object CE;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 0 0 0 0 0 0];

internalField uniform 0;

boundaryField
{
wall
{
type calculated;
value uniform 0;
}
pressure-far-field-1
{
type calculated;
value uniform 0;
}
frontAndBackPlanes
{
type empty;
}
}

"


Can any one suggest me my mistake.
Thanks a lot.
the_ichthyologist likes this.
BSengupta is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
It would be wonderful if a tool for FoamToTecplot is available luckyluke OpenFOAM Post-Processing 165 November 27, 2012 07:54
max node values exceed max element values in contour plot jason_t FLUENT 0 August 19, 2009 12:32
exact face values RubenG Main CFD Forum 0 June 22, 2009 12:09
Writing yPlusRAS Values velan OpenFOAM Running, Solving & CFD 0 December 30, 2008 07:09
strange node values @ solid/fluid interface - help JB FLUENT 2 November 1, 2008 13:04


All times are GMT -4. The time now is 18:40.