From 6fdda583c22d6dd93a2247a3d358cd253b5484d3 Mon Sep 17 00:00:00 2001 From: Daniel <2929574+danielque@users.noreply.github.com> Date: Fri, 18 Mar 2022 13:25:04 +0100 Subject: [PATCH] fix deadlock in IOModel force construction of face-diagonal decomposition (called from all procs!) before call of particle constructor (potentially not on all procs!) to avoid blocking sync operation, when it looks for tet face index and tet point index. fix #131 --- .../subModels/IOModel/IOModel/IOModel.C | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/lagrangian/cfdemParticle/subModels/IOModel/IOModel/IOModel.C b/src/lagrangian/cfdemParticle/subModels/IOModel/IOModel/IOModel.C index ce63280d..d0396774 100644 --- a/src/lagrangian/cfdemParticle/subModels/IOModel/IOModel/IOModel.C +++ b/src/lagrangian/cfdemParticle/subModels/IOModel/IOModel/IOModel.C @@ -125,6 +125,14 @@ void IOModel::streamDataToPath(const fileName& path, const double* const* array, else fileStream << "{}" << "\n"; return; } +#if OPENFOAM_VERSION_MAJOR > 4 + else if (type == "position") + { + // Force construction of face-diagonal decomposition before construction + // of particle which uses parallel transfers. + (void)particleCloud_.mesh().tetBasePtIs(); + } +#endif fileStream << token::BEGIN_LIST << nl; @@ -139,19 +147,24 @@ void IOModel::streamDataToPath(const fileName& path, const double* const* array, } else if (type == "position") { -#if OPENFOAM_VERSION_MAJOR < 5 - fileStream << "( " << array[index][0] << " " << array[index][1] << " " << array[index][2] << " ) " << cellIDs[index][0] << nl; -#else - particle part - ( - particleCloud_.mesh(), - vector(array[index][0],array[index][1],array[index][2]), - cellIDs[index][0] - ); +#if OPENFOAM_VERSION_MAJOR > 4 + if (true) + { + particle part + ( + particleCloud_.mesh(), + vector(array[index][0],array[index][1],array[index][2]), + cellIDs[index][0] + ); - part.writePosition(fileStream); - fileStream << nl; + part.writePosition(fileStream); + fileStream << nl; + } + else #endif + { + fileStream << "( " << array[index][0] << " " << array[index][1] << " " << array[index][2] << " ) " << cellIDs[index][0] << nl; + } } else if (type == "vector") {