27 #include "grins_config.h" 
   36 #include "libmesh/getpot.h" 
   37 #include "libmesh/string_to_enum.h" 
   38 #include "libmesh/fem_system.h" 
   39 #include "libmesh/quadrature.h" 
   47       _stab_helper( physics_name+
"StabHelper", input )
 
   59     context.get_element_fe(this->_press_var.p())->get_dphi();
 
   61     context.get_element_fe(this->_flow_vars.u())->get_dphi();
 
   62     context.get_element_fe(this->_flow_vars.u())->get_d2phi();
 
   72 #ifdef GRINS_USE_GRVY_TIMERS 
   73     this->_timer->BeginTimer(
"BoussinesqBuoyancyAdjointStabilization::element_time_derivative");
 
   77     const unsigned int n_u_dofs = context.get_dof_indices(_flow_vars.u()).size();
 
   78     const unsigned int n_T_dofs = context.get_dof_indices(_temp_vars.T()).size();
 
   81     const std::vector<libMesh::Real> &JxW =
 
   82       context.get_element_fe(_flow_vars.u())->get_JxW();
 
   84     const std::vector<std::vector<libMesh::Real> >& T_phi =
 
   85       context.get_element_fe(this->_temp_vars.T())->get_phi();
 
   87     const std::vector<std::vector<libMesh::Real> >& u_phi =
 
   88       context.get_element_fe(this->_flow_vars.u())->get_phi();
 
   90     const std::vector<std::vector<libMesh::RealGradient> >& u_gradphi =
 
   91       context.get_element_fe(this->_flow_vars.u())->get_dphi();
 
   93     const std::vector<std::vector<libMesh::RealTensor> >& u_hessphi =
 
   94       context.get_element_fe(this->_flow_vars.u())->get_d2phi();
 
   97     libMesh::DenseSubVector<libMesh::Number> &Fu = context.get_elem_residual(_flow_vars.u()); 
 
   98     libMesh::DenseSubVector<libMesh::Number> &Fv = context.get_elem_residual(_flow_vars.v()); 
 
   99     libMesh::DenseSubVector<libMesh::Number> *Fw = NULL;
 
  101     libMesh::DenseSubMatrix<libMesh::Number> &KuT = 
 
  102       context.get_elem_jacobian(_flow_vars.u(), _temp_vars.T()); 
 
  103     libMesh::DenseSubMatrix<libMesh::Number> &KvT = 
 
  104       context.get_elem_jacobian(_flow_vars.v(), _temp_vars.T()); 
 
  105     libMesh::DenseSubMatrix<libMesh::Number> &Kuu = 
 
  106       context.get_elem_jacobian(_flow_vars.u(), _flow_vars.u()); 
 
  107     libMesh::DenseSubMatrix<libMesh::Number> &Kuv = 
 
  108       context.get_elem_jacobian(_flow_vars.u(), _flow_vars.v()); 
 
  109     libMesh::DenseSubMatrix<libMesh::Number> &Kvu = 
 
  110       context.get_elem_jacobian(_flow_vars.v(), _flow_vars.u()); 
 
  111     libMesh::DenseSubMatrix<libMesh::Number> &Kvv = 
 
  112       context.get_elem_jacobian(_flow_vars.v(), _flow_vars.v()); 
 
  114     libMesh::DenseSubMatrix<libMesh::Number> *KwT = NULL;
 
  115     libMesh::DenseSubMatrix<libMesh::Number> *Kuw = NULL;
 
  116     libMesh::DenseSubMatrix<libMesh::Number> *Kvw = NULL;
 
  117     libMesh::DenseSubMatrix<libMesh::Number> *Kwu = NULL;
 
  118     libMesh::DenseSubMatrix<libMesh::Number> *Kwv = NULL;
 
  119     libMesh::DenseSubMatrix<libMesh::Number> *Kww = NULL;
 
  123         Fw = &context.get_elem_residual(this->_flow_vars.w()); 
 
  124         KwT = &context.get_elem_jacobian
 
  125           (_flow_vars.w(), _temp_vars.T()); 
 
  126         Kuw = &context.get_elem_jacobian
 
  127           (_flow_vars.u(), _flow_vars.w()); 
 
  128         Kvw = &context.get_elem_jacobian
 
  129           (_flow_vars.v(), _flow_vars.w()); 
 
  130         Kwu = &context.get_elem_jacobian
 
  131           (_flow_vars.w(), _flow_vars.u()); 
 
  132         Kwv = &context.get_elem_jacobian
 
  133           (_flow_vars.w(), _flow_vars.v()); 
 
  134         Kww = &context.get_elem_jacobian
 
  135           (_flow_vars.w(), _flow_vars.w()); 
 
  144     unsigned int n_qpoints = context.get_element_qrule().n_points();
 
  146     libMesh::FEBase* fe = context.get_element_fe(this->_flow_vars.u());
 
  148     for (
unsigned int qp=0; qp != n_qpoints; qp++)
 
  150         libMesh::RealGradient g = this->_stab_helper.compute_g( fe, context, qp );
 
  151         libMesh::RealTensor G = this->_stab_helper.compute_G( fe, context, qp );
 
  153         libMesh::RealGradient U( context.interior_value( this->_flow_vars.u(), qp ),
 
  154                                  context.interior_value( this->_flow_vars.v(), qp ) );
 
  155         if( this->_dim == 3 )
 
  157             U(2) = context.interior_value( this->_flow_vars.w(), qp );
 
  161         libMesh::Real mu_qp = this->_mu(context, qp);
 
  164         libMesh::Real d_tau_M_d_rho;
 
  165         libMesh::Gradient d_tau_M_dU;
 
  167         if (compute_jacobian)
 
  168           this->_stab_helper.compute_tau_momentum_and_derivs
 
  169             ( context, qp, g, G, this->_rho, U, mu_qp,
 
  170               tau_M, d_tau_M_d_rho, d_tau_M_dU,
 
  173           tau_M = this->_stab_helper.compute_tau_momentum
 
  174                     ( context, qp, g, G, this->_rho, U, mu_qp,
 
  179         T = context.interior_value(_temp_vars.T(), qp);
 
  181         libMesh::RealGradient d_residual_dT = _rho*_beta_T*_g;
 
  183         libMesh::RealGradient residual = (T-_T_ref)*d_residual_dT;
 
  185         for (
unsigned int i=0; i != n_u_dofs; i++)
 
  187             libMesh::Real test_func = this->_rho*U*u_gradphi[i][qp] +
 
  188               mu_qp*( u_hessphi[i][qp](0,0) + u_hessphi[i][qp](1,1) + u_hessphi[i][qp](2,2) );
 
  189             Fu(i) += -tau_M*residual(0)*test_func*JxW[qp];
 
  191             Fv(i) += -tau_M*residual(1)*test_func*JxW[qp];
 
  195                 (*Fw)(i) += -tau_M*residual(2)*test_func*JxW[qp];
 
  198             if (compute_jacobian)
 
  200                 libMesh::Gradient d_test_func_dU = this->_rho*u_gradphi[i][qp];
 
  203                 for (
unsigned int j=0; j != n_u_dofs; ++j)
 
  205                     Kuu(i,j) += -tau_M*residual(0)*d_test_func_dU(0)*u_phi[j][qp]*JxW[qp] * context.get_elem_solution_derivative();
 
  206                     Kuu(i,j) += -d_tau_M_dU(0)*u_phi[j][qp]*residual(0)*test_func*JxW[qp] * context.get_elem_solution_derivative();
 
  207                     Kuv(i,j) += -tau_M*residual(0)*d_test_func_dU(1)*u_phi[j][qp]*JxW[qp] * context.get_elem_solution_derivative();
 
  208                     Kuv(i,j) += -d_tau_M_dU(1)*u_phi[j][qp]*residual(0)*test_func*JxW[qp] * context.get_elem_solution_derivative();
 
  209                     Kvu(i,j) += -tau_M*residual(1)*d_test_func_dU(0)*u_phi[j][qp]*JxW[qp] * context.get_elem_solution_derivative();
 
  210                     Kvu(i,j) += -d_tau_M_dU(0)*u_phi[j][qp]*residual(1)*test_func*JxW[qp] * context.get_elem_solution_derivative();
 
  211                     Kvv(i,j) += -tau_M*residual(1)*d_test_func_dU(1)*u_phi[j][qp]*JxW[qp] * context.get_elem_solution_derivative();
 
  212                     Kvv(i,j) += -d_tau_M_dU(1)*u_phi[j][qp]*residual(1)*test_func*JxW[qp] * context.get_elem_solution_derivative();
 
  215                 for (
unsigned int j=0; j != n_T_dofs; ++j)
 
  218                     KuT(i,j) += -tau_M*d_residual_dT(0)*T_phi[j][qp]*test_func*JxW[qp] * context.get_elem_solution_derivative();
 
  220                     KvT(i,j) += -tau_M*d_residual_dT(1)*T_phi[j][qp]*test_func*JxW[qp] * context.get_elem_solution_derivative();
 
  224                     for (
unsigned int j=0; j != n_T_dofs; ++j)
 
  227                         (*KwT)(i,j) += -tau_M*d_residual_dT(2)*T_phi[j][qp]*test_func*JxW[qp] * context.get_elem_solution_derivative();
 
  230                     for (
unsigned int j=0; j != n_u_dofs; ++j)
 
  232                         (*Kuw)(i,j) += -tau_M*residual(0)*d_test_func_dU(2)*u_phi[j][qp]*JxW[qp] * context.get_elem_solution_derivative();
 
  233                         (*Kuw)(i,j) += -d_tau_M_dU(2)*u_phi[j][qp]*residual(0)*test_func*JxW[qp] * context.get_elem_solution_derivative();
 
  234                         (*Kvw)(i,j) += -tau_M*residual(1)*d_test_func_dU(2)*u_phi[j][qp]*JxW[qp] * context.get_elem_solution_derivative();
 
  235                         (*Kvw)(i,j) += -d_tau_M_dU(2)*u_phi[j][qp]*residual(1)*test_func*JxW[qp] * context.get_elem_solution_derivative();
 
  236                         (*Kwu)(i,j) += -tau_M*residual(2)*d_test_func_dU(0)*u_phi[j][qp]*JxW[qp] * context.get_elem_solution_derivative();
 
  237                         (*Kwu)(i,j) += -d_tau_M_dU(0)*u_phi[j][qp]*residual(2)*test_func*JxW[qp] * context.get_elem_solution_derivative();
 
  238                         (*Kwv)(i,j) += -tau_M*residual(2)*d_test_func_dU(1)*u_phi[j][qp]*JxW[qp] * context.get_elem_solution_derivative();
 
  239                         (*Kwv)(i,j) += -d_tau_M_dU(1)*u_phi[j][qp]*residual(2)*test_func*JxW[qp] * context.get_elem_solution_derivative();
 
  240                         (*Kww)(i,j) += -tau_M*residual(2)*d_test_func_dU(2)*u_phi[j][qp]*JxW[qp] * context.get_elem_solution_derivative();
 
  241                         (*Kww)(i,j) += -d_tau_M_dU(2)*u_phi[j][qp]*residual(2)*test_func*JxW[qp] * context.get_elem_solution_derivative();
 
  250 #ifdef GRINS_USE_GRVY_TIMERS 
  251     this->_timer->EndTimer(
"BoussinesqBuoyancyAdjointStabilization::element_time_derivative");
 
  262 #ifdef GRINS_USE_GRVY_TIMERS 
  263     this->_timer->BeginTimer(
"BoussinesqBuoyancyAdjointStabilization::element_constraint");
 
  267     const unsigned int n_p_dofs = context.get_dof_indices(_press_var.p()).size();
 
  268     const unsigned int n_u_dofs = context.get_dof_indices(_flow_vars.u()).size();
 
  269     const unsigned int n_T_dofs = context.get_dof_indices(_temp_vars.T()).size();
 
  272     const std::vector<libMesh::Real> &JxW =
 
  273       context.get_element_fe(_flow_vars.u())->get_JxW();
 
  275     const std::vector<std::vector<libMesh::Real> >& T_phi =
 
  276       context.get_element_fe(this->_temp_vars.T())->get_phi();
 
  278     const std::vector<std::vector<libMesh::Real> >& u_phi =
 
  279       context.get_element_fe(this->_flow_vars.u())->get_phi();
 
  281     const std::vector<std::vector<libMesh::RealGradient> >& p_dphi =
 
  282       context.get_element_fe(this->_press_var.p())->get_dphi();
 
  284     libMesh::DenseSubVector<libMesh::Number> &Fp = context.get_elem_residual(this->_press_var.p()); 
 
  286     libMesh::DenseSubMatrix<libMesh::Number> &KpT = 
 
  287       context.get_elem_jacobian(_press_var.p(), _temp_vars.T()); 
 
  288     libMesh::DenseSubMatrix<libMesh::Number> &Kpu = 
 
  289       context.get_elem_jacobian(_press_var.p(), _flow_vars.u()); 
 
  290     libMesh::DenseSubMatrix<libMesh::Number> &Kpv = 
 
  291       context.get_elem_jacobian(_press_var.p(), _flow_vars.v()); 
 
  292     libMesh::DenseSubMatrix<libMesh::Number> *Kpw = NULL;
 
  296         Kpw = &context.get_elem_jacobian
 
  297           (_press_var.p(), _flow_vars.w()); 
 
  306     unsigned int n_qpoints = context.get_element_qrule().n_points();
 
  308     libMesh::FEBase* fe = context.get_element_fe(this->_flow_vars.u());
 
  310     for (
unsigned int qp=0; qp != n_qpoints; qp++)
 
  312         libMesh::RealGradient g = this->_stab_helper.compute_g( fe, context, qp );
 
  313         libMesh::RealTensor G = this->_stab_helper.compute_G( fe, context, qp );
 
  315         libMesh::RealGradient U( context.interior_value( this->_flow_vars.u(), qp ),
 
  316                                  context.interior_value( this->_flow_vars.v(), qp ) );
 
  317         if( this->_dim == 3 )
 
  319             U(2) = context.interior_value( this->_flow_vars.w(), qp );
 
  323         libMesh::Real mu_qp = this->_mu(context, qp);
 
  326         libMesh::Real d_tau_M_d_rho;
 
  327         libMesh::Gradient d_tau_M_dU;
 
  329         if (compute_jacobian)
 
  330           this->_stab_helper.compute_tau_momentum_and_derivs
 
  331             ( context, qp, g, G, this->_rho, U, mu_qp,
 
  332               tau_M, d_tau_M_d_rho, d_tau_M_dU,
 
  335           tau_M = this->_stab_helper.compute_tau_momentum
 
  336                     ( context, qp, g, G, this->_rho, U, mu_qp,
 
  341         T = context.interior_value(_temp_vars.T(), qp);
 
  343         libMesh::RealGradient d_residual_dT = _rho*_beta_T*_g;
 
  345         libMesh::RealGradient residual = (T-_T_ref)*d_residual_dT;
 
  350         for (
unsigned int i=0; i != n_p_dofs; i++)
 
  352             Fp(i) += tau_M*residual*p_dphi[i][qp]*JxW[qp];
 
  354             if (compute_jacobian)
 
  356                 for (
unsigned int j=0; j != n_T_dofs; ++j)
 
  358                     KpT(i,j) += tau_M*d_residual_dT*T_phi[j][qp]*p_dphi[i][qp]*JxW[qp] * context.get_elem_solution_derivative();
 
  361                 for (
unsigned int j=0; j != n_u_dofs; ++j)
 
  363                     Kpu(i,j) += d_tau_M_dU(0)*u_phi[j][qp]*residual*p_dphi[i][qp]*JxW[qp] * context.get_elem_solution_derivative();
 
  364                     Kpv(i,j) += d_tau_M_dU(1)*u_phi[j][qp]*residual*p_dphi[i][qp]*JxW[qp] * context.get_elem_solution_derivative();
 
  366                 if( this->_dim == 3 )
 
  367                   for (
unsigned int j=0; j != n_u_dofs; ++j)
 
  369                       (*Kpw)(i,j) += d_tau_M_dU(2)*u_phi[j][qp]*residual*p_dphi[i][qp]*JxW[qp] * context.get_elem_solution_derivative();
 
  375 #ifdef GRINS_USE_GRVY_TIMERS 
  376     this->_timer->EndTimer(
"BoussinesqBuoyancyAdjointStabilization::element_constraint");
 
  384     ( 
const std::string & param_name,
 
  389     _mu.register_parameter(param_name, param_pointer);
 
BoussinesqBuoyancyAdjointStabilization()
 
INSTANTIATE_INC_NS_SUBCLASS(BoussinesqBuoyancyAdjointStabilization)
 
virtual void element_time_derivative(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Time dependent part(s) of physics for element interiors. 
 
virtual void init_context(AssemblyContext &context)
Initialize context for added physics variables. 
 
Helper functions for parsing material properties. 
 
virtual void element_constraint(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Constraint part(s) of physics for element interiors. 
 
~BoussinesqBuoyancyAdjointStabilization()
 
virtual void register_parameter(const std::string ¶m_name, libMesh::ParameterMultiAccessor< libMesh::Number > ¶m_pointer) const 
Each subclass will register its copy of an independent. 
 
virtual void register_parameter(const std::string ¶m_name, libMesh::ParameterMultiAccessor< libMesh::Number > ¶m_pointer) const 
Each subclass will register its copy of an independent.