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

Printing mesh details

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 13, 2011, 16:28
Question Printing mesh details
  #1
New Member
 
Abhijit Joshi
Join Date: May 2011
Location: Atlanta, GA
Posts: 5
Rep Power: 14
jabhiji is on a distinguished road
Hi all,

This question is about the OpenFOAM source code. Perhaps some experienced OpenFOAM user can point me in the right direction.

I am trying to print out the X, Y and Z coordinates of the mesh for (say) a simple 2-D cavity flow problem using 20 x 20 control volumes (400 cells, 882 vertices). Suppose I add in the following for loop inside icoFoam.C:

for(label dummy=0; dummy < mesh.nPoints(); dummy++)
{
Info << SOMETHING GOES HERE;
}


What I want this loop to print is something like this:

indx = 1 X(1) = ..... Y(1) = ..... Z(1) = ....
indx = 2 X(2) = ..... Y(2) = ..... Z(2) = ....
.
.
.
and so on, for all 882 vertices.

What is the OpenFOAM function to print something like this ?

Thanks in advance,

- jabhiji
jabhiji is offline   Reply With Quote

Old   June 13, 2011, 17:40
Default
  #2
Member
 
Logan Page
Join Date: Sep 2010
Posts: 38
Rep Power: 15
Logan Page is on a distinguished road
For the element cell centres it would be something like

forAll(mesh.C(), cellI)
{
X = mesh.C()[cellI].component(0);
Y = mesh.C()[cellI].component(1);
Z = mesh.C()[cellI].component(2);

Info << "Ind = " << cellI << "X(" << cellI << ") = " << X << ... etc ... << endl;
}

or you can save all X, Y and Z values without the for loop like

scalarField CX = mesh.C().component(0);
scalarField CY = mesh.C().component(1);
scalarField CZ = mesh.C().component(2);
Logan Page is offline   Reply With Quote

Old   June 13, 2011, 18:14
Default
  #3
New Member
 
Abhijit Joshi
Join Date: May 2011
Location: Atlanta, GA
Posts: 5
Rep Power: 14
jabhiji is on a distinguished road
Thanks, Logan ! This is exactly what I was looking for. What is a good place to search for thing like this within the OpenFOAM documentation ? I am new to C++ and would like to get familiar with the overall design of this code but the online C++ documentation is a little intimidating...
jabhiji is offline   Reply With Quote

Old   June 13, 2011, 19:30
Default
  #4
Member
 
Logan Page
Join Date: Sep 2010
Posts: 38
Rep Power: 15
Logan Page is on a distinguished road
Unfortunately i cant help with that, im also new to C++ and i find the documentation rather confusing. What ive learnt so far has been from playing around and hours of googleing :P
Sorry
Logan Page is offline   Reply With Quote

Old   June 27, 2011, 18:52
Default
  #5
New Member
 
Abhijit Joshi
Join Date: May 2011
Location: Atlanta, GA
Posts: 5
Rep Power: 14
jabhiji is on a distinguished road
Hi Logan,

This is a follow-up question to the one you answered a few weeks ago, related to accessing information about the mesh and printing it out. The syntax worked perfectly fine when I was printing everything from the solver file (say, "pisoFoam.C").

But if we want to access the mesh information from inside one of the LES models (say, the file "DeardorffDiffStress.C", how can we make sure that the "mesh" object is in scope inside the "DeardorffDiffStress.C" file ? I assume that once a program begins to run, the mesh information is stored in a global location, which should then be accessible to all functions / classes etc.

Should one use

Foam::meshTools::mesh.C()

or something of that sort ? If I use the exact expression I wrote above, OpenFOAM gives me the following error during compile time:

Foam::meshTools’ has not been declared.

All I am doing is adding the following line inside "DeardorffStress.C"

const int total_cells = Foam::meshTools::mesh.nCells(); // total number of cells

Thanks and Regards,

- jabhiji
jabhiji is offline   Reply With Quote

Old   June 28, 2011, 07:50
Default
  #6
Member
 
Logan Page
Join Date: Sep 2010
Posts: 38
Rep Power: 15
Logan Page is on a distinguished road
I'm not 100% sure on the answer to this.

If I look at a post processing tool I use, there are the following lines.

#include "createMesh.H"
runTime.setTime(timeDirs[timeI], timeI);
mesh.readUpdate();

from what I understand the 1st line is the Mesh header file and this should include the mesh tools you need
the next 2 lines point to the required time directory and read the the variable information from there.
Logan Page is offline   Reply With Quote

Reply

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
[Other] vtk mesh or Abaqus mesh to OpenFOAM bigphil OpenFOAM Meshing & Mesh Conversion 27 November 23, 2015 17:31
[ICEM] Negative volume error in hybrid mesh siw ANSYS Meshing & Geometry 4 September 3, 2014 05:25
[Gmsh] 2D Mesh Generation Tutorial for GMSH aeroslacker OpenFOAM Meshing & Mesh Conversion 12 January 19, 2012 03:52
[snappyHexMesh] external flow with snappyHexMesh chelvistero OpenFOAM Meshing & Mesh Conversion 11 January 15, 2010 19:43
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 11:55


All times are GMT -4. The time now is 09:50.