Esempio n. 1
0
  void ICHandlingBase::read_ic_data( const GetPot& input, const std::string& id_str,
                                     const std::string& ic_str,
                                     const std::string& var_str,
                                     const std::string& value_str)
  {
    int num_ids = input.vector_variable_size(id_str);
    int num_ics = input.vector_variable_size(ic_str);
    int num_vars = input.vector_variable_size(var_str);
    int num_values = input.vector_variable_size(value_str);

    if( num_ids != num_ics )
      {
        std::cerr << "Error: number of subdomain ids " << num_ids
                  << "must equal number of initial condition types " << num_ics
                  << std::endl;
        libmesh_error();
      }

    if( num_ids != num_vars )
      {
        std::cerr << "Error: number of subdomain ids " << num_ids
                  << "must equal number of variable name lists " << num_vars
                  << std::endl;
        libmesh_error();
      }

    if( num_ids != num_values )
      {
        std::cerr << "Error: number of subdomain ids " << num_ids
                  << "must equal number of initial condition values " << num_values
                  << std::endl;
        libmesh_error();
      }

    if( num_ids > 1 )
      {
        std::cerr << "Error: GRINS does not yet support per-subdomain initial conditions" << std::endl;
        libmesh_not_implemented();
      }

    for( int i = 0; i < num_ids; i++ )
      {
        int ic_id = input(id_str, -1, i );
        std::string ic_type_in = input(ic_str, "NULL", i );
        std::string ic_value_in = input(value_str, "NULL", i );
        std::string ic_vars_in = input(var_str, "NULL", i );

        int ic_type = this->string_to_int( ic_type_in );

        std::stringstream ss;
        ss << ic_id;
        std::string ic_id_string = ss.str();

        this->init_ic_types( ic_id, ic_id_string, ic_type, ic_vars_in, ic_value_in, input );
      }

    return;
  }
Esempio n. 2
0
void
LinearSolver<T>::restrict_solve_to(const std::vector<unsigned int>* const dofs,
				   const SubsetSolveMode /*subset_solve_mode*/)
{
  if(dofs!=NULL)
    {
      libmesh_not_implemented();
    }
}
//void EpetraMatrix<T>::print_matlab (const std::string name) const
void EpetraMatrix<T>::print_matlab (const std::string) const
{
  libmesh_assert (this->initialized());

  // libmesh_assert (this->closed());
  this->close();

  libmesh_not_implemented();

//   int ierr=0;
//   PetscViewer petsc_viewer;


//   ierr = PetscViewerCreate (libMesh::COMM_WORLD,
// 			    &petsc_viewer);
//          CHKERRABORT(libMesh::COMM_WORLD,ierr);

//   /**
//    * Create an ASCII file containing the matrix
//    * if a filename was provided.
//    */
//   if (name != "NULL")
//     {
//       ierr = PetscViewerASCIIOpen( libMesh::COMM_WORLD,
// 				   name.c_str(),
// 				   &petsc_viewer);
//              CHKERRABORT(libMesh::COMM_WORLD,ierr);

//       ierr = PetscViewerSetFormat (petsc_viewer,
// 				   PETSC_VIEWER_ASCII_MATLAB);
//              CHKERRABORT(libMesh::COMM_WORLD,ierr);

//       ierr = MatView (_mat, petsc_viewer);
//              CHKERRABORT(libMesh::COMM_WORLD,ierr);
//     }

//   /**
//    * Otherwise the matrix will be dumped to the screen.
//    */
//   else
//     {
//       ierr = PetscViewerSetFormat (PETSC_VIEWER_STDOUT_WORLD,
// 				   PETSC_VIEWER_ASCII_MATLAB);
//              CHKERRABORT(libMesh::COMM_WORLD,ierr);

//       ierr = MatView (_mat, PETSC_VIEWER_STDOUT_WORLD);
//              CHKERRABORT(libMesh::COMM_WORLD,ierr);
//     }


//   /**
//    * Destroy the viewer.
//    */
//   ierr = LibMeshPetscViewerDestroy (petsc_viewer);
//          CHKERRABORT(libMesh::COMM_WORLD,ierr);
}
Esempio n. 4
0
Real FE<3,CLOUGH>::shape_second_deriv(const Elem* elem,
                                      const Order,
                                      const unsigned int,
                                      const unsigned int,
                                      const Point&)
{
  libmesh_assert (elem != NULL);
  libmesh_not_implemented();
  return 0.;
}
std::pair<unsigned int, Real>
EigenSparseLinearSolver<T>::solve (const ShellMatrix<T>& /*shell_matrix*/,
                                   NumericVector<T>& /*solution_in*/,
                                   NumericVector<T>& /*rhs_in*/,
                                   const double /*tol*/,
                                   const unsigned int /*m_its*/)
{
  libmesh_not_implemented();
  return std::make_pair(0,0.0);
}
Real FE<3,CLOUGH>::shape_deriv(const Elem* libmesh_dbg_var(elem),
                               const Order,
                               const unsigned int,
                               const unsigned int,
                               const Point&)
{
  libmesh_assert(elem);
  libmesh_not_implemented();
  return 0.;
}
Esempio n. 7
0
 void SpalartAllmarasStabilizationHelper::compute_res_spalart_transient_and_derivs
 ( AssemblyContext& /*context*/,
   unsigned int /*qp*/,
   const libMesh::Real /*rho*/,
   libMesh::RealGradient& /*res_M*/,
   libMesh::Real& /*d_res_Muvw_duvw*/
   ) const
 {
   libmesh_not_implemented();
 }
void EpetraVector<T>::print_matlab (const std::string /* name */) const
{
  libmesh_not_implemented();

//   libmesh_assert (this->initialized());
//   libmesh_assert (this->closed());

//   int ierr=0;
//   EpetraViewer epetra_viewer;


//   ierr = EpetraViewerCreate (libMesh::COMM_WORLD,
// 			    &epetra_viewer);
//          CHKERRABORT(libMesh::COMM_WORLD,ierr);

//   /**
//    * Create an ASCII file containing the matrix
//    * if a filename was provided.
//    */
//   if (name != "NULL")
//     {
//       ierr = EpetraViewerASCIIOpen( libMesh::COMM_WORLD,
// 				   name.c_str(),
// 				   &epetra_viewer);
//              CHKERRABORT(libMesh::COMM_WORLD,ierr);

//       ierr = EpetraViewerSetFormat (epetra_viewer,
// 				   EPETRA_VIEWER_ASCII_MATLAB);
//              CHKERRABORT(libMesh::COMM_WORLD,ierr);

//       ierr = VecView (_vec, epetra_viewer);
//              CHKERRABORT(libMesh::COMM_WORLD,ierr);
//     }

//   /**
//    * Otherwise the matrix will be dumped to the screen.
//    */
//   else
//     {
//       ierr = EpetraViewerSetFormat (EPETRA_VIEWER_STDOUT_WORLD,
// 				   EPETRA_VIEWER_ASCII_MATLAB);
//              CHKERRABORT(libMesh::COMM_WORLD,ierr);

//       ierr = VecView (_vec, EPETRA_VIEWER_STDOUT_WORLD);
//              CHKERRABORT(libMesh::COMM_WORLD,ierr);
//     }


//   /**
//    * Destroy the viewer.
//    */
//   ierr = EpetraViewerDestroy (epetra_viewer);
//          CHKERRABORT(libMesh::COMM_WORLD,ierr);
}
Esempio n. 9
0
 void Hyperelasticity<StrainEnergy>::compute_stress_and_elasticity_imp( unsigned int dim,
                                                                        const libMesh::TensorValue<libMesh::Real>& g_contra,
                                                                        const libMesh::TensorValue<libMesh::Real>& g_cov,
                                                                        const libMesh::TensorValue<libMesh::Real>& G_contra,
                                                                        const libMesh::TensorValue<libMesh::Real>& G_cov,
                                                                        libMesh::TensorValue<libMesh::Real>& stress,
                                                                        ElasticityTensor& C )
 {
   libmesh_not_implemented();
   return;
 }
Esempio n. 10
0
 void SpalartAllmarasStabilizationHelper::compute_res_spalart_steady_and_derivs
 ( AssemblyContext& /*context*/,
   unsigned int /*qp*/, const libMesh::Real /*rho*/, const libMesh::Real /*mu*/,
   libMesh::Gradient& /*res_M*/,
   libMesh::Tensor&   /*d_res_M_dgradp*/,
   libMesh::Tensor&   /*d_res_M_dU*/,
   libMesh::Gradient& /*d_res_Muvw_dgraduvw*/,
   libMesh::Tensor&   /*d_res_Muvw_dhessuvw*/
   ) const
 {
   // To be filled when we start using analytic jacobians with SA
   libmesh_not_implemented();
 }
Esempio n. 11
0
  void HeatTransferSPGSMStabilization<K>::element_time_derivative
  ( 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();

    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}

    libMesh::FEBase* fe = context.get_element_fe(this->_temp_vars.T());

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

    for (unsigned int qp=0; qp != n_qpoints; qp++)
      {
        libMesh::RealGradient g = this->_stab_helper.compute_g( fe, context, qp );
        libMesh::RealTensor G = this->_stab_helper.compute_G( fe, context, qp );

        libMesh::RealGradient U( context.interior_value( this->_flow_vars.u(), qp ),
                                 context.interior_value( this->_flow_vars.v(), qp ) );
        if( this->_flow_vars.dim() == 3 )
          {
            U(2) = context.interior_value( this->_flow_vars.w(), qp );
          }

        // Compute Conductivity at this qp
        libMesh::Real _k_qp = this->_k(context, qp);

        libMesh::Real tau_E = this->_stab_helper.compute_tau_energy( context, G, this->_rho, this->_Cp, _k_qp,  U, this->_is_steady );

        libMesh::Real RE_s = this->_stab_helper.compute_res_energy_steady( context, qp, this->_rho, this->_Cp, _k_qp );

        for (unsigned int i=0; i != n_T_dofs; i++)
          {
            FT(i) += -tau_E*RE_s*this->_rho*this->_Cp*U*T_gradphi[i][qp]*JxW[qp];
          }

        if( compute_jacobian )
          {
            libmesh_not_implemented();
          }

      }
  }
std::pair<unsigned int, Real>
AztecLinearSolver<T>::solve (const ShellMatrix<T>&,
                             NumericVector<T>&,
                             NumericVector<T>&,
                             const double,
                             const unsigned int)
//AztecLinearSolver<T>::solve (const ShellMatrix<T>& shell_matrix,
//     NumericVector<T>& solution_in,
//     NumericVector<T>& rhs_in,
//     const double tol,
//     const unsigned int m_its)
{
  libmesh_not_implemented();
}
Esempio n. 13
0
AutoPtr<FunctionBase<Number> > new_function_base(const std::string& func_type,
                                        const std::string& func_value)
{
  if (func_type == "parsed")
    return AutoPtr<FunctionBase<Number> >
      (new ParsedFunction<Number>(func_value));
  else if (func_type == "factory")
    return AutoPtr<FunctionBase<Number> >
      (Factory<FunctionBase<Number> >::build(func_value).release());
  else if (func_type == "zero")
    return AutoPtr<FunctionBase<Number> >
      (new ZeroFunction<Number>);
  else
    libmesh_not_implemented();

  return AutoPtr<FunctionBase<Number> >();
}
Esempio n. 14
0
void FEMSystem::mesh_position_get()
{
  // This function makes no sense unless we've already picked out some
  // variable(s) to reflect mesh position coordinates
  if (!_mesh_sys)
    libmesh_error();

  // We currently assume mesh variables are in our own system
  if (_mesh_sys != this)
    libmesh_not_implemented();

  // Loop over every active mesh element on this processor
  const MeshBase& mesh = this->get_mesh();

  MeshBase::const_element_iterator el =
    mesh.active_local_elements_begin();
  const MeshBase::const_element_iterator end_el =
    mesh.active_local_elements_end();

  AutoPtr<DiffContext> con = this->build_context();
  FEMContext &_femcontext = libmesh_cast_ref<FEMContext&>(*con);
  this->init_context(_femcontext);

  // Get the solution's mesh variables from every element
  for ( ; el != end_el; ++el)
    {
      _femcontext.pre_fe_reinit(*this, *el);

      _femcontext.elem_position_get();

      if (_mesh_x_var != libMesh::invalid_uint)
        this->solution->insert(*_femcontext.elem_subsolutions[_mesh_x_var],
                               _femcontext.dof_indices_var[_mesh_x_var]);
      if (_mesh_y_var != libMesh::invalid_uint)
        this->solution->insert(*_femcontext.elem_subsolutions[_mesh_y_var],
                               _femcontext.dof_indices_var[_mesh_y_var]);
      if (_mesh_z_var != libMesh::invalid_uint)
        this->solution->insert(*_femcontext.elem_subsolutions[_mesh_z_var],
                               _femcontext.dof_indices_var[_mesh_z_var]);
    }

  this->solution->close();

  // And make sure the current_local_solution is up to date too
  this->System::update();
}
Esempio n. 15
0
  SharedPtr<Solver> SolverFactory::build(const GetPot& input)
  {
    bool mesh_adaptive = input("MeshAdaptivity/mesh_adaptive", false );

    bool transient = input("unsteady-solver/transient", false );

    SharedPtr<Solver> solver;  // Effectively NULL

    std::string solver_type = input("SolverOptions/solver_type", "DIE!");

    if( solver_type == std::string("displacement_continuation") )
      {
        solver.reset( new DisplacementContinuationSolver(input) );
      }
    else if(transient && !mesh_adaptive)
      {
        solver.reset( new UnsteadySolver(input) );
      }
    else if( !transient && !mesh_adaptive )
      {
        solver.reset( new SteadySolver(input) );
      }
    else if( !transient && mesh_adaptive )
      {
        solver.reset( new SteadyMeshAdaptiveSolver(input) );
      }
    else if( transient && mesh_adaptive )
      {
        libmesh_not_implemented();
      }
    else
      {
        std::cerr << "Invalid solver options!" << std::endl;
      }

    return solver;
  }
Esempio n. 16
0
void ExactSolution::_compute_error(const std::string& sys_name,
				   const std::string& unknown_name,
				   std::vector<Real>& error_vals)
{
  // This function must be run on all processors at once
  parallel_only();

  // Make sure we aren't "overconfigured"
  libmesh_assert (!(_exact_values.size() && _equation_systems_fine));

  // Get a reference to the system whose error is being computed.
  // If we have a fine grid, however, we'll integrate on that instead
  // for more accuracy.
  const System& computed_system = _equation_systems_fine ?
    _equation_systems_fine->get_system(sys_name) :
    _equation_systems.get_system (sys_name);

  const Real time = _equation_systems.get_system(sys_name).time;

  const unsigned int sys_num = computed_system.number();
  const unsigned int var = computed_system.variable_number(unknown_name);
  const unsigned int var_component =
    computed_system.variable_scalar_number(var, 0);

  // Prepare a global solution and a MeshFunction of the coarse system if we need one
  AutoPtr<MeshFunction> coarse_values;
  AutoPtr<NumericVector<Number> > comparison_soln = NumericVector<Number>::build();
  if (_equation_systems_fine)
    {
      const System& comparison_system
	= _equation_systems.get_system(sys_name);

      std::vector<Number> global_soln;
      comparison_system.update_global_solution(global_soln);
      comparison_soln->init(comparison_system.solution->size(), true, SERIAL);
      (*comparison_soln) = global_soln;

      coarse_values = AutoPtr<MeshFunction>
	(new MeshFunction(_equation_systems,
			  *comparison_soln,
			  comparison_system.get_dof_map(),
			  comparison_system.variable_number(unknown_name)));
      coarse_values->init();
    }

  // Initialize any functors we're going to use
  for (unsigned int i=0; i != _exact_values.size(); ++i)
    if (_exact_values[i])
      _exact_values[i]->init();

  for (unsigned int i=0; i != _exact_derivs.size(); ++i)
    if (_exact_derivs[i])
      _exact_derivs[i]->init();

  for (unsigned int i=0; i != _exact_hessians.size(); ++i)
    if (_exact_hessians[i])
      _exact_hessians[i]->init();

  // Get a reference to the dofmap and mesh for that system
  const DofMap& computed_dof_map = computed_system.get_dof_map();

  const MeshBase& _mesh = computed_system.get_mesh();

  const unsigned int dim = _mesh.mesh_dimension();

  // Zero the error before summation
  // 0 - sum of square of function error (L2)
  // 1 - sum of square of gradient error (H1 semi)
  // 2 - sum of square of Hessian error (H2 semi)
  // 3 - sum of sqrt(square of function error) (L1)
  // 4 - max of sqrt(square of function error) (Linfty)
  // 5 - sum of square of curl error (HCurl semi)
  // 6 - sum of square of div error (HDiv semi)
  error_vals = std::vector<Real>(7, 0.);

  // Construct Quadrature rule based on default quadrature order
  const FEType& fe_type  = computed_dof_map.variable_type(var);

  unsigned int n_vec_dim = FEInterface::n_vec_dim( _mesh, fe_type );

  // FIXME: MeshFunction needs to be updated to support vector-valued
  //        elements before we can use a reference solution.
  if( (n_vec_dim > 1) && _equation_systems_fine )
    {
      libMesh::err << "Error calculation using reference solution not yet\n"
		   << "supported for vector-valued elements."
		   << std::endl;
      libmesh_not_implemented();
    }

  AutoPtr<QBase> qrule =
    fe_type.default_quadrature_rule (dim,
                                     _extra_order);

  // Construct finite element object

  AutoPtr<FEGenericBase<OutputShape> > fe(FEGenericBase<OutputShape>::build(dim, fe_type));

  // Attach quadrature rule to FE object
  fe->attach_quadrature_rule (qrule.get());

  // The Jacobian*weight at the quadrature points.
  const std::vector<Real>& JxW                               = fe->get_JxW();

  // The value of the shape functions at the quadrature points
  // i.e. phi(i) = phi_values[i][qp]
  const std::vector<std::vector<OutputShape> >&  phi_values         = fe->get_phi();

  // The value of the shape function gradients at the quadrature points
  const std::vector<std::vector<typename FEGenericBase<OutputShape>::OutputGradient> >& 
		    dphi_values = fe->get_dphi();

  // The value of the shape function curls at the quadrature points
  // Only computed for vector-valued elements
  const std::vector<std::vector<typename FEGenericBase<OutputShape>::OutputShape> >* curl_values = NULL;

  // The value of the shape function divergences at the quadrature points
  // Only computed for vector-valued elements
  const std::vector<std::vector<typename FEGenericBase<OutputShape>::OutputDivergence> >* div_values = NULL;

  if( FEInterface::field_type(fe_type) == TYPE_VECTOR )
    {
      curl_values = &fe->get_curl_phi();
      div_values = &fe->get_div_phi();
    }

#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
  // The value of the shape function second derivatives at the quadrature points
  const std::vector<std::vector<typename FEGenericBase<OutputShape>::OutputTensor> >& 
		    d2phi_values = fe->get_d2phi(); 
#endif

  // The XYZ locations (in physical space) of the quadrature points
  const std::vector<Point>& q_point                          = fe->get_xyz();

  // The global degree of freedom indices associated
  // with the local degrees of freedom.
  std::vector<dof_id_type> dof_indices;


  //
  // Begin the loop over the elements
  //
  // TODO: this ought to be threaded (and using subordinate
  // MeshFunction objects in each thread rather than a single
  // master)
  MeshBase::const_element_iterator       el     = _mesh.active_local_elements_begin();
  const MeshBase::const_element_iterator end_el = _mesh.active_local_elements_end();

  for ( ; el != end_el; ++el)
    {
      // Store a pointer to the element we are currently
      // working on.  This allows for nicer syntax later.
      const Elem* elem = *el;

      // reinitialize the element-specific data
      // for the current element
      fe->reinit (elem);

      // Get the local to global degree of freedom maps
      computed_dof_map.dof_indices    (elem, dof_indices, var);

      // The number of quadrature points
      const unsigned int n_qp = qrule->n_points();

      // The number of shape functions
      const unsigned int n_sf = 
	libmesh_cast_int<unsigned int>(dof_indices.size());

      //
      // Begin the loop over the Quadrature points.
      //
      for (unsigned int qp=0; qp<n_qp; qp++)
	{
	  // Real u_h = 0.;
	  // RealGradient grad_u_h;

	  typename FEGenericBase<OutputShape>::OutputNumber u_h = 0.;

	  typename FEGenericBase<OutputShape>::OutputNumberGradient grad_u_h;
#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
	  typename FEGenericBase<OutputShape>::OutputNumberTensor grad2_u_h;
#endif
	  typename FEGenericBase<OutputShape>::OutputNumber curl_u_h = 0.0;
	  typename FEGenericBase<OutputShape>::OutputNumberDivergence div_u_h = 0.0;

	  // Compute solution values at the current
	  // quadrature point.  This reqiures a sum
	  // over all the shape functions evaluated
	  // at the quadrature point.
	  for (unsigned int i=0; i<n_sf; i++)
	    {
	      // Values from current solution.
	      u_h      += phi_values[i][qp]*computed_system.current_solution  (dof_indices[i]);
	      grad_u_h += dphi_values[i][qp]*computed_system.current_solution (dof_indices[i]);
#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
	      grad2_u_h += d2phi_values[i][qp]*computed_system.current_solution (dof_indices[i]);
#endif
	      if( FEInterface::field_type(fe_type) == TYPE_VECTOR )
		{
		  curl_u_h += (*curl_values)[i][qp]*computed_system.current_solution (dof_indices[i]);
		  div_u_h += (*div_values)[i][qp]*computed_system.current_solution (dof_indices[i]);
		}
	    }

	  // Compute the value of the error at this quadrature point
	  typename FEGenericBase<OutputShape>::OutputNumber exact_val = 0;
	  RawAccessor<typename FEGenericBase<OutputShape>::OutputNumber> exact_val_accessor( exact_val, dim );
          if (_exact_values.size() > sys_num && _exact_values[sys_num])
	    {
	      for( unsigned int c = 0; c < n_vec_dim; c++)
		exact_val_accessor(c) =
		  _exact_values[sys_num]->
		  component(var_component+c, q_point[qp], time);
	    }
	  else if (_equation_systems_fine)
	    {
	      // FIXME: Needs to be updated for vector-valued elements
	      exact_val = (*coarse_values)(q_point[qp]);
	    }
	  const typename FEGenericBase<OutputShape>::OutputNumber val_error = u_h - exact_val;

	  // Add the squares of the error to each contribution
	  Real error_sq = TensorTools::norm_sq(val_error);
	  error_vals[0] += JxW[qp]*error_sq;

	  Real norm = sqrt(error_sq);
	  error_vals[3] += JxW[qp]*norm;

	  if(error_vals[4]<norm) { error_vals[4] = norm; }

	  // Compute the value of the error in the gradient at this
	  // quadrature point
	  typename FEGenericBase<OutputShape>::OutputNumberGradient exact_grad;
	  RawAccessor<typename FEGenericBase<OutputShape>::OutputNumberGradient> exact_grad_accessor( exact_grad, _mesh.spatial_dimension() );
	  if (_exact_derivs.size() > sys_num && _exact_derivs[sys_num])
	    {
	      for( unsigned int c = 0; c < n_vec_dim; c++)
		for( unsigned int d = 0; d < _mesh.spatial_dimension(); d++ )
		  exact_grad_accessor(d + c*_mesh.spatial_dimension() ) =
		    _exact_derivs[sys_num]->
		    component(var_component+c, q_point[qp], time)(d);
	    }
	  else if (_equation_systems_fine)
	    {
	      // FIXME: Needs to be updated for vector-valued elements
	      exact_grad = coarse_values->gradient(q_point[qp]);
	    }

	  const typename FEGenericBase<OutputShape>::OutputNumberGradient grad_error = grad_u_h - exact_grad;
	  
	  error_vals[1] += JxW[qp]*grad_error.size_sq();


	  if( FEInterface::field_type(fe_type) == TYPE_VECTOR )
	    {
	      // Compute the value of the error in the curl at this
	      // quadrature point
	      typename FEGenericBase<OutputShape>::OutputNumber exact_curl = 0.0;
	      if (_exact_derivs.size() > sys_num && _exact_derivs[sys_num])
		{
		  exact_curl = TensorTools::curl_from_grad( exact_grad );
		}
	      else if (_equation_systems_fine)
		{
		  // FIXME: Need to implement curl for MeshFunction and support reference
		  //        solution for vector-valued elements
		}

	      const typename FEGenericBase<OutputShape>::OutputNumber curl_error = curl_u_h - exact_curl;
	      
	      error_vals[5] += JxW[qp]*TensorTools::norm_sq(curl_error);

	      // Compute the value of the error in the divergence at this
	      // quadrature point
	      typename FEGenericBase<OutputShape>::OutputNumberDivergence exact_div = 0.0;
	      if (_exact_derivs.size() > sys_num && _exact_derivs[sys_num])
		{
		  exact_div = TensorTools::div_from_grad( exact_grad );
		}
	      else if (_equation_systems_fine)
		{
		  // FIXME: Need to implement div for MeshFunction and support reference
		  //        solution for vector-valued elements
		}
	      
	      const typename FEGenericBase<OutputShape>::OutputNumberDivergence div_error = div_u_h - exact_div;
	      
	      error_vals[6] += JxW[qp]*TensorTools::norm_sq(div_error);
	    }

#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
	  // Compute the value of the error in the hessian at this
	  // quadrature point
	  typename FEGenericBase<OutputShape>::OutputNumberTensor exact_hess;
	  RawAccessor<typename FEGenericBase<OutputShape>::OutputNumberTensor> exact_hess_accessor( exact_hess, dim );
	  if (_exact_hessians.size() > sys_num && _exact_hessians[sys_num])
	    {
	      //FIXME: This needs to be implemented to support rank 3 tensors 
	      //       which can't happen until type_n_tensor is fully implemented
	      //       and a RawAccessor<TypeNTensor> is fully implemented
	      if( FEInterface::field_type(fe_type) == TYPE_VECTOR )
		libmesh_not_implemented();

	      for( unsigned int c = 0; c < n_vec_dim; c++)
		for( unsigned int d = 0; d < dim; d++ )
		  for( unsigned int e =0; e < dim; e++ )
		    exact_hess_accessor(d + e*dim + c*dim*dim) =
		      _exact_hessians[sys_num]->
		      component(var_component+c, q_point[qp], time)(d,e);
	    }
	  else if (_equation_systems_fine)
	    {
	      // FIXME: Needs to be updated for vector-valued elements
	      exact_hess = coarse_values->hessian(q_point[qp]);
	    }
	  
	  const typename FEGenericBase<OutputShape>::OutputNumberTensor grad2_error = grad2_u_h - exact_hess;
	  
	  // FIXME: PB: Is this what we want for rank 3 tensors?
	  error_vals[2] += JxW[qp]*grad2_error.size_sq();
#endif

	} // end qp loop
    } // end element loop

  // Add up the error values on all processors, except for the L-infty
  // norm, for which the maximum is computed.
  Real l_infty_norm = error_vals[4];
  CommWorld.max(l_infty_norm);
  CommWorld.sum(error_vals);
  error_vals[4] = l_infty_norm;
}
  bool GasRecombinationCatalyticWall<Chemistry>::eval_flux( bool compute_jacobian,
                                                            AssemblyContext& context,
                                                            libMesh::Real sign,
                                                            bool is_axisymmetric )
  {
    libMesh::FEGenericBase<libMesh::Real>* side_fe = NULL;
    context.get_side_fe( _reactant_var_idx, side_fe );

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

    libmesh_assert_equal_to( n_var_dofs, context.get_dof_indices(_product_var_idx).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<libMesh::Real> >& var_phi_side = side_fe->get_phi();

    // Physical location of the quadrature points
    const std::vector<libMesh::Point>& var_qpoint = side_fe->get_xyz();

    // reactant residual
    libMesh::DenseSubVector<libMesh::Number> &F_r_var = context.get_elem_residual(_reactant_var_idx);

    // product residual
    libMesh::DenseSubVector<libMesh::Number> &F_p_var = context.get_elem_residual(_product_var_idx);

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

    for (unsigned int qp=0; qp != n_qpoints; qp++)
      {
        libMesh::Real jac = JxW_side[qp];

        if(is_axisymmetric)
          {
            const libMesh::Number r = var_qpoint[qp](0);
            jac *= r;
          }

        std::vector<libMesh::Real> mass_fractions(this->_chem_ptr->n_species());
        for( unsigned int s = 0; s < this->_chem_ptr->n_species(); s++ )
          mass_fractions[s] = context.side_value(this->_species_vars[s], qp);

        libMesh::Real Y_r = mass_fractions[this->_reactant_species_idx];
        libMesh::Real T =  context.side_value(this->_T_var, qp);
        libMesh::Real R_mix = this->_chem_ptr->R_mix(mass_fractions);
        libMesh::Real rho = this->rho( T, this->_p0, R_mix );

         const libMesh::Real r_value = this->compute_reactant_mass_flux(rho, Y_r, T);

         const libMesh::Real p_value = -r_value;

         for (unsigned int i=0; i != n_var_dofs; i++)
          {
            F_r_var(i) += sign*r_value*var_phi_side[i][qp]*jac;

            F_p_var(i) += sign*p_value*var_phi_side[i][qp]*jac;

            if( compute_jacobian )
              libmesh_not_implemented();
          }
      }

    // We're not computing the Jacobian yet
    return false;
  }
  void GasRecombinationCatalyticWall<Chemistry>::apply_fluxes( AssemblyContext& context,
                                                               const CachedValues& cache,
                                                               const bool request_jacobian )
  {
    libmesh_do_once(libmesh_deprecated());

    libMesh::FEGenericBase<libMesh::Real>* side_fe = NULL;
    context.get_side_fe( _reactant_var_idx, side_fe );

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

    libmesh_assert_equal_to( n_var_dofs, context.get_dof_indices(_product_var_idx).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<libMesh::Real> >& var_phi_side = side_fe->get_phi();

    // Physical location of the quadrature points
    const std::vector<libMesh::Point>& var_qpoint = side_fe->get_xyz();

    // reactant residual
    libMesh::DenseSubVector<libMesh::Number> &F_r_var = context.get_elem_residual(_reactant_var_idx);

    // product residual
    libMesh::DenseSubVector<libMesh::Number> &F_p_var = context.get_elem_residual(_product_var_idx);

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

    for (unsigned int qp=0; qp != n_qpoints; qp++)
      {
        libMesh::Real jac = JxW_side[qp];

        if(Physics::is_axisymmetric())
          {
            const libMesh::Number r = var_qpoint[qp](0);
            jac *= r;
          }

        const libMesh::Real rho = cache.get_cached_values(Cache::MIXTURE_DENSITY)[qp];

        const libMesh::Real Y_r = cache.get_cached_vector_values(Cache::MASS_FRACTIONS)[qp][this->_reactant_species_idx];

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

        const libMesh::Real r_value = this->compute_reactant_mass_flux(rho, Y_r, T);

        const libMesh::Real p_value = -r_value;

        for (unsigned int i=0; i != n_var_dofs; i++)
          {
            F_r_var(i) += r_value*var_phi_side[i][qp]*jac;

            F_p_var(i) += p_value*var_phi_side[i][qp]*jac;

            if( request_jacobian )
              {
                libmesh_not_implemented();
              }
          }
      }
  }
Esempio n. 19
0
void InfFE<Dim,T_radial,T_base>::reinit(const Elem* inf_elem,
                                        const unsigned int s,
                                        const Real tolerance,
                                        const std::vector<Point>* const pts,
                                        const std::vector<Real>* const weights)
{
  if (weights != NULL)
    {
      libMesh::err << "ERROR: User-specified weights for infinite elements "
                   << "are not implemented!" << std::endl;
      libmesh_not_implemented();
    }

  if (pts != NULL)
    {
      libMesh::err << "ERROR: User-specified points for infinite elements "
                   << "are not implemented!" << std::endl;
      libmesh_not_implemented();
    }

  // We don't do this for 1D elements!
  libmesh_assert_not_equal_to (Dim, 1);

  libmesh_assert(inf_elem);
  libmesh_assert(qrule);

  // Don't do this for the base
  libmesh_assert_not_equal_to (s, 0);

  // Build the side of interest
  const AutoPtr<Elem> side(inf_elem->build_side(s));

  // set the element type
  elem_type = inf_elem->type();

  // eventually initialize radial quadrature rule
  bool radial_qrule_initialized = false;

  if (current_fe_type.radial_order != fe_type.radial_order)
    {
      current_fe_type.radial_order = fe_type.radial_order;
      radial_qrule->init(EDGE2, inf_elem->p_level());
      radial_qrule_initialized = true;
    }

  // Initialize the face shape functions
  if (this->get_type() != inf_elem->type() ||
      base_fe->shapes_need_reinit()        ||
      radial_qrule_initialized)
    this->init_face_shape_functions (qrule->get_points(), side.get());


  // compute the face map
  this->_fe_map->compute_face_map(this->dim, _total_qrule_weights, side.get());

  // make a copy of the Jacobian for integration
  const std::vector<Real> JxW_int(this->_fe_map->get_JxW());

  // Find where the integration points are located on the
  // full element.
  std::vector<Point> qp; this->inverse_map (inf_elem, this->_fe_map->get_xyz(),
                                            qp, tolerance);

  // compute the shape function and derivative values
  // at the points qp
  this->reinit  (inf_elem, &qp);

  // copy back old data
  this->_fe_map->get_JxW() = JxW_int;

}
Esempio n. 20
0
void EpetraMatrix<T>::get_transpose (SparseMatrix<T>&) const
{
  libmesh_not_implemented();
}
Esempio n. 21
0
void ElemCutter::cut_3D (const Elem & elem,
                         const std::vector<Real> & vertex_distance_func)
{
#ifndef LIBMESH_HAVE_TETGEN

  // current implementation requires tetgen!
  libMesh::err << "ERROR: current libMesh ElemCutter 3D implementation requires\n"
               << "       the \"tetgen\" library!\n"
               << std::endl;
  libmesh_not_implemented();

#else // OK, LIBMESH_HAVE_TETGEN

  std::cout << "Inside cut cell element!\n";

  libmesh_assert (_inside_mesh_3D.get()  != nullptr);
  libmesh_assert (_outside_mesh_3D.get() != nullptr);

  _inside_mesh_3D->clear();
  _outside_mesh_3D->clear();

  for (unsigned int v=0; v<elem.n_vertices(); v++)
    {
      if (vertex_distance_func[v] >= 0.)
        _outside_mesh_3D->add_point (elem.point(v));

      if (vertex_distance_func[v] <= 0.)
        _inside_mesh_3D->add_point (elem.point(v));
    }

  for (const auto & pt : _intersection_pts)
    {
      _inside_mesh_3D->add_point(pt);
      _outside_mesh_3D->add_point(pt);
    }


  // Triangulate!
  _tetgen_inside->triangulate_pointset();
  //_inside_mesh_3D->print_info();
  _tetgen_outside->triangulate_pointset();
  //_outside_mesh_3D->print_info();


  // (below generates some horribly expensive meshes,
  //  but seems immune to the 0 volume problem).
  // _tetgen_inside->pointset_convexhull();
  // _inside_mesh_3D->find_neighbors();
  // _inside_mesh_3D->print_info();
  // _tetgen_inside->triangulate_conformingDelaunayMesh (1.e3, 100.);
  // _inside_mesh_3D->print_info();

  // _tetgen_outside->pointset_convexhull();
  // _outside_mesh_3D->find_neighbors();
  // _outside_mesh_3D->print_info();
  // _tetgen_outside->triangulate_conformingDelaunayMesh (1.e3, 100.);
  // _outside_mesh_3D->print_info();

  std::ostringstream name;

  name << "cut_cell_"
       << cut_cntr++
       << ".dat";
  _inside_mesh_3D->write  ("in_"  + name.str());
  _outside_mesh_3D->write ("out_" + name.str());

  // finally, add the elements to our lists.
  _inside_elem.clear();
  _outside_elem.clear();

  for (const auto & elem : _inside_mesh_3D->element_ptr_range())
    if (elem->volume() > std::numeric_limits<Real>::epsilon())
      _inside_elem.push_back (elem);

  for (const auto & elem : _outside_mesh_3D->element_ptr_range())
    if (elem->volume() > std::numeric_limits<Real>::epsilon())
      _outside_elem.push_back (elem);

#endif
}
Esempio n. 22
0
void ElemCutter::cut_2D (const Elem & elem,
                         const std::vector<Real> & vertex_distance_func)
{
#ifndef LIBMESH_HAVE_TRIANGLE

  // current implementation requires triangle!
  libMesh::err << "ERROR: current libMesh ElemCutter 2D implementation requires\n"
               << "       the \"triangle\" library!\n"
               << std::endl;
  libmesh_not_implemented();

#else // OK, LIBMESH_HAVE_TRIANGLE

  std::cout << "Inside cut face element!\n";

  libmesh_assert (_inside_mesh_2D.get()  != nullptr);
  libmesh_assert (_outside_mesh_2D.get() != nullptr);

  _inside_mesh_2D->clear();
  _outside_mesh_2D->clear();

  for (unsigned int v=0; v<elem.n_vertices(); v++)
    {
      if (vertex_distance_func[v] >= 0.)
        _outside_mesh_2D->add_point (elem.point(v));

      if (vertex_distance_func[v] <= 0.)
        _inside_mesh_2D->add_point (elem.point(v));
    }

  for (const auto & pt : _intersection_pts)
    {
      _inside_mesh_2D->add_point(pt);
      _outside_mesh_2D->add_point(pt);
    }


  // Customize the variables for the triangulation
  // we will be cutting reference cell, and want as few triangles
  // as possible, so jack this up larger than the area we will be
  // triangulating so we are governed only by accurately defining
  // the boundaries.
  _triangle_inside->desired_area()  = 100.;
  _triangle_outside->desired_area() = 100.;

  // allow for small angles
  _triangle_inside->minimum_angle()  = 5.;
  _triangle_outside->minimum_angle() = 5.;

  // Turn off Laplacian mesh smoothing after generation.
  _triangle_inside->smooth_after_generating()  = false;
  _triangle_outside->smooth_after_generating() = false;

  // Triangulate!
  _triangle_inside->triangulate();
  _triangle_outside->triangulate();

  // std::ostringstream name;

  // name << "cut_face_"
  //  << cut_cntr++
  //  << ".dat";
  // _inside_mesh_2D->write  ("in_"  + name.str());
  // _outside_mesh_2D->write ("out_" + name.str());

  // finally, add the elements to our lists.
  _inside_elem.clear();
  _outside_elem.clear();

  for (const auto & elem : _inside_mesh_2D->element_ptr_range())
    _inside_elem.push_back (elem);

  for (const auto & elem : _outside_mesh_2D->element_ptr_range())
    _outside_elem.push_back (elem);

#endif
}
LinearConvergenceReason AztecLinearSolver<T>::get_converged_reason() const
{
  libmesh_not_implemented();

  return UNKNOWN_FLAG;
}
Esempio n. 24
0
void LaspackMatrix<T>::get_diagonal (NumericVector<T>& /*dest*/) const
{
  libmesh_not_implemented();
}
Esempio n. 25
0
void LaspackMatrix<T>::get_transpose (SparseMatrix<T>& /*dest*/) const
{
  libmesh_not_implemented();
}
Esempio n. 26
0
RealGradient FE<3,NEDELEC_ONE>::shape_second_deriv(const Elem * elem,
                                                   const Order order,
                                                   const unsigned int i,
                                                   const unsigned int j,
                                                   const Point & libmesh_dbg_var(p))
{
#if LIBMESH_DIM == 3

  libmesh_assert(elem);

  // j = 0 ==> d^2 phi / dxi^2
  // j = 1 ==> d^2 phi / dxi deta
  // j = 2 ==> d^2 phi / deta^2
  // j = 3 ==> d^2 phi / dxi dzeta
  // j = 4 ==> d^2 phi / deta dzeta
  // j = 5 ==> d^2 phi / dzeta^2
  libmesh_assert_less (j, 6);

  const Order totalorder = static_cast<Order>(order + elem->p_level());

  switch (totalorder)
    {
      // linear Lagrange shape functions
    case FIRST:
      {
        switch (elem->type())
          {
          case HEX20:
          case HEX27:
            {
              libmesh_assert_less (i, 12);

#ifndef NDEBUG
              const Real xi   = p(0);
              const Real eta  = p(1);
              const Real zeta = p(2);
#endif

              libmesh_assert_less_equal ( std::fabs(xi),   1.0+TOLERANCE );
              libmesh_assert_less_equal ( std::fabs(eta),  1.0+TOLERANCE );
              libmesh_assert_less_equal ( std::fabs(zeta), 1.0+TOLERANCE );

              switch (j)
                {
                  // d^2()/dxi^2
                case 0:
                  {
                    // All d^2()/dxi^2 derivatives for linear hexes are zero.
                    return RealGradient();
                  } // j=0

                  // d^2()/dxideta
                case 1:
                  {
                    switch(i)
                      {
                      case 0:
                      case 1:
                      case 2:
                      case 3:
                      case 8:
                      case 9:
                      case 10:
                      case 11:
                        return RealGradient();
                      case 4:
                        {
                          if( elem->point(0) > elem->point(4) )
                            return RealGradient( 0.0, 0.0, -0.125 );
                          else
                            return RealGradient( 0.0, 0.0,  0.125 );
                        }
                      case 5:
                        {
                          if( elem->point(1) > elem->point(5) )
                            return RealGradient( 0.0, 0.0,  0.125 );
                          else
                            return RealGradient( 0.0, 0.0, -0.125 );
                        }
                      case 6:
                        {
                          if( elem->point(2) > elem->point(6) )
                            return RealGradient( 0.0, 0.0, -0.125 );
                          else
                            return RealGradient( 0.0, 0.0,  0.125 );
                        }
                      case 7:
                        {
                          if( elem->point(3) > elem->point(7) )
                            return RealGradient( 0.0, 0.0,  0.125 );
                          else
                            return RealGradient( 0.0, 0.0, -0.125 );
                        }
                      default:
                        libmesh_error_msg("Invalid i = " << i);
                      } // switch(i)

                  } // j=1

                  // d^2()/deta^2
                case 2:
                  {
                    // All d^2()/deta^2 derivatives for linear hexes are zero.
                    return RealGradient();
                  } // j = 2

                  // d^2()/dxidzeta
                case 3:
                  {
                    switch(i)
                      {
                      case 0:
                      case 2:
                      case 4:
                      case 5:
                      case 6:
                      case 7:
                      case 8:
                      case 10:
                        return RealGradient();

                      case 1:
                        {
                          if( elem->point(1) > elem->point(2) )
                            return RealGradient( 0.0,  0.125 );
                          else
                            return RealGradient( 0.0, -0.125 );
                        }
                      case 3:
                        {
                          if( elem->point(3) > elem->point(0) )
                            return RealGradient( 0.0, -0.125 );
                          else
                            return RealGradient( 0.0,  0.125 );
                        }
                      case 9:
                        {
                          if( elem->point(5) > elem->point(6) )
                            return RealGradient( 0.0, -0.125, 0.0 );
                          else
                            return RealGradient( 0.0,  0.125, 0.0 );
                        }
                      case 11:
                        {
                          if( elem->point(4) > elem->point(7) )
                            return RealGradient( 0.0,  0.125, 0.0 );
                          else
                            return RealGradient( 0.0, -0.125, 0.0 );
                        }
                      default:
                        libmesh_error_msg("Invalid i = " << i);
                      } // switch(i)

                  } // j = 3

                  // d^2()/detadzeta
                case 4:
                  {
                    switch(i)
                      {
                      case 1:
                      case 3:
                      case 4:
                      case 5:
                      case 6:
                      case 7:
                      case 9:
                      case 11:
                        return RealGradient();

                      case 0:
                        {
                          if( elem->point(0) > elem->point(1) )
                            return RealGradient( -0.125, 0.0, 0.0 );
                          else
                            return RealGradient(  0.125, 0.0, 0.0 );
                        }
                      case 2:
                        {
                          if( elem->point(2) > elem->point(3) )
                            return RealGradient(  0.125, 0.0, 0.0 );
                          else
                            return RealGradient( -0.125, 0.0, 0.0 );
                        }
                      case 8:
                        {
                          if( elem->point(4) > elem->point(5) )
                            return RealGradient(  0.125, 0.0, 0.0 );
                          else
                            return RealGradient( -0.125, 0.0, 0.0 );
                        }
                      case 10:
                        {
                          if( elem->point(7) > elem->point(6) )
                            return RealGradient( -0.125, 0.0, 0.0 );
                          else
                            return RealGradient(  0.125, 0.0, 0.0 );
                        }
                      default:
                        libmesh_error_msg("Invalid i = " << i);
                      } // switch(i)

                  } // j = 4

                  // d^2()/dzeta^2
                case 5:
                  {
                    // All d^2()/dzeta^2 derivatives for linear hexes are zero.
                    return RealGradient();
                  } // j = 5

                default:
                  libmesh_error_msg("Invalid j = " << j);
                }

              return RealGradient();
            }

          case TET10:
            {
              libmesh_assert_less (i, 6);

              libmesh_not_implemented();
              return RealGradient();
            }

          default:
            libmesh_error_msg("ERROR: Unsupported 3D element type!: " << elem->type());

          } //switch(type)

      } // case FIRST:
      // unsupported order
    default:
      libmesh_error_msg("ERROR: Unsupported 3D FE order!: " << totalorder);
    }

#endif

  libmesh_error_msg("We'll never get here!");
  return RealGradient();
}
void AztecLinearSolver<T>::get_residual_history(std::vector<double>& /* hist */)
{
  libmesh_not_implemented();
}
Esempio n. 28
0
bool Tet10::is_child_on_side(const unsigned int /*c*/,
                             const unsigned int /*s*/) const
{
  libmesh_not_implemented();
  return false;
}
Esempio n. 29
0
void NoSolutionHistory::retrieve()
{
  // Nothing was stored, so nothing can be retrieved
  libmesh_not_implemented();
}
Esempio n. 30
0
void ElemCutter::cut_1D (const Elem & /*elem*/,
                         const std::vector<Real> &/*vertex_distance_func*/)
{
  libmesh_not_implemented();
}