From 46cdaf8e32fa11f1578712900166b32d0cf357c5 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 30 Nov 2010 16:10:48 +0000 Subject: [PATCH 01/76] ENH: Updated nBottomSweeps->nFinestSweeps in tutorials --- .../coalChemistryFoam/simplifiedSiwek/system/fvSolution | 2 +- .../compressibleInterFoam/les/depthCharge2D/system/fvSolution | 2 +- .../compressibleInterFoam/les/depthCharge3D/system/fvSolution | 2 +- .../interDyMFoam/ras/damBreakWithObstacle/system/fvSolution | 2 +- .../interDyMFoam/ras/floatingObject/system/fvSolution | 2 +- .../interDyMFoam/ras/sloshingTank2D/system/fvSolution | 2 +- .../interDyMFoam/ras/sloshingTank2D3DoF/system/fvSolution | 2 +- .../interDyMFoam/ras/sloshingTank3D/system/fvSolution | 2 +- .../interDyMFoam/ras/sloshingTank3D3DoF/system/fvSolution | 2 +- .../interDyMFoam/ras/sloshingTank3D6DoF/system/fvSolution | 2 +- .../multiphase/interDyMFoam/ras/testTubeMixer/system/fvSolution | 2 +- .../multiphase/interFoam/les/nozzleFlow2D/system/fvSolution | 2 +- .../laminar/damBreak4phase/system/fvSolution | 2 +- .../laminar/damBreak4phaseFine/system/fvSolution | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/fvSolution b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/fvSolution index aa49989c5b..c40ce42cf8 100644 --- a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/fvSolution +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/fvSolution @@ -40,7 +40,7 @@ solvers smoother GaussSeidel; nPreSweeps 0; nPostSweeps 2; - nBottomSweeps 2; + nFinestSweeps 2; cacheAgglomeration false; nCellsInCoarsestLevel 10; agglomerator faceAreaPair; diff --git a/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/system/fvSolution b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/system/fvSolution index 66a8e350d9..9d09fcfdb3 100644 --- a/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/system/fvSolution +++ b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/system/fvSolution @@ -28,7 +28,7 @@ solvers smoother DICGaussSeidel; nPreSweeps 0; nPostSweeps 2; - nBottomSweeps 2; + nFinestSweeps 2; cacheAgglomeration false; nCellsInCoarsestLevel 10; agglomerator faceAreaPair; diff --git a/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/system/fvSolution b/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/system/fvSolution index 66a8e350d9..9d09fcfdb3 100644 --- a/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/system/fvSolution +++ b/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/system/fvSolution @@ -28,7 +28,7 @@ solvers smoother DICGaussSeidel; nPreSweeps 0; nPostSweeps 2; - nBottomSweeps 2; + nFinestSweeps 2; cacheAgglomeration false; nCellsInCoarsestLevel 10; agglomerator faceAreaPair; diff --git a/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/system/fvSolution b/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/system/fvSolution index b8143ab07b..3f91dae6d4 100644 --- a/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/system/fvSolution +++ b/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/system/fvSolution @@ -28,7 +28,7 @@ solvers smoother GaussSeidel; nPreSweeps 0; nPostSweeps 2; - nBottomSweeps 2; + nFinestSweeps 2; cacheAgglomeration false; nCellsInCoarsestLevel 10; agglomerator faceAreaPair; diff --git a/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/fvSolution b/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/fvSolution index b6d29c6241..0cd58c354f 100644 --- a/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/fvSolution +++ b/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/fvSolution @@ -40,7 +40,7 @@ solvers smoother DICGaussSeidel; nPreSweeps 0; nPostSweeps 2; - nBottomSweeps 2; + nFinestSweeps 2; cacheAgglomeration false; nCellsInCoarsestLevel 10; agglomerator faceAreaPair; diff --git a/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D/system/fvSolution b/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D/system/fvSolution index 11a72d517a..12812ad721 100644 --- a/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D/system/fvSolution +++ b/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D/system/fvSolution @@ -28,7 +28,7 @@ solvers smoother DICGaussSeidel; nPreSweeps 0; nPostSweeps 2; - nBottomSweeps 2; + nFinestSweeps 2; cacheAgglomeration false; nCellsInCoarsestLevel 10; agglomerator faceAreaPair; diff --git a/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D3DoF/system/fvSolution b/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D3DoF/system/fvSolution index 11a72d517a..12812ad721 100644 --- a/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D3DoF/system/fvSolution +++ b/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D3DoF/system/fvSolution @@ -28,7 +28,7 @@ solvers smoother DICGaussSeidel; nPreSweeps 0; nPostSweeps 2; - nBottomSweeps 2; + nFinestSweeps 2; cacheAgglomeration false; nCellsInCoarsestLevel 10; agglomerator faceAreaPair; diff --git a/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D/system/fvSolution b/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D/system/fvSolution index 11a72d517a..12812ad721 100644 --- a/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D/system/fvSolution +++ b/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D/system/fvSolution @@ -28,7 +28,7 @@ solvers smoother DICGaussSeidel; nPreSweeps 0; nPostSweeps 2; - nBottomSweeps 2; + nFinestSweeps 2; cacheAgglomeration false; nCellsInCoarsestLevel 10; agglomerator faceAreaPair; diff --git a/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D3DoF/system/fvSolution b/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D3DoF/system/fvSolution index 11a72d517a..12812ad721 100644 --- a/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D3DoF/system/fvSolution +++ b/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D3DoF/system/fvSolution @@ -28,7 +28,7 @@ solvers smoother DICGaussSeidel; nPreSweeps 0; nPostSweeps 2; - nBottomSweeps 2; + nFinestSweeps 2; cacheAgglomeration false; nCellsInCoarsestLevel 10; agglomerator faceAreaPair; diff --git a/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D6DoF/system/fvSolution b/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D6DoF/system/fvSolution index 11a72d517a..12812ad721 100644 --- a/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D6DoF/system/fvSolution +++ b/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D6DoF/system/fvSolution @@ -28,7 +28,7 @@ solvers smoother DICGaussSeidel; nPreSweeps 0; nPostSweeps 2; - nBottomSweeps 2; + nFinestSweeps 2; cacheAgglomeration false; nCellsInCoarsestLevel 10; agglomerator faceAreaPair; diff --git a/tutorials/multiphase/interDyMFoam/ras/testTubeMixer/system/fvSolution b/tutorials/multiphase/interDyMFoam/ras/testTubeMixer/system/fvSolution index b2f497532f..3764ff4c6e 100644 --- a/tutorials/multiphase/interDyMFoam/ras/testTubeMixer/system/fvSolution +++ b/tutorials/multiphase/interDyMFoam/ras/testTubeMixer/system/fvSolution @@ -28,7 +28,7 @@ solvers smoother DICGaussSeidel; nPreSweeps 0; nPostSweeps 2; - nBottomSweeps 2; + nFinestSweeps 2; cacheAgglomeration false; nCellsInCoarsestLevel 10; agglomerator faceAreaPair; diff --git a/tutorials/multiphase/interFoam/les/nozzleFlow2D/system/fvSolution b/tutorials/multiphase/interFoam/les/nozzleFlow2D/system/fvSolution index 06e675ebf8..38782da870 100644 --- a/tutorials/multiphase/interFoam/les/nozzleFlow2D/system/fvSolution +++ b/tutorials/multiphase/interFoam/les/nozzleFlow2D/system/fvSolution @@ -28,7 +28,7 @@ solvers smoother DICGaussSeidel; nPreSweeps 0; nPostSweeps 2; - nBottomSweeps 2; + nFinestSweeps 2; cacheAgglomeration false; nCellsInCoarsestLevel 10; agglomerator faceAreaPair; diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/system/fvSolution b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/system/fvSolution index 143bfa585a..c194ad7907 100644 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/system/fvSolution +++ b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/system/fvSolution @@ -28,7 +28,7 @@ solvers smoother GaussSeidel; nPreSweeps 0; nPostSweeps 2; - nBottomSweeps 2; + nFinestSweeps 2; cacheAgglomeration off; nCellsInCoarsestLevel 10; agglomerator faceAreaPair; diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/system/fvSolution b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/system/fvSolution index c58dfc3740..cd28739cd7 100644 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/system/fvSolution +++ b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/system/fvSolution @@ -28,7 +28,7 @@ solvers smoother GaussSeidel; nPreSweeps 0; nPostSweeps 2; - nBottomSweeps 2; + nFinestSweeps 2; cacheAgglomeration off; nCellsInCoarsestLevel 10; agglomerator faceAreaPair; From ba5b08ddd26faf64a93580eed7792fd7d0e95f8b Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 1 Dec 2010 11:27:36 +0000 Subject: [PATCH 02/76] ENH: Added initialisation for variables in ODE solvers --- src/ODE/ODESolvers/KRR4/KRR4.C | 22 +++++++++++----------- src/ODE/ODESolvers/RK/RK.C | 16 ++++++++-------- src/ODE/ODESolvers/SIBS/SIBS.C | 20 ++++++++++---------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/ODE/ODESolvers/KRR4/KRR4.C b/src/ODE/ODESolvers/KRR4/KRR4.C index 95927e01b6..09df33ad9d 100644 --- a/src/ODE/ODESolvers/KRR4/KRR4.C +++ b/src/ODE/ODESolvers/KRR4/KRR4.C @@ -58,17 +58,17 @@ const scalar Foam::KRR4::KRR4(const ODE& ode) : ODESolver(ode), - yTemp_(n_), - dydxTemp_(n_), - g1_(n_), - g2_(n_), - g3_(n_), - g4_(n_), - yErr_(n_), - dfdx_(n_), - dfdy_(n_, n_), - a_(n_, n_), - pivotIndices_(n_) + yTemp_(n_, 0.0), + dydxTemp_(n_, 0.0), + g1_(n_, 0.0), + g2_(n_, 0.0), + g3_(n_, 0.0), + g4_(n_, 0.0), + yErr_(n_, 0.0), + dfdx_(n_, 0.0), + dfdy_(n_, n_, 0.0), + a_(n_, n_, 0.0), + pivotIndices_(n_, 0.0) {} diff --git a/src/ODE/ODESolvers/RK/RK.C b/src/ODE/ODESolvers/RK/RK.C index dd17c4aee5..3b74eb8f45 100644 --- a/src/ODE/ODESolvers/RK/RK.C +++ b/src/ODE/ODESolvers/RK/RK.C @@ -57,14 +57,14 @@ const scalar Foam::RK::RK(const ODE& ode) : ODESolver(ode), - yTemp_(n_), - ak2_(n_), - ak3_(n_), - ak4_(n_), - ak5_(n_), - ak6_(n_), - yErr_(n_), - yTemp2_(n_) + yTemp_(n_, 0.0), + ak2_(n_, 0.0), + ak3_(n_, 0.0), + ak4_(n_, 0.0), + ak5_(n_, 0.0), + ak6_(n_, 0.0), + yErr_(n_, 0.0), + yTemp2_(n_, 0.0) {} diff --git a/src/ODE/ODESolvers/SIBS/SIBS.C b/src/ODE/ODESolvers/SIBS/SIBS.C index 41f73e78a1..acaa5c9e76 100644 --- a/src/ODE/ODESolvers/SIBS/SIBS.C +++ b/src/ODE/ODESolvers/SIBS/SIBS.C @@ -50,17 +50,17 @@ namespace Foam Foam::SIBS::SIBS(const ODE& ode) : ODESolver(ode), - a_(iMaxX_), - alpha_(kMaxX_, kMaxX_), - d_p_(n_, kMaxX_), - x_p_(kMaxX_), - err_(kMaxX_), + a_(iMaxX_, 0.0), + alpha_(kMaxX_, kMaxX_, 0.0), + d_p_(n_, kMaxX_, 0.0), + x_p_(kMaxX_, 0.0), + err_(kMaxX_, 0.0), - yTemp_(n_), - ySeq_(n_), - yErr_(n_), - dfdx_(n_), - dfdy_(n_, n_), + yTemp_(n_, 0.0), + ySeq_(n_, 0.0), + yErr_(n_, 0.0), + dfdx_(n_, 0.0), + dfdy_(n_, n_, 0.0), first_(1), epsOld_(-1.0) {} From d645c06da6837c3c1cffa68d9572fed2218d8128 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 1 Dec 2010 11:47:24 +0000 Subject: [PATCH 03/76] ENH: Added Corrected enthalpy field name lookup for alphaSgsJayatillekeWallFunction --- ...ayatillekeWallFunctionFvPatchScalarField.C | 20 +++++++++++++------ ...ayatillekeWallFunctionFvPatchScalarField.H | 3 +++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/alphaSgsWallFunctions/alphaSgsJayatillekeWallFunction/alphaSgsJayatillekeWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/alphaSgsWallFunctions/alphaSgsJayatillekeWallFunction/alphaSgsJayatillekeWallFunctionFvPatchScalarField.C index adc76f9f4f..d9dffce684 100644 --- a/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/alphaSgsWallFunctions/alphaSgsJayatillekeWallFunction/alphaSgsJayatillekeWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/alphaSgsWallFunctions/alphaSgsJayatillekeWallFunction/alphaSgsJayatillekeWallFunctionFvPatchScalarField.C @@ -115,7 +115,9 @@ alphaSgsJayatillekeWallFunctionFvPatchScalarField fixedValueFvPatchScalarField(p, iF), Prt_(0.85), kappa_(0.41), - E_(9.8) + E_(9.8), + hsName_("hs") + { checkType(); } @@ -133,7 +135,9 @@ alphaSgsJayatillekeWallFunctionFvPatchScalarField fixedValueFvPatchScalarField(ptf, p, iF, mapper), Prt_(ptf.Prt_), kappa_(ptf.kappa_), - E_(ptf.E_) + E_(ptf.E_), + hsName_(ptf.hsName_) + {} @@ -148,7 +152,8 @@ alphaSgsJayatillekeWallFunctionFvPatchScalarField fixedValueFvPatchScalarField(p, iF, dict), Prt_(dict.lookupOrDefault("Prt", 0.85)), kappa_(dict.lookupOrDefault("kappa", 0.41)), - E_(dict.lookupOrDefault("E", 9.8)) + E_(dict.lookupOrDefault("E", 9.8)), + hsName_(dict.lookupOrDefault("hs", "hs")) { checkType(); } @@ -163,7 +168,8 @@ alphaSgsJayatillekeWallFunctionFvPatchScalarField fixedValueFvPatchScalarField(awfpsf), Prt_(awfpsf.Prt_), kappa_(awfpsf.kappa_), - E_(awfpsf.E_) + E_(awfpsf.E_), + hsName_(awfpsf.hsName_) { checkType(); } @@ -179,7 +185,8 @@ alphaSgsJayatillekeWallFunctionFvPatchScalarField fixedValueFvPatchScalarField(awfpsf, iF), Prt_(awfpsf.Prt_), kappa_(awfpsf.kappa_), - E_(awfpsf.E_) + E_(awfpsf.E_), + hsName_(awfpsf.hsName_) { checkType(); } @@ -209,7 +216,7 @@ void alphaSgsJayatillekeWallFunctionFvPatchScalarField::evaluate const scalarField& rhow = lesModel.rho().boundaryField()[patchI]; const fvPatchScalarField& hw = - patch().lookupPatchField("h"); + patch().lookupPatchField(hsName_); const scalarField& ry = patch().deltaCoeffs(); @@ -312,6 +319,7 @@ void alphaSgsJayatillekeWallFunctionFvPatchScalarField::write(Ostream& os) const os.writeKeyword("Prt") << Prt_ << token::END_STATEMENT << nl; os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; + os.writeKeyword("hs") << hsName_ << token::END_STATEMENT << nl; writeEntry("value", os); } diff --git a/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/alphaSgsWallFunctions/alphaSgsJayatillekeWallFunction/alphaSgsJayatillekeWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/alphaSgsWallFunctions/alphaSgsJayatillekeWallFunction/alphaSgsJayatillekeWallFunctionFvPatchScalarField.H index b06ba8c1c2..940d5fa263 100644 --- a/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/alphaSgsWallFunctions/alphaSgsJayatillekeWallFunction/alphaSgsJayatillekeWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/alphaSgsWallFunctions/alphaSgsJayatillekeWallFunction/alphaSgsJayatillekeWallFunctionFvPatchScalarField.H @@ -66,6 +66,9 @@ class alphaSgsJayatillekeWallFunctionFvPatchScalarField //- E coefficient scalar E_; + //- Name of (sensible/total) enthalpy field + word hsName_; + // Solution parameters From 0f8c3f0309a21448780db4143a37b1cee52a6a61 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 7 Dec 2010 15:43:12 +0000 Subject: [PATCH 04/76] BUG: mapDistribute : scheduled comms --- .../mapPolyMesh/mapDistribute/mapDistribute.C | 29 ++ .../mapPolyMesh/mapDistribute/mapDistribute.H | 9 + .../mapDistribute/mapDistributeTemplates.C | 254 ++++++------------ .../interpolationCellPoint.C | 5 +- 4 files changed, 122 insertions(+), 175 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C index 95813de6b6..af5b4393b8 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C @@ -165,6 +165,35 @@ const Foam::List& Foam::mapDistribute::schedule() const } +void Foam::mapDistribute::checkReceivedSize +( + const label procI, + const label expectedSize, + const label receivedSize +) +{ + if (receivedSize != expectedSize) + { + FatalErrorIn + ( + "template\n" + "void mapDistribute::distribute\n" + "(\n" + " const Pstream::commsTypes commsType,\n" + " const List& schedule,\n" + " const label constructSize,\n" + " const labelListList& subMap,\n" + " const labelListList& constructMap,\n" + " List& field\n" + ")\n" + ) << "Expected from processor " << procI + << " " << expectedSize << " but received " + << receivedSize << " elements." + << abort(FatalError); + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // //- Construct from components diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H index 0df1ce8484..ddd0486707 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H @@ -93,6 +93,15 @@ class mapDistribute mutable autoPtr > schedulePtr_; + // Private Member Functions + + static void checkReceivedSize + ( + const label procI, + const label expectedSize, + const label receivedSize + ); + public: // Constructors diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C index ef6c78299e..1a028f7443 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C @@ -111,25 +111,7 @@ void Foam::mapDistribute::distribute IPstream fromNbr(Pstream::blocking, domain); List subField(fromNbr); - if (subField.size() != map.size()) - { - FatalErrorIn - ( - "template\n" - "void mapDistribute::distribute\n" - "(\n" - " const Pstream::commsTypes commsType,\n" - " const List& schedule,\n" - " const label constructSize,\n" - " const labelListList& subMap,\n" - " const labelListList& constructMap,\n" - " List& field\n" - ")\n" - ) << "Expected from processor " << domain - << " " << map.size() << " but received " - << subField.size() << " elements." - << abort(FatalError); - } + checkReceivedSize(domain, map.size(), subField.size()); forAll(map, i) { @@ -160,46 +142,52 @@ void Foam::mapDistribute::distribute forAll(schedule, i) { const labelPair& twoProcs = schedule[i]; + // twoProcs is a swap pair of processors. The first one is the + // one that needs to send first and then receive. + label sendProc = twoProcs[0]; label recvProc = twoProcs[1]; if (Pstream::myProcNo() == sendProc) { - // I am sender. Send to recvProc. - OPstream toNbr(Pstream::scheduled, recvProc); - toNbr << UIndirectList(field, subMap[recvProc]); + // I am send first, receive next + { + OPstream toNbr(Pstream::scheduled, recvProc); + toNbr << UIndirectList(field, subMap[recvProc]); + } + { + IPstream fromNbr(Pstream::scheduled, recvProc); + List subField(fromNbr); + + const labelList& map = constructMap[recvProc]; + + checkReceivedSize(recvProc, map.size(), subField.size()); + + forAll(map, i) + { + newField[map[i]] = subField[i]; + } + } } else { - // I am receiver. Receive from sendProc. - IPstream fromNbr(Pstream::scheduled, sendProc); - List subField(fromNbr); - - const labelList& map = constructMap[sendProc]; - - if (subField.size() != map.size()) + // I am receive first, send next { - FatalErrorIn - ( - "template\n" - "void mapDistribute::distribute\n" - "(\n" - " const Pstream::commsTypes commsType,\n" - " const List& schedule,\n" - " const label constructSize,\n" - " const labelListList& subMap,\n" - " const labelListList& constructMap,\n" - " List& field\n" - ")\n" - ) << "Expected from processor " << sendProc - << " " << map.size() << " but received " - << subField.size() << " elements." - << abort(FatalError); + IPstream fromNbr(Pstream::scheduled, sendProc); + List subField(fromNbr); + + const labelList& map = constructMap[sendProc]; + + checkReceivedSize(sendProc, map.size(), subField.size()); + + forAll(map, i) + { + newField[map[i]] = subField[i]; + } } - - forAll(map, i) { - newField[map[i]] = subField[i]; + OPstream toNbr(Pstream::scheduled, sendProc); + toNbr << UIndirectList(field, subMap[sendProc]); } } } @@ -258,25 +246,7 @@ void Foam::mapDistribute::distribute UIPstream str(domain, pBufs); List recvField(str); - if (recvField.size() != map.size()) - { - FatalErrorIn - ( - "template\n" - "void mapDistribute::distribute\n" - "(\n" - " const Pstream::commsTypes commsType,\n" - " const List& schedule,\n" - " const label constructSize,\n" - " const labelListList& subMap,\n" - " const labelListList& constructMap,\n" - " List& field\n" - ")\n" - ) << "Expected from processor " << domain - << " " << map.size() << " but received " - << recvField.size() << " elements." - << abort(FatalError); - } + checkReceivedSize(domain, map.size(), recvField.size()); forAll(map, i) { @@ -379,29 +349,13 @@ void Foam::mapDistribute::distribute if (domain != Pstream::myProcNo() && map.size()) { - if (recvFields[domain].size() != map.size()) - { - FatalErrorIn - ( - "template\n" - "void mapDistribute::distribute\n" - "(\n" - " const Pstream::commsTypes commsType,\n" - " const List& schedule,\n" - " const label constructSize,\n" - " const labelListList& subMap,\n" - " const labelListList& constructMap,\n" - " List& field\n" - ")\n" - ) << "Expected from processor " << domain - << " " << map.size() << " but received " - << recvFields[domain].size() << " elements." - << abort(FatalError); - } + const List& subField = recvFields[domain]; + + checkReceivedSize(domain, map.size(), subField.size()); forAll(map, i) { - field[map[i]] = recvFields[domain][i]; + field[map[i]] = subField[i]; } } } @@ -502,25 +456,7 @@ void Foam::mapDistribute::distribute IPstream fromNbr(Pstream::blocking, domain); List subField(fromNbr); - if (subField.size() != map.size()) - { - FatalErrorIn - ( - "template\n" - "void mapDistribute::distribute\n" - "(\n" - " const Pstream::commsTypes commsType,\n" - " const List& schedule,\n" - " const label constructSize,\n" - " const labelListList& subMap,\n" - " const labelListList& constructMap,\n" - " List& field\n" - ")\n" - ) << "Expected from processor " << domain - << " " << map.size() << " but received " - << subField.size() << " elements." - << abort(FatalError); - } + checkReceivedSize(domain, map.size(), subField.size()); forAll(map, i) { @@ -551,46 +487,50 @@ void Foam::mapDistribute::distribute forAll(schedule, i) { const labelPair& twoProcs = schedule[i]; + // twoProcs is a swap pair of processors. The first one is the + // one that needs to send first and then receive. + label sendProc = twoProcs[0]; label recvProc = twoProcs[1]; if (Pstream::myProcNo() == sendProc) { - // I am sender. Send to recvProc. - OPstream toNbr(Pstream::scheduled, recvProc); - toNbr << UIndirectList(field, subMap[recvProc]); + // I am send first, receive next + { + OPstream toNbr(Pstream::scheduled, recvProc); + toNbr << UIndirectList(field, subMap[recvProc]); + } + { + IPstream fromNbr(Pstream::scheduled, recvProc); + List subField(fromNbr); + const labelList& map = constructMap[recvProc]; + + checkReceivedSize(recvProc, map.size(), subField.size()); + + forAll(map, i) + { + cop(newField[map[i]], subField[i]); + } + } } else { - // I am receiver. Receive from sendProc. - IPstream fromNbr(Pstream::scheduled, sendProc); - List subField(fromNbr); - - const labelList& map = constructMap[sendProc]; - - if (subField.size() != map.size()) + // I am receive first, send next { - FatalErrorIn - ( - "template\n" - "void mapDistribute::distribute\n" - "(\n" - " const Pstream::commsTypes commsType,\n" - " const List& schedule,\n" - " const label constructSize,\n" - " const labelListList& subMap,\n" - " const labelListList& constructMap,\n" - " List& field\n" - ")\n" - ) << "Expected from processor " << sendProc - << " " << map.size() << " but received " - << subField.size() << " elements." - << abort(FatalError); + IPstream fromNbr(Pstream::scheduled, sendProc); + List subField(fromNbr); + const labelList& map = constructMap[sendProc]; + + checkReceivedSize(sendProc, map.size(), subField.size()); + + forAll(map, i) + { + cop(newField[map[i]], subField[i]); + } } - - forAll(map, i) { - cop(newField[map[i]], subField[i]); + OPstream toNbr(Pstream::scheduled, sendProc); + toNbr << UIndirectList(field, subMap[sendProc]); } } } @@ -649,25 +589,7 @@ void Foam::mapDistribute::distribute UIPstream str(domain, pBufs); List recvField(str); - if (recvField.size() != map.size()) - { - FatalErrorIn - ( - "template\n" - "void mapDistribute::distribute\n" - "(\n" - " const Pstream::commsTypes commsType,\n" - " const List& schedule,\n" - " const label constructSize,\n" - " const labelListList& subMap,\n" - " const labelListList& constructMap,\n" - " List& field\n" - ")\n" - ) << "Expected from processor " << domain - << " " << map.size() << " but received " - << recvField.size() << " elements." - << abort(FatalError); - } + checkReceivedSize(domain, map.size(), recvField.size()); forAll(map, i) { @@ -769,29 +691,13 @@ void Foam::mapDistribute::distribute if (domain != Pstream::myProcNo() && map.size()) { - if (recvFields[domain].size() != map.size()) - { - FatalErrorIn - ( - "template\n" - "void mapDistribute::distribute\n" - "(\n" - " const Pstream::commsTypes commsType,\n" - " const List& schedule,\n" - " const label constructSize,\n" - " const labelListList& subMap,\n" - " const labelListList& constructMap,\n" - " List& field\n" - ")\n" - ) << "Expected from processor " << domain - << " " << map.size() << " but received " - << recvFields[domain].size() << " elements." - << abort(FatalError); - } + const List& subField = recvFields[domain]; + + checkReceivedSize(domain, map.size(), subField.size()); forAll(map, i) { - cop(field[map[i]], recvFields[domain][i]); + cop(field[map[i]], subField[i]); } } } diff --git a/src/finiteVolume/interpolation/interpolation/interpolationCellPoint/interpolationCellPoint.C b/src/finiteVolume/interpolation/interpolation/interpolationCellPoint/interpolationCellPoint.C index 9b76c5bb21..b71fccb8f7 100644 --- a/src/finiteVolume/interpolation/interpolation/interpolationCellPoint/interpolationCellPoint.C +++ b/src/finiteVolume/interpolation/interpolation/interpolationCellPoint/interpolationCellPoint.C @@ -36,7 +36,10 @@ Foam::interpolationCellPoint::interpolationCellPoint : interpolation(psi), psip_(volPointInterpolation::New(psi.mesh()).interpolate(psi)) -{} +{ + // Uses cellPointWeight to do interpolation which needs tet decomposition + (void)psi.mesh().tetBasePtIs(); +} // ************************************************************************* // From 069117eb8573650826d9ca404a8617d88611924b Mon Sep 17 00:00:00 2001 From: sergio Date: Tue, 7 Dec 2010 15:47:07 +0000 Subject: [PATCH 05/76] ENH: patchProbes additions. Test probes at patches --- src/sampling/Make/files | 1 + src/sampling/probes/IOprobes.H | 2 + src/sampling/probes/patchProbes.C | 162 ++++++++++++++++++ src/sampling/probes/patchProbes.H | 152 ++++++++++++++++ src/sampling/probes/patchProbesTemplates.C | 162 ++++++++++++++++++ src/sampling/probes/probes.C | 22 +-- src/sampling/probes/probes.H | 14 +- .../probesFunctionObject.C | 7 + .../probesFunctionObject.H | 2 + src/sampling/probes/probesTemplates.C | 4 +- 10 files changed, 510 insertions(+), 18 deletions(-) create mode 100644 src/sampling/probes/patchProbes.C create mode 100644 src/sampling/probes/patchProbes.H create mode 100644 src/sampling/probes/patchProbesTemplates.C diff --git a/src/sampling/Make/files b/src/sampling/Make/files index 6fee75b8f7..505719685f 100644 --- a/src/sampling/Make/files +++ b/src/sampling/Make/files @@ -1,4 +1,5 @@ probes/probes.C +probes/patchProbes.C probes/probesGrouping.C probes/probesFunctionObject/probesFunctionObject.C diff --git a/src/sampling/probes/IOprobes.H b/src/sampling/probes/IOprobes.H index e0c7b2e5ae..a7c279b853 100644 --- a/src/sampling/probes/IOprobes.H +++ b/src/sampling/probes/IOprobes.H @@ -33,6 +33,7 @@ Description #define IOprobes_H #include "probes.H" +#include "patchProbes.H" #include "IOOutputFilter.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -40,6 +41,7 @@ Description namespace Foam { typedef IOOutputFilter IOprobes; + typedef IOOutputFilter IOpatchProbes; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/sampling/probes/patchProbes.C b/src/sampling/probes/patchProbes.C new file mode 100644 index 0000000000..55ae5cd09d --- /dev/null +++ b/src/sampling/probes/patchProbes.C @@ -0,0 +1,162 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-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 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 . + +\*---------------------------------------------------------------------------*/ + +#include "patchProbes.H" +#include "volFields.H" +#include "dictionary.H" +#include "Time.H" +#include "IOmanip.H" +#include "directMappedPatchBase.C" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(patchProbes, 0); +} + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::patchProbes::findElements(const fvMesh& mesh) +{ + + elementList_.clear(); + elementList_.setSize(size()); + // All the info for nearest. Construct to miss + List nearest(this->size()); + + // Octree based search engine + meshSearch meshSearchEngine(mesh, false); + + forAll(*this, probeI) + { + const vector& sample = operator[](probeI); + label faceI = meshSearchEngine.findNearestBoundaryFace(sample); + if (faceI == -1) + { + nearest[probeI].second().first() = Foam::sqr(GREAT); + nearest[probeI].second().second() = Pstream::myProcNo(); + } + else + { + const point& fc = mesh.faceCentres()[faceI]; + nearest[probeI].first() = pointIndexHit + ( + true, + fc, + faceI + ); + nearest[probeI].second().first() = magSqr(fc-sample); + nearest[probeI].second().second() = Pstream::myProcNo(); + } + } + + + // Find nearest. + Pstream::listCombineGather(nearest, nearestEqOp()); + Pstream::listCombineScatter(nearest); + + if (debug) + { + Info<< "patchProbes::findElements" << " : " << endl; + forAll(nearest, sampleI) + { + label procI = nearest[sampleI].second().second(); + label localI = nearest[sampleI].first().index(); + + Info<< " " << sampleI << " coord:"<< operator[](sampleI) + << " found on processor:" << procI + << " in local cell/face:" << localI + << " with cc:" << nearest[sampleI].first().rawPoint() << endl; + } + } + + + + // Check if all patchProbes have been found. + forAll(nearest, sampleI) + { + label localI = nearest[sampleI].first().index(); + + if (localI == -1) + { + if (Pstream::master()) + { + WarningIn("patchProbes::findElements()") + << "Did not find location " + << nearest[sampleI].second().first() + << " in any cell. Skipping location." << endl; + } + } + else + { + elementList_[sampleI] = localI; + } + } +} + + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::patchProbes::patchProbes +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +: + probes(name, obr, dict, loadFromFiles) +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::patchProbes::~patchProbes() +{} + + +void Foam::patchProbes::write() +{ + if (this->size() && prepare()) + { + sampleAndWrite(scalarFields_); + sampleAndWrite(vectorFields_); + sampleAndWrite(sphericalTensorFields_); + sampleAndWrite(symmTensorFields_); + sampleAndWrite(tensorFields_); + } +} + +void Foam::patchProbes::read(const dictionary& dict) +{ + probes::read(dict); +} + + +// ************************************************************************* // diff --git a/src/sampling/probes/patchProbes.H b/src/sampling/probes/patchProbes.H new file mode 100644 index 0000000000..01a3559bad --- /dev/null +++ b/src/sampling/probes/patchProbes.H @@ -0,0 +1,152 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-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 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 . + +Class + Foam::patchProbes + +Description + Set of locations to sample.at patches + + Call write() to sample and write files. + +SourceFiles + patchProbes.C + +\*---------------------------------------------------------------------------*/ + +#ifndef patchProbes_H +#define patchProbes_H + +#include "HashPtrTable.H" +#include "OFstream.H" +#include "polyMesh.H" +#include "pointField.H" +#include "volFieldsFwd.H" +#include "probes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class objectRegistry; +class dictionary; +class fvMesh; +class mapPolyMesh; + +/*---------------------------------------------------------------------------*\ + Class patchProbes Declaration +\*---------------------------------------------------------------------------*/ + +class patchProbes +: + public probes +{ + + // Private Member Functions + + //- Sample and write a particular volume field + template + void sampleAndWrite + ( + const GeometricField& + ); + + + //- Sample and write all the fields of the given type + template + void sampleAndWrite(const fieldGroup&); + + + //- Sample a volume field at all locations + template + tmp > sample + ( + const GeometricField& + ) const; + + + //- Sample a single field on all sample locations + template + tmp > sample(const word& fieldName) const; + + + //- Disallow default bitwise copy construct + patchProbes(const patchProbes&); + + //- Disallow default bitwise assignment + void operator=(const patchProbes&); + + +public: + + //- Runtime type information + TypeName("patchProbes"); + + + // Constructors + + //- Construct for given objectRegistry and dictionary. + // Allow the possibility to load fields from files + patchProbes + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); + + + //- Destructor + virtual ~patchProbes(); + + //- Public members + + //- Sample and write + virtual void write(); + + //- Read + virtual void read(const dictionary&); + + //- Find elements containing patchProbes + virtual void findElements(const fvMesh&); + + +}; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "patchProbesTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/sampling/probes/patchProbesTemplates.C b/src/sampling/probes/patchProbesTemplates.C new file mode 100644 index 0000000000..c8176fb398 --- /dev/null +++ b/src/sampling/probes/patchProbesTemplates.C @@ -0,0 +1,162 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-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 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 . + +\*---------------------------------------------------------------------------*/ + +#include "patchProbes.H" +#include "volFields.H" +#include "IOmanip.H" + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +void Foam::patchProbes::sampleAndWrite +( + const GeometricField& vField +) +{ + Field values = sample(vField); + + if (Pstream::master()) + { + unsigned int w = IOstream::defaultPrecision() + 7; + OFstream& probeStream = *probeFilePtrs_[vField.name()]; + + probeStream << setw(w) << vField.time().value(); + + forAll(values, probeI) + { + probeStream << ' ' << setw(w) << values[probeI]; + } + probeStream << endl; + } +} + + +template +void Foam::patchProbes::sampleAndWrite +( + const fieldGroup& fields +) +{ + forAll(fields, fieldI) + { + if (loadFromFiles_) + { + sampleAndWrite + ( + GeometricField + ( + IOobject + ( + fields[fieldI], + mesh_.time().timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ), + mesh_ + ) + ); + } + else + { + objectRegistry::const_iterator iter = mesh_.find(fields[fieldI]); + + if + ( + iter != objectRegistry::end() + && iter()->type() + == GeometricField::typeName + ) + { + sampleAndWrite + ( + mesh_.lookupObject + > + ( + fields[fieldI] + ) + ); + } + } + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +Foam::tmp > +Foam::patchProbes::sample +( + const GeometricField& vField +) const +{ + const Type unsetVal(-VGREAT*pTraits::one); + + tmp > tValues + ( + new Field(this->size(), unsetVal) + ); + + Field& values = tValues(); + + const polyBoundaryMesh& patches = mesh_.boundaryMesh(); + + forAll(*this, probeI) + { + label faceI = elementList_[probeI]; + + if (faceI >= 0) + { + label patchI = patches.whichPatch(faceI); + label localFaceI = patches[patchI].whichFace(faceI); + values[probeI] = vField.boundaryField()[patchI][localFaceI]; + } + } + + Pstream::listCombineGather(values, isNotEqOp()); + Pstream::listCombineScatter(values); + + return tValues; +} + + +template +Foam::tmp > +Foam::patchProbes::sample(const word& fieldName) const +{ + return sample + ( + mesh_.lookupObject > + ( + fieldName + ) + ); +} + + +// ************************************************************************* // diff --git a/src/sampling/probes/probes.C b/src/sampling/probes/probes.C index 6ca13f1da2..11bf67af89 100644 --- a/src/sampling/probes/probes.C +++ b/src/sampling/probes/probes.C @@ -36,30 +36,30 @@ defineTypeNameAndDebug(Foam::probes, 0); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::probes::findCells(const fvMesh& mesh) +void Foam::probes::findElements(const fvMesh& mesh) { - cellList_.clear(); - cellList_.setSize(size()); + elementList_.clear(); + elementList_.setSize(size()); forAll(*this, probeI) { const vector& location = operator[](probeI); - cellList_[probeI] = mesh.findCell(location); + elementList_[probeI] = mesh.findCell(location); - if (debug && cellList_[probeI] != -1) + if (debug && elementList_[probeI] != -1) { Pout<< "probes : found point " << location - << " in cell " << cellList_[probeI] << endl; + << " in cell " << elementList_[probeI] << endl; } } // Check if all probes have been found. - forAll(cellList_, probeI) + forAll(elementList_, probeI) { const vector& location = operator[](probeI); - label cellI = cellList_[probeI]; + label cellI = elementList_[probeI]; // Check at least one processor with cell. reduce(cellI, maxOp