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 : #include "INSAD3Eqn.h" 11 : #include "INSADObjectTracker.h" 12 : #include "Function.h" 13 : 14 : registerMooseObject("NavierStokesApp", INSAD3Eqn); 15 : 16 : InputParameters 17 2613 : INSAD3Eqn::validParams() 18 : { 19 2613 : InputParameters params = INSADMaterial::validParams(); 20 2613 : params.addClassDescription("This material computes properties needed for stabilized formulations " 21 : "of the mass, momentum, and energy equations."); 22 5226 : params.addRequiredCoupledVar("temperature", "The temperature"); 23 5226 : params.addParam<MaterialPropertyName>("cp_name", "cp", "The name of the specific heat capacity"); 24 2613 : return params; 25 0 : } 26 : 27 2052 : INSAD3Eqn::INSAD3Eqn(const InputParameters & parameters) 28 : : INSADMaterial(parameters), 29 2052 : _temperature(adCoupledValue("temperature")), 30 2052 : _grad_temperature(adCoupledGradient("temperature")), 31 4104 : _cp(getADMaterialProperty<Real>("cp_name")), 32 2052 : _temperature_advective_strong_residual( 33 2052 : declareADProperty<Real>("temperature_advective_strong_residual")), 34 2052 : _temperature_td_strong_residual(declareADProperty<Real>("temperature_td_strong_residual")), 35 2052 : _temperature_ambient_convection_strong_residual( 36 2052 : declareADProperty<Real>("temperature_ambient_convection_strong_residual")), 37 2052 : _temperature_source_strong_residual( 38 2052 : declareADProperty<Real>("temperature_source_strong_residual")), 39 2052 : _temperature_advected_mesh_strong_residual( 40 4104 : declareADProperty<Real>("temperature_advected_mesh_strong_residual")) 41 : { 42 2052 : } 43 : 44 : void 45 514972 : INSAD3Eqn::subdomainSetup() 46 : { 47 514972 : INSADMaterial::subdomainSetup(); 48 : 49 1029944 : if ((_has_energy_transient = 50 514972 : _object_tracker->get<bool>("has_energy_transient", _current_subdomain_id))) 51 137625 : _temperature_dot = &adCoupledDot("temperature"); 52 : else 53 377347 : _temperature_dot = nullptr; 54 : 55 1029944 : if ((_has_ambient_convection = 56 514972 : _object_tracker->get<bool>("has_ambient_convection", _current_subdomain_id))) 57 : { 58 1641 : _ambient_convection_alpha = 59 1641 : _object_tracker->get<Real>("ambient_convection_alpha", _current_subdomain_id); 60 1641 : _ambient_temperature = _object_tracker->get<Real>("ambient_temperature", _current_subdomain_id); 61 : } 62 : else 63 : { 64 513331 : _ambient_convection_alpha = 0; 65 513331 : _ambient_temperature = 0; 66 : } 67 : 68 514972 : if ((_has_heat_source = _object_tracker->get<bool>("has_heat_source", _current_subdomain_id))) 69 : { 70 4376 : if (_object_tracker->isTrackerParamValid("heat_source_var", _current_subdomain_id)) 71 : { 72 1094 : _heat_source_var = &_subproblem 73 1094 : .getStandardVariable(_tid, 74 1094 : _object_tracker->get<std::string>( 75 1094 : "heat_source_var", _current_subdomain_id)) 76 1094 : .adSln(); 77 1094 : _heat_source_function = nullptr; 78 : } 79 2188 : else if (_object_tracker->isTrackerParamValid("heat_source_function", _current_subdomain_id)) 80 : { 81 1094 : _heat_source_function = &_fe_problem.getFunction( 82 1094 : _object_tracker->get<FunctionName>("heat_source_function", _current_subdomain_id), _tid); 83 1094 : _heat_source_var = nullptr; 84 : } 85 : } 86 : else 87 : { 88 512784 : _heat_source_var = nullptr; 89 512784 : _heat_source_function = nullptr; 90 : } 91 514972 : } 92 : 93 : void 94 21785509 : INSAD3Eqn::computeQpProperties() 95 : { 96 21785509 : INSADMaterial::computeQpProperties(); 97 : 98 : // For the remaining terms we make individual properties so they can be consumed by non-SUPG 99 : // kernels. This avoids double calculation for the non-supg and supg parts of the residual. We 100 : // don't need an individual property for the conductive term because the corresponding non-supg 101 : // contribution is integrated by parts and hence there is no double calculation (the 'weak' and 102 : // 'strong' terms are diferent in this case) 103 : 104 21785509 : _temperature_advective_strong_residual[_qp] = 105 43571018 : _rho[_qp] * _cp[_qp] * _velocity[_qp] * _grad_temperature[_qp]; 106 : 107 21785509 : if (_has_energy_transient) 108 : { 109 : mooseAssert(_temperature_dot, "The temperature time derivative is null"); 110 10434218 : _temperature_td_strong_residual[_qp] = _cp[_qp] * _rho[_qp] * (*_temperature_dot)[_qp]; 111 : } 112 : 113 21785509 : if (_has_ambient_convection) 114 248832 : _temperature_ambient_convection_strong_residual[_qp] = 115 497664 : _ambient_convection_alpha * (_temperature[_qp] - _ambient_temperature); 116 : 117 21785509 : if (_has_heat_source) 118 : { 119 331776 : if (_heat_source_var) 120 165888 : _temperature_source_strong_residual[_qp] = -(*_heat_source_var)[_qp]; 121 : else 122 : { 123 : mooseAssert(_heat_source_function, 124 : "Either the heat source var or the heat source function must be non-null in " 125 : "'INSAD3Eqn'"); 126 165888 : _temperature_source_strong_residual[_qp] = -_heat_source_function->value(_t, _q_point[_qp]); 127 : } 128 : } 129 : 130 21785509 : if (_has_advected_mesh) 131 690184 : _temperature_advected_mesh_strong_residual[_qp] = 132 1380368 : -_rho[_qp] * _cp[_qp] * _mesh_velocity[_qp] * _grad_temperature[_qp]; 133 21785509 : }