// constructors
 ParallelEvolver(const operator_type& L,
                 const bc_set& bcs) {
     evolvers_.reserve(L.size());
     for (Size i=0; i < L.size(); i++) {
         evolvers_.push_back(boost::shared_ptr<Evolver>(new
                             Evolver(L[i], bcs[i])));
     }
 }
// ===================================================
// Methods
// ===================================================
Int
PreconditionerIfpack::buildPreconditioner( operator_type& matrix )
{
    M_operator     = matrix->matrixPtr();

    M_overlapLevel = this->M_list.get( "overlap level", -1 );

    M_precType     = this->M_list.get( "prectype", "Amesos" );

    Ifpack factory;

    M_preconditioner.reset( factory.Create( M_precType, M_operator.get(), M_overlapLevel ) );

    M_precType += "_Ifpack";

    if ( !M_preconditioner.get() )
    {
        ERROR_MSG( "Preconditioner not set, something went wrong in its computation\n" );
    }

    IFPACK_CHK_ERR( M_preconditioner->SetParameters( this->M_list ) );
    IFPACK_CHK_ERR( M_preconditioner->Initialize() );
    IFPACK_CHK_ERR( M_preconditioner->Compute() );

    this->M_preconditionerCreated = true;

    return ( EXIT_SUCCESS );
}
Beispiel #3
0
    //! Compute Lanczos basis
    static void computeNormalized(ordinal_type k, 
				  const vectorspace_type& vs,
				  const operator_type& A,
				  const vector_type& u_init,
				  matrix_type& u,
				  Teuchos::Array<value_type>& alpha,
				  Teuchos::Array<value_type>& beta,
				  Teuchos::Array<value_type>& nrm_sqrd) {

      // u[i-1], u[i], u[i+1]
      vector_type u0, u1, u2;

      // set starting vector
      u0 = Teuchos::getCol(Teuchos::View, u, 0);
      u0.assign(u_init);
      u1 = u0;

      vector_type v = vs.create_vector();
      for (ordinal_type i=0; i<k; i++) {

	// Compute (u_i,u_i)
	beta[i] = std::sqrt(vs.inner_product(u1, u1));
	u1.scale(1.0/beta[i]);
	nrm_sqrd[i] = value_type(1.0);

	// Compute v = A*u_i
        A.apply(u1, v);

	// Compute (v,u_i)
	alpha[i] = vs.inner_product(u1, v);

	// Compute u_{i+1} = v - alpha_i*u_i - beta_i*u_{i-1}
	if (i < k-1) {
	  u2 = Teuchos::getCol(Teuchos::View, u, i+1);
	  if (i == 0) 
	    vs.add2(value_type(1), v, -alpha[i], u1, u2);
	  else
	    vs.add3(value_type(1), v, -alpha[i], u1, -beta[i], u0, u2);
	  gramSchmidt(i+1, vs, u, u2);
	}

	// std::cout << "i = " << i 
	// 	  << " alpha = " << alpha[i] << " beta = " << beta[i]
	// 	  << " nrm = " << nrm_sqrd[i] << std::endl;
        TEUCHOS_TEST_FOR_EXCEPTION(nrm_sqrd[i] < 0, std::logic_error,
	       	           "Stokhos::LanczosProjPCEBasis::lanczos():  "
		           << " Polynomial " << i << " out of " << k
		           << " has norm " << nrm_sqrd[i] << "!");

	// Shift -- these are just pointer copies
	u0 = u1;
	u1 = u2;		  

      }
    }
Beispiel #4
0
        static int do_print(
            FILE *ff,
            const tdop_type &tdop,
            const operator_type op
        ) throw() {
            if(op.is_category()) {
                category_type cat;
                unsigned lower_bound(0);

                if(op.match(cat, lower_bound)) {
                    int num(do_print(ff, tdop, cat));
                    num += fprintf(ff, "(%u)", lower_bound);
                    return num;

                } else if(op.match(cat)) {
                    return do_print(ff, tdop, cat);

                } else {
                    assert(false);
                }

            } else if(op.is_symbol()) {
                int num(0);
                if(op.is_symbol_predicate()) {
                    num += fprintf(ff, "&");
                }

                symbol_type sym;
                op.match(sym);

                return num + do_print(ff, tdop, sym);
            }

            return 0;
        }
Beispiel #5
0
 // constructors
 TRBDF2(const operator_type& L,
        const bc_set& bcs)
 : L_(L), I_(operator_type::identity(L.size())),
   dt_(0.0), bcs_(bcs), alpha_(2.0-sqrt(2.0)) {}
Beispiel #6
0
 // constructors
 MixedScheme(const operator_type& L,
             Real theta,
             const bc_set& bcs)
 : L_(L), I_(operator_type::identity(L.size())),
   dt_(0.0), theta_(theta) , bcs_(bcs) {}