CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   How to extract ONLY ONE Boundary data to make a VectorField File from volVectorField (https://www.cfd-online.com/Forums/openfoam-programming-development/169496-how-extract-only-one-boundary-data-make-vectorfield-file-volvectorfield.html)

hy1112006 April 11, 2016 18:05

How to extract ONLY ONE Boundary data to make a VectorField File from volVectorField
 
I have a volVectorField file which reflects the face and cell center of the whole block. Now I need to extract only the Inlet Boundary VectorField. Could anyone tell me how can I do it?

Staring file :

/--------------------------------- C++ -----------------------------------\ | |
| \ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \ / O peration | Version: 2.1.1 |
| \ / A nd | Web: www.OpenFOAM.org |
| \/ M anipulation | |
*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0";
object HAG_BC;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 1 0 0 0 0 0];

internalField uniform (0 0 0);

boundaryField
{
east
{
type calculated;
value uniform (0 0 0);
}
lower
{
type calculated;
value uniform (0 0 0);
}
north
{
type calculated;
value uniform (0 0 0);
}
south
{
type calculated;
value uniform (0 0 0);
}
upper
{
type calculated;
value uniform (0 0 0);
}
west
{
type calculated;
value nonuniform List<vector>
25704
(
(9.19230379557e-13 15.015839523 1.65544315243)
(7.49421465245e-13 45.1163422992 1.61844085759)
(1.09919448444e-12 75.2338386748 2.04987578236)
......


//================================================== ===============//

Want:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.2.2 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class vectorField;
object values;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


25704
(
(9.19230379557e-13 15.015839523 1.65544315243)
(7.49421465245e-13 45.1163422992 1.61844085759)
(1.09919448444e-12 75.2338386748 2.04987578236)
(1.00178036208e-12 105.373361965 2.31514277443
... ...
)

volker1 April 12, 2016 06:09

2 Attachment(s)
Hi there,

I understand that you just want to process the strings in the output file.
Another option - however requiring source code changes - would be to print out something like
Code:

Info << HAG_BC.boundaryField()[5] ;
that basically should provide access to the specific boundary field data (at least if HAG_BC was a scalar field, never checked out for a vector field however).

I did something similar you want to do, but for scalar fields, see example in the attachment.
I think one could modify that to process vector fields, too.

hy1112006 April 14, 2016 12:11

Quote:

Originally Posted by volker1 (Post 594614)
Hi there,

I understand that you just want to process the strings in the output file.
Another option - however requiring source code changes - would be to print out something like
Code:

Info << HAG_BC.boundaryField()[5] ;
that basically should provide access to the specific boundary field data (at least if HAG_BC was a scalar field, never checked out for a vector field however).

I did something similar you want to do, but for scalar fields, see example in the attachment.
I think one could modify that to process vector fields, too.

//================================================== ================//

Hi volker1,

I have figured it out a way which will not touch the structure of the volVectorField. I just add 2 statement before and after the Input part as:

// Read the Heigh_Above_Ground data (Try volVectorField, not complete)

const fvMesh& mesh = patch().boundaryMesh().mesh(); //Add 1st
volVectorField Hightprof
(
IOobject
(
"HAG_BC",
this->db().time().timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
mesh
);
const label inletPatchID = mesh.boundaryMesh().findPatchID("west"); // Add 2nd
vectorField faceCenterHgtag = Hightprof.boundaryField()[inletPatchID];

But thanks also for your solution. It is another method to learn.
Thanks ,
Yi


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