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

[blockMesh] set of xyz data in blockMesh

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By nimasam
  • 1 Post By wyldckat
  • 1 Post By wyldckat

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 1, 2013, 09:38
Post set of xyz data in blockMesh
  #1
psk
Member
 
david
Join Date: Jun 2013
Location: Montreal, Canada
Posts: 62
Rep Power: 12
psk is an unknown quantity at this point
Good Day Folks,

Basically what I did is by using camera to capture wing motion by frame by frame, the output is .csv file format. If you see inside csv file, the 1st row gives first frame(xyz of point 1,2,3), 2nd row gives 2nd frame (xyz of point 1,2,3) similarly up to last.

I did small program in Matlab program to replicate my wing. I don't how to make loop inside or any suitable way for create blockMesh.

Our OF folks suggest me few ways,
1).cylinder blockMesh from potentialFoam is suitable for importing the coordinates to make blockMesh

2.)write script file and import in blender for create blockMesh.

I am thinking by using these coordinates or script to make loop inside the blockMesh is somewhat easy to replicate the wing. Because I am new to blender & other programming language apart from matlab.

kindly see my attached image(wing), csv file & matlab program for your kind perusal. kindly help me, how I can built blockMesh?
__________________
Million Thanks,
David

"Small Dream is a Crime"

Last edited by psk; August 12, 2013 at 03:27.
psk is offline   Reply With Quote

Old   August 1, 2013, 17:39
Default
  #2
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25
nimasam is on a distinguished road
you can repeat coordinate using codeStream,look at following tutorials
Quote:
.....-2.2.0/run/tutorials/basic/potentialFoam/cylinder/
a snippet of code is:
Code:
vertices #codeStream
{
    codeInclude
    #{
        #include "pointField.H"
    #};

    code
    #{
        pointField points(19);
        points[0]  = point(0.5, 0, -0.5);
        points[1]  = point(1, 0, -0.5);
        points[2]  = point(2, 0, -0.5);
        points[3]  = point(2, 0.707107, -0.5);
        points[4]  = point(0.707107, 0.707107, -0.5);
        points[5]  = point(0.353553, 0.353553, -0.5);
        points[6]  = point(2, 2, -0.5);
        points[7]  = point(0.707107, 2, -0.5);
        points[8]  = point(0, 2, -0.5);
        points[9]  = point(0, 1, -0.5);
        points[10] = point(0, 0.5, -0.5);
        points[11] = point(-0.5, 0, -0.5);
        points[12] = point(-1, 0, -0.5);
        points[13] = point(-2, 0, -0.5);
        points[14] = point(-2, 0.707107, -0.5);
        points[15] = point(-0.707107, 0.707107, -0.5);
        points[16] = point(-0.353553, 0.353553, -0.5);
        points[17] = point(-2, 2, -0.5);
        points[18] = point(-0.707107, 2, -0.5);

        // Duplicate z points
        label sz = points.size();
        points.setSize(2*sz);
        for (label i = 0; i < sz; i++)
        {
            const point& pt = points[i];
            points[i+sz] = point(pt.x(), pt.y(), -pt.z());
        }

        os  << points;
    #};
};
Mojtaba.a likes this.
__________________
My Personal Website (http://nimasamkhaniani.ir/)
Telegram channel (https://t.me/cfd_foam)
nimasam is offline   Reply With Quote

Old   August 2, 2013, 03:52
Default
  #3
psk
Member
 
david
Join Date: Jun 2013
Location: Montreal, Canada
Posts: 62
Rep Power: 12
psk is an unknown quantity at this point
Many thanks for your reply & information Nima Sam,

1). You are correct, cylinder tutorial is good for this case. Please see the attached zip file for your kind persual. I edit blockMeshDict, I hope I have to correct something. kindly guide me.

2). I already try to run cylinder tutorial, but I am not successful on that, I run potentialFoam it shows error, take a look [ http://www.cfd-online.com/Forums/ope...tml#post441524 ]. I didn't understand how it works. Please help me
__________________
Million Thanks,
David

"Small Dream is a Crime"

Last edited by psk; August 12, 2013 at 03:27. Reason: Forgot to add Zip file
psk is offline   Reply With Quote

Old   August 7, 2013, 05:18
Default
  #4
psk
Member
 
david
Join Date: Jun 2013
Location: Montreal, Canada
Posts: 62
Rep Power: 12
psk is an unknown quantity at this point
Good Day Nima sam,

I hope you see my blockMeshDict, Kindly guide me what I have to do? give your feedback.
__________________
Million Thanks,
David

"Small Dream is a Crime"
psk is offline   Reply With Quote

Old   August 7, 2013, 10:23
Default
  #5
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25
nimasam is on a distinguished road
Dear David
i dont have time to check your blockMeshDict, but a fast look in it i feel you should write appropriate program, in fact, codeStream gives this chance to write a run-time compilable program.
Hint: check your syntax and the program you write
__________________
My Personal Website (http://nimasamkhaniani.ir/)
Telegram channel (https://t.me/cfd_foam)
nimasam is offline   Reply With Quote

Old   August 7, 2013, 14:43
Default
  #6
psk
Member
 
david
Join Date: Jun 2013
Location: Montreal, Canada
Posts: 62
Rep Power: 12
psk is an unknown quantity at this point
Many Thanks for your reply & Information NimaSam, Apolozie for disturbing you, Here I post my blockMesh & also see my attached csv file & matlab script. kindly help me, I am looking for only meshing.

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

convertToMeters 1;

vertices #codeStream
{
codeInclude
#{
#include "pointField.H"
#};

code
#{
pointField points(24); // 1 to 24

points[1] = point(11.03188, 3.534115, 6.404323); 
points[2] = point(3.190682, 4.892467, 5.764356); 
points[3] = point(9.559749, -5.47123, 2.317475); 
/// The above xyz points are corresponding to pt1(xyz), pt2(xyz), pt3(xyz) for 1st frame 


points[4] = point(10.96441, 3.571152, 6.276311); 
points[5] = point(3.116855, 4.871729, 5.870568); 
points[6] = point(9.643979, -5.58868, 3.602635); 
/// The above xyz points are corresponding to pt1(xyz), pt2(xyz), pt3(xyz) for 2nd frame 


points[7] = point(10.89945, 3.532348, 6.343315);
points[8] = point(3.389355, 4.850251, 5.801583); 
points[9] = point(8.287025, -4.58698, 11.05406); 
/// The above xyz points are corresponding to pt1(xyz), pt2(xyz), pt3(xyz) for 3rd frame


points[10] = point(10.89958, 3.532292, 6.343871); 
points[11] = point(3.389355, 4.850251, 5.801583); 
points[12] = point(8.331151, -5.00143, 10.40822); 
/// The above xyz points are corresponding to pt1(xyz) ,pt2(xyz), pt3(xyz) for 4th frame 


points[13] = point(10.8994, 3.533178, 6.338943); 
points[14] = point(3.389355, 4.850251, 5.801583); 
points[15] = point(8.349275, -5.27453 9.506363); 
/// The above xyz points are corresponding to pt1(xyz), pt2(xyz), pt3(xyz) for 5th frame 


points[16] = point(10.88493, 3.587584, 6.315026); 
points[17] = point(3.179451, 4.973716, 5.81553); 
points[18] = point(9.157894, -1.23074, -1.43747); 
/// The above xyz points are corresponding to pt1(xyz), pt2(xyz), pt3(xyz) for 6th frame 


points[19] = point(10.88638, 3.59006, 6.305255); 
points[20] = point(3.25526, 4.992905, 5.931494); 
points[21] = point(9.567679, -2.77394, -0.66752); 
/// The above xyz points are corresponding to pt1(xyz), pt2(xyz), pt3(xyz) for 7th frame 


points[22] = point(10.88564, 3.590991, 6.298537); 
points[23] = point(3.199731, 4.965945, 5.914939); 
points[24] = point(9.154611, -2.72368, 0.472577); 
/// The above xyz points are corresponding to pt1(xyz), pt2(xyz), pt3(xyz) for 8th frame 

---------------------------->upto this I import my xyz data, Kindly see my csv file for your perusal.
edges ---------------------> Here I start to draw my geometry
( 
///First Frame 
line 1 2 (-7.841198 1.358352 -0.639967) // subtract (2-1)
line 2 3 (6.369067 -0.578763 -3.446881) // subtract (3-2)


///second Frame
line 4 5 ( -7.847555 1.300577 -0.405743) // subtract (5-4)
line 5 6 (6.527124 -10.460409 -2.267933) // subtract (6-5)


///third Frame
line 7 8 (-7.510095 1.317903 -0.541732) // subtract (8-7)
line 8 9 (4.89767 -9.437231 5.252477) // subtract (9-8)


///fourth Frame 
line 10 11 (-7.510225 1.317959 -0.542288) // subtract (11-10)
line 11 12 (4.941796 -9.851681 4.606637) // subtract (12-11)


///fifth Frame 
line 13 14 (-7.510045 1.317073 -0.53736) // subtract (14-13)
line 14 15 (4.95992 -10.124781 3.70478) // subtract (15-14)


///sixth Frame 
line 16 17 (-7.705479 1.386132 -0.499496) // subtract (17-16)
line 17 18 (5.978443 -6.204456 -7.253) // subtract (18-17)


///seventh Frame
line 19 20 (-7.63112 1.402845 -0.373761) // subtract (20-19)
line 20 21(6.312419 -7.766845 -6.599014) // subtract (21-20)


///Eighth Frame 
line 22 23 (-7685909 1.374954 -0.383598) // subtract (23-22)
line 23 24 (5.95488 -7.689625 -5.442362) // subtract (24-23)

);

// Duplicate z points
label sz = points.size();
points.setSize(2*sz);
for (label i = 0; i < sz; i++)
{
const point& pt = points[i];
points[i+sz] = point(pt.x(), pt.y(), -pt.z());
}

os << points;
#};
};
__________________
Million Thanks,
David

"Small Dream is a Crime"

Last edited by wyldckat; August 18, 2013 at 08:55. Reason: Added [CODE][/CODE]
psk is offline   Reply With Quote

Old   August 8, 2013, 04:58
Default
  #7
Senior Member
 
romant's Avatar
 
Roman Thiele
Join Date: Aug 2009
Location: Eindhoven, NL
Posts: 374
Rep Power: 21
romant is on a distinguished road
Quote:
Originally Posted by psk View Post
2). I already try to run cylinder tutorial, but I am not successful on that, I run potentialFoam it shows error, take a look [ http://www.cfd-online.com/Forums/ope...tml#post441524 ]. I didn't understand how it works. Please help me
Your error indicates that you don't have the tutorials in your own folder, but you try to run the tutorial in the root directory, which is not possible, since you should not have write permissions in this folder, look at http://openfoam.org/download/ubuntu.php under getting started to copy the tutorial files into your own folder.
__________________
~roman
romant is offline   Reply With Quote

Old   August 8, 2013, 12:44
Default
  #8
psk
Member
 
david
Join Date: Jun 2013
Location: Montreal, Canada
Posts: 62
Rep Power: 12
psk is an unknown quantity at this point
Quote:
Originally Posted by romant View Post
Your error indicates that you don't have the tutorials in your own folder, but you try to run the tutorial in the root directory, which is not possible, since you should not have write permissions in this folder, look at http://openfoam.org/download/ubuntu.php under getting started to copy the tutorial files into your own folder.
GoodDay Romant,

Again it gives the same error, please post your feedback in this link [http://www.cfd-online.com/Forums/ope...ml#post441524], kindly help me
__________________
Million Thanks,
David

"Small Dream is a Crime"
psk is offline   Reply With Quote

Old   August 18, 2013, 10:32
Default
  #9
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings to all!

@David:
Quote:
Originally Posted by psk View Post
Again it gives the same error, please post your feedback in this link [http://www.cfd-online.com/Forums/ope...ml#post441524], kindly help me
I've answered to you here: http://www.cfd-online.com/Forums/ope...tml#post446405 post #23

As for the "blockMeshDict":
  1. You should study the user guide a bit more: http://www.openfoam.org/docs/user/blockMesh.php - it indicates that although "arc" needs a location value, "line" does not.
  2. This line was missing a comma:
    Code:
    points[15] = point(8.349275, -5.27453 9.506363);
    Should be:
    Code:
    points[15] = point(8.349275, -5.27453, 9.506363);
    You can diagnose these issues by commenting out most of the source code and running blockMesh for checking things. For example, to diagnose this particular section:
    Code:
    vertices #codeStream
    {
      codeInclude
      #{
        #include "pointField.H"
      #};
    
      code
      #{
        pointField points(25); // 1 to 24 + 0 dummy
    
        //points[0] = point(0.0, 0.0, 0.0);  //dummy point, because I don't feel like editing 24 indexes
    
    
    //... omitted code on purpose
    
    
    //    points[13] = point(10.8994, 3.533178, 6.338943); 
    //    points[14] = point(3.389355, 4.850251, 5.801583); 
        points[15] = point(8.349275, -5.27453 9.506363); 
        /// The above xyz points are corresponding to pt1(xyz), pt2(xyz), pt3(xyz) for 5th frame 
    
    //... omitted code on purpose
    
    
    //     // Duplicate z points
    //     label sz = points.size();
    //     points.setSize(2*sz);
    //     for (label i = 0; i < sz; i++)
    //     {
    //       const point& pt = points[i];
    //       points[i+sz] = point(pt.x(), pt.y(), -pt.z());
    //     }
    
        os << points;
    
      #};
    };
  3. As you can see in the example above, I had to add an extra dummy point in the position "0". This is because:
    • MATLAB uses vectors that start on the index 1.
    • But C++ uses vectors that on the index 0.
    Therefore, defining 24 points means that you should define the indexes 0 to 23, not 1 to 24. Unless of course, you use the trick above, which is to leave a dummy point that will not be used and indicate that there are 25 points.
  4. Attached is a partially fixed "blockMeshDict" file. blockMesh will run with it, but it will not generate a mesh, because there are no blocks defined. The reason is because the "edges" list are only for specifying special edges, such as arcs, splines and so on; but "line" is the default setting, so it's not necessary to define it, since it's implicit.
    For defining the actual mesh, you have to define the respective mesh blocks in the "blocks" list.
In addition to everything that has been explained to you until now, I suggest that you study the following:


And I know I've said this before to you: start working with a simple geometry! Then gradually increase the level of complexity. Otherwise it will be very complicated to help you, as has happened in this case. Since there are 24 points, I'm not going to spend time figuring out what point is where! Specially since you took down the CSV attachement



Last but not least, to other forum readers, the following thread is also related to this same topic, which David created some time ago as well, but he is trying to address the same issue in another form: www.cfd-online.com/Forums/openfoam-meshing-blockmesh/121421-making-loop-inside-blockmesh-help-plz.html

Best regards,
Bruno
Attached Files
File Type: zip blockMeshDict.zip (1.7 KB, 30 views)
psk likes this.
__________________
wyldckat is offline   Reply With Quote

Old   August 19, 2013, 04:54
Default
  #10
psk
Member
 
david
Join Date: Jun 2013
Location: Montreal, Canada
Posts: 62
Rep Power: 12
psk is an unknown quantity at this point
Good Day Bruno,

I hope you fine, Many Thanks for coming.

last couple of weeks, I try two way for Making blockMeshDict,

a) Convert matlab script to python script (I am new to python that's why I convert using this link : [ http://ompclib.appspot.com/m2py ] I hope there is some mistake in converted python script)then import in blender to make blockMeshDict-------> suggested by elvis

b) Another one is your suggestion, I edit blockMeshDict with including external domain. Kindly see the attached file for your kind perusal and also please give your suggestion about converted python script ( I am newbie)
__________________
Million Thanks,
David

"Small Dream is a Crime"

Last edited by psk; September 5, 2013 at 12:57.
psk is offline   Reply With Quote

Old   August 20, 2013, 03:07
Default
  #11
psk
Member
 
david
Join Date: Jun 2013
Location: Montreal, Canada
Posts: 62
Rep Power: 12
psk is an unknown quantity at this point
Good Day Bruno,

Kindly see my above post and guide me.
__________________
Million Thanks,
David

"Small Dream is a Crime"
psk is offline   Reply With Quote

Old   August 25, 2013, 10:14
Default
  #12
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi David,

I finally managed to look into this. OK, my suggestions from this point onwards are:
  1. At least for now, forget Python.
    • If you do not want to forget it, what happens is that you converted the whole script, which is a bit pointless, since you don't need to plot all of the frames.
    • The best you can do is to create a simple import script in Python that loads a single set of points from the CSV file.
  2. As the first step in generating the mesh, you should forget the CSV. And you should also forget the way that has been discussed on this thread, namely to use C++ code inside the "blockMeshDict" file. This is too much confusion to start with.
  3. Now, with or without the help of SwiftBlock ( http://openfoamwiki.net/index.php/Contrib/SwiftBlock ), you should first manually create a dummy mesh that will act as the place-holder reference "blockMeshDict" dictionary for your mesh generation system. The idea is that you create the working mesh zone, including both the blocks outside of the wing zone, as well as around the wing zone.
    • Attached is an image depicting one such example. The idea in the attached image "ExampleBaseMesh.jpg" is that at least 6 blocks are needed: 3 blocks below the wing and 3 above the wing.
  4. Once you have this dummy mesh up and running, you can easily modify the mesh by relying on file inclusion and variables in "blockMeshDict". Attached is also the zip "exampleBlockMesh.zip" file that provides an example case with following example files, based on the tutorial "incompressible/porousSimpleFoam/angledDuctImplicit" (it does not represent the mesh on the attached image!):
    • The file "constant/polyMesh/blockMeshDict.orig" is the original "blockMeshDict" file, which was generated on the tutorial case using m4. It's this original file that I modified to achieve the next ones.
    • The file "constant/polyMesh/blockMeshDict" is the modified dictionary file, which is designed to act as a template that does not need further modifications. It relies on including the file "constant/polyMesh/blockMeshDict.positions", which is the file that can easily be generated using MATLAB.
    • The file "constant/polyMesh/blockMeshDict.positions" has got only the positions that matter, which in your case will be the wing points.
    As you can see, in the positions file is a list of variables that define the positions of the points you can easily change. In the main dictionary file is included the other file and uses the variables by invoking them with the symbol "$".
    In addition, this example case uses 3 blocks: two blocks for normal flow zones and one for porous zones. The idea to get from this is how the blocks are connects, since you'll be needing 6 blocks, not just 3. The "porosity" is a term that can be ignored.
Now, the suggestion is that you play with these ideas and make a working example, without relying on the CSV file. Because once you understand better these meshing concepts and how blockMesh works, it'll be easier for you to start understanding how you can use the data from the CSV file and what you need to generate with MATLAB.

Best regards,
Bruno
Attached Images
File Type: jpg ExampleBaseMesh.jpg (26.4 KB, 63 views)
Attached Files
File Type: zip exampleBlockMesh.zip (9.6 KB, 33 views)
psk likes this.
__________________
wyldckat is offline   Reply With Quote

Old   August 27, 2013, 09:37
Default
  #13
psk
Member
 
david
Join Date: Jun 2013
Location: Montreal, Canada
Posts: 62
Rep Power: 12
psk is an unknown quantity at this point
Many thanks bruno, apologize for late reply,First of all I have to go through thoroughly block Mesh concept and then I will let you. I hope it works for this case.

Have a nice day
__________________
Million Thanks,
David

"Small Dream is a Crime"
psk 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
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem Attesz OpenFOAM Meshing & Mesh Conversion 12 May 2, 2013 11:52
OF 1.6 | Ubuntu 9.10 (64bit) | GLIBCXX_3.4.11 not found piprus OpenFOAM Installation 22 February 25, 2010 14:43
XYZ (ASCII format) data points into GAMBIT Neil FLUENT 1 August 7, 2007 10:24
Env variable not set gruber2 OpenFOAM Installation 5 December 30, 2005 05:27
How to set environment variables kanishka OpenFOAM Installation 1 September 4, 2005 11:15


All times are GMT -4. The time now is 00:47.