#codeStream loop inside a blockMeshDict
1 Attachment(s)
Hi all,
I would like to use #codeStream to define the points of splines in a blockMeshDict. Here is the code snippet I use: Code:
spline 0 1 ( #codeStream I've got this error message: Code:
--> FOAM FATAL IO ERROR: Any idea ? Thanks a lot for your help Happy foaming :) François |
Just remove the red semicolon ;)
Quote:
|
1 Attachment(s)
Thank you very much hk318i ! :)
Note for myself: always read twice before posting, especially if it's in front of my nose :D Here is a working example if someone wants to try this #codeStream feature: Code:
/*--------------------------------*- C++ -*----------------------------------*\ |
Don't worry, it happens with every foamer :)
I have only one comment about your code, which could be useful for someone else in the future. Instead of repeating the code for each edge, you can use the codeStream directly inside edges. Code:
edges (#codeStream { Code:
#codeStream myfun.H Code:
Hopefully these tips will be useful for someone coming directly from google search. Best wishes, Hassan Quote:
|
Thanks Hassan for your kind and very relevant suggestions. :)
I was thinking myself of refactoring the code which was submitted here only as proof of concept for myself or other newcomers to #codeStream. Anyway, those are indeed very nice additions to put into the code, thanks ! I may put all this stuff on the wiki when I'll find the time. You're a good example that illustrates why I like so much the OpenFOAM community. Happy foaming :) |
Hello!
I hit one of the codeStream limitations today. I would like to share it with everyone here. Code:
string " Code:
code So to read any variable from the blockMeshDict in this case, you have to lookup it. Code:
scalar a = readScalar(dict.lookup("a")); |
On using codestream... I understand the syntax to duplicate points but I want to then see the points so I can construct the blocks... Maybe this is a stupid question but I'm very very new to CFD and meshing so I don't understand how, once I've duplicated the points, I "know" where each one is and how the block structure should be using the new points... can anyone advise on the best practice for this?
|
Quote:
Code:
paraFoam -block I am not sure if that what you are looking for or not. Maybe you mean if you have list called points and you want use points[5] in blocks. In this case, based on my experience, you cannot do that directly because the variables are limited to codeStream scope. BUT there is a way around this problem which is including the blocks section inside the same codeStream as points. Then use os stream to print blocks as well. Or you can write a script (using python or octave or m4 .) to create blockMesh file. |
Hi there,
Thanks for that. Actually I wasn't sure if that would work without running blockMesh first... Ok just tried and how is it possible to do this without first building the blocks? Or do I just put: Code:
blocks |
It works without executing blockMesh, just make sure that boundary is empty as well. It will show you the points and edges
|
perfect! Thanks for that... very difficult to find something so simple online!
|
Sorry, last question.. say I'm trying to duplicate both the z points (as done in the cylinder tutorial) and the y points. I tried to just include a second loop as follows:
Code:
label sy = points.size(); |
What is pt? This expression looks wrong.
|
I took that directly from the cylinder tutorial (uses potentialFoam) but I believe pt the name of the pointer that points to the location of that point?
|
Sorry, I did see the first expression in the loop. The code should work without errors.
|
The code works without errors when I have the second loop to duplicate the y-values but it doesn't actually duplicate the y-values. It does duplicate the z-values successfully but I'm not sure why it isnt' fully working to duplicate everything. Any thoughts?
|
Try to print the points to see the values.
Code:
Info << points << endl; |
Why negative volumes?
2 Attachment(s)
Hi all,
taking inspiration from this thread, I tried to generate my geometry with #codestream directive inside blockMeshDict (the method is really smart indeed and overcomes the difficulty of "manual meshing - the trappist way :rolleyes: " with plain text blockMeshDict, so thanks Francois and Hassan for sharing this conversation!). The mesh I obtain is apparently correct but if I run checkMesh against it, the situation is much different: Code:
/*---------------------------------------------------------------------------*\ I checked several time the definition of each block for the vertexes sequence without finding any error. I attached here the blockMeshDict for your reference. So: what I am doing wrong? Thank You Gianluca |
Quick answer: Negative volume is usually related to the vertices being order in the wrong direction.
|
1 Attachment(s)
I totally agree with Bruno, most probably one there is a block is not following the right had rule.
I tried to run your code using OpenFOAM2.3.x and I got few errors. I don't know if you are facing the same errors or not. I had to modify minor things to run it. I tested it also on OpenFOAM-dev hoping that the new updates will overcome your problem but unfortunately not. The new updates are related to boundary definition only. I attached the modified file here in case you needed it. I just modified the x and y type to scalarField. Also changed the int to label (which is exactly the same (just a habit)). Best Wishes Hassan |
Okay, Bruno you were right: I was living in the illusion that the blocks topology could take advantage from the edges curvature (spline in my case) so I tried to define with just one block the helical sweep of each block face whose normal is in tangential direction (local x axis). Instead topology is built, as far as I understand, by only connecting the edges in the block's vertexes list with straight lines.
So I solved the negative volume error by defining 27 blocks instead of 9, sweeping on the helical path by only 120° and not 360° (sigh). Hassan, I did not get any error from the #codestream routines during blockmeshing. What errors did it show to you? Thank you both for your help Cheers Gianluca |
1 Attachment(s)
Hello Gianluc,
I am investigating the reasons of this error (log attached). It is strange error but it seems to be related to OpenFOAM version. I am not sure yet. I tried your code using two versions of OpenFOAM-2.3.x. The newer version (18th Jun 2015) is not working, however the older version (26th Feb) is fine. I will update both and recompile both to pinpoint the problem. Another possibility, maybe, it is related to gcc version. I will check that as well. Best wishes, Hassan |
I updated OpenFOAM-2.3.x, to check if this error due to any new commits. It seems not, because your blockMesh worked even with the updated OpenFOAM-2.3.x. Therefore I tried a third updated version of OpenFOAM-2.3.x on different system and I get the same error.
Now, I think (maybe), it is something related to GCC version because it worked with GCC-4.9.2 (Ubuntu 15.04) but it did not work with GCC-4.8.4 (Ubuntu 14.04LTS) nor GCC-4.7.3 (CentOS 6.5). Could you please check your GCC version? Bw, Hassan |
Hi Hassan,
here is the output of "gcc -v": gcc version 4.9.2 (Debian 4.9.2-10). The error you are getting seems to be strange to me because in my humble experience, normally the use of uninitialized array leads to a gcc warning, unless gcc is instructed to treat warnings as errors. Regards Gianluca |
Similar issues with #codeStream in openfoam8
I realize this is an old thread but thought I would try and revive it to ask a related question. I am using openfoam8 and #codeStream in blockMeshDict. The vertices are computing okay, but there are issues with the edges. It seems that the quoted response provided by hk318i to output the edge dictionary does not work anymore in openfoam8. Here is the loop in my code where i output each line:
Code:
//std::string v1, v2; Code:
--> FOAM FATAL IO ERROR: Thanks! Luca Quote:
|
It would helpful if you added in a full listing of the blockMeshDict that the code tried to create. From the error message, it looks like you have the wrong syntax for the arc command - check out section 5.3.1.2 in https://cfd.direct/openfoam/user-guide/v6-blockmesh/ and compare against what you have in your file.
Good luck! |
1 Attachment(s)
Here is the full blockMeshDict file, as well as a geometryInput file from the constant directory which is required for it to run. I am trying to recreate a previously generated blockMeshDict file with codeStream, so it can eventually be expanded. There is a commented out edges() dictionary in the file as well with hardcoded values, the blockMeshDict file fine runs with this edges dictionary. The boundaries are eliminated for use with paraFoam -block. Thanks for taking the time to look at this!
|
Could you also just include the Info output? I.e. from this, we can see the parsing of the previous lines and the line that it crashes on ... would be quicker than debugging your code.
|
One quick thing to consider - your codestream creates lists of vertices and then edges ... these need to be bracketed, and I don't see those brackets in your code. e.g.
Code:
vertices Code:
vertices (#codeStream |
Yes that makes sense, I apologize for the missing info. Here is the last line of my output including Info output for edges in the blockMeshDict I sent:
Code:
arc01(0.041 0 0) |
Quote:
Code:
vertices #codeStream Code:
38 |
Solved!
Yes thank you! With the brackets added, and also outputting the vertices as integers with spaces in between, everything works. Here is the final edges call with codeStream output for each point:
Code:
edges (#codeStream |
All times are GMT -4. The time now is 23:59. |