diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C index 6ae60e42dc..2224030613 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C +++ b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C @@ -629,8 +629,9 @@ Foam::multiphaseSystem::dragCoeffs() const ( max ( - fvc::average(dm.phase1())*fvc::average(dm.phase2()), - //dm.phase1()*dm.phase2(), + //fvc::average(dm.phase1()*dm.phase2()), + //fvc::average(dm.phase1())*fvc::average(dm.phase2()), + dm.phase1()*dm.phase2(), dm.residualPhaseFraction() ) *dm.K diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/phaseModel/phaseModel/phaseModel.C b/applications/solvers/multiphase/multiphaseEulerFoam/phaseModel/phaseModel/phaseModel.C index bf65fe659c..543927e29b 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/phaseModel/phaseModel/phaseModel.C +++ b/applications/solvers/multiphase/multiphaseEulerFoam/phaseModel/phaseModel/phaseModel.C @@ -212,10 +212,10 @@ bool Foam::phaseModel::read(const dictionary& phaseDict) //if (nuModel_->read(phaseDict_)) { - phaseDict_.lookup("nu") >> nu_; - phaseDict_.lookup("kappa") >> kappa_; - phaseDict_.lookup("Cp") >> Cp_; - phaseDict_.lookup("rho") >> rho_; + phaseDict_.lookup("nu") >> nu_.value(); + phaseDict_.lookup("kappa") >> kappa_.value(); + phaseDict_.lookup("Cp") >> Cp_.value(); + phaseDict_.lookup("rho") >> rho_.value(); return true; } 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/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