diff --git a/src/dynamicMesh/motionSolver/displacement/displacementMotionSolver.C b/src/dynamicMesh/motionSolver/displacement/displacementMotionSolver.C index 9330b5b35a39c6bd39650df827ae6f8ccfa3441b..6d759d96477feda464353f0b37431e3123a0a8dc 100644 --- a/src/dynamicMesh/motionSolver/displacement/displacementMotionSolver.C +++ b/src/dynamicMesh/motionSolver/displacement/displacementMotionSolver.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,6 +34,76 @@ namespace Foam } +// * * * * * * * * * * * * * Protected Data Members * * * * * * * * * * * * * // + +Foam::IOobject Foam::displacementMotionSolver::points0IO +( + const polyMesh& mesh +) const +{ + const word instance = + time().findInstance + ( + mesh.meshDir(), + "points0", + IOobject::READ_IF_PRESENT + ); + + if (instance != time().constant()) + { + // points0 written to a time folder + + return + IOobject + ( + "points0", + instance, + polyMesh::meshSubDir, + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); + } + else + { + // check that points0 are actually in constant directory + + IOobject io + ( + "points0", + instance, + polyMesh::meshSubDir, + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); + + if (io.headerOk()) + { + return io; + } + else + { + // copy of original mesh points + + return + IOobject + ( + "points", + instance, + polyMesh::meshSubDir, + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); + } + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::displacementMotionSolver::displacementMotionSolver @@ -49,29 +119,14 @@ Foam::displacementMotionSolver::displacementMotionSolver IOobject ( "pointDisplacement", - mesh.time().timeName(), + time().timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), pointMesh::New(mesh) ), - points0_ - ( - pointIOField - ( - IOobject - ( - "points", - mesh.time().constant(), - polyMesh::meshSubDir, - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ) - ) + points0_(pointIOField(points0IO(mesh))) { if (points0_.size() != mesh.nPoints()) { @@ -81,7 +136,8 @@ Foam::displacementMotionSolver::displacementMotionSolver "displacementMotionSolver\n" "(\n" " const polyMesh&,\n" - " const IOdictionary&\n" + " const IOdictionary&,\n" + " const word&\n" ")" ) << "Number of points in mesh " << mesh.nPoints() << " differs from number of points " << points0_.size() @@ -90,7 +146,7 @@ Foam::displacementMotionSolver::displacementMotionSolver IOobject ( "points", - mesh.time().constant(), + time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, @@ -118,7 +174,7 @@ void Foam::displacementMotionSolver::movePoints(const pointField&) void Foam::displacementMotionSolver::updateMesh(const mapPolyMesh& mpm) { - // pointMesh already updates pointFields. + // pointMesh already updates pointFields motionSolver::updateMesh(mpm); @@ -136,7 +192,7 @@ void Foam::displacementMotionSolver::updateMesh(const mapPolyMesh& mpm) // Note: boundBox does reduce const vector span0 = boundBox(points0_).span(); - const vector span = boundBox(points).span(); + const vector span = boundBox(points).span(); vector scaleFactors(cmptDivide(span0, span)); @@ -156,11 +212,11 @@ void Foam::displacementMotionSolver::updateMesh(const mapPolyMesh& mpm) } else { - // New point. Assume motion is scaling. + // New point - assume motion is scaling newPoints0[pointI] = points0_[oldPointI] + cmptMultiply ( scaleFactors, - points[pointI]-points[masterPointI] + points[pointI] - points[masterPointI] ); } } @@ -170,12 +226,21 @@ void Foam::displacementMotionSolver::updateMesh(const mapPolyMesh& mpm) ( "displacementMotionSolver::updateMesh" "(const mapPolyMesh&)" - ) << "Cannot work out coordinates of introduced vertices." - << " New vertex " << pointI << " at coordinate " + ) << "Cannot determine co-ordinates of introduced vertices." + << " New vertex " << pointI << " at co-ordinate " << points[pointI] << exit(FatalError); } } + + twoDCorrectPoints(newPoints0); + points0_.transfer(newPoints0); + + // points0 changed - set to write and check-in to database + points0_.rename("points0"); + points0_.writeOpt() = IOobject::AUTO_WRITE; + points0_.instance() = time().timeName(); + points0_.checkIn(); } diff --git a/src/dynamicMesh/motionSolver/displacement/displacementMotionSolver.H b/src/dynamicMesh/motionSolver/displacement/displacementMotionSolver.H index ad7aa193b9a925953bb61ab15953610829fda4f5..810aae068c9cb8a3658328ffbd6b5552f0f7f578 100644 --- a/src/dynamicMesh/motionSolver/displacement/displacementMotionSolver.H +++ b/src/dynamicMesh/motionSolver/displacement/displacementMotionSolver.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -40,6 +40,7 @@ SourceFiles #include "motionSolver.H" #include "pointFields.H" +#include "pointIOField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -63,21 +64,22 @@ protected: //- Point motion field mutable pointVectorField pointDisplacement_; -private: + //- Starting points + pointIOField points0_; - // Private data - //- Starting points - pointField points0_; + // Protected Member Functions + + //- Return IO object for points0 + IOobject points0IO(const polyMesh& mesh) const; + +private: // Private Member Functions //- Disallow default bitwise copy construct - displacementMotionSolver - ( - const displacementMotionSolver& - ); + displacementMotionSolver(const displacementMotionSolver&); //- Disallow default bitwise assignment void operator=(const displacementMotionSolver&);