terça-feira, 30 de abril de 2013

Minor Setback - Creating a Circular Annular Structured Grid With Salomé

I had a minor set back.

To write a report I usually solve the problem first and repeat the "solving" while making the report. Unfortunately, I had everything done (grid, chosen Openfoam solver, parameters, etc) but the problem was not getting stable. Courant numbers were reaching high values on the third iteration.

When you face something like that you have to attack the problem in two ways: Dt and Ds. In other words, pacing time and the grid. For this case, the problem was related to time. But when you reduce the pace so much, you'll have to wait a lot to see your results. I don't have a shitty computer and of course is not an academic cluster. It has 4 cores and I can divide into 8 threads, but even so, depending on the problem, can take from 3 minutes to 18 hours to solve it.

My Openfoam solver is not calibrated yet and it is quite boring to tweak every little detail.

I like Salomé ... a lot ... and to test the solver you must have some few grids to perform some sensitive test while simulating, because of this I decided to make a structured grid with this annular.

It is really not that complicated when you discover the way but it has some "magic" behind it.

Lets begin!!

Follow the base geometry script, I changed a little the previous one, but it has the same core:

######


import sys
import salome
import geompy
import math

salome.salome_init()
theStudy = salome.myStudy

import salome_notebook
notebook = salome_notebook.notebook

gg = salome.ImportComponentGUI("GEOM")

O = geompy.MakeVertex(0, 0, 0)
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)

# BHA components parameters
Wellbore = 8.5 # in
OD_Component = 6.5 # in
Length_Component =2 # m


# Converting imperial units to SI
Wellbore = Wellbore*0.0254
OD_Component = OD_Component*0.0254


# Base vector for rotation and extrusion
Origin = geompy.MakeVertex (0,0,0)
EndVector = geompy.MakeVertex (0,0,1)
Vector = geompy.MakeVector(Origin ,EndVector)


# Base line for wellbore annular
pOD = geompy.MakeVertex(OD_Component,0,0)
pWell = geompy.MakeVertex(Wellbore,0,0)
vAnnular = geompy.MakeVector(pOD,pWell)


# Base annular disc
wAnnular = geompy.MakeWire([vAnnular])
Extrusion_1 = geompy.MakePrismVecH(wAnnular, OZ, 1)
[Edge_1,Seed,Edge_3,Edge_4] = geompy.ExtractShapes(Extrusion_1, geompy.ShapeType["EDGE"], True)
Annular_Simple= geompy.MakeRevolution(Extrusion_1, OZ, 360*math.pi/180.0)
Annular = geompy.MakeCompound([Annular_Simple, Extrusion_1])
[Inlet,Inner_Wall,Outer_Wall,Outlet,Face_Seed] = geompy.ExtractShapes(Annular, geompy.ShapeType["FACE"], True)
[Edge_2,Edge_Seed_Base,Edge_Seed_Top,Edge_7] = geompy.ExtractShapes(Face_Seed, geompy.ShapeType["EDGE"], True)

geompy.addToStudy( Annular, 'Annular' )
geompy.addToStudy( Extrusion_1, 'Extrusion_1' )
geompy.addToStudyInFather( Extrusion_1, Edge_1, 'Edge_1' )
geompy.addToStudyInFather( Extrusion_1, Seed, 'Seed' )
geompy.addToStudyInFather( Extrusion_1, Edge_3, 'Edge_3' )
geompy.addToStudyInFather( Extrusion_1, Edge_4, 'Edge_4' )
geompy.addToStudyInFather( Annular, Inlet, 'Inlet' )
geompy.addToStudyInFather( Annular, Inner_Wall, 'Inner_Wall' )
geompy.addToStudyInFather( Annular, Outer_Wall, 'Outer_Wall' )
geompy.addToStudyInFather( Annular, Outlet, 'Outlet' )
geompy.addToStudyInFather( Annular, Face_Seed, 'Face_Seed' )
geompy.addToStudyInFather( Annular, Edge_Seed_Base, 'Edge_Seed_Base' )
geompy.addToStudyInFather( Annular, Edge_Seed_Top, 'Edge_Seed_Top' )

######

With the created geometry we can have our structured grid.

Activate the Salomé's Mesh Module.

Go to Mesh >> Create Mesh. Pay attention on this one. You'll choose <None> on everything in here. <None>!!!

Go to Mesh >> Create Sub-Mesh. The chosen geometry is a face. I call it Face_Seed because this guy helped us making the solid and we are going to use it to produce the grid as well. The algorithm is Quadrangle (Mapping) because is going to divide this face into structured small pieces. Regarding the Hypothesis ... just standard.
In the same box, choose "1D" and choose "Wire Discretisation". We will divide the z-axial length into equal pieces.
Click on Hypothesis and follow these parameters (or choose another one if you prefer). Apply. (Don't Apply and Close ... just Apply).

Select "Edge_Seed_Base" and choose "Wire Discretisation". Instead of 200 divisions I will choose 20 for this one on the Hypothesis. Apply.
Repeat the same procedure to "Edge_Seed_Top" but press Apply and Close.

Right Click over the Mesh_1 and Compute the mesh.

You can see you have some few warnings on your left just below the Mesh_1. Don't worry. Now, go to Modification >> Revolution. The angle 360 is because we will rotate 360 degrees and "Number of Steps" is 36 because it is going to divide 360 by 36 ... So we will divide the circle into 36 pieces and every piece corresponds to 10 degrees.
You should have something like this.


We have the structured grid already, but we can't export like this. We must define the boundaries and that is when comes the tricky part.

Go to Mesh >> Create Group.

Repeat the same procedure to "Outlet" and Apply. Remember, when setting the filter Threshold Value (third column) choose "Outlet" on the geometry.

Now we can proceed to "Inner_Wall". Apply.
Proceed the same way with "Outer_Wall". The same thing here ... when setting the filter Threshold Value choose "Outer_Wall" on the geometry. Apply and Close.

Now we have the mesh and the boundaries. Everything Ok to export to UNV format and then Openfoam?! NO!!!

If you export like this you won't be able to run your simulations. Unfortunately when you set the groups while using the filter you picked some nodes that belonged to another geometry. For example, when you created the Inlet you are picking up nodes that belong to Inner_Wall and Outer_Wall. We must erase the excess.

Go to Modification >> Transformation >> Merge Nodes.


Now we are done. We can export this grid!


Nenhum comentário:

Postar um comentário