From 01fb221ee3104d481c8f43a09ec713ee0172562e Mon Sep 17 00:00:00 2001 From: Henrik Rusche Date: Wed, 2 Aug 2017 18:56:55 +0200 Subject: [PATCH 1/3] Bugfix: Injection model hangs on parallel --- .../Kinematic/InjectionModel/InjectionModel/InjectionModel.C | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.C index 163edf3bf..c876169b0 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.C @@ -137,6 +137,8 @@ void Foam::InjectionModel::findCellAtPosition bool foundCell = false; + // Force creation of mesh.C() to avoid dead-lock in comms + owner_.mesh().C(); cellI = owner_.mesh().findCell(position); if (cellI >= 0) From 71983fec41a63843e687894f1c098f771a715cc4 Mon Sep 17 00:00:00 2001 From: Henrik Rusche Date: Wed, 13 Sep 2017 12:26:36 +0200 Subject: [PATCH 2/3] Bugfix: reactingParcelFoam/evaporationTest tut hangs in parallel --- .../meshes/primitiveMesh/primitiveMeshFindCell.C | 10 ++++++---- src/lagrangian/basic/Particle/Particle.C | 2 +- src/lagrangian/basic/Particle/ParticleI.H | 14 ++++++++++++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/foam/meshes/primitiveMesh/primitiveMeshFindCell.C b/src/foam/meshes/primitiveMesh/primitiveMeshFindCell.C index 591ad8a09..747ac8ac5 100644 --- a/src/foam/meshes/primitiveMesh/primitiveMeshFindCell.C +++ b/src/foam/meshes/primitiveMesh/primitiveMeshFindCell.C @@ -48,8 +48,6 @@ bool Foam::primitiveMesh::pointInCell(const point& p, label celli) const const vectorField& cf = faceCentres(); const vectorField& Sf = faceAreas(); - bool inCell = true; - forAll(f, facei) { label nFace = f[facei]; @@ -59,10 +57,14 @@ bool Foam::primitiveMesh::pointInCell(const point& p, label celli) const { normal = -normal; } - inCell = inCell && ((normal & proj) <= 0); + + if ((normal & proj) > 0) + { + return false; + } } - return inCell; + return true; } diff --git a/src/lagrangian/basic/Particle/Particle.C b/src/lagrangian/basic/Particle/Particle.C index 2cee8dfa4..06f54532d 100644 --- a/src/lagrangian/basic/Particle/Particle.C +++ b/src/lagrangian/basic/Particle/Particle.C @@ -376,7 +376,7 @@ Foam::scalar Foam::Particle::trackToFace ); } else - { + { p.hitPatch(patch, td); } } diff --git a/src/lagrangian/basic/Particle/ParticleI.H b/src/lagrangian/basic/Particle/ParticleI.H index fbecf43b8..ff864dbaf 100644 --- a/src/lagrangian/basic/Particle/ParticleI.H +++ b/src/lagrangian/basic/Particle/ParticleI.H @@ -37,6 +37,7 @@ inline Foam::scalar Foam::Particle::lambda ) const { const polyMesh& mesh = cloud_.polyMesh_; + const polyBoundaryMesh& patches = mesh.boundaryMesh(); bool movingMesh = mesh.moving(); if (movingMesh) @@ -46,7 +47,11 @@ inline Foam::scalar Foam::Particle::lambda vector Cf = mesh.faceCentres()[facei]; // move reference point for wall - if (!cloud_.internalFace(facei)) + if + ( + !cloud_.internalFace(facei) + && isA(patches[cloud_.facePatch(facei)]) + ) { const vector& C = mesh.cellCentres()[celli_]; scalar CCf = mag((C - Cf) & Sf); @@ -184,13 +189,18 @@ inline Foam::scalar Foam::Particle::lambda ) const { const polyMesh& mesh = cloud_.polyMesh_; + const polyBoundaryMesh& patches = mesh.boundaryMesh(); vector Sf = mesh.faceAreas()[facei]; Sf /= mag(Sf); vector Cf = mesh.faceCentres()[facei]; // move reference point for wall - if (!cloud_.internalFace(facei)) + if + ( + !cloud_.internalFace(facei) + && isA(patches[cloud_.facePatch(facei)]) + ) { const vector& C = mesh.cellCentres()[celli_]; scalar CCf = mag((C - Cf) & Sf); From aaf0bf5037e590cdfb10d900b842b0ba911e14ed Mon Sep 17 00:00:00 2001 From: Henrik Rusche Date: Wed, 3 May 2017 21:47:04 +0200 Subject: [PATCH 3/3] BUGFIX: Enable point interpolation with global non-blocking comms --- .../processor/ProcessorPointPatchField.C | 108 ++++++++++++------ .../processor/ProcessorPointPatchField.H | 6 + 2 files changed, 76 insertions(+), 38 deletions(-) diff --git a/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.C b/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.C index 01aaf3aa6..263e1020e 100644 --- a/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.C +++ b/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.C @@ -84,7 +84,7 @@ sendField //HJ: This needs complete rewrite: // - move communications into a patch - // - allow for various types of communication + // - allow for various types of communication - done HR, 12/6/2017 // HJ, 15/Apr/2009 if (commsType == Pstream::blocking || commsType == Pstream::scheduled) @@ -101,6 +101,7 @@ sendField { resizeBuf(receiveBuf_, f.size()*sizeof(Type)); + outstandingRecvRequest_ = Pstream::nRequests(); IPstream::read ( commsType, @@ -112,6 +113,7 @@ sendField resizeBuf(sendBuf_, f.byteSize()); memcpy(sendBuf_.begin(), f.begin(), f.byteSize()); + outstandingSendRequest_ = Pstream::nRequests(); OPstream::write ( commsType, @@ -127,22 +129,6 @@ sendField << exit(FatalError); } - // Not using non-blocking comms -// if (commsType == Pstream::nonBlocking) -// { -// FatalErrorIn("void ProcessorPointPatchField::sendField") -// << "Non-blocking comms not implemented" -// << abort(FatalError); -// } - -// OPstream::write -// ( -// commsType, -// procPatch_.neighbProcNo(), -// reinterpret_cast(f.begin()), -// f.byteSize() -// ); - tf.clear(); } @@ -167,13 +153,36 @@ receivePointField { tmp > tf(new Field(this->size())); - IPstream::read - ( - commsType, - procPatch_.neighbProcNo(), - reinterpret_cast(tf().begin()), - tf().byteSize() - ); + if (Pstream::parRun()) + { + if (commsType == Pstream::nonBlocking) + { + // Receive into tf + + if + ( + outstandingRecvRequest_ >= 0 + && outstandingRecvRequest_ < Pstream::nRequests() + ) + { + Pstream::waitRequest(outstandingRecvRequest_); + } + outstandingSendRequest_ = -1; + outstandingRecvRequest_ = -1; + + memcpy(tf().begin(), receiveBuf_.begin(), tf().byteSize()); + } + else + { + IPstream::read + ( + commsType, + procPatch_.neighbProcNo(), + reinterpret_cast(tf().begin()), + tf().byteSize() + ); + } + } return tf; } @@ -202,13 +211,36 @@ receiveEdgeField new Field(procPatch_.localEdgeIndices().size()) ); - IPstream::read - ( - commsType, - procPatch_.neighbProcNo(), - reinterpret_cast(tf().begin()), - tf().byteSize() - ); + if (Pstream::parRun()) + { + if (commsType == Pstream::nonBlocking) + { + // Receive into tf + + if + ( + outstandingRecvRequest_ >= 0 + && outstandingRecvRequest_ < Pstream::nRequests() + ) + { + Pstream::waitRequest(outstandingRecvRequest_); + } + outstandingSendRequest_ = -1; + outstandingRecvRequest_ = -1; + + memcpy(tf().begin(), receiveBuf_.begin(), tf().byteSize()); + } + else + { + IPstream::read + ( + commsType, + procPatch_.neighbProcNo(), + reinterpret_cast(tf().begin()), + tf().byteSize() + ); + } + } return tf; } @@ -470,7 +502,7 @@ initEvaluate { if (this->isPointField()) { - initAddFieldTempl(Pstream::blocking, this->internalField()); + initAddFieldTempl(commsType, this->internalField()); } } } @@ -551,7 +583,7 @@ ProcessorPointPatchField :: initAddField() const { - initAddFieldTempl(Pstream::blocking, this->internalField()); + initAddFieldTempl(Pstream::defaultComms(), this->internalField()); } @@ -570,7 +602,7 @@ ProcessorPointPatchField :: addField(Field& f) const { - addFieldTempl(Pstream::blocking, f); + addFieldTempl(Pstream::defaultComms(), f); } @@ -636,7 +668,7 @@ ProcessorPointPatchField :: initAddDiag(const scalarField& d) const { - initAddFieldTempl(Pstream::blocking, d); + initAddFieldTempl(Pstream::defaultComms(), d); } @@ -655,7 +687,7 @@ ProcessorPointPatchField :: initAddSource(const scalarField& s) const { - initAddFieldTempl(Pstream::blocking, s); + initAddFieldTempl(Pstream::defaultComms(), s); } @@ -674,7 +706,7 @@ ProcessorPointPatchField :: addDiag(scalarField& d) const { - addFieldTempl(Pstream::blocking, d); + addFieldTempl(Pstream::defaultComms(), d); } @@ -693,7 +725,7 @@ ProcessorPointPatchField :: addSource(scalarField& s) const { - addFieldTempl(Pstream::blocking, s); + addFieldTempl(Pstream::defaultComms(), s); } diff --git a/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.H b/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.H index cdbf8673c..8f42cc7d4 100644 --- a/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.H +++ b/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.H @@ -75,6 +75,12 @@ class ProcessorPointPatchField // Non-blocking parallel communications // Temporary: move to patch. HJ, 15/Apr/2008 + //- Outstanding request + mutable label outstandingSendRequest_; + + //- Outstanding request + mutable label outstandingRecvRequest_; + //- Send buffer. // Only sized and used when compressed or non-blocking comms used. mutable List sendBuf_;