Ejemplo n.º 1
0
void AssemblyA0::interior_assembly(FEMContext & c)
{
  const unsigned int n_components = rb_sys.n_vars();

  // make sure we have three components
  libmesh_assert_equal_to (n_components, 3);

  const unsigned int u_var = rb_sys.u_var;
  const unsigned int v_var = rb_sys.v_var;
  const unsigned int w_var = rb_sys.w_var;

  FEBase * elem_fe = libmesh_nullptr;
  c.get_element_fe(u_var, elem_fe);

  const std::vector<Real> & JxW = elem_fe->get_JxW();

  // The velocity shape function gradients at interior
  // quadrature points.
  const std::vector<std::vector<RealGradient> > & dphi = elem_fe->get_dphi();

  // Now we will build the affine operator
  unsigned int n_qpoints = c.get_element_qrule().n_points();

  std::vector<unsigned int> n_var_dofs(n_components);
  n_var_dofs[u_var] = c.get_dof_indices(u_var).size();
  n_var_dofs[v_var] = c.get_dof_indices(v_var).size();
  n_var_dofs[w_var] = c.get_dof_indices(w_var).size();

  for (unsigned int C_i = 0; C_i < n_components; C_i++)
    {
      unsigned int C_j = 0;
      for (unsigned int C_k = 0; C_k < n_components; C_k++)
        for (unsigned int C_l = 1; C_l < n_components; C_l++)
          {
            Real C_ijkl = elasticity_tensor(C_i, C_j, C_k, C_l);
            for (unsigned int qp=0; qp<n_qpoints; qp++)
              for (unsigned int i=0; i<n_var_dofs[C_i]; i++)
                for (unsigned int j=0; j<n_var_dofs[C_k]; j++)
                  (c.get_elem_jacobian(C_i,C_k))(i,j) +=
                    JxW[qp]*(C_ijkl * dphi[i][qp](C_j)*dphi[j][qp](C_l));
          }
    }

  for (unsigned int C_i = 0; C_i < n_components; C_i++)
    for (unsigned int C_j = 1; C_j < n_components; C_j++)
      for (unsigned int C_k = 0; C_k < n_components; C_k++)
        {
          unsigned int C_l = 0;

          Real C_ijkl = elasticity_tensor(C_i, C_j, C_k, C_l);
          for (unsigned int qp=0; qp<n_qpoints; qp++)
            for (unsigned int i=0; i<n_var_dofs[C_i]; i++)
              for (unsigned int j=0; j<n_var_dofs[C_k]; j++)
                (c.get_elem_jacobian(C_i,C_k))(i,j) +=
                  JxW[qp]*(C_ijkl * dphi[i][qp](C_j)*dphi[j][qp](C_l));
        }

}
Ejemplo n.º 2
0
void RBEIMConstruction::init_context(FEMContext &c)
{
  // default implementation of init_context
  // for compute_best_fit
  for(unsigned int var=0; var<n_vars(); var++)
    {
      FEBase* elem_fe = NULL;
      c.get_element_fe( var, elem_fe );
      elem_fe->get_JxW();
      elem_fe->get_phi();
      elem_fe->get_xyz();
    }
}
Ejemplo n.º 3
0
void InnerProductAssembly::interior_assembly(FEMContext & c)
{
  const unsigned int u_var = rb_sys.u_var;
  const unsigned int v_var = rb_sys.v_var;
  const unsigned int w_var = rb_sys.w_var;

  FEBase * elem_fe = libmesh_nullptr;
  c.get_element_fe(u_var, elem_fe);

  const std::vector<Real> & JxW = elem_fe->get_JxW();

  // The velocity shape function gradients at interior
  // quadrature points.
  const std::vector<std::vector<RealGradient> >& dphi = elem_fe->get_dphi();

  // The number of local degrees of freedom in each variable
  const unsigned int n_u_dofs = c.get_dof_indices(u_var).size();
  const unsigned int n_v_dofs = c.get_dof_indices(v_var).size();
  const unsigned int n_w_dofs = c.get_dof_indices(w_var).size();

  // Now we will build the affine operator
  unsigned int n_qpoints = c.get_element_qrule().n_points();

  DenseSubMatrix<Number> & Kuu = c.get_elem_jacobian(u_var, u_var);
  DenseSubMatrix<Number> & Kvv = c.get_elem_jacobian(v_var, v_var);
  DenseSubMatrix<Number> & Kww = c.get_elem_jacobian(w_var, w_var);

  for (unsigned int qp=0; qp<n_qpoints; qp++)
    {
      for (unsigned int i=0; i<n_u_dofs; i++)
        for (unsigned int j=0; j<n_u_dofs; j++)
          Kuu(i,j) += JxW[qp]*(dphi[i][qp]*dphi[j][qp]);

      for (unsigned int i=0; i<n_v_dofs; i++)
        for (unsigned int j=0; j<n_v_dofs; j++)
          Kvv(i,j) += JxW[qp]*(dphi[i][qp]*dphi[j][qp]);

      for (unsigned int i=0; i<n_w_dofs; i++)
        for (unsigned int j=0; j<n_w_dofs; j++)
          Kww(i,j) += JxW[qp]*(dphi[i][qp]*dphi[j][qp]);
    }
}