Creating a Model of a Butterfly Valve and run snappyHexMesh from ISCAD - hkroeger/insightcae GitHub Wiki

Building the Parametric Model

The model script is created first. The geometry looks like on the image below.

InsightCAE ISCAD butterfly valve model

The scripts starts with the parameters of the model:

mm = 1e-3;		# unit

Li = 100*mm;	# tube length upstream
Lo = 300*mm;	# tube length downstream
D = 50*mm;		# tube diameter
t = 1.5*mm;		# valve plate thickness
d = 5*mm;		# valve shaft diameter
gap = 0.7*mm;	# gap between tube and plate in closed state

alpha = 35*deg;	# opening angle

First the surrounding pipe is created:

tube : Cylinder(-Li*EX, Lo*EX, D);

The upstream and downstream face of the pipe is sought (detected from the x component of its center of gravity):

f_inlet = tube ? faces('minimal(CoG.x)');
f_outlet = tube ? faces('maximal(CoG.x)');

The valve geometry is composed from a cylinder (the shaft) and a round plate:

throttle1 =
 Cylinder(O, ax t*EX, D-2*gap, centered)
  |
 Cylinder(O, 1.5*D*EY, d, centered)
;

throttle : Rotate(throttle1, alpha*EY, O); # rotate to final position

Finally, the outer edges of the valve plate are extracted for later specification of additional refinements:

e_th_edges = throttle?edges(
 'isCircle&&(circRadius ~ %d0 {1e-6} )', 
 0.5*D-gap
);

Meshing using snappyHexMesh

The last step is to do the meshing. After the geometry creation statements, an optional post processing section can appear in ISCAD scripts. It is started by "@post". In this section, different evaluation procedures may be defined. Here we use a single "snappyHexMesh" procedure:

@post

snappyHexMesh("./throttle_cfd", OFplus) <<  # output directory, OpenFOAM installation to use
 PiM=0.45*Lo*EX	# location of point in mesh
 dx=5*mm		# template mesh cell size

 # geometry entities in meshing scene follow:
 (*f_inlet) as inlet @ 1 to 2	# faces in f_inlet named as "inlet", refinement level 1 to 2
 (*f_outlet) as outlet @ 1 to 2  # faces in f_outlet named "outlet", refinement level 1 to 2
 
 # remaining faces (not in f_inlet or f_outlet) of tube named "tube"
 # refinement level1 to 2, with 3 prism layers
 (*tube?faces('!(in(%0)||in(%1))', f_inlet, f_outlet))
  as tube @ 1 to 2 >> 3  

 # geometry throttle named as "throttle".
 # refinement level 2 to 3 with 3 prism layers
 throttle as throttle @ 2 to 3 >> 3

 # additional edge refinements (exported as *.eMesh files)
 edgeRefinements (
  edges = e_th_edges @ 3 # refine all cells intersected by e_th_edges to level 3
 )
;

All geometry entries in the "snappyHexMesh" procedure are added to the snappyHexMesh meshing scene with the given properties. The template mesh is a rectangular box around the meshing scene (slightly larger than the bounding box). The cell counts are chosen such that the cells are cubical with the given cell size "dx".

Once the “@post” section is completed as above, the meshing will be executed on the next model rebuild, if the “Skip Postproc Actions” checkbox is unchecked. Note that it is checked by default. It is also possible to execute iscad in batch mode from the command line (“iscad -b “). Then no GUI will be started, but all statements in the “@post” section are executed.

After execution, the directory "throttle_cfd" will be created. Please note that it is not deleted, if it is existing, but only files in it will be overwritten. If the snappyHexMesh procedure is executed several times with different settings, errors might appear because of inconsistenst data which remained from previous runs. So in case of errors, just try to delete the the directory first.

The resulting mesh looks like this:

InsightCAE ISCAD butterfly valve snappyHexMesh mesh

Once the mesh is ready, the remaining OpenFOAM case setup can be completed using the OpenFOAM Case Builder (execute "isofCaseBuilder"). See the tutorial Creating an OpenFOAM Simulation from Scratch for an example of the Case Builder usage (the blockMeshDict_Box and snappyHexMeshDict in the example should be skipped, because we just created the mesh).

InsightCAE ISCAD butterfly valve simpleFoam pressure velocity