|
[Sponsors] |
June 13, 2011, 16:28 |
Printing mesh details
|
#1 |
New Member
Abhijit Joshi
Join Date: May 2011
Location: Atlanta, GA
Posts: 5
Rep Power: 14 |
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 |
|
June 13, 2011, 17:40 |
|
#2 |
Member
Logan Page
Join Date: Sep 2010
Posts: 38
Rep Power: 15 |
For the element cell centres it would be something like
forAll(mesh.C(), cellI) { X = mesh.C()[cellI].component(0);} 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); |
|
June 13, 2011, 18:14 |
|
#3 |
New Member
Abhijit Joshi
Join Date: May 2011
Location: Atlanta, GA
Posts: 5
Rep Power: 14 |
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...
|
|
June 13, 2011, 19:30 |
|
#4 |
Member
Logan Page
Join Date: Sep 2010
Posts: 38
Rep Power: 15 |
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 |
|
June 27, 2011, 18:52 |
|
#5 |
New Member
Abhijit Joshi
Join Date: May 2011
Location: Atlanta, GA
Posts: 5
Rep Power: 14 |
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 |
|
June 28, 2011, 07:50 |
|
#6 |
Member
Logan Page
Join Date: Sep 2010
Posts: 38
Rep Power: 15 |
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. |
|
|
|
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 |