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

boundary mesh and interpolation questions

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By mkraposhin

Reply
 
LinkBack Thread Tools Display Modes
Old   September 13, 2009, 06:33
Default boundary mesh and interpolation questions
  #1
New Member
 
Paul Schiefer
Join Date: Sep 2009
Posts: 25
Rep Power: 7
pauls is on a distinguished road
Dear all,
The boundary mesh handling of the fvMesh and GeometricField classes does not work quite as I expect. I believe the implementation makes sense, but I'll need some support to loop over boundaries faces and get field values on those face centers or vertices.

For example, if I run a modified solidDisplacementFoam on the plateHole tutorial (OF 1.5), I observe that the D.boundaryField() has 140 faces, while mesh.boundary() has 2140 faces. (D is the volVectorField related to deformation).
It looks like D.boundaryField() does not include the 2x1000 faces of patch "frontAndBack" which is defined with "type empty".

1) What is the natural procedure to loop over the values of D on *all* boundary faces (including the "frontAndBack" patch)? Right now I think I need to first interpolate D onto the face centers, then for each face check whether it is touching only one (->boundary face) or two cells (->internal face). I'm sure, OpenFOAM has functions for this purpose. Can you point me to the right functions in the class documentation? I didn't find enough information in the user guide or in the programming guide.

2) How do I get the face label of a Foam::face?
For example, setting
Foam::face fc=D.boundaryField()[patchIndex][faceIndex];
gives me a face fc, which I would like find in mesh.faces(). Without getting the label of fc, I can only compare the geometric coordinates, which is very expensive.

3) Does a function exist which returns the values of a vol(Scalar/Vector)Field on the vertices of the cells? Or do I first have to interpolate onto the face centers and from the face centers onto the vertices?

Thank you
Paul
pauls is offline   Reply With Quote

Old   September 13, 2009, 11:17
Default
  #2
Senior Member
 
mkraposhin's Avatar
 
Matvej Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 172
Rep Power: 8
mkraposhin is on a distinguished road
Hi, Paul

Quote:
For example, if I run a modified solidDisplacementFoam on the plateHole tutorial (OF 1.5), I observe that the D.boundaryField() has 140 faces, while mesh.boundary() has 2140 faces. (D is the volVectorField related to deformation).
It looks like D.boundaryField() does not include the 2x1000 faces of patch "frontAndBack" which is defined with "type empty".
I think, you need to read description of boundaries types in OpenFOAM carefully. Empty - is a PHYSICAL boundary type for excluding dimension (perpendicular to boundary faces) from calculations. For example, if you set all planes (oXoY) to 'empty', then, direction Z will be excluded from calculations - see fied D in tutorial plateHole - 3rd component of displacement vector is about 1e-17. So, it is no need to output values at this boundaries - they are like 'slip' type - if field is scalar, acts as zeroGradient, if field is vector - normal components are zero, tangential are zeroGradient.

Moreover, if field value is uniform across the boundary, then values are not printed, but used spicifier 'uniform' and 'value' to show this. See fixedValue, fixedGardient, zeroGradient (grad(psi) = 0)

Quote:
1) What is the natural procedure to loop over the values of D on *all* boundary faces (including the "frontAndBack" patch)? Right now I think I need to first interpolate D onto the face centers, then for each face check whether it is touching only one (->boundary face) or two cells (->internal face). I'm sure, OpenFOAM has functions for this purpose. Can you point me to the right functions in the class documentation? I didn't find enough information in the user guide or in the programming guide.
to iterate through all cells (values at cell centers of internal field volScalar(or Vector)Field psi)
forAll(psi, celli)
{
psi[celli] = ...
}

to iterate through all faces (values at all face centers at all patches)
forAll(psi.boundaryField(), patchi)
{

forAll(psi.boundaryField()[patchi], facei)
{
psi.boundaryField()[patchi][facei] = ....
}
}

or

forAll(psi.boundaryField(), patchi)
{
fvPatchScalarField &ppsi = psi.boundaryField()[patchi]
forAll(ppsi, facei)
{
ppsi[facei] = ....
}
}

Quote:
2) How do I get the face label of a Foam::face?
For example, setting
Foam::face fc=D.boundaryField()[patchIndex][faceIndex];
gives me a face fc, which I would like find in mesh.faces(). Without getting the label of fc, I can only compare the geometric coordinates, which is very expensive.
I think, in previous example 'facei' is face label.

Quote:
3) Does a function exist which returns the values of a vol(Scalar/Vector)Field on the vertices of the cells? Or do I first have to interpolate onto the face centers and from the face centers onto the vertices?
For managing point scalar (vector, tensor, etc) fields, use
pointScalar(Vector, Tensor, etc)Field, defined as

typedef GeometricField< scalar, pointPatchField, pointMesh > pointScalarField

defined at
line 45 of file pointFields.H


To volume field vField to point file pField (both of them define on fvMesh mesh), use (for example)

volPointInterpolation::New(mesh).interpolate
(
vField,
pField
);




As you see, the key function here is volPointInterpolation::interpolate(...) member of class volPointInterpolation

hope, this helps you
hua1015 likes this.
mkraposhin is offline   Reply With Quote

Old   September 13, 2009, 14:22
Default
  #3
New Member
 
Paul Schiefer
Join Date: Sep 2009
Posts: 25
Rep Power: 7
pauls is on a distinguished road
Dear Matjev,
thank you for the explanations. But some of your suggestions are not helpful, as I had already tried them, and they don't provide a solution to my questions.

Quote:
So, it is no need to output values at this boundaries - they are like 'slip' type - if field is scalar, acts as zeroGradient, if field is vector - normal components are zero, tangential are zeroGradient.
In my opinion there is need to output values on these boundaries. A surface plot in paraview shows not only values on the fixedValue, zeroGradient or whatever patches, but also on the empty patches, which is very useful. The displayed value is the value of the adjacent cell, I assume. In a similar fashion I want to evaluate D on all boundaries.

Quote:
forAll(psi.boundaryField(), patchi)
{
forAll(psi.boundaryField()[patchi], facei)
{
psi.boundaryField()[patchi][facei] = ....
}
}
I think, in previous example 'facei' is face label.
No, in this example facei is the index into the patch psi.boundaryField()[patchi]. mesh.faces()[facei] is a different face than psi.boundaryField()[patchi][facei].

Quote:
As you see, the key function here is volPointInterpolation::interpolate(...) member of class volPointInterpolation
Thanks, this is what I needed.

Paul
pauls is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Field interpolation in mesh points code jzlam OpenFOAM Post-Processing 2 December 14, 2010 17:48
interpolation in unstructured FV mesh ehsan Main CFD Forum 2 January 5, 2008 05:06
Has anyone successfully used transition modell..p2 PetrK CFX 12 May 26, 2006 16:27
periodic Boundary Condition for unstructured grid MLJ Main CFD Forum 2 June 16, 2000 05:57
3-d elliptic generation mesh Gang Sun Main CFD Forum 5 September 16, 1998 00:24


All times are GMT -4. The time now is 04:32.