From d6104bd497eb686f1b47ce972caaddadc09fe3f1 Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Fri, 12 Jun 2020 14:34:56 +0100 Subject: [PATCH] INT: Minor integration updates --- .../adjointBoundaryCondition/adjointBoundaryCondition.C | 6 ++---- .../adjointRotatingWallVelocityFvPatchVectorField.C | 4 ++-- .../objectiveManager/objectiveManager/objectiveManager.C | 2 +- .../objectiveForceTarget/objectiveForceTarget.C | 6 ++++-- .../objectiveForceTarget/objectiveForceTarget.H | 4 ++-- .../objectiveIncompressible/objectiveIncompressible.C | 6 +++--- .../objectiveIncompressible/objectiveIncompressible.H | 4 ++-- .../incompressible/objectiveNutSqr/objectiveNutSqr.C | 6 +++--- .../incompressible/objectiveNutSqr/objectiveNutSqr.H | 4 ++-- .../objectivePartialVolume/objectivePartialVolume.C | 4 +++- .../objectivePartialVolume/objectivePartialVolume.H | 4 ++-- .../incompressible/objectivePtLosses/objectivePtLosses.C | 4 +++- .../incompressible/objectivePtLosses/objectivePtLosses.H | 4 ++-- .../adjoint/objectives/objective/objective.C | 6 ++++-- .../adjoint/objectives/objective/objective.H | 4 ++-- .../optMeshMovement/optMeshMovement/optMeshMovement.C | 2 +- .../optimisation/updateMethod/updateMethod/updateMethod.C | 2 +- 17 files changed, 39 insertions(+), 33 deletions(-) diff --git a/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointBoundaryCondition/adjointBoundaryCondition.C b/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointBoundaryCondition/adjointBoundaryCondition.C index b0177fbeb82..2febf7f9125 100644 --- a/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointBoundaryCondition/adjointBoundaryCondition.C +++ b/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointBoundaryCondition/adjointBoundaryCondition.C @@ -266,10 +266,8 @@ template<class Type> const ATCModel& adjointBoundaryCondition<Type>::getATC() const { return - patch_.boundaryMesh().mesh().lookupObject<ATCModel> - ( - "ATCModel" + adjointSolverName_ - ); + patch_.boundaryMesh().mesh().template + lookupObject<ATCModel>("ATCModel" + adjointSolverName_); } diff --git a/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointRotatingWallVelocity/adjointRotatingWallVelocityFvPatchVectorField.C b/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointRotatingWallVelocity/adjointRotatingWallVelocityFvPatchVectorField.C index f5b8362cd05..c7d4487a479 100644 --- a/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointRotatingWallVelocity/adjointRotatingWallVelocityFvPatchVectorField.C +++ b/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointRotatingWallVelocity/adjointRotatingWallVelocityFvPatchVectorField.C @@ -70,8 +70,8 @@ adjointRotatingWallVelocityFvPatchVectorField ) : adjointWallVelocityFvPatchVectorField(p, iF, dict), - origin_(dict.lookup("origin")), - axis_(dict.lookup("axis")), + origin_(dict.get<vector>("origin")), + axis_(dict.get<vector>("axis")), omega_(Function1<scalar>::New("omega", dict)) {} diff --git a/src/optimisation/adjointOptimisation/adjoint/objectiveManager/objectiveManager/objectiveManager.C b/src/optimisation/adjointOptimisation/adjoint/objectiveManager/objectiveManager/objectiveManager.C index cd3cdc7c0d2..2420ebfb244 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectiveManager/objectiveManager/objectiveManager.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectiveManager/objectiveManager/objectiveManager.C @@ -177,7 +177,7 @@ void objectiveManager::update() void objectiveManager::updateOrNullify() { - //- Update contributions to adjoint if true, otherwise return nulls + // Update contributions to adjoint if true, otherwise return nulls for (objective& obj : objectives_) { if (obj.isWithinIntegrationTime()) diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveForceTarget/objectiveForceTarget.C b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveForceTarget/objectiveForceTarget.C index 19195b77b0b..b6895320e3e 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveForceTarget/objectiveForceTarget.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveForceTarget/objectiveForceTarget.C @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2013-2019 FOSS GP - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -75,7 +75,7 @@ scalar objectiveForceTarget::J() } -void objectiveForceTarget::write() const +bool objectiveForceTarget::write(const bool valid) const { if (Pstream::master()) { @@ -99,6 +99,8 @@ void objectiveForceTarget::write() const << setw(width) << force_ << " " << setw(width) << target_ << endl; } + + return true; } diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveForceTarget/objectiveForceTarget.H b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveForceTarget/objectiveForceTarget.H index 1e6bb6acc3d..f94763aeb9e 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveForceTarget/objectiveForceTarget.H +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveForceTarget/objectiveForceTarget.H @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2013-2019 FOSS GP - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -92,7 +92,7 @@ public: scalar J(); //- Write objective value - void write() const; + virtual bool write(const bool valid = true) const; }; diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveIncompressible/objectiveIncompressible.C b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveIncompressible/objectiveIncompressible.C index 1ce8b4caa4e..dbc0789d24b 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveIncompressible/objectiveIncompressible.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveIncompressible/objectiveIncompressible.C @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2013-2019 FOSS GP - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -546,9 +546,9 @@ void objectiveIncompressible::nullify() } -void objectiveIncompressible::write() const +bool objectiveIncompressible::write(const bool valid) const { - objective::write(); + return objective::write(valid); } diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveIncompressible/objectiveIncompressible.H b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveIncompressible/objectiveIncompressible.H index 19dad810756..a96a07b003c 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveIncompressible/objectiveIncompressible.H +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveIncompressible/objectiveIncompressible.H @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2013-2019 FOSS GP - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -306,7 +306,7 @@ public: {} //- Write objective function history - virtual void write() const; + virtual bool write(const bool valid = true) const; //- Inline functions for checking whether pointers are set or not inline bool hasdJdv() const; diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveNutSqr/objectiveNutSqr.C b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveNutSqr/objectiveNutSqr.C index c4e3edb9414..515b82061ff 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveNutSqr/objectiveNutSqr.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveNutSqr/objectiveNutSqr.C @@ -65,7 +65,7 @@ objectiveNutSqr::objectiveNutSqr mesh_.cellZones().indices(this->dict().get<wordRes>("zones")) ) { - //- Allocate source term for the adjoint turbulence model + // Allocate source term for the adjoint turbulence model dJdTMvar1Ptr_.reset ( createZeroFieldPtr<scalar> @@ -75,7 +75,7 @@ objectiveNutSqr::objectiveNutSqr (dimless/dimTime/dimTime) ) ); - //- Allocate term to be added to volume-based sensitivity derivatives + // Allocate term to be added to volume-based sensitivity derivatives divDxDbMultPtr_.reset ( createZeroFieldPtr<scalar> @@ -87,7 +87,7 @@ objectiveNutSqr::objectiveNutSqr dimensionSet(0,0,0,0,0,0,0) ) ); - //- set file pointer + // set file pointer //objFunctionFilePtr_ = new OFstream(objFunctionFolder_/type()); } diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveNutSqr/objectiveNutSqr.H b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveNutSqr/objectiveNutSqr.H index 977c7cc342b..b2211b9b506 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveNutSqr/objectiveNutSqr.H +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveNutSqr/objectiveNutSqr.H @@ -85,7 +85,7 @@ public: // Constructors - //- from components + //- From components objectiveNutSqr ( const fvMesh& mesh, @@ -110,7 +110,7 @@ public: void update_dJdTMvar1(); //- Update field to be added to be added to volume-based - // sensitivity derivatives, emerging from delta ( dV ) / delta b + //- sensitivity derivatives, emerging from delta ( dV ) / delta b void update_divDxDbMultiplier(); }; diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePartialVolume/objectivePartialVolume.C b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePartialVolume/objectivePartialVolume.C index 7861fac8392..8fec4c11ff1 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePartialVolume/objectivePartialVolume.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePartialVolume/objectivePartialVolume.C @@ -133,7 +133,7 @@ void objectivePartialVolume::update_dSdbMultiplier() } -void objectivePartialVolume::write() const +bool objectivePartialVolume::write(const bool valid) const { if (Pstream::master()) { @@ -153,6 +153,8 @@ void objectivePartialVolume::write() const objFunctionFilePtr_() << setw(width) << J_ << " "; objFunctionFilePtr_() << setw(width) << initVol_ << endl; } + + return true; } diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePartialVolume/objectivePartialVolume.H b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePartialVolume/objectivePartialVolume.H index ba409f2af07..aec678088a9 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePartialVolume/objectivePartialVolume.H +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePartialVolume/objectivePartialVolume.H @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2013-2019 FOSS GP - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -99,7 +99,7 @@ public: void update_dSdbMultiplier(); //- Write objective function history - void write() const; + virtual bool write(const bool valid = true) const; }; diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePtLosses/objectivePtLosses.C b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePtLosses/objectivePtLosses.C index c0e0abd2ff7..53792824458 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePtLosses/objectivePtLosses.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePtLosses/objectivePtLosses.C @@ -234,7 +234,7 @@ void objectivePtLosses::update_boundarydJdvt() } -void objectivePtLosses::write() const +bool objectivePtLosses::write(const bool valid) const { if (Pstream::master()) { @@ -266,6 +266,8 @@ void objectivePtLosses::write() const } objFunctionFilePtr_() << endl; } + + return true; } diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePtLosses/objectivePtLosses.H b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePtLosses/objectivePtLosses.H index 99ce83439cc..014dd3cabdc 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePtLosses/objectivePtLosses.H +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectivePtLosses/objectivePtLosses.H @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2013-2019 FOSS GP - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -109,7 +109,7 @@ public: void update_boundarydJdvt(); //- Write objective function values and its contrituents - void write() const; + virtual bool write(const bool valid = true) const; }; diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objective.C b/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objective.C index 1eb423c0b8e..5a0bf4dea6d 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objective.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objective.C @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2007-2020 PCOpt/NTUA Copyright (C) 2013-2020 FOSS GP - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -677,7 +677,7 @@ void objective::nullify() } -void objective::write() const +bool objective::write(const bool valid) const { if (Pstream::master()) { @@ -691,6 +691,8 @@ void objective::write() const objFunctionFilePtr_() << mesh_.time().value() << tab << J_ << endl; } + + return true; } diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objective.H b/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objective.H index 56cf28ed46d..4ded76e0d0e 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objective.H +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objective.H @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2007-2020 PCOpt/NTUA Copyright (C) 2013-2020 FOSS GP - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -373,7 +373,7 @@ public: {} //- Write objective function history - virtual void write() const; + virtual bool write(const bool valid = true) const; //- Write objective function history at each primal solver iteration virtual void writeInstantaneousValue() const; diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/optMeshMovement/optMeshMovement/optMeshMovement.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/optMeshMovement/optMeshMovement/optMeshMovement.C index b26898be43b..1cce17ff3bf 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/optMeshMovement/optMeshMovement/optMeshMovement.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/optMeshMovement/optMeshMovement/optMeshMovement.C @@ -76,7 +76,7 @@ Foam::optMeshMovement::optMeshMovement dict.getOrDefault("writeMeshQualityMetrics", false) ) { - //- Set maxAllowedDisplacement if provided + // Set maxAllowedDisplacement if provided if (dict.found("maxAllowedDisplacement")) { maxAllowedDisplacement_.reset diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/updateMethod/updateMethod/updateMethod.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/updateMethod/updateMethod/updateMethod.C index 1410824a72b..2b9b0851196 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/updateMethod/updateMethod/updateMethod.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/updateMethod/updateMethod/updateMethod.C @@ -127,7 +127,7 @@ Foam::updateMethod::inv(SquareMatrix<scalar> A) label n(A.n()); SquareMatrix<scalar> invA(n, Zero); - //- LU decomposition of A + // LU decomposition of A labelList pivotIndices(n, Zero); LUDecompose(A, pivotIndices); DebugInfo -- GitLab