SensitivitiesWrapper
-
class SensitivitiesWrapper
Class used to abstract sensitivities and objective functions from the hyperoptimization class.
Any inherited class can be used in lieu of this class when initializing hyperoptimization. Instances are passed by reference, so any virtual functions in the derived class which overwrite the ones provided here will be called by the design loop.
Public Functions
-
inline SensitivitiesWrapper()
Empty constructor to allow passing by reference.
Warning
Do not instantiate using this constructor! This is only provided as a means to pass by reference to the Hyperoptimization class.
-
inline SensitivitiesWrapper(LinearElasticity *physics, PetscScalar Emin, PetscScalar Emax, PetscScalar penal, PetscScalar volfrac)
Correct constructor to use.
- Parameters:
physics – Topopt filter object to be abstracted.
Emin – used in the LinearElasticity AssembleStiffnessMatrix function.
Emax – used in the LinearElasticity AssembleStiffnessMatrix function.
penal – optimization penalty power.
volfrac – volume fraction.
-
inline PetscInt getSolverIterationCount()
Accessor for the Petsc solver iteration count.
This is updated every time computeSensitivities or computeObjectiveFunction is called.
- Returns:
the number of iterations needed for the last finite element analysis calculation.
-
virtual PetscErrorCode computeSensitivities(Vec filteredPositions, Vec sensitivities, Vec constraintSensitivities)
Wraps the LinearElasticity::ComputeSensitivities function.
This solves the finite element analysis problem required to calcualte the sensitivities and constraint sensitivities.
- Parameters:
filteredPositions – filtered design particle position vector.
sensitivities – [out] resulting sensitivities vector.
constraintSensitivities – [out] resulting constraint sensitivities vector.
- Returns:
0 on success, PetscError otherwise.
-
virtual PetscErrorCode computeObjectiveFunction(Vec filteredPositions, PetscScalar *objectiveFunction)
Wraps the LinearElasticity::ComputeObjectiveConstraints function.
Note that the constraints are also calculated, but not used or returned. The finite element analysis is calculated here too, which is the bottleneck in most hyperoptimization applications.
- Parameters:
filteredPositions – filtered design particle position vector.
objectiveFunction – [out] the resulting objective function.
- Returns:
0 on success, PetscError otherwise.
-
inline SensitivitiesWrapper()