Loading...
Searching...
No Matches
ShapeSensitivitiesBase Class Reference

Base class supporting Shape sensitivity derivatives. More...

#include <ShapeSensitivitiesBase.H>

Inheritance diagram for ShapeSensitivitiesBase:
Collaboration diagram for ShapeSensitivitiesBase:

Public Member Functions

 TypeName ("ShapeSensitivitiesBase")
 Runtime type information.
 ShapeSensitivitiesBase (const fvMesh &mesh, const dictionary &dict, adjointSolver &adjointSolver)
 Construct from components.
virtual ~ShapeSensitivitiesBase ()=default
 Destructor.
virtual bool readDict (const dictionary &dict)
 Read dict if changed.
const labelHashSetsensitivityPatchIDs () const
 Get patch IDs on which sensitivities are computed.
void setSensitivityPatchIDs (const labelHashSet &sensPatchIDs)
 Overwrite sensitivityPatchIDs.
virtual const labelHashSetgeometryVariationIntegrationPatches () const
 Return set of patches on which to compute direct sensitivities.
virtual void accumulateIntegrand (const scalar dt)
 Accumulate sensitivity integrands.
void clearSensitivities ()
 Zero sensitivity fields and their constituents.
virtual void write (const word &baseName=word::null)
 Write sensitivity fields.
tmp< volVectorFieldgetWallFaceSensVec ()
 Get wall face sensitivity vectors field.
tmp< volScalarFieldgetWallFaceSensNormal ()
 Get wall face sensitivity projected to normal field.
tmp< volVectorFieldgetWallFaceSensNormalVec ()
 Get wall face normal sens as vectors field.
tmp< pointVectorFieldgetWallPointSensVec ()
 Get wall point sensitivity vectors field.
tmp< pointScalarFieldgetWallPointSensNormal ()
 Get wall point sensitivity projected to normal field.
tmp< pointVectorFieldgetWallPointSensNormalVec ()
 Get wall point sens as vectors field.
virtual const boundaryVectorFieldgetWallFaceSensVecBoundary () const
 Get wall face sensitivity vectors field.
virtual const boundaryScalarFieldgetWallFaceSensNormalBoundary () const
 Get wall face sensitivity projected to normal field.
virtual const boundaryVectorFieldgetWallFaceSensNormalVecBoundary () const
 Get wall face normal sens as vectors field.
Public Member Functions inherited from adjointSensitivity
 TypeName ("adjointSensitivity")
 Runtime type information.
 declareRunTimeSelectionTable (autoPtr, adjointSensitivity, dictionary,(const fvMesh &mesh, const dictionary &dict, adjointSolver &adjointSolver),(mesh, dict, adjointSolver))
 adjointSensitivity (const fvMesh &mesh, const dictionary &dict, adjointSolver &adjointSolver)
 Construct from components.
virtual ~adjointSensitivity ()=default
 Destructor.
const adjointSolvergetAdjointSolver () const
 Const access to adjoint solver.
adjointSolvergetAdjointSolver ()
 Non-const access to adjoint solver.
bool includeDistance () const
 Should the adjoint eikonal PDE should be solved.
autoPtr< adjointEikonalSolver > & getAdjointEikonalSolver ()
 Return the adjoint eikonal solver.
autoPtr< adjointMeshMovementSolver > & getAdjointMeshMovementSolver ()
 Return the adjoint eikonal solver.
void setSuffix (const word &suffix)
 Set suffix.
const wordgetSuffix () const
 Get suffix.
virtual bool computeDxDbInternalField () const
 Should the parameterization compute the internalField of dxdb.
virtual void assembleSensitivities (autoPtr< designVariables > &designVars)
 Assemble sensitivities.
virtual const scalarFieldcalculateSensitivities (autoPtr< designVariables > &designVars)
 Calculates and returns sensitivity fields.
const scalarFieldgetSensitivities () const
 Returns the sensitivity fields.
const autoPtr< volTensorField > & gradDxDbMult () const
autoPtr< volTensorField > & gradDxDbMult ()
const autoPtr< scalarField > & divDxDbMult () const
const autoPtr< boundaryVectorField > & dxdbMult () const
const autoPtr< boundaryVectorField > & dSfdbMult () const
const autoPtr< boundaryVectorField > & dnfdbMult () const
const autoPtr< boundaryVectorField > & dxdbDirectMult () const
const autoPtr< pointBoundaryVectorField > & pointDxDbDirectMult () const
const autoPtr< boundaryVectorField > & bcDxDbMult () const
const autoPtr< vectorField > & optionsDxDbMult () const
Public Member Functions inherited from sensitivity
 TypeName ("sensitivity")
 Runtime type information.
 sensitivity (const fvMesh &mesh, const dictionary &dict)
 Construct from components.
virtual ~sensitivity ()=default
 Destructor.
const fvMeshmesh () const
 Return reference to mesh.
const dictionarydict () const
 Return the construction dictionary.
const autoPtr< volScalarField > & fieldSensPtr () const
 Get the fieldSensPtr.

Protected Member Functions

void allocateEikonalSolver ()
 Allocate the adjoint eikonal solver.
bool hasMultiplier (bool(objective::*hasFunction)() const)
 Check if any of the available objective has a certain multiplier, provided through a function object.
template<class Type>
void constructAndWriteSensitivityField (const autoPtr< typename GeometricField< Type, fvPatchField, volMesh >::Boundary > &sensFieldPtr, const word &name) const
 Constructs volField based on boundaryField and writes it.
template<class Type>
void constructAndWriteSensitivtyPointField (const autoPtr< List< Field< Type > > > &sensFieldPtr, const word &name) const
 Constructs pointField based on boundaryField and writes it.
template<class Type>
tmp< GeometricField< Type, fvPatchField, volMesh > > constructVolSensitivtyField (const autoPtr< typename GeometricField< Type, fvPatchField, volMesh >::Boundary > &sensFieldPtr, const word &name) const
 Constructs volField based on boundaryField and writes it.
void writeFaceBasedSens () const
 Write face-based sensitivities, if present.
void writePointBasedSens () const
 Write point-based sensitivities, if present.
void clearSurfaceFields ()
 Clear surface/point fields.
void allocateMultipliers ()
 Allocate multiplier fields.
void clearMultipliers ()
 Clear multipliers.

Protected Attributes

labelHashSet sensitivityPatchIDs_
 Patches on which to compute shape sensitivities.
bool writeAllSurfaceFiles_
 Whether to write all surface sensitivity fields.
autoPtr< boundaryVectorFieldwallFaceSensVecPtr_
 Wall face sens w.r.t. (x,y.z).
autoPtr< boundaryScalarFieldwallFaceSensNormalPtr_
 Wall face sens projected to normal.
autoPtr< boundaryVectorFieldwallFaceSensNormalVecPtr_
 Normal sens as vectors.
autoPtr< pointBoundaryVectorFieldwallPointSensVecPtr_
 Wall point sens w.r.t. (x,y.z).
autoPtr< pointBoundaryScalarFieldwallPointSensNormalPtr_
 Wall point sens projected to normal.
autoPtr< pointBoundaryVectorFieldwallPointSensNormalVecPtr_
 Normal sens as vectors.
Protected Attributes inherited from adjointSensitivity
adjointSolveradjointSolver_
 Reference to the underlaying adjoint solver.
scalarField derivatives_
 The sensitivity derivative values.
word suffix_
 Append this word to files related to the sensitivities.
bool includeDistance_
 Include distance variation in sensitivity computations.
autoPtr< adjointEikonalSolvereikonalSolver_
 Adjoint eikonal equation solver.
autoPtr< adjointMeshMovementSolveradjointMeshMovementSolver_
 Adjoint grid displacement solver.
autoPtr< volTensorFieldgradDxDbMult_
 Multiplier of grad(dx/b).
autoPtr< scalarFielddivDxDbMult_
 Multiplier of div(dx/db).
autoPtr< boundaryVectorFielddxdbMult_
 Multiplier of face dx/db.
autoPtr< boundaryVectorFielddSfdbMult_
 Multiplier of dSf/db.
autoPtr< boundaryVectorFielddnfdbMult_
 Multiplier of dnf/db.
autoPtr< boundaryVectorFielddxdbDirectMult_
 Multiplier of dCf/db, found in the objective function.
autoPtr< pointBoundaryVectorFieldpointDxDbDirectMult_
 Multiplier of dx/db computed at points, found in the objective function.
autoPtr< boundaryVectorFieldbcDxDbMult_
 Multiplier of dx/db, coming from boundary conditions that depend on the geometry, like rotatingWallVelocity.
autoPtr< vectorFieldoptionsDxDbMult_
 dx/db multiplier coming from fvOptions
Protected Attributes inherited from sensitivity
const fvMeshmesh_
dictionary dict_
bool writeFieldSens_
autoPtr< volScalarFieldfieldSensPtr_

Additional Inherited Members

Static Public Member Functions inherited from adjointSensitivity
static autoPtr< adjointSensitivity > New (const fvMesh &mesh, const dictionary &dict, adjointSolver &adjointSolver)
 Return a reference to the selected turbulence model.

Detailed Description

Base class supporting Shape sensitivity derivatives.

Reference:

    For the FI formulation see
        Kavvadias, I., Papoutsis-Kiachagias, E., & Giannakoglou, K. (2015).
        On the proper treatment of grid sensitivities in continuous adjoint
        methods for shape optimization.
        Journal of Computational Physics, 301, 1–18.
        http://doi.org/10.1016/j.jcp.2015.08.012

    The ESI formulation is derived in a slightly different way than the
    one described in this paper, to provide a common mathematical
    formulation for both low- and high-Re meshes and to produce numerically
    identical results as the FI formulation. In brief, the boundary-bound
    part of the sensitivities is the patchInternalField of the tensor
    multiplying grad(dxdb) in the FI formulation.
Source files

Definition at line 75 of file ShapeSensitivitiesBase.H.

Constructor & Destructor Documentation

◆ ShapeSensitivitiesBase()

◆ ~ShapeSensitivitiesBase()

virtual ~ShapeSensitivitiesBase ( )
virtualdefault

Destructor.

References sensitivity::dict().

Here is the call graph for this function:

Member Function Documentation

◆ allocateEikonalSolver()

void allocateEikonalSolver ( )
protected

Allocate the adjoint eikonal solver.

Definition at line 39 of file ShapeSensitivitiesBase.C.

References adjointSensitivity::adjointSolver_, sensitivity::dict(), adjointSensitivity::eikonalSolver_, geometryVariationIntegrationPatches(), adjointSensitivity::includeDistance_, and sensitivity::mesh_.

Referenced by readDict(), and ShapeSensitivitiesBase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasMultiplier()

bool hasMultiplier ( bool(objective::* hasFunction )() const)
protected

Check if any of the available objective has a certain multiplier, provided through a function object.

Definition at line 58 of file ShapeSensitivitiesBase.C.

References adjointSensitivity::adjointSolver_.

Referenced by allocateMultipliers(), and sensitivityShapeESI::sensitivityShapeESI().

Here is the caller graph for this function:

◆ constructAndWriteSensitivityField()

template<class Type>
void constructAndWriteSensitivityField ( const autoPtr< typename GeometricField< Type, fvPatchField, volMesh >::Boundary > & sensFieldPtr,
const word & name ) const
protected

Constructs volField based on boundaryField and writes it.

Definition at line 33 of file ShapeSensitivitiesBaseTemplates.C.

References GeometricField< Type, PatchField, GeoMesh >::boundaryFieldRef(), Foam::dimless, sensitivity::mesh_, Foam::name(), IOobjectOption::NO_READ, IOobjectOption::NO_WRITE, sensitivityPatchIDs_, regIOobject::write(), and Foam::Zero.

Referenced by writeFaceBasedSens().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ constructAndWriteSensitivtyPointField()

template<class Type>
void constructAndWriteSensitivtyPointField ( const autoPtr< List< Field< Type > > > & sensFieldPtr,
const word & name ) const
protected

◆ constructVolSensitivtyField()

template<class Type>
tmp< GeometricField< Type, fvPatchField, volMesh > > constructVolSensitivtyField ( const autoPtr< typename GeometricField< Type, fvPatchField, volMesh >::Boundary > & sensFieldPtr,
const word & name ) const
protected

Constructs volField based on boundaryField and writes it.

Definition at line 105 of file ShapeSensitivitiesBaseTemplates.C.

References GeometricField< Type, PatchField, GeoMesh >::boundaryFieldRef(), forAll, sensitivity::mesh_, Foam::name(), IOobjectOption::NO_READ, IOobjectOption::NO_WRITE, tmp< T >::ref(), and sensitivityPatchIDs_.

Referenced by getWallFaceSensNormal(), getWallFaceSensNormalVec(), and getWallFaceSensVec().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeFaceBasedSens()

void writeFaceBasedSens ( ) const
protected

Write face-based sensitivities, if present.

Definition at line 74 of file ShapeSensitivitiesBase.C.

References constructAndWriteSensitivityField(), adjointSensitivity::suffix_, wallFaceSensNormalPtr_, wallFaceSensNormalVecPtr_, wallFaceSensVecPtr_, and writeAllSurfaceFiles_.

Referenced by write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writePointBasedSens()

void writePointBasedSens ( ) const
protected

Write point-based sensitivities, if present.

Definition at line 111 of file ShapeSensitivitiesBase.C.

References constructAndWriteSensitivtyPointField(), adjointSensitivity::suffix_, wallPointSensNormalPtr_, wallPointSensNormalVecPtr_, wallPointSensVecPtr_, and writeAllSurfaceFiles_.

Referenced by write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearSurfaceFields()

void clearSurfaceFields ( )
protected

Clear surface/point fields.

Definition at line 151 of file ShapeSensitivitiesBase.C.

References wallFaceSensNormalPtr_, wallFaceSensNormalVecPtr_, wallFaceSensVecPtr_, wallPointSensNormalPtr_, wallPointSensNormalVecPtr_, wallPointSensVecPtr_, and VectorSpace< Form, Cmpt, Ncmpts >::zero.

Referenced by clearSensitivities().

Here is the caller graph for this function:

◆ allocateMultipliers()

◆ clearMultipliers()

◆ TypeName()

TypeName ( "ShapeSensitivitiesBase" )

Runtime type information.

References sensitivity::dict(), and sensitivity::mesh().

Here is the call graph for this function:

◆ readDict()

bool readDict ( const dictionary & dict)
virtual

◆ sensitivityPatchIDs()

const labelHashSet & sensitivityPatchIDs ( ) const
inline

Get patch IDs on which sensitivities are computed.

Definition at line 262 of file ShapeSensitivitiesBase.H.

References sensitivityPatchIDs_.

◆ setSensitivityPatchIDs()

void setSensitivityPatchIDs ( const labelHashSet & sensPatchIDs)
inline

Overwrite sensitivityPatchIDs.

Definition at line 270 of file ShapeSensitivitiesBase.H.

References sensitivityPatchIDs_.

◆ geometryVariationIntegrationPatches()

const Foam::labelHashSet & geometryVariationIntegrationPatches ( ) const
virtual

Return set of patches on which to compute direct sensitivities.

Reimplemented in sensitivitySurfacePoints.

Definition at line 340 of file ShapeSensitivitiesBase.C.

References sensitivityPatchIDs_.

Referenced by accumulateIntegrand(), allocateEikonalSolver(), and sensitivityShapeESI::computeDxDbMult().

Here is the caller graph for this function:

◆ accumulateIntegrand()

◆ clearSensitivities()

void clearSensitivities ( )
virtual

Zero sensitivity fields and their constituents.

Reimplemented from adjointSensitivity.

Definition at line 380 of file ShapeSensitivitiesBase.C.

References clearMultipliers(), adjointSensitivity::clearSensitivities(), and clearSurfaceFields().

Here is the call graph for this function:

◆ write()

void write ( const word & baseName = word::null)
virtual

Write sensitivity fields.

If valid, copies boundaryFields to volFields and writes them.

Reimplemented from adjointSensitivity.

Reimplemented in sensitivitySurfacePoints.

Definition at line 388 of file ShapeSensitivitiesBase.C.

References adjointSensitivity::write(), writeFaceBasedSens(), and writePointBasedSens().

Referenced by sensitivitySurfacePoints::write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getWallFaceSensVec()

Foam::tmp< Foam::volVectorField > getWallFaceSensVec ( )

Get wall face sensitivity vectors field.

Definition at line 397 of file ShapeSensitivitiesBase.C.

References constructVolSensitivtyField(), Foam::createZeroFieldPtr(), Foam::dimless, Foam::endl(), sensitivity::mesh_, adjointSensitivity::suffix_, wallFaceSensVecPtr_, and WarningInFunction.

Referenced by getWallPointSensVec().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getWallFaceSensNormal()

Foam::tmp< Foam::volScalarField > getWallFaceSensNormal ( )

Get wall face sensitivity projected to normal field.

Definition at line 428 of file ShapeSensitivitiesBase.C.

References constructVolSensitivtyField(), Foam::createZeroFieldPtr(), Foam::dimless, Foam::endl(), sensitivity::mesh_, adjointSensitivity::suffix_, wallFaceSensNormalPtr_, and WarningInFunction.

Referenced by getWallPointSensNormal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getWallFaceSensNormalVec()

Foam::tmp< Foam::volVectorField > getWallFaceSensNormalVec ( )

Get wall face normal sens as vectors field.

Definition at line 458 of file ShapeSensitivitiesBase.C.

References constructVolSensitivtyField(), Foam::createZeroFieldPtr(), Foam::dimless, Foam::endl(), sensitivity::mesh_, adjointSensitivity::suffix_, wallFaceSensNormalVecPtr_, and WarningInFunction.

Referenced by getWallPointSensNormalVec().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getWallPointSensVec()

Foam::tmp< Foam::pointVectorField > getWallPointSensVec ( )

Get wall point sensitivity vectors field.

Uses volPointInterpolation

Definition at line 490 of file ShapeSensitivitiesBase.C.

References getWallFaceSensVec(), volPointInterpolation::interpolate(), and sensitivity::mesh_.

Here is the call graph for this function:

◆ getWallPointSensNormal()

Foam::tmp< Foam::pointScalarField > getWallPointSensNormal ( )

Get wall point sensitivity projected to normal field.

Uses volPointInterpolation

Definition at line 500 of file ShapeSensitivitiesBase.C.

References getWallFaceSensNormal(), volPointInterpolation::interpolate(), and sensitivity::mesh_.

Here is the call graph for this function:

◆ getWallPointSensNormalVec()

Foam::tmp< Foam::pointVectorField > getWallPointSensNormalVec ( )

Get wall point sens as vectors field.

Uses volPointInterpolation

Definition at line 510 of file ShapeSensitivitiesBase.C.

References getWallFaceSensNormalVec(), volPointInterpolation::interpolate(), and sensitivity::mesh_.

Here is the call graph for this function:

◆ getWallFaceSensVecBoundary()

const Foam::boundaryVectorField & getWallFaceSensVecBoundary ( ) const
virtual

Get wall face sensitivity vectors field.

Definition at line 520 of file ShapeSensitivitiesBase.C.

References wallFaceSensVecPtr_.

◆ getWallFaceSensNormalBoundary()

const Foam::boundaryScalarField & getWallFaceSensNormalBoundary ( ) const
virtual

Get wall face sensitivity projected to normal field.

Definition at line 527 of file ShapeSensitivitiesBase.C.

References wallFaceSensNormalPtr_.

◆ getWallFaceSensNormalVecBoundary()

const Foam::boundaryVectorField & getWallFaceSensNormalVecBoundary ( ) const
virtual

Get wall face normal sens as vectors field.

Definition at line 534 of file ShapeSensitivitiesBase.C.

References wallFaceSensNormalVecPtr_.

Member Data Documentation

◆ sensitivityPatchIDs_

◆ writeAllSurfaceFiles_

bool writeAllSurfaceFiles_
protected

Whether to write all surface sensitivity fields.

Definition at line 92 of file ShapeSensitivitiesBase.H.

Referenced by readDict(), ShapeSensitivitiesBase(), writeFaceBasedSens(), and writePointBasedSens().

◆ wallFaceSensVecPtr_

◆ wallFaceSensNormalPtr_

◆ wallFaceSensNormalVecPtr_

◆ wallPointSensVecPtr_

◆ wallPointSensNormalPtr_

◆ wallPointSensNormalVecPtr_


The documentation for this class was generated from the following files:
  • src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/adjointSensitivity/shape/shapeSensitivityBase/ShapeSensitivitiesBase.H
  • src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/adjointSensitivity/shape/shapeSensitivityBase/ShapeSensitivitiesBase.C
  • src/optimisation/adjointOptimisation/adjoint/optimisation/adjointSensitivity/adjointSensitivity/shape/shapeSensitivityBase/ShapeSensitivitiesBaseTemplates.C