One of the Boundaries lost from Salome to Elmer - solved

Clearly defined bug reports and their fixes
Post Reply
thomasatelmer
Posts: 47
Joined: 18 Jan 2019, 18:18
Antispam: Yes

One of the Boundaries lost from Salome to Elmer - solved

Post by thomasatelmer »

Hi altogether,
although I found a personal work-around for this issue, I'd like to post it here still. I am using Salome for digesting STP files into meshes, or for creating models from scratch to form meshes. The meshes get a Group of solid for each Body and a Group of faces for each boundary. However lately I missed the first boundary face from each model when reading the UNV file into Elmer. Numbering the model with boundary Indexes Shows that the first denominated boundary face from Salome has the same boundary index number like the General surface of the whole Body.

An example: A simple bar is created, one end face is the fixed end, the other one is the loaded one. The body of the bar has body index 1, the fixed boundary receives boundary index 2 and the loaded face gets index 3. But all other surface of the bar also gets boundary index 2, hence I cannot assign the fixed condition to boundary 2, otherwise the whole body is fixed....

Elmergrid Output reads as follows (normally I open the UNV file directly in ElmerGUI, but also after Treatment with Elmergrid, the Problem remains):

Code: Select all

D:\Elmer_workdir>elmergrid 8 2 mesh_2.unv

Starting program Elmergrid
Elmergrid reading in-line arguments
Output will be saved to file mesh_2.

Elmergrid loading data:
-----------------------
Reading mesh from universal mesh file mesh_2.unv.
First round for allocating data
Units dataset content is currently omitted!
Part UID = 1
Part name = SMESH_Mesh
Coord system name = Global
There are 1306 nodes in the mesh
Element type range in mesh [202,504]
Allocating mesh with 1306 nodes and 6902 4-node elements in 3 dims.
Physical index interval is [2,2]
Group index interval is [1,3]
Using offset 2 for physical indexes
Second round for reading data
Reading Coordinate system information
Reading node coordinates
Reading element topologies
Reading element groups in mode 2467
Reading 1:th group with index 1 with 5136 entities: Box_
Element type range in group is [504 504]
Reading 2:th group with index 2 with 114 entities: fix_
Element type range in group is [303 303]
Reading 3:th group with index 3 with 118 entities: load_
Element type range in group is [303 303]
Moving bulk elements to boundary elements
Leading bulk elementtype is 504
Trailing bulk elementtype is 202
There are 1766 (out of 6902) lower dimensional elements.
Node 1020 belongs to maximum of 40 elements
Found correctly 1766 side elements.
Parent elements were reordered up to indx 5136.
Moved 5136 elements (out of 6902) to new positions
The Universal mesh was loaded from file mesh_2.unv.


Elmergrid creating and manipulating meshes:
-------------------------------------------

Elmergrid saving data with method 2:
-------------------------------------
Saving mesh in ElmerSolver format to directory mesh_2.
Saving 1306 coordinates to mesh.nodes.
Saving 5136 element topologies to mesh.elements.
Saving boundary elements to mesh.boundary.
Saving header info to mesh.header.
Saving names info to mesh.names.
Saving entities info to entities.sif.

Thank you for using Elmergrid!
Send bug reports and feature wishes to elmeradm@csc.fi


The python script for Salome geometry Generation Shows geometry Groups:

Code: Select all

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

###
### This file is generated automatically by SALOME v8.3.0 with dump python functionality
###

import sys
import salome

salome.salome_init()
theStudy = salome.myStudy

import salome_notebook
notebook = salome_notebook.NoteBook(theStudy)
sys.path.insert( 0, r'D:/Elmer_workdir')

###
### 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)
Box_1 = geompy.MakeBoxDXDYDZ(200, 400, 100)
Partition_1 = geompy.MakePartition([Box_1], [], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["VERTEX"])
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["VERTEX"])
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["SOLID"])
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["SOLID"])
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["SOLID"])
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["SOLID"])
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["SOLID"])
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["SOLID"])
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["SOLID"])
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["FACE"])
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["FACE"])
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["FACE"])
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["FACE"])
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["FACE"])
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["FACE"])
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["FACE"])
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["FACE"])
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["FACE"])
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["FACE"])
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["FACE"])
listSubShapeIDs = geompy.SubShapeAllIDs(Partition_1, geompy.ShapeType["FACE"])
Box_itself = geompy.CreateGroup(Partition_1, geompy.ShapeType["SOLID"])
geompy.UnionIDs(Box_itself, [1])
fix = geompy.CreateGroup(Partition_1, geompy.ShapeType["FACE"])
geompy.UnionIDs(fix, [23])
load = geompy.CreateGroup(Partition_1, geompy.ShapeType["FACE"])
geompy.UnionIDs(load, [27])
geompy.addToStudy( O, 'O' )
geompy.addToStudy( OX, 'OX' )
geompy.addToStudy( OY, 'OY' )
geompy.addToStudy( OZ, 'OZ' )
geompy.addToStudy( Box_1, 'Box_1' )
geompy.addToStudy( Partition_1, 'Partition_1' )
geompy.addToStudyInFather( Partition_1, Box_itself, 'Box_itself' )
geompy.addToStudyInFather( Partition_1, fix, 'fix' )
geompy.addToStudyInFather( Partition_1, load, 'load' )

###
### SMESH component
###

import  SMESH, SALOMEDS
from salome.smesh import smeshBuilder

smesh = smeshBuilder.New(theStudy)
Mesh_2 = smesh.Mesh(Partition_1)
NETGEN_1D_2D_3D = Mesh_2.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D)
NETGEN_3D_Parameters_1 = NETGEN_1D_2D_3D.Parameters()
NETGEN_3D_Parameters_1.SetMaxSize( 20 )
NETGEN_3D_Parameters_1.SetSecondOrder( 0 )
NETGEN_3D_Parameters_1.SetOptimize( 1 )
NETGEN_3D_Parameters_1.SetFineness( 2 )
NETGEN_3D_Parameters_1.SetMinSize( 0 )
NETGEN_3D_Parameters_1.SetUseSurfaceCurvature( 1 )
NETGEN_3D_Parameters_1.SetFuseEdges( 1 )
NETGEN_3D_Parameters_1.SetQuadAllowed( 0 )
isDone = Mesh_2.Compute()
Box_ = Mesh_2.GroupOnGeom(Box_itself,'Box_',SMESH.VOLUME)
fix_ = Mesh_2.GroupOnGeom(fix,'fix_',SMESH.FACE)
fix_.SetColor( SALOMEDS.Color( 1, 0, 0 ))
load_ = Mesh_2.GroupOnGeom(load,'load_',SMESH.FACE)
load_.SetColor( SALOMEDS.Color( 0, 0.666667, 0 ))
try:
  Mesh_2.ExportUNV( r'D:/Elmer_workdir/Mesh_2.unv' )
  pass
except:
  print 'ExportUNV() failed. Invalid file name?'


## Set names of Mesh objects
smesh.SetName(NETGEN_1D_2D_3D.GetAlgorithm(), 'NETGEN 1D-2D-3D')
smesh.SetName(Box_, 'Box_')
smesh.SetName(NETGEN_3D_Parameters_1, 'NETGEN 3D Parameters_1')
smesh.SetName(Mesh_2.GetMesh(), 'Mesh_2')
smesh.SetName(load_, 'load_')
smesh.SetName(fix_, 'fix_')
In ElmerGUI, the numbering Looks like shown in the attached Picture.
boundaries_in_Elmer.JPG
boundaries_in_Elmer.JPG (135.74 KiB) Viewed 4457 times
oh, and the Workaround is to define the first boundary face again as last boundary, then the mesh in Elmer has an adressable boundary at this place.

As far as I know myself, there is a fair Chance this is not a bug of Elmer, but a bug in my thinking ;) . But clarification would definitely appreciated!

Thanks, Thomas.
Last edited by thomasatelmer on 24 Apr 2019, 17:42, edited 1 time in total.
kevinarden
Posts: 2237
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: One of the Boundaries lost from Salome to Elmer

Post by kevinarden »

If you are reading the unv file into ElmerGUI there are known bugs. Using ElmerGrid to convert mesh to an Elmer mesh is a better experience. Also on this board is a Slaome python script to write an Elmer mesh directly from Salome.
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: One of the Boundaries lost from Salome to Elmer

Post by mzenker »

Hi,

did you set the -autoclean option? This can be done in ElmerGrid as well as in ElmerGUI (Mesh->configure, BEFORE opening the unv file) and does quite often arrange things.

HTH,
Matthias
thomasatelmer
Posts: 47
Joined: 18 Jan 2019, 18:18
Antispam: Yes

Re: One of the Boundaries lost from Salome to Elmer

Post by thomasatelmer »

Good morning to all,

thank you for the suggestions and sorry for not replying earlier. It sometimes takes me a while to return to work with ElmerFEM :)

I tried the -autoclean Option under the configure-dialogue in the section "elmergrid", and it did Change things - now the faces that were numbered 2 are numbered 1 and the ones numbered 3 have become 2, but the pattern remains. I will continue to try to dig up the mentioned script for generating Elmer mesh from Salome directly and Report when I was able to give it a try.

Thank you so far,
Thomas.
thomasatelmer
Posts: 47
Joined: 18 Jan 2019, 18:18
Antispam: Yes

Re: One of the Boundaries lost from Salome to Elmer

Post by thomasatelmer »

Hi everybody,

I finally figured out a good and robust way to get things in order when importing a mesh. I also came across the thought that this may have been meant by kevinarden, but I didn't immediately get the Point.

I now generate in Salome the mesh and Export it to UNV. Using the commandline

Code: Select all

elmergrid 8 2 mesh.unv -autoclean 

I get the Elmer mesh structure generated in a new subdirectory. It also contains the file "entities.sif" that clearly states which boundary was which Group Name in Salome, e.g.

Code: Select all

Boundary Condition 4
  Name = Rand_msh
End
Now the trick that helped me - instead of importing the UNV file via "File" -> "Open" in Elmer, use "File" -> "Open mesh". That way Elmer reads the generated mesh Information from the mesh subdirectory without further Manipulation of the boundary indices, and one can rely on that the numbering is like in entities.sif.

HTH,
Thomas.
Post Reply