View Issue Details

IDProjectCategoryView StatusLast Update
0002286OpenFOAM[All Projects] Bugpublic2016-11-18 14:36
ReportertniemiAssigned Tohenry 
Status resolvedResolutionfixed 
Product Versiondev 
Fixed in Versiondev 
Summary0002286: PatchInjectionBase: inaccurate initialization of tetFaceI and tetPtI
DescriptionIn PatchInjectionBase.C lines 211-212, the tetFaceI and tetPtI of the injected parcel are initialized to arbitrary values. In the comment it is said that the tracking should handle them in the first step. However, in my tests I have found out that this is not true and the wrongly initialized tetFaceI and tetPtI can cause a lot of tracking issues.

I have attached a simple fix, where tetFaceI and tetPtI are initialized to correct values with mesh.findTetFacePt. This seems to greatly reduce the amount of tracking rescues needed. In an earlier bug report (, 30 % of parcels will get stuck in a very simple mesh. After this patch no particles get stuck even if tracking rescues are disabled.

I have not thoroughly tested this yet, but in a few test cases it has worked well.
TagsNo tags attached.



2016-10-07 12:16


patchInjectionBase.C (6,572 bytes)


2016-10-07 14:26

reporter   ~0006979

Hmm, in a more complex test case the patched code crashed, because the cell of the parcel had changed due to the perturbation of its position. Changing the findTetFacePt to findCellFacePt seemed to help.

I guess this needs more testing. In any case the logic in patchInjectionBase seems quite dangerous to me.


2016-10-07 16:11

reporter   ~0006980

With findCellFacePt the code seems to work in several more complex test cases, but there is some unnecessary overhead because usually the cell does not change and searching for it is not needed. Also I'm not sure, but I think that it might be even possible that the parcel gets pushed out of the domain when it is perturbed. In such a case even findCellFacePt won't probably work.

Perhaps a following strategy could be used?

1. Try to use findTetFacePt
2. If step 1 fails, the parcel is likely in another cell or out of the domain. Move the parcel to the center of the cell and try findTetFacePt again.
3. As a final fallback we could revert to the current method, ie. choose an arbitrary tet and hope that the tracking algorithm can rescue the parcel

In any case the current situation, where the tetFaceI and tetPtI are random and even the cell can be different than what the parcel thinks it is, is very demanding to the tracking algorithm.


2016-10-07 16:46

manager   ~0006981

I agree that the current approach of hoping that the tracking algorithm will rescue the parcel if it is not in the cell it is supposed to be in is VERY poor and should be replaced. The problem with the "move the parcel to the center of the cell" is that in DEM the particle may overlap with an existing particle and in the first time-step they repel eachother at the speed of light or greater.


2016-10-11 13:03


patchInjectionBase_rand.H (3,996 bytes)


2016-10-11 13:03


patchInjectionBase_rand.C (8,001 bytes)


2016-10-11 13:06

reporter   ~0007000

Yes, with DEM there could be problems... How about randomizing the position instead of using the cell centre in cases where the normal perturbation does not work? Of course this doesn't prevent overlap but it would make it less probable.

I have attached a modified patchInjectionBase with randomizing code taken from CellZoneInjection. I have not yet tested it thoroughly, but in a few test cases (steady state, no DEM) it has worked ok with a clear reduction in the amount of stalled parcels (=parcels requiring more than 1 sequential rescue).


2016-11-17 16:21

manager   ~0007226

Are you satisfied with the tests of new patchInjectionBase with randomized location? If so I will merge the change into OpenFOAM-dev.


2016-11-18 06:57

reporter   ~0007236

Yes, I have had the modified code running for a while now and I have not encountered any issues.


2016-11-18 14:36

manager   ~0007242

Resolved in OpenFOAM-dev by commit 2001653352040f4020b598742de4e7efafdc2379

Issue History

Date Modified Username Field Change
2016-10-07 12:16 tniemi New Issue
2016-10-07 12:16 tniemi File Added: patchInjectionBase.C
2016-10-07 14:26 tniemi Note Added: 0006979
2016-10-07 16:11 tniemi Note Added: 0006980
2016-10-07 16:46 henry Note Added: 0006981
2016-10-11 13:03 tniemi File Added: patchInjectionBase_rand.H
2016-10-11 13:03 tniemi File Added: patchInjectionBase_rand.C
2016-10-11 13:06 tniemi Note Added: 0007000
2016-11-17 16:21 henry Note Added: 0007226
2016-11-18 06:57 tniemi Note Added: 0007236
2016-11-18 14:36 henry Assigned To => henry
2016-11-18 14:36 henry Status new => resolved
2016-11-18 14:36 henry Resolution open => fixed
2016-11-18 14:36 henry Fixed in Version => dev
2016-11-18 14:36 henry Note Added: 0007242