diff --git a/README b/README index 52fba8b216..dbb820aad3 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ # #+TITLE: OpenFOAM README for version 1.6 #+AUTHOR: OpenCFD Ltd. -#+DATE: November 2009 +#+DATE: March 2010 #+LINK: http://www.opencfd.co.uk #+OPTIONS: author:nil ^:{} @@ -23,10 +23,10 @@ section "Running OpenFOAM in 32-bit mode". *** Qt (from http://trolltech.com/products/qt) - The ParaView 3.6.1 visualisation package requires Qt to be installed on the + The ParaView 3.7.0 visualisation package requires Qt to be installed on the system. ParaView's producers state that ParaView is only officially - supported on Qt version 4.3.x. However, we have found in limited tests that - ParaView works satisfactorily with newer versions of Qt than 4.3.x. To + supported on Qt version 4.6.x. However, we have found in limited tests that + ParaView works satisfactorily with Qt than 4.5.x. To check whether Qt4 is installed, and the version, type: + qmake --version @@ -44,13 +44,14 @@ + openSUSE-10.3: Version 4.3.1 + openSUSE-11.0: Version 4.4.0 + openSUSE-11.1: Version 4.4.3 + + openSUSE-11.2: Version 4.5.3 Compilation and running of ParaView has been successful using the libraries downloaded in the "libqt4-dev" package on ubuntu. If you don't have an appropriate version of Qt installed you can download - the sources from TrollTech e.g.: - ftp://ftp.trolltech.com/qt/source/qt-x11-opensource-src-4.3.5.tar.bz2 + the sources e.g.: + http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.6.2.tar.gz and compile and install in /usr/local or some other location that does not conflict with the pre-installed version. @@ -108,7 +109,7 @@ * Building from Sources (Optional) If you cannot find an appropriate binary pack for your platform, you can build the complete OpenFOAM from the source-pack. You will first need to compile or - obtain a recent version of gcc (we recomend gcc-4.3.?) for your platform, + obtain a recent version of gcc (we recommend gcc-4.4.?) for your platform, which may be obtained from http://gcc.gnu.org/. Install the compiler in @@ -157,16 +158,16 @@ Refer to the OpenFOAM User Guide at http://www.OpenFOAM.org/doc/user.html for more information. -* Compiling Paraview 3.6.1 and the PV3FoamReader module +* Compiling Paraview 3.7.0 and the PV3FoamReader module If there are problems encountered with ParaView, then it may be necessary to compile ParaView from sources. The compilation is a fairly simple process using the makeParaView script (found in ThirdParty directory), which has worked in our tests with other - packages supplied in the ThirdParty directory, namely cmake-2.6.4 and - gcc-4.3.3. Execute the following: + packages supplied in the ThirdParty directory, namely cmake-2.8.0 and + gcc-4.4.3. Execute the following: + cd $WM_THIRD_PARTY_DIR - + rm -rf paraview-3.6.1/platforms - + rm -rf platforms/*/paraview-3.6.1 + + rm -rf paraview-3.7.0/platforms + + rm -rf platforms/*/paraview-3.7.0 + ./makeParaView The PV3blockMeshReader and the PV3FoamReader ParaView plugins are compiled @@ -178,7 +179,7 @@ *** Compiling Paraview with a local version of Qt If the user still encounters problems with ParaView, it may relate to the version of Qt, in which case, it is recommended that the user first - downloads a supported version of Qt /e.g./ 4.3.5 as described in the section + downloads a supported version of Qt /e.g./ 4.5.3 as described in the section on "Qt". The user should unpack the source pack in the $WM_THIRD_PARTY_DIR. Then the user can build Qt by executing from within $WM_THIRD_PARTY_DIR: + ./makeQt diff --git a/applications/solvers/compressible/rhoPorousMRFPimpleFoam/Make/files b/applications/solvers/compressible/rhoPorousMRFPimpleFoam/Make/files new file mode 100644 index 0000000000..a798455eb7 --- /dev/null +++ b/applications/solvers/compressible/rhoPorousMRFPimpleFoam/Make/files @@ -0,0 +1,4 @@ +rhoPorousMRFPimpleFoam.C + +EXE = $(FOAM_APPBIN)/rhoPorousMRFPimpleFoam + diff --git a/applications/solvers/compressible/rhoPorousMRFPimpleFoam/Make/options b/applications/solvers/compressible/rhoPorousMRFPimpleFoam/Make/options new file mode 100644 index 0000000000..61c1b6fe46 --- /dev/null +++ b/applications/solvers/compressible/rhoPorousMRFPimpleFoam/Make/options @@ -0,0 +1,15 @@ +EXE_INC = \ + -I../rhoPimpleFoam \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel \ + -I$(LIB_SRC)/finiteVolume/cfdTools \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +EXE_LIBS = \ + -lbasicThermophysicalModels \ + -lspecie \ + -lcompressibleRASModels \ + -lcompressibleLESModels \ + -lfiniteVolume \ + -lmeshTools diff --git a/applications/solvers/compressible/rhoPorousMRFPimpleFoam/UEqn.H b/applications/solvers/compressible/rhoPorousMRFPimpleFoam/UEqn.H new file mode 100644 index 0000000000..3b4ead17e7 --- /dev/null +++ b/applications/solvers/compressible/rhoPorousMRFPimpleFoam/UEqn.H @@ -0,0 +1,39 @@ +// Solve the Momentum equation + +tmp UEqn +( + pZones.ddt(rho, U) + + fvm::div(phi, U) + + turbulence->divDevRhoReff(U) +); + +if (oCorr == nOuterCorr-1) +{ + UEqn().relax(1); +} +else +{ + UEqn().relax(); +} + +mrfZones.addCoriolis(rho, UEqn()); +pZones.addResistance(UEqn()); + +volScalarField rUA = 1.0/UEqn().A(); + +if (momentumPredictor) +{ + if (oCorr == nOuterCorr-1) + { + solve(UEqn() == -fvc::grad(p), mesh.solver("UFinal")); + } + else + { + solve(UEqn() == -fvc::grad(p)); + } +} +else +{ + U = rUA*(UEqn().H() - fvc::grad(p)); + U.correctBoundaryConditions(); +} diff --git a/applications/solvers/compressible/rhoPorousMRFPimpleFoam/createFields.H b/applications/solvers/compressible/rhoPorousMRFPimpleFoam/createFields.H new file mode 100644 index 0000000000..b9a86ef995 --- /dev/null +++ b/applications/solvers/compressible/rhoPorousMRFPimpleFoam/createFields.H @@ -0,0 +1,70 @@ + Info<< "Reading thermophysical properties\n" << endl; + + autoPtr pThermo + ( + basicPsiThermo::New(mesh) + ); + basicPsiThermo& thermo = pThermo(); + + volScalarField& p = thermo.p(); + volScalarField& h = thermo.h(); + const volScalarField& psi = thermo.psi(); + + volScalarField rho + ( + IOobject + ( + "rho", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + thermo.rho() + ); + + Info<< "Reading field U\n" << endl; + volVectorField U + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + #include "compressibleCreatePhi.H" + + dimensionedScalar pMin + ( + mesh.solutionDict().subDict("PIMPLE").lookup("pMin") + ); + + Info<< "Creating turbulence model\n" << endl; + autoPtr turbulence + ( + compressible::turbulenceModel::New + ( + rho, + U, + phi, + thermo + ) + ); + + //dimensionedScalar initialMass = fvc::domainIntegrate(rho); + + + Info<< "Creating field DpDt\n" << endl; + volScalarField DpDt = + fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); + + MRFZones mrfZones(mesh); + mrfZones.correctBoundaryVelocity(U); + + porousZones pZones(mesh); + Switch pressureImplicitPorosity(false); diff --git a/applications/solvers/compressible/rhoPorousMRFPimpleFoam/pEqn.H b/applications/solvers/compressible/rhoPorousMRFPimpleFoam/pEqn.H new file mode 100644 index 0000000000..c74fb4d84b --- /dev/null +++ b/applications/solvers/compressible/rhoPorousMRFPimpleFoam/pEqn.H @@ -0,0 +1,123 @@ +rho = thermo.rho(); + +volScalarField rUA = 1.0/UEqn().A(); +U = rUA*UEqn().H(); + +if (nCorr <= 1) +{ + UEqn.clear(); +} + +if (transonic) +{ + surfaceScalarField phid + ( + "phid", + fvc::interpolate(psi) + *( + (fvc::interpolate(U) & mesh.Sf()) + + fvc::ddtPhiCorr(rUA, rho, U, phi) + ) + ); + mrfZones.relativeFlux(fvc::interpolate(psi), phid); + + for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + fvScalarMatrix pEqn + ( + fvm::ddt(psi, p) + + fvm::div(phid, p) + - fvm::laplacian(rho*rUA, p) + ); + + if + ( + oCorr == nOuterCorr-1 + && corr == nCorr-1 + && nonOrth == nNonOrthCorr + ) + { + pEqn.solve(mesh.solver("pFinal")); + } + else + { + pEqn.solve(); + } + + if (nonOrth == nNonOrthCorr) + { + phi == pEqn.flux(); + } + } +} +else +{ + phi = + fvc::interpolate(rho)* + ( + (fvc::interpolate(U) & mesh.Sf()) + //+ fvc::ddtPhiCorr(rUA, rho, U, phi) + ); + mrfZones.relativeFlux(fvc::interpolate(rho), phi); + + for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + // Pressure corrector + fvScalarMatrix pEqn + ( + fvm::ddt(psi, p) + + fvc::div(phi) + - fvm::laplacian(rho*rUA, p) + ); + + if + ( + oCorr == nOuterCorr-1 + && corr == nCorr-1 + && nonOrth == nNonOrthCorr + ) + { + pEqn.solve(mesh.solver("pFinal")); + } + else + { + pEqn.solve(); + } + + if (nonOrth == nNonOrthCorr) + { + phi += pEqn.flux(); + } + } +} + +#include "rhoEqn.H" +#include "compressibleContinuityErrs.H" + +//if (oCorr != nOuterCorr-1) +{ + // Explicitly relax pressure for momentum corrector + p.relax(); + + rho = thermo.rho(); + rho.relax(); + Info<< "rho max/min : " << max(rho).value() + << " " << min(rho).value() << endl; +} + +U -= rUA*fvc::grad(p); +U.correctBoundaryConditions(); + +DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); + +bound(p, pMin); + +// For closed-volume cases adjust the pressure and density levels +// to obey overall mass continuity +/* +if (closedVolume) +{ + p += (initialMass - fvc::domainIntegrate(psi*p)) + /fvc::domainIntegrate(psi); +} +*/ diff --git a/applications/solvers/compressible/rhoPorousMRFPimpleFoam/rhoPorousMRFPimpleFoam.C b/applications/solvers/compressible/rhoPorousMRFPimpleFoam/rhoPorousMRFPimpleFoam.C new file mode 100644 index 0000000000..45d7646d04 --- /dev/null +++ b/applications/solvers/compressible/rhoPorousMRFPimpleFoam/rhoPorousMRFPimpleFoam.C @@ -0,0 +1,105 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2010 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 + +Application + rhoPorousMRFPimpleFoam + +Description + Transient solver for laminar or turbulent flow of compressible fluids + with support for porous media and MRF for HVAC and similar applications. + + Uses the flexible PIMPLE (PISO-SIMPLE) solution for time-resolved and + pseudo-transient simulations. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "basicPsiThermo.H" +#include "turbulenceModel.H" +#include "bound.H" +#include "MRFZones.H" +#include "porousZones.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "createFields.H" + #include "initContinuityErrs.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + #include "readTimeControls.H" + #include "readPIMPLEControls.H" + #include "compressibleCourantNo.H" + #include "setDeltaT.H" + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + if (nOuterCorr != 1) + { + p.storePrevIter(); + rho.storePrevIter(); + } + + #include "rhoEqn.H" + + // --- Pressure-velocity PIMPLE corrector loop + for (int oCorr=0; oCorrcorrect(); + } + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/alphaEqns.H b/applications/solvers/multiphase/compressibleInterDyMFoam/alphaEqns.H index 819cd0f538..f545262767 100644 --- a/applications/solvers/multiphase/compressibleInterDyMFoam/alphaEqns.H +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/alphaEqns.H @@ -59,7 +59,17 @@ alpharScheme ); - MULES::explicitSolve(oneField(), alpha1, phi, phiAlpha1, Sp, Su, 1, 0); + MULES::explicitSolve + ( + geometricOneField(), + alpha1, + phi, + phiAlpha1, + Sp, + Su, + 1, + 0 + ); surfaceScalarField rho1f = fvc::interpolate(rho1); surfaceScalarField rho2f = fvc::interpolate(rho2); diff --git a/applications/solvers/multiphase/compressibleInterFoam/alphaEqns.H b/applications/solvers/multiphase/compressibleInterFoam/alphaEqns.H index 819cd0f538..dd704c0693 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/alphaEqns.H +++ b/applications/solvers/multiphase/compressibleInterFoam/alphaEqns.H @@ -59,7 +59,7 @@ alpharScheme ); - MULES::explicitSolve(oneField(), alpha1, phi, phiAlpha1, Sp, Su, 1, 0); + MULES::explicitSolve(geometricOneField(), alpha1, phi, phiAlpha1, Sp, Su, 1, 0); surfaceScalarField rho1f = fvc::interpolate(rho1); surfaceScalarField rho2f = fvc::interpolate(rho2); diff --git a/applications/solvers/multiphase/interMixingFoam/alphaEqns.H b/applications/solvers/multiphase/interMixingFoam/alphaEqns.H index f9bad0a705..972d1d7121 100644 --- a/applications/solvers/multiphase/interMixingFoam/alphaEqns.H +++ b/applications/solvers/multiphase/interMixingFoam/alphaEqns.H @@ -70,12 +70,12 @@ MULES::limiter ( allLambda, - oneField(), + geometricOneField(), alpha1, phiAlpha1BD, phiAlpha1, - zeroField(), - zeroField(), + zero(), + zero(), 1, 0, 3 @@ -107,12 +107,12 @@ MULES::limiter ( allLambda, - oneField(), + geometricOneField(), alpha2, phiAlpha2BD, phiAlpha2, - zeroField(), - zeroField(), + zero(), + zero(), 1, 0, 3 diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqn.H b/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqn.H index 15a5291ee6..a232056b8d 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqn.H +++ b/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqn.H @@ -51,8 +51,8 @@ ); //MULES::explicitSolve(alpha1, phi, phiAlpha, 1, 0); - //MULES::explicitSolve(oneField(), alpha1, phi, phiAlpha, Sp, Su, 1, 0); - MULES::implicitSolve(oneField(), alpha1, phi, phiAlpha, Sp, Su, 1, 0); + //MULES::explicitSolve(geometricOneField(), alpha1, phi, phiAlpha, Sp, Su, 1, 0); + MULES::implicitSolve(geometricOneField(), alpha1, phi, phiAlpha, Sp, Su, 1, 0); rhoPhi += (runTime.deltaT()/totalDeltaT) diff --git a/applications/utilities/mesh/generation/snappyHexMesh/Make/options b/applications/utilities/mesh/generation/snappyHexMesh/Make/options index 77932a8cdc..3c224d318f 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/Make/options +++ b/applications/utilities/mesh/generation/snappyHexMesh/Make/options @@ -11,6 +11,7 @@ EXE_INC = \ EXE_LIBS = \ -lfiniteVolume \ -ldecompositionMethods \ + -L$(FOAM_MPI_LIBBIN) -lptscotchDecomp \ -lmeshTools \ -ldynamicMesh \ -lautoMesh diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index 4ab7a771be..e9d637cddf 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -347,7 +347,7 @@ int main(int argc, char *argv[]) << "You have selected decomposition method " << decomposer.typeName << " which is not parallel aware." << endl - << "Please select one that is (hierarchical, parMetis)" + << "Please select one that is (hierarchical, ptscotch)" << exit(FatalError); } diff --git a/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.C b/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.C index 52735eb41a..fa8d5c780e 100644 --- a/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.C +++ b/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.C @@ -28,20 +28,6 @@ License #include "Time.H" #include "plane.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -const Foam::label Foam::mirrorFvMesh::cellRenumber[8][8] = -{ - {-1, -1, -1, -1, -1, -1, -1, -1}, // unknown - {-1, -1, -1, -1, -1, -1, -1, -1}, // - {-1, -1, -1, -1, -1, -1, -1, -1}, // - { 0, 3, 2, 1, 4, 7, 6, 5}, // hex - { 2, 1, 0, 5, 4, 3, 6, -1}, // wedge - { 0, 2, 1, 3, 5, 4, -1, -1}, // prism - { 0, 3, 2, 1, 4, -1, -1, -1}, // pyramid - { 2, 1, 0, 3, -1, -1, -1, -1}, // tet -}; - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io) diff --git a/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.H b/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.H index fd3903d6ad..01033c963c 100644 --- a/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.H +++ b/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.H @@ -71,12 +71,6 @@ class mirrorFvMesh public: - // Static data - - //- Cell renumnering table - static const label cellRenumber[8][8]; - - // Constructors //- Construct from IOobject diff --git a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C index b382a79d0d..8034fe5b9b 100644 --- a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C +++ b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C @@ -68,6 +68,104 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +label addPointZone(const polyMesh& mesh, const word& name) +{ + label zoneID = mesh.pointZones().findZoneID(name); + + if (zoneID != -1) + { + Info<< "Reusing existing pointZone " + << mesh.pointZones()[zoneID].name() + << " at index " << zoneID << endl; + } + else + { + pointZoneMesh& pointZones = const_cast(mesh).pointZones(); + zoneID = pointZones.size(); + Info<< "Adding pointZone " << name << " at index " << zoneID << endl; + + pointZones.setSize(zoneID+1); + pointZones.set + ( + zoneID, + new pointZone + ( + name, + labelList(0), + zoneID, + pointZones + ) + ); + } + return zoneID; +} + + +label addFaceZone(const polyMesh& mesh, const word& name) +{ + label zoneID = mesh.faceZones().findZoneID(name); + + if (zoneID != -1) + { + Info<< "Reusing existing faceZone " << mesh.faceZones()[zoneID].name() + << " at index " << zoneID << endl; + } + else + { + faceZoneMesh& faceZones = const_cast(mesh).faceZones(); + zoneID = faceZones.size(); + Info<< "Adding faceZone " << name << " at index " << zoneID << endl; + + faceZones.setSize(zoneID+1); + faceZones.set + ( + zoneID, + new faceZone + ( + name, + labelList(0), + boolList(), + zoneID, + faceZones + ) + ); + } + return zoneID; +} + + +label addCellZone(const polyMesh& mesh, const word& name) +{ + label zoneID = mesh.cellZones().findZoneID(name); + + if (zoneID != -1) + { + Info<< "Reusing existing cellZone " << mesh.cellZones()[zoneID].name() + << " at index " << zoneID << endl; + } + else + { + cellZoneMesh& cellZones = const_cast(mesh).cellZones(); + zoneID = cellZones.size(); + Info<< "Adding cellZone " << name << " at index " << zoneID << endl; + + cellZones.setSize(zoneID+1); + cellZones.set + ( + zoneID, + new cellZone + ( + name, + labelList(0), + zoneID, + cellZones + ) + ); + } + return zoneID; +} + + // Checks whether patch present void checkPatch(const polyBoundaryMesh& bMesh, const word& name) { @@ -211,29 +309,20 @@ int main(int argc, char *argv[]) polyTopoChanger stitcher(mesh); stitcher.setSize(1); - DynamicList pz; - DynamicList fz; - DynamicList cz; + mesh.pointZones().clearAddressing(); + mesh.faceZones().clearAddressing(); + mesh.cellZones().clearAddressing(); if (perfectCover) { // Add empty zone for resulting internal faces - fz.append - ( - new faceZone - ( - cutZoneName, - isf, - boolList(masterPatch.size(), false), - 0, - mesh.faceZones() - ) - ); + label cutZoneID = addFaceZone(mesh, cutZoneName); - // Note: make sure to add the zones BEFORE constructing polyMeshModifier - // (since looks up various zones at construction time) - Info<< "Adding point and face zones" << endl; - mesh.addZones(pz.shrink(), fz.shrink(), cz.shrink()); + mesh.faceZones()[cutZoneID].resetAddressing + ( + isf, + boolList(masterPatch.size(), false) + ); // Add the perfect interface mesh modifier stitcher.set @@ -252,27 +341,15 @@ int main(int argc, char *argv[]) } else { - pz.append - ( - new pointZone - ( - mergePatchName + "CutPointZone", - labelList(0), - 0, - mesh.pointZones() - ) - ); + label pointZoneID = addPointZone(mesh, mergePatchName + "CutPointZone"); + mesh.pointZones()[pointZoneID] = labelList(0); - fz.append + label masterZoneID = addFaceZone(mesh, mergePatchName + "MasterZone"); + + mesh.faceZones()[masterZoneID].resetAddressing ( - new faceZone - ( - mergePatchName + "MasterZone", - isf, - boolList(masterPatch.size(), false), - 0, - mesh.faceZones() - ) + isf, + boolList(masterPatch.size(), false) ); // Slave patch @@ -284,42 +361,27 @@ int main(int argc, char *argv[]) labelList osf(slavePatch.size()); - forAll(osf, i) + forAll (osf, i) { osf[i] = slavePatch.start() + i; } - fz.append + label slaveZoneID = addFaceZone(mesh, mergePatchName + "SlaveZone"); + mesh.faceZones()[slaveZoneID].resetAddressing ( - new faceZone - ( - mergePatchName + "SlaveZone", - osf, - boolList(slavePatch.size(), false), - 1, - mesh.faceZones() - ) + osf, + boolList(slavePatch.size(), false) ); // Add empty zone for cut faces - fz.append + label cutZoneID = addFaceZone(mesh, cutZoneName); + mesh.faceZones()[cutZoneID].resetAddressing ( - new faceZone - ( - cutZoneName, - labelList(0), - boolList(0, false), - 2, - mesh.faceZones() - ) + labelList(0), + boolList(0, false) ); - // Note: make sure to add the zones BEFORE constructing polyMeshModifier - // (since looks up various zones at construction time) - Info<< "Adding point and face zones" << endl; - mesh.addZones(pz.shrink(), fz.shrink(), cz.shrink()); - // Add the sliding interface mesh modifier stitcher.set ( diff --git a/applications/utilities/parallelProcessing/decomposePar/Make/options b/applications/utilities/parallelProcessing/decomposePar/Make/options index b79ab555e8..3ae2128234 100644 --- a/applications/utilities/parallelProcessing/decomposePar/Make/options +++ b/applications/utilities/parallelProcessing/decomposePar/Make/options @@ -7,6 +7,6 @@ EXE_INC = \ EXE_LIBS = \ -lfiniteVolume \ -lgenericPatchFields \ - -ldecompositionMethods \ + -ldecompositionMethods -lmetisDecomp -lscotchDecomp \ -llagrangian \ -lmeshTools diff --git a/applications/utilities/parallelProcessing/redistributeMeshPar/Make/options b/applications/utilities/parallelProcessing/redistributeMeshPar/Make/options index b691383cf6..505234515d 100644 --- a/applications/utilities/parallelProcessing/redistributeMeshPar/Make/options +++ b/applications/utilities/parallelProcessing/redistributeMeshPar/Make/options @@ -7,5 +7,6 @@ EXE_INC = \ EXE_LIBS = \ -lfiniteVolume \ -ldecompositionMethods \ + -L$(FOAM_MPI_LIBBIN) -lptscotchDecomp \ -lmeshTools \ -ldynamicMesh diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H index 577edfc310..9febbad6f8 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H @@ -356,8 +356,15 @@ class vtkPV3Foam //- Zone info void updateInfoZones(vtkDataArraySelection*); - //- Read zone names for zoneType from file - wordList readZoneNames(const word& zoneType); + //- Get non-empty zone names for zoneType from file + wordList getZoneNames(const word& zoneType) const; + + //- Get non-empty zone names from mesh info + template + wordList getZoneNames + ( + const ZoneMesh& + ) const; //- Add objects of Type to paraview array selection template diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C index f83be3ee15..bdac311fcd 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C @@ -82,9 +82,31 @@ public: // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -Foam::wordList Foam::vtkPV3Foam::readZoneNames(const word& zoneType) +template +Foam::wordList Foam::vtkPV3Foam::getZoneNames +( + const ZoneMesh& zmesh +) const { - wordList zoneNames; + wordList names(zmesh.size()); + label nZone = 0; + + forAll(zmesh, zoneI) + { + if (zmesh[zoneI].size()) + { + names[nZone++] = zmesh[zoneI].name(); + } + } + names.setSize(nZone); + + return names; +} + + +Foam::wordList Foam::vtkPV3Foam::getZoneNames(const word& zoneType) const +{ + wordList names; // mesh not loaded - read from file IOobject ioObj @@ -107,14 +129,14 @@ Foam::wordList Foam::vtkPV3Foam::readZoneNames(const word& zoneType) { zonesEntries zones(ioObj); - zoneNames.setSize(zones.size()); + names.setSize(zones.size()); forAll(zones, zoneI) { - zoneNames[zoneI] = zones[zoneI].keyword(); + names[zoneI] = zones[zoneI].keyword(); } } - return zoneNames; + return names; } @@ -312,11 +334,11 @@ void Foam::vtkPV3Foam::updateInfoZones // ~~~~~~~~~~~~~~~~~~~~~ if (meshPtr_) { - namesLst = meshPtr_->cellZones().names(); + namesLst = getZoneNames(meshPtr_->cellZones()); } else { - namesLst = readZoneNames("cellZones"); + namesLst = getZoneNames("cellZones"); } arrayRangeCellZones_.reset(arraySelection->GetNumberOfArrays()); @@ -335,11 +357,11 @@ void Foam::vtkPV3Foam::updateInfoZones // ~~~~~~~~~~~~~~~~~~~~~ if (meshPtr_) { - namesLst = meshPtr_->faceZones().names(); + namesLst = getZoneNames(meshPtr_->faceZones()); } else { - namesLst = readZoneNames("faceZones"); + namesLst = getZoneNames("faceZones"); } arrayRangeFaceZones_.reset(arraySelection->GetNumberOfArrays()); @@ -358,11 +380,11 @@ void Foam::vtkPV3Foam::updateInfoZones // ~~~~~~~~~~~~~~~~~~~~~~ if (meshPtr_) { - namesLst = meshPtr_->pointZones().names(); + namesLst = getZoneNames(meshPtr_->pointZones()); } else { - namesLst = readZoneNames("pointZones"); + namesLst = getZoneNames("pointZones"); } arrayRangePointZones_.reset(arraySelection->GetNumberOfArrays()); diff --git a/bin/foamCleanPath b/bin/foamCleanPath index 0ef171e455..8f98b06423 100755 --- a/bin/foamCleanPath +++ b/bin/foamCleanPath @@ -43,7 +43,6 @@ usage() { cat <&2 Usage: ${0##*/} [OPTION] path [wildcard1] .. [wildcardN] options: - -space treat 'path' as space-delimited (eg, from C-Shell) -strip remove inaccessible directories -help print the usage @@ -57,7 +56,7 @@ USAGE } -unset space strip +unset strip # parse options while [ "$#" -gt 0 ] do @@ -65,10 +64,6 @@ do -h | -help) usage ;; - -space) - space=true - shift - ;; -strip) strip=true shift @@ -82,12 +77,7 @@ done [ "$#" -ge 1 ] || usage -if [ "$space" = true ] -then - dirList=$(echo "$1" | sed -e 's/ /:/g') -else - dirList="$1" -fi +dirList="$1" shift ##DEBUG echo "input>$dirList<" 1>&2 @@ -140,11 +130,8 @@ done IFS=' ' set -- $dirList -# join on ':', unless -space option was specified -if [ "$space" != true ] -then - IFS=':' -fi +# rejoin on ':' +IFS=':' dirList="$*" # restore IFS diff --git a/bin/foamEndJob b/bin/foamEndJob index f82f7409ce..ba213c86aa 100755 --- a/bin/foamEndJob +++ b/bin/foamEndJob @@ -85,7 +85,8 @@ setRawEntry() { oldLine=`echo "$oldNumLine" | sed -e 's/^[^:]*://'` oldKey=`getKey "$oldLine"` oldVal=`getRawEntry $1 "$2"` - if [ ! "$oldKey" -o ! "$oldVal" -o ! "$oldLine" ]; then + if [ ! "$oldKey" -o ! "$oldVal" -o ! "$oldLine" ] + then echo "setRawStringEntry: entry $2 not found in $1" echo "oldKey=$oldKey" echo "lineNo=$lineNo" @@ -134,9 +135,12 @@ getBoolEntry() } # newerFile file1 file2 -newerFile() { +# ... could also use if [ $file1 -nt $file2 ] ... +newerFile() +{ latest=`ls -1 -t $1 $2 2> /dev/null | head -1` - if [ "$latest" = $1 ]; then + if [ "$latest" = $1 ] + then return 0 else return 1 @@ -149,8 +153,8 @@ processExists() { ps -u $LOGNAME -o 'pid' | fgrep $1 >/dev/null } -printUsage() { -cat << USAGELABEL +usage() { +cat << USAGE Usage: $PROGNAME [-n] or $PROGNAME -c @@ -165,7 +169,8 @@ finish. Restores original controlDict if The -c option clears any outstanding $PROGNAME for the case. -USAGELABEL +USAGE + exit 1 } @@ -174,7 +179,8 @@ restoreDict() { trap 2 3 15 echo "$PROGNAME : Restoring controlDict from controlDict_bak." - if [ -r ${controlDict}_bak ]; then + if [ -r ${controlDict}_bak ] + then cp ${controlDict}_bak $controlDict fi @@ -208,61 +214,69 @@ esac # # Initial checks # -if [ $# -lt 3 ]; then - printUsage - exit 1 +if [ $# -lt 3 ] +then + usage fi + STOPNOW='' -if [ $1 = '-n' ]; then +if [ $1 = '-n' ] +then STOPNOW='yes' shift fi CLEAR='' -if [ $1 = '-c' ]; then +if [ $1 = '-c' ] +then CLEAR='yes' shift - if [ $# -ne 2 ]; then - printUsage - exit 1 + if [ $# -ne 2 ] + then + usage fi ROOT=$1 CASE=$2 else - if [ $# -ne 3 ]; then - printUsage - exit 1 + if [ $# -ne 3 ] + then + usage fi ROOT=$1 CASE=$2 PID=$3 fi -CASE=`echo $CASE | sed -e 's!/.*!!'` #strip of processorXXX ending +CASE=`echo $CASE | sed -e 's!/.*!!'` # strip of processorXXX ending #- Pid actually running -if [ ! "$CLEAR" ]; then +if [ ! "$CLEAR" ] +then processExists $PID - if [ $? -ne 0 ] ;then + if [ $? -ne 0 ] + then echo "$PROGNAME : process $PID not running." exit 1 fi fi #- case directory writeable -if [ ! -w $ROOT/$CASE ]; then +if [ ! -w $ROOT/$CASE ] +then echo "$PROGNAME : $ROOT/$CASE is not writeable." exit 1 fi #- Controldict writeable controlDict=$ROOT/$CASE/system/controlDict -if [ ! -w $controlDict ]; then +if [ ! -w $controlDict ] +then echo "$PROGNAME : $controlDict is not writeable." exit 1 fi #- runTimeModifiable getBoolEntry $controlDict 'runTimeModifiable' -if [ $? -ne 0 ]; then +if [ $? -ne 0 ] +then echo "$PROGNAME : runTimeModifiable not true in dictionary $controlDict." exit 1 fi @@ -270,12 +284,14 @@ fi # #- Check if another foamEndJob running # -if [ "$CLEAR" ]; then +if [ "$CLEAR" ] +then pidFiles=`ls $ROOT/$CASE/.foamEndJob* 2>/dev/null` for pidFile in $pidFiles do pid=`cat $pidFile` - if [ "$pid" ]; then + if [ "$pid" ] + then echo "$PROGNAME : found $PROGNAME (pid $pid) for Foam process" echo " root: $ROOT" echo " case: $CASE" @@ -288,11 +304,14 @@ if [ "$CLEAR" ]; then fi pidFile=$ROOT/$CASE/.foamEndJob${PID} -if [ -f $pidFile ]; then +if [ -f $pidFile ] +then pid=`cat $pidFile` - if [ "$pid" ]; then + if [ "$pid" ] + then processExists $pid - if [ $? -eq 0 ] ;then + if [ $? -eq 0 ] + then echo "$PROGNAME : found running $PROGNAME (pid $pid) for Foam process" echo " root: $ROOT" echo " case: $CASE" @@ -314,28 +333,32 @@ echo $$ > $pidFile #- startTime startTime=`getEntry $controlDict 'startTime'` -if [ ! "$startTime" ]; then +if [ ! "$startTime" ] +then echo "$PROGNAME : startTime not set in dictionary $controlDict." exit 1 fi #- Write interval writeInterval=`getEntry $controlDict 'writeInterval'` -if [ ! "$writeInterval" ]; then +if [ ! "$writeInterval" ] +then echo "$PROGNAME : writeInterval not set in dictionary $controlDict." exit 1 fi #- stopAt stopAt=`getEntry $controlDict 'stopAt'` -if [ ! "$stopAt" ]; then +if [ ! "$stopAt" ] +then echo "$PROGNAME : stopAt not set in dictionary $controlDict." exit 1 fi #- endTime endTime=`getEntry $controlDict 'endTime'` -if [ ! "$endTime" ]; then +if [ ! "$endTime" ] +then echo "$PROGNAME : endTime not set in dictionary $controlDict." exit 1 fi @@ -353,7 +376,8 @@ cp $controlDict ${controlDict}_bak #- Set up handler to restore controlDict trap restoreDict 2 3 15 -if [ "$STOPNOW" ]; then +if [ "$STOPNOW" ] +then setRawEntry $controlDict 'stopAt' 'nextWrite' setRawEntry $controlDict 'writeInterval' '1' @@ -385,7 +409,8 @@ if newerFile ${controlDict} ${controlDict}_bak; then iter=0 while newerFile ${controlDict} ${controlDict}_bak do - if [ $iter -ge 120 ]; then + if [ $iter -ge 120 ] + then #- 120*5 sec = 10 mins passed. Give up echo "$PROGNAME : File date not yet ok after 10 mins. Giving up." break @@ -412,22 +437,25 @@ while true do sleep 5 - if [ ! -r ${controlDict}_bak ]; then + if [ ! -r ${controlDict}_bak ] + then echo "$PROGNAME : ${controlDict}_bak dissappeared. Exiting without restore." exit 1 fi - if newerFile ${controlDict} ${controlDict}_bak; then + if newerFile ${controlDict} ${controlDict}_bak + then echo "$PROGNAME : ${controlDict} modified externally. Exiting without restore." exit 0 fi processExists $PID - if [ $? -ne 0 ] ;then + if [ $? -ne 0 ] + then #- Job finished break fi - #echo "Foam job $PID still running ..." + # echo "Foam job $PID still running ..." done #- Dictionary restore diff --git a/bin/foamEtcFile b/bin/foamEtcFile index 851ef739b4..b749a76e97 100755 --- a/bin/foamEtcFile +++ b/bin/foamEtcFile @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -27,8 +27,17 @@ # foamEtcFile # # Description -# Locate user/site/shipped file with the semantics used in the -# ~OpenFOAM/fileName expansion +# Locate user/group/shipped file with semantics similar to the +# ~OpenFOAM/fileName expansion. +# +# The -mode option can be used to allow chaining from +# personal settings to site-wide settings. +# +# For example, within the user ~/.OpenFOAM//prefs.sh: +# @verbatim +# foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile -m go prefs.sh` \ +# && _foamSource $foamPrefs +# @endverbatim # #------------------------------------------------------------------------------- unset listOpt quietOpt @@ -41,24 +50,32 @@ usage() { cat< any combination of u(user), g(group), o(other) + -quiet suppress all normal output + -help print the usage - Locate user/site/shipped file with the semantics used in the - ~OpenFOAM/fileName expansion + Locate user/group/shipped file with semantics similar to the + ~OpenFOAM/fileName expansion. - Exit status 0 when the file is found and output resolved path to stdout. - Exit status 1 for miscellaneous errors. - Exit status 2 when the file is not found. + The options can also be specified as a single character + (eg, '-q' instead of '-quiet'), but must not be grouped. + + Exit status + 0 when the file is found. Print resolved path to stdout. + 1 for miscellaneous errors. + 2 when the file is not found. USAGE exit 1 } +# default mode is 'ugo' +mode=ugo + # parse options while [ "$#" -gt 0 ] do @@ -70,6 +87,20 @@ do listOpt=true shift ;; + -m | -mode) + [ "$#" -ge 2 ] || usage "'$1' option requires an argument" + mode="$2" + + # sanity check: + case "$mode" in + *u* | *g* | *o* ) + ;; + *) + usage "'$1' option with invalid mode '$mode'" + ;; + esac + shift 2 + ;; -q | -quiet) quietOpt=true shift @@ -83,18 +114,32 @@ do esac done - # Save the essential bits of information: nArgs=$# fileName="$1" -# The various places to be searched: -set -- \ - $HOME/.${WM_PROJECT:-OpenFOAM}/$WM_PROJECT_VERSION \ - $HOME/.${WM_PROJECT:-OpenFOAM} \ - $WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION \ - $WM_PROJECT_INST_DIR/site \ - $WM_PROJECT_DIR/etc +# Define the various places to be searched: +files="" +case "$mode" in +*u*) # user + files="$files $HOME/.${WM_PROJECT:-OpenFOAM}/$WM_PROJECT_VERSION" + files="$files $HOME/.${WM_PROJECT:-OpenFOAM}" + ;; +esac + +case "$mode" in +*g*) # group + files="$files $WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION" + files="$files $WM_PROJECT_INST_DIR/site" + ;; +esac + +case "$mode" in +*o*) # other + files="$files $WM_PROJECT_DIR/etc" + ;; +esac +set -- $files # diff --git a/bin/foamJob b/bin/foamJob index ca51fb6074..612d003fbe 100755 --- a/bin/foamJob +++ b/bin/foamJob @@ -30,14 +30,14 @@ # #------------------------------------------------------------------------------ usage() { - while [ "$#" -ge 1 ]; do echo "$1"; shift; done - cat< ... options: -case specify alternative case directory, default is the cwd - -s also sends output to screen -p parallel run of processors + -s also sends output to screen -v specify OpenFOAM version -help print the usage @@ -45,56 +45,46 @@ options: Redirects the output to 'log' in the case directory USAGE - exit 1 + exit 1 } unset version # replacement for possibly buggy 'which' findExec() { - case "$1" in - */*) - if [ -x "$1" ] ; then - echo "$1" - return 0 - fi - ;; - esac + case "$1" in + */*) + if [ -x "$1" ] + then + echo "$1" + return 0 + fi + ;; + esac - oldIFS=$IFS - IFS=':' - for d in $PATH - do - # echo "testing: $d/$1" 1>&2 - if [ -x "$d/$1" -a ! -d "$d/$1" ] ; then - # echo "Found exec: $d/$1" 1>&2 - IFS=$oldIFS - echo "$d/$1" - return 0 - fi - done - IFS=$oldIFS - echo "" - return 1 -} - -# grep for $1 -getPID() { - ps -u $LOGNAME -o 'pid,args' | fgrep "$1 " | fgrep -v grep | head -1 | awk '{ print $1 }' + oldIFS=$IFS + IFS=':' + for d in $PATH + do + # echo "testing: $d/$1" 1>&2 + if [ -x "$d/$1" -a ! -d "$d/$1" ] + then + # echo "Found exec: $d/$1" 1>&2 + IFS=$oldIFS + echo "$d/$1" + return 0 + fi + done + IFS=$oldIFS + echo "" + return 1 } -consultGuide() { -cat</dev/null || usage "directory does not exist: '$caseDir'" ;; - -s) - SCREEN=yes + -p) + parallelOpt=true shift ;; - -p) - PARALLEL=yes + -s) + screenOpt=true shift ;; -v) @@ -136,100 +126,119 @@ do esac done -if [ "$#" -lt 1 ]; then - usage "No application specified" +if [ "$#" -lt 1 ] +then + usage "No application specified" fi # use foamExec for a specified version and for remote (parallel) runs -if [ -n "$version" -o "$PARALLEL" = yes ]; then - APPLICATION=`findExec foamExec` - if [ $? -ne 0 ]; then - usage "'foamExec' not found" - fi - if [ -n "$version" ]; then - APPLICATION="$APPLICATION -v $version" - fi +if [ -n "$version" -o "$parallelOpt" = true ] +then + APPLICATION=`findExec foamExec` + if [ $? -ne 0 ] + then + usage "'foamExec' not found" + fi + if [ -n "$version" ] + then + APPLICATION="$APPLICATION -v $version" + fi else - APPLICATION=`findExec $1` - if [ $? -ne 0 ]; then - usage "Application '$1' executable not found" - fi - echo "Application : $1" - shift + APPLICATION=`findExec $1` + if [ $? -ne 0 ] + then + usage "Application '$1' executable not found" + fi + echo "Application : $1" + shift fi -if [ "$PARALLEL" = no ]; then -# -# RUN ON SINGLE PROCESSOR -# - if [ "$SCREEN" = no ]; then - echo "Executing: $APPLICATION $@ > log 2>&1 &" - $APPLICATION $@ > log 2>&1 & + +if [ "$parallelOpt" = true ] +then + # parallel + # ~~~~~~~~ + + # + # is the case decomposed? + # + if [ -r "processor0" ] + then + NPROCS="`/bin/ls -1d processor* | wc -l`" else - echo "Executing: $APPLICATION $@ | tee log &" - $APPLICATION $@ | tee log & - wait $! + echo "Case is not currently decomposed" + if [ -r system/decomposeParDict ] + then + echo "system/decomposeParDict exists" + echo "Try decomposing with \"foamJob decomposePar\"" + exit 1 + else + echo "Cannot find system/decomposeParDict file required to decompose the case for parallel running." + echo "Please consult the User Guide for details of parallel running" + exit 1 + fi + fi + + # + # locate mpirun + # + mpirun=`findExec mpirun` + if [ $? -ne 0 ] + then + usage "'mpirun' not found" + fi + mpiopts="-np $NPROCS" + + # + # is the machine ready to run parallel? + # + echo "Parallel processing using $WM_MPLIB with $NPROCS processors" + case "$WM_MPLIB" in + OPENMPI) + # add hostfile info + for hostfile in \ + hostfile \ + machines \ + system/hostfile \ + system/machines \ + ; + do + if [ -r $hostfile ] + then + mpiopts="$mpiopts -hostfile $hostfile" + break + fi + done + ;; + esac + + # + # run (in parallel) + # + if [ "$screenOpt" = true ] + then + echo "Executing: mpirun $mpiopts $APPLICATION $@ -parallel | tee log" + $mpirun $mpiopts $APPLICATION $@ -parallel | tee log + else + echo "Executing: mpirun $mpiopts $APPLICATION $@ -parallel > log 2>&1" + $mpirun $mpiopts $APPLICATION $@ -parallel > log 2>&1 & + fi + +else + # + # run (on single processor) + # + if [ "$screenOpt" = true ] + then + echo "Executing: $APPLICATION $@ | tee log &" + $APPLICATION $@ | tee log & + wait $! + else + echo "Executing: $APPLICATION $@ > log 2>&1 &" + $APPLICATION $@ > log 2>&1 & fi else -# -# IS THE CASE DECOMPOSED? -# - if [ -r "processor0" ] ; then - NPROCS="`/bin/ls -1d processor* | wc -l`" - else - echo "Case is not currently decomposed" - if [ -r system/decomposeParDict ] ; then - echo "system/decomposeParDict exists" - echo "Try decomposing with \"foamJob decomposePar\"" - exit 1 - else - echo "Cannot find system/decomposeParDict file required to decompose the case for parallel running." - consultGuide - exit 1 - fi - fi -# -# LOCATE MPIRUN -# - mpirun=`findExec mpirun` - if [ $? -ne 0 ]; then - usage "'mpirun' not found" - fi - mpiopts="-np $NPROCS" - -# -# IS THE MACHINE READY TO RUN PARALLEL? -# - echo "Parallel processing using $WM_MPLIB with $NPROCS processors" - case "$WM_MPLIB" in - OPENMPI) - # add hostfile info - for hostfile in \ - hostfile \ - machines \ - system/hostfile \ - system/machines \ - ; - do - if [ -r $hostfile ]; then - mpiopts="$mpiopts -hostfile $hostfile" - break - fi - done - ;; - esac - -# -# RUN IN PARALLEL -# - if [ "$SCREEN" = no ] ; then - echo "Executing: mpirun $mpiopts $APPLICATION $@ -parallel > log 2>&1" - $mpirun $mpiopts $APPLICATION $@ -parallel > log 2>&1 & - else - echo "Executing: mpirun $mpiopts $APPLICATION $@ -parallel | tee log" - $mpirun $mpiopts $APPLICATION $@ -parallel | tee log - fi fi #------------------------------------------------------------------------------ diff --git a/bin/mpirunDebug b/bin/mpirunDebug index 6869e64e30..1588265866 100755 --- a/bin/mpirunDebug +++ b/bin/mpirunDebug @@ -40,34 +40,39 @@ else fi -printUsage() { - echo "" - echo "Usage: ${0##*/} -np
" - echo "" - echo "This will run like mpirun but with each process in an xterm" +usage() +{ + cat< + +* This will run like mpirun but with each process in an XTerm + +USAGE + exit 1 } -nProcs='' -exec='' -args='' +unset nProcs exec args -while [ "$1" != "" ]; do +while [ "$1" != "" ] +do echo "$1" case $1 in - -np) + -np) nProcs=$2 shift ;; - *) - if [ ! "$exec" ]; then + *) + if [ ! "$exec" ] + then exec=$1 - elif [ ! "$args" ]; then + elif [ ! "$args" ] + then args="\"$1\"" else args="$args \"$1\"" fi ;; - esac shift done @@ -76,27 +81,19 @@ echo "nProcs=$nProcs" echo "exec=$exec" echo "args=$args" -if [ ! "$nProcs" ]; then - printUsage - exit 1 -fi -if [ ! "$args" ]; then - printUsage - exit 1 -fi -if [ ! "$exec" ]; then - printUsage - exit 1 -fi +[ "$nProcs" ] || usage +[ "$args" ] || usage +[ "$exec" ] || usage exec=`which $exec` -if [ ! -x "$exec" ]; then +if [ ! -x "$exec" ] +then echo "Cannot find executable $exec or is not executable" - printUsage - exit 1 + usage fi -if [ ! "$PWD" ]; then +if [ ! "$PWD" ] +then PWD=`pwd` fi @@ -106,43 +103,51 @@ echo "Constructed gdb initialization file $PWD/gdbCommands" $ECHO "Choose running method: 0)normal 1)gdb+xterm 2)gdb 3)log 4)log+xterm 5)xterm+valgrind: \c" read method -if [ "$method" -ne 0 -a "$method" -ne 1 -a "$method" -ne 2 -a "$method" -ne 3 -a "$method" -ne 4 -a "$method" -ne 5 ]; then - printUsage - exit 1 -fi +case "$method" in +0 | 1 | 2 | 3 | 4 | 5 ) + # okay + ;; +*) + usage + ;; +esac $ECHO "Run all processes local or distributed? 1)local 2)remote: \c" read spawn -if [ "$spawn" -ne 1 -a "$spawn" -ne 2 ]; then - printUsage - exit 1 +if [ "$spawn" -ne 1 -a "$spawn" -ne 2 ] +then + usage fi + # check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/ # check ~/.$WM_PROJECT/ # check /etc/ -if [ "$WM_PROJECT" ]; then +if [ "$WM_PROJECT" ] +then - for i in \ - $HOME/.WM_PROJECT/$WM_PROJECT_VERSION \ - $HOME/.WM_PROJECT \ - $WM_PROJECT_DIR/etc \ - ; - do - if [ -f "$i/bashrc" ]; then - sourceFoam="$i/bashrc" - break - fi - done + for i in \ + $HOME/.WM_PROJECT/$WM_PROJECT_VERSION \ + $HOME/.WM_PROJECT \ + $WM_PROJECT_DIR/etc \ + ; + do + if [ -f "$i/bashrc" ] + then + sourceFoam="$i/bashrc" + break + fi + done fi # Construct test string for remote execution. # Source OpenFOAM settings if OpenFOAM environment not set. # attempt to preserve the installation directory 'FOAM_INST_DIR' -if [ "$FOAM_INST_DIR" ]; then - sourceFoam='[ "$WM_PROJECT" ] || '"FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam" +if [ "$FOAM_INST_DIR" ] +then + sourceFoam='[ "$WM_PROJECT" ] || '"FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam" else - sourceFoam='[ "$WM_PROJECT" ] || '". $sourceFoam" + sourceFoam='[ "$WM_PROJECT" ] || '". $sourceFoam" fi echo "**sourceFoam:$sourceFoam" @@ -160,36 +165,45 @@ do geom="-geometry 120x20+$xpos+$ypos" node="" - if [ .$WM_MPLIB = .OPENMPI ]; then + if [ "$WM_MPLIB" = OPENMPI ] + then node="-np 1 " fi echo "#!/bin/sh" > $procCmdFile - if [ "$method" -eq 0 ]; then + case "$method" in + 0) echo "$sourceFoam; cd $PWD; $exec $args | tee $procLog" >> $procCmdFile echo "${node}$procCmdFile" >> $PWD/mpirun.schema - elif [ "$method" -eq 1 ]; then + ;; + 1) echo "$sourceFoam; cd $PWD; gdb -command $PWD/gdbCommands $exec 2>&1 | tee $procLog; read dummy" >> $procCmdFile #echo "$sourceFoam; cd $PWD; $exec $args; read dummy" >> $procCmdFile echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $PWD/mpirun.schema - elif [ "$method" -eq 2 ]; then + ;; + 2) echo "$sourceFoam; cd $PWD; gdb -command $PWD/gdbCommands >& $procLog" >> $procCmdFile echo "${node}$procCmdFile" >> $PWD/mpirun.schema - elif [ "$method" -eq 3 ]; then + ;; + 3) echo "$sourceFoam; cd $PWD; $exec $args >& $procLog" >> $procCmdFile echo "${node}$procCmdFile" >> $PWD/mpirun.schema - elif [ "$method" -eq 4 ]; then + ;; + 4) echo "$sourceFoam; cd $PWD; $exec $args 2>&1 | tee $procLog; read dummy" >> $procCmdFile echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $PWD/mpirun.schema - elif [ "$method" -eq 5 ]; then + ;; + 5) echo "$sourceFoam; cd $PWD; valgrind $exec $args; read dummy" >> $procCmdFile echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $PWD/mpirun.schema - fi + ;; + esac chmod +x $procCmdFile let column=proc%6 - if [ $proc -ne 0 -a $column -eq 0 ]; then + if [ $proc -ne 0 -a $column -eq 0 ] + then ((xpos+=600)) ((ypos=0)) else @@ -203,10 +217,13 @@ do echo " tail -f $procLog" done -cmd="" -if [ .$WM_MPLIB = .OPENMPI ]; then +unset cmd + +case "$WM_MPLIB" in +OPENMPI) cmd="mpirun -app $PWD/mpirun.schema $procXtermCmdFile echo "$procCmd" >> $procXtermCmdFile chmod +x $procXtermCmdFile - if [ $proc -ne 0 ]; then + if [ $proc -ne 0 ] + then cmd="${cmd} :" fi cmd="${cmd} -n 1 ${procXtermCmdFile}" done < $PWD/mpirun.schema -fi + ;; +esac echo "Constructed $PWD/mpirun.schema file." echo "" diff --git a/etc/apps/ensight/cshrc b/etc/apps/ensight/cshrc index 7367af5083..36f4dac076 100644 --- a/etc/apps/ensight/cshrc +++ b/etc/apps/ensight/cshrc @@ -40,11 +40,11 @@ if ( -r $CEI_HOME ) then # special treatment for 32bit OpenFOAM and 64bit Ensight if ($WM_ARCH == linux && `uname -m` == x86_64) then - setenv CEI_ARCH linux_2.6_32 + setenv CEI_ARCH linux_2.6_32 endif # add to path - set path=($CEI_HOME/bin $path) + setenv PATH ${CEI_HOME}/bin:${PATH} setenv ENSIGHT9_INPUT dummy setenv ENSIGHT9_READER $FOAM_LIBBIN diff --git a/etc/apps/paraview3/cshrc b/etc/apps/paraview3/cshrc index 4b7f470028..61b446007d 100644 --- a/etc/apps/paraview3/cshrc +++ b/etc/apps/paraview3/cshrc @@ -35,8 +35,8 @@ #------------------------------------------------------------------------------ # clean the PATH -set cleaned=`$WM_PROJECT_DIR/bin/foamCleanPath -space "$path" "$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/cmake- $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/paraview-"` -if ( $status == 0 ) set path=($cleaned) +set cleaned=`$WM_PROJECT_DIR/bin/foamCleanPath "$PATH" "$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/cmake- $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/paraview-"` +if ( $status == 0 ) setenv PATH $cleaned # determine the cmake to be used unsetenv CMAKE_HOME @@ -44,7 +44,7 @@ foreach cmake ( cmake-2.8.1 cmake-2.8.0 cmake-2.6.4 ) set cmake=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cmake if ( -r $cmake ) then setenv CMAKE_HOME $cmake - set path=($CMAKE_HOME/bin $path) + setenv PATH ${CMAKE_HOME}/bin:${PATH} break endif end @@ -73,7 +73,7 @@ setenv ParaView_DIR $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/paraview- # set paths if binaries or source are present if ( -r $ParaView_DIR || -r $paraviewInstDir ) then - set path=($ParaView_DIR/bin $path) + setenv PATH ${ParaView_DIR}/bin:${PATH} setenv PV_PLUGIN_PATH $FOAM_LIBBIN/paraview-${ParaView_MAJOR} # add in python libraries if required diff --git a/etc/bashrc b/etc/bashrc index d15c5324d5..c3e7c82bb3 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -272,4 +272,4 @@ fi unset cleaned foamClean foamInstall foamOldDirs unset _foamSource -# ----------------------------------------------------------------------------- +# ----------------------------------------------------------------- end-of-file diff --git a/etc/cshrc b/etc/cshrc index 7b959e8c43..fd3e7d6834 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -209,16 +209,19 @@ default: endsw -# Clean standard environment variables (path/PATH, LD_LIBRARY_PATH, MANPATH) +# Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ set foamClean=$WM_PROJECT_DIR/bin/foamCleanPath if (! $?LD_LIBRARY_PATH ) setenv LD_LIBRARY_PATH '' if (! $?MANPATH) setenv MANPATH '' -#- Clean path/PATH -set cleaned=`$foamClean -space "$path" "$foamOldDirs"` -if ( $status == 0 ) set path=($cleaned) +#- Clean PATH (path) +set cleaned=`$foamClean "$PATH" "$foamOldDirs"` +if ( $status == 0 ) then + unset PATH + setenv PATH $cleaned +endif #- Clean LD_LIBRARY_PATH set cleaned=`$foamClean "$LD_LIBRARY_PATH" "$foamOldDirs"` @@ -242,9 +245,9 @@ _foamSource $WM_PROJECT_DIR/etc/apps/paraview3/cshrc # Clean environment paths again. Only remove duplicates # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -#- Clean path/PATH -set cleaned=`$foamClean -space "$path"` -if ( $status == 0 ) set path=($cleaned) +#- Clean PATH (path) +set cleaned=`$foamClean "$PATH"` +if ( $status == 0 ) setenv PATH $cleaned #- Clean LD_LIBRARY_PATH set cleaned=`$foamClean "$LD_LIBRARY_PATH"` @@ -265,4 +268,4 @@ endif unset cleaned foamClean foamInstall foamOldDirs unalias _foamSource -# ----------------------------------------------------------------------------- +# ----------------------------------------------------------------- end-of-file diff --git a/etc/prefs.csh-EXAMPLE b/etc/prefs.csh-EXAMPLE index 775747ea66..66d4d5ae45 100644 --- a/etc/prefs.csh-EXAMPLE +++ b/etc/prefs.csh-EXAMPLE @@ -22,7 +22,7 @@ # along with OpenFOAM; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -# Script +# File # etc/prefs.csh # # Description @@ -50,4 +50,4 @@ setenv ParaView_VERSION git # eg, cvs/git version setenv ParaView_MAJOR 3.7 -# ----------------------------------------------------------------------------- +# ----------------------------------------------------------------- end-of-file diff --git a/etc/prefs.sh-EXAMPLE b/etc/prefs.sh-EXAMPLE index 5878e82dbc..39a18660ce 100644 --- a/etc/prefs.sh-EXAMPLE +++ b/etc/prefs.sh-EXAMPLE @@ -22,7 +22,7 @@ # along with OpenFOAM; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -# Script +# File # etc/prefs.sh # # Description @@ -49,4 +49,5 @@ export WM_MPLIB=SYSTEMOPENMPI # ~~~~~~~~~~~~~~~~~~~~~~~~ export ParaView_VERSION=git # eg, cvs/git version export ParaView_MAJOR=3.7 -# ----------------------------------------------------------------------------- + +# ----------------------------------------------------------------- end-of-file diff --git a/etc/settings.csh b/etc/settings.csh index 7a0d1f40c8..5d2950662c 100644 --- a/etc/settings.csh +++ b/etc/settings.csh @@ -32,7 +32,7 @@ #------------------------------------------------------------------------------ # prefix to PATH -alias _foamAddPath 'set path=(\!* $path)' +alias _foamAddPath 'setenv PATH \!*\:${PATH}' # prefix to LD_LIBRARY_PATH alias _foamAddLib 'setenv LD_LIBRARY_PATH \!*\:${LD_LIBRARY_PATH}' # prefix to MANPATH @@ -68,14 +68,11 @@ setenv FOAM_SOLVERS $FOAM_APP/solvers setenv FOAM_RUN $WM_PROJECT_USER_DIR/run # add OpenFOAM scripts and wmake to the path -set path=($WM_DIR $WM_PROJECT_DIR/bin $path) +setenv PATH ${WM_DIR}:${WM_PROJECT_DIR}/bin:${PATH} -_foamAddPath $FOAM_APPBIN -_foamAddPath $FOAM_SITE_APPBIN -_foamAddPath $FOAM_USER_APPBIN -_foamAddLib $FOAM_LIBBIN -_foamAddLib $FOAM_SITE_LIBBIN -_foamAddLib $FOAM_USER_LIBBIN +_foamAddPath ${FOAM_USER_APPBIN}:${FOAM_SITE_APPBIN}:${FOAM_APPBIN} + # Make sure to pick up dummy versions of external libraries last +_foamAddLib ${FOAM_USER_LIBBIN}:${FOAM_SITE_LIBBIN}:${FOAM_LIBBIN}:${FOAM_LIBBIN}/dummy # Select compiler installation @@ -101,9 +98,6 @@ case OpenFOAM: _foamAddLib $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/mpfr-2.4.1/lib _foamAddLib $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/gmp-4.2.4/lib breaksw - case Gcc42: - setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/gcc-4.2.4 - breaksw endsw # Check that the compiler directory can be found @@ -117,8 +111,7 @@ case OpenFOAM: endif _foamAddPath ${WM_COMPILER_DIR}/bin - _foamAddLib ${WM_COMPILER_DIR}/lib${WM_COMPILER_LIB_ARCH} - _foamAddLib ${WM_COMPILER_DIR}/lib + _foamAddLib ${WM_COMPILER_DIR}/lib${WM_COMPILER_LIB_ARCH}:${WM_COMPILER_DIR}/lib _foamAddMan ${WM_COMPILER_DIR}/man breaksw @@ -128,12 +121,11 @@ endsw # Communications library # ~~~~~~~~~~~~~~~~~~~~~~ -unset MPI_ARCH_PATH +unsetenv MPI_ARCH_PATH MPI_HOME switch ("$WM_MPLIB") case OPENMPI: set mpi_version=openmpi-1.4.1 - setenv MPI_HOME $WM_THIRD_PARTY_DIR/$mpi_version setenv MPI_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$mpi_version # Tell OpenMPI where to find its install directory @@ -163,7 +155,7 @@ case SYSTEMOPENMPI: echo " libmpi dir : $libDir" endif - _foamAddLib $libDir + _foamAddLib $libDir setenv FOAM_MPI_LIBBIN $FOAM_LIBBIN/$mpi_version unset mpi_version libDir @@ -187,9 +179,9 @@ case MPICH-GM: setenv MPICH_PATH $MPI_ARCH_PATH setenv GM_LIB_PATH /opt/gm/lib64 - _foamAddPath $MPI_ARCH_PATH/bin - _foamAddLib $MPI_ARCH_PATH/lib - _foamAddLib $GM_LIB_PATH + _foamAddPath $MPI_ARCH_PATH/bin + _foamAddLib $MPI_ARCH_PATH/lib + _foamAddLib $GM_LIB_PATH setenv FOAM_MPI_LIBBIN $FOAM_LIBBIN/mpich-gm breaksw @@ -231,18 +223,18 @@ case MPI: case FJMPI: setenv MPI_ARCH_PATH /opt/FJSVmpi2 setenv FOAM_MPI_LIBBIN $FOAM_LIBBIN/mpi - _foamAddPath $MPI_ARCH_PATH/bin - _foamAddLib $MPI_ARCH_PATH/lib/sparcv9 - _foamAddLib /opt/FSUNf90/lib/sparcv9 - _foamAddLib /opt/FJSVpnidt/lib + _foamAddPath $MPI_ARCH_PATH/bin + _foamAddLib $MPI_ARCH_PATH/lib/sparcv9 + _foamAddLib /opt/FSUNf90/lib/sparcv9 + _foamAddLib /opt/FJSVpnidt/lib breaksw case QSMPI: setenv MPI_ARCH_PATH /usr/lib/mpi setenv FOAM_MPI_LIBBIN FOAM_LIBBIN/qsmpi - _foamAddPath $MPI_ARCH_PATH/bin - _foamAddLib $MPI_ARCH_PATH/lib + _foamAddPath $MPI_ARCH_PATH/bin + _foamAddLib $MPI_ARCH_PATH/lib breaksw @@ -256,7 +248,7 @@ _foamAddLib $FOAM_MPI_LIBBIN # Set the minimum MPI buffer size (used by all platforms except SGI MPI) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -set minBufferSize=20000000 +if ( ! $?minBufferSize ) set minBufferSize=20000000 if ( $?MPI_BUFFER_SIZE ) then if ( $MPI_BUFFER_SIZE < $minBufferSize ) then @@ -274,8 +266,8 @@ if ( $?CGAL_LIB_DIR ) then endif -# Switch on the hoard memory allocator if available -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Enable the hoard memory allocator if available +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #if ( -f $FOAM_LIBBIN/libhoard.so ) then # setenv LD_PRELOAD $FOAM_LIBBIN/libhoard.so:${LD_PRELOAD} #endif @@ -283,9 +275,7 @@ endif # cleanup environment: # ~~~~~~~~~~~~~~~~~~~~ -unalias _foamAddPath -unalias _foamAddLib -unalias _foamAddMan -unset minBufferSize +unalias _foamAddPath _foamAddLib _foamAddMan +unset compilerInstall minBufferSize -# ----------------------------------------------------------------------------- +# ----------------------------------------------------------------- end-of-file diff --git a/etc/settings.sh b/etc/settings.sh index ca3ab25c2c..8aab7498a6 100644 --- a/etc/settings.sh +++ b/etc/settings.sh @@ -94,8 +94,9 @@ export FOAM_RUN=$WM_PROJECT_USER_DIR/run # add OpenFOAM scripts and wmake to the path export PATH=$WM_DIR:$WM_PROJECT_DIR/bin:$PATH -_foamAddPath $FOAM_APPBIN $FOAM_SITE_APPBIN $FOAM_USER_APPBIN -_foamAddLib $FOAM_LIBBIN $FOAM_SITE_LIBBIN $FOAM_USER_LIBBIN +_foamAddPath $FOAM_USER_APPBIN:$FOAM_SITE_APPBIN:$FOAM_APPBIN + # Make sure to pick up dummy versions of external libraries last +_foamAddLib $FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN:$FOAM_LIBBIN:$FOAM_LIBBIN/dummy # Compiler settings @@ -130,9 +131,6 @@ OpenFOAM) _foamAddLib $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/mpfr-2.4.1/lib _foamAddLib $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/gmp-4.2.4/lib ;; - Gcc42) - export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/gcc-4.2.4 - ;; esac # Check that the compiler directory can be found @@ -164,12 +162,11 @@ unset compilerBin compilerLib compilerMan compilerInstall # Communications library # ~~~~~~~~~~~~~~~~~~~~~~ -unset MPI_ARCH_PATH +unset MPI_ARCH_PATH MPI_HOME case "$WM_MPLIB" in OPENMPI) mpi_version=openmpi-1.4.1 - export MPI_HOME=$WM_THIRD_PARTY_DIR/$mpi_version export MPI_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$mpi_version # Tell OpenMPI where to find its install directory @@ -200,7 +197,7 @@ SYSTEMOPENMPI) echo " libmpi dir : $libDir" fi - _foamAddLib $libDir + _foamAddLib $libDir export FOAM_MPI_LIBBIN=$FOAM_LIBBIN/$mpi_version unset mpi_version libDir @@ -224,9 +221,9 @@ MPICH-GM) export MPICH_PATH=$MPI_ARCH_PATH export GM_LIB_PATH=/opt/gm/lib64 - _foamAddPath $MPI_ARCH_PATH/bin - _foamAddLib $MPI_ARCH_PATH/lib - _foamAddLib $GM_LIB_PATH + _foamAddPath $MPI_ARCH_PATH/bin + _foamAddLib $MPI_ARCH_PATH/lib + _foamAddLib $GM_LIB_PATH export FOAM_MPI_LIBBIN=$FOAM_LIBBIN/mpich-gm ;; @@ -270,18 +267,18 @@ FJMPI) export MPI_ARCH_PATH=/opt/FJSVmpi2 export FOAM_MPI_LIBBIN=$FOAM_LIBBIN/mpi - _foamAddPath $MPI_ARCH_PATH/bin - _foamAddLib $MPI_ARCH_PATH/lib/sparcv9 - _foamAddLib /opt/FSUNf90/lib/sparcv9 - _foamAddLib /opt/FJSVpnidt/lib + _foamAddPath $MPI_ARCH_PATH/bin + _foamAddLib $MPI_ARCH_PATH/lib/sparcv9 + _foamAddLib /opt/FSUNf90/lib/sparcv9 + _foamAddLib /opt/FJSVpnidt/lib ;; QSMPI) export MPI_ARCH_PATH=/usr/lib/mpi export FOAM_MPI_LIBBIN=$FOAM_LIBBIN/qsmpi - _foamAddPath $MPI_ARCH_PATH/bin - _foamAddLib $MPI_ARCH_PATH/lib + _foamAddPath $MPI_ARCH_PATH/bin + _foamAddLib $MPI_ARCH_PATH/lib ;; @@ -295,7 +292,7 @@ _foamAddLib $FOAM_MPI_LIBBIN # Set the minimum MPI buffer size (used by all platforms except SGI MPI) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -minBufferSize=20000000 +: ${minBufferSize:=20000000} if [ "${MPI_BUFFER_SIZE:=$minBufferSize}" -lt $minBufferSize ] then @@ -309,8 +306,8 @@ export MPI_BUFFER_SIZE [ -d "$CGAL_LIB_DIR" ] && _foamAddLib $CGAL_LIB_DIR -# Switch on the hoard memory allocator if available -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Enable the hoard memory allocator if available +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #if [ -f $FOAM_LIBBIN/libhoard.so ] #then # export LD_PRELOAD=$FOAM_LIBBIN/libhoard.so:$LD_PRELOAD @@ -321,4 +318,4 @@ export MPI_BUFFER_SIZE # ~~~~~~~~~~~~~~~~~~~~ unset _foamAddPath _foamAddLib _foamAddMan minBufferSize -# ----------------------------------------------------------------------------- +# ----------------------------------------------------------------- end-of-file diff --git a/src/OpenFOAM/fields/FieldFields/oneFieldField/oneFieldField.H b/src/OpenFOAM/fields/FieldFields/oneFieldField/oneFieldField.H new file mode 100644 index 0000000000..3f9e2865a7 --- /dev/null +++ b/src/OpenFOAM/fields/FieldFields/oneFieldField/oneFieldField.H @@ -0,0 +1,84 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +Class + Foam::oneFieldField + +Description + A class representing the concept of a field of oneFields used to + avoid unnecessary manipulations for objects which are known to be one at + compile-time. + + Used for example as the density argument to a function written for + compressible to be used for incompressible flow. + +\*---------------------------------------------------------------------------*/ + +#ifndef oneFieldField_H +#define oneFieldField_H + +#include "oneField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class oneField Declaration +\*---------------------------------------------------------------------------*/ + +class oneFieldField +: + public one +{ + +public: + + // Constructors + + //- Construct null + oneFieldField() + {} + + + // Member Operators + + inline oneField operator[](const label) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +# include "oneFieldFieldI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/FieldFields/oneFieldField/oneFieldFieldI.H b/src/OpenFOAM/fields/FieldFields/oneFieldField/oneFieldFieldI.H new file mode 100644 index 0000000000..1fe0c66c4c --- /dev/null +++ b/src/OpenFOAM/fields/FieldFields/oneFieldField/oneFieldFieldI.H @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "oneFieldField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +inline Foam::oneField Foam::oneFieldField::operator[](const label) const +{ + return oneField(); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/FieldFields/zeroFieldField/zeroFieldField.H b/src/OpenFOAM/fields/FieldFields/zeroFieldField/zeroFieldField.H new file mode 100644 index 0000000000..c551d39bc2 --- /dev/null +++ b/src/OpenFOAM/fields/FieldFields/zeroFieldField/zeroFieldField.H @@ -0,0 +1,84 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +Class + Foam::zeroFieldField + +Description + A class representing the concept of a field of zeroFields used to + avoid unnecessary manipulations for objects which are known to be zero at + compile-time. + + Used for example as the density argument to a function written for + compressible to be used for incompressible flow. + +\*---------------------------------------------------------------------------*/ + +#ifndef zeroFieldField_H +#define zeroFieldField_H + +#include "zeroField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class zeroField Declaration +\*---------------------------------------------------------------------------*/ + +class zeroFieldField +: + public zero +{ + +public: + + // Constructors + + //- Construct null + zeroFieldField() + {} + + + // Member Operators + + inline zeroField operator[](const label) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +# include "zeroFieldFieldI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/FieldFields/zeroFieldField/zeroFieldFieldI.H b/src/OpenFOAM/fields/FieldFields/zeroFieldField/zeroFieldFieldI.H new file mode 100644 index 0000000000..2eecfae7ad --- /dev/null +++ b/src/OpenFOAM/fields/FieldFields/zeroFieldField/zeroFieldFieldI.H @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "zeroFieldField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +inline Foam::zeroField Foam::zeroFieldField::operator[](const label) const +{ + return zeroField(); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/Fields/oneField/oneField.H b/src/OpenFOAM/fields/Fields/oneField/oneField.H index 8a21131b26..c4869e5a16 100644 --- a/src/OpenFOAM/fields/Fields/oneField/oneField.H +++ b/src/OpenFOAM/fields/Fields/oneField/oneField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -53,6 +53,7 @@ class oneField : public one { + public: // Constructors @@ -65,10 +66,6 @@ public: // Member Operators inline scalar operator[](const label) const; - - inline oneField field() const; - - inline oneField oldTime() const; }; diff --git a/src/OpenFOAM/fields/Fields/oneField/oneFieldI.H b/src/OpenFOAM/fields/Fields/oneField/oneFieldI.H index 7809caa045..1c0526f370 100644 --- a/src/OpenFOAM/fields/Fields/oneField/oneFieldI.H +++ b/src/OpenFOAM/fields/Fields/oneField/oneFieldI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -33,15 +33,5 @@ inline Foam::scalar Foam::oneField::operator[](const label) const return scalar(1); } -inline Foam::oneField Foam::oneField::field() const -{ - return oneField(); -} - -inline Foam::oneField Foam::oneField::oldTime() const -{ - return oneField(); -} - // ************************************************************************* // diff --git a/src/OpenFOAM/fields/Fields/zeroField/zeroField.H b/src/OpenFOAM/fields/Fields/zeroField/zeroField.H index 97f090623c..0281c154b6 100644 --- a/src/OpenFOAM/fields/Fields/zeroField/zeroField.H +++ b/src/OpenFOAM/fields/Fields/zeroField/zeroField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -65,10 +65,6 @@ public: // Member Operators inline scalar operator[](const label) const; - - inline zeroField field() const; - - inline zeroField oldTime() const; }; @@ -78,7 +74,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -# include "zeroFieldI.H" +#include "zeroFieldI.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/fields/Fields/zeroField/zeroFieldI.H b/src/OpenFOAM/fields/Fields/zeroField/zeroFieldI.H index 67d1dd0e9e..38072ac2e2 100644 --- a/src/OpenFOAM/fields/Fields/zeroField/zeroFieldI.H +++ b/src/OpenFOAM/fields/Fields/zeroField/zeroFieldI.H @@ -33,14 +33,4 @@ inline Foam::scalar Foam::zeroField::operator[](const label) const return scalar(0); } -inline Foam::zeroField Foam::zeroField::field() const -{ - return zeroField(); -} - -inline Foam::zeroField Foam::zeroField::oldTime() const -{ - return zeroField(); -} - // ************************************************************************* // diff --git a/src/OpenFOAM/fields/GeometricFields/geometricOneField/geometricOneField.H b/src/OpenFOAM/fields/GeometricFields/geometricOneField/geometricOneField.H new file mode 100644 index 0000000000..51aa859b10 --- /dev/null +++ b/src/OpenFOAM/fields/GeometricFields/geometricOneField/geometricOneField.H @@ -0,0 +1,91 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +Class + Foam::GeometricField + +Description + A class representing the concept of a GeometricField of 1 used to avoid + unnecessary manipulations for objects which are known to be one at + compile-time. + + Used for example as the density argument to a function written for + compressible to be used for incompressible flow. + +\*---------------------------------------------------------------------------*/ + +#ifndef geometricOneField_H +#define geometricOneField_H + +#include "oneFieldField.H" +#include "scalar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class geometricOneField Declaration +\*---------------------------------------------------------------------------*/ + +class geometricOneField +: + public one +{ + +public: + + // Constructors + + //- Construct null + geometricOneField() + {} + + + // Member Operators + + inline scalar operator[](const label) const; + + inline oneField field() const; + + inline oneField oldTime() const; + + inline oneFieldField boundaryField() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +# include "geometricOneFieldI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/GeometricFields/geometricOneField/geometricOneFieldI.H b/src/OpenFOAM/fields/GeometricFields/geometricOneField/geometricOneFieldI.H new file mode 100644 index 0000000000..cd9a79e2c9 --- /dev/null +++ b/src/OpenFOAM/fields/GeometricFields/geometricOneField/geometricOneFieldI.H @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "geometricOneField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +inline Foam::scalar Foam::geometricOneField::operator[](const label) const +{ + return scalar(1); +} + +inline Foam::oneField Foam::geometricOneField::field() const +{ + return oneField(); +} + +inline Foam::oneField Foam::geometricOneField::oldTime() const +{ + return oneField(); +} + +inline Foam::oneFieldField Foam::geometricOneField::boundaryField() const +{ + return oneFieldField(); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/GeometricFields/geometricZeroField/geometricZeroField.H b/src/OpenFOAM/fields/GeometricFields/geometricZeroField/geometricZeroField.H new file mode 100644 index 0000000000..1168d936ee --- /dev/null +++ b/src/OpenFOAM/fields/GeometricFields/geometricZeroField/geometricZeroField.H @@ -0,0 +1,91 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +Class + Foam::GeometricField + +Description + A class representing the concept of a GeometricField of 1 used to avoid + unnecessary manipulations for objects which are known to be zero at + compile-time. + + Used for example as the density argument to a function written for + compressible to be used for incompressible flow. + +\*---------------------------------------------------------------------------*/ + +#ifndef geometricZeroField_H +#define geometricZeroField_H + +#include "zeroFieldField.H" +#include "scalar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class geometricZeroField Declaration +\*---------------------------------------------------------------------------*/ + +class geometricZeroField +: + public zero +{ + +public: + + // Constructors + + //- Construct null + geometricZeroField() + {} + + + // Member Operators + + inline scalar operator[](const label) const; + + inline zeroField field() const; + + inline zeroField oldTime() const; + + inline zeroFieldField boundaryField() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +# include "geometricZeroFieldI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/parallel/decompose/parMetisDecomp/parMetisDecompTemplates.C b/src/OpenFOAM/fields/GeometricFields/geometricZeroField/geometricZeroFieldI.H similarity index 60% rename from src/parallel/decompose/parMetisDecomp/parMetisDecompTemplates.C rename to src/OpenFOAM/fields/GeometricFields/geometricZeroField/geometricZeroFieldI.H index 8a883c8073..027145167e 100644 --- a/src/parallel/decompose/parMetisDecomp/parMetisDecompTemplates.C +++ b/src/OpenFOAM/fields/GeometricFields/geometricZeroField/geometricZeroFieldI.H @@ -24,52 +24,28 @@ License \*---------------------------------------------------------------------------*/ -#include "parMetisDecomp.H" +#include "geometricZeroField.H" -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Insert at front of list -template -void Foam::parMetisDecomp::prepend -( - const UList& extraLst, - List& lst -) +inline Foam::scalar Foam::geometricZeroField::operator[](const label) const { - label nExtra = extraLst.size(); - - // Make space for initial elements - lst.setSize(lst.size() + nExtra); - for (label i = lst.size()-1; i >= nExtra; i--) - { - lst[i] = lst[i-nExtra]; - } - - // Insert at front - forAll(extraLst, i) - { - lst[i] = extraLst[i]; - } + return scalar(0); } -// Insert at back of list -template -void Foam::parMetisDecomp::append -( - const UList& extraLst, - List& lst -) +inline Foam::zeroField Foam::geometricZeroField::field() const { - label sz = lst.size(); + return zeroField(); +} - // Make space for initial elements - lst.setSize(sz + extraLst.size()); +inline Foam::zeroField Foam::geometricZeroField::oldTime() const +{ + return zeroField(); +} - // Insert at back - forAll(extraLst, i) - { - lst[sz++] = extraLst[i]; - } +inline Foam::zeroFieldField Foam::geometricZeroField::boundaryField() const +{ + return zeroFieldField(); } diff --git a/src/OpenFOAM/primitives/one/oneI.H b/src/OpenFOAM/primitives/one/oneI.H index 2d0a006be9..8393af5ff2 100644 --- a/src/OpenFOAM/primitives/one/oneI.H +++ b/src/OpenFOAM/primitives/one/oneI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -52,6 +52,13 @@ inline Type operator/(const one&, const Type& t) } +template +inline const Type& operator/(const Type& t, const one&) +{ + return t; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/dummyThirdParty/Allwmake b/src/dummyThirdParty/Allwmake index 6629894909..c584d92194 100755 --- a/src/dummyThirdParty/Allwmake +++ b/src/dummyThirdParty/Allwmake @@ -3,8 +3,8 @@ cd ${0%/*} || exit 1 # run from this directory set -x wmake libso scotchDecomp +wmake libso ptscotchDecomp wmake libso metisDecomp -wmake libso parMetisDecomp wmake libso MGridGen diff --git a/src/dummyThirdParty/parMetisDecomp/Make/files b/src/dummyThirdParty/parMetisDecomp/Make/files deleted file mode 100644 index beb734541c..0000000000 --- a/src/dummyThirdParty/parMetisDecomp/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -dummyParMetisDecomp.C - -LIB = $(FOAM_LIBBIN)/dummy/libparMetisDecomp diff --git a/src/dummyThirdParty/ptscotchDecomp/Make/files b/src/dummyThirdParty/ptscotchDecomp/Make/files new file mode 100644 index 0000000000..18402ebfca --- /dev/null +++ b/src/dummyThirdParty/ptscotchDecomp/Make/files @@ -0,0 +1,3 @@ +dummyPtscotchDecomp.C + +LIB = $(FOAM_LIBBIN)/dummy/libptscotchDecomp diff --git a/src/dummyThirdParty/parMetisDecomp/Make/options b/src/dummyThirdParty/ptscotchDecomp/Make/options similarity index 60% rename from src/dummyThirdParty/parMetisDecomp/Make/options rename to src/dummyThirdParty/ptscotchDecomp/Make/options index 2b87d62057..3cb176ccf9 100644 --- a/src/dummyThirdParty/parMetisDecomp/Make/options +++ b/src/dummyThirdParty/ptscotchDecomp/Make/options @@ -1,5 +1,5 @@ EXE_INC = \ -I$(FOAM_SRC)/parallel/decompose/decompositionMethods/lnInclude \ - -I$(FOAM_SRC)/parallel/decompose/parMetisDecomp/lnInclude + -I$(FOAM_SRC)/parallel/decompose/ptscotchDecomp/lnInclude LIB_LIBS = diff --git a/src/dummyThirdParty/parMetisDecomp/dummyParMetisDecomp.C b/src/dummyThirdParty/ptscotchDecomp/dummyPtscotchDecomp.C similarity index 60% rename from src/dummyThirdParty/parMetisDecomp/dummyParMetisDecomp.C rename to src/dummyThirdParty/ptscotchDecomp/dummyPtscotchDecomp.C index 2898907047..6130c240d3 100644 --- a/src/dummyThirdParty/parMetisDecomp/dummyParMetisDecomp.C +++ b/src/dummyThirdParty/ptscotchDecomp/dummyPtscotchDecomp.C @@ -24,64 +24,59 @@ License \*---------------------------------------------------------------------------*/ -#include "parMetisDecomp.H" +#include "ptscotchDecomp.H" #include "addToRunTimeSelectionTable.H" -#include "polyMesh.H" #include "Time.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // +static const char* notImplementedMessage = +"You are trying to use ptscotch but do not have the " +"ptscotchDecomp library loaded." +"\nThis message is from the dummy ptscotchDecomp stub library instead.\n" +"\n" +"Please install ptscotch and make sure that libptscotch.so is in your " +"LD_LIBRARY_PATH.\n" +"The ptscotchDecomp library can then be built in " +"$FOAM_SRC/parallel/decompose/ptscotchDecomp\n"; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - defineTypeNameAndDebug(parMetisDecomp, 0); + defineTypeNameAndDebug(ptscotchDecomp, 0); addToRunTimeSelectionTable ( decompositionMethod, - parMetisDecomp, + ptscotchDecomp, dictionaryMesh ); } -static const char* notImplementedMessage = -"You are trying to use parMetis but do not have the parMetisDecomp library " -"loaded.\n" -"This message is from the dummy parMetisDecomp stub library instead.\n" -"\n" -"Please install parMetis and make sure that libparMetis.so is in your " -"LD_LIBRARY_PATH.\n" -"The parMetisDecomp library can then be built in " -"$FOAM_SRC/parallel/decompose/decompositionMethods/parMetisDecomp\n"; - - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -//- Does prevention of 0 cell domains and calls parmetis. -Foam::label Foam::parMetisDecomp::decompose -( - Field& xadj, - Field& adjncy, - const pointField& cellCentres, - Field& cellWeights, - Field& faceWeights, - const List& options, +void Foam::ptscotchDecomp::check(const int retVal, const char* str) +{} + +Foam::label Foam::ptscotchDecomp::decompose +( + List& adjncy, + List& xadj, + const scalarField& cWeights, List& finalDecomp ) { FatalErrorIn ( - "label parMetisDecomp::decompose" + "label ptscotchDecomp::decompose" "(" - "Field&, " - "Field&, " - "const pointField&, " - "Field&, " - "Field&, " "const List&, " + "const List&, " + "const scalarField&, " "List&" ")" - )<< notImplementedMessage << exit(FatalError); + ) << notImplementedMessage << exit(FatalError); return -1; } @@ -89,7 +84,7 @@ Foam::label Foam::parMetisDecomp::decompose // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::parMetisDecomp::parMetisDecomp +Foam::ptscotchDecomp::ptscotchDecomp ( const dictionary& decompositionDict, const polyMesh& mesh @@ -102,35 +97,35 @@ Foam::parMetisDecomp::parMetisDecomp // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::labelList Foam::parMetisDecomp::decompose +Foam::labelList Foam::ptscotchDecomp::decompose ( - const pointField& cc, - const scalarField& cWeights + const pointField& points, + const scalarField& pointWeights ) { FatalErrorIn ( - "labelList parMetisDecomp::decompose" + "labelList ptscotchDecomp::decompose" "(" "const pointField&, " "const scalarField&" ")" ) << notImplementedMessage << exit(FatalError); - return labelList(); + return labelList::null(); } -Foam::labelList Foam::parMetisDecomp::decompose +Foam::labelList Foam::ptscotchDecomp::decompose ( - const labelList& cellToRegion, - const pointField& regionPoints, - const scalarField& regionWeights + const labelList& agglom, + const pointField& agglomPoints, + const scalarField& pointWeights ) { FatalErrorIn ( - "labelList parMetisDecomp::decompose" + "labelList ptscotchDecomp::decompose" "(" "const labelList&, " "const pointField&, " @@ -138,11 +133,11 @@ Foam::labelList Foam::parMetisDecomp::decompose ")" ) << notImplementedMessage << exit(FatalError); - return labelList(); + return labelList::null(); } -Foam::labelList Foam::parMetisDecomp::decompose +Foam::labelList Foam::ptscotchDecomp::decompose ( const labelListList& globalCellCells, const pointField& cellCentres, @@ -151,7 +146,7 @@ Foam::labelList Foam::parMetisDecomp::decompose { FatalErrorIn ( - "labelList parMetisDecomp::decompose" + "labelList ptscotchDecomp::decompose" "(" "const labelListList&, " "const pointField&, " @@ -159,26 +154,7 @@ Foam::labelList Foam::parMetisDecomp::decompose ")" ) << notImplementedMessage << exit(FatalError); - return labelList(); -} - - -void Foam::parMetisDecomp::calcMetisDistributedCSR -( - const polyMesh& mesh, - List& adjncy, - List& xadj -) -{ - FatalErrorIn - ( - "void parMetisDecomp::calcMetisDistributedCSR" - "(" - "const polyMesh&, " - "List&, " - "List&" - ")" - ) << notImplementedMessage << exit(FatalError); + return labelList::null(); } diff --git a/src/dummyThirdParty/scotchDecomp/dummyScotchDecomp.C b/src/dummyThirdParty/scotchDecomp/dummyScotchDecomp.C index b9a7ba73e2..a77286a767 100644 --- a/src/dummyThirdParty/scotchDecomp/dummyScotchDecomp.C +++ b/src/dummyThirdParty/scotchDecomp/dummyScotchDecomp.C @@ -22,87 +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 - From scotch forum: - - By: Francois PELLEGRINI RE: Graph mapping 'strategy' string [ reply ] - 2008-08-22 10:09 Strategy handling in Scotch is a bit tricky. In order - not to be confused, you must have a clear view of how they are built. - Here are some rules: - - 1- Strategies are made up of "methods" which are combined by means of - "operators". - - 2- A method is of the form "m{param=value,param=value,...}", where "m" - is a single character (this is your first error: "f" is a method name, - not a parameter name). - - 3- There exist different sort of strategies : bipartitioning strategies, - mapping strategies, ordering strategies, which cannot be mixed. For - instance, you cannot build a bipartitioning strategy and feed it to a - mapping method (this is your second error). - - To use the "mapCompute" routine, you must create a mapping strategy, not - a bipartitioning one, and so use stratGraphMap() and not - stratGraphBipart(). Your mapping strategy should however be based on the - "recursive bipartitioning" method ("b"). For instance, a simple (and - hence not very efficient) mapping strategy can be : - - "b{sep=f}" - - which computes mappings with the recursive bipartitioning method "b", - this latter using the Fiduccia-Mattheyses method "f" to compute its - separators. - - If you want an exact partition (see your previous post), try - "b{sep=fx}". - - However, these strategies are not the most efficient, as they do not - make use of the multi-level framework. - - To use the multi-level framework, try for instance: - - "b{sep=m{vert=100,low=h,asc=f}x}" - - The current default mapping strategy in Scotch can be seen by using the - "-vs" option of program gmap. It is, to date: - - b - { - job=t, - map=t, - poli=S, - sep= - ( - m - { - asc=b - { - bnd=d{pass=40,dif=1,rem=1}f{move=80,pass=-1,bal=0.005}, - org=f{move=80,pass=-1,bal=0.005}, - width=3 - }, - low=h{pass=10}f{move=80,pass=-1,bal=0.0005}, - type=h, - vert=80, - rat=0.8 - } - | m - { - asc=b - { - bnd=d{pass=40,dif=1,rem=1}f{move=80,pass=-1,bal=0.005}, - org=f{move=80,pass=-1,bal=0.005}, - width=3 - }, - low=h{pass=10}f{move=80,pass=-1,bal=0.0005}, - type=h, - vert=80, - rat=0.8 - } - ) - } - - \*---------------------------------------------------------------------------*/ #include "scotchDecomp.H" @@ -239,42 +158,4 @@ Foam::labelList Foam::scotchDecomp::decompose } -void Foam::scotchDecomp::calcCSR -( - const polyMesh& mesh, - List& adjncy, - List& xadj -) -{ - FatalErrorIn - ( - "labelList scotchDecomp::decompose" - "(" - "const polyMesh&, " - "const List&, " - "const List&" - ")" - ) << notImplementedMessage << exit(FatalError); -} - - -void Foam::scotchDecomp::calcCSR -( - const labelListList& cellCells, - List& adjncy, - List& xadj -) -{ - FatalErrorIn - ( - "labelList scotchDecomp::decompose" - "(" - "const labelListList&, " - "const List&, " - "const List&" - ")" - ) << notImplementedMessage << exit(FatalError); -} - - // ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZone.C b/src/finiteVolume/cfdTools/general/MRF/MRFZone.C index 3618d87ef5..3ed30360dc 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZone.C +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZone.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -31,6 +31,7 @@ License #include "fvMatrices.H" #include "syncTools.H" #include "faceSet.H" +#include "geometricOneField.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -377,85 +378,33 @@ void Foam::MRFZone::relativeVelocity(volVectorField& U) const void Foam::MRFZone::relativeFlux(surfaceScalarField& phi) const { - const surfaceVectorField& Cf = mesh_.Cf(); - const surfaceVectorField& Sf = mesh_.Sf(); + relativeRhoFlux(geometricOneField(), phi); +} - const vector& origin = origin_.value(); - const vector& Omega = Omega_.value(); - // Internal faces - forAll(internalFaces_, i) - { - label facei = internalFaces_[i]; - phi[facei] -= (Omega ^ (Cf[facei] - origin)) & Sf[facei]; - } - - // Included patches - forAll(includedFaces_, patchi) - { - forAll(includedFaces_[patchi], i) - { - label patchFacei = includedFaces_[patchi][i]; - - phi.boundaryField()[patchi][patchFacei] = 0.0; - } - } - - // Excluded patches - forAll(excludedFaces_, patchi) - { - forAll(excludedFaces_[patchi], i) - { - label patchFacei = excludedFaces_[patchi][i]; - - phi.boundaryField()[patchi][patchFacei] -= - (Omega ^ (Cf.boundaryField()[patchi][patchFacei] - origin)) - & Sf.boundaryField()[patchi][patchFacei]; - } - } +void Foam::MRFZone::relativeFlux +( + const surfaceScalarField& rho, + surfaceScalarField& phi +) const +{ + relativeRhoFlux(rho, phi); } void Foam::MRFZone::absoluteFlux(surfaceScalarField& phi) const { - const surfaceVectorField& Cf = mesh_.Cf(); - const surfaceVectorField& Sf = mesh_.Sf(); + absoluteRhoFlux(geometricOneField(), phi); +} - const vector& origin = origin_.value(); - const vector& Omega = Omega_.value(); - // Internal faces - forAll(internalFaces_, i) - { - label facei = internalFaces_[i]; - phi[facei] += (Omega ^ (Cf[facei] - origin)) & Sf[facei]; - } - - // Included patches - forAll(includedFaces_, patchi) - { - forAll(includedFaces_[patchi], i) - { - label patchFacei = includedFaces_[patchi][i]; - - phi.boundaryField()[patchi][patchFacei] += - (Omega ^ (Cf.boundaryField()[patchi][patchFacei] - origin)) - & Sf.boundaryField()[patchi][patchFacei]; - } - } - - // Excluded patches - forAll(excludedFaces_, patchi) - { - forAll(excludedFaces_[patchi], i) - { - label patchFacei = excludedFaces_[patchi][i]; - - phi.boundaryField()[patchi][patchFacei] += - (Omega ^ (Cf.boundaryField()[patchi][patchFacei] - origin)) - & Sf.boundaryField()[patchi][patchFacei]; - } - } +void Foam::MRFZone::absoluteFlux +( + const surfaceScalarField& rho, + surfaceScalarField& phi +) const +{ + absoluteRhoFlux(rho, phi); } diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZone.H b/src/finiteVolume/cfdTools/general/MRF/MRFZone.H index d5554a5b08..f36a8350e5 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZone.H +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZone.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -97,6 +97,22 @@ class MRFZone //- Divide faces in frame according to patch void setMRFFaces(); + //- Make the given absolute mass/vol flux relative within the MRF region + template + void relativeRhoFlux + ( + const RhoFieldType& rho, + surfaceScalarField& phi + ) const; + + //- Make the given relative mass/vol flux absolute within the MRF region + template + void absoluteRhoFlux + ( + const RhoFieldType& rho, + surfaceScalarField& phi + ) const; + //- Disallow default bitwise copy construct MRFZone(const MRFZone&); @@ -163,9 +179,23 @@ public: //- Make the given absolute flux relative within the MRF region void relativeFlux(surfaceScalarField& phi) const; + //- Make the given absolute mass-flux relative within the MRF region + void relativeFlux + ( + const surfaceScalarField& rho, + surfaceScalarField& phi + ) const; + //- Make the given relative flux absolute within the MRF region void absoluteFlux(surfaceScalarField& phi) const; + //- Make the given relative mass-flux absolute within the MRF region + void absoluteFlux + ( + const surfaceScalarField& rho, + surfaceScalarField& phi + ) const; + //- Correct the boundary velocity for the roation of the MRF region void correctBoundaryVelocity(volVectorField& U) const; @@ -186,6 +216,12 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#ifdef NoRepository +# include "MRFZoneTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #endif // ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZoneTemplates.C b/src/finiteVolume/cfdTools/general/MRF/MRFZoneTemplates.C new file mode 100644 index 0000000000..b195f111a4 --- /dev/null +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZoneTemplates.C @@ -0,0 +1,130 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "MRFZone.H" +#include "fvMesh.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "geometricOneField.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +void Foam::MRFZone::relativeRhoFlux +( + const RhoFieldType& rho, + surfaceScalarField& phi +) const +{ + const surfaceVectorField& Cf = mesh_.Cf(); + const surfaceVectorField& Sf = mesh_.Sf(); + + const vector& origin = origin_.value(); + const vector& Omega = Omega_.value(); + + // Internal faces + forAll(internalFaces_, i) + { + label facei = internalFaces_[i]; + phi[facei] -= rho[facei]*(Omega ^ (Cf[facei] - origin)) & Sf[facei]; + } + + // Included patches + forAll(includedFaces_, patchi) + { + forAll(includedFaces_[patchi], i) + { + label patchFacei = includedFaces_[patchi][i]; + + phi.boundaryField()[patchi][patchFacei] = 0.0; + } + } + + // Excluded patches + forAll(excludedFaces_, patchi) + { + forAll(excludedFaces_[patchi], i) + { + label patchFacei = excludedFaces_[patchi][i]; + + phi.boundaryField()[patchi][patchFacei] -= + rho.boundaryField()[patchi][patchFacei] + *(Omega ^ (Cf.boundaryField()[patchi][patchFacei] - origin)) + & Sf.boundaryField()[patchi][patchFacei]; + } + } +} + + +template +void Foam::MRFZone::absoluteRhoFlux +( + const RhoFieldType& rho, + surfaceScalarField& phi +) const +{ + const surfaceVectorField& Cf = mesh_.Cf(); + const surfaceVectorField& Sf = mesh_.Sf(); + + const vector& origin = origin_.value(); + const vector& Omega = Omega_.value(); + + // Internal faces + forAll(internalFaces_, i) + { + label facei = internalFaces_[i]; + phi[facei] += (Omega ^ (Cf[facei] - origin)) & Sf[facei]; + } + + // Included patches + forAll(includedFaces_, patchi) + { + forAll(includedFaces_[patchi], i) + { + label patchFacei = includedFaces_[patchi][i]; + + phi.boundaryField()[patchi][patchFacei] += + (Omega ^ (Cf.boundaryField()[patchi][patchFacei] - origin)) + & Sf.boundaryField()[patchi][patchFacei]; + } + } + + // Excluded patches + forAll(excludedFaces_, patchi) + { + forAll(excludedFaces_[patchi], i) + { + label patchFacei = excludedFaces_[patchi][i]; + + phi.boundaryField()[patchi][patchFacei] += + (Omega ^ (Cf.boundaryField()[patchi][patchFacei] - origin)) + & Sf.boundaryField()[patchi][patchFacei]; + } + } +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZones.C b/src/finiteVolume/cfdTools/general/MRF/MRFZones.C index 5ef8b3ee83..6bfafcca77 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZones.C +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZones.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -96,6 +96,19 @@ void Foam::MRFZones::relativeFlux(surfaceScalarField& phi) const } +void Foam::MRFZones::relativeFlux +( + const surfaceScalarField& rho, + surfaceScalarField& phi +) const +{ + forAll(*this, i) + { + operator[](i).relativeFlux(rho, phi); + } +} + + void Foam::MRFZones::absoluteFlux(surfaceScalarField& phi) const { forAll(*this, i) @@ -105,6 +118,19 @@ void Foam::MRFZones::absoluteFlux(surfaceScalarField& phi) const } +void Foam::MRFZones::absoluteFlux +( + const surfaceScalarField& rho, + surfaceScalarField& phi +) const +{ + forAll(*this, i) + { + operator[](i).absoluteFlux(rho, phi); + } +} + + void Foam::MRFZones::correctBoundaryVelocity(volVectorField& U) const { forAll(*this, i) diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZones.H b/src/finiteVolume/cfdTools/general/MRF/MRFZones.H index 6e979903a9..b074cd5fd5 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZones.H +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZones.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -85,9 +85,23 @@ public: //- Make the given absolute flux relative within the MRF region void relativeFlux(surfaceScalarField& phi) const; + //- Make the given absolute mass-flux relative within the MRF region + void relativeFlux + ( + const surfaceScalarField& rho, + surfaceScalarField& phi + ) const; + //- Make the given relative flux absolute within the MRF region void absoluteFlux(surfaceScalarField& phi) const; + //- Make the given relative mass-flux absolute within the MRF region + void absoluteFlux + ( + const surfaceScalarField& rho, + surfaceScalarField& phi + ) const; + //- Correct the boundary velocity for the roation of the MRF region void correctBoundaryVelocity(volVectorField& U) const; }; diff --git a/src/finiteVolume/cfdTools/general/porousMedia/PorousZones.C b/src/finiteVolume/cfdTools/general/porousMedia/PorousZones.C index 444cd25131..92a5a822a0 100644 --- a/src/finiteVolume/cfdTools/general/porousMedia/PorousZones.C +++ b/src/finiteVolume/cfdTools/general/porousMedia/PorousZones.C @@ -87,7 +87,7 @@ template Foam::tmp > Foam::PorousZones::ddt ( - const oneField&, + const geometricOneField&, GeometricField& vf ) { diff --git a/src/finiteVolume/cfdTools/general/porousMedia/PorousZones.H b/src/finiteVolume/cfdTools/general/porousMedia/PorousZones.H index cc55fc4264..b86bf6c573 100644 --- a/src/finiteVolume/cfdTools/general/porousMedia/PorousZones.H +++ b/src/finiteVolume/cfdTools/general/porousMedia/PorousZones.H @@ -44,7 +44,7 @@ SourceFiles #include "volFieldsFwd.H" #include "fvMatricesFwd.H" #include "dimensionedScalarFwd.H" -#include "oneField.H" +#include "geometricOneField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -105,7 +105,7 @@ public: template tmp > ddt ( - const oneField&, + const geometricOneField&, GeometricField& ); diff --git a/src/finiteVolume/cfdTools/general/porousMedia/porousZone.C b/src/finiteVolume/cfdTools/general/porousMedia/porousZone.C index 3251e2541e..1e334d0dfc 100644 --- a/src/finiteVolume/cfdTools/general/porousMedia/porousZone.C +++ b/src/finiteVolume/cfdTools/general/porousMedia/porousZone.C @@ -27,7 +27,7 @@ License #include "porousZone.H" #include "fvMesh.H" #include "fvMatrices.H" -#include "oneField.H" +#include "geometricOneField.H" // * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * // @@ -236,7 +236,7 @@ void Foam::porousZone::addResistance(fvVectorMatrix& UEqn) const Udiag, cells, V, - oneField(), + geometricOneField(), U ); } @@ -268,7 +268,7 @@ void Foam::porousZone::addResistance(fvVectorMatrix& UEqn) const Usource, cells, V, - oneField(), + geometricOneField(), mesh_.lookupObject("nu"), U ); @@ -316,7 +316,7 @@ void Foam::porousZone::addResistance ( AU, cells, - oneField(), + geometricOneField(), U ); } @@ -344,7 +344,7 @@ void Foam::porousZone::addResistance ( AU, cells, - oneField(), + geometricOneField(), mesh_.lookupObject("nu"), U ); diff --git a/src/finiteVolume/finiteVolume/fvm/fvmDdt.C b/src/finiteVolume/finiteVolume/fvm/fvmDdt.C index d7610206d0..b3ae5b8f37 100644 --- a/src/finiteVolume/finiteVolume/fvm/fvmDdt.C +++ b/src/finiteVolume/finiteVolume/fvm/fvmDdt.C @@ -60,7 +60,7 @@ template tmp > ddt ( - const oneField&, + const one&, const GeometricField& vf ) { diff --git a/src/finiteVolume/finiteVolume/fvm/fvmDdt.H b/src/finiteVolume/finiteVolume/fvm/fvmDdt.H index 2b8124e559..31e0e18fab 100644 --- a/src/finiteVolume/finiteVolume/fvm/fvmDdt.H +++ b/src/finiteVolume/finiteVolume/fvm/fvmDdt.H @@ -38,7 +38,7 @@ SourceFiles #include "volFieldsFwd.H" #include "fvMatrix.H" -#include "oneField.H" +#include "one.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -60,7 +60,7 @@ namespace fvm template tmp > ddt ( - const oneField&, + const one&, const GeometricField& ); diff --git a/src/finiteVolume/finiteVolume/fvm/fvmLaplacian.C b/src/finiteVolume/finiteVolume/fvm/fvmLaplacian.C index 501456da3c..24128f4c0d 100644 --- a/src/finiteVolume/finiteVolume/fvm/fvmLaplacian.C +++ b/src/finiteVolume/finiteVolume/fvm/fvmLaplacian.C @@ -99,7 +99,7 @@ template tmp > laplacian ( - const zeroField&, + const zero&, const GeometricField& vf, const word& name ) @@ -115,7 +115,7 @@ template tmp > laplacian ( - const zeroField&, + const zero&, const GeometricField& vf ) { @@ -130,7 +130,7 @@ template tmp > laplacian ( - const oneField&, + const one&, const GeometricField& vf, const word& name ) @@ -143,7 +143,7 @@ template tmp > laplacian ( - const oneField&, + const one&, const GeometricField& vf ) { diff --git a/src/finiteVolume/finiteVolume/fvm/fvmLaplacian.H b/src/finiteVolume/finiteVolume/fvm/fvmLaplacian.H index c41774361f..4025505deb 100644 --- a/src/finiteVolume/finiteVolume/fvm/fvmLaplacian.H +++ b/src/finiteVolume/finiteVolume/fvm/fvmLaplacian.H @@ -39,7 +39,8 @@ SourceFiles #include "volFieldsFwd.H" #include "surfaceFieldsFwd.H" #include "fvMatrix.H" -#include "oneField.H" +#include "zero.H" +#include "one.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -69,7 +70,7 @@ namespace fvm template tmp > laplacian ( - const zeroField&, + const zero&, const GeometricField&, const word& ); @@ -77,7 +78,7 @@ namespace fvm template tmp > laplacian ( - const zeroField&, + const zero&, const GeometricField& ); @@ -85,7 +86,7 @@ namespace fvm template tmp > laplacian ( - const oneField&, + const one&, const GeometricField&, const word& ); @@ -93,7 +94,7 @@ namespace fvm template tmp > laplacian ( - const oneField&, + const one&, const GeometricField& ); diff --git a/src/finiteVolume/finiteVolume/fvm/fvmSup.C b/src/finiteVolume/finiteVolume/fvm/fvmSup.C index 99e2d14746..28d592c571 100644 --- a/src/finiteVolume/finiteVolume/fvm/fvmSup.C +++ b/src/finiteVolume/finiteVolume/fvm/fvmSup.C @@ -85,7 +85,7 @@ template Foam::zeroField Foam::fvm::Su ( - const zeroField&, + const zero&, const GeometricField& vf ) { @@ -174,7 +174,7 @@ template Foam::zeroField Foam::fvm::Sp ( - const zeroField&, + const zero&, const GeometricField& ) { @@ -240,7 +240,7 @@ template Foam::zeroField Foam::fvm::SuSp ( - const zeroField&, + const zero&, const GeometricField& vf ) { diff --git a/src/finiteVolume/finiteVolume/fvm/fvmSup.H b/src/finiteVolume/finiteVolume/fvm/fvmSup.H index a5662c1733..56d3aa09e9 100644 --- a/src/finiteVolume/finiteVolume/fvm/fvmSup.H +++ b/src/finiteVolume/finiteVolume/fvm/fvmSup.H @@ -38,6 +38,7 @@ SourceFiles #include "volFieldsFwd.H" #include "fvMatrix.H" +#include "zeroField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -76,7 +77,7 @@ namespace fvm template zeroField Su ( - const zeroField&, + const zero&, const GeometricField& ); @@ -116,7 +117,7 @@ namespace fvm template zeroField Sp ( - const zeroField&, + const zero&, const GeometricField& ); @@ -147,7 +148,7 @@ namespace fvm template zeroField SuSp ( - const zeroField&, + const zero&, const GeometricField& ); } diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C index 9ce8d888c4..f335eeab30 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C @@ -1088,7 +1088,7 @@ void Foam::fvMatrix::operator-= template void Foam::fvMatrix::operator+= ( - const zeroField& + const zero& ) {} @@ -1096,7 +1096,7 @@ void Foam::fvMatrix::operator+= template void Foam::fvMatrix::operator-= ( - const zeroField& + const zero& ) {} @@ -1507,7 +1507,7 @@ template Foam::tmp > Foam::operator== ( const fvMatrix& A, - const zeroField& + const zero& ) { return A; @@ -1518,7 +1518,7 @@ template Foam::tmp > Foam::operator== ( const tmp >& tA, - const zeroField& + const zero& ) { return tA; diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H index 8569862e13..fc3efa6261 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H @@ -44,7 +44,7 @@ SourceFiles #include "tmp.H" #include "autoPtr.H" #include "dimensionedTypes.H" -#include "zeroField.H" +#include "zero.H" #include "className.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -435,8 +435,8 @@ public: void operator+=(const dimensioned&); void operator-=(const dimensioned&); - void operator+=(const zeroField&); - void operator-=(const zeroField&); + void operator+=(const zero&); + void operator-=(const zero&); void operator*=(const DimensionedField&); void operator*=(const tmp >&); @@ -647,14 +647,14 @@ template tmp > operator== ( const fvMatrix&, - const zeroField& + const zero& ); template tmp > operator== ( const tmp >&, - const zeroField& + const zero& ); diff --git a/src/finiteVolume/fvMatrices/solvers/MULES/MULES.C b/src/finiteVolume/fvMatrices/solvers/MULES/MULES.C index 9c055ca339..dd7c35ea6e 100644 --- a/src/finiteVolume/fvMatrices/solvers/MULES/MULES.C +++ b/src/finiteVolume/fvMatrices/solvers/MULES/MULES.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,6 +34,7 @@ License #include "fvcSurfaceIntegrate.H" #include "slicedSurfaceFields.H" #include "syncTools.H" + #include "fvm.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,11 +50,11 @@ void Foam::MULES::explicitSolve { explicitSolve ( - oneField(), + geometricOneField(), psi, phi, phiPsi, - zeroField(), zeroField(), + zero(), zero(), psiMax, psiMin ); } @@ -70,11 +71,11 @@ void Foam::MULES::implicitSolve { implicitSolve ( - oneField(), + geometricOneField(), psi, phi, phiPsi, - zeroField(), zeroField(), + zero(), zero(), psiMax, psiMin ); } diff --git a/src/finiteVolume/fvMatrices/solvers/MULES/MULES.H b/src/finiteVolume/fvMatrices/solvers/MULES/MULES.H index 59c4072fee..8db5bf347a 100644 --- a/src/finiteVolume/fvMatrices/solvers/MULES/MULES.H +++ b/src/finiteVolume/fvMatrices/solvers/MULES/MULES.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -46,8 +46,8 @@ SourceFiles #include "volFields.H" #include "surfaceFieldsFwd.H" #include "primitiveFieldsFwd.H" -#include "zeroField.H" -#include "oneField.H" +#include "zero.H" +#include "geometricOneField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C index bf72983e4a..858ff4b150 100644 --- a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C +++ b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C @@ -88,8 +88,8 @@ void Foam::MULES::explicitSolve psi, phiBD, phiCorr, - Sp.field(), - Su.field(), + Sp, + Su, psiMax, psiMin, 3 @@ -109,18 +109,18 @@ void Foam::MULES::explicitSolve psiIf = ( mesh.Vsc0()*rho.oldTime()*psi0/(deltaT*mesh.Vsc()) - + Su.field() + + Su - psiIf - )/(rho/deltaT - Sp.field()); + )/(rho/deltaT - Sp); } else { psiIf = ( rho.oldTime()*psi0/deltaT - + Su.field() + + Su - psiIf - )/(rho/deltaT - Sp.field()); + )/(rho/deltaT - Sp); } psi.correctBoundaryConditions(); @@ -244,8 +244,8 @@ void Foam::MULES::implicitSolve psi, phiBD, phiCorr, - Sp.field(), - Su.field(), + Sp, + Su, psiMax, psiMin, nLimiterIter diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C index 03284173da..93e52d6250 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C @@ -431,7 +431,7 @@ Foam::autoHexMeshDriver::autoHexMeshDriver << "You have selected decomposition method " << decomposer.typeName << " which is not parallel aware." << endl - << "Please select one that is (parMetis, hierarchical)" + << "Please select one that is (hierarchical, ptscotch)" << exit(FatalError); } diff --git a/src/parallel/decompose/Allwmake b/src/parallel/decompose/Allwmake index 2adc739cf1..3ca612fb5b 100755 --- a/src/parallel/decompose/Allwmake +++ b/src/parallel/decompose/Allwmake @@ -9,7 +9,7 @@ wmake libso metisDecomp if [ -d "$FOAM_MPI_LIBBIN" ] then - ( WM_OPTIONS=${WM_OPTIONS}$WM_MPLIB; wmake libso parMetisDecomp ) + ( WM_OPTIONS=${WM_OPTIONS}$WM_MPLIB; wmake libso ptscotchDecomp ) fi wmake libso decompositionMethods diff --git a/src/parallel/decompose/AllwmakeLnInclude b/src/parallel/decompose/AllwmakeLnInclude index 6542722030..c6a537aa42 100755 --- a/src/parallel/decompose/AllwmakeLnInclude +++ b/src/parallel/decompose/AllwmakeLnInclude @@ -4,7 +4,7 @@ set -x wmakeLnInclude decompositionMethods wmakeLnInclude metisDecomp -wmakeLnInclude parMetisDecomp wmakeLnInclude scotchDecomp +wmakeLnInclude ptscotchDecomp # ----------------------------------------------------------------- end-of-file diff --git a/src/parallel/decompose/decompositionMethods/Make/options b/src/parallel/decompose/decompositionMethods/Make/options index 3af406f8ac..30ba3a8df3 100644 --- a/src/parallel/decompose/decompositionMethods/Make/options +++ b/src/parallel/decompose/decompositionMethods/Make/options @@ -1,10 +1,4 @@ EXE_INC = -LIB_LIBS = \ - -L$(FOAM_LIBBIN)/dummy \ - -L$(FOAM_MPI_LIBBIN) \ - -lscotchDecomp \ - -lmetisDecomp \ - -lparMetisDecomp - +LIB_LIBS = diff --git a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C index d5c98d52b5..8dcecfb7dc 100644 --- a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C +++ b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C @@ -28,6 +28,9 @@ InClass \*---------------------------------------------------------------------------*/ #include "decompositionMethod.H" +#include "globalIndex.H" +#include "cyclicPolyPatch.H" +#include "syncTools.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -156,6 +159,18 @@ Foam::labelList Foam::decompositionMethod::decompose } +Foam::labelList Foam::decompositionMethod::decompose +( + const labelListList& globalCellCells, + const pointField& cc +) +{ + scalarField cWeights(0); + + return decompose(globalCellCells, cc, cWeights); +} + + void Foam::decompositionMethod::calcCellCells ( const polyMesh& mesh, @@ -201,15 +216,284 @@ void Foam::decompositionMethod::calcCellCells } -Foam::labelList Foam::decompositionMethod::decompose +void Foam::decompositionMethod::calcCSR ( - const labelListList& globalCellCells, - const pointField& cc + const polyMesh& mesh, + List& adjncy, + List& xadj ) { - scalarField cWeights(0); + // Make Metis CSR (Compressed Storage Format) storage + // adjncy : contains neighbours (= edges in graph) + // xadj(celli) : start of information in adjncy for celli - return decompose(globalCellCells, cc, cWeights); + xadj.setSize(mesh.nCells()+1); + + // Initialise the number of internal faces of the cells to twice the + // number of internal faces + label nInternalFaces = 2*mesh.nInternalFaces(); + + // Check the boundary for coupled patches and add to the number of + // internal faces + const polyBoundaryMesh& pbm = mesh.boundaryMesh(); + + forAll(pbm, patchi) + { + if (isA(pbm[patchi])) + { + nInternalFaces += pbm[patchi].size(); + } + } + + // Create the adjncy array the size of the total number of internal and + // coupled faces + adjncy.setSize(nInternalFaces); + + // Fill in xadj + // ~~~~~~~~~~~~ + label freeAdj = 0; + + for (label cellI = 0; cellI < mesh.nCells(); cellI++) + { + xadj[cellI] = freeAdj; + + const labelList& cFaces = mesh.cells()[cellI]; + + forAll(cFaces, i) + { + label faceI = cFaces[i]; + + if + ( + mesh.isInternalFace(faceI) + || isA(pbm[pbm.whichPatch(faceI)]) + ) + { + freeAdj++; + } + } + } + xadj[mesh.nCells()] = freeAdj; + + + // Fill in adjncy + // ~~~~~~~~~~~~~~ + + labelList nFacesPerCell(mesh.nCells(), 0); + + // Internal faces + for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++) + { + label own = mesh.faceOwner()[faceI]; + label nei = mesh.faceNeighbour()[faceI]; + + adjncy[xadj[own] + nFacesPerCell[own]++] = nei; + adjncy[xadj[nei] + nFacesPerCell[nei]++] = own; + } + + // Coupled faces. Only cyclics done. + forAll(pbm, patchi) + { + if (isA(pbm[patchi])) + { + const unallocLabelList& faceCells = pbm[patchi].faceCells(); + + label sizeby2 = faceCells.size()/2; + + for (label facei=0; facei& adjncy, + List& xadj +) +{ + // Count number of internal faces + label nConnections = 0; + + forAll(cellCells, coarseI) + { + nConnections += cellCells[coarseI].size(); + } + + // Create the adjncy array as twice the size of the total number of + // internal faces + adjncy.setSize(nConnections); + + xadj.setSize(cellCells.size()+1); + + + // Fill in xadj + // ~~~~~~~~~~~~ + label freeAdj = 0; + + forAll(cellCells, coarseI) + { + xadj[coarseI] = freeAdj; + + const labelList& cCells = cellCells[coarseI]; + + forAll(cCells, i) + { + adjncy[freeAdj++] = cCells[i]; + } + } + xadj[cellCells.size()] = freeAdj; +} + + +void Foam::decompositionMethod::calcDistributedCSR +( + const polyMesh& mesh, + List& adjncy, + List& xadj +) +{ + // Create global cell numbers + // ~~~~~~~~~~~~~~~~~~~~~~~~~~ + + globalIndex globalCells(mesh.nCells()); + + + // + // Make Metis Distributed CSR (Compressed Storage Format) storage + // adjncy : contains cellCells (= edges in graph) + // xadj(celli) : start of information in adjncy for celli + // + + + const labelList& faceOwner = mesh.faceOwner(); + const labelList& faceNeighbour = mesh.faceNeighbour(); + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + + // Get renumbered owner on other side of coupled faces + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + List globalNeighbour(mesh.nFaces()-mesh.nInternalFaces()); + + forAll(patches, patchI) + { + const polyPatch& pp = patches[patchI]; + + if (pp.coupled()) + { + label faceI = pp.start(); + label bFaceI = pp.start() - mesh.nInternalFaces(); + + forAll(pp, i) + { + globalNeighbour[bFaceI++] = globalCells.toGlobal + ( + faceOwner[faceI++] + ); + } + } + } + + // Get the cell on the other side of coupled patches + syncTools::swapBoundaryFaceList(mesh, globalNeighbour, false); + + + // Count number of faces (internal + coupled) + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + // Number of faces per cell + List nFacesPerCell(mesh.nCells(), 0); + + // Number of coupled faces + label nCoupledFaces = 0; + + for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++) + { + nFacesPerCell[faceOwner[faceI]]++; + nFacesPerCell[faceNeighbour[faceI]]++; + } + // Handle coupled faces + forAll(patches, patchI) + { + const polyPatch& pp = patches[patchI]; + + if (pp.coupled()) + { + label faceI = pp.start(); + + forAll(pp, i) + { + nCoupledFaces++; + nFacesPerCell[faceOwner[faceI++]]++; + } + } + } + + + // Fill in xadj + // ~~~~~~~~~~~~ + + xadj.setSize(mesh.nCells()+1); + + int freeAdj = 0; + + for (label cellI = 0; cellI < mesh.nCells(); cellI++) + { + xadj[cellI] = freeAdj; + + freeAdj += nFacesPerCell[cellI]; + } + xadj[mesh.nCells()] = freeAdj; + + + + // Fill in adjncy + // ~~~~~~~~~~~~~~ + + adjncy.setSize(2*mesh.nInternalFaces() + nCoupledFaces); + + nFacesPerCell = 0; + + // For internal faces is just offsetted owner and neighbour + for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++) + { + label own = faceOwner[faceI]; + label nei = faceNeighbour[faceI]; + + adjncy[xadj[own] + nFacesPerCell[own]++] = globalCells.toGlobal(nei); + adjncy[xadj[nei] + nFacesPerCell[nei]++] = globalCells.toGlobal(own); + } + // For boundary faces is offsetted coupled neighbour + forAll(patches, patchI) + { + const polyPatch& pp = patches[patchI]; + + if (pp.coupled()) + { + label faceI = pp.start(); + label bFaceI = pp.start()-mesh.nInternalFaces(); + + forAll(pp, i) + { + label own = faceOwner[faceI]; + adjncy[xadj[own] + nFacesPerCell[own]++] = + globalNeighbour[bFaceI]; + + faceI++; + bFaceI++; + } + } + } } diff --git a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.H b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.H index 7f66e9f50d..71f26d4ac3 100644 --- a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.H +++ b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.H @@ -66,6 +66,31 @@ protected: labelListList& cellCells ); + // From mesh to compact row storage format + // (like CompactListList) + static void calcCSR + ( + const polyMesh& mesh, + List& adjncy, + List& xadj + ); + + // From cell-cell connections to compact row storage format + // (like CompactListList) + static void calcCSR + ( + const labelListList& cellCells, + List& adjncy, + List& xadj + ); + + static void calcDistributedCSR + ( + const polyMesh& mesh, + List& adjncy, + List& xadj + ); + private: // Private Member Functions diff --git a/src/parallel/decompose/metisDecomp/Make/options b/src/parallel/decompose/metisDecomp/Make/options index 2115beb95a..a7d5398f03 100644 --- a/src/parallel/decompose/metisDecomp/Make/options +++ b/src/parallel/decompose/metisDecomp/Make/options @@ -1,7 +1,6 @@ EXE_INC = \ -I$(WM_THIRD_PARTY_DIR)/metis-5.0pre2/include \ - -I../decompositionMethods/lnInclude \ - -I../scotchDecomp/lnInclude + -I../decompositionMethods/lnInclude LIB_LIBS = \ -lmetis \ diff --git a/src/parallel/decompose/metisDecomp/metisDecomp.C b/src/parallel/decompose/metisDecomp/metisDecomp.C index fb2fddb868..50e58cdf06 100644 --- a/src/parallel/decompose/metisDecomp/metisDecomp.C +++ b/src/parallel/decompose/metisDecomp/metisDecomp.C @@ -28,7 +28,6 @@ License #include "addToRunTimeSelectionTable.H" #include "floatScalar.H" #include "Time.H" -#include "scotchDecomp.H" extern "C" { @@ -340,7 +339,7 @@ Foam::labelList Foam::metisDecomp::decompose List adjncy; List xadj; - scotchDecomp::calcCSR(mesh_, adjncy, xadj); + calcCSR(mesh_, adjncy, xadj); // Decompose using default weights List finalDecomp; @@ -390,7 +389,7 @@ Foam::labelList Foam::metisDecomp::decompose cellCells ); - scotchDecomp::calcCSR(cellCells, adjncy, xadj); + calcCSR(cellCells, adjncy, xadj); } // Decompose using default weights @@ -435,7 +434,7 @@ Foam::labelList Foam::metisDecomp::decompose List adjncy; List xadj; - scotchDecomp::calcCSR(globalCellCells, adjncy, xadj); + calcCSR(globalCellCells, adjncy, xadj); // Decompose using default weights diff --git a/src/parallel/decompose/parMetisDecomp/Make/files b/src/parallel/decompose/parMetisDecomp/Make/files deleted file mode 100644 index 7b771b8161..0000000000 --- a/src/parallel/decompose/parMetisDecomp/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -parMetisDecomp.C - -LIB = $(FOAM_MPI_LIBBIN)/libparMetisDecomp diff --git a/src/parallel/decompose/parMetisDecomp/Make/options b/src/parallel/decompose/parMetisDecomp/Make/options deleted file mode 100644 index 76a64be219..0000000000 --- a/src/parallel/decompose/parMetisDecomp/Make/options +++ /dev/null @@ -1,14 +0,0 @@ -include $(RULES)/mplib$(WM_MPLIB) - -EXE_INC = \ - $(PFLAGS) $(PINC) \ - -I$(WM_THIRD_PARTY_DIR)/ParMetis-3.1/ParMETISLib \ - -I$(WM_THIRD_PARTY_DIR)/ParMetis-3.1 \ - -I../decompositionMethods/lnInclude \ - -I../metisDecomp/lnInclude \ - -I../scotchDecomp/lnInclude - -LIB_LIBS = \ - -L$(FOAM_MPI_LIBBIN) \ - -lmetis-parmetis \ - -lparmetis diff --git a/src/parallel/decompose/parMetisDecomp/parMetisDecomp.C b/src/parallel/decompose/parMetisDecomp/parMetisDecomp.C deleted file mode 100644 index f8e590c957..0000000000 --- a/src/parallel/decompose/parMetisDecomp/parMetisDecomp.C +++ /dev/null @@ -1,1016 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / 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 "parMetisDecomp.H" -#include "metisDecomp.H" -#include "scotchDecomp.H" -#include "syncTools.H" -#include "addToRunTimeSelectionTable.H" -#include "floatScalar.H" -#include "polyMesh.H" -#include "Time.H" -#include "labelIOField.H" -#include "globalIndex.H" - -#include - -extern "C" -{ -# include "parmetis.h" -} - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(parMetisDecomp, 0); - - addToRunTimeSelectionTable - ( - decompositionMethod, - parMetisDecomp, - dictionaryMesh - ); -} - - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -//- Does prevention of 0 cell domains and calls parmetis. -Foam::label Foam::parMetisDecomp::decompose -( - Field& xadj, - Field& adjncy, - const pointField& cellCentres, - Field& cellWeights, - Field& faceWeights, - const List& options, - - List& finalDecomp -) -{ - // C style numbering - int numFlag = 0; - - // Number of dimensions - int nDims = 3; - - - if (cellCentres.size() != xadj.size()-1) - { - FatalErrorIn("parMetisDecomp::decompose(..)") - << "cellCentres:" << cellCentres.size() - << " xadj:" << xadj.size() - << abort(FatalError); - } - - - // Get number of cells on all processors - List nLocalCells(Pstream::nProcs()); - nLocalCells[Pstream::myProcNo()] = xadj.size()-1; - Pstream::gatherList(nLocalCells); - Pstream::scatterList(nLocalCells); - - // Get cell offsets. - List cellOffsets(Pstream::nProcs()+1); - int nGlobalCells = 0; - forAll(nLocalCells, procI) - { - cellOffsets[procI] = nGlobalCells; - nGlobalCells += nLocalCells[procI]; - } - cellOffsets[Pstream::nProcs()] = nGlobalCells; - - // Convert pointField into float - Field xyz(3*cellCentres.size()); - int compI = 0; - forAll(cellCentres, cellI) - { - const point& cc = cellCentres[cellI]; - xyz[compI++] = float(cc.x()); - xyz[compI++] = float(cc.y()); - xyz[compI++] = float(cc.z()); - } - - // Make sure every domain has at least one cell - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // (Metis falls over with zero sized domains) - // Trickle cells from processors that have them up to those that - // don't. - - - // Number of cells to send to the next processor - // (is same as number of cells next processor has to receive) - List nSendCells(Pstream::nProcs(), 0); - - for (label procI = nLocalCells.size()-1; procI >=1; procI--) - { - if (nLocalCells[procI]-nSendCells[procI] < 1) - { - nSendCells[procI-1] = nSendCells[procI]-nLocalCells[procI]+1; - } - } - - // First receive (so increasing the sizes of all arrays) - - if (Pstream::myProcNo() >= 1 && nSendCells[Pstream::myProcNo()-1] > 0) - { - // Receive cells from previous processor - IPstream fromPrevProc(Pstream::blocking, Pstream::myProcNo()-1); - - Field prevXadj(fromPrevProc); - Field prevAdjncy(fromPrevProc); - Field prevXyz(fromPrevProc); - Field prevCellWeights(fromPrevProc); - Field prevFaceWeights(fromPrevProc); - - if (prevXadj.size() != nSendCells[Pstream::myProcNo()-1]) - { - FatalErrorIn("parMetisDecomp::decompose(..)") - << "Expected from processor " << Pstream::myProcNo()-1 - << " connectivity for " << nSendCells[Pstream::myProcNo()-1] - << " nCells but only received " << prevXadj.size() - << abort(FatalError); - } - - // Insert adjncy - prepend(prevAdjncy, adjncy); - // Adapt offsets and prepend xadj - xadj += prevAdjncy.size(); - prepend(prevXadj, xadj); - // Coords - prepend(prevXyz, xyz); - // Weights - prepend(prevCellWeights, cellWeights); - prepend(prevFaceWeights, faceWeights); - } - - - // Send to my next processor - - if (nSendCells[Pstream::myProcNo()] > 0) - { - // Send cells to next processor - OPstream toNextProc(Pstream::blocking, Pstream::myProcNo()+1); - - int nCells = nSendCells[Pstream::myProcNo()]; - int startCell = xadj.size()-1 - nCells; - int startFace = xadj[startCell]; - int nFaces = adjncy.size()-startFace; - - // Send for all cell data: last nCells elements - // Send for all face data: last nFaces elements - toNextProc - << Field::subField(xadj, nCells, startCell)-startFace - << Field::subField(adjncy, nFaces, startFace) - << SubField(xyz, nDims*nCells, nDims*startCell) - << - ( - cellWeights.size() - ? static_cast&> - ( - Field::subField(cellWeights, nCells, startCell) - ) - : Field(0) - ) - << - ( - faceWeights.size() - ? static_cast&> - ( - Field::subField(faceWeights, nFaces, startFace) - ) - : Field(0) - ); - - // Remove data that has been sent - if (faceWeights.size()) - { - faceWeights.setSize(faceWeights.size()-nFaces); - } - if (cellWeights.size()) - { - cellWeights.setSize(cellWeights.size()-nCells); - } - xyz.setSize(xyz.size()-nDims*nCells); - adjncy.setSize(adjncy.size()-nFaces); - xadj.setSize(xadj.size() - nCells); - } - - - - // Adapt number of cells - forAll(nSendCells, procI) - { - // Sent cells - nLocalCells[procI] -= nSendCells[procI]; - - if (procI >= 1) - { - // Received cells - nLocalCells[procI] += nSendCells[procI-1]; - } - } - // Adapt cellOffsets - nGlobalCells = 0; - forAll(nLocalCells, procI) - { - cellOffsets[procI] = nGlobalCells; - nGlobalCells += nLocalCells[procI]; - } - - - if (nLocalCells[Pstream::myProcNo()] != (xadj.size()-1)) - { - FatalErrorIn("parMetisDecomp::decompose(..)") - << "Have connectivity for " << xadj.size()-1 - << " cells but nLocalCells:" << nLocalCells[Pstream::myProcNo()] - << abort(FatalError); - } - - // Weight info - int wgtFlag = 0; - int* vwgtPtr = NULL; - int* adjwgtPtr = NULL; - - if (cellWeights.size()) - { - vwgtPtr = cellWeights.begin(); - wgtFlag += 2; // Weights on vertices - } - if (faceWeights.size()) - { - adjwgtPtr = faceWeights.begin(); - wgtFlag += 1; // Weights on edges - } - - - // Number of weights or balance constraints - int nCon = 1; - // Per processor, per constraint the weight - Field tpwgts(nCon*nProcessors_, 1./nProcessors_); - // Imbalance tolerance - Field ubvec(nCon, 1.02); - if (nProcessors_ == 1) - { - // If only one processor there is no imbalance. - ubvec[0] = 1; - } - - MPI_Comm comm = MPI_COMM_WORLD; - - // output: cell -> processor addressing - finalDecomp.setSize(nLocalCells[Pstream::myProcNo()]); - - // output: number of cut edges - int edgeCut = 0; - - - ParMETIS_V3_PartGeomKway - ( - cellOffsets.begin(), // vtxDist - xadj.begin(), - adjncy.begin(), - vwgtPtr, // vertexweights - adjwgtPtr, // edgeweights - &wgtFlag, - &numFlag, - &nDims, - xyz.begin(), - &nCon, - &nProcessors_, // nParts - tpwgts.begin(), - ubvec.begin(), - const_cast&>(options).begin(), - &edgeCut, - finalDecomp.begin(), - &comm - ); - - - // If we sent cells across make sure we undo it - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - // Receive back from next processor if I sent something - if (nSendCells[Pstream::myProcNo()] > 0) - { - IPstream fromNextProc(Pstream::blocking, Pstream::myProcNo()+1); - - List nextFinalDecomp(fromNextProc); - - if (nextFinalDecomp.size() != nSendCells[Pstream::myProcNo()]) - { - FatalErrorIn("parMetisDecomp::decompose(..)") - << "Expected from processor " << Pstream::myProcNo()+1 - << " decomposition for " << nSendCells[Pstream::myProcNo()] - << " nCells but only received " << nextFinalDecomp.size() - << abort(FatalError); - } - - append(nextFinalDecomp, finalDecomp); - } - - // Send back to previous processor. - if (Pstream::myProcNo() >= 1 && nSendCells[Pstream::myProcNo()-1] > 0) - { - OPstream toPrevProc(Pstream::blocking, Pstream::myProcNo()-1); - - int nToPrevious = nSendCells[Pstream::myProcNo()-1]; - - toPrevProc << - SubList - ( - finalDecomp, - nToPrevious, - finalDecomp.size()-nToPrevious - ); - - // Remove locally what has been sent - finalDecomp.setSize(finalDecomp.size()-nToPrevious); - } - - return edgeCut; -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::parMetisDecomp::parMetisDecomp -( - const dictionary& decompositionDict, - const polyMesh& mesh -) -: - decompositionMethod(decompositionDict), - mesh_(mesh) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::labelList Foam::parMetisDecomp::decompose -( - const pointField& cc, - const scalarField& cWeights -) -{ - if (cc.size() != mesh_.nCells()) - { - FatalErrorIn - ( - "parMetisDecomp::decompose" - "(const pointField&, const scalarField&)" - ) << "Can use this decomposition method only for the whole mesh" - << endl - << "and supply one coordinate (cellCentre) for every cell." << endl - << "The number of coordinates " << cc.size() << endl - << "The number of cells in the mesh " << mesh_.nCells() - << exit(FatalError); - } - - // For running sequential ... - if (Pstream::nProcs() <= 1) - { - return metisDecomp(decompositionDict_, mesh_).decompose - ( - cc, - cWeights - ); - } - - - // Connections - Field adjncy; - // Offsets into adjncy - Field xadj; - calcMetisDistributedCSR - ( - mesh_, - adjncy, - xadj - ); - - - // decomposition options. 0 = use defaults - List options(3, 0); - //options[0] = 1; // don't use defaults but use values below - //options[1] = -1; // full debug info - //options[2] = 15; // random number seed - - // cell weights (so on the vertices of the dual) - Field cellWeights; - - // face weights (so on the edges of the dual) - Field faceWeights; - - - // Check for externally provided cellweights and if so initialise weights - scalar minWeights = gMin(cWeights); - if (cWeights.size() > 0) - { - if (minWeights <= 0) - { - WarningIn - ( - "metisDecomp::decompose" - "(const pointField&, const scalarField&)" - ) << "Illegal minimum weight " << minWeights - << endl; - } - - if (cWeights.size() != mesh_.nCells()) - { - FatalErrorIn - ( - "parMetisDecomp::decompose" - "(const pointField&, const scalarField&)" - ) << "Number of cell weights " << cWeights.size() - << " does not equal number of cells " << mesh_.nCells() - << exit(FatalError); - } - - // Convert to integers. - cellWeights.setSize(cWeights.size()); - forAll(cellWeights, i) - { - cellWeights[i] = int(cWeights[i]/minWeights); - } - } - - - // Check for user supplied weights and decomp options - if (decompositionDict_.found("metisCoeffs")) - { - const dictionary& metisCoeffs = - decompositionDict_.subDict("metisCoeffs"); - word weightsFile; - - if (metisCoeffs.readIfPresent("cellWeightsFile", weightsFile)) - { - Info<< "parMetisDecomp : Using cell-based weights read from " - << weightsFile << endl; - - labelIOField cellIOWeights - ( - IOobject - ( - weightsFile, - mesh_.time().timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ) - ); - cellWeights.transfer(cellIOWeights); - - if (cellWeights.size() != mesh_.nCells()) - { - FatalErrorIn - ( - "parMetisDecomp::decompose" - "(const pointField&, const scalarField&)" - ) << "Number of cell weights " << cellWeights.size() - << " read from " << cellIOWeights.objectPath() - << " does not equal number of cells " << mesh_.nCells() - << exit(FatalError); - } - } - - if (metisCoeffs.readIfPresent("faceWeightsFile", weightsFile)) - { - Info<< "parMetisDecomp : Using face-based weights read from " - << weightsFile << endl; - - labelIOField weights - ( - IOobject - ( - weightsFile, - mesh_.time().timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ) - ); - - if (weights.size() != mesh_.nFaces()) - { - FatalErrorIn - ( - "parMetisDecomp::decompose" - "(const pointField&, const scalarField&)" - ) << "Number of face weights " << weights.size() - << " does not equal number of internal and boundary faces " - << mesh_.nFaces() - << exit(FatalError); - } - - faceWeights.setSize(adjncy.size()); - - // Assume symmetric weights. Keep same ordering as adjncy. - List nFacesPerCell(mesh_.nCells(), 0); - - // Handle internal faces - for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++) - { - label w = weights[faceI]; - - label own = mesh_.faceOwner()[faceI]; - label nei = mesh_.faceNeighbour()[faceI]; - - faceWeights[xadj[own] + nFacesPerCell[own]++] = w; - faceWeights[xadj[nei] + nFacesPerCell[nei]++] = w; - } - // Coupled boundary faces - const polyBoundaryMesh& patches = mesh_.boundaryMesh(); - - forAll(patches, patchI) - { - const polyPatch& pp = patches[patchI]; - - if (pp.coupled()) - { - label faceI = pp.start(); - - forAll(pp, i) - { - label w = weights[faceI]; - label own = mesh_.faceOwner()[faceI]; - faceWeights[xadj[own] + nFacesPerCell[own]++] = w; - faceI++; - } - } - } - } - - if (metisCoeffs.readIfPresent("options", options)) - { - Info<< "Using Metis options " << options - << nl << endl; - - if (options.size() != 3) - { - FatalErrorIn - ( - "parMetisDecomp::decompose" - "(const pointField&, const scalarField&)" - ) << "Number of options " << options.size() - << " should be three." << exit(FatalError); - } - } - } - - - // Do actual decomposition - List finalDecomp; - decompose - ( - xadj, - adjncy, - cc, - cellWeights, - faceWeights, - options, - - finalDecomp - ); - - // Copy back to labelList - labelList decomp(finalDecomp.size()); - forAll(decomp, i) - { - decomp[i] = finalDecomp[i]; - } - return decomp; -} - - -Foam::labelList Foam::parMetisDecomp::decompose -( - const labelList& cellToRegion, - const pointField& regionPoints, - const scalarField& regionWeights -) -{ - const labelList& faceOwner = mesh_.faceOwner(); - const labelList& faceNeighbour = mesh_.faceNeighbour(); - const polyBoundaryMesh& patches = mesh_.boundaryMesh(); - - if (cellToRegion.size() != mesh_.nCells()) - { - FatalErrorIn - ( - "parMetisDecomp::decompose(const labelList&, const pointField&)" - ) << "Size of cell-to-coarse map " << cellToRegion.size() - << " differs from number of cells in mesh " << mesh_.nCells() - << exit(FatalError); - } - - - // Global region numbering engine - globalIndex globalRegions(regionPoints.size()); - - - // Get renumbered owner region on other side of coupled faces - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - List globalNeighbour(mesh_.nFaces()-mesh_.nInternalFaces()); - - forAll(patches, patchI) - { - const polyPatch& pp = patches[patchI]; - - if (pp.coupled()) - { - label faceI = pp.start(); - label bFaceI = pp.start() - mesh_.nInternalFaces(); - - forAll(pp, i) - { - label ownRegion = cellToRegion[faceOwner[faceI]]; - globalNeighbour[bFaceI++] = globalRegions.toGlobal(ownRegion); - faceI++; - } - } - } - - // Get the cell on the other side of coupled patches - syncTools::swapBoundaryFaceList(mesh_, globalNeighbour, false); - - - // Get globalCellCells on coarse mesh - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - labelListList globalRegionRegions; - { - List > dynRegionRegions(regionPoints.size()); - - // Internal faces first - forAll(faceNeighbour, faceI) - { - label ownRegion = cellToRegion[faceOwner[faceI]]; - label neiRegion = cellToRegion[faceNeighbour[faceI]]; - - if (ownRegion != neiRegion) - { - label globalOwn = globalRegions.toGlobal(ownRegion); - label globalNei = globalRegions.toGlobal(neiRegion); - - if (findIndex(dynRegionRegions[ownRegion], globalNei) == -1) - { - dynRegionRegions[ownRegion].append(globalNei); - } - if (findIndex(dynRegionRegions[neiRegion], globalOwn) == -1) - { - dynRegionRegions[neiRegion].append(globalOwn); - } - } - } - - // Coupled boundary faces - forAll(patches, patchI) - { - const polyPatch& pp = patches[patchI]; - - if (pp.coupled()) - { - label faceI = pp.start(); - label bFaceI = pp.start() - mesh_.nInternalFaces(); - - forAll(pp, i) - { - label ownRegion = cellToRegion[faceOwner[faceI]]; - label globalNei = globalNeighbour[bFaceI++]; - faceI++; - - if (findIndex(dynRegionRegions[ownRegion], globalNei) == -1) - { - dynRegionRegions[ownRegion].append(globalNei); - } - } - } - } - - globalRegionRegions.setSize(dynRegionRegions.size()); - forAll(dynRegionRegions, i) - { - globalRegionRegions[i].transfer(dynRegionRegions[i]); - } - } - - labelList regionDecomp - ( - decompose - ( - globalRegionRegions, - regionPoints, - regionWeights - ) - ); - - // Rework back into decomposition for original mesh_ - labelList cellDistribution(cellToRegion.size()); - - forAll(cellDistribution, cellI) - { - cellDistribution[cellI] = regionDecomp[cellToRegion[cellI]]; - } - return cellDistribution; -} - - -Foam::labelList Foam::parMetisDecomp::decompose -( - const labelListList& globalCellCells, - const pointField& cellCentres, - const scalarField& cWeights -) -{ - if (cellCentres.size() != globalCellCells.size()) - { - FatalErrorIn - ( - "parMetisDecomp::decompose(const labelListList&" - ", const pointField&, const scalarField&)" - ) << "Inconsistent number of cells (" << globalCellCells.size() - << ") and number of cell centres (" << cellCentres.size() - << ") or weights (" << cWeights.size() << ")." << exit(FatalError); - } - - // For running sequential ... - if (Pstream::nProcs() <= 1) - { - return metisDecomp(decompositionDict_, mesh_) - .decompose(globalCellCells, cellCentres, cWeights); - } - - - // Make Metis Distributed CSR (Compressed Storage Format) storage - - // Connections - Field adjncy; - // Offsets into adjncy - Field xadj; - scotchDecomp::calcCSR(globalCellCells, adjncy, xadj); - - // decomposition options. 0 = use defaults - List options(3, 0); - //options[0] = 1; // don't use defaults but use values below - //options[1] = -1; // full debug info - //options[2] = 15; // random number seed - - // cell weights (so on the vertices of the dual) - Field cellWeights; - - // face weights (so on the edges of the dual) - Field faceWeights; - - - // Check for externally provided cellweights and if so initialise weights - scalar minWeights = gMin(cWeights); - if (cWeights.size() > 0) - { - if (minWeights <= 0) - { - WarningIn - ( - "parMetisDecomp::decompose(const labelListList&" - ", const pointField&, const scalarField&)" - ) << "Illegal minimum weight " << minWeights - << endl; - } - - if (cWeights.size() != globalCellCells.size()) - { - FatalErrorIn - ( - "parMetisDecomp::decompose(const labelListList&" - ", const pointField&, const scalarField&)" - ) << "Number of cell weights " << cWeights.size() - << " does not equal number of cells " << globalCellCells.size() - << exit(FatalError); - } - - // Convert to integers. - cellWeights.setSize(cWeights.size()); - forAll(cellWeights, i) - { - cellWeights[i] = int(cWeights[i]/minWeights); - } - } - - - // Check for user supplied weights and decomp options - if (decompositionDict_.found("metisCoeffs")) - { - const dictionary& metisCoeffs = - decompositionDict_.subDict("metisCoeffs"); - - if (metisCoeffs.readIfPresent("options", options)) - { - Info<< "Using Metis options " << options - << nl << endl; - - if (options.size() != 3) - { - FatalErrorIn - ( - "parMetisDecomp::decompose(const labelListList&" - ", const pointField&, const scalarField&)" - ) << "Number of options " << options.size() - << " should be three." << exit(FatalError); - } - } - } - - - // Do actual decomposition - List finalDecomp; - decompose - ( - xadj, - adjncy, - cellCentres, - cellWeights, - faceWeights, - options, - - finalDecomp - ); - - // Copy back to labelList - labelList decomp(finalDecomp.size()); - forAll(decomp, i) - { - decomp[i] = finalDecomp[i]; - } - return decomp; -} - - -void Foam::parMetisDecomp::calcMetisDistributedCSR -( - const polyMesh& mesh, - List& adjncy, - List& xadj -) -{ - // Create global cell numbers - // ~~~~~~~~~~~~~~~~~~~~~~~~~~ - - globalIndex globalCells(mesh.nCells()); - - - // - // Make Metis Distributed CSR (Compressed Storage Format) storage - // adjncy : contains cellCells (= edges in graph) - // xadj(celli) : start of information in adjncy for celli - // - - - const labelList& faceOwner = mesh.faceOwner(); - const labelList& faceNeighbour = mesh.faceNeighbour(); - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - - // Get renumbered owner on other side of coupled faces - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - List globalNeighbour(mesh.nFaces()-mesh.nInternalFaces()); - - forAll(patches, patchI) - { - const polyPatch& pp = patches[patchI]; - - if (pp.coupled()) - { - label faceI = pp.start(); - label bFaceI = pp.start() - mesh.nInternalFaces(); - - forAll(pp, i) - { - globalNeighbour[bFaceI++] = globalCells.toGlobal - ( - faceOwner[faceI++] - ); - } - } - } - - // Get the cell on the other side of coupled patches - syncTools::swapBoundaryFaceList(mesh, globalNeighbour, false); - - - // Count number of faces (internal + coupled) - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - // Number of faces per cell - List nFacesPerCell(mesh.nCells(), 0); - - // Number of coupled faces - label nCoupledFaces = 0; - - for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++) - { - nFacesPerCell[faceOwner[faceI]]++; - nFacesPerCell[faceNeighbour[faceI]]++; - } - // Handle coupled faces - forAll(patches, patchI) - { - const polyPatch& pp = patches[patchI]; - - if (pp.coupled()) - { - label faceI = pp.start(); - - forAll(pp, i) - { - nCoupledFaces++; - nFacesPerCell[faceOwner[faceI++]]++; - } - } - } - - - // Fill in xadj - // ~~~~~~~~~~~~ - - xadj.setSize(mesh.nCells()+1); - - int freeAdj = 0; - - for (label cellI = 0; cellI < mesh.nCells(); cellI++) - { - xadj[cellI] = freeAdj; - - freeAdj += nFacesPerCell[cellI]; - } - xadj[mesh.nCells()] = freeAdj; - - - - // Fill in adjncy - // ~~~~~~~~~~~~~~ - - adjncy.setSize(2*mesh.nInternalFaces() + nCoupledFaces); - - nFacesPerCell = 0; - - // For internal faces is just offsetted owner and neighbour - for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++) - { - label own = faceOwner[faceI]; - label nei = faceNeighbour[faceI]; - - adjncy[xadj[own] + nFacesPerCell[own]++] = globalCells.toGlobal(nei); - adjncy[xadj[nei] + nFacesPerCell[nei]++] = globalCells.toGlobal(own); - } - // For boundary faces is offsetted coupled neighbour - forAll(patches, patchI) - { - const polyPatch& pp = patches[patchI]; - - if (pp.coupled()) - { - label faceI = pp.start(); - label bFaceI = pp.start()-mesh.nInternalFaces(); - - forAll(pp, i) - { - label own = faceOwner[faceI]; - adjncy[xadj[own] + nFacesPerCell[own]++] = - globalNeighbour[bFaceI]; - - faceI++; - bFaceI++; - } - } - } -} - - -// ************************************************************************* // diff --git a/src/parallel/decompose/ptscotchDecomp/Make/files b/src/parallel/decompose/ptscotchDecomp/Make/files new file mode 100644 index 0000000000..d2494e36ba --- /dev/null +++ b/src/parallel/decompose/ptscotchDecomp/Make/files @@ -0,0 +1,3 @@ +ptscotchDecomp.C + +LIB = $(FOAM_MPI_LIBBIN)/libptscotchDecomp diff --git a/src/parallel/decompose/ptscotchDecomp/Make/options b/src/parallel/decompose/ptscotchDecomp/Make/options new file mode 100644 index 0000000000..f8e8f92460 --- /dev/null +++ b/src/parallel/decompose/ptscotchDecomp/Make/options @@ -0,0 +1,10 @@ +include $(RULES)/mplib$(WM_MPLIB) + +EXE_INC = \ + $(PFLAGS) $(PINC) \ + -I$(WM_THIRD_PARTY_DIR)/scotch_5.1/include \ + -I/usr/include/scotch \ + -I../decompositionMethods/lnInclude + +LIB_LIBS = \ + -L$(FOAM_MPI_LIBBIN) -lptscotch -lptscotcherrexit diff --git a/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C b/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C new file mode 100644 index 0000000000..9cf84914bb --- /dev/null +++ b/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C @@ -0,0 +1,592 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + + From scotch forum: + + By: Francois PELLEGRINI RE: Graph mapping 'strategy' string [ reply ] + 2008-08-22 10:09 Strategy handling in Scotch is a bit tricky. In order + not to be confused, you must have a clear view of how they are built. + Here are some rules: + + 1- Strategies are made up of "methods" which are combined by means of + "operators". + + 2- A method is of the form "m{param=value,param=value,...}", where "m" + is a single character (this is your first error: "f" is a method name, + not a parameter name). + + 3- There exist different sort of strategies : bipartitioning strategies, + mapping strategies, ordering strategies, which cannot be mixed. For + instance, you cannot build a bipartitioning strategy and feed it to a + mapping method (this is your second error). + + To use the "mapCompute" routine, you must create a mapping strategy, not + a bipartitioning one, and so use stratGraphMap() and not + stratGraphBipart(). Your mapping strategy should however be based on the + "recursive bipartitioning" method ("b"). For instance, a simple (and + hence not very efficient) mapping strategy can be : + + "b{sep=f}" + + which computes mappings with the recursive bipartitioning method "b", + this latter using the Fiduccia-Mattheyses method "f" to compute its + separators. + + If you want an exact partition (see your previous post), try + "b{sep=fx}". + + However, these strategies are not the most efficient, as they do not + make use of the multi-level framework. + + To use the multi-level framework, try for instance: + + "b{sep=m{vert=100,low=h,asc=f}x}" + + The current default mapping strategy in Scotch can be seen by using the + "-vs" option of program gmap. It is, to date: + + b + { + job=t, + map=t, + poli=S, + sep= + ( + m + { + asc=b + { + bnd=d{pass=40,dif=1,rem=1}f{move=80,pass=-1,bal=0.005}, + org=f{move=80,pass=-1,bal=0.005}, + width=3 + }, + low=h{pass=10}f{move=80,pass=-1,bal=0.0005}, + type=h, + vert=80, + rat=0.8 + } + | m + { + asc=b + { + bnd=d{pass=40,dif=1,rem=1}f{move=80,pass=-1,bal=0.005}, + org=f{move=80,pass=-1,bal=0.005}, + width=3 + }, + low=h{pass=10}f{move=80,pass=-1,bal=0.0005}, + type=h, + vert=80, + rat=0.8 + } + ) + } + + +\*---------------------------------------------------------------------------*/ + +#include "ptscotchDecomp.H" +#include "addToRunTimeSelectionTable.H" +#include "Time.H" +#include "OFstream.H" + +extern "C" +{ +#include +#include "mpi.h" +#include "ptscotch.h" +} + + +// Hack: scotch generates floating point errors so need to switch of error +// trapping! +#if defined(linux) || defined(linuxAMD64) || defined(linuxIA64) +# define LINUX +#endif + +#if defined(LINUX) && defined(__GNUC__) +# define LINUX_GNUC +#endif + +#ifdef LINUX_GNUC +# ifndef __USE_GNU +# define __USE_GNU +# endif +# include +#endif + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(ptscotchDecomp, 0); + + addToRunTimeSelectionTable + ( + decompositionMethod, + ptscotchDecomp, + dictionaryMesh + ); +} + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::ptscotchDecomp::check(const int retVal, const char* str) +{ + if (retVal) + { + FatalErrorIn("ptscotchDecomp::decompose(..)") + << "Call to scotch routine " << str << " failed." + << exit(FatalError); + } +} + + +// Call scotch with options from dictionary. +Foam::label Foam::ptscotchDecomp::decompose +( + List& adjncy, + List& xadj, + const scalarField& cWeights, + + List& finalDecomp +) +{ +// // Dump graph +// if (decompositionDict_.found("ptscotchCoeffs")) +// { +// const dictionary& scotchCoeffs = +// decompositionDict_.subDict("ptscotchCoeffs"); +// +// if (scotchCoeffs.found("writeGraph")) +// { +// Switch writeGraph(scotchCoeffs.lookup("writeGraph")); +// +// if (writeGraph) +// { +// OFstream str(mesh_.time().path() / mesh_.name() + ".grf"); +// +// Info<< "Dumping Scotch graph file to " << str.name() << endl +// << "Use this in combination with gpart." << endl; +// +// label version = 0; +// str << version << nl; +// // Numer of vertices +// str << xadj.size()-1 << ' ' << adjncy.size() << nl; +// // Numbering starts from 0 +// label baseval = 0; +// // Has weights? +// label hasEdgeWeights = 0; +// label hasVertexWeights = 0; +// label numericflag = 10*hasEdgeWeights+hasVertexWeights; +// str << baseval << ' ' << numericflag << nl; +// for (label cellI = 0; cellI < xadj.size()-1; cellI++) +// { +// label start = xadj[cellI]; +// label end = xadj[cellI+1]; +// str << end-start; +// +// for (label i = start; i < end; i++) +// { +// str << ' ' << adjncy[i]; +// } +// str << nl; +// } +// } +// } +// } + + + // Strategy + // ~~~~~~~~ + + // Default. + SCOTCH_Strat stradat; + check(SCOTCH_stratInit(&stradat), "SCOTCH_stratInit"); + + if (decompositionDict_.found("scotchCoeffs")) + { + const dictionary& scotchCoeffs = + decompositionDict_.subDict("scotchCoeffs"); + + + string strategy; + if (scotchCoeffs.readIfPresent("strategy", strategy)) + { + if (debug) + { + Info<< "ptscotchDecomp : Using strategy " << strategy << endl; + } + SCOTCH_stratDgraphMap(&stradat, strategy.c_str()); + //fprintf(stdout, "S\tStrat="); + //SCOTCH_stratSave(&stradat, stdout); + //fprintf(stdout, "\n"); + } + } + + + // Graph + // ~~~~~ + + List velotab; + + + // Check for externally provided cellweights and if so initialise weights + scalar minWeights = gMin(cWeights); + if (cWeights.size() > 0) + { + if (minWeights <= 0) + { + WarningIn + ( + "ptscotchDecomp::decompose" + "(const pointField&, const scalarField&)" + ) << "Illegal minimum weight " << minWeights + << endl; + } + + if (cWeights.size() != xadj.size()-1) + { + FatalErrorIn + ( + "ptscotchDecomp::decompose" + "(const pointField&, const scalarField&)" + ) << "Number of cell weights " << cWeights.size() + << " does not equal number of cells " << xadj.size()-1 + << exit(FatalError); + } + + // Convert to integers. + velotab.setSize(cWeights.size()); + forAll(velotab, i) + { + velotab[i] = int(cWeights[i]/minWeights); + } + } + + + + SCOTCH_Dgraph grafdat; + check(SCOTCH_dgraphInit(&grafdat, MPI_COMM_WORLD), "SCOTCH_dgraphInit"); + check + ( + SCOTCH_dgraphBuild + ( + &grafdat, // grafdat + 0, // baseval, c-style numbering + xadj.size()-1, // vertlocnbr, nCells + xadj.size()-1, // vertlocmax + const_cast(xadj.begin()), // vertloctab, start index per cell into + // adjncy + &xadj[1], // vendloctab, end index ,, + + velotab.begin(), // veloloctab, vertex weights + NULL, // vlblloctab + + adjncy.size(), // edgelocnbr, number of arcs + adjncy.size(), // edgelocsiz + adjncy.begin(), // edgeloctab + NULL, // edgegsttab + NULL // edlotab, edge weights + ), + "SCOTCH_dgraphBuild" + ); + check(SCOTCH_dgraphCheck(&grafdat), "SCOTCH_dgraphCheck"); + + + // Architecture + // ~~~~~~~~~~~~ + // (fully connected network topology since using switch) + + SCOTCH_Arch archdat; + check(SCOTCH_archInit(&archdat), "SCOTCH_archInit"); + + List