当前位置: 首页>>代码示例>>C++>>正文


C++ AssemblyContext类代码示例

本文整理汇总了C++中AssemblyContext的典型用法代码示例。如果您正苦于以下问题:C++ AssemblyContext类的具体用法?C++ AssemblyContext怎么用?C++ AssemblyContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AssemblyContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: rhocpU

  void HeatTransferStabilizationHelper::compute_res_energy_steady_and_derivs
  ( AssemblyContext& context,
    unsigned int qp,
    const libMesh::Real rho,
    const libMesh::Real Cp,
    const libMesh::Real k,
    libMesh::Real &res,
    libMesh::Real &d_res_dT,
    libMesh::Gradient &d_res_dgradT,
    libMesh::Tensor   &d_res_dhessT,
    libMesh::Gradient &d_res_dU
    ) const
  {
    libMesh::Gradient grad_T = context.fixed_interior_gradient(this->_temp_vars.T(), qp);
    libMesh::Tensor hess_T = context.fixed_interior_hessian(this->_temp_vars.T(), qp);

    libMesh::RealGradient rhocpU( rho*Cp*context.fixed_interior_value(this->_flow_vars.u(), qp),
                                  rho*Cp*context.fixed_interior_value(this->_flow_vars.v(), qp) );
    if(this->_flow_vars.dim() == 3)
      rhocpU(2) = rho*Cp*context.fixed_interior_value(this->_flow_vars.w(), qp);

    res = rhocpU*grad_T - k*(hess_T(0,0) + hess_T(1,1) + hess_T(2,2));
    d_res_dT = 0;
    d_res_dgradT = rhocpU;
    d_res_dhessT = 0;
    d_res_dhessT(0,0) = -k;
    d_res_dhessT(1,1) = -k;
    d_res_dhessT(2,2) = -k;
    d_res_dU = rho * Cp * grad_T;
  }
开发者ID:tradowsk,项目名称:grins,代码行数:30,代码来源:heat_transfer_stab_helper.C

示例2: Fs

  void AveragedTurbine<Mu>::nonlocal_time_derivative(bool compute_jacobian,
				                 AssemblyContext& context,
				                 CachedValues& /* cache */ )
  {
    libMesh::DenseSubMatrix<libMesh::Number> &Kss =
            context.get_elem_jacobian(this->fan_speed_var(), this->fan_speed_var()); // R_{s},{s}

    libMesh::DenseSubVector<libMesh::Number> &Fs =
            context.get_elem_residual(this->fan_speed_var()); // R_{s}

    const std::vector<libMesh::dof_id_type>& dof_indices =
      context.get_dof_indices(this->fan_speed_var());

    const libMesh::Number fan_speed =
      context.get_system().current_solution(dof_indices[0]);

    const libMesh::Number output_torque =
      this->torque_function(libMesh::Point(0), fan_speed);

    Fs(0) += output_torque;

    if (compute_jacobian)
      {
        // FIXME: we should replace this FEM with a hook to the AD fparser stuff
        const libMesh::Number epsilon = 1e-6;
        const libMesh::Number output_torque_deriv =
          (this->torque_function(libMesh::Point(0), fan_speed+epsilon) -
           this->torque_function(libMesh::Point(0), fan_speed-epsilon)) / (2*epsilon);

        Kss(0,0) += output_torque_deriv * context.get_elem_solution_derivative();
      }

    return;
  }
开发者ID:coreymbryant,项目名称:grins,代码行数:34,代码来源:averaged_turbine.C

示例3: apply_neumann_normal

  void BoundaryConditions::apply_neumann_normal( AssemblyContext& context,
                                                 const VariableIndex var,
                                                 const libMesh::Real sign,
                                                 const FEShape& value ) const
  {
    libMesh::FEGenericBase<FEShape>* side_fe = NULL; 
    context.get_side_fe( var, side_fe );

    // The number of local degrees of freedom in each variable.
    const unsigned int n_var_dofs = context.get_dof_indices(var).size();

    // Element Jacobian * quadrature weight for side integration.
    const std::vector<libMesh::Real> &JxW_side = side_fe->get_JxW();

    // The var shape functions at side quadrature points.
    const std::vector<std::vector<FEShape> >& var_phi_side = side_fe->get_phi();

    libMesh::DenseSubVector<libMesh::Number> &F_var = context.get_elem_residual(var); // residual

    unsigned int n_qpoints = context.get_side_qrule().n_points();
    for (unsigned int qp=0; qp != n_qpoints; qp++)
      {
	for (unsigned int i=0; i != n_var_dofs; i++)
	  {
	    F_var(i) += sign*value*var_phi_side[i][qp]*JxW_side[qp];
	  }
      }

    return;
  }
开发者ID:gdmcbain,项目名称:grins,代码行数:30,代码来源:boundary_conditions.C

示例4:

void BoussinesqBuoyancyAdjointStabilization<Mu>::init_context( AssemblyContext& context )
{
    context.get_element_fe(this->_flow_vars.p_var())->get_dphi();

    context.get_element_fe(this->_flow_vars.u_var())->get_dphi();
    context.get_element_fe(this->_flow_vars.u_var())->get_d2phi();

    return;
}
开发者ID:vikramvgarg,项目名称:grins,代码行数:9,代码来源:boussinesq_buoyancy_adjoint_stab.C

示例5: U

void LowMachNavierStokesSPGSMStabilization<Mu,SH,TC>::assemble_energy_mass_residual( bool /*compute_jacobian*/,
        AssemblyContext& context )
{
    // The number of local degrees of freedom in each variable.
    const unsigned int n_T_dofs = context.get_dof_indices(this->_temp_vars.T()).size();

    // Element Jacobian * quadrature weights for interior integration.
    const std::vector<libMesh::Real> &JxW =
        context.get_element_fe(this->_temp_vars.T())->get_JxW();

    // The temperature shape functions gradients at interior quadrature points.
    const std::vector<std::vector<libMesh::RealGradient> >& T_gradphi =
        context.get_element_fe(this->_temp_vars.T())->get_dphi();

    libMesh::DenseSubVector<libMesh::Number> &FT = context.get_elem_residual(this->_temp_vars.T()); // R_{T}

    unsigned int n_qpoints = context.get_element_qrule().n_points();

    for (unsigned int qp=0; qp != n_qpoints; qp++)
    {
        libMesh::Number u, v;
        u = context.fixed_interior_value(this->_flow_vars.u(), qp);
        v = context.fixed_interior_value(this->_flow_vars.v(), qp);

        libMesh::Gradient grad_T = context.fixed_interior_gradient(this->_temp_vars.T(), qp);

        libMesh::NumberVectorValue U(u,v);
        if (this->mesh_dim(context) == 3)
            U(2) = context.fixed_interior_value(this->_flow_vars.w(), qp); // w

        libMesh::Real T = context.fixed_interior_value( this->_temp_vars.T(), qp );
        libMesh::Real rho = this->rho( T, this->get_p0_transient( context, qp ) );

        libMesh::Real k = this->_k(T);
        libMesh::Real cp = this->_cp(T);

        libMesh::Number rho_cp = rho*this->_cp(T);

        libMesh::FEBase* fe = context.get_element_fe(this->_flow_vars.u());

        libMesh::RealGradient g = this->_stab_helper.compute_g( fe, context, qp );
        libMesh::RealTensor G = this->_stab_helper.compute_G( fe, context, qp );

        libMesh::Real tau_E = this->_stab_helper.compute_tau_energy( context, qp, g, G, rho, U, k, cp, false );

        libMesh::Real RE_t = this->compute_res_energy_transient( context, qp );

        for (unsigned int i=0; i != n_T_dofs; i++)
        {
            FT(i) -= rho_cp*tau_E*RE_t*U*T_gradphi[i][qp]*JxW[qp];
        }

    }

    return;
}
开发者ID:nicholasmalaya,项目名称:grins,代码行数:56,代码来源:low_mach_navier_stokes_spgsm_stab.C

示例6:

  void VelocityPenaltyAdjointStabilization<Mu>::init_context( AssemblyContext& context )
  {
    context.get_element_fe(this->_press_var.p())->get_dphi();

    context.get_element_fe(this->_flow_vars.u())->get_xyz();
    context.get_element_fe(this->_flow_vars.u())->get_phi();
    context.get_element_fe(this->_flow_vars.u())->get_dphi();
    context.get_element_fe(this->_flow_vars.u())->get_d2phi();

    return;
  }
开发者ID:coreymbryant,项目名称:grins,代码行数:11,代码来源:velocity_penalty_adjoint_stab.C

示例7:

  void ReactingLowMachNavierStokesStabilizationBase<Mixture,Evaluator>::init_context( AssemblyContext& context )
  {
    // First call base class
    ReactingLowMachNavierStokesAbstract::init_context(context);

    // We need pressure derivatives
    context.get_element_fe(this->_press_var.p())->get_dphi();

    // We also need second derivatives, so initialize those.
    context.get_element_fe(this->_flow_vars.u())->get_d2phi();
    context.get_element_fe(this->_temp_vars.T())->get_d2phi();
  }
开发者ID:coreymbryant,项目名称:grins,代码行数:12,代码来源:reacting_low_mach_navier_stokes_stab_base.C

示例8: U

  void LowMachNavierStokes<Mu,SH,TC>::assemble_mass_time_deriv( bool /*compute_jacobian*/, 
								AssemblyContext& context,
								CachedValues& cache )
  {
    // The number of local degrees of freedom in each variable.
    const unsigned int n_p_dofs = context.get_dof_indices(this->_p_var).size();

    // Element Jacobian * quadrature weights for interior integration.
    const std::vector<libMesh::Real> &JxW =
      context.get_element_fe(this->_u_var)->get_JxW();

    // The pressure shape functions at interior quadrature points.
    const std::vector<std::vector<libMesh::Real> >& p_phi =
      context.get_element_fe(this->_p_var)->get_phi();

    libMesh::DenseSubVector<libMesh::Number> &Fp = context.get_elem_residual(this->_p_var); // R_{p}

    unsigned int n_qpoints = context.get_element_qrule().n_points();

    for (unsigned int qp=0; qp != n_qpoints; qp++)
      {
	libMesh::Number u, v, T;
	u = cache.get_cached_values(Cache::X_VELOCITY)[qp];
	v = cache.get_cached_values(Cache::Y_VELOCITY)[qp];

	T = cache.get_cached_values(Cache::TEMPERATURE)[qp];

	libMesh::Gradient grad_u = cache.get_cached_gradient_values(Cache::X_VELOCITY_GRAD)[qp];
	libMesh::Gradient grad_v = cache.get_cached_gradient_values(Cache::Y_VELOCITY_GRAD)[qp];

	libMesh::Gradient grad_T = cache.get_cached_gradient_values(Cache::TEMPERATURE_GRAD)[qp];

	libMesh::NumberVectorValue U(u,v);
	if (this->_dim == 3)
	  U(2) = cache.get_cached_values(Cache::Z_VELOCITY)[qp]; // w

	libMesh::Number divU = grad_u(0) + grad_v(1);
	if (this->_dim == 3)
          {
	    libMesh::Gradient grad_w = cache.get_cached_gradient_values(Cache::Z_VELOCITY_GRAD)[qp];
	    divU += grad_w(2);
          }

	// Now a loop over the pressure degrees of freedom.  This
	// computes the contributions of the continuity equation.
	for (unsigned int i=0; i != n_p_dofs; i++)
	  {
	    Fp(i) += (-U*grad_T/T + divU)*p_phi[i][qp]*JxW[qp];
	  }
      }

    return;
  }
开发者ID:SylvainPlessis,项目名称:grins,代码行数:53,代码来源:low_mach_navier_stokes.C

示例9:

  void IncompressibleNavierStokesStabilizationBase<Mu>::init_context( AssemblyContext& context )
  {
    // First call base class
    IncompressibleNavierStokesBase<Mu>::init_context(context);
  
    // We need pressure derivatives
    context.get_element_fe(this->_flow_vars.p_var())->get_dphi();

    // We also need second derivatives, so initialize those.
    context.get_element_fe(this->_flow_vars.u_var())->get_d2phi();

    return;
  }
开发者ID:gdmcbain,项目名称:grins,代码行数:13,代码来源:inc_navier_stokes_stab_base.C

示例10: side_qoi_derivative

  void AverageNusseltNumber::side_qoi_derivative( AssemblyContext& context,
                                                  const unsigned int qoi_index )
  {

    for( std::set<libMesh::boundary_id_type>::const_iterator id = _bc_ids.begin();
	 id != _bc_ids.end(); id++ )
      {
	if( context.has_side_boundary_id( (*id) ) )
	  {
	    libMesh::FEBase* T_side_fe;
	    context.get_side_fe<libMesh::Real>(this->_T_var, T_side_fe);

	    const std::vector<libMesh::Real> &JxW = T_side_fe->get_JxW();
	    
	    const std::vector<libMesh::Point>& normals = T_side_fe->get_normals();

	    unsigned int n_qpoints = context.get_side_qrule().n_points();
	    
            const unsigned int n_T_dofs = context.get_dof_indices(_T_var).size();

            const std::vector<std::vector<libMesh::Gradient> >& T_gradphi = T_side_fe->get_dphi();

	    libMesh::DenseSubVector<libMesh::Number>& dQ_dT =
              context.get_qoi_derivatives(qoi_index, _T_var);

	    // Loop over quadrature points  
	    for (unsigned int qp = 0; qp != n_qpoints; qp++)
	      {
		// Get the solution value at the quadrature point
		libMesh::Gradient grad_T = 0.0; 
		context.side_gradient(this->_T_var, qp, grad_T);
		
		// Update the elemental increment dR for each qp
		//qoi += (this->_scaling)*(this->_k)*(grad_T*normals[qp])*JxW[qp];

                for( unsigned int i = 0; i != n_T_dofs; i++ )
                  {
                    dQ_dT(i) += _scaling*_k*T_gradphi[i][qp]*normals[qp]*JxW[qp];
                  }

	      } // quadrature loop

	  } // end check on boundary id

      }

    return;
  }
开发者ID:vikramvgarg,项目名称:grins,代码行数:48,代码来源:average_nusselt_number.C

示例11: F

  void HeatConduction<K>::mass_residual( bool compute_jacobian,
				      AssemblyContext& context,
				      CachedValues& /*cache*/ )
  {
    // First we get some references to cell-specific data that
    // will be used to assemble the linear system.

    // Element Jacobian * quadrature weights for interior integration
    const std::vector<libMesh::Real> &JxW = 
      context.get_element_fe(_temp_vars.T_var())->get_JxW();

    // The shape functions at interior quadrature points.
    const std::vector<std::vector<libMesh::Real> >& phi = 
      context.get_element_fe(_temp_vars.T_var())->get_phi();

    // The number of local degrees of freedom in each variable
    const unsigned int n_T_dofs = context.get_dof_indices(_temp_vars.T_var()).size();

    // The subvectors and submatrices we need to fill:
    libMesh::DenseSubVector<libMesh::Real> &F =
      context.get_elem_residual(_temp_vars.T_var());

    libMesh::DenseSubMatrix<libMesh::Real> &M =
      context.get_elem_jacobian(_temp_vars.T_var(), _temp_vars.T_var());

    unsigned int n_qpoints = context.get_element_qrule().n_points();
    
    for (unsigned int qp = 0; qp != n_qpoints; ++qp)
      {
	// For the mass residual, we need to be a little careful.
	// The time integrator is handling the time-discretization
	// for us so we need to supply M(u_fixed)*u' for the residual.
	// u_fixed will be given by the fixed_interior_value function
	// while u' will be given by the interior_rate function.
        libMesh::Real T_dot;
        context.interior_rate(_temp_vars.T_var(), qp, T_dot);

	for (unsigned int i = 0; i != n_T_dofs; ++i)
	  {
	    F(i) -= JxW[qp]*(_rho*_Cp*T_dot*phi[i][qp] );

	    if( compute_jacobian )
              {
                for (unsigned int j=0; j != n_T_dofs; j++)
                  {
		    // We're assuming rho, cp are constant w.r.t. T here.
                    M(i,j) -=
                      context.get_elem_solution_rate_derivative()
                        * JxW[qp]*_rho*_Cp*phi[j][qp]*phi[i][qp] ;
                  }
              }// End of check on Jacobian

	  } // End of element dof loop

      } // End of the quadrature point loop

    return;
  }
开发者ID:jcamata,项目名称:grins,代码行数:58,代码来源:heat_conduction.C

示例12:

  void LowMachNavierStokes<Mu,SH,TC>::assemble_thermo_press_side_time_deriv( bool /*compute_jacobian*/,
									     AssemblyContext& context )
  {
    // The number of local degrees of freedom in each variable.
    const unsigned int n_p0_dofs = context.get_dof_indices(this->_p0_var).size();

    // Element Jacobian * quadrature weight for side integration.
    //const std::vector<libMesh::Real> &JxW_side = context.get_side_fe(this->_T_var)->get_JxW();

    //const std::vector<Point> &normals = context.get_side_fe(this->_T_var)->get_normals();

    //libMesh::DenseSubVector<libMesh::Number> &F_p0 = context.get_elem_residual(this->_p0_var); // residual

    // Physical location of the quadrature points
    //const std::vector<libMesh::Point>& qpoint = context.get_side_fe(this->_T_var)->get_xyz();

    unsigned int n_qpoints = context.get_side_qrule().n_points();
    for (unsigned int qp=0; qp != n_qpoints; qp++)
      {
	/*
	libMesh::Number T = context.side_value( this->_T_var, qp );
	libMesh::Gradient U = ( context.side_value( this->_u_var, qp ),
				context.side_value( this->_v_var, qp ) );
	libMesh::Gradient grad_T = context.side_gradient( this->_T_var, qp );

	
	libMesh::Number p0 = context.side_value( this->_p0_var, qp );

	libMesh::Number k = this->_k(T);
	libMesh::Number cp = this->_cp(T);

	libMesh::Number cv = cp + this->_R;
	libMesh::Number gamma = cp/cv;
	libMesh::Number gamma_ratio = gamma/(gamma-1.0);
	*/

	//std::cout << "U = " << U << std::endl;

	//std::cout << "x = " << qpoint[qp] << ", grad_T = " << grad_T << std::endl;

	for (unsigned int i=0; i != n_p0_dofs; i++)
	  {
	    //F_p0(i) += (k*grad_T*normals[qp] - p0*gamma_ratio*U*normals[qp]  )*JxW_side[qp];
	  }
      }
  
    return;
  }
开发者ID:SylvainPlessis,项目名称:grins,代码行数:48,代码来源:low_mach_navier_stokes.C

示例13: compute_res_energy_steady

  libMesh::Real HeatTransferStabilizationHelper::compute_res_energy_steady( AssemblyContext& context,
                                                                            unsigned int qp,
                                                                            const libMesh::Real rho,
                                                                            const libMesh::Real Cp,
                                                                            const libMesh::Real k ) const
  {
    libMesh::Gradient grad_T = context.fixed_interior_gradient(this->_temp_vars.T(), qp);
    libMesh::Tensor hess_T = context.fixed_interior_hessian(this->_temp_vars.T(), qp);

    libMesh::RealGradient rhocpU( rho*Cp*context.fixed_interior_value(this->_flow_vars.u(), qp),
                                  rho*Cp*context.fixed_interior_value(this->_flow_vars.v(), qp) );
    if(this->_flow_vars.dim() == 3)
      rhocpU(2) = rho*Cp*context.fixed_interior_value(this->_flow_vars.w(), qp);

    return rhocpU*grad_T - k*(hess_T(0,0) + hess_T(1,1) + hess_T(2,2));
  }
开发者ID:tradowsk,项目名称:grins,代码行数:16,代码来源:heat_transfer_stab_helper.C

示例14:

  void ParsedVelocitySource<Mu>::init_context( AssemblyContext& context )
  {
    context.get_element_fe(this->_flow_vars.u())->get_xyz();
    context.get_element_fe(this->_flow_vars.u())->get_phi();

    return;
  }
开发者ID:coreymbryant,项目名称:grins,代码行数:7,代码来源:parsed_velocity_source.C

示例15:

  void AveragedTurbine<Mu>::init_context( AssemblyContext& context )
  {
    context.get_element_fe(this->_flow_vars.u_var())->get_xyz();
    context.get_element_fe(this->_flow_vars.u_var())->get_phi();

    return;
  }
开发者ID:gdmcbain,项目名称:grins,代码行数:7,代码来源:averaged_turbine.C


注:本文中的AssemblyContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。