INT: integration updates

- Minor code style
- virtual functions
- added some noexcept
This commit is contained in:
Andrew Heather
2023-11-13 17:59:18 +00:00
committed by Andrew Heather
parent bd84860e9b
commit adaac7257f
32 changed files with 199 additions and 204 deletions

View File

@ -30,7 +30,6 @@ Class
Foam::adjointOutletVelocityFluxFvPatchVectorField Foam::adjointOutletVelocityFluxFvPatchVectorField
Description Description
An outlet boundary condition for patches in which the primal flow exhibits An outlet boundary condition for patches in which the primal flow exhibits
recirculation. Adds the contribution of the objective as an adjoint recirculation. Adds the contribution of the objective as an adjoint
momentum flux directly to the PDEs, without the need to first compute an momentum flux directly to the PDEs, without the need to first compute an

View File

@ -31,7 +31,7 @@ Group
grpFvOptionsSources grpFvOptionsSources
Description Description
Impelements Brinkman penalisation terms for topology optimisation. Implements Brinkman penalisation terms for topology optimisation.
Looks up the indicator field (beta) from the registry, through Looks up the indicator field (beta) from the registry, through
topOVariablesBase topOVariablesBase

View File

@ -88,15 +88,15 @@ public:
// Member Functions // Member Functions
//- Return the objective function value //- Return the objective function value
scalar J(); virtual scalar J();
//- Update d (x) / db multiplier. Surface and volume-based sensitivity //- Update d (x) / db multiplier. Surface and volume-based sensitivity
//- term //- term
void update_dxdbDirectMultiplier(); virtual void update_dxdbDirectMultiplier();
//- Update d (normal dS) / db multiplier. Surface and volume-based //- Update d (normal dS) / db multiplier. Surface and volume-based
//- sensitivity term //- sensitivity term
void update_dSdbMultiplier(); virtual void update_dSdbMultiplier();
//- Write initial volume for continuation //- Write initial volume for continuation
virtual bool writeData(Ostream& os) const; virtual bool writeData(Ostream& os) const;

View File

@ -91,7 +91,7 @@ public:
// Member Functions // Member Functions
//- Return the objective function value //- Return the objective function value
scalar J(); virtual scalar J();
//- Contribution to field sensitivities //- Contribution to field sensitivities
virtual void update_dJdb(); virtual void update_dJdb();

View File

@ -75,7 +75,7 @@ public:
// Constructors // Constructors
//- from components //- From components
objectiveTopOVolume objectiveTopOVolume
( (
const fvMesh& mesh, const fvMesh& mesh,
@ -92,7 +92,7 @@ public:
// Member Functions // Member Functions
//- Return the objective function value //- Return the objective function value
scalar J(); virtual scalar J();
//- Contribution to field sensitivities //- Contribution to field sensitivities
virtual void update_dJdb(); virtual void update_dJdb();

View File

@ -85,19 +85,19 @@ public:
//- Destructor //- Destructor
~objectiveFlowRate() = default; virtual ~objectiveFlowRate() = default;
// Member Functions // Member Functions
//- Return the objective function value //- Return the objective function value
scalar J(); virtual scalar J();
//- Update values to be added to the adjoint outlet velocity //- Update values to be added to the adjoint outlet velocity
void update_boundarydJdv(); virtual void update_boundarydJdv();
//- Update values to be added to the adjoint outlet pressure //- Update values to be added to the adjoint outlet pressure
void update_boundarydJdvn(); virtual void update_boundarydJdvn();
// Helper write functions // Helper write functions

View File

@ -92,13 +92,13 @@ public:
// Member Functions // Member Functions
//- Return the objective function value //- Return the objective function value
scalar J(); virtual scalar J();
//- Update values to be added to the adjoint outlet velocity //- Update values to be added to the adjoint outlet velocity
void update_boundarydJdv(); virtual void update_boundarydJdv();
//- Update values to be added to the adjoint outlet pressure //- Update values to be added to the adjoint outlet pressure
void update_boundarydJdvn(); virtual void update_boundarydJdvn();
// Helper write functions // Helper write functions

View File

@ -96,28 +96,28 @@ public:
// Member Functions // Member Functions
//- Return the objective function value //- Return the objective function value
scalar J(); virtual scalar J();
//- Update values to be added to the adjoint wall velocity //- Update values to be added to the adjoint wall velocity
void update_boundarydJdp(); virtual void update_boundarydJdp();
//- Update delta(n dS)/delta b multiplier //- Update delta(n dS)/delta b multiplier
void update_dSdbMultiplier(); virtual void update_dSdbMultiplier();
//- Update delta(x)/delta b multiplier //- Update delta(x)/delta b multiplier
void update_dxdbMultiplier(); virtual void update_dxdbMultiplier();
//- Update dJ/dnut multiplier //- Update dJ/dnut multiplier
void update_boundarydJdnut(); virtual void update_boundarydJdnut();
//- Update dJ/dGradU multiplier //- Update dJ/dGradU multiplier
void update_boundarydJdGradU(); virtual void update_boundarydJdGradU();
//- Return denominator, without density //- Return denominator, without density
virtual scalar denom() const; virtual scalar denom() const;
//- Return force direction //- Return force direction
const vector& forceDirection() const; virtual const vector& forceDirection() const;
}; };

View File

@ -354,20 +354,20 @@ public:
virtual bool write(const bool valid = true) const; virtual bool write(const bool valid = true) const;
//- Inline functions for checking whether pointers are set or not //- Inline functions for checking whether pointers are set or not
inline bool hasdJdv() const; inline bool hasdJdv() const noexcept;
inline bool hasdJdp() const; inline bool hasdJdp() const noexcept;
inline bool hasdJdT() const; inline bool hasdJdT() const noexcept;
inline bool hasdJdTMVar1() const; inline bool hasdJdTMVar1() const noexcept;
inline bool hasdJdTMVar2() const; inline bool hasdJdTMVar2() const noexcept;
inline bool hasBoundarydJdv() const; inline bool hasBoundarydJdv() const noexcept;
inline bool hasBoundarydJdvn() const; inline bool hasBoundarydJdvn() const noexcept;
inline bool hasBoundarydJdvt() const; inline bool hasBoundarydJdvt() const noexcept;
inline bool hasBoundarydJdp() const; inline bool hasBoundarydJdp() const noexcept;
inline bool hasBoundarydJdT() const; inline bool hasBoundarydJdT() const noexcept;
inline bool hasBoundarydJdTMVar1() const; inline bool hasBoundarydJdTMVar1() const noexcept;
inline bool hasBoundarydJdTMVar2() const; inline bool hasBoundarydJdTMVar2() const noexcept;
inline bool hasBoundarydJdnut() const; inline bool hasBoundarydJdnut() const noexcept;
inline bool hasBoundarydJdGradU() const; inline bool hasBoundarydJdGradU() const noexcept;
}; };

View File

@ -213,85 +213,85 @@ Foam::objectiveIncompressible::boundarydJdGradU()
} }
inline bool Foam::objectiveIncompressible::hasdJdv() const inline bool Foam::objectiveIncompressible::hasdJdv() const noexcept
{ {
return bool(dJdvPtr_); return bool(dJdvPtr_);
} }
inline bool Foam::objectiveIncompressible::hasdJdp() const inline bool Foam::objectiveIncompressible::hasdJdp() const noexcept
{ {
return bool(dJdpPtr_); return bool(dJdpPtr_);
} }
inline bool Foam::objectiveIncompressible::hasdJdT() const inline bool Foam::objectiveIncompressible::hasdJdT() const noexcept
{ {
return bool(dJdTPtr_); return bool(dJdTPtr_);
} }
inline bool Foam::objectiveIncompressible::hasdJdTMVar1() const inline bool Foam::objectiveIncompressible::hasdJdTMVar1() const noexcept
{ {
return bool(dJdTMvar1Ptr_); return bool(dJdTMvar1Ptr_);
} }
inline bool Foam::objectiveIncompressible::hasdJdTMVar2() const inline bool Foam::objectiveIncompressible::hasdJdTMVar2() const noexcept
{ {
return bool(dJdTMvar2Ptr_); return bool(dJdTMvar2Ptr_);
} }
inline bool Foam::objectiveIncompressible::hasBoundarydJdv() const inline bool Foam::objectiveIncompressible::hasBoundarydJdv() const noexcept
{ {
return bool(bdJdvPtr_); return bool(bdJdvPtr_);
} }
inline bool Foam::objectiveIncompressible::hasBoundarydJdvn() const inline bool Foam::objectiveIncompressible::hasBoundarydJdvn() const noexcept
{ {
return bool(bdJdvnPtr_); return bool(bdJdvnPtr_);
} }
inline bool Foam::objectiveIncompressible::hasBoundarydJdvt() const inline bool Foam::objectiveIncompressible::hasBoundarydJdvt() const noexcept
{ {
return bool(bdJdvtPtr_); return bool(bdJdvtPtr_);
} }
inline bool Foam::objectiveIncompressible::hasBoundarydJdp() const inline bool Foam::objectiveIncompressible::hasBoundarydJdp() const noexcept
{ {
return bool(bdJdpPtr_); return bool(bdJdpPtr_);
} }
inline bool Foam::objectiveIncompressible::hasBoundarydJdT() const inline bool Foam::objectiveIncompressible::hasBoundarydJdT() const noexcept
{ {
return bool(bdJdTPtr_); return bool(bdJdTPtr_);
} }
inline bool Foam::objectiveIncompressible::hasBoundarydJdTMVar1() const inline bool Foam::objectiveIncompressible::hasBoundarydJdTMVar1() const noexcept
{ {
return bool(bdJdTMvar1Ptr_); return bool(bdJdTMvar1Ptr_);
} }
inline bool Foam::objectiveIncompressible::hasBoundarydJdTMVar2() const inline bool Foam::objectiveIncompressible::hasBoundarydJdTMVar2() const noexcept
{ {
return bool(bdJdTMvar2Ptr_); return bool(bdJdTMvar2Ptr_);
} }
inline bool Foam::objectiveIncompressible::hasBoundarydJdnut() const inline bool Foam::objectiveIncompressible::hasBoundarydJdnut() const noexcept
{ {
return bool(bdJdnutPtr_); return bool(bdJdnutPtr_);
} }
inline bool Foam::objectiveIncompressible::hasBoundarydJdGradU() const inline bool Foam::objectiveIncompressible::hasBoundarydJdGradU() const noexcept
{ {
return bool(bdJdGradUPtr_); return bool(bdJdGradUPtr_);
} }

View File

@ -97,30 +97,30 @@ public:
// Member Functions // Member Functions
//- Return the objective function value //- Return the objective function value
scalar J(); virtual scalar J();
//- Update mean drag and lift values //- Update mean drag and lift values
void update_meanValues(); virtual void update_meanValues();
//- Update values to be added to the adjoint wall velocity //- Update values to be added to the adjoint wall velocity
void update_boundarydJdp(); virtual void update_boundarydJdp();
//- Update delta(n dS)/delta b multiplier //- Update delta(n dS)/delta b multiplier
void update_dSdbMultiplier(); virtual void update_dSdbMultiplier();
//- Update delta(x)/delta b multiplier //- Update delta(x)/delta b multiplier
void update_dxdbMultiplier(); virtual void update_dxdbMultiplier();
//- Update delta(x)/delta b multiplier coming directly from the //- Update delta(x)/delta b multiplier coming directly from the
//- objective //- objective
void update_dxdbDirectMultiplier(); virtual void update_dxdbDirectMultiplier();
//- Update dJ/dnut multiplier //- Update dJ/dnut multiplier
void update_boundarydJdnut(); virtual void update_boundarydJdnut();
//- Update dJ/dGradU multiplier //- Update dJ/dGradU multiplier
/* WIP /* WIP
void update_boundarydJdGradU(); virtual void update_boundarydJdGradU();
*/ */
}; };

View File

@ -116,20 +116,20 @@ public:
// Member Functions // Member Functions
//- Return the objective function value //- Return the objective function value
scalar J(); virtual scalar J();
//- Update values to be added to the adjoint outlet velocity //- Update values to be added to the adjoint outlet velocity
void update_dJdv(); virtual void update_dJdv();
//- Update field to be added to the first adjoint turbulence model PDE //- Update field to be added to the first adjoint turbulence model PDE
void update_dJdTMvar1(); virtual void update_dJdTMvar1();
//- Update field to be added to the second adjoint turbulence model PDE //- Update field to be added to the second adjoint turbulence model PDE
void update_dJdTMvar2(); virtual void update_dJdTMvar2();
//- Update field to be added to be added to volume-based //- 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(); virtual void update_divDxDbMultiplier();
//- Add source terms to the adjoint turbulence model equations //- Add source terms to the adjoint turbulence model equations
virtual void addSource(fvScalarMatrix& matrix); virtual void addSource(fvScalarMatrix& matrix);

View File

@ -97,16 +97,16 @@ public:
// Member Functions // Member Functions
//- Return the objective function value //- Return the objective function value
scalar J(); virtual scalar J();
//- Update values to be added to the adjoint outlet velocity //- Update values to be added to the adjoint outlet velocity
void update_dJdv(); virtual void update_dJdv();
//- Update field to be added to the first adjoint turbulence model PDE //- Update field to be added to the first adjoint turbulence model PDE
void update_dJdTMvar1(); virtual void update_dJdTMvar1();
//- Update field to be added to the second adjoint turbulence model PDE //- Update field to be added to the second adjoint turbulence model PDE
void update_dJdTMvar2(); virtual void update_dJdTMvar2();
//- Update div(dx/db multiplier). Volume-based sensitivity term //- Update div(dx/db multiplier). Volume-based sensitivity term
virtual void update_divDxDbMultiplier(); virtual void update_divDxDbMultiplier();

View File

@ -52,32 +52,7 @@ addToRunTimeSelectionTable
); );
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
objectivePtLosses::objectivePtLosses
(
const fvMesh& mesh,
const dictionary& dict,
const word& adjointSolverName,
const word& primalSolverName
)
:
objectiveIncompressible(mesh, dict, adjointSolverName, primalSolverName),
patches_(0),
patchPt_(0)
{
// Find inlet/outlet patches
initialize();
// Allocate boundary field pointers
bdJdpPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
bdJdvPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
bdJdvnPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
bdJdvtPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void objectivePtLosses::initialize() void objectivePtLosses::initialize()
{ {
@ -132,6 +107,33 @@ void objectivePtLosses::initialize()
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
objectivePtLosses::objectivePtLosses
(
const fvMesh& mesh,
const dictionary& dict,
const word& adjointSolverName,
const word& primalSolverName
)
:
objectiveIncompressible(mesh, dict, adjointSolverName, primalSolverName),
patches_(0),
patchPt_(0)
{
// Find inlet/outlet patches
initialize();
// Allocate boundary field pointers
bdJdpPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
bdJdvPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
bdJdvnPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
bdJdvtPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
scalar objectivePtLosses::J() scalar objectivePtLosses::J()
{ {
J_ = Zero; J_ = Zero;

View File

@ -66,6 +66,12 @@ class objectivePtLosses
scalarField patchPt_; scalarField patchPt_;
// Private Member Functions
//- Return the objectiveReportPatches
void initialize();
public: public:
//- Runtime type information //- Runtime type information
@ -90,23 +96,20 @@ public:
// Member Functions // Member Functions
//- Return the objectiveReportPatches
void initialize();
//- Return the objective function value //- Return the objective function value
scalar J(); virtual scalar J();
//- Update values to be added to the adjoint inlet velocity //- Update values to be added to the adjoint inlet velocity
void update_boundarydJdp(); virtual void update_boundarydJdp();
//- Update values to be added to the adjoint outlet velocity //- Update values to be added to the adjoint outlet velocity
void update_boundarydJdv(); virtual void update_boundarydJdv();
//- Update values to be added to the adjoint outlet pressure //- Update values to be added to the adjoint outlet pressure
void update_boundarydJdvn(); virtual void update_boundarydJdvn();
//- Update values to be added to the adjoint outlet tangential velocity //- Update values to be added to the adjoint outlet tangential velocity
void update_boundarydJdvt(); virtual void update_boundarydJdvt();
// Helper write functions // Helper write functions

View File

@ -97,14 +97,11 @@ public:
// Member Functions // Member Functions
//- Return the objectiveReportPatches
void initialize();
//- Return the objective function value //- Return the objective function value
scalar J(); virtual scalar J();
//- Update values to be added to the adjoint outlet velocity //- Update values to be added to the adjoint outlet velocity
void update_dJdv(); virtual void update_dJdv();
//- Update div( dx/db multiplier). Volume-based sensitivity term //- Update div( dx/db multiplier). Volume-based sensitivity term
virtual void update_divDxDbMultiplier(); virtual void update_divDxDbMultiplier();

View File

@ -51,32 +51,7 @@ addToRunTimeSelectionTable
); );
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
objectiveUniformityPatch::objectiveUniformityPatch
(
const fvMesh& mesh,
const dictionary& dict,
const word& adjointSolverName,
const word& primalSolverName
)
:
objectiveIncompressible(mesh, dict, adjointSolverName, primalSolverName),
patches_(),
UMean_(),
UVar_()
{
// Find inlet/outlet patches
initialize();
// Allocate boundary field pointers
bdJdvPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
bdJdvnPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
bdJdvtPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void objectiveUniformityPatch::initialize() void objectiveUniformityPatch::initialize()
{ {
@ -132,6 +107,33 @@ void objectiveUniformityPatch::initialize()
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
objectiveUniformityPatch::objectiveUniformityPatch
(
const fvMesh& mesh,
const dictionary& dict,
const word& adjointSolverName,
const word& primalSolverName
)
:
objectiveIncompressible(mesh, dict, adjointSolverName, primalSolverName),
patches_(),
UMean_(),
UVar_()
{
// Find inlet/outlet patches
initialize();
// Allocate boundary field pointers
bdJdvPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
bdJdvnPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
bdJdvtPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
scalar objectiveUniformityPatch::J() scalar objectiveUniformityPatch::J()
{ {
J_ = Zero; J_ = Zero;

View File

@ -70,6 +70,12 @@ class objectiveUniformityPatch
scalarField UVar_; scalarField UVar_;
// Private Member Functions
//- Return the objectiveReportPatches
void initialize();
public: public:
//- Runtime type information //- Runtime type information
@ -94,20 +100,17 @@ public:
// Member Functions // Member Functions
//- Return the objectiveReportPatches
void initialize();
//- Return the objective function value //- Return the objective function value
scalar J(); virtual scalar J();
//- Update values to be added to the adjoint outlet velocity //- Update values to be added to the adjoint outlet velocity
void update_boundarydJdv(); virtual void update_boundarydJdv();
//- Update values to be added to the adjoint outlet pressure //- Update values to be added to the adjoint outlet pressure
void update_boundarydJdvn(); virtual void update_boundarydJdvn();
//- Update values to be added to the adjoint outlet tangential velocity //- Update values to be added to the adjoint outlet tangential velocity
void update_boundarydJdvt(); virtual void update_boundarydJdvt();
// Helper write functions // Helper write functions

View File

@ -266,36 +266,31 @@ public:
//- Return the objective function of the optimisation cycle. //- Return the objective function of the optimisation cycle.
// This corresponds to the mean value, if it exists, or the // This corresponds to the mean value, if it exists, or the
// instantaneous value otherwise // instantaneous value otherwise
scalar JCycle(bool negate = false) const; virtual scalar JCycle(bool negate = false) const;
//- Accumulate contribution for the mean objective value //- Accumulate contribution for the mean objective value
// For steady-state runs // For steady-state runs
void accumulateJMean(solverControl& solverControl); virtual void accumulateJMean(solverControl& solverControl);
//- Accumulate contribution for the mean objective value //- Accumulate contribution for the mean objective value
// For unsteady runs // For unsteady runs
void accumulateJMean(); virtual void accumulateJMean();
//- Return the objective function weight //- Return the objective function weight
scalar weight() const; virtual scalar weight() const;
//- Return the normalization factor
const autoPtr<scalar>& normFactor() const;
//- Return the objective target value
const autoPtr<scalar>& target() const;
//- Is the objective normalized //- Is the objective normalized
bool normalize() const; virtual bool normalize() const;
//- Normalize all fields allocated by the objective //- Normalize all fields allocated by the objective
virtual void doNormalization(); virtual void doNormalization();
//- Check whether this is an objective integration time //- Check whether this is an objective integration time
bool isWithinIntegrationTime() const; virtual bool isWithinIntegrationTime() const;
//- Increment integration times //- Increment integration times
void incrementIntegrationTimes(const scalar timeSpan); virtual void incrementIntegrationTimes(const scalar timeSpan);
//- Contribution to field sensitivities //- Contribution to field sensitivities
inline const volScalarField& dJdb() const; inline const volScalarField& dJdb() const;
@ -450,22 +445,23 @@ public:
inline void setWrite(const bool shouldWrite); inline void setWrite(const bool shouldWrite);
// Inline functions for checking whether pointers are set or not // Inline functions for checking whether pointers are set or not
inline bool hasdJdb() const; inline bool hasdJdb() const noexcept;
inline bool hasdJdbField() const; inline bool hasdJdbField() const noexcept;
inline bool hasBoundarydJdb() const; inline bool hasBoundarydJdb() const noexcept;
inline bool hasdSdbMult() const; inline bool hasdSdbMult() const noexcept;
inline bool hasdndbMult() const; inline bool hasdndbMult() const noexcept;
inline bool hasdxdbMult() const; inline bool hasdxdbMult() const noexcept;
inline bool hasdxdbDirectMult() const; inline bool hasdxdbDirectMult() const noexcept;
inline bool hasBoundaryEdgeContribution() const; inline bool hasBoundaryEdgeContribution() const noexcept;
inline bool hasDivDxDbMult() const; inline bool hasDivDxDbMult() const noexcept;
inline bool hasGradDxDbMult() const; inline bool hasGradDxDbMult() const noexcept;
// Inline functions for checking whether integration times are set // Inline functions for checking whether integration times are set
inline bool hasIntegrationStartTime() const; inline bool hasIntegrationStartTime() const noexcept;
inline bool hasIntegrationEndTime() const; inline bool hasIntegrationEndTime() const noexcept;
// Set the computed status of the objective
inline void setComputed(const bool isComputed); //- Set the computed status of the objective
inline void setComputed(const bool isComputed) noexcept;
//- Return objective dictionary //- Return objective dictionary
const dictionary& dict() const; const dictionary& dict() const;

View File

@ -167,79 +167,79 @@ inline const Foam::volTensorField& Foam::objective::gradDxDbMultiplier() const
} }
inline bool Foam::objective::hasdJdb() const inline bool Foam::objective::hasdJdb() const noexcept
{ {
return bool(dJdbPtr_); return bool(dJdbPtr_);
} }
inline bool Foam::objective::hasdJdbField() const inline bool Foam::objective::hasdJdbField() const noexcept
{ {
return bool(dJdbFieldPtr_); return bool(dJdbFieldPtr_);
} }
inline bool Foam::objective::hasBoundarydJdb() const inline bool Foam::objective::hasBoundarydJdb() const noexcept
{ {
return bool(bdJdbPtr_); return bool(bdJdbPtr_);
} }
inline bool Foam::objective::hasdSdbMult() const inline bool Foam::objective::hasdSdbMult() const noexcept
{ {
return bool(bdSdbMultPtr_); return bool(bdSdbMultPtr_);
} }
inline bool Foam::objective::hasdndbMult() const inline bool Foam::objective::hasdndbMult() const noexcept
{ {
return bool(bdndbMultPtr_); return bool(bdndbMultPtr_);
} }
inline bool Foam::objective::hasdxdbMult() const inline bool Foam::objective::hasdxdbMult() const noexcept
{ {
return bool(bdxdbMultPtr_); return bool(bdxdbMultPtr_);
} }
inline bool Foam::objective::hasdxdbDirectMult() const inline bool Foam::objective::hasdxdbDirectMult() const noexcept
{ {
return bool(bdxdbDirectMultPtr_); return bool(bdxdbDirectMultPtr_);
} }
inline bool Foam::objective::hasBoundaryEdgeContribution() const inline bool Foam::objective::hasBoundaryEdgeContribution() const noexcept
{ {
return bool(bEdgeContribution_); return bool(bEdgeContribution_);
} }
inline bool Foam::objective::hasDivDxDbMult() const inline bool Foam::objective::hasDivDxDbMult() const noexcept
{ {
return bool(divDxDbMultPtr_); return bool(divDxDbMultPtr_);
} }
inline bool Foam::objective::hasGradDxDbMult() const inline bool Foam::objective::hasGradDxDbMult() const noexcept
{ {
return bool(gradDxDbMultPtr_); return bool(gradDxDbMultPtr_);
} }
inline bool Foam::objective::hasIntegrationStartTime() const inline bool Foam::objective::hasIntegrationStartTime() const noexcept
{ {
return bool(integrationStartTimePtr_); return bool(integrationStartTimePtr_);
} }
inline bool Foam::objective::hasIntegrationEndTime() const inline bool Foam::objective::hasIntegrationEndTime() const noexcept
{ {
return bool(integrationEndTimePtr_); return bool(integrationEndTimePtr_);
} }
inline void Foam::objective::setComputed(const bool isComputed) inline void Foam::objective::setComputed(const bool isComputed) noexcept
{ {
computed_ = isComputed; computed_ = isComputed;
} }

View File

@ -73,7 +73,7 @@ protected:
//- Which of the design variables will be updated //- Which of the design variables will be updated
labelList activeDesignVariables_; labelList activeDesignVariables_;
//- Copy of old design variables. Usefull when performing line-search //- Copy of old design variables. Useful when performing line-search
autoPtr<scalarField> oldDesignVariables_; autoPtr<scalarField> oldDesignVariables_;
//- Maximum design variables' change in the first optimisation cycle //- Maximum design variables' change in the first optimisation cycle

View File

@ -119,7 +119,7 @@ tmp<scalarField> sigmoidalHeaviside::derivative(const scalarField& arg) const
const scalar pi = constant::mathematical::pi; const scalar pi = constant::mathematical::pi;
scalarField argLimited(max(min(dNB_, arg), -dNB_)); scalarField argLimited(max(min(dNB_, arg), -dNB_));
DebugInfo DebugInfo
<< type() << "::interpolate:: t, dNB " << t << ", " << dNB_ << endl; << type() << "::derivative:: t, dNB " << t << ", " << dNB_ << endl;
deriv = 0.5*(scalar(1) + cos(pi*argLimited/dNB_))/dNB_; deriv = 0.5*(scalar(1) + cos(pi*argLimited/dNB_))/dNB_;

View File

@ -43,14 +43,14 @@ Description
\endverbatim \endverbatim
The implemented approach borrows from the references therein, but does not The implemented approach borrows from the references therein, but does not
follow any of them exactly. The underlaying field of the design variables follow any of them exactly. The underlying field of the design variables
is not the level-set field but affects the latter through: is not the level-set field but affects the latter through:
a) a regularisation approach similar to that used in porosity-based topO a) a regularisation approach similar to that used in porosity-based topO
(see the regularisation class and references therein) and (see the regularisation class and references therein) and
b) a re-initialisation strategy. Since solving a modified Hamilton-Jacobi b) a re-initialisation strategy. Since solving a modified Hamilton-Jacobi
equation poses a number of numerical challenges, the signed distance field equation poses a number of numerical challenges, the signed distance field
is obtained by identifying the zero level-set contour using the is obtained by identifying the zero level-set contour using the
cutFaceIso, cutCellIso infrastucture (see references therein for the cutFaceIso, cutCellIso infrastructure (see references therein for the
methodology) and using these "cut-faces" as seeds for meshWave. methodology) and using these "cut-faces" as seeds for meshWave.
SourceFiles SourceFiles
@ -96,7 +96,7 @@ protected:
//- into signed distances //- into signed distances
volScalarField aTilda_; volScalarField aTilda_;
//- Function to transorm signed distances to the indicator field beta_ //- Function to transform signed distances to the indicator field beta_
autoPtr<topOInterpolationFunction> interpolation_; autoPtr<topOInterpolationFunction> interpolation_;
//- The indicator field //- The indicator field
@ -105,7 +105,7 @@ protected:
//- Fix aTilda values in fixed{Zero}PorousZones and IOcells //- Fix aTilda values in fixed{Zero}PorousZones and IOcells
bool fixATildaValues_; bool fixATildaValues_;
//- Write all fields related to the distance calculation (debuging) //- Write all fields related to the distance calculation (debugging)
bool writeAllDistanceFields_; bool writeAllDistanceFields_;

View File

@ -86,7 +86,7 @@ Foam::dynamicTopODesignVariables::dynamicTopODesignVariables
topODesignVariables(mesh, dict, size), topODesignVariables(mesh, dict, size),
marchCells_(mesh, dict.subDict("marchingCoeffs")) marchCells_(mesh, dict.subDict("marchingCoeffs"))
{ {
// Rest of the contrsuctor initialization // Rest of the constructor initialization
initialize(); initialize();
} }
@ -100,10 +100,7 @@ Foam::dynamicTopODesignVariables::New
const dictionary& dict const dictionary& dict
) )
{ {
return autoPtr<dynamicTopODesignVariables> return autoPtr<dynamicTopODesignVariables>::New(mesh, dict);
(
new dynamicTopODesignVariables(mesh, dict)
);
} }

View File

@ -100,8 +100,7 @@ Foam::fieldRegularisation::fieldRegularisation
) )
{ {
DebugInfo DebugInfo
<< "Regularise " << Switch(regularise_) << endl; << "Regularise " << Switch(regularise_) << nl
DebugInfo
<< "Project " << Switch(project_) << endl; << "Project " << Switch(project_) << endl;
} }
@ -160,7 +159,7 @@ void Foam::fieldRegularisation::postProcessSens(scalarField& sens)
{ {
sens *= sharpenFunction_->derivative(betaArg_); sens *= sharpenFunction_->derivative(betaArg_);
} }
// Add part due to regulatisation // Add part due to regularisation
if (regularise_) if (regularise_)
{ {
// Solve the adjoint to the regularisation equation // Solve the adjoint to the regularisation equation

View File

@ -69,7 +69,6 @@ private:
protected: protected:
// Protected Data // Protected Data
//- Solve the regularisationPDE only on a subset mesh made of the //- Solve the regularisationPDE only on a subset mesh made of the

View File

@ -1,3 +1,4 @@
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox

View File

@ -174,7 +174,7 @@ void Foam::topODesignVariables::setActiveDesignVariables
label varI(activeDesignVariables_.size()); label varI(activeDesignVariables_.size());
activeDesignVariables_.setSize(offset + mesh_.nCells(), -1); activeDesignVariables_.setSize(offset + mesh_.nCells(), -1);
// Set active design variables // Set active design variables
// If specific porosity zones are perscribed, use them directly // If specific porosity zones are prescribed, use them directly
if (!zones_.adjointPorousZoneIDs().empty()) if (!zones_.adjointPorousZoneIDs().empty())
{ {
for (label cellZoneID : zones_.adjointPorousZoneIDs()) for (label cellZoneID : zones_.adjointPorousZoneIDs())
@ -346,10 +346,7 @@ Foam::autoPtr<Foam::topODesignVariables> Foam::topODesignVariables::New
const dictionary& dict const dictionary& dict
) )
{ {
return autoPtr<topODesignVariables> return autoPtr<topODesignVariables>::New(mesh, dict);
(
new topODesignVariables(mesh, dict)
);
} }

View File

@ -81,7 +81,7 @@ protected:
// Protected data // Protected data
//- A subfield of the design variables correponding to the porosity //- A subfield of the design variables corresponding to the porosity
//- field. //- field.
// Usually the same as *this // Usually the same as *this
SubField<scalar> alpha_; SubField<scalar> alpha_;

View File

@ -66,7 +66,7 @@ protected:
// Protected data // Protected data
//- Cell zones usefull for defining the constant and changing parts //- Cell zones useful for defining the constant and changing parts
//- of the domain in topO //- of the domain in topO
topOZones zones_; topOZones zones_;
@ -206,7 +206,7 @@ public:
// field // field
// - 0 distance contour for levelSet or // - 0 distance contour for levelSet or
// - 0.5 beta contour for porosity-based topO. // - 0.5 beta contour for porosity-based topO.
// For levelSet topO, the process of identitying the contour sets also // For levelSet topO, the process of identifying the contour sets also
// the seeds for computing the distance field in the entire domain // the seeds for computing the distance field in the entire domain
void writeFluidSolidInterface void writeFluidSolidInterface
( (

View File

@ -89,7 +89,7 @@ protected:
//- Get zone IDs corresponding to a wordList, read from a dict. //- Get zone IDs corresponding to a wordList, read from a dict.
// Avoid going through ZoneMesh.indices() since this practically sorts // Avoid going through ZoneMesh.indices() since this practically sorts
// the IDs from smallest to largest while we need to keep them in the // the IDs from smallest to largest while we need to keep them in the
// same order as that perscribed in the wordList // same order as that prescribed in the wordList
labelList getZoneIDs(const dictionary& dict, const word& zoneGroup); labelList getZoneIDs(const dictionary& dict, const word& zoneGroup);
//- Add a cellZone containing the cells next to IO patches //- Add a cellZone containing the cells next to IO patches

View File

@ -167,7 +167,7 @@ void Foam::incompressiblePrimalSolver::correctBoundaryConditions()
// including averaged ones, if present // including averaged ones, if present
vars.correctBoundaryConditions(); vars.correctBoundaryConditions();
// phi cannot be updated through correctBoundayrConditions. // phi cannot be updated through correctBoundaryConditions.
// Re-compute based on the Rhie-Chow interpolation scheme. // Re-compute based on the Rhie-Chow interpolation scheme.
// This is a non-linear process // This is a non-linear process
// (phi depends on UEqn().A() which depends on phi) // (phi depends on UEqn().A() which depends on phi)