Version

Date

Description

0

2018-12-18

axisymmetric model Geometry and mesh in Salome - CFd in openFoam

In this documentation you can obtain basis for: - Axisymmetric Meshing. - Turbulence and multiphase fluid modeling.

PY-A873 Skimming Hocol Toldado

Create Geometry

# -*- coding: utf-8 -*-

###
### This file is generated automatically by SALOME v7.8.0 with dump python functionality
###

import sys
import salome

#Parámetros
#Radio Skimming
RSk=4.57
#Altura Mayor skimming
HSk=6.746
#Radio tubo  central distribuidor
RDist=0.305
#Altura tubo distribuidor central
HDist=2.1
#Radio hasta inicio caja de agua
RIcajaH2O=2.832
#Longitud caja de agua
LcajaH2O=1
#altura caja de agua
HcajaH2O=0.8
#Longitud caja aceite
LcajaOil=0.457
# Altura caja de aceite
HcajaOil=0.444
#Altura diente sierra
Hds=0.026
#Diámetro boquilla
DBoq=0.00231911516659705
#Radio ubicación centro Boquilla 1
Rbq1=0.381
# Distancia entre Boquillas
Pitch=0.406
#Altura boquillas
Hboq=1.8
#Diámetro tubo H2O
DH2O=0.2032
#Profundidad salida de agua
HH2O= -0.532
# Radio localización salida agua
RLH2O=3.23

salome.salome_init()
theStudy = salome.myStudy

import salome_notebook
notebook = salome_notebook.NoteBook(theStudy)
sys.path.insert( 0, r'/home/hernando')


###
### GEOM component
###

import GEOM
from salome.geom import geomBuilder
import math
import SALOMEDS


geompy = geomBuilder.New(theStudy)

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

# Cuerpo del Tanque
geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
sk = geompy.Sketcher2D()
sk.addPoint(RDist, 0.0000000)
sk.addSegmentRelative(RIcajaH2O-RDist, 0.0000000)
sk.addSegmentRelative(0,-HcajaH2O)
sk.addSegmentRelative(LcajaH2O,0)
sk.addSegmentRelative(0, HcajaH2O)
sk.addSegmentRelative(RSk-RIcajaH2O-LcajaH2O,0)
sk.addSegmentRelative(0, HSk-HcajaOil)
sk.addSegmentRelative(-LcajaOil,0)
sk.addSegmentRelative(0, HcajaOil-Hds)
sk.addSegmentRelative(Hds/2,0)
sk.addSegmentRelative(0, Hds)
sk.addSegmentRelative(-(RSk+Hds/2-LcajaOil),0)
sk.addSegmentRelative(0, -(HSk-HDist))
sk.addSegmentRelative(RDist,0)
sk.addSegmentRelative(0, -HDist)
sk.close()
Sketch_1_1 = sk.wire(geomObj_1)
geompy.addToStudy( Sketch_1_1, 'Sketch_1_1' )
#Sketch_1 = geompy.MakeFillet1D(Sketch_1_1,HSk/5000,[])


# Primer elemento del difusor 1


geomObj_5 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
LocalCS_1 = geompy.MakeMarker(Rbq1-DBoq/2, Hboq, 0, 1, 0, 0, 0, 1, 0)

sk = geompy.Sketcher2D()
sk.addPoint(0.0000000, 0)
sk.addSegmentRelative(DBoq, 0.0000000)
sk.addSegmentRelative(0.0000000,DBoq)
sk.addSegmentRelative(-DBoq, 0.0000000)
sk.addSegmentRelative(0.0000000, -DBoq)
sk.close()
Sketch_4 = sk.wire(LocalCS_1)

# Salida de agua

geomObj_2 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
LocalCS_2 = geompy.MakeMarker(RLH2O,HH2O, 0, 1, 0, 0, 0, 1, 0)

sk = geompy.Sketcher2D()
sk.addPoint(0, 0)
sk.addSegmentRelative(DH2O, 0.0000000)
sk.addSegmentRelative(0.0000000,4*DH2O)
sk.addSegmentRelative(-DH2O, 0.0000000)
sk.addSegmentRelative(0.0000000, -4*DH2O)
sk.close()
Sketch_2 = sk.wire(LocalCS_2)


# AddtoStudy General 1

geompy.addToStudy( O, 'O' )
geompy.addToStudy( OX, 'OX' )
geompy.addToStudy( OY, 'OY' )
geompy.addToStudy( OZ, 'OZ' )

geompy.addToStudy( Sketch_1_1, 'Cuerpo' )
geompy.addToStudy( Sketch_2, 'SalH2O' )


# Boquilla 1
geompy.addToStudy( LocalCS_1, 'LocalCS_1' )
geompy.addToStudy( LocalCS_2, 'LocalCS_2' )
geompy.addToStudy( Sketch_4, 'Sketch_4' )

geomObj_6 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
Difusor1=geompy.MakeFuseList([Sketch_4],True,True)
geompy.addToStudy( Difusor1, 'Difusor1' )




# Entradas
Fuse_3=Sketch_4
for x in range(0,10):
    Translation_1 = geompy.MakeTranslation(Sketch_4, x*Pitch, 0, 0)
    Fuse_1 = geompy.MakeFuseList([Translation_1, Fuse_3], True, True)
    geompy.addToStudyInFather(Difusor1, Translation_1, 'Translation1_'+str(x))
        geompy.addToStudy( Fuse_1, 'Fuse_1' )
    Fuse_3=Fuse_1
    geompy.addToStudy( Fuse_3, 'Fuse_3' )

Fuse_2 = geompy.MakeFuseList([Sketch_1_1,Sketch_2,Fuse_1], True, True)
geompy.addToStudy( O, 'O' )
geompy.addToStudy( OX, 'OX' )
geompy.addToStudy( OY, 'OY' )
geompy.addToStudy( OZ, 'OZ' )
geompy.addToStudy( Sketch_1_1, 'Sketch_1_1' )
geompy.addToStudy( LocalCS_1, 'LocalCS_1' )
geompy.addToStudy( Sketch_4, 'Sketch_4' )
geompy.addToStudy( LocalCS_2, 'LocalCS_2' )
geompy.addToStudy( Difusor1, 'Difusor1' )

geompy.addToStudy( Fuse_2, 'Fuse_2' )
Face_1 = geompy.MakeFaceWires([Fuse_2], 1)
geompy.addToStudy( Face_1, 'Face_1' )

#Crea grupos desde la geometría
Techo = geompy.CreateGroup(Face_1, geompy.ShapeType["EDGE"])
geompy.UnionIDs(Techo, [24])
movingWall = geompy.CreateGroup(Face_1, geompy.ShapeType["EDGE"])
geompy.UnionIDs(movingWall, [26])
Fondo = geompy.CreateGroup(Face_1, geompy.ShapeType["EDGE"])
geompy.UnionIDs(Fondo, [3, 8, 12, 28])
Pared = geompy.CreateGroup(Face_1, geompy.ShapeType["EDGE"])
geompy.UnionIDs(Pared, [18, 14, 30, 10, 6, 20])
outOil = geompy.CreateGroup(Face_1, geompy.ShapeType["EDGE"])
geompy.UnionIDs(outOil, [22])
outH2O = geompy.CreateGroup(Face_1, geompy.ShapeType["EDGE"])
geompy.UnionIDs(outH2O, [32])
geompy.DifferenceIDs(Pared, [18, 14, 30, 10, 6, 20])
geompy.UnionIDs(Pared, [18, 14, 30, 10, 6, 20, 35, 37, 39])
geompy.DifferenceIDs(Pared, [18, 14, 30, 10, 6, 20, 35, 37, 39])
geompy.UnionIDs(Pared, [18, 14, 30, 10, 6, 20, 35, 37, 39])
geompy.DifferenceIDs(Techo, [24])
geompy.UnionIDs(Techo, [24, 16])
geompy.DifferenceIDs(Pared, [18, 14, 30, 10, 6, 20, 35, 37, 39])
geompy.UnionIDs(Pared, [18, 14, 30, 10, 6, 20, 35, 37, 39, 86, 122, 77, 50, 59, 113, 68, 41, 104, 95])
geompy.DifferenceIDs(Pared, [18, 14, 30, 10, 6, 20, 35, 37, 39, 86, 122, 77, 50, 59, 113, 68, 41, 104, 95])
geompy.UnionIDs(Pared, [18, 14, 30, 10, 6, 20, 35, 37, 39, 86, 122, 77, 50, 59, 113, 68, 41, 104, 95, 129, 125, 120, 116, 111, 107, 102, 98, 93, 89, 84, 80, 75, 71, 66, 62, 57, 53, 48, 44])
E1 = geompy.CreateGroup(Face_1, geompy.ShapeType["EDGE"])
geompy.UnionIDs(E1, [127])
E2 = geompy.CreateGroup(Face_1, geompy.ShapeType["EDGE"])
geompy.UnionIDs(E2, [118])
E3 = geompy.CreateGroup(Face_1, geompy.ShapeType["EDGE"])
geompy.UnionIDs(E3, [109])
E4 = geompy.CreateGroup(Face_1, geompy.ShapeType["EDGE"])
geompy.UnionIDs(E4, [100])
E5 = geompy.CreateGroup(Face_1, geompy.ShapeType["EDGE"])
geompy.UnionIDs(E5, [91])
E6 = geompy.CreateGroup(Face_1, geompy.ShapeType["EDGE"])
geompy.UnionIDs(E6, [82])
E7 = geompy.CreateGroup(Face_1, geompy.ShapeType["EDGE"])
geompy.UnionIDs(E7, [73])
E8 = geompy.CreateGroup(Face_1, geompy.ShapeType["EDGE"])
geompy.UnionIDs(E8, [64])
E9 = geompy.CreateGroup(Face_1, geompy.ShapeType["EDGE"])
geompy.UnionIDs(E9, [55])
E10 = geompy.CreateGroup(Face_1, geompy.ShapeType["EDGE"])
geompy.UnionIDs(E10, [46])

geompy.addToStudyInFather( Face_1, Techo, 'Techo' )
geompy.addToStudyInFather( Face_1, movingWall, 'movingWall' )
geompy.addToStudyInFather( Face_1, Fondo, 'Fondo' )
geompy.addToStudyInFather( Face_1, Pared, 'Pared' )
geompy.addToStudyInFather( Face_1, outOil, 'outOil' )
geompy.addToStudyInFather( Face_1, outH2O, 'outH2O' )
geompy.addToStudyInFather( Face_1, E1, 'E1' )
geompy.addToStudyInFather( Face_1, E2, 'E2' )
geompy.addToStudyInFather( Face_1, E3, 'E3' )
geompy.addToStudyInFather( Face_1, E4, 'E4' )
geompy.addToStudyInFather( Face_1, E5, 'E5' )
geompy.addToStudyInFather( Face_1, E6, 'E6' )
geompy.addToStudyInFather( Face_1, E10, 'E10' )
geompy.addToStudyInFather( Face_1, E9, 'E9' )
geompy.addToStudyInFather( Face_1, E8, 'E8' )
geompy.addToStudyInFather( Face_1, E7, 'E7' )

This model was done for an axysimmetric model but it was an openFoam Tool that converted a volumme of one (1) element depth into a wedge. It is not available now. Then for axisymmetric wedge convert this code using as a gude the PY-A910 project.

   ###
   ### SMESH component
   ###

   import  SMESH, SALOMEDS
   from salome.smesh import smeshBuilder

   smesh = smeshBuilder.New(theStudy)
   Mesh_1 = smesh.Mesh(Face_1)
   NETGEN_2D = Mesh_1.Triangle(algo=smeshBuilder.NETGEN_1D2D)
   NETGEN_2D_Parameters = NETGEN_2D.Parameters()
   NETGEN_2D_Parameters.SetMaxSize( 0.05 )
   NETGEN_2D_Parameters.SetSecondOrder( 0 )
   NETGEN_2D_Parameters.SetOptimize( 1 )
   NETGEN_2D_Parameters.SetFineness( 3 )
   NETGEN_2D_Parameters.SetMinSize( 0.0005 )
   NETGEN_2D_Parameters.SetUseSurfaceCurvature( 1 )
   NETGEN_2D_Parameters.SetFuseEdges( 1 )
   NETGEN_2D_Parameters.SetQuadAllowed( 0 )
   Viscous_Layers_2D_1 = NETGEN_2D.ViscousLayers2D(0.05,5,3)
   isDone = Mesh_1.Compute()
   Techo_1 = Mesh_1.GroupOnGeom(Techo,'Techo',SMESH.EDGE)
   movingWall_1 = Mesh_1.GroupOnGeom(movingWall,'movingWall',SMESH.EDGE)
   Fondo_1 = Mesh_1.GroupOnGeom(Fondo,'Fondo',SMESH.EDGE)
   Pared_1 = Mesh_1.GroupOnGeom(Pared,'Pared',SMESH.EDGE)
   outOil_1 = Mesh_1.GroupOnGeom(outOil,'outOil',SMESH.EDGE)
   outH2O_1 = Mesh_1.GroupOnGeom(outH2O,'outH2O',SMESH.EDGE)
   E1_1 = Mesh_1.GroupOnGeom(E1,'E1',SMESH.EDGE)
   E2_1 = Mesh_1.GroupOnGeom(E2,'E2',SMESH.EDGE)
   E3_1 = Mesh_1.GroupOnGeom(E3,'E3',SMESH.EDGE)
   E4_1 = Mesh_1.GroupOnGeom(E4,'E4',SMESH.EDGE)
   E5_1 = Mesh_1.GroupOnGeom(E5,'E5',SMESH.EDGE)
   E6_1 = Mesh_1.GroupOnGeom(E6,'E6',SMESH.EDGE)
   E10_1 = Mesh_1.GroupOnGeom(E10,'E10',SMESH.EDGE)
   E9_1 = Mesh_1.GroupOnGeom(E9,'E9',SMESH.EDGE)
   E8_1 = Mesh_1.GroupOnGeom(E8,'E8',SMESH.EDGE)
   E7_1 = Mesh_1.GroupOnGeom(E7,'E7',SMESH.EDGE)
   [ Techo_extruded, movingWall_extruded, Fondo_extruded, Pared_extruded, outOil_extruded, outH2O_extruded, E1_extruded, E2_extruded, E3_extruded, E4_extruded, E5_extruded, E6_extruded, E10_extruded, E9_extruded, E8_extruded, E7_extruded, Techo_top, movingWall_top, Fondo_top, Pared_top, outOil_top, outH2O_top, E1_top, E2_top, E3_top, E4_top, E5_top, E6_top, E10_top, E9_top, E8_top, E7_top ] = Mesh_1.ExtrusionSweepObjects( [], [], [ Mesh_1 ], [ 0, 0, 0.01 ], 1, 1 )


   ## Set names of Mesh objects
   smesh.SetName(NETGEN_2D.GetAlgorithm(), 'NETGEN_2D')
   smesh.SetName(E2_extruded, 'E2_extruded')
   smesh.SetName(E3_extruded, 'E3_extruded')
   smesh.SetName(Viscous_Layers_2D_1, 'Viscous Layers 2D_1')
   smesh.SetName(NETGEN_2D_Parameters, 'NETGEN 2D Parameters')
   smesh.SetName(movingWall_top, 'movingWall_top')
   smesh.SetName(Techo_extruded, 'Techo_extruded')
   smesh.SetName(Fondo_top, 'Fondo_top')
   smesh.SetName(movingWall_extruded, 'movingWall_extruded')
   smesh.SetName(Fondo_extruded, 'Fondo_extruded')
   smesh.SetName(Pared_extruded, 'Pared_extruded')
   smesh.SetName(outOil_extruded, 'outOil_extruded')
   smesh.SetName(outH2O_extruded, 'outH2O_extruded')
   smesh.SetName(E1_extruded, 'E1_extruded')
   smesh.SetName(E4_1, 'E4')
   smesh.SetName(E5_1, 'E5')
   smesh.SetName(E6_1, 'E6')
   smesh.SetName(E10_1, 'E10')
   smesh.SetName(E9_1, 'E9')
   smesh.SetName(E8_1, 'E8')
   smesh.SetName(E7_1, 'E7')
   smesh.SetName(Techo_top, 'Techo_top')
   smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1')
   smesh.SetName(E5_extruded, 'E5_extruded')
   smesh.SetName(E4_extruded, 'E4_extruded')
   smesh.SetName(E10_extruded, 'E10_extruded')
   smesh.SetName(E6_extruded, 'E6_extruded')
   smesh.SetName(E8_extruded, 'E8_extruded')
   smesh.SetName(E9_extruded, 'E9_extruded')
   smesh.SetName(E7_extruded, 'E7_extruded')
   smesh.SetName(E3_1, 'E3')
   smesh.SetName(E10_top, 'E10_top')
   smesh.SetName(E2_1, 'E2')
   smesh.SetName(E6_top, 'E6_top')
   smesh.SetName(E1_top, 'E1_top')
   smesh.SetName(outH2O_top, 'outH2O_top')
   smesh.SetName(Techo_1, 'Techo')
   smesh.SetName(outOil_top, 'outOil_top')
   smesh.SetName(Pared_top, 'Pared_top')
   smesh.SetName(Fondo_1, 'Fondo')
   smesh.SetName(E5_top, 'E5_top')
   smesh.SetName(movingWall_1, 'movingWall')
   smesh.SetName(E7_top, 'E7_top')
   smesh.SetName(E4_top, 'E4_top')
   smesh.SetName(outOil_1, 'outOil')
   smesh.SetName(E3_top, 'E3_top')
   smesh.SetName(Pared_1, 'Pared')
   smesh.SetName(E9_top, 'E9_top')
   smesh.SetName(E2_top, 'E2_top')
   smesh.SetName(E1_1, 'E1')
   smesh.SetName(E8_top, 'E8_top')
   smesh.SetName(outH2O_1, 'outH2O')

   if salome.sg.hasDesktop():
   salome.sg.updateObjBrowser(1)


   =================
   Use on OpenFOAM
   =================



   Export UNV file Mesh_1 and copy un /hgasca/OpenFOAM/run/case

.. code-block:: bash

   ideasUnvToFoam Mesh_1.unv



.. code-block:: bash

   collapseEdges

it creates a new time

Then replace constant Mesh by new time mesh and review names of boundaries

.. code-block:: bash

   FoamFile
   {
       version     2.0;
       format      ascii;
       class       polyBoundaryMesh;
       location    "1/polyMesh";
       object      boundary;
   }

openFoam Flies

Assign patches

File polimesh is located on ~hgasca/openFoam/hgasca6/run/zHOCOL/0.01 after you create the wedge by collapseEdges command. In the folder 0.01 (Equivalent to 0 in not axisymmetric models) you should find:

Files Folder 0.01

The files alpha will be changed in the first run, you should make a copy of them with .orig extension. The sum of all phases in each inlet, outlet, body must be 1 in order to preserve mass conservation.

In this special case we have a constant folder into de 0.01 with the important file:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  4.1                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      binary;
    class       polyBoundaryMesh;
    location    "0.01/polyMesh";
    object      boundary;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

8
(
    Techo
    {
        type            wall;
        nFaces          47;
        startFace       28296;
    }

    Fondo
    {
        type            wall;
        nFaces          93;
        startFace       28343;
    }
    Pared
    {
        type            wall;
        nFaces          1320;
        startFace       28436;
    }
    outOil
    {
        type            patch;
        nFaces          15;
        startFace       29756;
    }
    Entrada
    {
        type            patch;
        nFaces          150;
        startFace       29771;
    }
    outH2O
    {
        type            patch;
        nFaces          20;
        startFace       29921;
    }

    frontAndBack_pos
    {
        type            wedge;
        inGroups        1(wedge);
        nFaces          19423;
        startFace       29941;
    }
    frontAndBack_neg
    {
        type            wedge;
        inGroups        1(wedge);
        nFaces          19423;
        startFace       49364;
    }
)

// ************************************************************************* //

The folder polymesh (contains the original file boundary before has changed by collapseEdges)

constant folder

Pay special attention to transportProperties

system folder

Here there are important files: - collapseDict is necessary to run the collapseDict command. - decomposeParDict sets the parallel running decomposition. - setFieldsDict sets the phases into the geometry as an initial conditions. The subsecuent time steps must maintain the phase equilibrium in other way the run could diverge.

Actions

manually delete new time Then

checkMesh

if errors review your mesh know use pimpleFOAM with one or more processors

decomposePar

Then

mpirun -np 4 pimpleFoam

This is not working on kubunto and OpenFOAM6 by now»

Pruebas