#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 |
All times are GMT -4. The time now is 06:52. |