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

How to get coordinate of internal cellcentre and boundary facecenter as solution file

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By jurich

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 20, 2021, 01:52
Default How to get coordinate of internal cellcentre and boundary facecenter as solution file
  #1
Member
 
Bidesh Sengupta
Join Date: Sep 2018
Location: Sngapore
Posts: 76
Rep Power: 8
BSengupta is on a distinguished road
Hi!


I wish to create a solver that will give me coordinate of cell center and boundary face center as a solution file. I am presenting the file which I wish to get:


Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | foam-extend: Open Source CFD                    |
|  \\    /   O peration     | Version:     4.0                                |
|   \\  /    A nd           | Web:         http://www.foam-extend.org         |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       vectorField;
    location    "0.5";
    object      coordinate;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 0 0 0 0 0];

internalField   nonuniform List<vector> 
400
(
    (interCell0_x interCell0_y interCell0_z)
    (interCell1_x interCell1_y interCell1_z)
    (interCell2_x interCell2_y interCell2_z)
    (interCell3_x interCell3_y interCell3_z)
    ...........
    ...........
    ...........
    (interCell399_x interCell399_y interCell399_z)
)
;

boundaryField
{
    movingWall
    {
        type            fixedValue;
        value           nonuniform List<vector>
        19
        (
        (face0Center0_x face0Center0_y face0Center0_z)
        (face0Center1_x face0Center1_y face0Center1_z)
        (face0Center2_x face0Center2_y face0Center2_z)
        ...........
        ...........
        ...........
        (face0Center18_x face0Center18_y face0Center18_z)
        )
    }
    fixedWalls
    {
        type            fixedValue;
        value           nonuniform List<vector>
        57
        (
        (face1Center0_x face1Center0_y face1Center0_z)
        (face1Center1_x face1Center1_y face1Center1_z)
        (face1Center2_x face1Center2_y face1Center2_z)
        ...........
        ...........
        ...........
        (face1Center56_x face1Center56_y face1Center56_z)
        )
    }
}


// ************************************************************************* //

I tried something by declaring



Code:
vectorField cellCenter
(
    IOobject
    (
        "cellCenter",
        runTime.timeName(),
        mesh,
        IOobject::READ_IF_PRESENT,
        IOobject::AUTO_WRITE
    ),
    mesh
);

for the cell center and have no idea how to get face center coordinate in the generic manner. I am aware we can get these coordinates by :


Code:
label patchI = mesh.boundaryMesh().findPatchID("movingWall");

    forAll(mesh.boundaryMesh()[patchI].faceCentres(), faceI)
    {
        scalar x = mesh.boundaryMesh()[patchI].faceCentres()[faceI].x();
        scalar y = mesh.boundaryMesh()[patchI].faceCentres()[faceI].y();
        scalar z = mesh.boundaryMesh()[patchI].faceCentres()[faceI].z();
        Info<<faceI<<" "<<x<<" "<<y<<" "<<z<<" "<<endl;
    }

something like this. But I don't want this way. I wish to have the coordinates as a result file as indicated in the first snippet.


I will be grateful to receive suggestion to achieve what I wish.


Thank you,
Bidesh
BSengupta is offline   Reply With Quote

Old   January 20, 2021, 10:38
Default
  #2
New Member
 
Joseph Urich
Join Date: Mar 2009
Location: Pittsburgh, PA
Posts: 21
Rep Power: 17
jurich is on a distinguished road
Hello Bidesh,

You can use
Code:
postProcess -func writeCellCentres
to get that. You can see the code to do it in src/functionObjects/field/writeCellCentres
tariq and BSengupta like this.
jurich is offline   Reply With Quote

Old   January 21, 2021, 00:37
Default
  #3
Member
 
Bidesh Sengupta
Join Date: Sep 2018
Location: Sngapore
Posts: 76
Rep Power: 8
BSengupta is on a distinguished road
Quote:
Originally Posted by jurich View Post
Hello Bidesh,

You can use
Code:
postProcess -func writeCellCentres
to get that. You can see the code to do it in src/functionObjects/field/writeCellCentres

Thank you. It was very useful.
BSengupta is offline   Reply With Quote

Reply

Tags
cell, coordinate, face, foam extend, openfaom


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



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