Filter Wrapper

class FilterWrapper

Class used to abstract filtering 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 FilterWrapper()

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.

FilterWrapper(Filter *filter, PetscInt numConstraints)

Correct constructor to use.

Parameters:
  • filter – Topopt filter object to be abstracted.

  • numConstraints – Initialized by the TopOpt class: TopOpt::m.

virtual PetscErrorCode filterDesignVariable(Vec unfiltered, Vec filtered)

Applies the Topopt standard filter to the given design variables.

Warning

Unfiltered and filtered must be different objects (Petsc limitation). ie cannot call FilterWrapper::filterDesignVariable(y, y).

Parameters:
  • unfiltered – the design variable to filter.

  • filtered – [out] filtered positions. Must be identical settings to unfiltered Vec.

Returns:

0 on success, PetscError otherwise.

virtual PetscErrorCode filterSensitivities(Vec position, Vec sensitivities, Vec *constraintSensitivities)

Applies the Topopt standard gradient filter to the provided sensitivities.

Parameters:
  • position – Position vector, should typically be filtered before using.

  • sensitivities – [in/out] The sensitivities to filter. Function will overwrite this variable with the filtered result.

  • constraintSensitivities – [in/out] The constraint sensitivities to filter. Function will overwrite this variable with the filtered result. Should just be passed by reference, not an array.

Returns:

0 on success, PetscError otherwise.

Private Members

Filter *filter
PetscInt numConstraints