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

[Technical] Points

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 28, 2004, 17:00
Default Points
  #1
Satish Undapalli (Satish)
Guest
 
Posts: n/a
Hi
I want to read the points file using a code. I have multi blocks in my FOAM grid. I would like to know how these points are written in the file. I want to read these points using a FORTRAN code. Is this possible?
  Reply With Quote

Old   January 28, 2004, 18:27
Default Do you want to read the point
  #2
Mattijs Janssens (Mattijs)
Guest
 
Posts: n/a
Do you want to read the points from the blockMeshDict only (i.e. the block points) or the points from the generated mesh?

If the latter you can write a simple application to read the mesh and dump the points into a file with one coordinate per line so Fortran can easily read it.

Something like (starting from an application which read a mesh)
..
OFstream pointStream("points.txt");
forAll(mesh.points(), pointI)
{
const point& pt = mesh.points()[pointI];
pointStream << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl;
}
..


(if you want to read the block points that will be a bit harder. You'll have to read the blockMeshDict dictionary and dump the points as above)
  Reply With Quote

Old   May 5, 2008, 13:57
Default Hi Mattijs, is there a chan
  #3
Senior Member
 
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19
braennstroem is on a distinguished road
Hi Mattijs,

is there a chance to do it vice versa, i.e. read two different point text files and create a points file for the polymesh?

I would read a file like:


fileName fileC= runTime.path()/runTime.constant()/"points2.txt";
IFstream CFile(fileC);
double T1;
double T2;
double T3;

while(0==CFile.eof() )
{
if (0==CFile.eof())
{
CFile >> T1 >> T2>> T3;
Info << CFile.eof() << endl;

}
}
but I get this:

--> FOAM FATAL IO ERROR : Attempt to get back from bad stream

file: /Software/OpenFOAM-1.4.1/tutorials_1.4.1/tutorials/simpleFoam/pitzDaily/constant /points2.txt at line 25014.

From function void Istream::getBack(token& t)
in file db/IOstreams/IOstreams/Istream.C at line 44.


Once this would work, I would read a different points-file and assign newT1, newT2 and newT3. Afterwards the difference should be added to the existings points:

diff1=T1-newT1
diff2=T2-newT2
diff3=T3-newT3



The difference could be added to the existing points by:


pointField zeroPoints(mesh.points());

pointField newPoints = zeroPoints + scaleFactor*pInterp.interpolate(diff)().internalFi eld();

mesh.polyMesh::movePoints(newPoints);
mesh.write();


where 'diff' is a somehow created vector.

Would be nice, if you have (or anyone) some good hints :-)

Thanks!
Fabian
braennstroem is offline   Reply With Quote

Old   May 6, 2008, 17:15
Default You are probably trying to rea
  #4
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
You are probably trying to read 3 scalars from a last empty line.

Fix file or loop instead mesh.nPoints() times is my advice.
mattijs is offline   Reply With Quote

Old   May 7, 2008, 02:09
Default Oh, pretty simple with the loo
  #5
Senior Member
 
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19
braennstroem is on a distinguished road
Oh, pretty simple with the loop over mesh.nPoints. Fixing the file my way did not help though. Thanks a lot!

Fabian
braennstroem is offline   Reply With Quote

Old   May 7, 2008, 03:42
Default me again... actually I use thi
  #6
Senior Member
 
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19
braennstroem is on a distinguished road
me again... actually I use this for reading the points2.txt file and the orig mesh. It works fine, but now the trouble is to combine the vector to a vectorField, which can be passed to the morphing:


fileName fileC= runTime.path()/runTime.constant()/"points2.txt";
IFstream CFile(fileC);
scalar diff;
vector diffv;
vector T;
double scale=1.0;

forAll(mesh.points(), pointI)
{
CFile >> T; //read shape vectors
const point& pt = mesh.points()[pointI]; //orig mesh
pointStream << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl; //read orig mesh
diff = pt.y()-T.component(1);
diffv = pt - scale* T; // create diff between orig mesh and shape
}

Info << "Vektor T: "<< T << endl;
Info << "Vektor T1: "<< T.component(1) << endl;
Info << "Diff: "<< diff << endl;
Info << "Diff-Vektor: "<< diffv << endl;


Do you have a hint, how to append the vectors to a vectorField?

Fabian
braennstroem is offline   Reply With Quote

Old   May 7, 2008, 04:09
Default Read your new position into a
  #7
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
Read your new position into a pointField first, then do your manipulation.

pointField newPoints(mesh.nPoints());
forAll(newPoints, pointI)
{
point& pt = newPoints[pointI];
CFile >> pt.x() >> pt.y() >>> pt.z();
}

vectorField diffv = scale*(mesh.points()-newPoints);
mattijs is offline   Reply With Quote

Old   May 8, 2008, 16:19
Default Thanks a lot! Works nice :-)
  #8
Senior Member
 
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19
braennstroem is on a distinguished road
Thanks a lot! Works nice :-)
Fabian
braennstroem is offline   Reply With Quote

Reply


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
[snappyHexMesh] .STL: non-closed manifold surface giulio.topazio OpenFOAM Meshing & Mesh Conversion 32 November 25, 2016 04:15
[snappyHexMesh] No layers in a small gap bobburnquist OpenFOAM Meshing & Mesh Conversion 6 August 26, 2015 10:38
[snappyHexMesh] determining displacement for added points CFDnewbie147 OpenFOAM Meshing & Mesh Conversion 1 October 22, 2013 10:53
[DesignModeler] DM's JScript: FPoint()'s GetPoint(i) function picks points backwards? ANT ANSYS Meshing & Geometry 2 July 23, 2012 16:25
[blockMesh] BlockMeshmergePatchPairs hjasak OpenFOAM Meshing & Mesh Conversion 11 August 15, 2008 08:36


All times are GMT -4. The time now is 16:03.