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

How to extract ONLY ONE Boundary data to make a VectorField File from volVectorField

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 11, 2016, 18:05
Default How to extract ONLY ONE Boundary data to make a VectorField File from volVectorField
  #1
New Member
 
Yi Han
Join Date: Oct 2013
Location: Laramie WY
Posts: 15
Rep Power: 12
hy1112006 is on a distinguished road
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
... ...
)
hy1112006 is offline   Reply With Quote

Old   April 12, 2016, 06:09
Default
  #2
New Member
 
Volker
Join Date: Aug 2014
Location: Germany
Posts: 16
Rep Power: 11
volker1 is on a distinguished road
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.
Attached Files
File Type: c readoutput.c (5.3 KB, 21 views)
File Type: txt infile.txt (1.4 KB, 13 views)
volker1 is offline   Reply With Quote

Old   April 14, 2016, 12:11
Default
  #3
New Member
 
Yi Han
Join Date: Oct 2013
Location: Laramie WY
Posts: 15
Rep Power: 12
hy1112006 is on a distinguished road
Quote:
Originally Posted by volker1 View Post
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
hy1112006 is offline   Reply With Quote

Reply

Tags
openfoam

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[swak4Foam] funkyDoCalc with OF2.3 massflow NiFl OpenFOAM Community Contributions 14 November 25, 2020 03:30
[waves2Foam] Waves2Foam Related Topics ngj OpenFOAM Community Contributions 660 August 20, 2018 12:39
Question about heat transfer coefficient setting for CFX Anna Tian CFX 1 June 16, 2013 06:28
pisoFoam compiling error with OF 1.7.1 on MAC OSX Greg Givogue OpenFOAM Programming & Development 3 March 4, 2011 17:18
OpenFOAM 1.7.1 installation problem on OpenSUSE 11.3 flakid OpenFOAM Installation 16 December 28, 2010 08:48


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