diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C index 2407bc5635fbcfb83836c6739718178c30a30246..4c30b4e0d1686eccfcdba0695b0c6bb5f199943a 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C @@ -188,15 +188,70 @@ void Foam::processorPolyPatch::calcGeometry(PstreamBuffers& pBufs) //Pout<< "processorPolyPatch::calcGeometry() : received data for " // << neighbFaceCentres_.size() << " faces." << endl; - calcGeometry + // My normals + vectorField faceNormals(size()); + + // Neighbour normals + vectorField nbrFaceNormals(neighbFaceAreas_.size()); + + // Calculate normals from areas and check + forAll(faceNormals, facei) + { + scalar magSf = mag(faceAreas()[facei]); + scalar nbrMagSf = mag(neighbFaceAreas_[facei]); + scalar avSf = (magSf + nbrMagSf)/2.0; + + if (magSf < ROOTVSMALL && nbrMagSf < ROOTVSMALL) + { + // Undetermined normal. Use dummy normal to force separation + // check. (note use of sqrt(VSMALL) since that is how mag + // scales) + faceNormals[facei] = point(1, 0, 0); + nbrFaceNormals[facei] = faceNormals[facei]; + } + else if (mag(magSf - nbrMagSf)/avSf > coupledPolyPatch::matchTol) + { + fileName nm + ( + boundaryMesh().mesh().time().path() + /name()+"_faces.obj" + ); + Pout<< "processorPolyPatch::order : Writing my " << size() + << " faces to OBJ file " << nm << endl; + writeOBJ(nm, *this, points()); + + FatalErrorIn + ( + "processorPolyPatch::calcGeometry()" + ) << "face " << facei << " area does not match neighbour by " + << 100*mag(magSf - nbrMagSf)/avSf + << "% -- possible face ordering problem." << endl + << "patch:" << name() + << " my area:" << magSf + << " neighbour area:" << nbrMagSf + << " matching tolerance:" << coupledPolyPatch::matchTol + << endl + << "Mesh face:" << start()+facei + << " vertices:" + << UIndirectList<point>(points(), operator[](facei))() + << endl + << "Rerun with processor debug flag set for" + << " more information." << exit(FatalError); + } + else + { + faceNormals[facei] = faceAreas()[facei]/magSf; + nbrFaceNormals[facei] = neighbFaceAreas_[facei]/nbrMagSf; + } + } + + calcTransformTensors ( - *this, faceCentres(), - faceAreas(), - faceCellCentres()(), neighbFaceCentres_, - neighbFaceAreas_, - neighbFaceCellCentres_ + faceNormals, + nbrFaceNormals, + calcFaceTol(*this, points(), faceCentres()) ); //Pout<< "**neighbFaceCentres_:" << neighbFaceCentres_ << endl; //Pout<< "**neighbFaceAreas_:" << neighbFaceAreas_ << endl;