CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[mesh manipulation] EngineMesh utilitities

Register Blogs Community New Posts Updated Threads Search

Like Tree7Likes
  • 1 Post By greg_karp
  • 4 Post By wyldckat
  • 1 Post By wyldckat
  • 1 Post By mturcios777

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 22, 2015, 16:42
Default EngineMesh utilitities
  #1
New Member
 
Grzegorz Karpiński
Join Date: Nov 2014
Location: Olsztyn, Poland
Posts: 6
Rep Power: 12
greg_karp is on a distinguished road
Hello,

I'm new in Open FOAM software (just after one basic online course). I'm interested in I.C. engines simulations. Do you know how I can get explanations (tutorials, descriptions) about engine utilities in Open FOAM? Specially:
- "MoveEngineMesh". I want to know how to prepare walls in "blockMeshdict" file (or in other utility to prepare mesh if it is better for engines) and files "MeshModifiers" , "DynamicMeshDict"
- Also what is necessary to run "engineFoam" solver (files in "0" and "system" folders).

My purpose is to run simulation for case of my master thesis (I did it already in AVL FIRE software which license I borrow for thesis preparation period). Below I present you link to presentation of my thesis:

http://prezi.com/dmif50zywkzl/?utm_c...py&rc=ex0share

Do you think it will be difficult to run in Open FOAM software ?
Junqing likes this.
greg_karp is offline   Reply With Quote

Old   March 23, 2015, 14:04
Default
  #2
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
Have a look at the engineFoam tutorial case ($FOAM_TUTORIALS/combustion/engineFoam). For multispecies diffusion flames, you may need to go to sprayEngineFoam.

The main thing with the current existing engine mesh types is to have the proper patches (cylinderHead, liner and piston) and the right values in the constant/engineGeometry dictionary. You can use moveEngineMesh to determine if the mesh quality will be acceptable during the stroke. I suspect you will need to remesh periodically to keep aspect ratio of the cells at a good quality.
mturcios777 is offline   Reply With Quote

Old   April 1, 2015, 16:37
Default
  #3
New Member
 
Grzegorz Karpiński
Join Date: Nov 2014
Location: Olsztyn, Poland
Posts: 6
Rep Power: 12
greg_karp is on a distinguished road
Thank you Marco for your response. It really helps me to start. I did not answer for a while because using OpenFoam takes me long time.

- About using sprayEngineFoam for multispecies diffusion: I didn’t activate multispecies module in

AVL FIRE because homogeneous mixture of methane was used, so I’ve just wanted to simulate

combustion. In the following link you can see movies how it looks:

https://www.dropbox.com/sh/w62sss9wm...5AyofEwIa?dl=0

- About tutorial which you recommend me ($FOAM_TUTORIALS/combustion/engineFoam) : this is kiva test tutorial and I cannot find the executive files for mesh. I’m using “simple

engine” tutorial which I found at following site:
http://powerlab.fsb.hr/ped/kturbo/Op...neTutorial.tgz

Now I stuck in following steps:

1. I don’t know which command I can use to execute the mesh (I tried “moveEngineMesh”, “moveDynamicMesh”, “moveMesh”. Do you know how to execute this mesh?

2. If I good understood I must only assign “cylinderHead”, “liner” and “piston” patches. I have to deactivate all valves settings. Do you know how?

3. Maybe you have access to more suitable tutorial?

4. About mesh: I prepare this with blockMesh utilities. I did “mergePatchpairs” but mesh is

complicated in joint area. In link below you can see result:
https://www.dropbox.com/sh/xxwfbp7ye...QHYf1oaIa?dl=0

In OF 2.3.0 one error appears in “checkMesh”:
https://www.dropbox.com/s/rnbq4yegp7...checkmesh?dl=0
Using OF ex 3.1 2 is not possible to execute “mergePatchpairs” tool (it is of interest for me).

5. Do you know how to manipulate mesh:

- Is it better to re-mesh periodically or make layer removal during stroke
movement? How to execute one of these methods?

- how to prepare sliding interface ?

I look forward to hearing from you.

Best regards

Gregory
greg_karp is offline   Reply With Quote

Old   April 1, 2015, 18:50
Default
  #4
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
1. The foam engine tutorial isn't completely straightforward. If you look at the Allrun script you will see how the mesh is initialized (converted from KIVA file) and then the application engineFoam is run (its being fancy and getting the application name from the controlDict).

moveEngineMesh and similar only move the mesh to see if your mesh motions are working properly.

2. engineMesh will work fine with additional patches beyond cylinderHead, liner and piston, but only the liner and piston patches will be moved; everything else will stay stationary, unless you are using fvMotionSolverEngineMesh

3. The kivaTest is very straightforward once you look at the Allrun script

4. Before using mergePatchPairs, make sure the mesh is acceptable without merging. I've found merging only works for the very simplest cases and you are usually better off ensuring your blocks are co-located.

5. When compressing, layer removal works well and shortens your runtime. On expansion you are better off remeshing.
mturcios777 is offline   Reply With Quote

Old   August 19, 2015, 10:22
Default
  #5
Member
 
Join Date: Jul 2015
Posts: 33
Rep Power: 11
kaveh19 is on a distinguished road
hi mturcios777,
I want to run kivaTest ,but i don't know how create my favorite compression ratio.Can you help me?
BlockMeshDict doesn't exist in this case
kaveh19 is offline   Reply With Quote

Old   August 19, 2015, 13:22
Default
  #6
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
Hello kaveh,

The compression ratio is set by the mesh itself, but there is a utility that can help you adjust your mesh to get what you want. engineCompRatio will calculate the compression ratio for your engine based on the parameters set in the constant/engineGeometry file.

Once you have the major parameters selected (stroke, conRodLength, stroke), you can make minor adjustments using the clearance. Its a bit of guess and test, but the equations of piston motion should give you a rough estimate of what your clearance value should be.

Good luck
mturcios777 is offline   Reply With Quote

Old   August 21, 2015, 08:10
Default
  #7
Member
 
Join Date: Jul 2015
Posts: 33
Rep Power: 11
kaveh19 is on a distinguished road
Dear mturcios777,
For example,
I want to run the blow case by the default mesh in kivaTest ,It's data in an article,
Bore=86 mm
Stroke=86 mm
Compression ratio=14.04
Connection rod length=154.49
*****
My engineGoemetry is

conRodLength conRodLength [ 0 1 0 0 0 0 0 ] 0.15449
bore bore [ 0 1 0 0 0 0 0 ] 0.086;
stroke stroke [ 0 1 0 0 0 0 0 ] 0.086;
clearance clearance [ 0 1 0 0 0 0 0 ] 0.02115;
rpm rpm [ 0 0 -1 0 0 0 0 ] 1500;
*****
but i receive blow results
CA = 0
deltaZ = 0.086
clearance: -0.000361
Piston speed = 4.3 m/s

Vmax = 0.000631297, Vmin = 5.97945e-05
Vmax/Vmin = 10.5578
*************
Of course by changing conRodLength & clearance, compression ratio doesn't change.
please help me.
thanks in advance.
kaveh19 is offline   Reply With Quote

Old   August 21, 2015, 17:07
Default
  #8
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings to all!

@kaveh19: I was curious about this and did some researching on how the names relate to the geometry of the piston+conrod+crankshaft. This wikipedia page pretty much explains it all: https://en.wikipedia.org/wiki/Engine_balance - the section "Secondary (non-sinusoidal) balance"

In addition, I already mentioned in another thread: http://www.cfd-online.com/Forums/ope...tml#post560092 - post #123 - what each parameter is identified as in the source code, since you asked about it there.

So, after playing around with the tutorial case, what I found out is that most likely you are going to create your own new mesh for your cylinder.
This is because the mesh on the tutorial "combustion/engineFoam/kivaTest" already geometrically includes:
  • the space for the valve ports;
  • the clearance gap;
  • and the indentation in the piston head.
All of these are all calibrated to work with a compression ratio of "Vmax/Vmin = 8.82231". At best, what you're able to do, is to possibly increase the compression ratio up to 10.0, without breaking the geometrical consistency.

Now, if you still want to try and manipulate this mesh until you can get a close enough mesh, here's what you can try doing:
  1. You are going to need to modify the mesh to fit the desired shape. For this, you can run these commands:
    Code:
    kivaToFoam -file otape17
    
    transformPoints -scale '(0.934782609 0.934782609 1.021013891)'
    The first one will import the original mesh to OpenFOAM format and the second one will scale the points of the mesh in a proportion for having the stroke and bore definitions you want.The calculations were:
    • bore = paper/original: 0.086 / 0.092 = 0.934782609
    • stroke = paper/original: 0.086 / 0.08423 = 1.021013891
  2. Now that you have the mesh you want, you need to configure the file "constant/engineGeometry". If you configure the way you did:
    Code:
    conRodLength    conRodLength [ 0 1 0 0 0 0 0 ] 0.15449;
    bore            bore [ 0 1 0 0 0 0 0 ] 0.086;
    stroke          stroke [ 0 1 0 0 0 0 0 ] 0.086;
    clearance       clearance [ 0 1 0 0 0 0 0 ] 0.02115;
    and then run the calculation utility:
    Code:
    engineCompRatio
    You will get this:
    Code:
    Selecting engineMesh layered
    deckHeight: 0.0874386
    CA = 0
    deltaZ = 0.086
    clearance: 0.00143861
    Piston speed = 4.3 m/s
    
    Vmax = 0.000563231, Vmin = 6.38417e-05
    Vmax/Vmin = 8.82231
    Which is the same compression ratio as the original case.
  3. Now, you need visual diagnose the mesh, in order to understand what's going on. For that, run:
    Code:
    moveEngineMesh
    Then follow the instructions given here: http://openfoamwiki.net/index.php/FA...is_in_ParaView
    • Don't forget to use the time controls, for changing the currently visible time step. If you're unfamiliar with ParaView, please study the ParaView User Guide, available here: http://www.paraview.org/download/
  4. Now, you can try to start over, by running:
    Code:
    ./Allclean
    And then start over from the step #1 on this list. But change the transformation over Z to something that gives you the compression ratio you're looking for. The result is very likely going to give you the top of the cylinder being collapsed into itself, because you cannot change the dimensions of the top of the mesh where the valve ports are and it's where a lot of volume is located.


Beyond this, I can still provide a few more details about the parameters defined in "constant/engineGeometry":
  • The "conRodLength" parameter does not affect the compression ratio. What it affects is how fast the piston moves. Study the diagram on the wikipedia page, to see what I mean.
  • The "clearance" parameter does not affect the compression ratio, it's only used for absolute position calculations. This is because the underlying dynamic engine mesh mechanism only works in displacement, i.e. the difference between the position before and the position after, making the "clearance" only useful for aboslute position calculations... which practically are only used for the displacement calculation.
    • Technically, the "clearance" output you see from engineFoam and engineCompRatio is the real clearance value that is achieved with the mesh for that angle.
Related to this, the source code for "engineCompRatio" has this description: https://github.com/OpenFOAM/OpenFOAM...ompRatio.C#L28

Code:
    Calculate the geometric compression ratio.
    Note that if you have valves and/or extra volumes it will not work,
    since it calculates the volume at BDC and TCD.
And I think that's all I discovered.


Best regards,
Bruno

PS: Here's another related answer: http://www.cfd-online.com/Forums/ope...tml#post560580 - post #5, on how to calculate the geometry settings.
__________________

Last edited by wyldckat; August 21, 2015 at 19:27. Reason: fixed typo
wyldckat is offline   Reply With Quote

Old   August 21, 2015, 18:10
Default
  #9
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
Very good post Bruno. I had forgotten that I adjusted clearance on our own internal mesh generation utility, not the engineMeshDict
mturcios777 is offline   Reply With Quote

Old   August 23, 2015, 10:41
Default
  #10
Member
 
Join Date: Jul 2015
Posts: 33
Rep Power: 11
kaveh19 is on a distinguished road
hi mturcios777,
I really appreciate u,but compression ratio doesn't change
in fact by this way we have changed the geometry .am i right?
kaveh19 is offline   Reply With Quote

Old   August 23, 2015, 14:55
Default
  #11
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quote:
Originally Posted by kaveh19 View Post
in fact by this way we have changed the geometry .am i right?
As explained in post #8, yes, the mesh is manipulated so that the mesh matches the same stroke and bore you asked for. That is what transformPoints is used for.

The parameters specified in "constant/engineGeometry" are for adjusting the parameters for the mesh motion.

The detail you're not seeing, perhaps because you did not follow all of the steps described in post #8, is that the mesh isn't simply a simple geometrical cylinder. It also has:
  • a zone for the valves that is not meant to change with the motion of the piston;
  • and the head of the piston itself has an indentation that doesn't change with the motion of the piston.
These two zones equate to a volume that is not easy to manipulate, and that is why the compression ratio can't got much more above 10:1.


My guess is that if you did follow the steps I wrote in post #8, you possibly would have seen this situation already. In addition, if you had seen the mesh in ParaView, you possibly would have asked as to how you could change the dimensions when the piston is located in the top position... which you didn't ask about.


Sometime after I wrote my answer in post #8, I did some additional thinking and perhaps it is possible to change the dimensions of the head of the cylinder and the head of the piston even further. The big problems are:
  • How to do the calculations for those dimensions?
  • And if that makes any sense, since we will be reducing the height of these two volumes.
In theory, the steps should be something like this:
  1. engineCompRatio tells us the total volume when the mesh is at the top maximum position. As explained in post #8, the mesh modified to have the requested bore and stroke gave these volume sizes:
    Code:
    Vmax = 0.000563231, Vmin = 6.38417e-05
    Vmax/Vmin = 8.82231
  2. The desired compression ratio is 14.04, therefore this means that the target "Vmin" has to be:
    Code:
    0.000563231 / 14.04 = 0.000040116
  3. Which means that we need to scale down the mesh along Z by an additional factor:
    Code:
    0.000040116 / 6.38417e-05 = 0.6283667
  4. Therefore, after running steps 1 to 3 from post #8, you should have various mesh positions, including for the angle "0". It's this position that can be used for compressing the volume even further...
  5. ...
Sorry, I'm tired of explaining even further. I've attached the package "kivaTestModified24.tar.gz" that has the case modified to do the steps needed for manipulating the mesh.
The case can be executed by running:
Code:
./Allrun
And reset back to the original version by running:
Code:
./Allclean
Study the contents of the files "Allrun" and "Allclean".
It should work with OpenFOAM 2.3 and 2.4.

And since I took the time to comment every step in "Allrun", here's the contents of the file as well:
Code:
#!/bin/sh
cd ${0%/*} || exit 1    # run from this directory

# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions

# Get application name
application=`getApplication`

# get the original mesh from the original tutorial
cp $FOAM_TUTORIALS/combustion/engineFoam/kivaTest/otape17 ./

# convert the mesh
runApplication kivaToFoam -file otape17

# reshape the cylinder so that it has the same bore and stroke as desired
runApplication transformPoints -scale '(0.934782609 0.934782609 1.021013891)'

# rename the log file, so that it doesn't collide with the next time we use
# the same application
mv log.transformPoints log.transformPoints.A

# create the temporary angle folder for -180 degrees, which is the starting
# position for the piston
mkdir ./-180

# use the controlDict that was created for moving the piston from -180 degrees
# to 0 degrees
cp system/controlDict.displaceMeshTo0 system/controlDict

# Move the piston from -180 degrees to 0 degrees
runApplication moveEngineMesh

# rename the log file, so that it doesn't collide with the next time we use
# the same application
mv log.moveEngineMesh log.moveEngineMesh.A

# Reshape the height of the cylinder, so that the volume is reduced to the desired
# compression ratio
runApplication transformPoints -scale '(1.0 1.0 0.6283667)'

# rename the log file, so that it doesn't collide with the next time we use
# the same application
mv log.transformPoints log.transformPoints.B

# use the controlDict that was created for moving the piston from 0 degrees
# to 180 degrees
cp system/controlDict.displaceMeshBackTo180 system/controlDict

# Move the piston from 0 degrees to 180 degrees
runApplication moveEngineMesh

# rename the log file, so that it doesn't collide with the next time we use
# the same application
mv log.moveEngineMesh log.moveEngineMesh.B

# Move the "points" file of the final position to the main mesh, because this
# is the starting position
mv 180/polyMesh/points constant/polyMesh/

# remove all temporary angle (time) folders that were used for manipulating
# the mesh.
rm -rf 180 0 ./-* > /dev/null 2>&1

# copy the angle folder that has all of the fields for running the case
cp -r ./original.-180 ./-180

# switch to using the original controlDict for engineFoam
cp system/controlDict.originalRun system/controlDict

# Calculate the compression ratio first
runApplication engineCompRatio

# Uncomment this line for also running the solver
#runApplication $application

# ----------------------------------------------------------------- end-of-file
___________________________

Warning
: This example does not achieve the compression ratio of 14.04:
Code:
Vmax = 0.000539505, Vmin = 4.0116e-05
Vmax/Vmin = 13.4486
This because the calculations explained on this post don't take into account a few more details, such as the fact that the stroke must be different before moving from -180 to 0 and from the stroke used after 0 to 180. You will have to do the missing calculations and adjustments yourself.
Attached Files
File Type: gz kivaTestModified24.tar.gz (4.9 KB, 30 views)
greg_karp likes this.
__________________
wyldckat is offline   Reply With Quote

Old   August 25, 2015, 17:22
Default
  #12
Member
 
Join Date: Jul 2015
Posts: 33
Rep Power: 11
kaveh19 is on a distinguished road
hi wyldckat,
I really appreciate you. according to AckivaTest tutorial-fault on temperature (engineFoam) I could fix my compression ratio ,but i have problem with boundary condition now. I will be happy if you participate in our discussion.
Thanks for your guides.
kaveh19 is offline   Reply With Quote

Old   August 31, 2015, 09:51
Default kivaTest
  #13
Member
 
Join Date: Jul 2015
Posts: 33
Rep Power: 11
kaveh19 is on a distinguished road
Hello guys,
I have modified the kivaTest for compression ratio equal to 14.04.
I want to change the fuel of kivaTest to gasoline . Would you mind telling me how i should start?
In combustionProperties :
fuel IsoOctane; says that fuel is Isooctane , but
GuldersCoeffs
{
Methane
{
W 0.422;
eta 0.15;
xi 5.18;
alpha 2;
beta -0.5;
f 2.3;
}

Propane
{
W 0.446;
eta 0.12;
xi 4.95;
alpha 1.77;
beta -0.2;
f 2.3;
}

IsoOctane
{
W 0.4658;
eta -0.326;
xi 4.48;
alpha 1.56;
beta -0.22;
f 2.3;
}
} specify some weird coefficient ,of course for me , for Methane ,Propane,and Isooctane.
In thermophysicalProperties;
thermodynamics
{
Tlow 298.15;
Thigh 5000;
Tcommon 1000;
highCpCoeffs ( 19.3963 0.0488137 -1.55798e-05 2.17831e-09 -1.08391e-13 -37133.9 -78.8531 );
lowCpCoeffs ( 0.429357 0.0765769 8.41306e-06 -5.86603e-08 2.79414e-11 -30446.4 25.6735 );
}
transport
{
As 1.67212e-06;
Ts 170.672;
} are really unfamiliar for me.
Thanks in advance.
kaveh19 is offline   Reply With Quote

Old   March 17, 2017, 08:49
Default
  #14
Senior Member
 
zhangyan's Avatar
 
Yan Zhang
Join Date: May 2014
Posts: 120
Rep Power: 12
zhangyan is on a distinguished road
Quote:
Originally Posted by mturcios777 View Post
5. When compressing, layer removal works well and shortens your runtime. On expansion you are better off remeshing.
Hi Marco,
Recently, I use the OpenFOAM-extend-4.0 to simulate engine combustion.
I use the layerAR.
And I also find that the case will crash when expansion.
You said remeshing for expansion. But I still don't know how to deal with it.
Would you tell me more details about this?
zhangyan is offline   Reply With Quote

Old   March 17, 2017, 12:46
Default
  #15
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
No worries. layerAR on expansion is a bit tricky as you have to interpolate the values of the cells in the new layer properly and ensure the flux on the newly created faces is oriented properly. I've got a some threads on this in the mantis for 2.3.x, can't find them at the moment.

But since re-meshing works better on expansion anyway, I usually end up doing that. Layer addition adds cells continuously on expansion, so if your flow isn't really sensitive to aspect ratio there is no great need for layer addition. What I do is just use the normal layered mesh and start with highly compressed cells (~5:1 aspect ratio) and expand until the liner cells are almost 1:1.5-2 aspect ratio. I then stop the simulation, map the results to a newer mesh with more cells that are compressed, then repeat the process as required. I have a bash script that performs this, and since my mesh is parametrically generated with Python and blockMesh, its pretty quick. Obviously if you are using sHM this process can be more involved.

Hope this helps,
Marco
zhangyan likes this.
mturcios777 is offline   Reply With Quote

Old   March 18, 2017, 21:47
Default
  #16
Senior Member
 
zhangyan's Avatar
 
Yan Zhang
Join Date: May 2014
Posts: 120
Rep Power: 12
zhangyan is on a distinguished road
Hi Marco,
Thanks for your suggestion.
And I have run moveEngineTopoMesh solver successfully, both compression and expansion.
So I think I can use the mesh generated by moveEngineTopoMesh for expansion in dieselEngineDymFoam(revised by myself).

Yan

Last edited by zhangyan; April 17, 2017 at 03:05.
zhangyan is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
engineMesh with layered addition removal mturcios777 OpenFOAM Programming & Development 19 May 20, 2014 19:16
engine simulation with fvmotionSolver engineMesh sasanghomi OpenFOAM 10 September 4, 2013 17:23
Autorefinement and deforming enginemesh Rickard.Solsjo OpenFOAM 0 August 22, 2011 05:20


All times are GMT -4. The time now is 21:48.