From 0c7ad1a77a45a603edb79a668e3011888fd484cb Mon Sep 17 00:00:00 2001 From: Ping He Date: Sat, 9 Dec 2023 16:23:19 -0600 Subject: [PATCH] Enabled UMag to change during varyingVelocity. --- dafoam/pyDAFoam.py | 5 +- src/adjoint/Make/files_Compressible | 2 +- src/adjoint/Make/files_Incompressible | 2 +- .../varyingVelocityFvPatchVectorField.C} | 94 +++++++++---------- .../varyingVelocityFvPatchVectorField.H} | 74 ++++++++------- 5 files changed, 91 insertions(+), 86 deletions(-) rename src/adjoint/boundaryConditions/{varyingFlowDirection/varyingFlowDirectionFvPatchVectorField.C => varyingVelocity/varyingVelocityFvPatchVectorField.C} (58%) rename src/adjoint/boundaryConditions/{varyingFlowDirection/varyingFlowDirectionFvPatchVectorField.H => varyingVelocity/varyingVelocityFvPatchVectorField.H} (64%) diff --git a/dafoam/pyDAFoam.py b/dafoam/pyDAFoam.py index fd977cdf..ffdb728e 100755 --- a/dafoam/pyDAFoam.py +++ b/dafoam/pyDAFoam.py @@ -2464,8 +2464,6 @@ def solveAdjointUnsteady(self): self.calcTotalDerivsField(objFuncName, designVarName, fieldType, dFScaling, True) else: raise Error("designVarType not valid!") - - Info("Computing partials for old times %f s" % self.solver.getElapsedClockTime()) # we need to calculate dRdW0TPsi for the previous time step if ddtSchemeOrder == 1: @@ -3083,6 +3081,9 @@ def _initSolver(self): if self.solverInitialized == 1: raise Error("pyDAFoam: self._initSolver has been called! One shouldn't initialize solvers twice!") + + Info("Init solver. ElapsedClockTime %f s" % self.solver.getElapsedClockTime()) + Info("Init solver. ElapsedCpuTime %f s" % self.solver.getElapsedCpuTime()) solverName = self.getOption("solverName") solverArg = solverName + " -python " + self.parallelFlag diff --git a/src/adjoint/Make/files_Compressible b/src/adjoint/Make/files_Compressible index b57407b5..bc18f4a9 100755 --- a/src/adjoint/Make/files_Compressible +++ b/src/adjoint/Make/files_Compressible @@ -91,7 +91,7 @@ DASolver/DATurboFoam/DATurboFoam.C boundaryConditions/multiFreqVector/multiFreqVectorFvPatchField.C boundaryConditions/nutUSpaldingWallFunctionDF/nutUSpaldingWallFunctionFvPatchScalarFieldDF.C -boundaryConditions/varyingFlowDirection/varyingFlowDirectionFvPatchVectorField.C +boundaryConditions/varyingVelocity/varyingVelocityFvPatchVectorField.C models/dummyTurbulenceModel/makeDummyTurbulenceModelCompressible.C models/SpalartAllmarasFv3/makeSpalartAllmarasFv3Compressible.C models/SpalartAllmarasFv3FieldInversion/makeSpalartAllmarasFv3FieldInversionCompressible.C diff --git a/src/adjoint/Make/files_Incompressible b/src/adjoint/Make/files_Incompressible index 03e6d78a..c64f0377 100755 --- a/src/adjoint/Make/files_Incompressible +++ b/src/adjoint/Make/files_Incompressible @@ -102,7 +102,7 @@ DASolver/DAPimpleDyMFoam/DAPimpleDyMFoam.C boundaryConditions/multiFreqVector/multiFreqVectorFvPatchField.C boundaryConditions/nutUSpaldingWallFunctionDF/nutUSpaldingWallFunctionFvPatchScalarFieldDF.C -boundaryConditions/varyingFlowDirection/varyingFlowDirectionFvPatchVectorField.C +boundaryConditions/varyingVelocity/varyingVelocityFvPatchVectorField.C models/dummyTurbulenceModel/makeDummyTurbulenceModelIncompressible.C models/SpalartAllmarasFv3/makeSpalartAllmarasFv3Incompressible.C models/SpalartAllmarasFv3FieldInversion/makeSpalartAllmarasFv3FieldInversionIncompressible.C diff --git a/src/adjoint/boundaryConditions/varyingFlowDirection/varyingFlowDirectionFvPatchVectorField.C b/src/adjoint/boundaryConditions/varyingVelocity/varyingVelocityFvPatchVectorField.C similarity index 58% rename from src/adjoint/boundaryConditions/varyingFlowDirection/varyingFlowDirectionFvPatchVectorField.C rename to src/adjoint/boundaryConditions/varyingVelocity/varyingVelocityFvPatchVectorField.C index ed2ceb52..5e95f421 100755 --- a/src/adjoint/boundaryConditions/varyingFlowDirection/varyingFlowDirectionFvPatchVectorField.C +++ b/src/adjoint/boundaryConditions/varyingVelocity/varyingVelocityFvPatchVectorField.C @@ -27,34 +27,36 @@ \*---------------------------------------------------------------------------*/ -#include "varyingFlowDirectionFvPatchVectorField.H" +#include "varyingVelocityFvPatchVectorField.H" #include "volFields.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::varyingFlowDirectionFvPatchVectorField::varyingFlowDirectionFvPatchVectorField( +Foam::varyingVelocityFvPatchVectorField::varyingVelocityFvPatchVectorField( const fvPatch& p, const DimensionedField& iF) : fixedValueFvPatchVectorField(p, iF), - UMag_(0.0), - flowDir_("x"), - normalDir_("y"), + U0_(0.0), + URate_(0.0), + flowComponent_(0), + normalComponent_(1), alpha0_(0), - rate_(0) + alphaRate_(0) { } -Foam::varyingFlowDirectionFvPatchVectorField::varyingFlowDirectionFvPatchVectorField( +Foam::varyingVelocityFvPatchVectorField::varyingVelocityFvPatchVectorField( const fvPatch& p, const DimensionedField& iF, const dictionary& dict) : fixedValueFvPatchVectorField(p, iF), - UMag_(dict.lookupOrDefault("UMag", 0.0)), - flowDir_(dict.lookupOrDefault("flowDir", "x")), - normalDir_(dict.lookupOrDefault("normalDir", "y")), + U0_(dict.lookupOrDefault("U0", 0.0)), + URate_(dict.lookupOrDefault("URate", 0.0)), + flowComponent_(dict.lookupOrDefault