Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #pragma once 11 : 12 : #include "ElementUserObject.h" 13 : #include "MooseTypes.h" 14 : 15 : /** 16 : * Element user object that performs SIMP optimization using a bisection algorithm using a volume 17 : * constraint. 18 : */ 19 : class DensityUpdate : public ElementUserObject 20 : { 21 : public: 22 : static InputParameters validParams(); 23 : 24 : DensityUpdate(const InputParameters & parameters); 25 : 26 512 : virtual void initialize() override{}; 27 : virtual void timestepSetup() override; 28 : virtual void execute() override; 29 422 : virtual void finalize() override{}; 30 90 : virtual void threadJoin(const UserObject &) override{}; 31 : 32 : protected: 33 : /// The system mesh 34 : const MooseMesh & _mesh; 35 : /// The name of the pseudo-density variable 36 : const VariableName _design_density_name; 37 : /// The elasticity compliance sensitivity name 38 : const VariableName _density_sensitivity_name; 39 : /// The pseudo-density variable 40 : MooseWritableVariable * _design_density; 41 : /// The filtered density sensitivity variable 42 : const MooseWritableVariable * _density_sensitivity; 43 : /// The volume fraction to be enforced 44 : const Real _volume_fraction; 45 : 46 : private: 47 : struct ElementData 48 : { 49 : Real old_density; 50 : Real sensitivity; 51 : Real volume; 52 : Real new_density; 53 : ElementData() = default; 54 : ElementData(Real dens, Real sens, Real vol, Real filt_dens) 55 : : old_density(dens), sensitivity(sens), volume(vol), new_density(filt_dens) 56 : { 57 : } 58 : }; 59 : 60 : /** 61 : * Gathers element date necessary to perform the bisection algorithm for optimization 62 : */ 63 : void gatherElementData(); 64 : 65 : /** 66 : * Performs the optimality criterion loop (bisection) 67 : */ 68 : void performOptimCritLoop(); 69 : 70 : Real computeUpdatedDensity(Real current_density, Real dc, Real lmid); 71 : 72 : /// Total volume allowed for volume contraint 73 : Real _total_allowable_volume; 74 : 75 : /// Data structure to hold old density, sensitivity, volume, current density. 76 : std::map<dof_id_type, ElementData> _elem_data_map; 77 : 78 : /// Lower bound for bisection algorithm 79 : const Real _lower_bound; 80 : /// Upper bound for bisection algorithm 81 : const Real _upper_bound; 82 : };