19 #include "libmesh/dirichlet_boundaries.h" 
   20 #include "libmesh/dof_map.h" 
   21 #include "libmesh/fe_base.h" 
   22 #include "libmesh/fe_interface.h" 
   23 #include "libmesh/fem_context.h" 
   24 #include "libmesh/getpot.h" 
   25 #include "libmesh/mesh.h" 
   26 #include "libmesh/parallel.h" 
   27 #include "libmesh/quadrature.h" 
   28 #include "libmesh/string_to_enum.h" 
   29 #include "libmesh/zero_function.h" 
   30 #include "libmesh/auto_ptr.h"  
   47   { this->_initialized = 
true; }
 
   51   { libmesh_not_implemented(); }
 
   53   virtual void operator() (
const Point & p,
 
   61     output(_u_var) = (_sign)*((y-2) * (y-3));
 
   65   virtual std::unique_ptr<FunctionBase<Number>> 
clone()
 const 
   66   { 
return libmesh_make_unique<BdyFunction>(_u_var, _v_var, 
int(_sign)); }
 
   78   GetPot infile(
"coupled_system.in");
 
   79   Peclet = infile(
"Peclet", 1.);
 
   80   unsigned int pressure_p = infile(
"pressure_p", 1);
 
   81   std::string fe_family = infile(
"fe_family", std::string(
"LAGRANGE"));
 
   88   FEFamily fefamily = Utility::string_to_enum<FEFamily>(fe_family);
 
   92   u_var = this->add_variable (
"u", static_cast<Order>(pressure_p+1),
 
   94   v_var = this->add_variable (
"v", static_cast<Order>(pressure_p+1),
 
  100   p_var = this->add_variable (
"p", static_cast<Order>(pressure_p),
 
  105   C_var = this->add_variable (
"C", static_cast<Order>(pressure_p+1),
 
  111   this->time_evolving(u_var, 1);
 
  112   this->time_evolving(v_var, 1);
 
  113   this->time_evolving(C_var, 1);
 
  116   this->verify_analytic_jacobians = infile(
"verify_analytic_jacobians", 0.);
 
  120   std::set<boundary_id_type> left_inlet_bdy;
 
  121   left_inlet_bdy.insert(left_inlet_id);
 
  124   std::set<boundary_id_type> right_inlet_bdy;
 
  125   right_inlet_bdy.insert(right_inlet_id);
 
  128   std::set<boundary_id_type> outlets_bdy;
 
  129   outlets_bdy.insert(outlets_id);
 
  132   std::set<boundary_id_type> wall_bdy;
 
  133   wall_bdy.insert(wall_id);
 
  136   std::vector<unsigned int> uv(1, u_var);
 
  139   std::vector<unsigned int> C_only(1, C_var);
 
  147   int velocity_sign = 1;
 
  148   BdyFunction inflow_left(u_var, v_var, -velocity_sign);
 
  149   BdyFunction inflow_right(u_var, v_var, velocity_sign);
 
  151 #ifdef LIBMESH_ENABLE_DIRICHLET 
  153   this->get_dof_map().add_dirichlet_boundary
 
  158   this->get_dof_map().add_dirichlet_boundary
 
  160   this->get_dof_map().add_dirichlet_boundary
 
  165   this->get_dof_map().add_dirichlet_boundary
 
  167   this->get_dof_map().add_dirichlet_boundary
 
  169 #endif // LIBMESH_ENABLE_DIRICHLET 
  181   FEMContext & c = cast_ref<FEMContext &>(context);
 
  187   FEBase * u_elem_fe = 
nullptr;
 
  194   FEBase * p_elem_fe = 
nullptr;
 
  198   FEBase * side_fe = 
nullptr;
 
  210   FEMContext & c = cast_ref<FEMContext &>(context);
 
  214   FEBase * u_elem_fe = 
nullptr;
 
  218   const std::vector<Real> & JxW = u_elem_fe->
get_JxW();
 
  221   const std::vector<std::vector<Real>> & phi = u_elem_fe->
get_phi();
 
  225   const std::vector<std::vector<RealGradient>> & dphi = u_elem_fe->
get_dphi();
 
  229   FEBase * p_elem_fe = 
nullptr;
 
  232   const std::vector<std::vector<Real>> & psi = p_elem_fe->
get_phi();
 
  261   for (
unsigned int qp=0; qp != n_qpoints; qp++)
 
  274       const Number C_x = grad_C(0);
 
  275       const Number C_y = grad_C(1);
 
  280       for (
unsigned int i=0; i != n_u_dofs; i++)
 
  285              (grad_u*dphi[i][qp]));            
 
  289              (grad_v*dphi[i][qp]));            
 
  293             ((U*grad_C)*phi[i][qp] +                
 
  294              (1./Peclet)*(grad_C*dphi[i][qp]));     
 
  304               for (
unsigned int j=0; j != n_u_dofs; j++)
 
  306                   Kuu(i,j) += JxW[qp] * (-(dphi[i][qp]*dphi[j][qp])); 
 
  308                   Kvv(i,j) += JxW[qp] * (-(dphi[i][qp]*dphi[j][qp])); 
 
  310                   KCu(i,j) += JxW[qp] * ((phi[j][qp]*C_x)*phi[i][qp]); 
 
  312                   KCv(i,j) += JxW[qp] * ((phi[j][qp]*C_y)*phi[i][qp]); 
 
  315                     ((U*dphi[j][qp])*phi[i][qp] +            
 
  316                      (1./Peclet)*(dphi[j][qp]*dphi[i][qp])); 
 
  320               for (
unsigned int j=0; j != n_p_dofs; j++)
 
  322                   Kup(i,j) += JxW[qp]*psi[j][qp]*dphi[i][qp](0);
 
  323                   Kvp(i,j) += JxW[qp]*psi[j][qp]*dphi[i][qp](1);
 
  329   return request_jacobian;
 
  336   FEMContext & c = cast_ref<FEMContext &>(context);
 
  340   FEBase * u_elem_fe = 
nullptr;
 
  343   FEBase * p_elem_fe = 
nullptr;
 
  347   const std::vector<Real> & JxW = u_elem_fe->
get_JxW();
 
  351   const std::vector<std::vector<RealGradient>> & dphi = u_elem_fe->
get_dphi();
 
  355   const std::vector<std::vector<Real>> & psi = p_elem_fe->
get_phi();
 
  368   for (
unsigned int qp=0; qp != n_qpoints; qp++)
 
  377       for (
unsigned int i=0; i != n_p_dofs; i++)
 
  379           Fp(i) += JxW[qp] * psi[i][qp] *
 
  380             (grad_u(0) + grad_v(1));
 
  386               for (
unsigned int j=0; j != n_u_dofs; j++)
 
  388                   Kpu(i,j) += JxW[qp]*psi[i][qp]*dphi[j][qp](0);
 
  389                   Kpv(i,j) += JxW[qp]*psi[i][qp]*dphi[j][qp](1);
 
  395   return request_jacobian;
 
  440       libmesh_error_msg(
"Wrong variable number "                        \
 
  442                         << 
" passed to CoupledFEMFunctionsx object! Quitting!");
 
  473       libmesh_error_msg(
"Wrong variable number "                        \
 
  475                         << 
" passed to CoupledFEMFunctionsy object! Quitting!");