diff --git a/README b/README index 390dd8edb5..449b8585b0 100644 --- a/README +++ b/README @@ -99,7 +99,7 @@ and a csh/tcsh example: + setenv FOAM_INST_DIR /data/app/OpenFOAM - + foamDotFile=$FOAM_INST_DIR/OpenFOAM-1.6/etc/bashrc + + foamDotFile=$FOAM_INST_DIR/OpenFOAM-1.6/etc/cshrc + if ( -f $foamDotFile ) source $foamDotFile The value set in '$FOAM_INST_DIR' will be used to locate the remaining parts diff --git a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C index be267f8724..b61d997399 100644 --- a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C +++ b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C @@ -45,7 +45,7 @@ Description so cannot have any cells in any other zone. - useCellZonesOnly does not do a walk and uses the cellZones only. Use this if you don't mind having disconnected domains in a single region. - This option requires all cells to be in one (and one only) region. + This option requires all cells to be in one (and one only) cellZone. \*---------------------------------------------------------------------------*/ diff --git a/applications/utilities/preProcessing/applyBoundaryLayer/Make/options b/applications/utilities/preProcessing/applyBoundaryLayer/Make/options index 06d42b6c3c..31f1dd4d95 100644 --- a/applications/utilities/preProcessing/applyBoundaryLayer/Make/options +++ b/applications/utilities/preProcessing/applyBoundaryLayer/Make/options @@ -1,8 +1,14 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/turbulenceModels \ + -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \ -I$(LIB_SRC)/meshTools/lnInclude EXE_LIBS = \ -lfiniteVolume \ + -lincompressibleRASModels \ + -lincompressibleTransportModels \ -lgenericPatchFields \ -lmeshTools diff --git a/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C b/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C index 5714cccbff..52d79cec81 100644 --- a/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C +++ b/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C @@ -37,6 +37,8 @@ Description \*---------------------------------------------------------------------------*/ #include "fvCFD.H" +#include "singlePhaseTransportModel.H" +#include "RASModel.H" #include "wallDist.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -52,54 +54,14 @@ int main(int argc, char *argv[]) argList::validOptions.insert("Cbl", "scalar"); argList::validOptions.insert("writenut", ""); -# include "setRootCase.H" -# include "createTime.H" -# include "createMesh.H" + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "createFields.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - Info<< "Reading field U\n" << endl; - volVectorField U - ( - IOobject - ( - "U", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE - ), - mesh - ); - -# include "createPhi.H" - - Info<< "Calculating wall distance field" << endl; - volScalarField y = wallDist(mesh).y(); - - // Set the mean boundary-layer thickness - dimensionedScalar ybl("ybl", dimLength, 0); - - if (args.optionFound("ybl")) - { - // If the boundary-layer thickness is provided use it - ybl.value() = args.optionRead("ybl"); - } - else if (args.optionFound("Cbl")) - { - // Calculate boundary layer thickness as Cbl * mean distance to wall - ybl.value() = gAverage(y) * args.optionRead("Cbl"); - } - else - { - FatalErrorIn(args.executable()) - << "Neither option 'ybl' or 'Cbl' have been provided to calculate" - " the boundary-layer thickness" - << exit(FatalError); - } - - Info<< "\nCreating boundary-layer for U of thickness " - << ybl.value() << " m" << nl << endl; + Info<< "Time = " << runTime.timeName() << nl << endl; // Modify velocity by applying a 1/7th power law boundary-layer // u/U0 = (y/ybl)^(1/7) @@ -114,45 +76,18 @@ int main(int argc, char *argv[]) } } - Info<< "Writing U" << endl; + Info<< "Writing U\n" << endl; U.write(); // Update/re-write phi phi = fvc::interpolate(U) & mesh.Sf(); phi.write(); - // Read and modify turbulence fields if present - - IOobject epsilonHeader - ( - "epsilon", - runTime.timeName(), - mesh, - IOobject::MUST_READ - ); - - IOobject kHeader - ( - "k", - runTime.timeName(), - mesh, - IOobject::MUST_READ - ); - - IOobject nuTildaHeader - ( - "nuTilda", - runTime.timeName(), - mesh, - IOobject::MUST_READ - ); - - // First calculate nut - volScalarField nut - ( - "nut", - sqr(kappa*min(y, ybl))*::sqrt(2)*mag(dev(symm(fvc::grad(U)))) - ); + // Calculate nut + tmp tnut = turbulence->nut(); + volScalarField& nut = tnut(); + volScalarField S = mag(dev(symm(fvc::grad(U)))); + nut = sqr(kappa*min(y, ybl))*::sqrt(2)*S; if (args.optionFound("writenut")) { @@ -160,12 +95,69 @@ int main(int argc, char *argv[]) nut.write(); } + // Create G field - used by RAS wall functions + volScalarField G("RASModel::G", nut*2*sqr(S)); - // Read and modify turbulence fields if present + + //--- Read and modify turbulence fields + + // Turbulence k + tmp tk = turbulence->k(); + volScalarField& k = tk(); + scalar ck0 = pow025(Cmu)*kappa; + k = sqr(nut/(ck0*min(y, ybl))); + k.correctBoundaryConditions(); + + Info<< "Writing k\n" << endl; + k.write(); + + + // Turbulence epsilon + tmp tepsilon = turbulence->epsilon(); + volScalarField& epsilon = tepsilon(); + scalar ce0 = ::pow(Cmu, 0.75)/kappa; + epsilon = ce0*k*sqrt(k)/min(y, ybl); + epsilon.correctBoundaryConditions(); + + Info<< "Writing epsilon\n" << endl; + epsilon.write(); + + + // Turbulence omega + IOobject omegaHeader + ( + "omega", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); + + if (omegaHeader.headerOk()) + { + volScalarField omega(omegaHeader, mesh); + omega = epsilon/(Cmu*k); + omega.correctBoundaryConditions(); + + Info<< "Writing omega\n" << endl; + omega.write(); + } + + + // Turbulence nuTilda + IOobject nuTildaHeader + ( + "nuTilda", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); if (nuTildaHeader.headerOk()) { - Info<< "Reading field nuTilda\n" << endl; volScalarField nuTilda(nuTildaHeader, mesh); nuTilda = nut; nuTilda.correctBoundaryConditions(); @@ -174,28 +166,6 @@ int main(int argc, char *argv[]) nuTilda.write(); } - if (kHeader.headerOk() && epsilonHeader.headerOk()) - { - Info<< "Reading field k\n" << endl; - volScalarField k(kHeader, mesh); - - Info<< "Reading field epsilon\n" << endl; - volScalarField epsilon(epsilonHeader, mesh); - - scalar ck0 = ::pow(Cmu, 0.25)*kappa; - k = sqr(nut/(ck0*min(y, ybl))); - k.correctBoundaryConditions(); - - scalar ce0 = ::pow(Cmu, 0.75)/kappa; - epsilon = ce0*k*sqrt(k)/min(y, ybl); - epsilon.correctBoundaryConditions(); - - Info<< "Writing k\n" << endl; - k.write(); - - Info<< "Writing epsilon\n" << endl; - epsilon.write(); - } Info<< nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" diff --git a/applications/utilities/preProcessing/applyBoundaryLayer/createFields.H b/applications/utilities/preProcessing/applyBoundaryLayer/createFields.H new file mode 100644 index 0000000000..e168ed978d --- /dev/null +++ b/applications/utilities/preProcessing/applyBoundaryLayer/createFields.H @@ -0,0 +1,78 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-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 + +\*---------------------------------------------------------------------------*/ + + Info<< "Reading field U\n" << endl; + volVectorField U + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + mesh + ); + + #include "createPhi.H" + + singlePhaseTransportModel laminarTransport(U, phi); + + autoPtr turbulence + ( + incompressible::RASModel::New(U, phi, laminarTransport) + ); + + Info<< "Calculating wall distance field" << endl; + volScalarField y = wallDist(mesh).y(); + + // Set the mean boundary-layer thickness + dimensionedScalar ybl("ybl", dimLength, 0); + + if (args.optionFound("ybl")) + { + // If the boundary-layer thickness is provided use it + ybl.value() = args.optionRead("ybl"); + } + else if (args.optionFound("Cbl")) + { + // Calculate boundary layer thickness as Cbl * mean distance to wall + ybl.value() = gAverage(y)*args.optionRead("Cbl"); + } + else + { + FatalErrorIn(args.executable()) + << "Neither option 'ybl' or 'Cbl' have been provided to calculate " + << "the boundary-layer thickness" + << exit(FatalError); + } + + Info<< "\nCreating boundary-layer for U of thickness " + << ybl.value() << " m" << nl << endl; + + +// ************************************************************************* // diff --git a/bin/mpirunDebug b/bin/mpirunDebug index 57df760873..2376d22601 100755 --- a/bin/mpirunDebug +++ b/bin/mpirunDebug @@ -206,6 +206,21 @@ done cmd="" if [ .$WM_MPLIB = .OPENMPI ]; then cmd="mpirun -app $PWD/mpirun.schema $procXtermCmdFile + echo "$procCmd" >> $procXtermCmdFile + chmod +x $procXtermCmdFile + if [ $proc -ne 0 ]; then + cmd="${cmd} :" + fi + cmd="${cmd} -n 1 ${procXtermCmdFile}" + done < $PWD/mpirun.schema fi echo "Constructed $PWD/mpirun.schema file." diff --git a/etc/apps/paraview/bashrc b/etc/apps/paraview/bashrc deleted file mode 100644 index a6e2c08051..0000000000 --- a/etc/apps/paraview/bashrc +++ /dev/null @@ -1,67 +0,0 @@ -#----------------------------------*-sh-*-------------------------------------- -# ========= | -# \\ / 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 -# -# Script -# paraview/bashrc -# -# Description -# Setup file for paraview-2.x -# Sourced from OpenFOAM-*/etc/bashrc -# -#------------------------------------------------------------------------------ - -# determine the cmake to be used -unset CMAKE_HOME -for cmake in cmake-2.6.4 cmake-2.6.2 cmake-2.4.6 -do - cmake=$WM_THIRD_PARTY_DIR/$cmake/platforms/$WM_ARCH - if [ -r $cmake ] - then - export CMAKE_HOME=$cmake - export PATH=$CMAKE_HOME/bin:$PATH - break - fi -done - -paraviewMajor=paraview-2.4 -export ParaView_VERSION=2.4.4 - -export ParaView_INST_DIR=$WM_THIRD_PARTY_DIR/ParaView$ParaView_VERSION -export ParaView_DIR=$ParaView_INST_DIR/lib/$paraviewMajor - -if [ -r $ParaView_INST_DIR ] -then - export PV_INTERFACE_PATH=$FOAM_UTILITIES/postProcessing/graphics/PVFoamReader/PVFoamReader/Make - - export PATH=$ParaView_INST_DIR/bin:$PATH - export LD_LIBRARY_PATH=${ParaView_INST_DIR}/lib:${ParaView_INST_DIR}/lib/vtk:${LD_LIBRARY_PATH} -fi - -if [ -r $ParaView_DIR ] -then - export VTK_DIR=$ParaView_DIR/VTK -fi - -unset cmake paraviewMajor -# ----------------------------------------------------------------------------- diff --git a/etc/apps/paraview/cshrc b/etc/apps/paraview/cshrc deleted file mode 100644 index a1552a5116..0000000000 --- a/etc/apps/paraview/cshrc +++ /dev/null @@ -1,63 +0,0 @@ -#----------------------------------*-sh-*-------------------------------------- -# ========= | -# \\ / 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 -# -# Script -# paraview/cshrc -# -# Description -# Setup file for paraview-2.x -# Sourced from OpenFOAM-*/etc/cshrc -# -#------------------------------------------------------------------------------ - -# determine the cmake to be used -unsetenv CMAKE_HOME -foreach cmake ( cmake-2.6.4 cmake-2.6.2 cmake-2.4.6 ) - set cmake=$WM_THIRD_PARTY_DIR/$cmake/platforms/$WM_ARCH - if ( -r $cmake ) then - setenv CMAKE_HOME $cmake - set path=($CMAKE_HOME/bin $path) - break - endif -end - -set paraviewMajor=paraview-2.4 -setenv ParaView_VERSION 2.4.4 - -setenv ParaView_INST_DIR $WM_THIRD_PARTY_DIR/ParaView$ParaView_VERSION -setenv ParaView_DIR $ParaView_INST_DIR/lib/$paraviewMajor - -if ( -r $ParaView_INST_DIR ) then - setenv PV_INTERFACE_PATH $FOAM_UTILITIES/postProcessing/graphics/PVFoamReader/PVFoamReader/Make - - set path=($ParaView_INST_DIR/bin $path) - setenv LD_LIBRARY_PATH ${ParaView_INST_DIR}/lib:${ParaView_INST_DIR}/lib/vtk:${LD_LIBRARY_PATH} -endif - -if ( -r $ParaView_DIR ) then - setenv VTK_DIR $ParaView_DIR/VTK -endif - -unset cmake paraviewMajor -# ----------------------------------------------------------------------------- diff --git a/etc/apps/paraview3/bashrc b/etc/apps/paraview3/bashrc index 354687e30a..7209dc0da8 100644 --- a/etc/apps/paraview3/bashrc +++ b/etc/apps/paraview3/bashrc @@ -46,21 +46,22 @@ do fi done -paraviewMajor=paraview-3.6 -export ParaView_VERSION=3.6.1 +# set MAJOR and VERSION variables if not already set +[ -z "$ParaView_MAJOR" ] && export ParaView_MAJOR=paraview-3.6 +[ -z "$ParaView_VERSION" ] && export ParaView_VERSION=3.6.1 export ParaView_INST_DIR=$WM_THIRD_PARTY_DIR/paraview-$ParaView_VERSION export ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER # add in python libraries if required -paraviewPython=$ParaView_DIR/Utilities/VTKPythonWrapping -if [ -r $paraviewPython ] +ParaView_PYTHON_DIR=$ParaView_DIR/Utilities/VTKPythonWrapping +if [ -r $ParaView_PYTHON_DIR ] then if [ "$PYTHONPATH" ] then - export PYTHONPATH=$PYTHONPATH:$paraviewPython:$ParaView_DIR/lib/$paraviewMajor + export PYTHONPATH=$PYTHONPATH:$ParaView_PYTHON_DIR:$ParaView_DIR/lib/$ParaView_MAJOR else - export PYTHONPATH=$paraviewPython:$ParaView_DIR/lib/$paraviewMajor + export PYTHONPATH=$ParaView_PYTHON_DIR:$ParaView_DIR/lib/$ParaView_MAJOR fi fi @@ -70,5 +71,5 @@ then export PV_PLUGIN_PATH=$FOAM_LIBBIN fi -unset cmake paraviewMajor paraviewPython +unset cmake ParaView_PYTHON_DIR # ----------------------------------------------------------------------------- diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H index 087f685ff6..b829c99ea5 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.H +++ b/src/OpenFOAM/containers/Lists/UList/UList.H @@ -184,6 +184,12 @@ public: // an out-of-range element returns false without any ill-effects inline const T& operator[](const label) const; + //- Return last element of UList. + inline T& last(); + + //- Return last element of UList. + inline const T& last() const; + //- Allow cast to a const List& inline operator const Foam::List&() const; diff --git a/src/OpenFOAM/containers/Lists/UList/UListI.H b/src/OpenFOAM/containers/Lists/UList/UListI.H index 5c1df4be15..aa7d396f10 100644 --- a/src/OpenFOAM/containers/Lists/UList/UListI.H +++ b/src/OpenFOAM/containers/Lists/UList/UListI.H @@ -114,6 +114,20 @@ inline void Foam::UList::checkIndex(const label i) const } +template +inline T& Foam::UList::last() +{ + return this->operator[](this->size()-1); +} + + +template +inline const T& Foam::UList::last() const +{ + return this->operator[](this->size()-1); +} + + template inline const T* Foam::UList::cdata() const { diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.C b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.C index 87f940db40..41cb1c4f11 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.C @@ -82,9 +82,6 @@ void Foam::PstreamBuffers::finishedSends(labelListList& sizes, const bool block) if (commsType_ == UPstream::nonBlocking) { - labelListList sizes; - labelListList send,recv; - Pstream::exchange, char> ( sendBuf_, @@ -96,20 +93,30 @@ void Foam::PstreamBuffers::finishedSends(labelListList& sizes, const bool block) } else { - sizes.setSize(UPstream::nProcs()); - labelList& nsTransPs = sizes[UPstream::myProcNo()]; - nsTransPs.setSize(UPstream::nProcs()); + FatalErrorIn + ( + "PstreamBuffers::finishedSends(labelListList&, const bool)" + ) << "Obtaining sizes not supported in " + << UPstream::commsTypeNames[commsType_] << endl + << " since transfers already in progress. Use non-blocking instead." + << exit(FatalError); - forAll(sendBuf_, procI) - { - nsTransPs[procI] = sendBuf_[procI].size(); - } - - // Send sizes across. - int oldTag = UPstream::msgType(); - UPstream::msgType() = tag_; - combineReduce(sizes, UPstream::listEq()); - UPstream::msgType() = oldTag; + // Note: possible only if using different tag from write started + // by ~UOPstream. Needs some work. + //sizes.setSize(UPstream::nProcs()); + //labelList& nsTransPs = sizes[UPstream::myProcNo()]; + //nsTransPs.setSize(UPstream::nProcs()); + // + //forAll(sendBuf_, procI) + //{ + // nsTransPs[procI] = sendBuf_[procI].size(); + //} + // + //// Send sizes across. + //int oldTag = UPstream::msgType(); + //UPstream::msgType() = tag_; + //combineReduce(sizes, UPstream::listEq()); + //UPstream::msgType() = oldTag; } } diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.H b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.H index d3dbbf23db..75f26f1d6a 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.H @@ -138,7 +138,8 @@ public: void finishedSends(const bool block = true); //- Mark all sends as having been done. Same as above but also returns - // sizes (bytes) transferred. + // sizes (bytes) transferred. Note:currently only valid for + // non-blocking. void finishedSends(labelListList& sizes, const bool block = true); }; diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/exchange.C b/src/OpenFOAM/db/IOstreams/Pstreams/exchange.C index 64ced34ecf..b950ed22f0 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/exchange.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/exchange.C @@ -50,43 +50,42 @@ void Pstream::exchange const bool block ) { - if (UPstream::parRun()) + if (!contiguous()) { - if (!contiguous()) - { - FatalErrorIn - ( - "Pstream::exchange(..)" - ) << "Continuous data only." << Foam::abort(FatalError); - } + FatalErrorIn + ( + "Pstream::exchange(..)" + ) << "Continuous data only." << Foam::abort(FatalError); + } - if (sendBufs.size() != UPstream::nProcs()) - { - FatalErrorIn - ( - "Pstream::exchange(..)" - ) << "Size of list:" << sendBufs.size() - << " does not equal the number of processors:" - << UPstream::nProcs() - << Foam::abort(FatalError); - } + if (sendBufs.size() != UPstream::nProcs()) + { + FatalErrorIn + ( + "Pstream::exchange(..)" + ) << "Size of list:" << sendBufs.size() + << " does not equal the number of processors:" + << UPstream::nProcs() + << Foam::abort(FatalError); + } - sizes.setSize(UPstream::nProcs()); - labelList& nsTransPs = sizes[UPstream::myProcNo()]; - nsTransPs.setSize(UPstream::nProcs()); + sizes.setSize(UPstream::nProcs()); + labelList& nsTransPs = sizes[UPstream::myProcNo()]; + nsTransPs.setSize(UPstream::nProcs()); - forAll(sendBufs, procI) - { - nsTransPs[procI] = sendBufs[procI].size(); - } - - // Send sizes across. - int oldTag = UPstream::msgType(); - UPstream::msgType() = tag; - combineReduce(sizes, UPstream::listEq()); - UPstream::msgType() = oldTag; + forAll(sendBufs, procI) + { + nsTransPs[procI] = sendBufs[procI].size(); + } + // Send sizes across. + int oldTag = UPstream::msgType(); + UPstream::msgType() = tag; + combineReduce(sizes, UPstream::listEq()); + UPstream::msgType() = oldTag; + if (Pstream::parRun()) + { // Set up receives // ~~~~~~~~~~~~~~~ diff --git a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C index 4e3bf3fad6..f7040df07c 100644 --- a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C +++ b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C @@ -37,8 +37,43 @@ void Foam::OutputFilterFunctionObject::readDict() dict_.readIfPresent("region", regionName_); dict_.readIfPresent("dictionary", dictName_); dict_.readIfPresent("enabled", enabled_); + dict_.readIfPresent("storeFilter", storeFilter_); } +template +void Foam::OutputFilterFunctionObject::allocateFilter() +{ + if (dictName_.size()) + { + ptr_.reset + ( + new IOOutputFilter + ( + name(), + time_.lookupObject(regionName_), + dictName_ + ) + ); + } + else + { + ptr_.reset + ( + new OutputFilter + ( + name(), + time_.lookupObject(regionName_), + dict_ + ) + ); + } +} + +template +void Foam::OutputFilterFunctionObject::destroyFilter() +{ + ptr_.reset(); +} // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -56,6 +91,7 @@ Foam::OutputFilterFunctionObject::OutputFilterFunctionObject regionName_(polyMesh::defaultRegion), dictName_(), enabled_(true), + storeFilter_(true), outputControl_(t, dict) { readDict(); @@ -83,32 +119,9 @@ bool Foam::OutputFilterFunctionObject::start() { readDict(); - if (enabled_) + if (enabled_&&storeFilter_) { - if (dictName_.size()) - { - ptr_.reset - ( - new IOOutputFilter - ( - name(), - time_.lookupObject(regionName_), - dictName_ - ) - ); - } - else - { - ptr_.reset - ( - new OutputFilter - ( - name(), - time_.lookupObject(regionName_), - dict_ - ) - ); - } + allocateFilter(); } return true; @@ -120,12 +133,22 @@ bool Foam::OutputFilterFunctionObject::execute() { if (enabled_) { + if (!storeFilter_) + { + allocateFilter(); + } + ptr_->execute(); - if (enabled_ && outputControl_.output()) + if (outputControl_.output()) { ptr_->write(); } + + if (!storeFilter_) + { + destroyFilter(); + } } return true; @@ -137,12 +160,22 @@ bool Foam::OutputFilterFunctionObject::end() { if (enabled_) { + if (!storeFilter_) + { + allocateFilter(); + } + ptr_->end(); - if (enabled_ && outputControl_.output()) + if (outputControl_.output()) { ptr_->write(); } + + if (!storeFilter_) + { + destroyFilter(); + } } return true; diff --git a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H index bce0c0abe9..92f0c43196 100644 --- a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H +++ b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H @@ -78,6 +78,10 @@ class OutputFilterFunctionObject //- Switch for the execution of the functionObject bool enabled_; + //- Switch to store filter in between writes or use on-the-fly + // construction + bool storeFilter_; + //- Output controls outputFilterOutputControl outputControl_; @@ -89,6 +93,12 @@ class OutputFilterFunctionObject //- Read relevant dictionary entries void readDict(); + + //- Creates most of the data associated with this object. + void allocateFilter(); + + //- Destroys most of the data associated with this object. + void destroyFilter(); //- Disallow default bitwise copy construct OutputFilterFunctionObject(const OutputFilterFunctionObject&); diff --git a/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.C b/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.C index 11be3c3b86..36e6fe6afd 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.C +++ b/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.C @@ -28,6 +28,9 @@ License #include "polyBoundaryMesh.H" #include "facePointPatch.H" #include "globalPointPatch.H" +#include "PstreamBuffers.H" +#include "lduSchedule.H" +#include "globalMeshData.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -58,14 +61,46 @@ Foam::pointBoundaryMesh::pointBoundaryMesh void Foam::pointBoundaryMesh::calcGeometry() { - forAll(*this, patchi) - { - operator[](patchi).initGeometry(); - } + PstreamBuffers pBufs(Pstream::defaultCommsType); - forAll(*this, patchi) + if + ( + Pstream::defaultCommsType == Pstream::blocking + || Pstream::defaultCommsType == Pstream::nonBlocking + ) { - operator[](patchi).calcGeometry(); + forAll(*this, patchi) + { + operator[](patchi).initGeometry(pBufs); + } + + pBufs.finishedSends(); + + forAll(*this, patchi) + { + operator[](patchi).calcGeometry(pBufs); + } + } + else if (Pstream::defaultCommsType == Pstream::scheduled) + { + const lduSchedule& patchSchedule = mesh().globalData().patchSchedule(); + + // Dummy. + pBufs.finishedSends(); + + forAll(patchSchedule, patchEvali) + { + label patchi = patchSchedule[patchEvali].patch; + + if (patchSchedule[patchEvali].init) + { + operator[](patchi).initGeometry(pBufs); + } + else + { + operator[](patchi).calcGeometry(pBufs); + } + } } } @@ -97,32 +132,92 @@ Foam::pointBoundaryMesh::globalPatch() const void Foam::pointBoundaryMesh::movePoints(const pointField& p) { - pointPatchList& patches = *this; + PstreamBuffers pBufs(Pstream::defaultCommsType); - forAll(patches, patchi) + if + ( + Pstream::defaultCommsType == Pstream::blocking + || Pstream::defaultCommsType == Pstream::nonBlocking + ) { - patches[patchi].initMovePoints(p); + forAll(*this, patchi) + { + operator[](patchi).initMovePoints(pBufs, p); + } + + pBufs.finishedSends(); + + forAll(*this, patchi) + { + operator[](patchi).movePoints(pBufs, p); + } } - - forAll(patches, patchi) + else if (Pstream::defaultCommsType == Pstream::scheduled) { - patches[patchi].movePoints(p); + const lduSchedule& patchSchedule = mesh().globalData().patchSchedule(); + + // Dummy. + pBufs.finishedSends(); + + forAll(patchSchedule, patchEvali) + { + label patchi = patchSchedule[patchEvali].patch; + + if (patchSchedule[patchEvali].init) + { + operator[](patchi).initMovePoints(pBufs, p); + } + else + { + operator[](patchi).movePoints(pBufs, p); + } + } } } void Foam::pointBoundaryMesh::updateMesh() { - pointPatchList& patches = *this; + PstreamBuffers pBufs(Pstream::defaultCommsType); - forAll(patches, patchi) + if + ( + Pstream::defaultCommsType == Pstream::blocking + || Pstream::defaultCommsType == Pstream::nonBlocking + ) { - patches[patchi].initUpdateMesh(); + forAll(*this, patchi) + { + operator[](patchi).initUpdateMesh(pBufs); + } + + pBufs.finishedSends(); + + forAll(*this, patchi) + { + operator[](patchi).updateMesh(pBufs); + } } - - forAll(patches, patchi) + else if (Pstream::defaultCommsType == Pstream::scheduled) { - patches[patchi].updateMesh(); + const lduSchedule& patchSchedule = mesh().globalData().patchSchedule(); + + // Dummy. + pBufs.finishedSends(); + + forAll(patchSchedule, patchEvali) + { + label patchi = patchSchedule[patchEvali].patch; + + if (patchSchedule[patchEvali].init) + { + operator[](patchi).initUpdateMesh(pBufs); + } + else + { + operator[](patchi).updateMesh(pBufs); + } + } } } diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/basic/coupled/coupledPointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/basic/coupled/coupledPointPatch.H index 77cbb4162f..79a2f2363c 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/basic/coupled/coupledPointPatch.H +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/basic/coupled/coupledPointPatch.H @@ -66,22 +66,22 @@ protected: // Protected Member Functions //- Initialise the calculation of the patch geometry - virtual void initGeometry() = 0; + virtual void initGeometry(PstreamBuffers&) = 0; //- Calculate the patch geometry - virtual void calcGeometry() = 0; + virtual void calcGeometry(PstreamBuffers&) = 0; //- Initialise the patches for moving points - virtual void initMovePoints(const pointField&) = 0; + virtual void initMovePoints(PstreamBuffers&, const pointField&) = 0; //- Correct patches after moving points - virtual void movePoints(const pointField&) = 0; + virtual void movePoints(PstreamBuffers&, const pointField&) = 0; //- Initialise the update of the patch topology - virtual void initUpdateMesh() = 0; + virtual void initUpdateMesh(PstreamBuffers&) = 0; //- Update of the patch topology - virtual void updateMesh() = 0; + virtual void updateMesh(PstreamBuffers&) = 0; public: diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/cyclic/cyclicPointPatch.C b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/cyclic/cyclicPointPatch.C index 81104d726e..6f65c70764 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/cyclic/cyclicPointPatch.C +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/cyclic/cyclicPointPatch.C @@ -50,13 +50,13 @@ addToRunTimeSelectionTable // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // -void Foam::cyclicPointPatch::initGeometry() +void Foam::cyclicPointPatch::initGeometry(PstreamBuffers&) { transformPairs_.setSize(0); } -void Foam::cyclicPointPatch::calcGeometry() +void Foam::cyclicPointPatch::calcGeometry(PstreamBuffers&) { const edgeList& cp = cyclicPolyPatch_.coupledPoints(); const labelList& mp = cyclicPolyPatch_.meshPoints(); @@ -128,16 +128,20 @@ void Foam::cyclicPointPatch::calcGeometry() } else if (pointMap[cp[i][0]] == -1 && pointMap[cp[i][1]] != -1) { - FatalErrorIn("cyclicPointPatch::calcGeometry() const") - << "Point " << cp[i][0] << "of point-pair " << i + FatalErrorIn + ( + "cyclicPointPatch::calcGeometry(PstreamBuffers&) const" + ) << "Point " << cp[i][0] << "of point-pair " << i << " is a global point but the other point " << cp[i][1] << " is not" << exit(FatalError); } else if (pointMap[cp[i][0]] != -1 && pointMap[cp[i][1]] == -1) { - FatalErrorIn("cyclicPointPatch::calcGeometry() const") - << "Point " << cp[i][1] << "of point-pair " << i + FatalErrorIn + ( + "cyclicPointPatch::calcGeometry(PstreamBuffers&) const" + ) << "Point " << cp[i][1] << "of point-pair " << i << " is a global point but the other point " << cp[i][0] << " is not" << exit(FatalError); @@ -149,25 +153,25 @@ void Foam::cyclicPointPatch::calcGeometry() } -void cyclicPointPatch::initMovePoints(const pointField&) +void cyclicPointPatch::initMovePoints(PstreamBuffers&, const pointField&) {} -void cyclicPointPatch::movePoints(const pointField&) +void cyclicPointPatch::movePoints(PstreamBuffers&, const pointField&) {} -void cyclicPointPatch::initUpdateMesh() +void cyclicPointPatch::initUpdateMesh(PstreamBuffers& pBufs) { - facePointPatch::initUpdateMesh(); - cyclicPointPatch::initGeometry(); + facePointPatch::initUpdateMesh(pBufs); + cyclicPointPatch::initGeometry(pBufs); } -void cyclicPointPatch::updateMesh() +void cyclicPointPatch::updateMesh(PstreamBuffers& pBufs) { - facePointPatch::updateMesh(); - cyclicPointPatch::calcGeometry(); + facePointPatch::updateMesh(pBufs); + cyclicPointPatch::calcGeometry(pBufs); } diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/cyclic/cyclicPointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/cyclic/cyclicPointPatch.H index 999c45613d..1d013f3421 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/cyclic/cyclicPointPatch.H +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/cyclic/cyclicPointPatch.H @@ -74,22 +74,22 @@ class cyclicPointPatch edgeList transformPairs_; //- Initialise the calculation of the patch geometry - virtual void initGeometry(); + virtual void initGeometry(PstreamBuffers&); //- Calculate the patch geometry - virtual void calcGeometry(); + virtual void calcGeometry(PstreamBuffers&); //- Initialise the patches for moving points - virtual void initMovePoints(const pointField&); + virtual void initMovePoints(PstreamBuffers&, const pointField&); //- Correct patches after moving points - virtual void movePoints(const pointField&); + virtual void movePoints(PstreamBuffers&, const pointField&); //- Initialise the update of the patch topology - virtual void initUpdateMesh(); + virtual void initUpdateMesh(PstreamBuffers&); //- Update of the patch topology - virtual void updateMesh(); + virtual void updateMesh(PstreamBuffers&); public: diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.C b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.C index eb99350c13..d3aae3ec87 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.C +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.C @@ -52,7 +52,7 @@ addToRunTimeSelectionTable // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // -void Foam::processorPointPatch::initGeometry() +void Foam::processorPointPatch::initGeometry(PstreamBuffers& pBufs) { // Algorithm: // Depending on whether the patch is a master or a slave, get the primitive @@ -84,16 +84,16 @@ void Foam::processorPointPatch::initGeometry() if (Pstream::parRun()) { - initPatchPatchPoints(); + initPatchPatchPoints(pBufs); } } -void Foam::processorPointPatch::calcGeometry() +void Foam::processorPointPatch::calcGeometry(PstreamBuffers& pBufs) { if (Pstream::parRun()) { - calcPatchPatchPoints(); + calcPatchPatchPoints(pBufs); } // If it is not runing parallel or there are no global points @@ -149,11 +149,11 @@ void Foam::processorPointPatch::calcGeometry() } -void processorPointPatch::initPatchPatchPoints() +void processorPointPatch::initPatchPatchPoints(PstreamBuffers& pBufs) { if (debug) { - Info<< "processorPointPatch::calcPatchPatchPoints() : " + Info<< "processorPointPatch::initPatchPatchPoints(PstreamBuffers&) : " << "constructing patch-patch points" << endl; } @@ -229,7 +229,7 @@ void processorPointPatch::initPatchPatchPoints() // Send the patchPatchPoints to the neighbouring processor - OPstream toNeighbProc(Pstream::blocking, neighbProcNo()); + UOPstream toNeighbProc(neighbProcNo(), pBufs); toNeighbProc << ppmp.size() // number of points for checking @@ -238,17 +238,17 @@ void processorPointPatch::initPatchPatchPoints() if (debug) { - Info<< "processorPointPatch::calcPatchPatchPoints() : " + Info<< "processorPointPatch::initPatchPatchPoints() : " << "constructed patch-patch points" << endl; } } -void Foam::processorPointPatch::calcPatchPatchPoints() +void Foam::processorPointPatch::calcPatchPatchPoints(PstreamBuffers& pBufs) { // Get the patchPatchPoints from the neighbouring processor - IPstream fromNeighbProc(Pstream::blocking, neighbProcNo()); + UIPstream fromNeighbProc(neighbProcNo(), pBufs); label nbrNPoints(readLabel(fromNeighbProc)); labelListList patchPatchPoints(fromNeighbProc); @@ -265,7 +265,7 @@ void Foam::processorPointPatch::calcPatchPatchPoints() // separate. if (nbrNPoints != ppmp.size()) { - WarningIn("processorPointPatch::calcPatchPatchPoints()") + WarningIn("processorPointPatch::calcPatchPatchPoints(PstreamBuffers&)") << "Processor patch " << name() << " has " << ppmp.size() << " points; coupled patch has " << nbrNPoints << " points." << endl @@ -352,25 +352,25 @@ void Foam::processorPointPatch::calcPatchPatchPoints() } -void processorPointPatch::initMovePoints(const pointField&) +void processorPointPatch::initMovePoints(PstreamBuffers&, const pointField&) {} -void processorPointPatch::movePoints(const pointField&) +void processorPointPatch::movePoints(PstreamBuffers&, const pointField&) {} -void processorPointPatch::initUpdateMesh() +void processorPointPatch::initUpdateMesh(PstreamBuffers& pBufs) { - facePointPatch::initUpdateMesh(); - processorPointPatch::initGeometry(); + facePointPatch::initUpdateMesh(pBufs); + processorPointPatch::initGeometry(pBufs); } -void processorPointPatch::updateMesh() +void processorPointPatch::updateMesh(PstreamBuffers& pBufs) { - facePointPatch::updateMesh(); - processorPointPatch::calcGeometry(); + facePointPatch::updateMesh(pBufs); + processorPointPatch::calcGeometry(pBufs); } diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.H index f17a00ca83..373416ac0a 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.H +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.H @@ -68,30 +68,30 @@ class processorPointPatch // Private Member Functions //- Initialise the calculation of the patch geometry - virtual void initGeometry(); + virtual void initGeometry(PstreamBuffers&); //- Calculate the patch geometry - virtual void calcGeometry(); + virtual void calcGeometry(PstreamBuffers&); //- Initialise the points on this patch which are should also be // on a neighbouring patch but are not part of faces of that patch - void initPatchPatchPoints(); + void initPatchPatchPoints(PstreamBuffers&); //- Calculate the points on this patch which are should also be // on a neighbouring patch but are not part of faces of that patch - void calcPatchPatchPoints(); + void calcPatchPatchPoints(PstreamBuffers&); //- Initialise the patches for moving points - virtual void initMovePoints(const pointField&); + virtual void initMovePoints(PstreamBuffers&, const pointField&); //- Correct patches after moving points - virtual void movePoints(const pointField&); + virtual void movePoints(PstreamBuffers&, const pointField&); //- Initialise the update of the patch topology - virtual void initUpdateMesh(); + virtual void initUpdateMesh(PstreamBuffers&); //- Update of the patch topology - virtual void updateMesh(); + virtual void updateMesh(PstreamBuffers&); //- Disallow default construct as copy diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/coupled/coupledFacePointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/coupled/coupledFacePointPatch.H index dc2437877d..a77af7af30 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/coupled/coupledFacePointPatch.H +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/coupled/coupledFacePointPatch.H @@ -86,7 +86,7 @@ protected: // Construction of demand-driven data //- Calculate mesh points - virtual void calcGeometry() = 0; + virtual void calcGeometry(PstreamBuffers&) = 0; public: diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/global/globalPointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/global/globalPointPatch.H index 990ab0de9a..ba89ca950c 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/global/globalPointPatch.H +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/global/globalPointPatch.H @@ -67,27 +67,27 @@ class globalPointPatch // Protected Member Functions //- Initialise the calculation of the patch geometry - virtual void initGeometry() + virtual void initGeometry(PstreamBuffers&) {} //- Calculate the patch geometry - virtual void calcGeometry() + virtual void calcGeometry(PstreamBuffers&) {} //- Initialise the patches for moving points - virtual void initMovePoints(const pointField&) + virtual void initMovePoints(PstreamBuffers&, const pointField&) {} //- Correct patches after moving points - virtual void movePoints(const pointField&) + virtual void movePoints(PstreamBuffers&, const pointField&) {} //- Initialise the update of the patch topology - virtual void initUpdateMesh() + virtual void initUpdateMesh(PstreamBuffers&) {} //- Update of the patch topology - virtual void updateMesh() + virtual void updateMesh(PstreamBuffers&) {} diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/facePointPatch/facePointPatch.C b/src/OpenFOAM/meshes/pointMesh/pointPatches/facePointPatch/facePointPatch.C index 25c91dd398..fb15ac4b96 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/facePointPatch/facePointPatch.C +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/facePointPatch/facePointPatch.C @@ -51,7 +51,7 @@ addToRunTimeSelectionTable // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // -void facePointPatch::initGeometry() +void facePointPatch::initGeometry(PstreamBuffers&) { meshPoints_.setSize(0); localPoints_.setSize(0); @@ -59,25 +59,25 @@ void facePointPatch::initGeometry() } -void facePointPatch::calcGeometry() +void facePointPatch::calcGeometry(PstreamBuffers&) {} -void facePointPatch::initMovePoints(const pointField&) +void facePointPatch::initMovePoints(PstreamBuffers&, const pointField&) {} -void facePointPatch::movePoints(const pointField&) +void facePointPatch::movePoints(PstreamBuffers&, const pointField&) {} -void facePointPatch::initUpdateMesh() +void facePointPatch::initUpdateMesh(PstreamBuffers& pBufs) { - facePointPatch::initGeometry(); + facePointPatch::initGeometry(pBufs); } -void facePointPatch::updateMesh() +void facePointPatch::updateMesh(PstreamBuffers&) {} diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/facePointPatch/facePointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/facePointPatch/facePointPatch.H index 7a75b4017f..0094d4ce1a 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/facePointPatch/facePointPatch.H +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/facePointPatch/facePointPatch.H @@ -76,22 +76,22 @@ protected: // Protected Member Functions //- Initialise the calculation of the patch geometry - virtual void initGeometry(); + virtual void initGeometry(PstreamBuffers&); //- Calculate the patch geometry - virtual void calcGeometry(); + virtual void calcGeometry(PstreamBuffers&); //- Initialise the patches for moving points - virtual void initMovePoints(const pointField&); + virtual void initMovePoints(PstreamBuffers&, const pointField&); //- Correct patches after moving points - virtual void movePoints(const pointField&); + virtual void movePoints(PstreamBuffers&, const pointField&); //- Initialise the update of the patch topology - virtual void initUpdateMesh(); + virtual void initUpdateMesh(PstreamBuffers&); //- Update of the patch topology - virtual void updateMesh(); + virtual void updateMesh(PstreamBuffers&); private: diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/pointPatch/pointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/pointPatch/pointPatch.H index bdf67c879b..637ac659dd 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/pointPatch/pointPatch.H +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/pointPatch/pointPatch.H @@ -49,6 +49,7 @@ namespace Foam class pointBoundaryMesh; class pointConstraint; +class PstreamBuffers; /*---------------------------------------------------------------------------*\ Class pointPatch Declaration @@ -79,27 +80,27 @@ protected: friend class pointBoundaryMesh; //- Initialise the calculation of the patch geometry - virtual void initGeometry() + virtual void initGeometry(PstreamBuffers&) {} //- Calculate the patch geometry - virtual void calcGeometry() + virtual void calcGeometry(PstreamBuffers&) {} //- Initialise the patches for moving points - virtual void initMovePoints(const pointField&) + virtual void initMovePoints(PstreamBuffers&, const pointField&) {} //- Correct patches after moving points - virtual void movePoints(const pointField&) + virtual void movePoints(PstreamBuffers&, const pointField&) {} //- Initialise the update of the patch topology - virtual void initUpdateMesh() + virtual void initUpdateMesh(PstreamBuffers&) {} //- Update of the patch topology - virtual void updateMesh() + virtual void updateMesh(PstreamBuffers&) {} diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C index eff7af933c..a111e0435d 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C @@ -29,6 +29,9 @@ License #include "primitiveMesh.H" #include "processorPolyPatch.H" #include "stringListOps.H" +#include "PstreamBuffers.H" +#include "lduSchedule.H" +#include "globalMeshData.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -144,14 +147,46 @@ void Foam::polyBoundaryMesh::clearAddressing() void Foam::polyBoundaryMesh::calcGeometry() { - forAll(*this, patchi) - { - operator[](patchi).initGeometry(); - } + PstreamBuffers pBufs(Pstream::defaultCommsType); - forAll(*this, patchi) + if + ( + Pstream::defaultCommsType == Pstream::blocking + || Pstream::defaultCommsType == Pstream::nonBlocking + ) { - operator[](patchi).calcGeometry(); + forAll(*this, patchi) + { + operator[](patchi).initGeometry(pBufs); + } + + pBufs.finishedSends(); + + forAll(*this, patchi) + { + operator[](patchi).calcGeometry(pBufs); + } + } + else if (Pstream::defaultCommsType == Pstream::scheduled) + { + const lduSchedule& patchSchedule = mesh().globalData().patchSchedule(); + + // Dummy. + pBufs.finishedSends(); + + forAll(patchSchedule, patchEvali) + { + label patchi = patchSchedule[patchEvali].patch; + + if (patchSchedule[patchEvali].init) + { + operator[](patchi).initGeometry(pBufs); + } + else + { + operator[](patchi).calcGeometry(pBufs); + } + } } } @@ -573,16 +608,46 @@ bool Foam::polyBoundaryMesh::checkDefinition(const bool report) const void Foam::polyBoundaryMesh::movePoints(const pointField& p) { - polyPatchList& patches = *this; + PstreamBuffers pBufs(Pstream::defaultCommsType); - forAll(patches, patchi) + if + ( + Pstream::defaultCommsType == Pstream::blocking + || Pstream::defaultCommsType == Pstream::nonBlocking + ) { - patches[patchi].initMovePoints(p); + forAll(*this, patchi) + { + operator[](patchi).initMovePoints(pBufs, p); + } + + pBufs.finishedSends(); + + forAll(*this, patchi) + { + operator[](patchi).movePoints(pBufs, p); + } } - - forAll(patches, patchi) + else if (Pstream::defaultCommsType == Pstream::scheduled) { - patches[patchi].movePoints(p); + const lduSchedule& patchSchedule = mesh().globalData().patchSchedule(); + + // Dummy. + pBufs.finishedSends(); + + forAll(patchSchedule, patchEvali) + { + label patchi = patchSchedule[patchEvali].patch; + + if (patchSchedule[patchEvali].init) + { + operator[](patchi).initMovePoints(pBufs, p); + } + else + { + operator[](patchi).movePoints(pBufs, p); + } + } } } @@ -591,16 +656,46 @@ void Foam::polyBoundaryMesh::updateMesh() { deleteDemandDrivenData(neighbourEdgesPtr_); - polyPatchList& patches = *this; + PstreamBuffers pBufs(Pstream::defaultCommsType); - forAll(patches, patchi) + if + ( + Pstream::defaultCommsType == Pstream::blocking + || Pstream::defaultCommsType == Pstream::nonBlocking + ) { - patches[patchi].initUpdateMesh(); + forAll(*this, patchi) + { + operator[](patchi).initUpdateMesh(pBufs); + } + + pBufs.finishedSends(); + + forAll(*this, patchi) + { + operator[](patchi).updateMesh(pBufs); + } } - - forAll(patches, patchi) + else if (Pstream::defaultCommsType == Pstream::scheduled) { - patches[patchi].updateMesh(); + const lduSchedule& patchSchedule = mesh().globalData().patchSchedule(); + + // Dummy. + pBufs.finishedSends(); + + forAll(patchSchedule, patchEvali) + { + label patchi = patchSchedule[patchEvali].patch; + + if (patchSchedule[patchEvali].init) + { + operator[](patchi).initUpdateMesh(pBufs); + } + else + { + operator[](patchi).updateMesh(pBufs); + } + } } } diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H index e3277defcc..fdea473ed3 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H @@ -50,8 +50,6 @@ class polyMesh; // Forward declaration of friend functions and operators -class polyBoundaryMesh; - Ostream& operator<<(Ostream&, const polyBoundaryMesh&); diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H index f823148d3a..e1afad60a8 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H @@ -90,22 +90,22 @@ protected: ) const; //- Initialise the calculation of the patch geometry - virtual void initGeometry() = 0; + virtual void initGeometry(PstreamBuffers&) = 0; //- Calculate the patch geometry - virtual void calcGeometry() = 0; + virtual void calcGeometry(PstreamBuffers&) = 0; //- Initialise the patches for moving points - virtual void initMovePoints(const pointField&) = 0; + virtual void initMovePoints(PstreamBuffers&, const pointField&) = 0; //- Correct patches after moving points - virtual void movePoints(const pointField&) = 0; + virtual void movePoints(PstreamBuffers&, const pointField&) = 0; //- Initialise the update of the patch topology - virtual void initUpdateMesh() = 0; + virtual void initUpdateMesh(PstreamBuffers&) = 0; //- Update of the patch topology - virtual void updateMesh() = 0; + virtual void updateMesh(PstreamBuffers&) = 0; //- Write point in OBJ format @@ -283,7 +283,11 @@ public: //- Initialize ordering for primitivePatch. Does not // refer to *this (except for name() and type() etc.) - virtual void initOrder(const primitivePatch&) const = 0; + virtual void initOrder + ( + PstreamBuffers&, + const primitivePatch& + ) const = 0; //- Return new ordering for primitivePatch. // Ordering is -faceMap: for every face @@ -292,6 +296,7 @@ public: // (faceMap is identity, rotation is 0), true otherwise. virtual bool order ( + PstreamBuffers&, const primitivePatch&, labelList& faceMap, labelList& rotation diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C index 8c6b202079..fef6c98ec0 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C @@ -516,7 +516,8 @@ void Foam::cyclicPolyPatch::getCentresAndAnchors // if (debug) // { // Pout<< "cyclicPolyPatch::getCentresAndAnchors :" - // << "Specified translation : " << separationVector_ << endl; + // << "Specified translation : " << separationVector_ + // << endl; // } // // half0Ctrs += separationVector_; @@ -858,36 +859,44 @@ Foam::cyclicPolyPatch::~cyclicPolyPatch() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::cyclicPolyPatch::initGeometry() +void Foam::cyclicPolyPatch::initGeometry(PstreamBuffers& pBufs) { - polyPatch::initGeometry(); + polyPatch::initGeometry(pBufs); } -void Foam::cyclicPolyPatch::calcGeometry() +void Foam::cyclicPolyPatch::calcGeometry(PstreamBuffers& pBufs) { - polyPatch::calcGeometry(); + polyPatch::calcGeometry(pBufs); calcTransforms(); } -void Foam::cyclicPolyPatch::initMovePoints(const pointField& p) +void Foam::cyclicPolyPatch::initMovePoints +( + PstreamBuffers& pBufs, + const pointField& p +) { - polyPatch::initMovePoints(p); + polyPatch::initMovePoints(pBufs, p); } -void Foam::cyclicPolyPatch::movePoints(const pointField& p) +void Foam::cyclicPolyPatch::movePoints +( + PstreamBuffers& pBufs, + const pointField& p +) { - polyPatch::movePoints(p); + polyPatch::movePoints(pBufs, p); calcTransforms(); } -void Foam::cyclicPolyPatch::initUpdateMesh() +void Foam::cyclicPolyPatch::initUpdateMesh(PstreamBuffers& pBufs) { - polyPatch::initUpdateMesh(); + polyPatch::initUpdateMesh(pBufs); } -void Foam::cyclicPolyPatch::updateMesh() +void Foam::cyclicPolyPatch::updateMesh(PstreamBuffers& pBufs) { - polyPatch::updateMesh(); + polyPatch::updateMesh(pBufs); deleteDemandDrivenData(coupledPointsPtr_); deleteDemandDrivenData(coupledEdgesPtr_); } @@ -1105,7 +1114,11 @@ const Foam::edgeList& Foam::cyclicPolyPatch::coupledEdges() const } -void Foam::cyclicPolyPatch::initOrder(const primitivePatch& pp) const +void Foam::cyclicPolyPatch::initOrder +( + PstreamBuffers&, + const primitivePatch& pp +) const {} @@ -1115,6 +1128,7 @@ void Foam::cyclicPolyPatch::initOrder(const primitivePatch& pp) const // is identity, rotation is 0) bool Foam::cyclicPolyPatch::order ( + PstreamBuffers& pBufs, const primitivePatch& pp, labelList& faceMap, labelList& rotation @@ -1300,7 +1314,8 @@ bool Foam::cyclicPolyPatch::order << endl; // Recalculate untransformed face centres - //pointField rawHalf0Ctrs = calcFaceCentres(half0Faces, pp.points()); + //pointField rawHalf0Ctrs = + // calcFaceCentres(half0Faces, pp.points()); label vertI = 0; forAll(half1Ctrs, i) @@ -1413,7 +1428,8 @@ bool Foam::cyclicPolyPatch::order << endl; // Recalculate untransformed face centres - //pointField rawHalf0Ctrs = calcFaceCentres(half0Faces, pp.points()); + //pointField rawHalf0Ctrs = + // calcFaceCentres(half0Faces, pp.points()); label vertI = 0; forAll(half1Ctrs, i) @@ -1499,7 +1515,8 @@ bool Foam::cyclicPolyPatch::order << endl; // Recalculate untransformed face centres - //pointField rawHalf0Ctrs = calcFaceCentres(half0Faces, pp.points()); + //pointField rawHalf0Ctrs = + // calcFaceCentres(half0Faces, pp.points()); label vertI = 0; forAll(half1Ctrs, i) diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H index ea67348891..4f81975e60 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H @@ -176,22 +176,22 @@ protected: // Protected Member functions //- Initialise the calculation of the patch geometry - virtual void initGeometry(); + virtual void initGeometry(PstreamBuffers&); //- Calculate the patch geometry - virtual void calcGeometry(); + virtual void calcGeometry(PstreamBuffers&); //- Initialise the patches for moving points - virtual void initMovePoints(const pointField&); + virtual void initMovePoints(PstreamBuffers&, const pointField&); //- Correct patches after moving points - virtual void movePoints(const pointField&); + virtual void movePoints(PstreamBuffers&, const pointField&); //- Initialise the update of the patch topology - virtual void initUpdateMesh(); + virtual void initUpdateMesh(PstreamBuffers&); //- Update of the patch topology - virtual void updateMesh(); + virtual void updateMesh(PstreamBuffers&); public: @@ -391,7 +391,7 @@ public: //- Initialize ordering for primitivePatch. Does not // refer to *this (except for name() and type() etc.) - virtual void initOrder(const primitivePatch&) const; + virtual void initOrder(PstreamBuffers&, const primitivePatch&) const; //- Return new ordering for primitivePatch. // Ordering is -faceMap: for every face @@ -400,6 +400,7 @@ public: // (faceMap is identity, rotation is 0), true otherwise. virtual bool order ( + PstreamBuffers&, const primitivePatch&, labelList& faceMap, labelList& rotation diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C index 6e4df9f4e5..05969ee593 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C @@ -34,6 +34,7 @@ License #include "polyMesh.H" #include "Time.H" #include "transformList.H" +#include "PstreamBuffers.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -155,16 +156,11 @@ Foam::processorPolyPatch::~processorPolyPatch() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::processorPolyPatch::initGeometry() +void Foam::processorPolyPatch::initGeometry(PstreamBuffers& pBufs) { if (Pstream::parRun()) { - OPstream toNeighbProc - ( - Pstream::blocking, - neighbProcNo(), - 3*(sizeof(label) + size()*sizeof(vector) + sizeof(scalar)) - ); + UOPstream toNeighbProc(neighbProcNo(), pBufs); toNeighbProc << faceCentres() @@ -174,17 +170,13 @@ void Foam::processorPolyPatch::initGeometry() } -void Foam::processorPolyPatch::calcGeometry() +void Foam::processorPolyPatch::calcGeometry(PstreamBuffers& pBufs) { if (Pstream::parRun()) { { - IPstream fromNeighbProc - ( - Pstream::blocking, - neighbProcNo(), - 3*(sizeof(label) + size()*sizeof(vector) + sizeof(scalar)) - ); + UIPstream fromNeighbProc(neighbProcNo(), pBufs); + fromNeighbProc >> neighbFaceCentres_ >> neighbFaceAreas_ @@ -251,22 +243,30 @@ void Foam::processorPolyPatch::calcGeometry() } -void Foam::processorPolyPatch::initMovePoints(const pointField& p) +void Foam::processorPolyPatch::initMovePoints +( + PstreamBuffers& pBufs, + const pointField& p +) { - polyPatch::movePoints(p); - processorPolyPatch::initGeometry(); + polyPatch::movePoints(pBufs, p); + processorPolyPatch::initGeometry(pBufs); } -void Foam::processorPolyPatch::movePoints(const pointField&) +void Foam::processorPolyPatch::movePoints +( + PstreamBuffers& pBufs, + const pointField& +) { - processorPolyPatch::calcGeometry(); + processorPolyPatch::calcGeometry(pBufs); } -void Foam::processorPolyPatch::initUpdateMesh() +void Foam::processorPolyPatch::initUpdateMesh(PstreamBuffers& pBufs) { - polyPatch::initUpdateMesh(); + polyPatch::initUpdateMesh(pBufs); deleteDemandDrivenData(neighbPointsPtr_); deleteDemandDrivenData(neighbEdgesPtr_); @@ -303,14 +303,7 @@ void Foam::processorPolyPatch::initUpdateMesh() edgeIndex[patchEdgeI] = findIndex(fEdges, patchEdgeI); } - OPstream toNeighbProc - ( - Pstream::blocking, - neighbProcNo(), - 8*sizeof(label) // four headers of labelList - + 2*nPoints()*sizeof(label) // two point-based labellists - + 2*nEdges()*sizeof(label) // two edge-based labelLists - ); + UOPstream toNeighbProc(neighbProcNo(), pBufs); toNeighbProc << pointFace @@ -321,10 +314,10 @@ void Foam::processorPolyPatch::initUpdateMesh() } -void Foam::processorPolyPatch::updateMesh() +void Foam::processorPolyPatch::updateMesh(PstreamBuffers& pBufs) { // For completeness - polyPatch::updateMesh(); + polyPatch::updateMesh(pBufs); if (Pstream::parRun()) { @@ -336,7 +329,7 @@ void Foam::processorPolyPatch::updateMesh() { // Note cannot predict exact size since opposite nPoints might // be different from one over here. - IPstream fromNeighbProc(Pstream::blocking, neighbProcNo()); + UIPstream fromNeighbProc(neighbProcNo(), pBufs); fromNeighbProc >> nbrPointFace @@ -446,7 +439,11 @@ const Foam::labelList& Foam::processorPolyPatch::neighbEdges() const } -void Foam::processorPolyPatch::initOrder(const primitivePatch& pp) const +void Foam::processorPolyPatch::initOrder +( + PstreamBuffers& pBufs, + const primitivePatch& pp +) const { if (!Pstream::parRun()) { @@ -491,7 +488,7 @@ void Foam::processorPolyPatch::initOrder(const primitivePatch& pp) const pointField anchors(getAnchorPoints(pp, pp.points())); // Now send all info over to the neighbour - OPstream toNeighbour(Pstream::blocking, neighbProcNo()); + UOPstream toNeighbour(neighbProcNo(), pBufs); toNeighbour << ctrs << anchors; } } @@ -503,6 +500,7 @@ void Foam::processorPolyPatch::initOrder(const primitivePatch& pp) const // is identity, rotation is 0) bool Foam::processorPolyPatch::order ( + PstreamBuffers& pBufs, const primitivePatch& pp, labelList& faceMap, labelList& rotation @@ -539,7 +537,7 @@ bool Foam::processorPolyPatch::order // Receive data from neighbour { - IPstream fromNeighbour(Pstream::blocking, neighbProcNo()); + UIPstream fromNeighbour(neighbProcNo(), pBufs); fromNeighbour >> masterCtrs >> masterAnchors; } diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.H index a8948fee43..1955892727 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.H @@ -28,11 +28,9 @@ Class Description Neighbour processor patch. - Note: morph patch face ordering comes geometric or topological. - Geometric: no cyclics allowed (assumes faces coincident) - Topological: needs unmodified faces on both sides to correspond. Also - needs at least one per connected patch area (so all patch faces can be - visited from an unmodified face) + Note: morph patch face ordering tries to do a geometric ordering. + (assumes faces coincident) Hence will have problems when cyclics + are present. SourceFiles processorPolyPatch.C @@ -97,22 +95,22 @@ protected: // Protected Member functions //- Initialise the calculation of the patch geometry - void initGeometry(); + void initGeometry(PstreamBuffers&); //- Calculate the patch geometry - void calcGeometry(); + void calcGeometry(PstreamBuffers&); //- Initialise the patches for moving points - void initMovePoints(const pointField&); + void initMovePoints(PstreamBuffers&, const pointField&); //- Correct patches after moving points - void movePoints(const pointField&); + void movePoints(PstreamBuffers&, const pointField&); //- Initialise the update of the patch topology - virtual void initUpdateMesh(); + virtual void initUpdateMesh(PstreamBuffers&); //- Update of the patch topology - virtual void updateMesh(); + virtual void updateMesh(PstreamBuffers&); public: @@ -283,7 +281,7 @@ public: //- Initialize ordering for primitivePatch. Does not // refer to *this (except for name() and type() etc.) - virtual void initOrder(const primitivePatch&) const; + virtual void initOrder(PstreamBuffers&, const primitivePatch&) const; //- Return new ordering for primitivePatch. // Ordering is -faceMap: for every face @@ -292,6 +290,7 @@ public: // (faceMap is identity, rotation is 0), true otherwise. virtual bool order ( + PstreamBuffers&, const primitivePatch&, labelList& faceMap, labelList& rotation diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C index be0aa378a6..0a6bde6b4f 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C @@ -55,12 +55,12 @@ namespace Foam // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -void Foam::polyPatch::movePoints(const pointField& p) +void Foam::polyPatch::movePoints(PstreamBuffers&, const pointField& p) { primitivePatch::movePoints(p); } -void Foam::polyPatch::updateMesh() +void Foam::polyPatch::updateMesh(PstreamBuffers&) { clearAddressing(); } @@ -334,12 +334,13 @@ void Foam::polyPatch::write(Ostream& os) const } -void Foam::polyPatch::initOrder(const primitivePatch&) const +void Foam::polyPatch::initOrder(PstreamBuffers&, const primitivePatch&) const {} bool Foam::polyPatch::order ( + PstreamBuffers&, const primitivePatch&, labelList& faceMap, labelList& rotation diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H index f8c8fa72e7..5694e53823 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H @@ -56,6 +56,7 @@ namespace Foam class polyBoundaryMesh; class polyPatch; +class PstreamBuffers; Ostream& operator<<(Ostream&, const polyPatch&); @@ -101,26 +102,26 @@ protected: friend class polyBoundaryMesh; //- Initialise the calculation of the patch geometry - virtual void initGeometry() + virtual void initGeometry(PstreamBuffers&) {} //- Calculate the patch geometry - virtual void calcGeometry() + virtual void calcGeometry(PstreamBuffers&) {} //- Initialise the patches for moving points - virtual void initMovePoints(const pointField&) + virtual void initMovePoints(PstreamBuffers&, const pointField&) {} //- Correct patches after moving points - virtual void movePoints(const pointField& p); + virtual void movePoints(PstreamBuffers&, const pointField& p); //- Initialise the update of the patch topology - virtual void initUpdateMesh() + virtual void initUpdateMesh(PstreamBuffers&) {} //- Update of the patch topology - virtual void updateMesh(); + virtual void updateMesh(PstreamBuffers&); public: @@ -358,7 +359,7 @@ public: //- Initialize ordering for primitivePatch. Does not // refer to *this (except for name() and type() etc.) - virtual void initOrder(const primitivePatch&) const; + virtual void initOrder(PstreamBuffers&, const primitivePatch&) const; //- Return new ordering for primitivePatch. // Ordering is -faceMap: for every face @@ -367,6 +368,7 @@ public: // (faceMap is identity, rotation is 0), true otherwise. virtual bool order ( + PstreamBuffers&, const primitivePatch&, labelList& faceMap, labelList& rotation diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.C index 6be9ef348b..a86dd36010 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.C @@ -28,7 +28,6 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from components template < class Face, @@ -36,7 +35,6 @@ template class PointField, class PointType > - Foam::PrimitivePatch:: PrimitivePatch ( @@ -60,12 +58,12 @@ PrimitivePatch edgeLoopsPtr_(NULL), localPointsPtr_(NULL), localPointOrderPtr_(NULL), + faceCentresPtr_(NULL), faceNormalsPtr_(NULL), pointNormalsPtr_(NULL) {} -// Construct from components template < class Face, @@ -73,7 +71,6 @@ template class PointField, class PointType > - Foam::PrimitivePatch:: PrimitivePatch ( @@ -98,12 +95,12 @@ PrimitivePatch edgeLoopsPtr_(NULL), localPointsPtr_(NULL), localPointOrderPtr_(NULL), + faceCentresPtr_(NULL), faceNormalsPtr_(NULL), pointNormalsPtr_(NULL) {} -// Construct as copy template < class Face, @@ -111,7 +108,6 @@ template class PointField, class PointType > - Foam::PrimitivePatch:: PrimitivePatch ( @@ -135,6 +131,7 @@ PrimitivePatch edgeLoopsPtr_(NULL), localPointsPtr_(NULL), localPointOrderPtr_(NULL), + faceCentresPtr_(NULL), faceNormalsPtr_(NULL), pointNormalsPtr_(NULL) {} @@ -149,8 +146,8 @@ template class PointField, class PointType > - -Foam::PrimitivePatch::~PrimitivePatch() +Foam::PrimitivePatch:: +~PrimitivePatch() { clearOut(); } @@ -158,7 +155,6 @@ Foam::PrimitivePatch::~PrimitivePatch() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -// Correct patch after moving points template < class Face, @@ -166,7 +162,6 @@ template class PointField, class PointType > - void Foam::PrimitivePatch:: movePoints @@ -193,7 +188,6 @@ template class PointField, class PointType > - const Foam::edgeList& Foam::PrimitivePatch:: edges() const @@ -214,7 +208,6 @@ template class PointField, class PointType > - Foam::label Foam::PrimitivePatch:: nInternalEdges() const @@ -235,7 +228,6 @@ template class PointField, class PointType > - const Foam::labelList& Foam::PrimitivePatch:: boundaryPoints() const @@ -256,7 +248,6 @@ template class PointField, class PointType > - const Foam::labelListList& Foam::PrimitivePatch:: faceFaces() const @@ -277,7 +268,6 @@ template class PointField, class PointType > - const Foam::labelListList& Foam::PrimitivePatch:: edgeFaces() const @@ -298,7 +288,6 @@ template class PointField, class PointType > - const Foam::labelListList& Foam::PrimitivePatch:: faceEdges() const @@ -319,7 +308,6 @@ template class PointField, class PointType > - const Foam::labelListList& Foam::PrimitivePatch:: pointEdges() const @@ -340,7 +328,6 @@ template class PointField, class PointType > - const Foam::labelListList& Foam::PrimitivePatch:: pointFaces() const @@ -361,7 +348,6 @@ template class PointField, class PointType > - const Foam::List& Foam::PrimitivePatch:: localFaces() const @@ -382,7 +368,6 @@ template class PointField, class PointType > - const Foam::labelList& Foam::PrimitivePatch:: meshPoints() const @@ -403,7 +388,6 @@ template class PointField, class PointType > - const Foam::Map& Foam::PrimitivePatch:: meshPointMap() const @@ -424,7 +408,6 @@ template class PointField, class PointType > - const Foam::Field& Foam::PrimitivePatch:: localPoints() const @@ -445,7 +428,6 @@ template class PointField, class PointType > - const Foam::labelList& Foam::PrimitivePatch:: localPointOrder() const @@ -466,7 +448,6 @@ template class PointField, class PointType > - Foam::label Foam::PrimitivePatch:: whichPoint @@ -495,7 +476,26 @@ template class PointField, class PointType > +const Foam::Field& +Foam::PrimitivePatch:: +faceCentres() const +{ + if (!faceCentresPtr_) + { + calcFaceCentres(); + } + return *faceCentresPtr_; +} + + +template +< + class Face, + template class FaceList, + class PointField, + class PointType +> const Foam::Field& Foam::PrimitivePatch:: faceNormals() const @@ -516,7 +516,6 @@ template class PointField, class PointType > - const Foam::Field& Foam::PrimitivePatch:: pointNormals() const @@ -539,7 +538,6 @@ template class PointField, class PointType > - void Foam::PrimitivePatch:: operator= @@ -552,6 +550,7 @@ operator= FaceList::operator=(pp); } + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #include "PrimitivePatchAddressing.C" diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.H b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.H index c741b0839e..dbd8a9ffb5 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.H +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.H @@ -166,6 +166,9 @@ private: //- Local point order for most efficient search mutable labelList* localPointOrderPtr_; + //- Face centres + mutable Field* faceCentresPtr_; + //- Face unit normals mutable Field* faceNormalsPtr_; @@ -205,6 +208,9 @@ private: //- Calculate local point order void calcLocalPointOrder() const; + //- Calculate face centres + void calcFaceCentres() const; + //- Calculate unit face normals void calcFaceNormals() const; @@ -370,6 +376,9 @@ public: const labelListList& pointEdges ) const; + //- Return face centres for patch + const Field& faceCentres() const; + //- Return face normals for patch const Field& faceNormals() const; diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchAddressing.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchAddressing.C index 14d91344d1..5deecba26c 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchAddressing.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchAddressing.C @@ -48,7 +48,6 @@ template class PointField, class PointType > - void Foam::PrimitivePatch:: calcAddressing() const diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchBdryPoints.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchBdryPoints.C index fbd309d2cf..379445b1c4 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchBdryPoints.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchBdryPoints.C @@ -22,8 +22,6 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - \*---------------------------------------------------------------------------*/ #include "PrimitivePatch.H" @@ -39,7 +37,6 @@ template class PointField, class PointType > - void Foam::PrimitivePatch:: calcBdryPoints() const diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchCheck.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchCheck.C index 172bc9db7e..11fe2235ba 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchCheck.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchCheck.C @@ -41,7 +41,6 @@ template class PointField, class PointType > - void Foam::PrimitivePatch:: visitPointRegion @@ -120,7 +119,6 @@ template class PointField, class PointType > - typename Foam::PrimitivePatch::surfaceTopo Foam::PrimitivePatch:: surfaceType() const @@ -174,7 +172,6 @@ template class PointField, class PointType > - bool Foam::PrimitivePatch:: checkTopology @@ -245,7 +242,6 @@ template class PointField, class PointType > - bool Foam::PrimitivePatch:: checkPointManifold diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchClear.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchClear.C index 160bf5546f..c85cf14789 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchClear.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchClear.C @@ -22,8 +22,6 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - \*---------------------------------------------------------------------------*/ #include "PrimitivePatch.H" @@ -39,7 +37,6 @@ template class PointField, class PointType > - void Foam::PrimitivePatch:: clearGeom() @@ -52,6 +49,7 @@ clearGeom() } deleteDemandDrivenData(localPointsPtr_); + deleteDemandDrivenData(faceCentresPtr_); deleteDemandDrivenData(faceNormalsPtr_); deleteDemandDrivenData(pointNormalsPtr_); } @@ -64,7 +62,6 @@ template class PointField, class PointType > - void Foam::PrimitivePatch:: clearTopology() @@ -106,7 +103,6 @@ template class PointField, class PointType > - void Foam::PrimitivePatch:: clearPatchMeshAddr() @@ -132,7 +128,6 @@ template class PointField, class PointType > - void Foam::PrimitivePatch:: clearOut() diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchEdgeLoops.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchEdgeLoops.C index 3b7d87df90..80e36f166d 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchEdgeLoops.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchEdgeLoops.C @@ -31,7 +31,6 @@ Description #include "PrimitivePatch.H" - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template @@ -41,7 +40,6 @@ template class PointField, class PointType > - void Foam::PrimitivePatch:: calcEdgeLoops() const @@ -174,7 +172,6 @@ template class PointField, class PointType > - const Foam::labelListList& Foam::PrimitivePatch:: edgeLoops() const diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchLocalPointOrder.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchLocalPointOrder.C index b4359d83eb..7a20d8a81b 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchLocalPointOrder.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchLocalPointOrder.C @@ -39,14 +39,13 @@ template class PointField, class PointType > - void Foam::PrimitivePatch:: calcLocalPointOrder() const { // Note: Cannot use bandCompressing as point-point addressing does // not exist and is not considered generally useful. - // + // if (debug) { @@ -137,4 +136,5 @@ calcLocalPointOrder() const } } + // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchMeshData.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchMeshData.C index 30cffb6310..cd05f3f0e1 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchMeshData.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchMeshData.C @@ -27,8 +27,6 @@ License #include "PrimitivePatch.H" #include "Map.H" - - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template @@ -38,7 +36,6 @@ template class PointField, class PointType > - void Foam::PrimitivePatch:: calcMeshData() const @@ -76,13 +73,13 @@ calcMeshData() const ////- 1.5 code: //// if the point is used, set the mark to 1 - //forAll (*this, faceI) + //forAll(*this, facei) //{ - // const Face& curPoints = this->operator[](faceI); + // const Face& curPoints = this->operator[](facei); // - // forAll (curPoints, pointI) + // forAll(curPoints, pointi) // { - // markedPoints.insert(curPoints[pointI], -1); + // markedPoints.insert(curPoints[pointi], -1); // } //} // @@ -95,22 +92,22 @@ calcMeshData() const //sort(pointPatch); // //// For every point in map give it its label in mesh points - //forAll (pointPatch, pointI) + //forAll(pointPatch, pointi) //{ - // markedPoints.find(pointPatch[pointI])() = pointI; + // markedPoints.find(pointPatch[pointi])() = pointi; //} //- Unsorted version: DynamicList