CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   How to get coordinate of internal cellcentre and boundary facecenter as solution file (https://www.cfd-online.com/Forums/openfoam/233275-how-get-coordinate-internal-cellcentre-boundary-facecenter-solution-file.html)

BSengupta January 20, 2021 00:52

How to get coordinate of internal cellcentre and boundary facecenter as solution file
 
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

jurich January 20, 2021 09:38

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

BSengupta January 20, 2021 23:37

Quote:

Originally Posted by jurich (Post 793855)
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.


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