From 4c9dc30ed425124346b4972e64b6ad81be052a4d Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 18 May 2014 21:17:49 +0100 Subject: [PATCH 1/5] flowRateInletVelocity: removed unused function --- .../flowRateInletVelocityFvPatchVectorField.C | 34 +------------------ .../flowRateInletVelocityFvPatchVectorField.H | 8 ++--- 2 files changed, 3 insertions(+), 39 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C index e05c34aa..b5948bed 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -145,38 +145,6 @@ flowRateInletVelocityFvPatchVectorField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs -( - const scalar uniformRho -) -{ - if (updated()) - { - return; - } - - const scalar t = db().time().timeOutputValue(); - - // a simpler way of doing this would be nice - const scalar avgU = -flowRate_->value(t)/gSum(patch().magSf()); - - tmp n = patch().nf(); - - if (volumetric_ || rhoName_ == "none") - { - // volumetric flow-rate - operator==(n*avgU); - } - else - { - // mass flow-rate - operator==(n*avgU/uniformRho); - } - - fixedValueFvPatchVectorField::updateCoeffs(); -} - - void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs() { if (updated()) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H index 80512611..f8e8f491 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -71,7 +71,7 @@ Description rhoInlet 1.0; } \endverbatim - + The \c flowRate entry is a \c DataEntry type, meaning that it can be specified as constant, a polynomial fuction of time, and ... @@ -195,10 +195,6 @@ public: // Member functions - //- Update the coefficients associated with the patch field given - // uniform density field - void updateCoeffs(const scalar uniformRho); - //- Update the coefficients associated with the patch field virtual void updateCoeffs(); From 08cff2ac41cf020f6eafd5e0d41dcf103d93a780 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 18 May 2014 21:18:30 +0100 Subject: [PATCH 2/5] fvMeshGeometry: Dump core if phi() is called for a non-moving mesh to help trace problem --- src/finiteVolume/fvMesh/fvMeshGeometry.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/finiteVolume/fvMesh/fvMeshGeometry.C b/src/finiteVolume/fvMesh/fvMeshGeometry.C index 422ca761..3c61706f 100644 --- a/src/finiteVolume/fvMesh/fvMeshGeometry.C +++ b/src/finiteVolume/fvMesh/fvMeshGeometry.C @@ -441,7 +441,7 @@ const surfaceScalarField& fvMesh::phi() const { FatalErrorIn("fvMesh::phi()") << "mesh flux field does not exist, is the mesh actually moving?" - << exit(FatalError); + << abort(FatalError); } // Set zero current time @@ -461,7 +461,7 @@ surfaceScalarField& fvMesh::setPhi() { FatalErrorIn("fvMesh::setPhi()") << "mesh flux field does not exist, is the mesh actually moving?" - << exit(FatalError); + << abort(FatalError); } return *phiPtr_; From 86498d3dbe17119aab90b007600292c7922677f8 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 18 May 2014 21:19:26 +0100 Subject: [PATCH 3/5] rhoPimpleDyMFoam/correctPhi.H: Add compressibility term in pcorr equation --- .../rhoPimpleFoam/rhoPimpleDyMFoam/correctPhi.H | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/correctPhi.H b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/correctPhi.H index e916b7a5..c7045732 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/correctPhi.H +++ b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/correctPhi.H @@ -46,14 +46,18 @@ if (mesh.changing()) { fvScalarMatrix pcorrEqn ( - fvm::laplacian(rAUf, pcorr) == fvc::div(phi) - divrhoU + fvm::ddt(psi, pcorr) + + fvc::div(phi) + - fvm::laplacian(rAUf, pcorr) + == + divrhoU ); pcorrEqn.solve(); if (pimple.finalNonOrthogonalIter()) { - phi -= pcorrEqn.flux(); + phi += pcorrEqn.flux(); } } } From 30947d15717ad74f6e278ae02fe0fac294ef4f99 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 18 May 2014 21:19:58 +0100 Subject: [PATCH 4/5] wallFunctions: Handle moving meshes --- .../epsilonWallFunctionFvPatchScalarField.C | 10 +++++----- .../omegaWallFunctionFvPatchScalarField.C | 10 +++++----- .../epsilonWallFunctionFvPatchScalarField.C | 10 +++++----- .../omegaWallFunctionFvPatchScalarField.C | 10 +++++----- .../epsilonWallFunctionFvPatchScalarField.C | 10 +++++----- .../omegaWallFunctionFvPatchScalarField.C | 10 +++++----- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C index 226d6ab3..2513312e 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C @@ -96,11 +96,6 @@ void epsilonWallFunctionFvPatchScalarField::setMaster() void epsilonWallFunctionFvPatchScalarField::createAveragingWeights() { - if (initialised_) - { - return; - } - const volScalarField& epsilon = static_cast(this->dimensionedInternalField()); @@ -108,6 +103,11 @@ void epsilonWallFunctionFvPatchScalarField::createAveragingWeights() const fvMesh& mesh = epsilon.mesh(); + if (initialised_ && !mesh.changing()) + { + return; + } + volScalarField weights ( IOobject diff --git a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C index 375d4c6c..c8f8b93f 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C @@ -98,11 +98,6 @@ void omegaWallFunctionFvPatchScalarField::setMaster() void omegaWallFunctionFvPatchScalarField::createAveragingWeights() { - if (initialised_) - { - return; - } - const volScalarField& omega = static_cast(this->dimensionedInternalField()); @@ -110,6 +105,11 @@ void omegaWallFunctionFvPatchScalarField::createAveragingWeights() const fvMesh& mesh = omega.mesh(); + if (initialised_ && !mesh.changing()) + { + return; + } + volScalarField weights ( IOobject diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C index b0899d12..1bf17b6f 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C @@ -98,11 +98,6 @@ void epsilonWallFunctionFvPatchScalarField::setMaster() void epsilonWallFunctionFvPatchScalarField::createAveragingWeights() { - if (initialised_) - { - return; - } - const volScalarField& epsilon = static_cast(this->dimensionedInternalField()); @@ -110,6 +105,11 @@ void epsilonWallFunctionFvPatchScalarField::createAveragingWeights() const fvMesh& mesh = epsilon.mesh(); + if (initialised_ && !mesh.changing()) + { + return; + } + volScalarField weights ( IOobject diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C index 4fa24330..89d4782a 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C @@ -100,11 +100,6 @@ void omegaWallFunctionFvPatchScalarField::setMaster() void omegaWallFunctionFvPatchScalarField::createAveragingWeights() { - if (initialised_) - { - return; - } - const volScalarField& omega = static_cast(this->dimensionedInternalField()); @@ -112,6 +107,11 @@ void omegaWallFunctionFvPatchScalarField::createAveragingWeights() const fvMesh& mesh = omega.mesh(); + if (initialised_ && !mesh.changing()) + { + return; + } + volScalarField weights ( IOobject diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C index 9a8841f7..2437271e 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C @@ -98,11 +98,6 @@ void epsilonWallFunctionFvPatchScalarField::setMaster() void epsilonWallFunctionFvPatchScalarField::createAveragingWeights() { - if (initialised_) - { - return; - } - const volScalarField& epsilon = static_cast(this->dimensionedInternalField()); @@ -110,6 +105,11 @@ void epsilonWallFunctionFvPatchScalarField::createAveragingWeights() const fvMesh& mesh = epsilon.mesh(); + if (initialised_ && !mesh.changing()) + { + return; + } + volScalarField weights ( IOobject diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C index 066f03a0..ebc195ec 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C @@ -100,11 +100,6 @@ void omegaWallFunctionFvPatchScalarField::setMaster() void omegaWallFunctionFvPatchScalarField::createAveragingWeights() { - if (initialised_) - { - return; - } - const volScalarField& omega = static_cast(this->dimensionedInternalField()); @@ -112,6 +107,11 @@ void omegaWallFunctionFvPatchScalarField::createAveragingWeights() const fvMesh& mesh = omega.mesh(); + if (initialised_ && !mesh.changing()) + { + return; + } + volScalarField weights ( IOobject From 137bb2e4a64cf2f1a15aaea331be149b0524135e Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 18 May 2014 21:31:44 +0100 Subject: [PATCH 5/5] rhoPimpleDyMFoam/pEqn: Filter use of meshPhi --- .../compressible/rhoPimpleFoam/rhoPimpleDyMFoam/pEqn.H | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/pEqn.H b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/pEqn.H index e9fab27b..5270e3d8 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/pEqn.H +++ b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/pEqn.H @@ -112,5 +112,10 @@ K = 0.5*magSqr(U); if (thermo.dpdt()) { - dpdt = fvc::ddt(p) - fvc::div(fvc::meshPhi(rho, U), p); + dpdt = fvc::ddt(p); + + if (mesh.moving()) + { + dpdt -= fvc::div(fvc::meshPhi(rho, U), p); + } }