diff --git a/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L b/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L index 7706ccb272..dc4531fef6 100644 --- a/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L +++ b/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L @@ -433,7 +433,7 @@ mtype {space}"MTYPE:"{space} } else { - curGroupID = readLabel(groupStream);; + curGroupID = readLabel(groupStream); } BEGIN(cellStreams); diff --git a/applications/utilities/mesh/manipulation/renumberMesh/Make/options b/applications/utilities/mesh/manipulation/renumberMesh/Make/options index 2981cf30be..dc78db3436 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/Make/options +++ b/applications/utilities/mesh/manipulation/renumberMesh/Make/options @@ -11,4 +11,4 @@ EXE_LIBS = \ -lfiniteVolume \ -lgenericPatchFields \ -lrenumberMethods \ - -ldecompositionMethods + -ldecompositionMethods -L$(FOAM_LIBBIN)/dummy -lmetisDecomp -lscotchDecomp diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C index 7e090fa30e..02e5a06567 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C +++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C @@ -29,7 +29,7 @@ Description renumbering all fields from all the time directories. By default uses bandCompression (CuthillMcKee) but will - read system/renumberMeshDict if present and use the method from there. + read system/renumberMeshDict if -dict option is present \*---------------------------------------------------------------------------*/ @@ -45,6 +45,7 @@ Description #include "renumberMethod.H" #include "zeroGradientFvPatchFields.H" #include "CuthillMcKeeRenumber.H" +#include "fvMeshSubset.H" using namespace Foam; @@ -455,6 +456,69 @@ autoPtr reorderMesh } +// Return new to old cell numbering +labelList regionRenumber +( + const renumberMethod& method, + const fvMesh& mesh, + const labelList& cellToRegion +) +{ + Info<< "Determining cell order:" << endl; + + labelList cellOrder(cellToRegion.size()); + + label nRegions = max(cellToRegion)+1; + + labelListList regionToCells(invertOneToMany(nRegions, cellToRegion)); + + label cellI = 0; + + forAll(regionToCells, regionI) + { + Info<< " region " << regionI << " starts at " << cellI << endl; + + // Make sure no parallel comms + bool oldParRun = UPstream::parRun(); + UPstream::parRun() = false; + + // Per region do a reordering. + fvMeshSubset subsetter(mesh); + subsetter.setLargeCellSubset(cellToRegion, regionI); + + const fvMesh& subMesh = subsetter.subMesh(); + + labelList subReverseCellOrder = method.renumber + ( + subMesh, + subMesh.cellCentres() + ); + + labelList subCellOrder + ( + invert + ( + subMesh.nCells(), + subReverseCellOrder + ) + ); + + // Restore state + UPstream::parRun() = oldParRun; + + const labelList& cellMap = subsetter.cellMap(); + + forAll(subCellOrder, i) + { + cellOrder[cellI++] = cellMap[subCellOrder[i]]; + } + } + Info<< endl; + + return cellOrder; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) @@ -505,23 +569,28 @@ int main(int argc, char *argv[]) label blockSize = 0; // Construct renumberMethod + autoPtr renumberDictPtr; autoPtr renumberPtr; if (readDict) { Info<< "Renumber according to renumberMeshDict." << nl << endl; - IOdictionary renumberDict + renumberDictPtr.reset ( - IOobject + new IOdictionary ( - "renumberMeshDict", - runTime.system(), - mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE + IOobject + ( + "renumberMeshDict", + runTime.system(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) ) ); + const IOdictionary renumberDict = renumberDictPtr(); renumberPtr = renumberMethod::New(renumberDict); @@ -562,7 +631,7 @@ int main(int argc, char *argv[]) << endl; } - writeMaps = readLabel(renumberDict.lookup("writeMaps")); + renumberDict.lookup("writeMaps") >> writeMaps; if (writeMaps) { Info<< "Writing renumber maps (new to old) to polyMesh." << nl @@ -683,22 +752,15 @@ int main(int argc, char *argv[]) // fields is done correctly! label nBlocks = mesh.nCells() / blockSize; - Info<< "nBlocks = " << nBlocks << endl; + Info<< "nBlocks = " << nBlocks << endl; - // Read decomposePar dictionary - IOdictionary decomposeDict - ( - IOobject - ( - "decomposeParDict", - runTime.system(), - mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE - ) - ); + // Read decompositionMethod dictionary + dictionary decomposeDict(renumberDictPtr().subDict("blockCoeffs")); decomposeDict.set("numberOfSubdomains", nBlocks); + bool oldParRun = UPstream::parRun(); + UPstream::parRun() = false; + autoPtr decomposePtr = decompositionMethod::New ( decomposeDict @@ -713,6 +775,9 @@ int main(int argc, char *argv[]) ) ); + // Restore state + UPstream::parRun() = oldParRun; + // For debugging: write out region createScalarField ( @@ -726,23 +791,7 @@ int main(int argc, char *argv[]) << nl << endl; - // Find point per region - pointField regionPoints(nBlocks, vector::zero); - forAll(cellToRegion, cellI) - { - regionPoints[cellToRegion[cellI]] = mesh.cellCentres()[cellI]; - } - - // Use block based renumbering. - // Detemines old to new cell ordering - labelList reverseCellOrder = renumberPtr().renumber - ( - mesh, - cellToRegion, - regionPoints - ); - - cellOrder = invert(mesh.nCells(), reverseCellOrder); + cellOrder = regionRenumber(renumberPtr(), mesh, cellToRegion); // Determine new to old face order with new cell numbering faceOrder = getRegionFaceOrder diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMeshDict b/applications/utilities/mesh/manipulation/renumberMesh/renumberMeshDict index a852fad7db..988379720b 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMeshDict +++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMeshDict @@ -22,10 +22,14 @@ writeMaps true; // e.g. nonBlockingGaussSeidel. sortCoupledFaceCells false; -// Optional entry: renumber on a block-by-block basis. This can be used on -// large cases to keep the blocks fitting in cache with all the the cache -// missed bunched at the end. -//blockSize 0; +// Optional entry: renumber on a block-by-block basis. It uses a +// blockCoeffs dictionary to construct a decompositionMethod to do +// a block subdivision) and then applies the renumberMethod to each +// block in turn. This can be used in large cases to keep the blocks +// fitting in cache with all the the cache misses bunched at the end. +// This number is the approximate size of the blocks - this gets converted +// to a number of blocks that is the input to the decomposition method. +//blockSize 1000; // Optional entry: sort points into internal and boundary points //orderPoints false; @@ -37,11 +41,11 @@ method CuthillMcKee; //method random; //method spring; -CuthillMcKeeCoeffs -{ - // Reverse CuthillMcKee (RCM) or plain - reverse true; -} +//CuthillMcKeeCoeffs +//{ +// // Reverse CuthillMcKee (RCM) or plain +// reverse true; +//} manualCoeffs @@ -65,4 +69,17 @@ springCoeffs } +blockCoeffs +{ + method scotch; + //method hierarchical; + //hierarchicalCoeffs + //{ + // n (1 2 1); + // delta 0.001; + // order xyz; + //} +} + + // ************************************************************************* // diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index fd58570b34..02acd59236 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -528,7 +528,7 @@ int main(int argc, char *argv[]) << "Cell number should be between 0 and " << mesh.nCells()-1 << nl << "On this mesh the particle should be in cell " - << mesh.findCell(iter().position()) + << mesh.findCell(iter().position()) << exit(FatalError); } @@ -789,6 +789,14 @@ int main(int argc, char *argv[]) // Point fields + if + ( + pointScalarFields.size() + || pointVectorFields.size() + || pointSphericalTensorFields.size() + || pointSymmTensorFields.size() + || pointTensorFields.size() + ) { labelIOList pointProcAddressing ( diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C index 5eaff912ef..cde7f5b12d 100644 --- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C +++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C @@ -795,9 +795,9 @@ int main(int argc, char *argv[]) ); fvMesh& mesh = meshPtr(); - //Pout<< "Read mesh:" << endl; - //printMeshData(Pout, mesh); - //Pout<< endl; + // Print some statistics + Info<< "Before distribution:" << endl; + printMeshData(mesh); @@ -1022,7 +1022,6 @@ int main(int argc, char *argv[]) //map().distributeFaceData(faceCc); - // Print a bit // Print some statistics Info<< "After distribution:" << endl; printMeshData(mesh); diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/Allwmake b/applications/utilities/postProcessing/graphics/PV3Readers/Allwmake index 6851210bd7..1568f8afb8 100755 --- a/applications/utilities/postProcessing/graphics/PV3Readers/Allwmake +++ b/applications/utilities/postProcessing/graphics/PV3Readers/Allwmake @@ -1,6 +1,6 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory -set -x +#set -x if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ] then @@ -15,6 +15,8 @@ then wmake libso vtkPV3Readers PV3blockMeshReader/Allwmake PV3FoamReader/Allwmake +else + echo "ERROR: ParaView not found in $ParaView_DIR" fi # ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_get_number_of_files_in_dataset.H b/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_get_number_of_files_in_dataset.H index e2246d27da..ed936ee082 100644 --- a/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_get_number_of_files_in_dataset.H +++ b/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_get_number_of_files_in_dataset.H @@ -9,5 +9,5 @@ int USERD_get_number_of_files_in_dataset(void) // use 1 insted of 0 which gives an un-necessary warning. Num_dataset_files = 1; - return Num_dataset_files;; + return Num_dataset_files; } diff --git a/applications/utilities/postProcessing/wall/wallShearStress/Make/options b/applications/utilities/postProcessing/wall/wallShearStress/Make/options index 8862565863..b386fa4540 100644 --- a/applications/utilities/postProcessing/wall/wallShearStress/Make/options +++ b/applications/utilities/postProcessing/wall/wallShearStress/Make/options @@ -1,11 +1,14 @@ EXE_INC = \ -I$(LIB_SRC)/transportModels \ -I$(LIB_SRC)/turbulenceModels \ - -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude EXE_LIBS = \ - -lincompressibleRASModels \ -lincompressibleTransportModels \ + -lincompressibleRASModels \ + -lbasicThermophysicalModels \ + -lspecie \ + -lcompressibleRASModels \ -lfiniteVolume \ -lgenericPatchFields diff --git a/applications/utilities/postProcessing/wall/wallShearStress/createFields.H b/applications/utilities/postProcessing/wall/wallShearStress/createFields.H deleted file mode 100644 index d069c4545d..0000000000 --- a/applications/utilities/postProcessing/wall/wallShearStress/createFields.H +++ /dev/null @@ -1,22 +0,0 @@ - Info<< "Reading field U\n" << endl; - volVectorField U - ( - IOobject - ( - "U", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - -# include "createPhi.H" - - singlePhaseTransportModel laminarTransport(U, phi); - - autoPtr RASModel - ( - incompressible::RASModel::New(U, phi, laminarTransport) - ); diff --git a/applications/utilities/postProcessing/wall/wallShearStress/wallShearStress.C b/applications/utilities/postProcessing/wall/wallShearStress/wallShearStress.C index 7d440417df..6069837b95 100644 --- a/applications/utilities/postProcessing/wall/wallShearStress/wallShearStress.C +++ b/applications/utilities/postProcessing/wall/wallShearStress/wallShearStress.C @@ -25,23 +25,130 @@ Application wallShearStress Description - Calculates and writes the wall shear stress, for the specified times. + Calculates and reports wall shear stress for all patches, for the + specified times when using RAS turbulence models. + + Default behaviour assumes operating in incompressible mode. + Use the -compressible option for compressible RAS cases. \*---------------------------------------------------------------------------*/ #include "fvCFD.H" + #include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H" -#include "RASModel.H" +#include "incompressible/RAS/RASModel/RASModel.H" + +#include "basicPsiThermo.H" +#include "compressible/RAS/RASModel/RASModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +void calcIncompressible +( + const fvMesh& mesh, + const Time& runTime, + const volVectorField& U, + volVectorField& wallShearStress +) +{ + #include "createPhi.H" + + singlePhaseTransportModel laminarTransport(U, phi); + + autoPtr model + ( + incompressible::RASModel::New(U, phi, laminarTransport) + ); + + const volSymmTensorField Reff(model->devReff()); + + forAll(wallShearStress.boundaryField(), patchI) + { + wallShearStress.boundaryField()[patchI] = + ( + -mesh.Sf().boundaryField()[patchI] + /mesh.magSf().boundaryField()[patchI] + ) & Reff.boundaryField()[patchI]; + } +} + + +void calcCompressible +( + const fvMesh& mesh, + const Time& runTime, + const volVectorField& U, + volVectorField& wallShearStress +) +{ + IOobject rhoHeader + ( + "rho", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (!rhoHeader.headerOk()) + { + Info<< " no rho field" << endl; + return; + } + + Info<< "Reading field rho\n" << endl; + volScalarField rho(rhoHeader, mesh); + + #include "compressibleCreatePhi.H" + + autoPtr pThermo + ( + basicPsiThermo::New(mesh) + ); + basicPsiThermo& thermo = pThermo(); + + autoPtr model + ( + compressible::RASModel::New + ( + rho, + U, + phi, + thermo + ) + ); + + const volSymmTensorField Reff(model->devRhoReff()); + + forAll(wallShearStress.boundaryField(), patchI) + { + wallShearStress.boundaryField()[patchI] = + ( + -mesh.Sf().boundaryField()[patchI] + /mesh.magSf().boundaryField()[patchI] + ) & Reff.boundaryField()[patchI]; + } +} + + int main(int argc, char *argv[]) { timeSelector::addOptions(); + + #include "addRegionOption.H" + + argList::addBoolOption + ( + "compressible", + "calculate compressible wall shear stress" + ); + #include "setRootCase.H" #include "createTime.H" instantList timeDirs = timeSelector::select0(runTime, args); - #include "createMesh.H" + #include "createNamedMesh.H" + + const bool compressible = args.optionFound("compressible"); forAll(timeDirs, timeI) { @@ -49,10 +156,6 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << endl; mesh.readUpdate(); - #include "createFields.H" - - volSymmTensorField Reff(RASModel->devReff()); - volVectorField wallShearStress ( IOobject @@ -67,19 +170,41 @@ int main(int argc, char *argv[]) dimensionedVector ( "wallShearStress", - Reff.dimensions(), + sqr(dimLength)/sqr(dimTime), vector::zero ) ); - forAll(wallShearStress.boundaryField(), patchi) + IOobject UHeader + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (UHeader.headerOk()) { - wallShearStress.boundaryField()[patchi] = - ( - -mesh.Sf().boundaryField()[patchi] - /mesh.magSf().boundaryField()[patchi] - ) & Reff.boundaryField()[patchi]; + Info<< "Reading field U\n" << endl; + volVectorField U(UHeader, mesh); + + if (compressible) + { + calcCompressible(mesh, runTime, U, wallShearStress); + } + else + { + calcIncompressible(mesh, runTime, U, wallShearStress); + } } + else + { + Info<< " no U field" << endl; + } + + Info<< "Writing wall shear stress to field " << wallShearStress.name() + << nl << endl; wallShearStress.write(); } diff --git a/applications/utilities/preProcessing/mapFields/MapConsistentVolFields.H b/applications/utilities/preProcessing/mapFields/MapConsistentVolFields.H index 2a203eac48..9015c473a2 100644 --- a/applications/utilities/preProcessing/mapFields/MapConsistentVolFields.H +++ b/applications/utilities/preProcessing/mapFields/MapConsistentVolFields.H @@ -35,12 +35,13 @@ License namespace Foam { -template +template void MapConsistentVolFields ( const IOobjectList& objects, const meshToMesh& meshToMeshInterp, - const meshToMesh::order& mapOrder + const meshToMesh::order& mapOrder, + const CombineOp& cop ) { const fvMesh& meshSource = meshToMeshInterp.fromMesh(); @@ -84,7 +85,13 @@ void MapConsistentVolFields ); // Interpolate field - meshToMeshInterp.interpolate(fieldTarget, fieldSource, mapOrder); + meshToMeshInterp.interpolate// > + ( + fieldTarget, + fieldSource, + mapOrder, + cop + ); // Write field fieldTarget.write(); @@ -97,7 +104,12 @@ void MapConsistentVolFields GeometricField fieldTarget ( fieldTargetIOobject, - meshToMeshInterp.interpolate(fieldSource, mapOrder) + meshToMeshInterp.interpolate// > + ( + fieldSource, + mapOrder, + cop + ) ); // Write field diff --git a/applications/utilities/preProcessing/mapFields/MapMeshes.H b/applications/utilities/preProcessing/mapFields/MapMeshes.H new file mode 100644 index 0000000000..e497eb0ccd --- /dev/null +++ b/applications/utilities/preProcessing/mapFields/MapMeshes.H @@ -0,0 +1,263 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#ifndef MapMeshes_H +#define MapMeshes_H + +#include "MapVolFields.H" +#include "MapConsistentVolFields.H" +#include "mapLagrangian.H" +#include "UnMapped.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +template class CombineOp> +void MapConsistentMesh +( + const fvMesh& meshSource, + const fvMesh& meshTarget, + const meshToMesh::order& mapOrder +) +{ + // Create the interpolation scheme + meshToMesh meshToMeshInterp(meshSource, meshTarget); + + Info<< nl + << "Consistently creating and mapping fields for time " + << meshSource.time().timeName() << nl << endl; + + { + // Search for list of objects for this time + IOobjectList objects(meshSource, meshSource.time().timeName()); + + // Map volFields + // ~~~~~~~~~~~~~ + MapConsistentVolFields + ( + objects, + meshToMeshInterp, + mapOrder, + CombineOp() + ); + MapConsistentVolFields + ( + objects, + meshToMeshInterp, + mapOrder, + CombineOp() + ); + MapConsistentVolFields + ( + objects, + meshToMeshInterp, + mapOrder, + CombineOp() + ); + MapConsistentVolFields + ( + objects, + meshToMeshInterp, + mapOrder, + CombineOp() + ); + MapConsistentVolFields + ( + objects, + meshToMeshInterp, + mapOrder, + CombineOp() + ); + } + + { + // Search for list of target objects for this time + IOobjectList objects(meshTarget, meshTarget.time().timeName()); + + // Mark surfaceFields as unmapped + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + UnMapped(objects); + UnMapped(objects); + UnMapped(objects); + UnMapped(objects); + UnMapped(objects); + + // Mark pointFields as unmapped + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + UnMapped(objects); + UnMapped(objects); + UnMapped(objects); + UnMapped(objects); + UnMapped(objects); + } + + mapLagrangian(meshToMeshInterp); +} + + +template class CombineOp> +void MapSubMesh +( + const fvMesh& meshSource, + const fvMesh& meshTarget, + const HashTable& patchMap, + const wordList& cuttingPatches, + const meshToMesh::order& mapOrder +) +{ + // Create the interpolation scheme + meshToMesh meshToMeshInterp + ( + meshSource, + meshTarget, + patchMap, + cuttingPatches + ); + + Info<< nl + << "Mapping fields for time " << meshSource.time().timeName() + << nl << endl; + + { + // Search for list of source objects for this time + IOobjectList objects(meshSource, meshSource.time().timeName()); + + // Map volFields + // ~~~~~~~~~~~~~ + MapVolFields + ( + objects, + meshToMeshInterp, + mapOrder, + CombineOp() + ); + MapVolFields + ( + objects, + meshToMeshInterp, + mapOrder, + CombineOp() + ); + MapVolFields + ( + objects, + meshToMeshInterp, + mapOrder, + CombineOp() + ); + MapVolFields + ( + objects, + meshToMeshInterp, + mapOrder, + CombineOp() + ); + MapVolFields + ( + objects, + meshToMeshInterp, + mapOrder, + CombineOp() + ); + } + + { + // Search for list of target objects for this time + IOobjectList objects(meshTarget, meshTarget.time().timeName()); + + // Mark surfaceFields as unmapped + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + UnMapped(objects); + UnMapped(objects); + UnMapped(objects); + UnMapped(objects); + UnMapped(objects); + + // Mark pointFields as unmapped + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + UnMapped(objects); + UnMapped(objects); + UnMapped(objects); + UnMapped(objects); + UnMapped(objects); + } + + mapLagrangian(meshToMeshInterp); +} + + +template class CombineOp> +void MapConsistentSubMesh +( + const fvMesh& meshSource, + const fvMesh& meshTarget, + const meshToMesh::order& mapOrder +) +{ + HashTable patchMap; + HashTable