From 2fcb6d506b52c31e38667829813a6a2183cb50a9 Mon Sep 17 00:00:00 2001 From: sergio Date: Thu, 11 Mar 2010 14:29:33 +0000 Subject: [PATCH 01/10] BUG: option file in combustionModel links general thermo --- .../solvers/combustion/fireFoam/combustionModels/Make/options | 2 -- 1 file changed, 2 deletions(-) diff --git a/applications/solvers/combustion/fireFoam/combustionModels/Make/options b/applications/solvers/combustion/fireFoam/combustionModels/Make/options index 42f59c8e17..3f557113c4 100644 --- a/applications/solvers/combustion/fireFoam/combustionModels/Make/options +++ b/applications/solvers/combustion/fireFoam/combustionModels/Make/options @@ -1,6 +1,4 @@ EXE_INC = \ - -I../sensibleEnthalpyCombustionThermophysicalModels/basic/lnInclude \ - -I../sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ From 0455e4a0134bbb770fbb5979ec944312451963f8 Mon Sep 17 00:00:00 2001 From: sergio Date: Thu, 11 Mar 2010 14:33:19 +0000 Subject: [PATCH 02/10] BUG: volScalarField G in registry named RANSModel::G --- .../PDRFoam/PDRModels/turbulence/PDRkEpsilon/PDRkEpsilon.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/solvers/combustion/PDRFoam/PDRModels/turbulence/PDRkEpsilon/PDRkEpsilon.C b/applications/solvers/combustion/PDRFoam/PDRModels/turbulence/PDRkEpsilon/PDRkEpsilon.C index aa9fd58b70..fdddddfbfe 100644 --- a/applications/solvers/combustion/PDRFoam/PDRModels/turbulence/PDRkEpsilon/PDRkEpsilon.C +++ b/applications/solvers/combustion/PDRFoam/PDRModels/turbulence/PDRkEpsilon/PDRkEpsilon.C @@ -270,7 +270,7 @@ void PDRkEpsilon::correct() } tmp tgradU = fvc::grad(U_); - volScalarField G = 2*mut_*(tgradU() && dev(symm(tgradU()))); + volScalarField G("RASModel::G", mut_*(tgradU() && dev(twoSymm(tgradU())))); tgradU.clear(); // Update espsilon and G at the wall From a04996d0f6a83cb3db61b101f796ca8628bf1895 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 11 Mar 2010 14:49:18 +0000 Subject: [PATCH 03/10] BUG: removed old (redundant) link libraries from options file --- .../solvers/combustion/fireFoam/combustionModels/Make/options | 2 -- 1 file changed, 2 deletions(-) diff --git a/applications/solvers/combustion/fireFoam/combustionModels/Make/options b/applications/solvers/combustion/fireFoam/combustionModels/Make/options index 42f59c8e17..3f557113c4 100644 --- a/applications/solvers/combustion/fireFoam/combustionModels/Make/options +++ b/applications/solvers/combustion/fireFoam/combustionModels/Make/options @@ -1,6 +1,4 @@ EXE_INC = \ - -I../sensibleEnthalpyCombustionThermophysicalModels/basic/lnInclude \ - -I../sensibleEnthalpyCombustionThermophysicalModels/reactionThermo/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ From 5e8d714dff768ea0dfeaadd90b4ef1d7cfbd652f Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 15 Mar 2010 17:00:02 +0000 Subject: [PATCH 04/10] Removed superfluous interpolation scheme. --- .../limitedSchemes/MC/MC.C | 38 -------- .../limitedSchemes/MC/MC.H | 94 ------------------- 2 files changed, 132 deletions(-) delete mode 100644 src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/MC/MC.C delete mode 100644 src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/MC/MC.H diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/MC/MC.C b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/MC/MC.C deleted file mode 100644 index 901d524a8c..0000000000 --- a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/MC/MC.C +++ /dev/null @@ -1,38 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -\*---------------------------------------------------------------------------*/ - -#include "LimitedScheme.H" -#include "MC.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - makeLimitedSurfaceInterpolationScheme(MC, MCLimiter) - makeLimitedVSurfaceInterpolationScheme(MCV, MCLimiter) -} - -// ************************************************************************* // diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/MC/MC.H b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/MC/MC.H deleted file mode 100644 index fa47fe13b7..0000000000 --- a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/MC/MC.H +++ /dev/null @@ -1,94 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Class - Foam::MCLimiter - -Description - Class with limiter function which returns the limiter for the - monotonised centred differencing scheme based on r obtained from - the LimiterFunc class. - - Used in conjunction with the template class LimitedScheme. - -SourceFiles - MC.C - -\*---------------------------------------------------------------------------*/ - -#ifndef MC_H -#define MC_H - -#include "vector.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class MCLimiter Declaration -\*---------------------------------------------------------------------------*/ - -template -class MCLimiter -: - public LimiterFunc -{ - -public: - - MCLimiter(Istream&) - {} - - scalar limiter - ( - const scalar cdWeight, - const scalar faceFlux, - const typename LimiterFunc::phiType& phiP, - const typename LimiterFunc::phiType& phiN, - const typename LimiterFunc::gradPhiType& gradcP, - const typename LimiterFunc::gradPhiType& gradcN, - const vector& d - ) const - { - scalar r = LimiterFunc::r - ( - faceFlux, phiP, phiN, gradcP, gradcN, d - ); - - return max(min(min(2*r, 0.5*(1 + r)), 2), 0); - } -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // From dbe29112e36c6a63e0237e93570ef38d1e585f43 Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 15 Mar 2010 17:02:12 +0000 Subject: [PATCH 05/10] MULES limitation removed: sub-cycling time now supported on morphing meshes Support for cell-volume interpolation during time sub-cycling now provided and used in the MULES VoF solver to allow sub-cycling on morphing meshes. --- src/OpenFOAM/db/Time/Time.C | 16 ++++-- src/OpenFOAM/db/Time/Time.H | 21 ++++++- src/OpenFOAM/db/Time/subCycleTime.C | 9 +-- src/OpenFOAM/db/Time/subCycleTime.H | 1 - .../fvMatrices/solvers/MULES/MULESTemplates.C | 14 +++-- src/finiteVolume/fvMesh/fvMesh.H | 6 ++ src/finiteVolume/fvMesh/fvMeshGeometry.C | 57 +++++++++++++++++++ .../floatingObject/0.org/pointDisplacement | 3 +- .../floatingObject/constant/polyMesh/boundary | 2 +- .../ras/floatingObject/system/controlDict | 8 +-- .../ras/floatingObject/system/fvSolution | 26 ++++----- 11 files changed, 125 insertions(+), 38 deletions(-) diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index f8b3fff3e9..de487f340e 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -625,21 +625,25 @@ void Foam::Time::setDeltaT(const scalar deltaT) Foam::TimeState Foam::Time::subCycle(const label nSubCycles) { subCycling_ = true; + prevTimeState_.set(new TimeState(*this)); - TimeState ts = *this; setTime(*this - deltaT(), (timeIndex() - 1)*nSubCycles); deltaT_ /= nSubCycles; deltaT0_ /= nSubCycles; deltaTSave_ = deltaT0_; - return ts; + return prevTimeState(); } -void Foam::Time::endSubCycle(const TimeState& ts) +void Foam::Time::endSubCycle() { - subCycling_ = false; - TimeState::operator=(ts); + if (subCycling_) + { + subCycling_ = false; + TimeState::operator=(prevTimeState()); + prevTimeState_.clear(); + } } diff --git a/src/OpenFOAM/db/Time/Time.H b/src/OpenFOAM/db/Time/Time.H index 9f935091d8..694013ac17 100644 --- a/src/OpenFOAM/db/Time/Time.H +++ b/src/OpenFOAM/db/Time/Time.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -127,6 +127,9 @@ protected: //- Is the time currently being sub-cycled? bool subCycling_; + //- If time is being sub-cycled this is the previous TimeState + autoPtr prevTimeState_; + //- Time directory name format static fmtflags format_; @@ -347,6 +350,18 @@ public: return functionObjects_; } + //- Return true if time currently being sub-cycled, otherwise false + bool subCycling() const + { + return subCycling_; + } + + //- Return previous TimeState if time is being sub-cycled + const TimeState& prevTimeState() const + { + return prevTimeState_(); + } + // Check @@ -427,8 +442,8 @@ public: //- Set time to sub-cycle for the given number of steps virtual TimeState subCycle(const label nSubCycles); - //- Reset time after sub-cycling back to given TimeState - virtual void endSubCycle(const TimeState&); + //- Reset time after sub-cycling back to previous TimeState + virtual void endSubCycle(); //- Return non-const access to the list of function objects functionObjectList& functionObjects() diff --git a/src/OpenFOAM/db/Time/subCycleTime.C b/src/OpenFOAM/db/Time/subCycleTime.C index 344c881f9d..def50ab412 100644 --- a/src/OpenFOAM/db/Time/subCycleTime.C +++ b/src/OpenFOAM/db/Time/subCycleTime.C @@ -32,9 +32,10 @@ Foam::subCycleTime::subCycleTime(Time& t, const label nSubCycles) : time_(t), nSubCycles_(nSubCycles), - subCycleIndex_(0), - initialTimeState_(time_.subCycle(nSubCycles_)) -{} + subCycleIndex_(0) +{ + time_.subCycle(nSubCycles_); +} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // @@ -55,7 +56,7 @@ bool Foam::subCycleTime::end() const void Foam::subCycleTime::endSubCycle() { - time_.endSubCycle(initialTimeState_); + time_.endSubCycle(); } diff --git a/src/OpenFOAM/db/Time/subCycleTime.H b/src/OpenFOAM/db/Time/subCycleTime.H index 01082625fb..22dafe18cf 100644 --- a/src/OpenFOAM/db/Time/subCycleTime.H +++ b/src/OpenFOAM/db/Time/subCycleTime.H @@ -55,7 +55,6 @@ class subCycleTime label nSubCycles_; label subCycleIndex_; - TimeState initialTimeState_; public: diff --git a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C index 3455b37804..bf72983e4a 100644 --- a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C +++ b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,6 +34,7 @@ License #include "fvcSurfaceIntegrate.H" #include "slicedSurfaceFields.H" #include "syncTools.H" + #include "fvm.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -107,7 +108,7 @@ void Foam::MULES::explicitSolve { psiIf = ( - mesh.V0()*rho.oldTime()*psi0/(deltaT*mesh.V()) + mesh.Vsc0()*rho.oldTime()*psi0/(deltaT*mesh.Vsc()) + Su.field() - psiIf )/(rho/deltaT - Sp.field()); @@ -325,7 +326,8 @@ void Foam::MULES::limiter const unallocLabelList& owner = mesh.owner(); const unallocLabelList& neighb = mesh.neighbour(); - const scalarField& V = mesh.V(); + tmp tVsc = mesh.Vsc(); + const scalarField& V = tVsc(); const scalar deltaT = mesh.time().deltaTValue(); const scalarField& phiBDIf = phiBD; @@ -452,14 +454,16 @@ void Foam::MULES::limiter if (mesh.moving()) { + tmp V0 = mesh.Vsc0(); + psiMaxn = V*((rho/deltaT - Sp)*psiMaxn - Su) - - (mesh.V0()/deltaT)*rho.oldTime()*psi0 + - (V0()/deltaT)*rho.oldTime()*psi0 + sumPhiBD; psiMinn = V*(Su - (rho/deltaT - Sp)*psiMinn) - + (mesh.V0()/deltaT)*rho.oldTime()*psi0 + + (V0/deltaT)*rho.oldTime()*psi0 - sumPhiBD; } else diff --git a/src/finiteVolume/fvMesh/fvMesh.H b/src/finiteVolume/fvMesh/fvMesh.H index 64e4d87f3e..8b75da3800 100644 --- a/src/finiteVolume/fvMesh/fvMesh.H +++ b/src/finiteVolume/fvMesh/fvMesh.H @@ -269,6 +269,12 @@ public: //- Return old-old-time cell volumes const DimensionedField& V00() const; + //- Return sub-cycle cell volumes + tmp > Vsc() const; + + //- Return sub-cycl old-time cell volumes + tmp > Vsc0() const; + //- Return cell face area vectors const surfaceVectorField& Sf() const; diff --git a/src/finiteVolume/fvMesh/fvMeshGeometry.C b/src/finiteVolume/fvMesh/fvMeshGeometry.C index 536b21c565..b7d0946f2a 100644 --- a/src/finiteVolume/fvMesh/fvMeshGeometry.C +++ b/src/finiteVolume/fvMesh/fvMeshGeometry.C @@ -285,6 +285,63 @@ const volScalarField::DimensionedInternalField& fvMesh::V00() const } +tmp fvMesh::Vsc() const +{ + if (moving() && time().subCycling()) + { + const TimeState& ts = time(); + const TimeState& ts0 = time().prevTimeState(); + + scalar tFrac = + ( + ts.value() - (ts0.value() - ts0.deltaTValue()) + )/ts0.deltaTValue(); + + if (tFrac < (1 - SMALL)) + { + return V0() + tFrac*(V() - V0()); + } + else + { + return V(); + } + } + else + { + return V(); + } +} + + +tmp fvMesh::Vsc0() const +{ + if (moving() && time().subCycling()) + { + const TimeState& ts = time(); + const TimeState& ts0 = time().prevTimeState(); + + scalar t0Frac = + ( + (ts.value() - ts.deltaTValue()) + - (ts0.value() - ts0.deltaTValue()) + )/ts0.deltaTValue(); + + if (t0Frac > SMALL) + { + return V0() + t0Frac*(V() - V0()); + } + else + { + return V0(); + } + } + else + { + return V0(); + } +} + + const surfaceVectorField& fvMesh::Sf() const { if (!SfPtr_) diff --git a/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/pointDisplacement b/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/pointDisplacement index a994b15b89..c808bc16bc 100644 --- a/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/pointDisplacement +++ b/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/pointDisplacement @@ -37,7 +37,8 @@ boundaryField centreOfMass (0.5 0.5 0.5); momentOfInertia (0.08622222 0.08622222 0.144); mass 9.6; - rhoInf 1; // for forces calculation + rhoInf 1; + report on; value uniform (0 0 0); } } diff --git a/tutorials/multiphase/interDyMFoam/ras/floatingObject/constant/polyMesh/boundary b/tutorials/multiphase/interDyMFoam/ras/floatingObject/constant/polyMesh/boundary index 62fd629b04..1543006b7a 100644 --- a/tutorials/multiphase/interDyMFoam/ras/floatingObject/constant/polyMesh/boundary +++ b/tutorials/multiphase/interDyMFoam/ras/floatingObject/constant/polyMesh/boundary @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.6.x | +| \\ / O peration | Version: dev | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/controlDict b/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/controlDict index 436dca3c27..b58fa81303 100644 --- a/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/controlDict +++ b/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/controlDict @@ -17,7 +17,7 @@ FoamFile application interDyMFoam; -startFrom startTime; +startFrom latestTime; startTime 0; @@ -29,7 +29,7 @@ deltaT 0.01; writeControl adjustableRunTime; -writeInterval 0.025; +writeInterval 0.1; purgeWrite 0; @@ -47,9 +47,9 @@ runTimeModifiable yes; adjustTimeStep yes; -maxCo 0.2; +maxCo 0.5; -maxDeltaT 0.025; +maxDeltaT 0.01; libs ( diff --git a/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/fvSolution b/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/fvSolution index 9edecbae82..55cffd160e 100644 --- a/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/fvSolution +++ b/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/fvSolution @@ -20,7 +20,7 @@ solvers cellDisplacement { solver GAMG; - tolerance 1e-08; + tolerance 1e-5; relTol 0; smoother GaussSeidel; cacheAgglomeration true; @@ -35,7 +35,7 @@ solvers preconditioner { preconditioner GAMG; - tolerance 1e-05; + tolerance 1e-5; relTol 0; smoother DICGaussSeidel; nPreSweeps 0; @@ -55,7 +55,7 @@ solvers p { solver GAMG; - tolerance 1e-08; + tolerance 1e-8; relTol 0.01; smoother DIC; nPreSweeps 0; @@ -73,7 +73,7 @@ solvers preconditioner { preconditioner GAMG; - tolerance 2e-09; + tolerance 1e-8; relTol 0; nVcycles 2; smoother DICGaussSeidel; @@ -86,7 +86,7 @@ solvers mergeLevels 1; } - tolerance 2e-09; + tolerance 1e-8; relTol 0; maxIter 20; } @@ -95,18 +95,18 @@ solvers { solver smoothSolver; smoother GaussSeidel; - tolerance 1e-06; + tolerance 1e-6; relTol 0; nSweeps 1; } - "(k|epsilon|R|nuTilda)" + "(k|epsilon|omega|R|nuTilda)" { - $U; - tolerance 1e-08; + solver PBiCG; + preconditioner DILU; + tolerance 1e-8; relTol 0; } - } PISO @@ -115,14 +115,14 @@ PISO nCorrectors 2; nNonOrthogonalCorrectors 0; nAlphaCorr 1; - nAlphaSubCycles 1; - cAlpha 1.5; + nAlphaSubCycles 3; + cAlpha 1; correctPhi yes; } relaxationFactors { - U 1; + "(U|k|epsilon|omega|R|nuTilda)" 1; } From 5cac2c00d67d916138be7fc96e50afcf408a1477 Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 15 Mar 2010 17:03:04 +0000 Subject: [PATCH 06/10] mhdFoam: General cleanup. --- .../electromagnetics/mhdFoam/createFields.H | 18 +++++++++--------- .../solvers/electromagnetics/mhdFoam/mhdFoam.C | 2 -- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/applications/solvers/electromagnetics/mhdFoam/createFields.H b/applications/solvers/electromagnetics/mhdFoam/createFields.H index 5b346858b6..04e05c032d 100644 --- a/applications/solvers/electromagnetics/mhdFoam/createFields.H +++ b/applications/solvers/electromagnetics/mhdFoam/createFields.H @@ -61,7 +61,7 @@ mesh ); -# include "createPhi.H" + #include "createPhi.H" Info<< "Reading field pB\n" << endl; volScalarField pB @@ -93,15 +93,15 @@ ); -# include "createPhiB.H" + #include "createPhiB.H" -dimensionedScalar DB = 1.0/(mu*sigma); -DB.name() = "DB"; + dimensionedScalar DB = 1.0/(mu*sigma); + DB.name() = "DB"; -dimensionedScalar DBU = 1.0/(2.0*mu*rho); -DBU.name() = "DBU"; + dimensionedScalar DBU = 1.0/(2.0*mu*rho); + DBU.name() = "DBU"; -label pRefCell = 0; -scalar pRefValue = 0.0; -setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + label pRefCell = 0; + scalar pRefValue = 0.0; + setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); diff --git a/applications/solvers/electromagnetics/mhdFoam/mhdFoam.C b/applications/solvers/electromagnetics/mhdFoam/mhdFoam.C index f09b35efc9..3603d04070 100644 --- a/applications/solvers/electromagnetics/mhdFoam/mhdFoam.C +++ b/applications/solvers/electromagnetics/mhdFoam/mhdFoam.C @@ -49,8 +49,6 @@ Description \*---------------------------------------------------------------------------*/ -#include "string.H" -#include "Time.H" #include "fvCFD.H" #include "OSspecific.H" From 3a8cb46beb05fd5be26e751f44898f7e740fd8ad Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 15 Mar 2010 17:03:27 +0000 Subject: [PATCH 07/10] files: Removed MC scheme. --- src/finiteVolume/Make/files | 1 - 1 file changed, 1 deletion(-) diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 622d8bf842..9101558af3 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -242,7 +242,6 @@ $(limitedSchemes)/SuperBee/SuperBee.C $(limitedSchemes)/QUICK/QUICK.C $(limitedSchemes)/MUSCL/MUSCL.C $(limitedSchemes)/UMIST/UMIST.C -$(limitedSchemes)/MC/MC.C $(limitedSchemes)/Phi/Phi.C $(limitedSchemes)/filteredLinear/filteredLinear.C $(limitedSchemes)/filteredLinear2/filteredLinear2.C From 3c1993798aac80a6c1277f7a7d359e8f4c6b57e2 Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 15 Mar 2010 17:04:24 +0000 Subject: [PATCH 08/10] fvMotionSolver: added pointEdgeStructuredWalk.C --- src/fvMotionSolver/Make/files | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fvMotionSolver/Make/files b/src/fvMotionSolver/Make/files index 44046b57ca..87e8e39c25 100644 --- a/src/fvMotionSolver/Make/files +++ b/src/fvMotionSolver/Make/files @@ -2,6 +2,7 @@ fvMotionSolvers/fvMotionSolver/fvMotionSolver.C fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.C fvMotionSolvers/displacement/layeredSolver/displacementLayeredMotionFvMotionSolver.C +fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalk.C fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.C fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C From d83d28733de2c3677be9d55b736871db7eb5fd7a Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 15 Mar 2010 17:06:38 +0000 Subject: [PATCH 09/10] Corrected headers. --- tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/0/U | 2 +- .../multiphase/interDyMFoam/ras/damBreakWithObstacle/0/alpha1 | 2 +- .../ras/damBreakWithObstacle/constant/polyMesh/boundary | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/0/U b/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/0/U index 9af6b12da9..6d3ce2531b 100644 --- a/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/0/U +++ b/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/0/U @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.6 | +| \\ / O peration | Version: dev | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/0/alpha1 b/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/0/alpha1 index 1b460494c0..c6e0907e27 100644 --- a/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/0/alpha1 +++ b/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/0/alpha1 @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.6 | +| \\ / O peration | Version: dev | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/constant/polyMesh/boundary b/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/constant/polyMesh/boundary index 0c26ed3159..8122fa3f3a 100644 --- a/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/constant/polyMesh/boundary +++ b/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/constant/polyMesh/boundary @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.6 | +| \\ / O peration | Version: dev | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ From d35773f4fb6880cda0fc6e150e30d765576c210d Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 15 Mar 2010 17:08:45 +0000 Subject: [PATCH 10/10] New solver: adjointShapeOptimizationFoam Uses adjoint method to block regions of the domain causing total pressure loss, e.g. recirculation zones. pitzDaily tutorial case supplied. --- .../ajointShapeOptimizationFoam/Make/files | 5 + .../ajointShapeOptimizationFoam/Make/options | 11 + .../adjointContinuityErrs.H | 47 ++++ .../adjointOutletPressureFvPatchScalarField.C | 132 ++++++++++ .../adjointOutletPressureFvPatchScalarField.H | 137 +++++++++++ .../adjointOutletVelocityFvPatchVectorField.C | 131 ++++++++++ .../adjointOutletVelocityFvPatchVectorField.H | 131 ++++++++++ .../adjointShapeOptimizationFoam.C | 226 ++++++++++++++++++ .../createFields.H | 105 ++++++++ .../ajointShapeOptimizationFoam/createPhia.H | 57 +++++ .../pitzDaily/0/U | 54 +++++ .../pitzDaily/0/Ua | 56 +++++ .../pitzDaily/0/epsilon | 56 +++++ .../pitzDaily/0/k | 50 ++++ .../pitzDaily/0/nut | 57 +++++ .../pitzDaily/0/p | 50 ++++ .../pitzDaily/0/pa | 50 ++++ .../pitzDaily/constant/RASProperties | 24 ++ .../pitzDaily/constant/polyMesh/blockMeshDict | 153 ++++++++++++ .../pitzDaily/constant/polyMesh/boundary | 57 +++++ .../pitzDaily/constant/transportProperties | 25 ++ .../pitzDaily/system/controlDict | 48 ++++ .../pitzDaily/system/fvSchemes | 76 ++++++ .../pitzDaily/system/fvSolution | 60 +++++ 24 files changed, 1798 insertions(+) create mode 100644 applications/solvers/incompressible/ajointShapeOptimizationFoam/Make/files create mode 100644 applications/solvers/incompressible/ajointShapeOptimizationFoam/Make/options create mode 100644 applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointContinuityErrs.H create mode 100644 applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointOutletPressure/adjointOutletPressureFvPatchScalarField.C create mode 100644 applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointOutletPressure/adjointOutletPressureFvPatchScalarField.H create mode 100644 applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointOutletVelocity/adjointOutletVelocityFvPatchVectorField.C create mode 100644 applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointOutletVelocity/adjointOutletVelocityFvPatchVectorField.H create mode 100644 applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointShapeOptimizationFoam.C create mode 100644 applications/solvers/incompressible/ajointShapeOptimizationFoam/createFields.H create mode 100644 applications/solvers/incompressible/ajointShapeOptimizationFoam/createPhia.H create mode 100644 tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/U create mode 100644 tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/Ua create mode 100644 tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/epsilon create mode 100644 tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/k create mode 100644 tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/nut create mode 100644 tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/p create mode 100644 tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/pa create mode 100644 tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/constant/RASProperties create mode 100644 tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/constant/polyMesh/blockMeshDict create mode 100644 tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/constant/polyMesh/boundary create mode 100644 tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/constant/transportProperties create mode 100644 tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/system/controlDict create mode 100644 tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/system/fvSchemes create mode 100644 tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/system/fvSolution diff --git a/applications/solvers/incompressible/ajointShapeOptimizationFoam/Make/files b/applications/solvers/incompressible/ajointShapeOptimizationFoam/Make/files new file mode 100644 index 0000000000..d42156d410 --- /dev/null +++ b/applications/solvers/incompressible/ajointShapeOptimizationFoam/Make/files @@ -0,0 +1,5 @@ +adjointOutletPressure/adjointOutletPressureFvPatchScalarField.C +adjointOutletVelocity/adjointOutletVelocityFvPatchVectorField.C +adjointShapeOptimizationFoam.C + +EXE = $(FOAM_APPBIN)/adjointShapeOptimizationFoam diff --git a/applications/solvers/incompressible/ajointShapeOptimizationFoam/Make/options b/applications/solvers/incompressible/ajointShapeOptimizationFoam/Make/options new file mode 100644 index 0000000000..1223bdd06f --- /dev/null +++ b/applications/solvers/incompressible/ajointShapeOptimizationFoam/Make/options @@ -0,0 +1,11 @@ +EXE_INC = \ + -I$(LIB_SRC)/turbulenceModels \ + -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +EXE_LIBS = \ + -lincompressibleRASModels \ + -lincompressibleTransportModels \ + -lfiniteVolume diff --git a/applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointContinuityErrs.H b/applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointContinuityErrs.H new file mode 100644 index 0000000000..74ebd457c0 --- /dev/null +++ b/applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointContinuityErrs.H @@ -0,0 +1,47 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Global + continuityErrs + +Description + Calculates and prints the continuity errors. + +\*---------------------------------------------------------------------------*/ + +{ + scalar sumLocalContErr = runTime.deltaT().value()* + mag(fvc::div(phia))().weightedAverage(mesh.V()).value(); + + scalar globalContErr = runTime.deltaT().value()* + fvc::div(phia)().weightedAverage(mesh.V()).value(); + cumulativeContErr += globalContErr; + + Info<< "Adjoint continuity errors : sum local = " << sumLocalContErr + << ", global = " << globalContErr + << ", cumulative = " << cumulativeContErr + << endl; +} + +// ************************************************************************* // diff --git a/applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointOutletPressure/adjointOutletPressureFvPatchScalarField.C b/applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointOutletPressure/adjointOutletPressureFvPatchScalarField.C new file mode 100644 index 0000000000..13debc1786 --- /dev/null +++ b/applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointOutletPressure/adjointOutletPressureFvPatchScalarField.C @@ -0,0 +1,132 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "adjointOutletPressureFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchMapper.H" +#include "volFields.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::adjointOutletPressureFvPatchScalarField:: +adjointOutletPressureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF) +{} + + +Foam::adjointOutletPressureFvPatchScalarField:: +adjointOutletPressureFvPatchScalarField +( + const adjointOutletPressureFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper) +{} + + +Foam::adjointOutletPressureFvPatchScalarField:: +adjointOutletPressureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF) +{ + fvPatchField::operator= + ( + scalarField("value", dict, p.size()) + ); +} + + +Foam::adjointOutletPressureFvPatchScalarField:: +adjointOutletPressureFvPatchScalarField +( + const adjointOutletPressureFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(tppsf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::adjointOutletPressureFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const fvsPatchField& phip = + patch().lookupPatchField("phi"); + + const fvsPatchField& phiap = + patch().lookupPatchField("phia"); + + const fvPatchField& Up = + patch().lookupPatchField("U"); + + const fvPatchField& Uap = + patch().lookupPatchField("Ua"); + + operator==((phiap/patch().magSf() - 1.0)*phip/patch().magSf() + (Up & Uap)); + + fixedValueFvPatchScalarField::updateCoeffs(); +} + + +void Foam::adjointOutletPressureFvPatchScalarField::write(Ostream& os) const +{ + fvPatchScalarField::write(os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + adjointOutletPressureFvPatchScalarField + ); +} + +// ************************************************************************* // diff --git a/applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointOutletPressure/adjointOutletPressureFvPatchScalarField.H b/applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointOutletPressure/adjointOutletPressureFvPatchScalarField.H new file mode 100644 index 0000000000..59514cb67f --- /dev/null +++ b/applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointOutletPressure/adjointOutletPressureFvPatchScalarField.H @@ -0,0 +1,137 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + adjointOutletPressureFvPatchScalarField + +Description + +SourceFiles + adjointOutletPressureFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef adjointOutletPressureFvPatchScalarField_H +#define adjointOutletPressureFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class adjointOutletPressureFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class adjointOutletPressureFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + +public: + + //- Runtime type information + TypeName("adjointOutletPressure"); + + + // Constructors + + //- Construct from patch and internal field + adjointOutletPressureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + adjointOutletPressureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given adjointOutletPressureFvPatchScalarField + // onto a new patch + adjointOutletPressureFvPatchScalarField + ( + const adjointOutletPressureFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new adjointOutletPressureFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + adjointOutletPressureFvPatchScalarField + ( + const adjointOutletPressureFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new adjointOutletPressureFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointOutletVelocity/adjointOutletVelocityFvPatchVectorField.C b/applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointOutletVelocity/adjointOutletVelocityFvPatchVectorField.C new file mode 100644 index 0000000000..e99550c619 --- /dev/null +++ b/applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointOutletVelocity/adjointOutletVelocityFvPatchVectorField.C @@ -0,0 +1,131 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "adjointOutletVelocityFvPatchVectorField.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" +#include "surfaceFields.H" +#include "fvPatchFieldMapper.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::adjointOutletVelocityFvPatchVectorField:: +adjointOutletVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchVectorField(p, iF) +{} + + +Foam::adjointOutletVelocityFvPatchVectorField:: +adjointOutletVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchVectorField(p, iF) +{ + fvPatchVectorField::operator=(vectorField("value", dict, p.size())); +} + + +Foam::adjointOutletVelocityFvPatchVectorField:: +adjointOutletVelocityFvPatchVectorField +( + const adjointOutletVelocityFvPatchVectorField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchVectorField(ptf, p, iF, mapper) +{} + + +Foam::adjointOutletVelocityFvPatchVectorField:: +adjointOutletVelocityFvPatchVectorField +( + const adjointOutletVelocityFvPatchVectorField& pivpvf, + const DimensionedField& iF +) +: + fixedValueFvPatchVectorField(pivpvf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +// Update the coefficients associated with the patch field +void Foam::adjointOutletVelocityFvPatchVectorField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const fvsPatchField& phiap = + patch().lookupPatchField("phia"); + + const fvPatchField& Up = + patch().lookupPatchField("U"); + + scalarField Un = mag(patch().nf() & Up); + vectorField UtHat = (Up - patch().nf()*Un)/(Un + SMALL); + + vectorField Uan = patch().nf()*(patch().nf() & patchInternalField()); + + vectorField::operator=(phiap*patch().Sf()/sqr(patch().magSf()) + UtHat); + //vectorField::operator=(Uan + UtHat); + + fixedValueFvPatchVectorField::updateCoeffs(); +} + + +void Foam::adjointOutletVelocityFvPatchVectorField::write(Ostream& os) const +{ + fvPatchVectorField::write(os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchVectorField, + adjointOutletVelocityFvPatchVectorField + ); +} + + +// ************************************************************************* // diff --git a/applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointOutletVelocity/adjointOutletVelocityFvPatchVectorField.H b/applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointOutletVelocity/adjointOutletVelocityFvPatchVectorField.H new file mode 100644 index 0000000000..2e14f96f9b --- /dev/null +++ b/applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointOutletVelocity/adjointOutletVelocityFvPatchVectorField.H @@ -0,0 +1,131 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + adjointOutletVelocityFvPatchVectorField + +Description + +SourceFiles + adjointOutletVelocityFvPatchVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef adjointOutletVelocityFvPatchVectorField_H +#define adjointOutletVelocityFvPatchVectorField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class adjointOutletVelocityFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class adjointOutletVelocityFvPatchVectorField +: + public fixedValueFvPatchVectorField +{ + +public: + + //- Runtime type information + TypeName("adjointOutletVelocity"); + + + // Constructors + + //- Construct from patch and internal field + adjointOutletVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + adjointOutletVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given adjointOutletVelocityFvPatchVectorField + // onto a new patch + adjointOutletVelocityFvPatchVectorField + ( + const adjointOutletVelocityFvPatchVectorField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new adjointOutletVelocityFvPatchVectorField(*this) + ); + } + + //- Construct as copy setting internal field reference + adjointOutletVelocityFvPatchVectorField + ( + const adjointOutletVelocityFvPatchVectorField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone(const DimensionedField& iF) const + { + return tmp + ( + new adjointOutletVelocityFvPatchVectorField(*this, iF) + ); + } + + + // Member functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointShapeOptimizationFoam.C b/applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointShapeOptimizationFoam.C new file mode 100644 index 0000000000..acf1be057f --- /dev/null +++ b/applications/solvers/incompressible/ajointShapeOptimizationFoam/adjointShapeOptimizationFoam.C @@ -0,0 +1,226 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + ajointShapeOptimizationFoam + +Description + Steady-state solver for incompressible, turbulent flow of non-Newtonian + fluids with optimisation of duct shape by applying "blockage" in regions + causing pressure loss as estimated using an adjoint formulation. + + References: + @verbatim + "Implementation of a continuous adjoint for topology optimization of + ducted flows" + C. Othmer, + E. de Villiers, + H.G. Weller + AIAA-2007-3947 + http://pdf.aiaa.org/preview/CDReadyMCFD07_1379/PV2007_3947.pdf + @endverbatim + + Note that this solver optimises for total pressure loss whereas the + above paper describes the method for optimising power-loss. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "singlePhaseTransportModel.H" +#include "RASModel.H" + +template +void zeroCells +( + GeometricField& vf, + const labelList& cells +) +{ + forAll(cells, i) + { + vf[cells[i]] = pTraits::zero; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + + #include "createTime.H" + #include "createMesh.H" + #include "createFields.H" + #include "initContinuityErrs.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + for (runTime++; !runTime.end(); runTime++) + { + Info<< "Time = " << runTime.timeName() << nl << endl; + + #include "readSIMPLEControls.H" + + p.storePrevIter(); + + laminarTransport.lookup("lambda") >> lambda; + + //alpha += + // mesh.relaxationFactor("alpha") + // *(lambda*max(Ua & U, zeroSensitivity) - alpha); + alpha += + mesh.relaxationFactor("alpha") + *(min(max(alpha + lambda*(Ua & U), zeroAlpha), alphaMax) - alpha); + + zeroCells(alpha, inletCells); + //zeroCells(alpha, outletCells); + + // Pressure-velocity SIMPLE corrector + { + // Momentum predictor + + tmp UEqn + ( + fvm::div(phi, U) + + turbulence->divDevReff(U) + + fvm::Sp(alpha, U) + ); + + UEqn().relax(); + + solve(UEqn() == -fvc::grad(p)); + + p.boundaryField().updateCoeffs(); + volScalarField rAU = 1.0/UEqn().A(); + U = rAU*UEqn().H(); + UEqn.clear(); + phi = fvc::interpolate(U) & mesh.Sf(); + adjustPhi(phi, U, p); + + // Non-orthogonal pressure corrector loop + for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + fvScalarMatrix pEqn + ( + fvm::laplacian(rAU, p) == fvc::div(phi) + ); + + pEqn.setReference(pRefCell, pRefValue); + pEqn.solve(); + + if (nonOrth == nNonOrthCorr) + { + phi -= pEqn.flux(); + } + } + + #include "continuityErrs.H" + + // Explicitly relax pressure for momentum corrector + p.relax(); + + // Momentum corrector + U -= rAU*fvc::grad(p); + U.correctBoundaryConditions(); + } + + pa.storePrevIter(); + + // Adjoint Pressure-velocity SIMPLE corrector + { + // Adjoint Momentum predictor + + volVectorField adjointTransposeConvection = (fvc::grad(Ua) & U); + //volVectorField adjointTransposeConvection = fvc::reconstruct + //( + // mesh.magSf()*(fvc::snGrad(Ua) & fvc::interpolate(U)) + //); + + zeroCells(adjointTransposeConvection, inletCells); + + tmp UaEqn + ( + fvm::div(-phi, Ua) + - adjointTransposeConvection + + turbulence->divDevReff(Ua) + + fvm::Sp(alpha, Ua) + ); + + UaEqn().relax(); + + solve(UaEqn() == -fvc::grad(pa)); + + pa.boundaryField().updateCoeffs(); + volScalarField rAUa = 1.0/UaEqn().A(); + Ua = rAUa*UaEqn().H(); + UaEqn.clear(); + phia = fvc::interpolate(Ua) & mesh.Sf(); + adjustPhi(phia, Ua, pa); + + // Non-orthogonal pressure corrector loop + for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + fvScalarMatrix paEqn + ( + fvm::laplacian(rAUa, pa) == fvc::div(phia) + ); + + paEqn.setReference(paRefCell, paRefValue); + paEqn.solve(); + + if (nonOrth == nNonOrthCorr) + { + phia -= paEqn.flux(); + } + } + + #include "adjointContinuityErrs.H" + + // Explicitly relax pressure for adjoint momentum corrector + pa.relax(); + + // Adjoint momentum corrector + Ua -= rAUa*fvc::grad(pa); + Ua.correctBoundaryConditions(); + } + + turbulence->correct(); + + runTime.write(); + + Info<< "ExecutionTime = " + << runTime.elapsedCpuTime() + << " s\n\n" << endl; + } + + Info<< "End\n" << endl; + + return(0); +} + + +// ************************************************************************* // diff --git a/applications/solvers/incompressible/ajointShapeOptimizationFoam/createFields.H b/applications/solvers/incompressible/ajointShapeOptimizationFoam/createFields.H new file mode 100644 index 0000000000..dd2f6416ee --- /dev/null +++ b/applications/solvers/incompressible/ajointShapeOptimizationFoam/createFields.H @@ -0,0 +1,105 @@ + Info << "Reading field p\n" << endl; + volScalarField p + ( + IOobject + ( + "p", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info << "Reading field U\n" << endl; + volVectorField U + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + #include "createPhi.H" + + + label pRefCell = 0; + scalar pRefValue = 0.0; + setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue); + + + Info << "Reading field pa\n" << endl; + volScalarField pa + ( + IOobject + ( + "pa", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info << "Reading field Ua\n" << endl; + volVectorField Ua + ( + IOobject + ( + "Ua", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + #include "createPhia.H" + + + label paRefCell = 0; + scalar paRefValue = 0.0; + setRefCell(pa, mesh.solutionDict().subDict("SIMPLE"), paRefCell, paRefValue); + + + singlePhaseTransportModel laminarTransport(U, phi); + + autoPtr turbulence + ( + incompressible::RASModel::New(U, phi, laminarTransport) + ); + + + dimensionedScalar zeroSensitivity("0", dimVelocity*dimVelocity, 0.0); + dimensionedScalar zeroAlpha("0", dimless/dimTime, 0.0); + + dimensionedScalar lambda(laminarTransport.lookup("lambda")); + dimensionedScalar alphaMax(laminarTransport.lookup("alphaMax")); + + const labelList& inletCells = + mesh.boundary()[mesh.boundaryMesh().findPatchID("inlet")].faceCells(); + //const labelList& outletCells = + // mesh.boundary()[mesh.boundaryMesh().findPatchID("outlet")].faceCells(); + + volScalarField alpha + ( + IOobject + ( + "alpha", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + lambda*max(Ua & U, zeroSensitivity) + ); + zeroCells(alpha, inletCells); + //zeroCells(alpha, outletCells); diff --git a/applications/solvers/incompressible/ajointShapeOptimizationFoam/createPhia.H b/applications/solvers/incompressible/ajointShapeOptimizationFoam/createPhia.H new file mode 100644 index 0000000000..ea227ab133 --- /dev/null +++ b/applications/solvers/incompressible/ajointShapeOptimizationFoam/createPhia.H @@ -0,0 +1,57 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Global + createPhia + +Description + Creates and initialises the face-flux field phia. + +\*---------------------------------------------------------------------------*/ + +#ifndef createPhia_H +#define createPhia_H + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Info<< "Reading/calculating face flux field phia\n" << endl; + +surfaceScalarField phia +( + IOobject + ( + "phia", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + linearInterpolate(Ua) & mesh.Sf() +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/U b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/U new file mode 100644 index 0000000000..539f35641f --- /dev/null +++ b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/U @@ -0,0 +1,54 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + inlet + { + type fixedValue; + value uniform (10 0 0); + } + + outlet + { + //type zeroGradient; + type inletOutlet; + inletValue uniform (0 0 0); + } + + upperWall + { + type fixedValue; + value uniform (0 0 0); + } + + lowerWall + { + type fixedValue; + value uniform (0 0 0); + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/Ua b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/Ua new file mode 100644 index 0000000000..2fdbc699de --- /dev/null +++ b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/Ua @@ -0,0 +1,56 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object Ua; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + inlet + { + type fixedValue; + value uniform (-1 0 0); + } + + outlet + { + //type zeroGradient; + //type inletOutlet; + //inletValue uniform (0 0 0); + type adjointOutletVelocity; + value uniform (0 0 0); + } + + upperWall + { + type fixedValue; + value uniform (0 0 0); + } + + lowerWall + { + type fixedValue; + value uniform (0 0 0); + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/epsilon b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/epsilon new file mode 100644 index 0000000000..ab06b7b912 --- /dev/null +++ b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/epsilon @@ -0,0 +1,56 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object epsilon; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -3 0 0 0 0]; + +internalField uniform 14.855; + +boundaryField +{ + inlet + { + type fixedValue; + value uniform 14.855; + } + outlet + { + type zeroGradient; + } + upperWall + { + type epsilonWallFunction; + Cmu 0.09; + kappa 0.41; + E 9.8; + value uniform 14.855; + } + lowerWall + { + type epsilonWallFunction; + Cmu 0.09; + kappa 0.41; + E 9.8; + value uniform 14.855; + } + frontAndBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/k b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/k new file mode 100644 index 0000000000..7de1adf4b5 --- /dev/null +++ b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/k @@ -0,0 +1,50 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object k; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -2 0 0 0 0]; + +internalField uniform 0.375; + +boundaryField +{ + inlet + { + type fixedValue; + value uniform 0.375; + } + outlet + { + type zeroGradient; + } + upperWall + { + type kqRWallFunction; + value uniform 0.375; + } + lowerWall + { + type kqRWallFunction; + value uniform 0.375; + } + frontAndBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/nut b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/nut new file mode 100644 index 0000000000..7e5dd36574 --- /dev/null +++ b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/nut @@ -0,0 +1,57 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object nut; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -1 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type calculated; + value uniform 0; + } + outlet + { + type calculated; + value uniform 0; + } + upperWall + { + type nutkWallFunction; + Cmu 0.09; + kappa 0.41; + E 9.8; + value uniform 0; + } + lowerWall + { + type nutkWallFunction; + Cmu 0.09; + kappa 0.41; + E 9.8; + value uniform 0; + } + frontAndBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/p b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/p new file mode 100644 index 0000000000..86135d2627 --- /dev/null +++ b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/p @@ -0,0 +1,50 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type zeroGradient; + } + + outlet + { + type fixedValue; + value uniform 0; + } + + upperWall + { + type zeroGradient; + } + + lowerWall + { + type zeroGradient; + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/pa b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/pa new file mode 100644 index 0000000000..225a69938a --- /dev/null +++ b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/0/pa @@ -0,0 +1,50 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object pa; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type zeroGradient; + } + + outlet + { + type adjointOutletPressure; + value uniform 0; + } + + upperWall + { + type zeroGradient; + } + + lowerWall + { + type zeroGradient; + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/constant/RASProperties b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/constant/RASProperties new file mode 100644 index 0000000000..aed2ebec56 --- /dev/null +++ b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/constant/RASProperties @@ -0,0 +1,24 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object RASProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +RASModel kEpsilon; + +turbulence on; + +printCoeffs on; + +// ************************************************************************* // diff --git a/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/constant/polyMesh/blockMeshDict b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/constant/polyMesh/blockMeshDict new file mode 100644 index 0000000000..ff3dc92a19 --- /dev/null +++ b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/constant/polyMesh/blockMeshDict @@ -0,0 +1,153 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 0.001; + +vertices +( + (-20.6 0 -0.5) + (-20.6 3 -0.5) + (-20.6 12.7 -0.5) + (-20.6 25.4 -0.5) + (0 -25.4 -0.5) + (0 -5 -0.5) + (0 0 -0.5) + (0 3 -0.5) + (0 12.7 -0.5) + (0 25.4 -0.5) + (206 -25.4 -0.5) + (206 -8.5 -0.5) + (206 0 -0.5) + (206 6.5 -0.5) + (206 17 -0.5) + (206 25.4 -0.5) + (290 -16.6 -0.5) + (290 -6.3 -0.5) + (290 0 -0.5) + (290 4.5 -0.5) + (290 11 -0.5) + (290 16.6 -0.5) + (-20.6 0 0.5) + (-20.6 3 0.5) + (-20.6 12.7 0.5) + (-20.6 25.4 0.5) + (0 -25.4 0.5) + (0 -5 0.5) + (0 0 0.5) + (0 3 0.5) + (0 12.7 0.5) + (0 25.4 0.5) + (206 -25.4 0.5) + (206 -8.5 0.5) + (206 0 0.5) + (206 6.5 0.5) + (206 17 0.5) + (206 25.4 0.5) + (290 -16.6 0.5) + (290 -6.3 0.5) + (290 0 0.5) + (290 4.5 0.5) + (290 11 0.5) + (290 16.6 0.5) +); + +blocks +( + hex (0 6 7 1 22 28 29 23) (18 7 1) simpleGrading (0.5 1.8 1) + hex (1 7 8 2 23 29 30 24) (18 10 1) simpleGrading (0.5 4 1) + hex (2 8 9 3 24 30 31 25) (18 13 1) simpleGrading (0.5 0.25 1) + hex (4 10 11 5 26 32 33 27) (180 18 1) simpleGrading (4 1 1) + hex (5 11 12 6 27 33 34 28) (180 9 1) edgeGrading (4 4 4 4 0.5 1 1 0.5 1 1 1 1) + hex (6 12 13 7 28 34 35 29) (180 7 1) edgeGrading (4 4 4 4 1.8 1 1 1.8 1 1 1 1) + hex (7 13 14 8 29 35 36 30) (180 10 1) edgeGrading (4 4 4 4 4 1 1 4 1 1 1 1) + hex (8 14 15 9 30 36 37 31) (180 13 1) simpleGrading (4 0.25 1) + hex (10 16 17 11 32 38 39 33) (25 18 1) simpleGrading (2.5 1 1) + hex (11 17 18 12 33 39 40 34) (25 9 1) simpleGrading (2.5 1 1) + hex (12 18 19 13 34 40 41 35) (25 7 1) simpleGrading (2.5 1 1) + hex (13 19 20 14 35 41 42 36) (25 10 1) simpleGrading (2.5 1 1) + hex (14 20 21 15 36 42 43 37) (25 13 1) simpleGrading (2.5 0.25 1) +); + +edges +( +); + +patches +( + patch inlet + ( + (0 22 23 1) + (1 23 24 2) + (2 24 25 3) + ) + patch outlet + ( + (16 17 39 38) + (17 18 40 39) + (18 19 41 40) + (19 20 42 41) + (20 21 43 42) + ) + wall upperWall + ( + (3 25 31 9) + (9 31 37 15) + (15 37 43 21) + ) + wall lowerWall + ( + (0 6 28 22) + (6 5 27 28) + (5 4 26 27) + (4 10 32 26) + (10 16 38 32) + ) + empty frontAndBack + ( + (22 28 29 23) + (23 29 30 24) + (24 30 31 25) + (26 32 33 27) + (27 33 34 28) + (28 34 35 29) + (29 35 36 30) + (30 36 37 31) + (32 38 39 33) + (33 39 40 34) + (34 40 41 35) + (35 41 42 36) + (36 42 43 37) + (0 1 7 6) + (1 2 8 7) + (2 3 9 8) + (4 5 11 10) + (5 6 12 11) + (6 7 13 12) + (7 8 14 13) + (8 9 15 14) + (10 11 17 16) + (11 12 18 17) + (12 13 19 18) + (13 14 20 19) + (14 15 21 20) + ) +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/constant/polyMesh/boundary b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/constant/polyMesh/boundary new file mode 100644 index 0000000000..7a50ba628b --- /dev/null +++ b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/constant/polyMesh/boundary @@ -0,0 +1,57 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class polyBoundaryMesh; + location "constant/polyMesh"; + object boundary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +5 +( + inlet + { + type patch; + physicalType inlet; + nFaces 30; + startFace 24170; + } + outlet + { + type patch; + physicalType outlet; + nFaces 57; + startFace 24200; + } + upperWall + { + type wall; + physicalType wallFunctions; + nFaces 223; + startFace 24257; + } + lowerWall + { + type wall; + physicalType wallFunctions; + nFaces 250; + startFace 24480; + } + frontAndBack + { + type empty; + physicalType empty; + nFaces 24450; + startFace 24730; + } +) + +// ************************************************************************* // diff --git a/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/constant/transportProperties b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/constant/transportProperties new file mode 100644 index 0000000000..53fd54c2ff --- /dev/null +++ b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/constant/transportProperties @@ -0,0 +1,25 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +transportModel Newtonian; + +nu nu [0 2 -1 0 0 0 0] 1e-5; + +lambda lambda [0 -2 1 0 0 0 0] 1e5; +alphaMax alphaMax [0 0 -1 0 0 0 0] 200.0; + +// ************************************************************************* // diff --git a/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/system/controlDict b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/system/controlDict new file mode 100644 index 0000000000..733efddbc0 --- /dev/null +++ b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/system/controlDict @@ -0,0 +1,48 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application adjointShapeOptimizationFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 1000; + +deltaT 1; + +writeControl timeStep; + +writeInterval 100; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 12; + +writeCompression uncompressed; + +timeFormat general; + +timePrecision 12; + +runTimeModifiable yes; + +// ************************************************************************* // diff --git a/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/system/fvSchemes b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/system/fvSchemes new file mode 100644 index 0000000000..43209ca130 --- /dev/null +++ b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/system/fvSchemes @@ -0,0 +1,76 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default steadyState; +} + +gradSchemes +{ + default Gauss linear; + + grad(p) Gauss linear; + grad(U) Gauss linear; +} + +divSchemes +{ + default none; + + div(phi,U) Gauss upwind; + div(phi,k) Gauss upwind; + div(phi,epsilon) Gauss upwind; + div((nuEff*dev(grad(U).T()))) Gauss linear; + + div(-phi,Ua) Gauss upwind; + div((nuEff*dev(grad(Ua).T()))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; + + laplacian(nuEff,U) Gauss linear corrected; + laplacian(1,p) Gauss linear corrected; + laplacian(1|A(U),p) Gauss linear corrected; + laplacian(DkEff,k) Gauss linear corrected; + laplacian(DepsilonEff,epsilon) Gauss linear corrected; + + laplacian(nuEff,Ua) Gauss linear corrected; + laplacian(1|A(Ua),pa) Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; + interpolate(U) linear; +} + +snGradSchemes +{ + default corrected; +} + +fluxRequired +{ + default no; + p; + pa; +} + +// ************************************************************************* // diff --git a/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/system/fvSolution b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/system/fvSolution new file mode 100644 index 0000000000..3e4364cd75 --- /dev/null +++ b/tutorials/incompressible/adjointShapeOptimizationFoam/pitzDaily/system/fvSolution @@ -0,0 +1,60 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + "(p|pa)" + { + solver GAMG; + tolerance 1e-08; + relTol 0.01; + smoother GaussSeidel; + nPreSweeps 0; + nPostSweeps 2; + cacheAgglomeration true; + nCellsInCoarsestLevel 10; + agglomerator faceAreaPair; + mergeLevels 1; + } + + "(U|Ua|k|epsilon)" + { + solver smoothSolver; + smoother GaussSeidel; + nSweeps 2; + tolerance 1e-08; + relTol 0.1; + } +} + +SIMPLE +{ + nNonOrthogonalCorrectors 0; + pRefCell 0; + pRefValue 0; +} + +relaxationFactors +{ + "(p|pa)" 0.3; + "(U|Ua)" 0.7; + "(k|epsilon)" 0.7; + alpha 0.1; +} + + +// ************************************************************************* //