コード例 #1
0
    UnitTestSetup() {
      rtol = 1e-4;
      atol = 1e-5;
      crtol = 1e-12;
      catol = 1e-12;
      a = 3.1;
      const int d = 2;
      const int p = 7;
      
      // Create product basis
      Teuchos::Array< Teuchos::RCP<const Stokhos::OneDOrthogPolyBasis<int,double> > > bases(d);
      for (int i=0; i<d; i++)
	bases[i] = 
	  Teuchos::rcp(new Stokhos::LegendreBasis<int,double>(p));
      basis =
	Teuchos::rcp(new Stokhos::CompletePolynomialBasis<int,double>(bases));
      
      // Tensor product quadrature
      quad = 
	Teuchos::rcp(new Stokhos::TensorProductQuadrature<int,double>(basis));

      // Triple product tensor
      Cijk = basis->computeTripleProductTensor(basis->size());
      
      // Quadrature expansion
      exp = 
	Teuchos::rcp(new Stokhos::QuadOrthogPolyExpansion<int,double>(basis, Cijk, quad));
      
      // Create approximation
      sz = basis->size();
      x.reset(exp);
      y.reset(exp);
      u.reset(exp); 
      u2.reset(exp);
      cx.reset(exp, 1);
      x.term(0, 0) = 1.0;
      cx.term(0, 0) = a;
      cu.reset(exp);
      cu2.reset(exp, 1);
      sx.reset(exp, d+1);
      su.reset(exp, d+1);
      su2.reset(exp, d+1);
      for (int i=0; i<d; i++) {
	x.term(i, 1) = 0.1;
	sx.term(i, 1) = 0.0;
      }
      y.term(0, 0) = 2.0;
      for (int i=0; i<d; i++)
	y.term(i, 1) = 0.25;
    }
コード例 #2
0
    UnitTestSetup() {
      rtol = 1e-4;
      atol = 1e-5;
      crtol = 1e-12;
      catol = 1e-12;
      a = 3.1;
      const ordinal_type d = 2;
      const ordinal_type p = 7;

      // Create product basis
      Teuchos::Array< Teuchos::RCP<const Stokhos::OneDOrthogPolyBasis<ordinal_type,value_type> > > bases(d);
      for (ordinal_type i=0; i<d; i++)
        bases[i] =
          Teuchos::rcp(new Stokhos::LegendreBasis<ordinal_type,value_type>(p, true));
      basis =
        Teuchos::rcp(new Stokhos::CompletePolynomialBasis<ordinal_type,value_type>(bases));

      // Triple product tensor
      Cijk = basis->computeTripleProductTensor();

      // Kokkos triple product tensor
      cijk = Stokhos::create_product_tensor<execution_space>(*basis, *Cijk);

      // Algebraic expansion
      exp = Teuchos::rcp(new Stokhos::AlgebraicOrthogPolyExpansion<ordinal_type,value_type>(basis, Cijk));

      // Quad expansion for initialization
      Teuchos::RCP<const Stokhos::Quadrature<int,double> > quad =
        Teuchos::rcp(new Stokhos::TensorProductQuadrature<int,double>(basis));
      Teuchos::RCP< Stokhos::QuadOrthogPolyExpansion<int,double> > quad_exp =
        Teuchos::rcp(new Stokhos::QuadOrthogPolyExpansion<int,double>(basis, Cijk, quad));

      // Create approximation
      x_opa.reset(basis);
      y_opa.reset(basis);
      sin_x_opa.reset(basis);
      cos_y_opa.reset(basis);
      cx_opa.reset(basis,1);
      x_opa.term(0, 0) = 1.0;
      y_opa.term(0, 0) = 2.0;
      cx_opa.term(0, 0) = a;
      for (int i=0; i<d; i++) {
        x_opa.term(i, 1) = 0.1;
        y_opa.term(i, 1) = 0.25;
      }
      quad_exp->sin(sin_x_opa, x_opa);
      quad_exp->cos(cos_y_opa, y_opa);

      // Create PCEs
      x.reset(cijk);
      y.reset(cijk);
      sin_x.reset(cijk);
      cos_y.reset(cijk);
      cx.reset(cijk, 1);
      x.load(x_opa.coeff());
      y.load(y_opa.coeff());
      sin_x.load(sin_x_opa.coeff());
      cos_y.load(cos_y_opa.coeff());
      cx.load(cx_opa.coeff());

      u.reset(cijk);
      u2.reset(cijk);
      cu.reset(cijk);
      cu2.reset(cijk, 1);
      sx.reset(cijk, d+1);
      su.reset(cijk, d+1);
      su2.reset(cijk, d+1);
      for (ordinal_type i=0; i<d; i++) {
        sx.fastAccessCoeff(i+1) = 0.0;
      }
    }