From e4b4bf2bf09ca65209e16f47e33a6df48798fe99 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 4 Mar 2010 15:03:10 +0000 Subject: [PATCH 1/8] ENH: UIPstream when reaches eof deletes the underlying buffer. Only in PstreamBuffers mode. This makes sure that data from other processors already handled gets deleted. --- src/OpenFOAM/db/IOstreams/Pstreams/IPstream.C | 12 +++++++++++- src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C | 15 +++++++++++++++ src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H | 8 ++++++++ src/Pstream/dummy/UIPread.C | 3 +++ src/Pstream/mpi/UIPread.C | 3 +++ 5 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.C index 8842768098..087028c3d2 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.C @@ -38,7 +38,17 @@ Foam::IPstream::IPstream ) : Pstream(commsType, bufSize), - UIPstream(commsType, fromProcNo, buf_, externalBufPosition_), + UIPstream + ( + commsType, + fromProcNo, + buf_, + externalBufPosition_, + UPstream::msgType(), // tag + false, // do not clear buf_ if at end + format, + version + ), externalBufPosition_(0) {} diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C index f4c37633f3..b644942c73 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C @@ -77,6 +77,21 @@ inline void Foam::UIPstream::readFromBuffer } +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::UIPstream::~UIPstream() +{ + if (clearAtEnd_ && eof()) + { + if (debug) + { + Pout<< "UIPstream::~UIPstream() : clearing externalBuf_ of size " + << externalBuf_.size() << endl; + } + externalBuf_.clearStorage(); + } +} + // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // Foam::Istream& Foam::UIPstream::read(token& t) diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H index 30e4e96119..b4f084baed 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H @@ -67,6 +67,8 @@ class UIPstream const int tag_; + const bool clearAtEnd_; + label messageSize_; @@ -96,6 +98,7 @@ public: DynamicList& externalBuf, label& externalBufPosition, const int tag = UPstream::msgType(), + const bool clearAtEnd = false, // destroy externalBuf if at end streamFormat format=BINARY, versionNumber version=currentVersion ); @@ -104,6 +107,11 @@ public: UIPstream(const int fromProcNo, PstreamBuffers&); + // Destructor + + ~UIPstream(); + + // Member functions // Inquiry diff --git a/src/Pstream/dummy/UIPread.C b/src/Pstream/dummy/UIPread.C index da9613af37..c21a7e77b5 100644 --- a/src/Pstream/dummy/UIPread.C +++ b/src/Pstream/dummy/UIPread.C @@ -38,6 +38,7 @@ Foam::UIPstream::UIPstream DynamicList& externalBuf, label& externalBufPosition, const int tag, + const bool clearAtEnd, streamFormat format, versionNumber version ) @@ -48,6 +49,7 @@ Foam::UIPstream::UIPstream externalBuf_(externalBuf), externalBufPosition_(externalBufPosition), tag_(tag), + clearAtEnd_(clearAtEnd), messageSize_(0) { notImplemented @@ -59,6 +61,7 @@ Foam::UIPstream::UIPstream "DynamicList&," "label&," "const int tag," + "const bool," "streamFormat, versionNumber" ")" ); diff --git a/src/Pstream/mpi/UIPread.C b/src/Pstream/mpi/UIPread.C index 9a70f456b9..28c3fe3e55 100644 --- a/src/Pstream/mpi/UIPread.C +++ b/src/Pstream/mpi/UIPread.C @@ -42,6 +42,7 @@ Foam::UIPstream::UIPstream DynamicList& externalBuf, label& externalBufPosition, const int tag, + const bool clearAtEnd, streamFormat format, versionNumber version ) @@ -52,6 +53,7 @@ Foam::UIPstream::UIPstream externalBuf_(externalBuf), externalBufPosition_(externalBufPosition), tag_(tag), + clearAtEnd_(clearAtEnd), messageSize_(0) { setOpened(); @@ -125,6 +127,7 @@ Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers) externalBuf_(buffers.recvBuf_[fromProcNo]), externalBufPosition_(buffers.recvBufPos_[fromProcNo]), tag_(buffers.tag_), + clearAtEnd_(true), messageSize_(0) { if (commsType() != UPstream::scheduled && !buffers.finishedSendsCalled_) From ebcb825fabf561fc06739e8c2a105ccc2dc4e28b Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 9 Mar 2010 13:21:19 +0000 Subject: [PATCH 2/8] BUG: used wrong variable names for faceZones. Did not close file. --- .../dataConversion/foamToTecplot360/foamToTecplot360.C | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C index 2d11a6538d..36d57be60e 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C @@ -1019,6 +1019,7 @@ int main(int argc, char *argv[]) } } writer.writeEnd(); + Info<< endl; @@ -1067,7 +1068,7 @@ int main(int argc, char *argv[]) writer.writeInit ( runTime.caseName(), - cellVarNames, + allVarNames, patchFileName, DataFileType_Full ); @@ -1163,6 +1164,8 @@ int main(int argc, char *argv[]) << nl << endl; } } + writer.writeEnd(); + Info<< endl; } From a3621bd6d126842014a0b6b549e7b4cb27c5acbf Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 9 Mar 2010 13:22:23 +0000 Subject: [PATCH 3/8] ENH: mesh motion on layered meshes. Specifies motion as a set of interpolations on subsets of the mesh. --- src/fvMotionSolver/Make/files | 1 + .../displacementLayeredMotionFvMotionSolver.C | 567 ++++++++++++++++++ .../displacementLayeredMotionFvMotionSolver.H | 187 ++++++ .../layeredSolver/pointEdgeStructuredWalk.C | 54 ++ .../layeredSolver/pointEdgeStructuredWalk.H | 224 +++++++ .../layeredSolver/pointEdgeStructuredWalkI.H | 302 ++++++++++ 6 files changed, 1335 insertions(+) create mode 100644 src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/displacementLayeredMotionFvMotionSolver.C create mode 100644 src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/displacementLayeredMotionFvMotionSolver.H create mode 100644 src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalk.C create mode 100644 src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalk.H create mode 100644 src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalkI.H diff --git a/src/fvMotionSolver/Make/files b/src/fvMotionSolver/Make/files index f229ae322e..44046b57ca 100644 --- a/src/fvMotionSolver/Make/files +++ b/src/fvMotionSolver/Make/files @@ -1,6 +1,7 @@ fvMotionSolvers/fvMotionSolver/fvMotionSolver.C fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.C +fvMotionSolvers/displacement/layeredSolver/displacementLayeredMotionFvMotionSolver.C fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.C fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/displacementLayeredMotionFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/displacementLayeredMotionFvMotionSolver.C new file mode 100644 index 0000000000..f86bd0439e --- /dev/null +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/displacementLayeredMotionFvMotionSolver.C @@ -0,0 +1,567 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "displacementLayeredMotionFvMotionSolver.H" +#include "addToRunTimeSelectionTable.H" +#include "pointEdgeStructuredWalk.H" +#include "pointFields.H" +#include "PointEdgeWave.H" +#include "syncTools.H" +#include "interpolationTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(displacementLayeredMotionFvMotionSolver, 0); + + addToRunTimeSelectionTable + ( + fvMotionSolver, + displacementLayeredMotionFvMotionSolver, + dictionary + ); +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::displacementLayeredMotionFvMotionSolver::calcZoneMask +( + const label cellZoneI, + PackedBoolList& isZonePoint, + PackedBoolList& isZoneEdge +) const +{ + if (cellZoneI == -1) + { + isZonePoint.setSize(mesh().nPoints()); + isZonePoint = 1; + + isZoneEdge.setSize(mesh().nEdges()); + isZoneEdge = 1; + } + else + { + const cellZone& cz = mesh().cellZones()[cellZoneI]; + + label nPoints = 0; + forAll(cz, i) + { + const labelList& cPoints = mesh().cellPoints(cz[i]); + forAll(cPoints, cPointI) + { + if (!isZonePoint[cPoints[cPointI]]) + { + isZonePoint[cPoints[cPointI]] = 1; + nPoints++; + } + } + } + syncTools::syncPointList + ( + mesh(), + isZonePoint, + orEqOp(), + 0 + ); + + + // Mark edge inside cellZone + label nEdges = 0; + forAll(cz, i) + { + const labelList& cEdges = mesh().cellEdges(cz[i]); + forAll(cEdges, cEdgeI) + { + if (!isZoneEdge[cEdges[cEdgeI]]) + { + isZoneEdge[cEdges[cEdgeI]] = 1; + nEdges++; + } + } + } + syncTools::syncEdgeList + ( + mesh(), + isZoneEdge, + orEqOp(), + 0 + ); + + + Info<< "On cellZone " << cz.name() + << " marked " << returnReduce(nPoints, sumOp