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 applying a volume 17 : * constraint and a cost constraint. 18 : */ 19 : class DensityUpdateTwoConstraints : public ElementUserObject 20 : { 21 : public: 22 : static InputParameters validParams(); 23 : 24 : DensityUpdateTwoConstraints(const InputParameters & parameters); 25 : 26 104 : virtual void initialize() override{}; 27 : virtual void timestepSetup() override; 28 : virtual void execute() override; 29 86 : virtual void finalize() override{}; 30 18 : 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 : const VariableName _cost_density_sensitivity_name; 40 : const VariableName _cost_name; 41 : /// The pseudo-density variable 42 : 43 : MooseWritableVariable * _design_density; 44 : /// The filtered density sensitivity variable (elasticity) 45 : const MooseWritableVariable * _density_sensitivity; 46 : /// The filtered density sensitivity variable (cost) 47 : const MooseWritableVariable * _cost_density_sensitivity; 48 : /// The cost variable 49 : const MooseVariable & _cost; 50 : /// The volume fraction to be enforced 51 : const Real _volume_fraction; 52 : /// The cost fraction to be enforced 53 : const Real _cost_fraction; 54 : // Relative tolerance used to stop the two-variable bisection method. 55 : const Real _relative_tolerance; 56 : // Weights to solve a dual physics problem, e.g. a thermomechanical one. 57 : std::vector<Real> _weight_values; 58 : 59 : private: 60 : struct ElementData 61 : { 62 : Real old_density; 63 : Real sensitivity; 64 : Real cost_sensitivity; 65 : Real thermal_sensitivity; 66 : Real cost; 67 : Real volume; 68 : Real new_density; 69 : 70 : ElementData() = default; 71 : ElementData( 72 : Real dens, Real sens, Real cost_sens, Real thermal_sens, Real cst, Real vol, Real filt_dens) 73 : : old_density(dens), 74 : sensitivity(sens), 75 : cost_sensitivity(cost_sens), 76 : thermal_sensitivity(thermal_sens), 77 : cost(cst), 78 : volume(vol), 79 : new_density(filt_dens) 80 : { 81 : } 82 : }; 83 : 84 : /** 85 : * Gathers element date necessary to perform the bisection algorithm for optimization 86 : */ 87 : void gatherElementData(); 88 : /** 89 : * Performs the optimality criterion loop (bisection) 90 : */ 91 : void performOptimCritLoop(); 92 : 93 : Real computeUpdatedDensity(Real current_density, 94 : Real dc, 95 : Real cost_sensitivity, 96 : Real thermal_sensitivity, 97 : Real cost, 98 : Real lmid, 99 : Real cmid); 100 : 101 : /// Total volume allowed for volume contraint 102 : Real _total_allowable_volume; 103 : 104 : /// Total volume allowed for cost contraint 105 : Real _total_allowable_cost; 106 : 107 : /// Data structure to hold old density, sensitivity, volume, current density. 108 : std::map<dof_id_type, ElementData> _elem_data_map; 109 : 110 : /// Lower bound for bisection algorithm 111 : const Real _lower_bound; 112 : /// Upper bound for bisection algorithm 113 : const Real _upper_bound; 114 : /// Bisection algorithm move 115 : const Real _bisection_move; 116 : /// Whether bisection moves are adaptive 117 : const bool _adaptive_move; 118 : /// Thermal compliance sensitivity name 119 : VariableName _thermal_sensitivity_name; 120 : /// Thermal compliance variable 121 : MooseVariable * _thermal_sensitivity; 122 : };