Example #1
0
bool compareRank1(const vector_type& y,
                          const vector_type& y_exp,
                          const scalar_type rel_tol,
                          const scalar_type abs_tol,
                          Teuchos::FancyOStream& out)
{
  typedef typename vector_type::size_type size_type;
  typename vector_type::HostMirror hy = Kokkos::create_mirror_view(y);
  typename vector_type::HostMirror hy_exp = Kokkos::create_mirror_view(y_exp);
  Kokkos::deep_copy(hy, y);
  Kokkos::deep_copy(hy_exp, y_exp);

  size_type num_rows = y.dimension_0();
  bool success = true;
  for (size_type i=0; i<num_rows; ++i) {
    for (size_type j=0; j<y.sacado_size(); ++j) {
      scalar_type diff = std::abs( hy(i).fastAccessCoeff(j) - hy_exp(i).fastAccessCoeff(j) );
      scalar_type tol = rel_tol*std::abs(hy_exp(i).fastAccessCoeff(j)) + abs_tol;
      bool s = diff < tol;
      out << "y_expected(" << i << ").coeff(" << j << ") - "
          << "y(" << i << ").coeff(" << j << ") = " << hy_exp(i).fastAccessCoeff(j)
          << " - " << hy(i).fastAccessCoeff(j) << " == "
          << diff << " < " << tol << " : ";
      if (s)
        out << "passed";
      else
        out << "failed";
      out << std::endl;
      success = success && s;
    }
  }
  return success;
}
Example #2
0
  static void apply( const value_type&   alpha ,
		     const vector_type & x ,
		     const value_type &  beta ,
                     const vector_type & y )
  {
    const size_t row_count = x.dimension_0() ;
    parallel_for( row_count , Update(alpha,x,beta,y) );
  }
Example #3
0
 static void apply( const vector_type    & solution ,
                    const mesh_type      & mesh ,
                    const ScalarCoordType  bc_lower_z ,
                    const ScalarCoordType  bc_upper_z ,
                    const ScalarType       bc_lower_value ,
                    const ScalarType       bc_upper_value )
 {
   DirichletSolution op ;
   op.node_coords    = mesh.node_coords ;
   op.solution       = solution ;
   op.bc_lower_z     = bc_lower_z ;
   op.bc_upper_z     = bc_upper_z ;
   op.bc_lower_value = bc_lower_value ;
   op.bc_upper_value = bc_upper_value ;
   parallel_for( solution.dimension_0() , op );
 }