CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   dieselEngineDyMFoam (

Peter_600 January 6, 2011 17:12

Hi Foamers,

Does anyone of you know how to make from dieselengineFoam ->dieselEngineDyMFoam?
I woul like to use the mesh strategies from the engineTopoChangerMesh class.


u22 November 21, 2012 01:02

I have same question. How to modify dieselEngineFoam to work with layer addition and removal ? I use 1.6-ext...

Peter_600 November 21, 2012 07:35


you have to include following header files in your solver before the main part will be executed.

#include "engineTopoChangerMesh.H instead of #include "dynamicFvMesh.H"

change mesh.move() to mesh.update()

Furthermore, you have to link the compiler to this lib with


cheers Peter

u22 November 22, 2012 06:06

Thanks, Peter!

Already figured out the issue. I did some change in code similar to the sonicTurbDyMEngineFoam.C

Here is diff dieselEngineDyMFoam.C dieselEngineFoam.C
< #include "engineTopoChangerMesh.H"
> #include "engineMesh.H"
< # include "createEngineDynamicMesh.H"
> # include "createEngineMesh.H"
< mesh.update();
> mesh.move();

And make diff options is
< -I$(LIB_SRC)/dynamicMesh/dynamicFvMesh/lnInclude \
< -I$(LIB_SRC)/dynamicMesh/dynamicMesh/lnInclude \
< -I$(LIB_SRC)/dynamicMesh/topoChangerFvMesh/lnInclude \
< -I$(LIB_SRC)/meshTools/lnInclude
< -llduSolvers \
< -ldynamicFvMesh \
< -ldynamicMesh \
< -ltopoChangerFvMesh \
< -lmeshTools
> -llduSolvers

u22 December 12, 2012 06:06

1 Attachment(s)
Hello, foamers!

Mоdified solver dieselEngineDyMFoam removes layers correсtly, but crashes in first layer addition.
Please explain purpose of the coordinate system (how it should be oriented for a piston patch? what means origin, direction and axis? ), as well as other parameters in engineGeometry dict.

I use
engineTopoChangerMesh layerAR;
minLayer 0.002;
maxLayer 0.005;
delta 0.001;
offSet 0.002 // i gues, it means "work area" for add/removal. In which direction?? And offset from which point??

My mesh is 0.005 m in Z directions...

patch piston;

// type Cartesian;
type cylindrical;
origin (0 0 0);
axis (0 0 1);
// direction (0 1 0);
direction (1 0 0);
minLayer 0.002;
maxLayer 0.005;

mturcios777 December 12, 2012 13:28

I'll tackle this one as layer addition/removal is something I managed to get working after a long struggle.

Offset is how far away from the highest z value of the piston patch you want to start looking for your add/remove surface. So if your piston patch has max z coordinate of -0.02 m, establishing the add/remove surface will begin looking there. If offset = 0, then the faces of the piston patch itself will be used (unless your piston patch is reasonably flat, don't do this)

delta is the range where you want to look for faces to make the add/remove surface. if delta is 0.001 m, then all faces in the range [-0.021, -0.019] will be eligible for being part of the add/remove surface.

Its always good to check the pistonLayerFaces faceZone that is created to ensure that the resulting faceZone is a singly connected surface, and that there aren't any faces whole normal deviates much from the z direction (if you create the surface with offset > 0, this should be okay).

Coordinate system is for the creation of the piston (which is a member of the layerAR class). As long as the coordinate system is aligned with your simulation domain (which looks like what you have done).

Hope this helps! Note that the entire engine library can be ported to work with 2.1.x.

u22 December 13, 2012 05:10

2 Attachment(s)
mturcios777, thanks for your comment!

So, my setup in engineGeometry looks reasonable for me. But i still get FPE in layer addition. And no printStack output...

I attached a mesh and pistonLayer facezone pictures for last saved CAD (deformAngle=20)

Why OpenFoam does not produce printStack output in that case?

How to debug what goes wrong with layer addition?

---After a while----

I discover, that moveDyMEngineMesh works fine when it start adding layers after deformAngle CAD.

And dieselEngineDyMFoam crashes in layerAR.C, in

autoPtr<mapPolyMesh> topoChangeMap = topoChanger_.changeMesh();


mturcios777 December 13, 2012 13:26

Ok, I'm assuming that the flat faces above your piston patch are the faceZone, so they look good. Not sure why the stack trace isn't output, though since the error looks like its occurring inside layerAR, you should probably turn on the debug options for polyTopoChange, polyTopoChanger, layerAdditionRemoval and dynamicMesh.

I would also recommend removing the cell/face/pointZones and meshModifiers file in your starting mesh every time until you are sure that the problem isn't from the mesh. It doesn't take that long to regenerate them when you start the simulation, plus if you've made changes to the layerAR in engineGeometry, it won't be updated until you delete all those files (have a look at addLayerARMeshModifiers.C).

Also, try switch to a cartesian coordinate system. You'll definitely need to remove the zones and modifiers to see the change (if any).

u22 December 14, 2012 06:35

Marco, thanks for help again.

1. I run simulation from -180 with cartesian CS and get same error
2. I compiled OF 1.6-ext with DEBUG , but didn't get no additional output in log file
how to switch on debug for polyTopoChange and etc.? I see many of "if(debug) ..." lines there

3. moveDyMEngineMesh works fine for my case. WHY? This is realy bother me.

4. May be, I need some additonal changes in dieselEngineFoam.C, not only replacing mesh.move() by mesh.Update().

code in sonicTurbDyMEngineFoam looks more sofisticated then just "mesh.Update".

Could you share your version of dieselEngineDyMFoam please...? Or working cases for this solver..

mturcios777 December 14, 2012 13:18

There are additional debug flags in the etc/controlDict file. As for moveDyMEngineMesh, remember that only the mesh is being changed, so its possible that the crash is ocurring after the mesh has been changed.

I don't have dieselDyMEngineFoam, but I was working on a sprayDyMFoam, which pretty much has the same changes that you need to make. Its posted on the Mantis site:

Good luck!

u22 December 17, 2012 02:26

Thanks, Marco! I enable additional debug flags in etc/controlDict. There is tail of log output:
const polyTopoChange& ref
) : completed topological change.

void polyTopoChanger::update(const mapPolyMesh& m) : Updating mesh modifiers
layerAdditionRemoval::updateMesh(const mapPolyMesh&) for object pistonLayer : Clearing addressing on external request. Pointers not set.

void polyMesh::setInstance(const fileName& inst) : Resetting file instance to "22.93"
void polyMesh::setMotionWriteOpt(IOobject::writeOption) Setting motion writeOpt to 0
void polyMesh::setTopoWriteOpt(IOobject::writeOption) Setting topo writeOpt to 0
Updating object pointMesh
Updating object volPointInterpolation
volPointInterpolation::makeWeights() : constructing weighting factors
volPointInterpolation::makeWeights() : 1
volPointInterpolation::makeWeights() : 2
Floating point exception
So, FPE generated in volPointInterpolation::makeWeights(), in following code
(i think, divide by zero). May be an error in my case setup? Is it mesh related problem?

if (debug) Info<< "volPointInterpolation::makeWeights() : 2" << endl;

// Calculate inverse distances between cell centres and points
// and store in weighting factor array
forAll(points, pointi)
scalarList& pw = pointWeights_[pointi];
const labelList& pcp = pointCells[pointi];

forAll(pcp, pointCelli)
pw[pointCelli] =
1.0/mag(points[pointi] - cellCentres[pcp[pointCelli]]);

sumWeights[pointi] += pw[pointCelli];

mturcios777 December 17, 2012 13:21

The divide by zero makes sense as far as where the error is ocurring. Not sure as to why, but most likely a mesh generation error. I can't remember the last time (or if ever) I tried layerAR on a sector mesh with periodic boundaries (it may be possible it doesn't work).

Could you make a simple flat piston mesh (use same angle for sector mesh) and try layerAR there with offset = 0? Then try it full cylinder with the same flat piston. Based on these tests we can figure out what the problem is. I'll see if I have an old cylinder mesh somewhere, but it may be faster for you to make your own.

Also, please send me a picture of the faceZone that is being used to create the layers.

u22 December 18, 2012 23:37

3 Attachment(s)
Dear Marco,

I construct cylindrical mesh for 45 degree sector and full 3d without cyclic BC.
Unfortunately, I got same errors. I enlarge the clearance and use zero offset. Here is pictures for last saved CA (23 degree). Piston patch looks equal pistonLayer faceZone...

There is post by Abhishekd18 with the same error volPointInterpolation::makeWeights() : constructing weighting factors

I guess, he used same "scania" case as I (by N. Nordin, without layerAR) and case conversion to 1.6 ext was not completed in right way...

May you have a look on case files??

This error not only IC-related, Look at here

mturcios777 December 19, 2012 13:38

Thanks for the files, but your points file appears to be missing; can you double check your case and re-submit it?

u22 December 20, 2012 01:23

Hello Marco,

There is small file limit on the forum, i put files on file hosting here

u22 December 23, 2012 22:49

So, one of possible solutions been found Next step - to check whether the solver with layerAR to work in parallel.

seju August 11, 2014 11:27


Originally Posted by u22 (Post 398839)
So, one of possible solutions been found Next step - to check whether the solver with layerAR to work in parallel.

I wanna compile dieselEngineDyMFoam .
plz help me how can I do it?
best regards

zhangyan January 15, 2017 04:14

I also met the same FPE problem after the first layer addition.
Have you got a solution?

zhangyan March 24, 2017 11:13


Originally Posted by zhangyan (Post 633320)
I also met the same FPE problem after the first layer addition.
Have you got a solution?


All times are GMT -4. The time now is 14:07.