From 379eac4f743753f9ad18b0b58bbf8574c0a2bff6 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Mon, 8 Feb 2010 11:12:52 +0000 Subject: [PATCH] BUG: meshes with differing pointsInstance and facesInstance were not decomposed correctly. In case of differing pointsInstance and facesInstance it will - read the points belonging to the facesInstance - construct and write the mesh belonging to the facesInstance (so with the old, facesInstance, points) - additionally write the current points to pointsInstance --- .../decomposePar/domainDecomposition.C | 107 ++++++++++++++++-- .../decomposePar/domainDecomposition.H | 3 + .../displacementFvMotionSolver.C | 28 ++++- 3 files changed, 125 insertions(+), 13 deletions(-) diff --git a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C index c7489886abd..1fc35607632 100644 --- a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C +++ b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C @@ -69,6 +69,24 @@ void Foam::domainDecomposition::mark Foam::domainDecomposition::domainDecomposition(const IOobject& io) : fvMesh(io), + facesInstancePointsPtr_ + ( + pointsInstance() != facesInstance() + ? new pointIOField + ( + IOobject + ( + "points", + facesInstance(), + polyMesh::meshSubDir, + *this, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ) + : NULL + ), decompositionDict_ ( IOobject @@ -262,20 +280,65 @@ bool Foam::domainDecomposition::writeDecomposition() "system", "constant" ); + processorDb.setTime(time()); - // create the mesh - polyMesh procMesh - ( - IOobject + // create the mesh. Two situations: + // - points and faces come from the same time ('instance'). The mesh + // will get constructed in the same instance. + // - points come from a different time (moving mesh cases). + // It will read the points belonging to the faces instance and + // construct the procMesh with it which then gets handled as above. + // (so with 'old' geometry). + // Only at writing time will it additionally write the current + // points. + + autoPtr<polyMesh> procMeshPtr; + + if (facesInstancePointsPtr_.valid()) + { + // Construct mesh from facesInstance. + pointField facesInstancePoints ( - this->polyMesh::name(), // region name of undecomposed mesh - pointsInstance(), - processorDb - ), - xferMove(procPoints), - xferMove(procFaces), - xferMove(procCells) - ); + facesInstancePointsPtr_(), + curPointLabels + ); + + procMeshPtr.reset + ( + new polyMesh + ( + IOobject + ( + this->polyMesh::name(), // region of undecomposed mesh + facesInstance(), + processorDb + ), + xferMove(facesInstancePoints), + xferMove(procFaces), + xferMove(procCells) + ) + ); + } + else + { + procMeshPtr.reset + ( + new polyMesh + ( + IOobject + ( + this->polyMesh::name(), // region of undecomposed mesh + facesInstance(), + processorDb + ), + xferMove(procPoints), + xferMove(procFaces), + xferMove(procCells) + ) + ); + } + polyMesh& procMesh = procMeshPtr(); + // Create processor boundary patches const labelList& curPatchSizes = procPatchSize_[procI]; @@ -584,6 +647,26 @@ bool Foam::domainDecomposition::writeDecomposition() procMesh.write(); + // Write points if pointsInstance differing from facesInstance + if (facesInstancePointsPtr_.valid()) + { + pointIOField pointsInstancePoints + ( + IOobject + ( + "points", + pointsInstance(), + polyMesh::meshSubDir, + procMesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + xferMove(procPoints) + ); + pointsInstancePoints.write(); + } + Info<< endl << "Processor " << procI << nl << " Number of cells = " << procMesh.nCells() diff --git a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.H b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.H index 80ad1da2396..3c871420170 100644 --- a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.H +++ b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.H @@ -55,6 +55,9 @@ class domainDecomposition { // Private data + //- Optional: points at the facesInstance + autoPtr<pointIOField> facesInstancePointsPtr_; + //- Mesh decomposition control dictionary IOdictionary decompositionDict_; diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.C index aa3d51bd4f6..61e2f9ad3a0 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.C @@ -61,7 +61,33 @@ Foam::displacementFvMotionSolver::displacementFvMotionSolver ) ) ) -{} +{ + if (points0_.size() != mesh.nPoints()) + { + FatalErrorIn + ( + "displacementFvMotionSolver::displacementFvMotionSolver\n" + "(\n" + " const polyMesh&,\n" + " Istream&\n" + ")" + ) << "Number of points in mesh " << mesh.nPoints() + << " differs from number of points " << points0_.size() + << " read from file " + << + IOobject + ( + "points", + mesh.time().constant(), + polyMesh::meshSubDir, + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ).filePath() + << exit(FatalError); + } +} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -- GitLab