From 7240fdd5f86364eeac5ad6f777473ec303de080a Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 7 Aug 2012 17:39:24 +0100 Subject: [PATCH 01/34] ENH: moveDynamicMesh: added option to dump AMI weights --- .../moveDynamicMesh/moveDynamicMesh.C | 86 ++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C b/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C index 47f1dba097..00c97614de 100644 --- a/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C +++ b/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,19 +32,98 @@ Description #include "argList.H" #include "Time.H" #include "dynamicFvMesh.H" +#include "vtkSurfaceWriter.H" +#include "cyclicAMIPolyPatch.H" using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Dump patch + weights to vtk file +void writeWeights +( + const scalarField& wghtSum, + const primitivePatch& patch, + const fileName& folder, + const fileName& prefix, + const word& timeName +) +{ + vtkSurfaceWriter writer; + + writer.write + ( + folder, + prefix + "_proc" + Foam::name(Pstream::myProcNo()) + "_" + timeName, + patch.localPoints(), + patch.localFaces(), + "weightsSum", + wghtSum, + false + ); +} + + +void writeWeights(const polyMesh& mesh) +{ + const polyBoundaryMesh& pbm = mesh.boundaryMesh(); + + const word tmName(mesh.time().timeName()); + + forAll(pbm, patchI) + { + if (isA(pbm[patchI])) + { + const cyclicAMIPolyPatch& cpp = + refCast(pbm[patchI]); + + if (cpp.owner()) + { + const AMIPatchToPatchInterpolation& ami = + cpp.AMI(); + writeWeights + ( + ami.tgtWeightsSum(), + cpp.neighbPatch(), + "output", + "tgt", + tmName + ); + writeWeights + ( + ami.srcWeightsSum(), + cpp, + "output", + "src", + tmName + ); + } + } + } +} + + // Main program: int main(int argc, char *argv[]) { + argList::addBoolOption + ( + "checkAMI", + "check AMI weights" + ); # include "setRootCase.H" # include "createTime.H" # include "createDynamicFvMesh.H" + const bool checkAMI = args.optionFound("checkAMI"); + + if (checkAMI) + { + Info<< "Writing VTK files with weights of AMI patches." << nl << endl; + } + while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << endl; @@ -52,6 +131,11 @@ int main(int argc, char *argv[]) mesh.update(); mesh.checkMesh(true); + if (checkAMI) + { + writeWeights(mesh); + } + runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" From affe532cd82f90d77a211aa88eef8856a58f16e1 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 14 Aug 2012 09:33:35 +0100 Subject: [PATCH 02/34] STYLE: updated notImplemented comment --- .../chemistryModel/ODEChemistryModel/ODEChemistryModel.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.C b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.C index c18cccb712..438971d9cd 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.C @@ -856,7 +856,7 @@ Foam::scalar Foam::ODEChemistryModel::solve "const scalar, " "const scalar, " "const scalar" - ")" + ") const" ); return (0); From 69cc8d8ae7daee12be6ddcc3feab6fef0208a797 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 14 Aug 2012 14:25:34 +0100 Subject: [PATCH 03/34] ENH: change deltaTChem to DimensionedField to enable auto mapping --- .../basicChemistryModel/basicChemistryModel.C | 14 +++++++++++++- .../basicChemistryModel/basicChemistryModel.H | 15 ++++++++++----- .../basicChemistryModel/basicChemistryModelI.H | 8 +++++--- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.C b/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.C index 38efa9e858..43b876fbd6 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.C @@ -64,7 +64,19 @@ Foam::basicChemistryModel::basicChemistryModel(const fvMesh& mesh) mesh_(mesh), chemistry_(lookup("chemistry")), deltaTChemIni_(readScalar(lookup("initialChemicalTimeStep"))), - deltaTChem_(mesh.nCells(), deltaTChemIni_) + deltaTChem_ + ( + IOobject + ( + "deltaTChem", + mesh.time().constant(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("deltaTChem0", dimTime, deltaTChemIni_) + ) {} diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.H b/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.H index 2f27d59f70..da54d4c916 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -40,6 +40,8 @@ SourceFiles #include "Switch.H" #include "scalarField.H" #include "volFieldsFwd.H" +#include "volMesh.H" +#include "DimensionedField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -80,14 +82,14 @@ protected: const scalar deltaTChemIni_; //- Latest estimation of integration step - scalarField deltaTChem_; + DimensionedField deltaTChem_; // Protected Member Functions //- Return non-const access to the latest estimation of integration // step, e.g. for multi-chemistry model - scalarField& deltaTChem(); + inline DimensionedField& deltaTChem(); //- Correct function - updates due to mesh changes void correct(); @@ -118,7 +120,7 @@ public: inline Switch chemistry() const; //- Return the latest estimation of integration step - inline const scalarField& deltaTChem() const; + inline const DimensionedField& deltaTChem() const; // Functions to be derived in derived classes @@ -126,7 +128,10 @@ public: // Fields //- Return const access to chemical source terms [kg/m3/s] - virtual tmp RR(const label i) const = 0; + virtual const DimensionedField& RR + ( + const label i + ) const = 0; // Chemistry solution diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModelI.H b/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModelI.H index eeec0af749..6455309e15 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModelI.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModelI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,13 +37,15 @@ inline Foam::Switch Foam::basicChemistryModel::chemistry() const } -inline const Foam::scalarField& Foam::basicChemistryModel::deltaTChem() const +inline const Foam::DimensionedField& +Foam::basicChemistryModel::deltaTChem() const { return deltaTChem_; } -inline Foam::scalarField& Foam::basicChemistryModel::deltaTChem() +inline Foam::DimensionedField& +Foam::basicChemistryModel::deltaTChem() { return deltaTChem_; } From af1437fd14b8209fcde3ac3a22098c537810cf11 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 14 Aug 2012 14:26:11 +0100 Subject: [PATCH 04/34] ENH: Added DimensionedField handling to volume/domain integrate --- .../finiteVolume/fvc/fvcVolumeIntegrate.C | 51 +++++++++++++++++-- .../finiteVolume/fvc/fvcVolumeIntegrate.H | 28 +++++++++- 2 files changed, 75 insertions(+), 4 deletions(-) diff --git a/src/finiteVolume/finiteVolume/fvc/fvcVolumeIntegrate.C b/src/finiteVolume/finiteVolume/fvc/fvcVolumeIntegrate.C index f01c72ce6c..783a20482e 100644 --- a/src/finiteVolume/finiteVolume/fvc/fvcVolumeIntegrate.C +++ b/src/finiteVolume/finiteVolume/fvc/fvcVolumeIntegrate.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -49,6 +49,7 @@ volumeIntegrate return vf.mesh().V()*vf.internalField(); } + template tmp > volumeIntegrate @@ -62,6 +63,23 @@ volumeIntegrate } +template +tmp > volumeIntegrate(const DimensionedField& df) +{ + return df.mesh().V()*df.field(); +} + + +template +tmp > +volumeIntegrate(const tmp >& tdf) +{ + tmp > tdidf = tdf().mesh().V()*tdf().field(); + tdf.clear(); + return tdidf; +} + + template dimensioned domainIntegrate @@ -77,9 +95,9 @@ domainIntegrate ); } + template -dimensioned -domainIntegrate +dimensioned domainIntegrate ( const tmp >& tvf ) @@ -90,6 +108,33 @@ domainIntegrate } +template +dimensioned domainIntegrate +( + const DimensionedField& df +) +{ + return dimensioned + ( + "domainIntegrate(" + df.name() + ')', + dimVol*df.dimensions(), + gSum(fvc::volumeIntegrate(df)) + ); +} + + +template +dimensioned domainIntegrate +( + const tmp >& tdf +) +{ + dimensioned integral = domainIntegrate(tdf()); + tdf.clear(); + return integral; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace fvc diff --git a/src/finiteVolume/finiteVolume/fvc/fvcVolumeIntegrate.H b/src/finiteVolume/finiteVolume/fvc/fvcVolumeIntegrate.H index 741d1451b4..784087ee30 100644 --- a/src/finiteVolume/finiteVolume/fvc/fvcVolumeIntegrate.H +++ b/src/finiteVolume/finiteVolume/fvc/fvcVolumeIntegrate.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -67,6 +67,19 @@ namespace fvc ); + template + tmp > volumeIntegrate + ( + const DimensionedField& + ); + + template + tmp > volumeIntegrate + ( + const tmp >& + ); + + template dimensioned domainIntegrate ( @@ -78,6 +91,19 @@ namespace fvc ( const tmp >& ); + + + template + dimensioned domainIntegrate + ( + const DimensionedField& + ); + + template + dimensioned domainIntegrate + ( + const tmp >& + ); } From 1b9320bc0cce74a34837c644012205fea320d555 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 14 Aug 2012 14:26:50 +0100 Subject: [PATCH 05/34] ENH: change reaction rates to DimensionedFields to enable auto mapping --- .../reactingOneDim/reactingOneDim.C | 6 +- .../ODEChemistryModel/ODEChemistryModel.C | 18 +++- .../ODEChemistryModel/ODEChemistryModel.H | 14 +-- .../ODEChemistryModel/ODEChemistryModelI.H | 31 +------ .../ODESolidChemistryModel.C | 45 ++++++++-- .../ODESolidChemistryModel.H | 28 ++++-- .../ODESolidChemistryModelI.H | 90 +++++-------------- .../solidChemistryModel/solidChemistryModel.H | 14 ++- 8 files changed, 118 insertions(+), 128 deletions(-) diff --git a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C index d20552f368..05c6c7b9a2 100644 --- a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C +++ b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C @@ -153,10 +153,10 @@ void reactingOneDim::updatePhiGas() tmp tHsiGas = solidChemistry_->gasHs(solidThermo_.p(), solidThermo_.T(), gasI); - tmp tRRiGas = solidChemistry_->RRg(gasI); - const volScalarField& HsiGas = tHsiGas(); - const volScalarField& RRiGas = tRRiGas(); + + const DimensionedField& RRiGas = + solidChemistry_->RRg(gasI); label totalFaceId = 0; forAll(intCoupledPatchIDs_, i) diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.C b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.C index 438971d9cd..882aeff0a0 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.C @@ -64,7 +64,19 @@ Foam::ODEChemistryModel::ODEChemistryModel RR_.set ( fieldI, - new scalarField(mesh.nCells(), 0.0) + new DimensionedField + ( + IOobject + ( + "RR::" + Y_[fieldI].name(), + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0) + ) ); } @@ -706,7 +718,7 @@ void Foam::ODEChemistryModel::calculate() for (label i=0; i::solve for (label i = 0; i < nSpecie_; i++) { RR_[i].setSize(this->mesh().nCells()); - RR_[i] = 0.0; + RR_[i].field() = 0.0; } } diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.H b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.H index 9128e41557..da560dae87 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -42,6 +42,7 @@ SourceFiles #include "ODE.H" #include "volFieldsFwd.H" #include "simpleMatrix.H" +#include "DimensionedField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -90,14 +91,14 @@ protected: label nReaction_; //- List of reaction rate per specie [kg/m3/s] - PtrList RR_; + PtrList > RR_; // Protected Member Functions //- Write access to chemical source terms // (e.g. for multi-chemistry model) - inline PtrList& RR(); + inline PtrList >& RR(); public: @@ -205,8 +206,11 @@ public: // Chemistry model functions (overriding abstract functions in // basicChemistryModel.H) - //- Return const access to the chemical source terms - inline tmp RR(const label i) const; + //- Return const access to the chemical source terms for specie, i + inline const DimensionedField& RR + ( + const label i + ) const; //- Solve the reaction system for the given start time and time // step and return the characteristic time diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModelI.H b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModelI.H index 8031b68ba4..9f06a064a7 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModelI.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModelI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,7 +29,7 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -inline Foam::PtrList& +inline Foam::PtrList >& Foam::ODEChemistryModel::RR() { return RR_; @@ -69,36 +69,13 @@ Foam::ODEChemistryModel::nReaction() const template -inline Foam::tmp +inline const Foam::DimensionedField& Foam::ODEChemistryModel::RR ( const label i ) const { - tmp tRR - ( - new volScalarField - ( - IOobject - ( - "RR(" + this->Y_[i].name() + ')', - this->time().timeName(), - this->mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - this->mesh(), - dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0), - zeroGradientFvPatchScalarField::typeName - ) - ); - - if (this->chemistry_) - { - tRR().internalField() = RR_[i]; - tRR().correctBoundaryConditions(); - } - return tRR; + return RR_[i]; } diff --git a/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModel.C b/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModel.C index 093c6d8d84..54097f267a 100644 --- a/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModel.C +++ b/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModel.C @@ -71,7 +71,19 @@ ODESolidChemistryModel RRs_.set ( fieldI, - new scalarField(mesh.nCells(), 0.0) + new DimensionedField + ( + IOobject + ( + "RRs::" + Ys_[fieldI].name(), + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0) + ) ); @@ -134,7 +146,8 @@ ODESolidChemistryModel Y0Default ) ); - // Calculate inital values of Ysi0 = rho*delta*Yi + + // Calculate inital values of Ysi0 = rho*delta*Yi Ys0_[fieldI].internalField() = this->solid().rho() *max(Ys_[fieldI], scalar(0.001))*mesh.V(); @@ -143,7 +156,23 @@ ODESolidChemistryModel forAll(RRg_, fieldI) { - RRg_.set(fieldI, new scalarField(mesh.nCells(), 0.0)); + RRg_.set + ( + fieldI, + new DimensionedField + ( + IOobject + ( + "RRg::" + pyrolisisGases_[fieldI], + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0) + ) + ); } forAll(gasThermo_, gasI) @@ -551,11 +580,11 @@ calculate() forAll(RRs_, i) { - RRs_[i] = 0.0; + RRs_[i].field() = 0.0; } forAll(RRg_, i) { - RRg_[i] = 0.0; + RRg_[i].field() = 0.0; } if (this->chemistry_) @@ -631,11 +660,11 @@ Foam::ODESolidChemistryModel::solve forAll(RRs_, i) { - RRs_[i] = 0.0; + RRs_[i].field() = 0.0; } forAll(RRg_, i) { - RRg_[i] = 0.0; + RRg_[i].field() = 0.0; } if (!this->chemistry_) @@ -798,7 +827,7 @@ Foam::ODESolidChemistryModel::solve "const scalar, " "const scalar, " "const scalar" - ")" + ") const" ); return (0); } diff --git a/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModel.H b/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModel.H index 5dc785c9c7..df48750381 100644 --- a/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModel.H +++ b/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModel.H @@ -41,6 +41,7 @@ SourceFiles #include "solidReaction.H" #include "ODE.H" #include "volFieldsFwd.H" +#include "DimensionedField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -96,19 +97,19 @@ protected: label nReaction_; //- List of reaction rate per solid [kg/m3/s] - PtrList RRs_; + PtrList > RRs_; //- List of reaction rate per gas [kg/m3/s] - PtrList RRg_; + PtrList > RRg_; // Protected Member Functions //- Write access to source terms for solids - inline PtrList& RRs(); + inline PtrList >& RRs(); //- Write access to source terms for gases - inline PtrList& RRg(); + inline PtrList >& RRg(); private: @@ -203,19 +204,28 @@ public: // Chemistry model functions //- Return const access to the chemical source terms for solids - inline tmp RRs(const label i) const; + inline const DimensionedField& RRs + ( + const label i + ) const; //- Return const access to the chemical source terms for gases - inline tmp RRg(const label i) const; + inline const DimensionedField& RRg + ( + const label i + ) const; //- Return total gas source term - inline tmp RRg() const; + inline tmp > RRg() const; //- Return total solid source term - inline tmp RRs() const; + inline tmp > RRs() const; //- Return const access to the total source terms - inline tmp RR(const label i) const; + inline const DimensionedField& RR + ( + const label i + ) const; //- Return sensible enthalpy for gas i [J/Kg] virtual tmp gasHs diff --git a/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModelI.H b/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModelI.H index 802345f3a9..bcb6a89f99 100644 --- a/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModelI.H +++ b/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModelI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,7 +29,7 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -inline Foam::PtrList& +inline Foam::PtrList >& Foam::ODESolidChemistryModel::RRs() { return RRs_; @@ -37,7 +37,7 @@ Foam::ODESolidChemistryModel::RRs() template -inline Foam::PtrList& +inline Foam::PtrList >& Foam::ODESolidChemistryModel::RRg() { return RRg_; @@ -87,80 +87,34 @@ nReaction() const template -inline Foam::tmp +inline const Foam::DimensionedField& Foam::ODESolidChemistryModel::RRs ( const label i ) const { - tmp tRRs - ( - new volScalarField - ( - IOobject - ( - "RRs(" + Ys_[i].name() + ')', - this->time().timeName(), - this->mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - this->mesh(), - dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0), - zeroGradientFvPatchScalarField::typeName - ) - ); - - if (this->chemistry_) - { - tRRs().internalField() = RRs_[i]; - tRRs().correctBoundaryConditions(); - } - return tRRs; + return RRs_[i]; } template -inline Foam::tmp +inline const Foam::DimensionedField& Foam::ODESolidChemistryModel::RRg ( const label i ) const { - tmp tRRg - ( - new volScalarField - ( - IOobject - ( - "RRg(" + this->pyrolisisGases_[i] + ')', - this->time().timeName(), - this->mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - this->mesh(), - dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0), - zeroGradientFvPatchScalarField::typeName - ) - ); - - if (this->chemistry_) - { - tRRg().internalField() = RRg_[i]; - tRRg().correctBoundaryConditions(); - } - return tRRg; + return RRg_[i]; } template -inline Foam::tmp +inline Foam::tmp > Foam::ODESolidChemistryModel::RRg() const { - tmp tRRg + tmp > tRRg ( - new volScalarField + new DimensionedField ( IOobject ( @@ -171,30 +125,29 @@ Foam::ODESolidChemistryModel::RRg() const IOobject::NO_WRITE ), this->mesh(), - dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0), - zeroGradientFvPatchScalarField::typeName + dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0) ) ); if (this->chemistry_) { + DimensionedField& RRg = tRRg(); for (label i=0; i < nGases_; i++) { - tRRg().internalField() += RRg_[i]; + RRg += RRg_[i]; } - tRRg().correctBoundaryConditions(); } return tRRg; } template -inline Foam::tmp +inline Foam::tmp > Foam::ODESolidChemistryModel::RRs() const { - tmp tRRs + tmp > tRRs ( - new volScalarField + new DimensionedField ( IOobject ( @@ -205,32 +158,31 @@ Foam::ODESolidChemistryModel::RRs() const IOobject::NO_WRITE ), this->mesh(), - dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0), - zeroGradientFvPatchScalarField::typeName + dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0) ) ); if (this->chemistry_) { + DimensionedField& RRs = tRRs(); for (label i=0; i < nSolids_; i++) { - tRRs().internalField() += RRs_[i]; + RRs += RRs_[i]; } - tRRs().correctBoundaryConditions(); } return tRRs; } template -inline Foam::tmp +inline const Foam::DimensionedField& Foam::ODESolidChemistryModel::RR ( const label i ) const { notImplemented("ODESolidChemistryModel::RR(const label)"); - return (Foam::volScalarField::null()); + return (DimensionedField::null()); } diff --git a/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModel.H b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModel.H index 9114f046ff..d9580162ef 100644 --- a/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModel.H +++ b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModel.H @@ -124,16 +124,22 @@ public: inline const solidReactionThermo& solid() const; //- Return total gases mass source term [kg/m3/s] - virtual tmp RRg() const = 0; + virtual tmp > RRg() const = 0; //- Return total solids mass source term [kg/m3/s] - virtual tmp RRs() const = 0; + virtual tmp > RRs() const = 0; //- Return chemical source terms for solids [kg/m3/s] - virtual tmp RRs(const label i) const = 0; + virtual const DimensionedField& RRs + ( + const label i + ) const = 0; //- Return chemical source terms for gases [kg/m3/s] - virtual tmp RRg(const label i) const = 0; + virtual const DimensionedField& RRg + ( + const label i + ) const = 0; //- Return sensible enthalpy for gas i [J/Kg] virtual tmp gasHs From 3821ee560adcd98ea44b12a10047a3dcd429afa7 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 14 Aug 2012 14:27:10 +0100 Subject: [PATCH 06/34] ENH: Tutorial input dictionary updates --- .../fireFoam/les/smallPoolFire2D/constant/combustionProperties | 3 ++- .../fireFoam/les/smallPoolFire3D/constant/combustionProperties | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/combustionProperties b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/combustionProperties index 9973e9ad7b..1576592b91 100644 --- a/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/combustionProperties +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/combustionProperties @@ -23,7 +23,8 @@ active true; infinitelyFastChemistryCoeffs { - C 5.0; + semiImplicit no; + C 5.0; } FSDCoeffs diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire3D/constant/combustionProperties b/tutorials/combustion/fireFoam/les/smallPoolFire3D/constant/combustionProperties index cfa2cd8f28..689dc54c62 100644 --- a/tutorials/combustion/fireFoam/les/smallPoolFire3D/constant/combustionProperties +++ b/tutorials/combustion/fireFoam/les/smallPoolFire3D/constant/combustionProperties @@ -22,6 +22,7 @@ active on; infinitelyFastChemistryCoeffs { + semiImplicit no; C 5.0; } From 0dae57fb58c612978a96160bf845af9f7b511c1e Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 14 Aug 2012 15:07:07 +0100 Subject: [PATCH 07/34] ENH: Removed unnecessary mapping for chemistry models since change to DimensionedFields --- .../ODEChemistryModel/ODEChemistryModel.C | 61 +++++-------- .../basicChemistryModel/basicChemistryModel.C | 6 +- .../ODESolidChemistryModel.C | 89 +++++++------------ 3 files changed, 56 insertions(+), 100 deletions(-) diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.C b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.C index 882aeff0a0..522afe5161 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.C @@ -699,6 +699,11 @@ Foam::label Foam::ODEChemistryModel::nEqns() const template void Foam::ODEChemistryModel::calculate() { + if (!this->chemistry_) + { + return; + } + const volScalarField rho ( IOobject @@ -713,36 +718,24 @@ void Foam::ODEChemistryModel::calculate() this->thermo().rho() ); - if (this->mesh().changing()) + forAll(rho, celli) { + const scalar rhoi = rho[celli]; + const scalar Ti = this->thermo().T()[celli]; + const scalar pi = this->thermo().p()[celli]; + + scalarField c(nSpecie_, 0.0); for (label i=0; ichemistry_) - { - forAll(rho, celli) + const scalarField dcdt(omega(c, Ti, pi)); + + for (label i=0; ithermo().T()[celli]; - const scalar pi = this->thermo().p()[celli]; - - scalarField c(nSpecie_, 0.0); - for (label i=0; i::solve scalar deltaTMin = GREAT; + if (!this->chemistry_) + { + return deltaTMin; + } + const volScalarField rho ( IOobject @@ -773,21 +771,6 @@ Foam::scalar Foam::ODEChemistryModel::solve this->thermo().rho() ); - if (this->mesh().changing()) - { - for (label i = 0; i < nSpecie_; i++) - { - RR_[i].setSize(this->mesh().nCells()); - RR_[i].field() = 0.0; - } - } - - if (!this->chemistry_) - { - return deltaTMin; - } - - tmp thc = this->thermo().hc(); const scalarField& hc = thc(); diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.C b/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.C index 43b876fbd6..1182c22b92 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.C @@ -38,11 +38,7 @@ namespace Foam void Foam::basicChemistryModel::correct() { - if (mesh_.changing()) - { - deltaTChem_.setSize(mesh_.nCells()); - deltaTChem_ = deltaTChemIni_; - } + // do nothing } diff --git a/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModel.C b/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModel.C index 54097f267a..23ad0e62a0 100644 --- a/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModel.C +++ b/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModel.C @@ -548,9 +548,12 @@ ODESolidChemistryModel::nEqns() const template -void Foam::ODESolidChemistryModel:: -calculate() +void Foam::ODESolidChemistryModel::calculate() { + if (!this->chemistry_) + { + return; + } const volScalarField rho ( @@ -566,18 +569,6 @@ calculate() this->solid().rho() ); - if (this->mesh().changing()) - { - forAll(RRs_, i) - { - RRs_[i].setSize(rho.size()); - } - forAll(RRg_, i) - { - RRg_[i].setSize(rho.size()); - } - } - forAll(RRs_, i) { RRs_[i].field() = 0.0; @@ -587,37 +578,34 @@ calculate() RRg_[i].field() = 0.0; } - if (this->chemistry_) + forAll(rho, celli) { - forAll(rho, celli) + cellCounter_ = celli; + + const scalar delta = this->mesh().V()[celli]; + + if (reactingCells_[celli]) { - cellCounter_ = celli; + scalar rhoi = rho[celli]; + scalar Ti = this->solid().T()[celli]; + scalar pi = this->solid().p()[celli]; - const scalar delta = this->mesh().V()[celli]; - - if (reactingCells_[celli]) + scalarField c(nSpecie_, 0.0); + for (label i=0; isolid().T()[celli]; - scalar pi = this->solid().p()[celli]; + c[i] = rhoi*Ys_[i][celli]*delta; + } - scalarField c(nSpecie_, 0.0); - for (label i=0; i::solve const scalar deltaT ) { + scalar deltaTMin = GREAT; + + if (!this->chemistry_) + { + return deltaTMin; + } + const volScalarField rho ( IOobject @@ -646,18 +641,6 @@ Foam::ODESolidChemistryModel::solve this->solid().rho() ); - if (this->mesh().changing()) - { - forAll(RRs_, i) - { - RRs_[i].setSize(rho.size()); - } - forAll(RRg_, i) - { - RRg_[i].setSize(rho.size()); - } - } - forAll(RRs_, i) { RRs_[i].field() = 0.0; @@ -667,12 +650,6 @@ Foam::ODESolidChemistryModel::solve RRg_[i].field() = 0.0; } - if (!this->chemistry_) - { - return GREAT; - } - - scalar deltaTMin = GREAT; forAll(rho, celli) { From 2d419cc7df6bd27cba48fdcbd8a00deb9192fcc2 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 15 Aug 2012 12:57:55 +0100 Subject: [PATCH 08/34] BUG: Corrected mechanical energy in pEqn of compressibleTwoPhaseEulerFoam - mantis #624 --- .../solvers/multiphase/compressibleTwoPhaseEulerFoam/pEqn.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/pEqn.H b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/pEqn.H index 926abe2a09..d5a5d20631 100644 --- a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/pEqn.H +++ b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/pEqn.H @@ -178,7 +178,7 @@ rho2 = rho20 + psi2*p; K1 = 0.5*magSqr(U1); - K2 = 0.5*magSqr(U1); + K2 = 0.5*magSqr(U2); dpdt = fvc::ddt(p); } From 9162ade598578506014389b6df67fe605e0ddeaa Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 16 Aug 2012 09:14:03 +0100 Subject: [PATCH 09/34] BUG: missing link option to incompressibleRASModels to enable wall function selection - mantis #627 --- applications/solvers/multiphase/multiphaseEulerFoam/Make/options | 1 + 1 file changed, 1 insertion(+) diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/Make/options b/applications/solvers/multiphase/multiphaseEulerFoam/Make/options index 5799557cc9..7cd8f48ee4 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/Make/options +++ b/applications/solvers/multiphase/multiphaseEulerFoam/Make/options @@ -20,4 +20,5 @@ EXE_LIBS = \ -lincompressibleTransportModels \ -lcompressibleMultiphaseEulerianInterfacialModels \ -lincompressibleLESModels \ + -lincompressibleRASModels \ -lfiniteVolume From 9bb7fad6aa1e2d20ab2ee91d6095422bacb3cd63 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 17 Aug 2012 10:29:29 +0100 Subject: [PATCH 10/34] COMP: moveDynamicMesh: add vtk writing libraries --- .../utilities/mesh/manipulation/moveDynamicMesh/Make/options | 2 ++ 1 file changed, 2 insertions(+) diff --git a/applications/utilities/mesh/manipulation/moveDynamicMesh/Make/options b/applications/utilities/mesh/manipulation/moveDynamicMesh/Make/options index 36fba156e5..f7e149613f 100644 --- a/applications/utilities/mesh/manipulation/moveDynamicMesh/Make/options +++ b/applications/utilities/mesh/manipulation/moveDynamicMesh/Make/options @@ -1,9 +1,11 @@ EXE_INC = \ -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude EXE_LIBS = \ -ldynamicFvMesh \ -lmeshTools \ + -lsampling \ -ldynamicMesh From 831bcdc6b926abf90459c01780e650ec83f41f01 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 17 Aug 2012 12:30:55 +0100 Subject: [PATCH 11/34] STYLE: scripts: removed trailing spaces --- .../chemFoam/nc7h16/validation/createGraph | 4 ++-- tutorials/mesh/cvMesh/blob/system/cvMeshDict | 2 +- tutorials/mesh/cvMesh/simpleShapes/system/cvMeshDict | 2 +- tutorials/mesh/snappyHexMesh/Allrun | 12 ++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) mode change 100755 => 100644 tutorials/combustion/chemFoam/nc7h16/validation/createGraph diff --git a/tutorials/combustion/chemFoam/nc7h16/validation/createGraph b/tutorials/combustion/chemFoam/nc7h16/validation/createGraph old mode 100755 new mode 100644 index 634beebec7..2302a2fe42 --- a/tutorials/combustion/chemFoam/nc7h16/validation/createGraph +++ b/tutorials/combustion/chemFoam/nc7h16/validation/createGraph @@ -11,10 +11,10 @@ gnuplot< Date: Fri, 17 Aug 2012 16:04:37 +0100 Subject: [PATCH 12/34] BUG: applyBoundaryLayer: consistent boundary values --- .../preProcessing/applyBoundaryLayer/applyBoundaryLayer.C | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C b/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C index 7ed970aff4..828ba5d9c7 100644 --- a/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C +++ b/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -93,6 +93,7 @@ int main(int argc, char *argv[]) U[celli] *= ::pow(y[celli]/yblv, (1.0/7.0)); } } + U.correctBoundaryConditions(); Info<< "Writing U\n" << endl; U.write(); From f29916e208707020be83101ace16e8ed9fa419f6 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 20 Aug 2012 10:15:14 +0100 Subject: [PATCH 13/34] STYLE: corrected typos in header file comments --- .../pyrolysisModels/pyrolysisModel/pyrolysisModel.H | 4 ++-- src/regionModels/regionModel/regionModel/regionModel.H | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.H b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.H index 7e4d0f4cc6..57d8caa3c4 100644 --- a/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.H +++ b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -161,7 +161,7 @@ public: // Selectors - //- Return a reference to the selected pyrolysis film model + //- Return a reference to the selected pyrolysis model static autoPtr New(const fvMesh& mesh); //- Return a reference to a named selected pyrolysis model diff --git a/src/regionModels/regionModel/regionModel/regionModel.H b/src/regionModels/regionModel/regionModel/regionModel.H index b65b3a23c7..6fbad3d372 100644 --- a/src/regionModels/regionModel/regionModel/regionModel.H +++ b/src/regionModels/regionModel/regionModel/regionModel.H @@ -262,7 +262,7 @@ public: //- Evolve the region virtual void evolveRegion(); - //- Evolve the film + //- Evolve the region virtual void evolve(); From 97d133bcf402e89dfc9861ff9d17111771232d6f Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 20 Aug 2012 10:19:14 +0100 Subject: [PATCH 14/34] ENH: wallHeatFlux: generalise for solids --- .../wall/wallHeatFlux/Make/options | 9 ++-- .../wall/wallHeatFlux/createFields.H | 49 ++++++++++++------- .../wall/wallHeatFlux/wallHeatFlux.C | 12 ++++- .../solidThermo/makeSolidThermo.H | 7 +++ 4 files changed, 54 insertions(+), 23 deletions(-) diff --git a/applications/utilities/postProcessing/wall/wallHeatFlux/Make/options b/applications/utilities/postProcessing/wall/wallHeatFlux/Make/options index 4d244f56ba..52ab08bdcc 100644 --- a/applications/utilities/postProcessing/wall/wallHeatFlux/Make/options +++ b/applications/utilities/postProcessing/wall/wallHeatFlux/Make/options @@ -1,15 +1,18 @@ EXE_INC = \ -I$(LIB_SRC)/turbulenceModels \ - -I$(LIB_SRC)/turbulenceModels/compressible/RAS/RASModel \ + -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basicSolidThermo/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude EXE_LIBS = \ - -lcompressibleRASModels \ + -lcompressibleTurbulenceModel \ -lreactionThermophysicalModels \ -lfiniteVolume \ -lgenericPatchFields \ -lspecie \ - -lbasicThermophysicalModels + -lsolid \ + -lbasicThermophysicalModels \ + -lbasicSolidThermo diff --git a/applications/utilities/postProcessing/wall/wallHeatFlux/createFields.H b/applications/utilities/postProcessing/wall/wallHeatFlux/createFields.H index 4461a3aa55..f1096d657e 100644 --- a/applications/utilities/postProcessing/wall/wallHeatFlux/createFields.H +++ b/applications/utilities/postProcessing/wall/wallHeatFlux/createFields.H @@ -5,6 +5,7 @@ autoPtr thermo const volScalarField& h = thermo->he(); +// Register copy of thermo density volScalarField rho ( IOobject @@ -16,28 +17,40 @@ volScalarField rho thermo->rho() ); -volVectorField U -( - IOobject +// Construct turbulence model (if fluid) +autoPtr UPtr; +autoPtr phiPtr; +autoPtr turbulence; + +if (!isA(thermo())) +{ + UPtr.reset ( - "U", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh -); + new volVectorField + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ) + ); + const volVectorField& U = UPtr(); -#include "compressibleCreatePhi.H" + #include "compressibleCreatePhi.H" + // Copy phi to autoPtr. Rename to make sure copy is now registered as 'phi'. + phi.rename("phiFluid"); + phiPtr.reset(new surfaceScalarField("phi", phi)); -autoPtr RASModel -( - compressible::RASModel::New + turbulence = compressible::turbulenceModel::New ( rho, U, - phi, + phiPtr(), thermo() - ) -); + ); +} diff --git a/applications/utilities/postProcessing/wall/wallHeatFlux/wallHeatFlux.C b/applications/utilities/postProcessing/wall/wallHeatFlux/wallHeatFlux.C index 18a0dbf6d4..137c4c0cfb 100644 --- a/applications/utilities/postProcessing/wall/wallHeatFlux/wallHeatFlux.C +++ b/applications/utilities/postProcessing/wall/wallHeatFlux/wallHeatFlux.C @@ -32,7 +32,8 @@ Description \*---------------------------------------------------------------------------*/ #include "fvCFD.H" -#include "RASModel.H" +#include "turbulenceModel.H" +#include "solidThermo.H" #include "wallFvPatch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -56,7 +57,14 @@ int main(int argc, char *argv[]) surfaceScalarField heatFlux ( - fvc::interpolate(RASModel->alphaEff())*fvc::snGrad(h) + fvc::interpolate + ( + ( + turbulence.valid() + ? turbulence->alphaEff()() + : thermo->alpha() + ) + )*fvc::snGrad(h) ); const surfaceScalarField::GeometricBoundaryField& patchHeatFlux = diff --git a/src/thermophysicalModels/basicSolidThermo/solidThermo/makeSolidThermo.H b/src/thermophysicalModels/basicSolidThermo/solidThermo/makeSolidThermo.H index c6fed868b5..4a911e8c0f 100644 --- a/src/thermophysicalModels/basicSolidThermo/solidThermo/makeSolidThermo.H +++ b/src/thermophysicalModels/basicSolidThermo/solidThermo/makeSolidThermo.H @@ -33,6 +33,7 @@ Description #define makesolidThermo_H #include "addToRunTimeSelectionTable.H" +#include "basicThermo.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -127,6 +128,12 @@ addToRunTimeSelectionTable \ BaseThermo, \ Cthermo##Mixture##Transport##Radiation##Type##Thermo##Rho##BaseThermo, \ mesh \ +); \ +addToRunTimeSelectionTable \ +( \ + basicThermo, \ + Cthermo##Mixture##Transport##Radiation##Type##Thermo##Rho##BaseThermo, \ + fvMesh \ ); \ \ addToRunTimeSelectionTable \ From 0b97b9aeafd98256baf231e7ccd53d80f08c440c Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 20 Aug 2012 11:21:17 +0100 Subject: [PATCH 15/34] ENH: checkMesh: check all points on coupled boundaries. --- .../manipulation/checkMesh/checkGeometry.C | 127 +++++++++++++++--- 1 file changed, 108 insertions(+), 19 deletions(-) diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C index 443576601d..e987f2ac28 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C @@ -262,6 +262,74 @@ bool Foam::checkWedges } +namespace Foam +{ + //- Default transformation behaviour for position + class transformPositionList + { + public: + + //- Transform patch-based field + void operator() + ( + const coupledPolyPatch& cpp, + List& pts + ) const + { + // Each element of pts is all the points in the face. Convert into + // lists of size cpp to transform. + + List newPts(pts.size()); + forAll(pts, faceI) + { + newPts[faceI].setSize(pts.size()); + } + + label index = 0; + while (true) + { + label n = 0; + + // Extract for every face the i'th position + pointField ptsAtIndex(pts.size(), vector::zero); + forAll(cpp, faceI) + { + const pointField& facePts = pts[faceI]; + if (facePts.size() > index) + { + ptsAtIndex[faceI] = facePts[index]; + n++; + } + } + + if (n == 0) + { + break; + } + + // Now ptsAtIndex will have for every face either zero or + // the position of the i'th vertex. Transform. + cpp.transformPosition(ptsAtIndex); + + // Extract back from ptsAtIndex into newPts + forAll(cpp, faceI) + { + pointField& facePts = newPts[faceI]; + if (facePts.size() > index) + { + facePts[index] = ptsAtIndex[faceI]; + } + } + + index++; + } + + pts.transfer(newPts); + } + }; +} + + bool Foam::checkCoupledPoints ( const polyMesh& mesh, @@ -274,7 +342,8 @@ bool Foam::checkCoupledPoints const polyBoundaryMesh& patches = mesh.boundaryMesh(); // Zero'th point on coupled faces - pointField nbrZeroPoint(fcs.size()-mesh.nInternalFaces(), vector::max); + //pointField nbrZeroPoint(fcs.size()-mesh.nInternalFaces(), vector::max); + List nbrPoints(fcs.size()-mesh.nInternalFaces()); // Exchange zero point forAll(patches, patchI) @@ -289,17 +358,28 @@ bool Foam::checkCoupledPoints forAll(cpp, i) { label bFaceI = cpp.start()+i-mesh.nInternalFaces(); - const point& p0 = p[cpp[i][0]]; - nbrZeroPoint[bFaceI] = p0; + const face& f = cpp[i]; + nbrPoints[bFaceI].setSize(f.size()); + forAll(f, fp) + { + const point& p0 = p[f[fp]]; + nbrPoints[bFaceI][fp] = p0; + } } } } - syncTools::swapBoundaryFacePositions(mesh, nbrZeroPoint); + syncTools::syncBoundaryFaceList + ( + mesh, + nbrPoints, + eqOp(), + transformPositionList() + ); // Compare to local ones. Use same tolerance as for matching label nErrorFaces = 0; scalar avgMismatch = 0; - label nCoupledFaces = 0; + label nCoupledPoints = 0; forAll(patches, patchI) { @@ -326,20 +406,28 @@ bool Foam::checkCoupledPoints forAll(cpp, i) { label bFaceI = cpp.start()+i-mesh.nInternalFaces(); - const point& p0 = p[cpp[i][0]]; + const face& f = cpp[i]; - scalar d = mag(p0 - nbrZeroPoint[bFaceI]); - - if (d > smallDist[i]) + label fp = 0; + forAll(f, j) { - if (setPtr) + const point& p0 = p[f[fp]]; + scalar d = mag(p0 - nbrPoints[bFaceI][j]); + + if (d > smallDist[i]) { - setPtr->insert(cpp.start()+i); + if (setPtr) + { + setPtr->insert(cpp.start()+i); + } + nErrorFaces++; + break; } - nErrorFaces++; + avgMismatch += d; + nCoupledPoints++; + + fp = f.rcIndex(fp); } - avgMismatch += d; - nCoupledFaces++; } } } @@ -347,11 +435,11 @@ bool Foam::checkCoupledPoints reduce(nErrorFaces, sumOp