diff --git a/applications/solvers/combustion/XiFoam/bEqn.H b/applications/solvers/combustion/XiFoam/bEqn.H index e4a2f1ac39..df37bf34c5 100644 --- a/applications/solvers/combustion/XiFoam/bEqn.H +++ b/applications/solvers/combustion/XiFoam/bEqn.H @@ -63,6 +63,7 @@ if (ign.ignited()) // Solve for b // ~~~~~~~~~~~ + bEqn.relax(); bEqn.solve(); Info<< "min(b) = " << min(b).value() << endl; @@ -201,7 +202,7 @@ if (ign.ignited()) volScalarField XiEq ( scalar(1.001) - + (scalar(1) + (2*XiShapeCoef)*(scalar(0.5) - b)) + + (scalar(1) + (2*XiShapeCoef)*(scalar(0.5) - min(max(b, 0.0), 1.0))) *(XiEqStar - scalar(1.001)) ); diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/readMechanicalProperties.H b/applications/solvers/stressAnalysis/solidDisplacementFoam/readMechanicalProperties.H index c8e3ccba56..762245abf4 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/readMechanicalProperties.H +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/readMechanicalProperties.H @@ -13,70 +13,176 @@ ); const dictionary& rhoDict(mechanicalProperties.subDict("rho")); - word rhoType(rhoDict.lookup("rho")); + word rhoType(rhoDict.lookup("type")); - volScalarField rho + autoPtr rhoPtr; + + IOobject rhoIO ( - IOobject - ( - "rho", - runTime.timeName(), - mesh, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE - ), + "rho", + runTime.timeName(0), mesh, - dimensionedScalar("zero", dimMass/dimVolume, 0.0) + IOobject::NO_READ, + IOobject::NO_WRITE ); - if (rhoType == "rhoInf") + if (rhoType == "uniform") { - rho = rhoDict.lookup("rhoInf"); + scalar rhoValue(readScalar(rhoDict.lookup("value"))); + + rhoPtr.reset + ( + new volScalarField + ( + rhoIO, + mesh, + dimensionedScalar + ( + "rho", + dimMass/dimVolume, + rhoValue + ), + zeroGradientFvPatchField::typeName + ) + ); + } + else if (rhoType == "field") + { + rhoIO.readOpt() = IOobject::MUST_READ; + + rhoPtr.reset + ( + new volScalarField + ( + rhoIO, + mesh + ) + ); + } + else + { + FatalErrorIn + ( + "readMechanicalProperties.H" + ) << "Valid type entries are uniform or field for rho" + << abort(FatalError); } - volScalarField rhoE - ( - IOobject - ( - "E", - runTime.timeName(0), - mesh, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE - ), - mesh, - dimensionedScalar("0", dimMass/dimLength/sqr(dimTime), 0.0) - ); + volScalarField& rho = rhoPtr(); const dictionary& EDict(mechanicalProperties.subDict("E")); - word EType(EDict.lookup("E")); - if (EType == "EInf") + word EType(EDict.lookup("type")); + + autoPtr EPtr; + + IOobject EIO + ( + "E", + runTime.timeName(0), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ); + + if (EType == "uniform") { - rhoE = EDict.lookup("EInf"); + scalar rhoEValue(readScalar(EDict.lookup("value"))); + + EPtr.reset + ( + new volScalarField + ( + EIO, + mesh, + dimensionedScalar + ( + "Erho", + dimMass/dimLength/sqr(dimTime), + rhoEValue + ), + zeroGradientFvPatchField::typeName + ) + ); + } + else if (EType == "field") + { + EIO.readOpt() = IOobject::MUST_READ; + + EPtr.reset + ( + new volScalarField + ( + EIO, + mesh + ) + ); + } + else + { + FatalErrorIn + ( + "readMechanicalProperties.H" + ) << "Valid type entries are uniform or field for E" + << abort(FatalError); } + volScalarField& rhoE = EPtr(); - volScalarField nu + autoPtr nuPtr; + + IOobject nuIO ( - IOobject - ( - "nu", - runTime.timeName(0), - mesh, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE - ), + "nu", + runTime.timeName(0), mesh, - dimensionedScalar("0", dimless, 0.0) + IOobject::NO_READ, + IOobject::NO_WRITE ); const dictionary& nuDict(mechanicalProperties.subDict("nu")); - word nuType(nuDict.lookup("nu")); + word nuType(nuDict.lookup("type")); - if (nuType == "nuInf") + if (nuType == "uniform") { - nu = nuDict.lookup("nuInf"); + scalar nuValue(readScalar(nuDict.lookup("value"))); + nuPtr.reset + ( + new volScalarField + ( + nuIO, + mesh, + dimensionedScalar + ( + "nu", + dimless, + nuValue + ), + zeroGradientFvPatchField::typeName + ) + ); } + else if(nuType == "field") + { + nuIO.readOpt() = IOobject::MUST_READ; + nuPtr.reset + ( + new volScalarField + ( + nuIO, + mesh + ) + ); + } + else + { + FatalErrorIn + ( + "readMechanicalProperties.H" + ) << "Valid type entries are uniform or field for nu" + << abort(FatalError); + } + + volScalarField& nu = nuPtr(); Info<< "Normalising E : E/rho\n" << endl; volScalarField E = rhoE/rho; diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/readThermalProperties.H b/applications/solvers/stressAnalysis/solidDisplacementFoam/readThermalProperties.H index 4d7bb43fc9..54ac7d6db9 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/readThermalProperties.H +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/readThermalProperties.H @@ -46,70 +46,180 @@ volScalarField DT if (thermalStress) { - volScalarField C + + autoPtr CPtr; + + IOobject CIO ( - IOobject - ( - "C", - runTime.timeName(0), - mesh, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE - ), + "C", + runTime.timeName(0), mesh, - dimensionedScalar("0", dimensionSet(0, 2, -2 , -1, 0), 0.0) + IOobject::NO_READ, + IOobject::NO_WRITE ); const dictionary& CDict(thermalProperties.subDict("C")); - word CType(CDict.lookup("C")); - if (CType == "CInf") + word CType(CDict.lookup("type")); + if (CType == "uniform") { - C = CDict.lookup("CInf"); + scalar CValue(readScalar(CDict.lookup("value"))); + + CPtr.reset + ( + new volScalarField + ( + CIO, + mesh, + dimensionedScalar + ( + "C", + dimensionSet(0, 2, -2 , -1, 0), + CValue + ), + zeroGradientFvPatchField::typeName + ) + ); + + } + else if(CType == "field") + { + CIO.readOpt() = IOobject::MUST_READ; + + CPtr.reset + ( + new volScalarField + ( + CIO, + mesh + ) + ); + } + else + { + FatalErrorIn + ( + "readThermalProperties.H" + ) << "Valid type entries are uniform or field for C" + << abort(FatalError); } + volScalarField& C = CPtr(); - volScalarField rhoK + autoPtr rhoKPtr; + + IOobject rhoKIO ( - IOobject - ( - "k", - runTime.timeName(0), - mesh, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE - ), + "k", + runTime.timeName(0), mesh, - dimensionedScalar("0", dimensionSet(1, 1, -3 , -1, 0), 0.0) + IOobject::NO_READ, + IOobject::NO_WRITE ); const dictionary& kDict(thermalProperties.subDict("k")); - word kType(kDict.lookup("k")); - if (kType == "kInf") + word kType(kDict.lookup("type")); + if (kType == "uniform") { - rhoK = kDict.lookup("kInf"); + scalar rhoKValue(readScalar(kDict.lookup("value"))); + + rhoKPtr.reset + ( + new volScalarField + ( + rhoKIO, + mesh, + dimensionedScalar + ( + "rhoK", + dimensionSet(1, 1, -3 , -1, 0), + rhoKValue + ), + zeroGradientFvPatchField::typeName + ) + ); + + } + else if (kType == "field") + { + rhoKIO.readOpt() = IOobject::MUST_READ; + + rhoKPtr.reset + ( + new volScalarField + ( + rhoKIO, + mesh + ) + ); + } + else + { + FatalErrorIn + ( + "readThermalProperties.H" + ) << "Valid type entries are uniform or field for K" + << abort(FatalError); } - volScalarField alpha + volScalarField& rhoK = rhoKPtr(); + + autoPtr alphaPtr; + + IOobject alphaIO ( - IOobject - ( - "alpha", - runTime.timeName(0), - mesh, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE - ), + "alpha", + runTime.timeName(0), mesh, - dimensionedScalar("0", dimensionSet(0, 0, 0 , -1, 0), 0.0) + IOobject::NO_READ, + IOobject::NO_WRITE ); - const dictionary& alphaDict(thermalProperties.subDict("alpha")); - word alphaType(alphaDict.lookup("alpha")); - if (alphaType == "alphaInf") + const dictionary& alphaDict(thermalProperties.subDict("alpha")); + word alphaType(alphaDict.lookup("type")); + + if (alphaType == "uniform") { - alpha = alphaDict.lookup("alphaInf"); + scalar alphaValue(readScalar(alphaDict.lookup("value"))); + alphaPtr.reset + ( + new volScalarField + ( + alphaIO, + mesh, + dimensionedScalar + ( + "alpha", + inv(dimTemperature), + alphaValue + ), + zeroGradientFvPatchField::typeName + ) + ); } + else if (alphaType == "field") + { + alphaIO.readOpt() = IOobject::MUST_READ; + + alphaPtr.reset + ( + new volScalarField + ( + alphaIO, + mesh + ) + ); + } + else + { + FatalErrorIn + ( + "readThermalProperties.H" + ) << "Valid type entries are uniform or field for alpha" + << abort(FatalError); + } + + volScalarField& alpha = alphaPtr(); Info<< "Normalising k : k/rho\n" << endl; volScalarField k = rhoK/rho; diff --git a/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/tractionDisplacementCorrection/tractionDisplacementCorrectionFvPatchVectorField.C b/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/tractionDisplacementCorrection/tractionDisplacementCorrectionFvPatchVectorField.C index 8aff8879e7..47a2005992 100644 --- a/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/tractionDisplacementCorrection/tractionDisplacementCorrectionFvPatchVectorField.C +++ b/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/tractionDisplacementCorrection/tractionDisplacementCorrectionFvPatchVectorField.C @@ -150,13 +150,18 @@ void tractionDisplacementCorrectionFvPatchVectorField::updateCoeffs() "mechanicalProperties" ); - dimensionedScalar rho(mechanicalProperties.lookup("rho")); - dimensionedScalar rhoE(mechanicalProperties.lookup("E")); - dimensionedScalar nu(mechanicalProperties.lookup("nu")); + const fvPatchField& rho = + patch().lookupPatchField("rho"); - dimensionedScalar E = rhoE/rho; - dimensionedScalar mu = E/(2.0*(1.0 + nu)); - dimensionedScalar lambda = nu*E/((1.0 + nu)*(1.0 - 2.0*nu)); + const fvPatchField& rhoE = + patch().lookupPatchField("E"); + + const fvPatchField& nu = + patch().lookupPatchField("nu"); + + scalarField E = rhoE/rho; + scalarField mu = E/(2.0*(1.0 + nu)); + scalarField lambda = nu*E/((1.0 + nu)*(1.0 - 2.0*nu)); Switch planeStress(mechanicalProperties.lookup("planeStress")); @@ -175,8 +180,8 @@ void tractionDisplacementCorrectionFvPatchVectorField::updateCoeffs() gradient() = ( - (traction_ + pressure_*n)/rho.value() - (n & (sigmaD + sigmaExp)) - )/(2.0*mu + lambda).value(); + (traction_ + pressure_*n)/rho - (n & (sigmaD + sigmaExp)) + )/(2.0*mu + lambda); fixedGradientFvPatchVectorField::updateCoeffs(); } diff --git a/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C b/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C index db7585039a..2f99404f9a 100644 --- a/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C +++ b/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C @@ -715,7 +715,7 @@ int main(int argc, char *argv[]) triSurfaceSearch querySurf(surf); // Search engine on mesh. No face decomposition since mesh unwarped. - meshSearch queryMesh(mesh, false); + meshSearch queryMesh(mesh, polyMesh::FACEPLANES); // Check all 'outside' points forAll(outsidePts, outsideI) diff --git a/applications/utilities/mesh/advanced/selectCells/selectCells.C b/applications/utilities/mesh/advanced/selectCells/selectCells.C index 424826284d..ae7525f127 100644 --- a/applications/utilities/mesh/advanced/selectCells/selectCells.C +++ b/applications/utilities/mesh/advanced/selectCells/selectCells.C @@ -381,7 +381,7 @@ int main(int argc, char *argv[]) (void)edgeCalc.minLen(Info); // Search engine on mesh. Face decomposition since faces might be warped. - meshSearch queryMesh(mesh, true); + meshSearch queryMesh(mesh, polyMesh::FACEDIAGTETS); // Check all 'outside' points forAll(outsidePts, outsideI) diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C index f8ce438b1f..ad420d096f 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C @@ -971,7 +971,7 @@ Foam::backgroundMeshDecomposition::distribute { // Map cellVertices, cellVertexIndices and cellVertexTypes - meshSearch cellSearch(mesh_); + meshSearch cellSearch(mesh_, polyMesh::FACEPLANES); const labelList& reverseCellMap = map().reverseCellMap(); diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 5d4961e93e..3c7720e92a 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -1405,7 +1405,7 @@ bool Foam::conformalVoronoiMesh::distributeBackground() zeroGradientFvPatchScalarField::typeName ); - meshSearch cellSearch(bMesh); + meshSearch cellSearch(bMesh, polyMesh::FACEPLANES); List > cellVertices(bMesh.nCells()); List > cellVertexIndices(bMesh.nCells()); diff --git a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C index b34676fac5..2d75cc36ef 100644 --- a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C +++ b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C @@ -2194,7 +2194,7 @@ int main(int argc, char *argv[]) label regionI = -1; - label cellI = mesh.findCell(insidePoint); + label cellI = mesh.findCell(insidePoint, polyMesh::FACEDIAGTETS); Info<< nl << "Found point " << insidePoint << " in cell " << cellI << endl; diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index 50c5f9b592..1a92c9bc39 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -528,7 +528,11 @@ 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(), + polyMesh::FACEDIAGTETS + ) << exit(FatalError); } diff --git a/applications/utilities/preProcessing/mapFields/mapLagrangian.C b/applications/utilities/preProcessing/mapFields/mapLagrangian.C index ee0e2aa4d3..f73029529e 100644 --- a/applications/utilities/preProcessing/mapFields/mapLagrangian.C +++ b/applications/utilities/preProcessing/mapFields/mapLagrangian.C @@ -56,7 +56,11 @@ static label findCell(const Cloud& cloud, const point& pt) // See if particle on face by finding nearest face and shifting // particle. - meshSearch meshSearcher(mesh, false); + meshSearch meshSearcher + ( + mesh, + polyMesh::FACEPLANES // no decomposition needed + ); label faceI = meshSearcher.findNearestBoundaryFace(pt); diff --git a/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.C b/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.C index 9dab19abe4..1bb57a44d7 100644 --- a/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.C +++ b/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.C @@ -25,7 +25,7 @@ License #include "treeDataCell.H" #include "indexedOctree.H" -#include "primitiveMesh.H" +#include "polyMesh.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -83,13 +83,15 @@ void Foam::treeDataCell::update() Foam::treeDataCell::treeDataCell ( const bool cacheBb, - const primitiveMesh& mesh, - const labelUList& cellLabels + const polyMesh& mesh, + const labelUList& cellLabels, + const polyMesh::cellRepresentation decompMode ) : mesh_(mesh), cellLabels_(cellLabels), - cacheBb_(cacheBb) + cacheBb_(cacheBb), + decompMode_(decompMode) { update(); } @@ -98,13 +100,15 @@ Foam::treeDataCell::treeDataCell Foam::treeDataCell::treeDataCell ( const bool cacheBb, - const primitiveMesh& mesh, - const Xfer& cellLabels + const polyMesh& mesh, + const Xfer& cellLabels, + const polyMesh::cellRepresentation decompMode ) : mesh_(mesh), cellLabels_(cellLabels), - cacheBb_(cacheBb) + cacheBb_(cacheBb), + decompMode_(decompMode) { update(); } @@ -113,12 +117,14 @@ Foam::treeDataCell::treeDataCell Foam::treeDataCell::treeDataCell ( const bool cacheBb, - const primitiveMesh& mesh + const polyMesh& mesh, + const polyMesh::cellRepresentation decompMode ) : mesh_(mesh), cellLabels_(identity(mesh_.nCells())), - cacheBb_(cacheBb) + cacheBb_(cacheBb), + decompMode_(decompMode) { update(); } @@ -162,7 +168,7 @@ bool Foam::treeDataCell::contains const point& sample ) const { - return mesh_.pointInCell(sample, cellLabels_[index]); + return mesh_.pointInCell(sample, cellLabels_[index], decompMode_); } diff --git a/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.H b/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.H index 62bf4b4a4f..476266faf9 100644 --- a/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.H +++ b/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.H @@ -36,6 +36,7 @@ SourceFiles #ifndef treeDataCell_H #define treeDataCell_H +#include "polyMesh.H" #include "treeBoundBoxList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -44,7 +45,6 @@ namespace Foam { // Forward declaration of classes -class primitiveMesh; template class indexedOctree; /*---------------------------------------------------------------------------*\ @@ -55,7 +55,7 @@ class treeDataCell { // Private data - const primitiveMesh& mesh_; + const polyMesh& mesh_; //- Subset of cells to work on const labelList cellLabels_; @@ -63,6 +63,9 @@ class treeDataCell //- Whether to precalculate and store cell bounding box const bool cacheBb_; + //- How to decide if point is inside cell + const polyMesh::cellRepresentation decompMode_; + //- cell bounding boxes (valid only if cacheBb_) treeBoundBoxList bbs_; @@ -87,20 +90,27 @@ public: treeDataCell ( const bool cacheBb, - const primitiveMesh&, - const labelUList& + const polyMesh&, + const labelUList&, + const polyMesh::cellRepresentation decompMode ); //- Construct from mesh and subset of cells, transferring contents treeDataCell ( const bool cacheBb, - const primitiveMesh&, - const Xfer& + const polyMesh&, + const Xfer&, + const polyMesh::cellRepresentation decompMode ); //- Construct from mesh. Uses all cells in mesh. - treeDataCell(const bool cacheBb, const primitiveMesh&); + treeDataCell + ( + const bool cacheBb, + const polyMesh&, + const polyMesh::cellRepresentation decompMode + ); // Member Functions @@ -112,11 +122,15 @@ public: return cellLabels_; } - inline const primitiveMesh& mesh() const + inline const polyMesh& mesh() const { return mesh_; } + inline polyMesh::cellRepresentation decompMode() const + { + return decompMode_; + } inline label size() const { diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaces/cyclicGAMGInterface/cyclicGAMGInterface.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaces/cyclicGAMGInterface/cyclicGAMGInterface.C index e4d56022f0..39038f5f29 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaces/cyclicGAMGInterface/cyclicGAMGInterface.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaces/cyclicGAMGInterface/cyclicGAMGInterface.C @@ -25,7 +25,8 @@ License #include "cyclicGAMGInterface.H" #include "addToRunTimeSelectionTable.H" -#include "Map.H" +#include "labelPair.H" +#include "HashTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -62,180 +63,65 @@ Foam::cyclicGAMGInterface::cyclicGAMGInterface ), fineCyclicInterface_(refCast(fineInterface)) { - // Make a lookup table of entries for owner/neighbour - Map > neighboursTable + // From coarse face to coarse cell + DynamicList