https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SensitivityFilter.C
Go to the documentation of this file.
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#include "SensitivityFilter.h"
11#include "MooseError.h"
12#include <algorithm>
13
15
18{
21 "Computes the filtered sensitivity using a radial average user object.");
22 params.addRequiredParam<UserObjectName>("filter_UO", "Radial Average user object");
23 params.addRequiredCoupledVar("density_sensitivity", "Name of the density_sensitivity variable.");
24 params.addRequiredParam<VariableName>("design_density", "Design density variable name.");
25
26 return params;
27}
28
30 : ElementUserObject(parameters),
31 _filter(getUserObject<RadialAverage>("filter_UO").getAverage()),
32 _density_sensitivity(writableVariable("density_sensitivity")),
33 _design_density_name(getParam<VariableName>("design_density")),
34 _design_density(_subproblem.getStandardVariable(_tid, _design_density_name))
35{
36}
37
38void
40{
41 // Find the current element in the filter
42 auto filter_iter = _filter.find(_current_elem->id());
43
44 // Assert the element is found in the filter
45 mooseAssert(filter_iter != _filter.end(),
46 "An element could not be found in the filter. Check that a RadialAverage user object "
47 "has run before this object.");
48
49 // Get the quadrature point values from the filter
50 std::vector<Real> qp_vals = filter_iter->second;
51
52 // Initialize the total elemental sensitivity value
53 Real den_sense_val = 0;
54
55 // Compute the total elemental sensitivity value by summing over all quadrature points
56 for (unsigned int qp = 0; qp < _qrule->n_points(); qp++)
57 den_sense_val += qp_vals[qp] * _JxW[qp];
58
59 den_sense_val /= _current_elem_volume;
60
61 // Set the nodal value of the density sensitivity
63}
registerMooseObject("OptimizationApp", SensitivityFilter)
static InputParameters validParams()
const QBase *const & _qrule
const Elem *const & _current_elem
const MooseArray< Real > & _JxW
const Real & _current_elem_volume
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
virtual void setNodalValue(const OutputType &value, unsigned int idx=0)=0
Element user object that filters the objective function sensitivities via a radial average user objec...
const RadialAverage::Result & _filter
Radial average user object.
virtual void execute() override
SensitivityFilter(const InputParameters &parameters)
MooseWritableVariable & _density_sensitivity
Sensitivity with respect to density.
static InputParameters validParams()