Cassiopee Forum
CFD python modules
S'il vous plaît connectez vous ou Enregistrement'.
Date et heure en ce moment : lundi, 23 octobre 2017, 09:56

Nouvelle discussion | Répondre
Cassiopee Forum :: Discussions, suggestions, bug report :: Generator :: Definition of a background mesh before octree refinement?  ::
Gianluca
Newbie
Image


Messages: 4
Definition of a background mesh before octree refinement? (mardi, 24 novembre 2015, 20:19) citation  
Is it possible to define a background mesh before refining with the octree method? Let's say I want to define a mesh with a dx=dy=dz=1.0 cm before refining with the octree.



Ip enregistré Statut: déconnecté Profil | Site Web 
Ordre des réponses: Première réponse en dernier :: Première réponse en premier
Gianluca
Newbie
Image


Messages: 4
RE: Definition of a background mesh before octree refinement? (vendredi, 27 novembre 2015, 04:47) citation  
Stephanie,

thank you very much for all your help; your examples are very clear and gave me an excellent starting point.

Best regards,

Gianluca


Ip enregistré Statut: déconnecté Profil | Site Web 
StephaniePeron
Full Member
Image


Messages: 158
RE: Definition of a background mesh before octree refinement? (jeudi, 26 novembre 2015, 10:14) citation  
Hi Gianluca,

You will find an example just below. In that case, I compute the distance field to the circle, and then mark elements for refinement (centers:indicator=1) if the distance to the circle is less than 0.1
You can find another example here, that refines inside the whole circle: http://elsa.onera.fr/Cassiopee/Tutorials/Tutorials.html (see 'Generator:octree refinement inside a surface'). For your purpose, the octree mesh generated by G.octree function can be replaced by your uniform HEX mesh. Note that the adaptation is achieved within a loop such that the required spacing is obtained at the end.

import Converter.PyTree as C
import Generator.PyTree as G
import Geom.PyTree as D
import Dist2Walls.PyTree as DTW

N = 101
dh = 10./(N-1)
a = G.cartHexa((0,0,0),(dh,dh,1),(N,N,1))
C.convertPyTree2File(a,'octree0.cgns')
#
r = 1.
x0 = C.getMeanValue(a,'CoordinateX')
y0 = C.getMeanValue(a,'CoordinateY')
z0 = C.getMeanValue(a,'CoordinateZ')
s = D.circle((x0,y0,z0),r, N=50)

# set the indicator to 1 (tag for refinement) if the center of the HEX element
# is inside a ring 0.9<R<1.1, centered on (x0,y0,z0)
a = DTW.distance2Walls(a,s,loc='centers',type='ortho')
a = C.initVars(a,'centers:indicator=({centers:TurbulentDistance}<0.1)')
a = G.adaptOctree(a)
C.convertPyTree2File([a],'octree1.cgns')


I hope all of these information will be useful for you. Do not hesitate to ask additional questions,
Cheers,
Stéphanie


Ip enregistré Statut: déconnecté Profil | Site Web 
Gianluca
Newbie
Image


Messages: 4
RE: Definition of a background mesh before octree refinement? (mercredi, 25 novembre 2015, 17:24) citation  
Stephanie,

thank you for your response; it's getting close to what I am trying to achieve. I am still missing a piece. So let's say I have a unit circle that I want to mesh initially with carthex with a uniform mesh of 1 cm. Once this initial mesh structure is generated, I want to apply the octree refinement on the circle. Do you think that this is possible?

I like the way you use that indicator (X-coords), cause I can use it to refine wherever I want.

Thank you in advance and cheers!

Gianluca

Ip enregistré Statut: déconnecté Profil | Site Web 
StephaniePeron
Full Member
Image


Messages: 158
RE: Definition of a background mesh before octree refinement? (mercredi, 25 novembre 2015, 09:09) citation  
Hello Gianluca,

Please let me know if I have misunderstood what you want to do: first, you want to generate a uniform mesh that is adapted then. It is possible by using G.cartHexa function, and then G.adaptOctree, as follows (the mesh is refined here if x>5).

import Converter.PyTree as C
import Generator.PyTree as G

[i]
a = G.cartHexa((0,0,0),(1,1,1),(11,11,1))
C.convertPyTree2File(a,'octree0.cgns')
a = C.initVars(a, 'centers:indicator={centers:CoordinateX}>5.')
a = G.adaptOctree(a)
C.convertPyTree2File(a,'octree1.cgns')
[\i]

Best regards
Stephanie

Ip enregistré Statut: déconnecté Profil | Site Web 
Nouvelle discussion | Répondre

Software PBLang 4.65 © 2002-2003 by Martin Senftleben
Image