Index: include/aspect/postprocess/interface.h =================================================================== --- include/aspect/postprocess/interface.h (revision 796) +++ include/aspect/postprocess/interface.h (working copy) @@ -7,6 +7,7 @@ #ifndef __aspect__postprocess_interface_h #define __aspect__postprocess_interface_h +#include #include #include #include @@ -278,7 +279,7 @@ * @note In general the vector is a distributed vector; however, it * contains ghost elements for all locally relevant degrees of freedom. */ - const TrilinosWrappers::MPI::BlockVector & + const LinearAlgebra::BlockVector & get_solution () const; /** @@ -290,7 +291,7 @@ * @note In general the vector is a distributed vector; however, it * contains ghost elements for all locally relevant degrees of freedom. */ - const TrilinosWrappers::MPI::BlockVector & + const LinearAlgebra::BlockVector & get_old_solution () const; /** Index: include/aspect/simulator.h =================================================================== --- include/aspect/simulator.h (revision 796) +++ include/aspect/simulator.h (working copy) @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -546,7 +547,7 @@ * This function is implemented in * source/simulator/helper_functions.cc. */ - void make_pressure_rhs_compatible(TrilinosWrappers::MPI::BlockVector &vector); + void make_pressure_rhs_compatible(LinearAlgebra::BlockVector &vector); /** * Computes a running average of a vector. @@ -633,7 +634,7 @@ * This function is implemented in * source/simulator/helper_functions.cc. */ - void normalize_pressure(TrilinosWrappers::MPI::BlockVector &vector); + void normalize_pressure(LinearAlgebra::BlockVector &vector); /** * Compute the maximal velocity throughout the domain. This is needed @@ -642,7 +643,7 @@ * This function is implemented in * source/simulator/helper_functions.cc. */ - double get_maximal_velocity (const TrilinosWrappers::MPI::BlockVector &solution) const; + double get_maximal_velocity (const LinearAlgebra::BlockVector &solution) const; /** * Compute the variation (i.e., the difference between maximal and @@ -787,22 +788,22 @@ * @name Variables that describe the linear systems and solution vectors * @{ */ - TrilinosWrappers::BlockSparseMatrix system_matrix; - TrilinosWrappers::BlockSparseMatrix system_preconditioner_matrix; + LinearAlgebra::BlockSparseMatrix system_matrix; + LinearAlgebra::BlockSparseMatrix system_preconditioner_matrix; - TrilinosWrappers::MPI::BlockVector solution; - TrilinosWrappers::MPI::BlockVector old_solution; - TrilinosWrappers::MPI::BlockVector old_old_solution; - TrilinosWrappers::MPI::BlockVector system_rhs; + LinearAlgebra::BlockVector solution; + LinearAlgebra::BlockVector old_solution; + LinearAlgebra::BlockVector old_old_solution; + LinearAlgebra::BlockVector system_rhs; // only used if is_compressible() - TrilinosWrappers::MPI::BlockVector pressure_shape_function_integrals; + LinearAlgebra::BlockVector pressure_shape_function_integrals; - std_cxx1x::shared_ptr Amg_preconditioner; - std_cxx1x::shared_ptr Mp_preconditioner; - std_cxx1x::shared_ptr T_preconditioner; + std_cxx1x::shared_ptr Amg_preconditioner; + std_cxx1x::shared_ptr Mp_preconditioner; + std_cxx1x::shared_ptr T_preconditioner; bool rebuild_stokes_matrix; bool rebuild_stokes_preconditioner; Index: include/aspect/global.h =================================================================== --- include/aspect/global.h (revision 796) +++ include/aspect/global.h (working copy) @@ -1,13 +1,16 @@ //------------------------------------------------------------- // $Id$ // -// Copyright (C) 2011 by the authors of the ASPECT code +// Copyright (C) 2011, 2012 by the authors of the ASPECT code // //------------------------------------------------------------- #ifndef __aspect__global_h #define __aspect__global_h +#include +#include +#include namespace aspect { @@ -17,6 +20,56 @@ extern const double year_in_seconds; extern const bool output_parallel_statistics; + + /** + * A namespace that contains typedefs for classes used in + * the linear algebra description. + */ + namespace LinearAlgebra + { + using namespace dealii; + + + /** + * Typedef for the vector type used. + */ + typedef TrilinosWrappers::MPI::Vector Vector; + + /** + * Typedef for the type used to describe vectors that + * consist of multiple blocks. + */ + typedef TrilinosWrappers::MPI::BlockVector BlockVector; + + /** + * Typedef for the sparse matrix type used. + */ + typedef TrilinosWrappers::SparseMatrix SparseMatrix; + + /** + * Typedef for the type used to describe sparse matrices that + * consist of multiple blocks. + */ + typedef TrilinosWrappers::BlockSparseMatrix BlockSparseMatrix; + + /** + * Typedef for the AMG preconditioner type used for the + * top left block of the Stokes matrix. + */ + typedef TrilinosWrappers::PreconditionAMG PreconditionAMG; + + /** + * Typedef for the Incomplete Cholesky preconditioner used + * for other blocks of the system matrix. + */ + typedef TrilinosWrappers::PreconditionIC PreconditionIC; + + /** + * Typedef for the Incomplete LU decomposition preconditioner used + * for other blocks of the system matrix. + */ + typedef TrilinosWrappers::PreconditionILU PreconditionILU; + } } Index: source/simulator/checkpoint_restart.cc =================================================================== --- source/simulator/checkpoint_restart.cc (revision 796) +++ source/simulator/checkpoint_restart.cc (working copy) @@ -68,12 +68,12 @@ // save Triangulation and Solution vectors: { - std::vector x_system (3); + std::vector x_system (3); x_system[0] = &solution; x_system[1] = &old_solution; x_system[2] = &old_old_solution; - parallel::distributed::SolutionTransfer + parallel::distributed::SolutionTransfer system_trans (dof_handler); system_trans.prepare_serialization (x_system); @@ -100,18 +100,18 @@ global_volume = GridTools::volume (triangulation, mapping); setup_dofs(); - TrilinosWrappers::MPI::BlockVector + LinearAlgebra::BlockVector distributed_system (system_rhs); - TrilinosWrappers::MPI::BlockVector + LinearAlgebra::BlockVector old_distributed_system (system_rhs); - TrilinosWrappers::MPI::BlockVector + LinearAlgebra::BlockVector old_old_distributed_system (system_rhs); - std::vector x_system (3); + std::vector x_system (3); x_system[0] = & (distributed_system); x_system[1] = & (old_distributed_system); x_system[2] = & (old_old_distributed_system); - parallel::distributed::SolutionTransfer + parallel::distributed::SolutionTransfer system_trans (dof_handler); system_trans.deserialize (x_system); Index: source/simulator/assembly.cc =================================================================== --- source/simulator/assembly.cc (revision 796) +++ source/simulator/assembly.cc (working copy) @@ -731,10 +731,10 @@ DoFTools::extract_constant_modes (dof_handler, velocity_components, constant_modes); - Mp_preconditioner.reset (new TrilinosWrappers::PreconditionILU()); - Amg_preconditioner.reset (new TrilinosWrappers::PreconditionAMG()); + Mp_preconditioner.reset (new LinearAlgebra::PreconditionILU()); + Amg_preconditioner.reset (new LinearAlgebra::PreconditionAMG()); - TrilinosWrappers::PreconditionAMG::AdditionalData Amg_data; + LinearAlgebra::PreconditionAMG::AdditionalData Amg_data; Amg_data.constant_modes = constant_modes; Amg_data.elliptic = true; Amg_data.higher_order_elements = true; @@ -1218,7 +1218,7 @@ computing_timer.exit_section(); computing_timer.enter_section (" Build temperature preconditioner"); - T_preconditioner.reset (new TrilinosWrappers::PreconditionILU()); + T_preconditioner.reset (new LinearAlgebra::PreconditionILU()); T_preconditioner->initialize (system_matrix.block(2,2)); computing_timer.exit_section(); Index: source/simulator/initial_conditions.cc =================================================================== --- source/simulator/initial_conditions.cc (revision 796) +++ source/simulator/initial_conditions.cc (working copy) @@ -35,7 +35,7 @@ // the VectorTools::interpolate function // needs to write into it and we can not // write into vectors with ghost elements - TrilinosWrappers::MPI::BlockVector initial_solution; + LinearAlgebra::BlockVector initial_solution; initial_solution.reinit(system_rhs); // interpolate the initial values @@ -77,7 +77,7 @@ // writable); the stokes_rhs vector is a valid template for // this kind of thing. interpolate into it and later copy it into the // solution vector that does have the necessary ghost elements - TrilinosWrappers::MPI::BlockVector system_tmp; + LinearAlgebra::BlockVector system_tmp; system_tmp.reinit (system_rhs); // interpolate the pressure given by the adiabatic conditions @@ -107,7 +107,7 @@ Assert (system_pressure_fe.dofs_per_face == 0, ExcNotImplemented()); - TrilinosWrappers::MPI::BlockVector system_tmp; + LinearAlgebra::BlockVector system_tmp; system_tmp.reinit (system_rhs); QGauss quadrature(parameters.stokes_velocity_degree+1); Index: source/simulator/helper_functions.cc =================================================================== --- source/simulator/helper_functions.cc (revision 796) +++ source/simulator/helper_functions.cc (working copy) @@ -89,7 +89,7 @@ **/ template double Simulator::get_maximal_velocity ( - const TrilinosWrappers::MPI::BlockVector &solution) const + const LinearAlgebra::BlockVector &solution) const { // use a quadrature formula that has one point at // the location of each degree of freedom in the @@ -267,7 +267,7 @@ * shell and subtracting this from all pressure nodes. */ template - void Simulator::normalize_pressure(TrilinosWrappers::MPI::BlockVector &vector) + void Simulator::normalize_pressure(LinearAlgebra::BlockVector &vector) { double my_pressure = 0.0; double my_area = 0.0; @@ -372,7 +372,7 @@ * information. */ template - void Simulator::make_pressure_rhs_compatible(TrilinosWrappers::MPI::BlockVector &vector) + void Simulator::make_pressure_rhs_compatible(LinearAlgebra::BlockVector &vector) { if (parameters.use_locally_conservative_discretization) throw ExcNotImplemented(); @@ -800,15 +800,15 @@ // explicit instantiation of the functions we implement in this file namespace aspect { - template void Simulator::normalize_pressure(TrilinosWrappers::MPI::BlockVector &vector); + template void Simulator::normalize_pressure(LinearAlgebra::BlockVector &vector); - template double Simulator::get_maximal_velocity (const TrilinosWrappers::MPI::BlockVector &solution) const; + template double Simulator::get_maximal_velocity (const LinearAlgebra::BlockVector &solution) const; template std::pair Simulator::get_extrapolated_temperature_range () const; template double Simulator::compute_time_step () const; - template void Simulator::make_pressure_rhs_compatible(TrilinosWrappers::MPI::BlockVector &vector); + template void Simulator::make_pressure_rhs_compatible(LinearAlgebra::BlockVector &vector); template void Simulator::compute_depth_average_temperature(std::vector &values) const; Index: source/simulator/core.cc =================================================================== --- source/simulator/core.cc (revision 796) +++ source/simulator/core.cc (working copy) @@ -578,7 +578,7 @@ if (parameters.refinement_strategy != "Temperature") { bool lookup_rho_c_p_T = (parameters.refinement_strategy == "Density c_p temperature"); - TrilinosWrappers::MPI::BlockVector vec_distributed (system_rhs); + LinearAlgebra::BlockVector vec_distributed (system_rhs); const Quadrature quadrature(finite_element.get_unit_support_points()); std::vector local_dof_indices (finite_element.dofs_per_cell); @@ -625,7 +625,7 @@ } } - TrilinosWrappers::MPI::BlockVector vec (solution); + LinearAlgebra::BlockVector vec (solution); vec = vec_distributed; DerivativeApproximation::approximate_gradient (mapping, @@ -784,11 +784,11 @@ cell != triangulation.end(); ++cell) cell->clear_refine_flag (); - std::vector x_system (2); + std::vector x_system (2); x_system[0] = &solution; x_system[1] = &old_solution; - parallel::distributed::SolutionTransfer + parallel::distributed::SolutionTransfer system_trans(dof_handler); triangulation.prepare_coarsening_and_refinement(); @@ -803,11 +803,11 @@ computing_timer.enter_section ("Refine mesh structure, part 2"); { - TrilinosWrappers::MPI::BlockVector + LinearAlgebra::BlockVector distributed_system (system_rhs); - TrilinosWrappers::MPI::BlockVector + LinearAlgebra::BlockVector old_distributed_system (system_rhs); - std::vector system_tmp (2); + std::vector system_tmp (2); system_tmp[0] = &(distributed_system); system_tmp[1] = &(old_distributed_system); Index: source/simulator/solver.cc =================================================================== --- source/simulator/solver.cc (revision 796) +++ source/simulator/solver.cc (working copy) @@ -28,7 +28,7 @@ /** * Implement multiplication with Stokes part of system matrix */ - class StokesBlock : public PointerMatrixBase + class StokesBlock : public PointerMatrixBase { public: /** @@ -36,23 +36,23 @@ * * @param S The entire system matrix */ - StokesBlock (const TrilinosWrappers::BlockSparseMatrix &S) + StokesBlock (const LinearAlgebra::BlockSparseMatrix &S) : system_matrix(S) {}; /** * Matrix vector product with Stokes block. */ - void vmult (TrilinosWrappers::MPI::BlockVector &dst, - const TrilinosWrappers::MPI::BlockVector &src) const; + void vmult (LinearAlgebra::BlockVector &dst, + const LinearAlgebra::BlockVector &src) const; - void Tvmult (TrilinosWrappers::MPI::BlockVector &dst, - const TrilinosWrappers::MPI::BlockVector &src) const; + void Tvmult (LinearAlgebra::BlockVector &dst, + const LinearAlgebra::BlockVector &src) const; - void vmult_add (TrilinosWrappers::MPI::BlockVector &dst, - const TrilinosWrappers::MPI::BlockVector &src) const; + void vmult_add (LinearAlgebra::BlockVector &dst, + const LinearAlgebra::BlockVector &src) const; - void Tvmult_add (TrilinosWrappers::MPI::BlockVector &dst, - const TrilinosWrappers::MPI::BlockVector &src) const; + void Tvmult_add (LinearAlgebra::BlockVector &dst, + const LinearAlgebra::BlockVector &src) const; void clear() {}; @@ -66,13 +66,13 @@ /** * References to the system matrix object. */ - const TrilinosWrappers::BlockSparseMatrix &system_matrix; + const LinearAlgebra::BlockSparseMatrix &system_matrix; }; - void StokesBlock::vmult (TrilinosWrappers::MPI::BlockVector &dst, - const TrilinosWrappers::MPI::BlockVector &src) const + void StokesBlock::vmult (LinearAlgebra::BlockVector &dst, + const LinearAlgebra::BlockVector &src) const { system_matrix.block(0,0).vmult(dst.block(0), src.block(0)); system_matrix.block(0,1).vmult_add(dst.block(0), src.block(1)); @@ -81,8 +81,8 @@ system_matrix.block(1,1).vmult_add(dst.block(1), src.block(1)); } - void StokesBlock::Tvmult (TrilinosWrappers::MPI::BlockVector &dst, - const TrilinosWrappers::MPI::BlockVector &src) const + void StokesBlock::Tvmult (LinearAlgebra::BlockVector &dst, + const LinearAlgebra::BlockVector &src) const { system_matrix.block(0,0).Tvmult(dst.block(0), src.block(0)); system_matrix.block(1,0).Tvmult_add(dst.block(0), src.block(1)); @@ -91,8 +91,8 @@ system_matrix.block(1,1).Tvmult_add(dst.block(1), src.block(1)); } - void StokesBlock::vmult_add (TrilinosWrappers::MPI::BlockVector &dst, - const TrilinosWrappers::MPI::BlockVector &src) const + void StokesBlock::vmult_add (LinearAlgebra::BlockVector &dst, + const LinearAlgebra::BlockVector &src) const { system_matrix.block(0,0).vmult_add(dst.block(0), src.block(0)); system_matrix.block(0,1).vmult_add(dst.block(0), src.block(1)); @@ -101,8 +101,8 @@ system_matrix.block(1,1).vmult_add(dst.block(1), src.block(1)); } - void StokesBlock::Tvmult_add (TrilinosWrappers::MPI::BlockVector &dst, - const TrilinosWrappers::MPI::BlockVector &src) const + void StokesBlock::Tvmult_add (LinearAlgebra::BlockVector &dst, + const LinearAlgebra::BlockVector &src) const { system_matrix.block(0,0).Tvmult_add(dst.block(0), src.block(0)); system_matrix.block(1,0).Tvmult_add(dst.block(0), src.block(1)); @@ -133,8 +133,8 @@ * @param do_solve_A A flag indicating whether we should actually solve with * the matrix $A$, or only apply one preconditioner step with it. **/ - BlockSchurPreconditioner (const TrilinosWrappers::BlockSparseMatrix &S, - const TrilinosWrappers::BlockSparseMatrix &Spre, + BlockSchurPreconditioner (const LinearAlgebra::BlockSparseMatrix &S, + const LinearAlgebra::BlockSparseMatrix &Spre, const PreconditionerMp &Mppreconditioner, const PreconditionerA &Apreconditioner, const bool do_solve_A); @@ -142,15 +142,15 @@ /** * Matrix vector product with this preconditioner object. */ - void vmult (TrilinosWrappers::MPI::BlockVector &dst, - const TrilinosWrappers::MPI::BlockVector &src) const; + void vmult (LinearAlgebra::BlockVector &dst, + const LinearAlgebra::BlockVector &src) const; private: /** * References to the various matrix object this preconditioner works on. */ - const TrilinosWrappers::BlockSparseMatrix &stokes_matrix; - const TrilinosWrappers::BlockSparseMatrix &stokes_preconditioner_matrix; + const LinearAlgebra::BlockSparseMatrix &stokes_matrix; + const LinearAlgebra::BlockSparseMatrix &stokes_preconditioner_matrix; const PreconditionerMp &mp_preconditioner; const PreconditionerA &a_preconditioner; @@ -164,8 +164,8 @@ template BlockSchurPreconditioner:: - BlockSchurPreconditioner (const TrilinosWrappers::BlockSparseMatrix &S, - const TrilinosWrappers::BlockSparseMatrix &Spre, + BlockSchurPreconditioner (const LinearAlgebra::BlockSparseMatrix &S, + const LinearAlgebra::BlockSparseMatrix &Spre, const PreconditionerMp &Mppreconditioner, const PreconditionerA &Apreconditioner, const bool do_solve_A) @@ -181,10 +181,10 @@ template void BlockSchurPreconditioner:: - vmult (TrilinosWrappers::MPI::BlockVector &dst, - const TrilinosWrappers::MPI::BlockVector &src) const + vmult (LinearAlgebra::BlockVector &dst, + const LinearAlgebra::BlockVector &src) const { - TrilinosWrappers::MPI::Vector utmp(src.block(0)); + LinearAlgebra::Vector utmp(src.block(0)); { SolverControl solver_control(5000, 1e-6 * src.block(1).l2_norm()); @@ -235,10 +235,10 @@ SolverControl solver_control (system_matrix.block(2,2).m(), 1e-12*system_rhs.block(2).l2_norm()); - SolverGMRES solver (solver_control, - SolverGMRES::AdditionalData(30,true)); + SolverGMRES solver (solver_control, + SolverGMRES::AdditionalData(30,true)); - TrilinosWrappers::MPI::BlockVector + LinearAlgebra::BlockVector distributed_solution (system_rhs); distributed_solution = solution; @@ -269,7 +269,7 @@ pcout << " Solving Stokes system... " << std::flush; // extract Stokes parts of solution vector, without any ghost elements - TrilinosWrappers::MPI::BlockVector distributed_stokes_solution; + LinearAlgebra::BlockVector distributed_stokes_solution; distributed_stokes_solution.reinit(system_rhs); distributed_stokes_solution.block(0) = solution.block(0); distributed_stokes_solution.block(1) = solution.block(1); @@ -293,12 +293,12 @@ make_pressure_rhs_compatible(system_rhs); // extract Stokes parts of rhs vector - TrilinosWrappers::MPI::BlockVector distributed_stokes_rhs; + LinearAlgebra::BlockVector distributed_stokes_rhs; distributed_stokes_rhs.reinit(system_rhs); distributed_stokes_rhs.block(0) = system_rhs.block(0); distributed_stokes_rhs.block(1) = system_rhs.block(1); - PrimitiveVectorMemory< TrilinosWrappers::MPI::BlockVector > mem; + PrimitiveVectorMemory< LinearAlgebra::BlockVector > mem; const internal::StokesBlock stokes_block(system_matrix); @@ -311,15 +311,15 @@ try { - const internal::BlockSchurPreconditioner + const internal::BlockSchurPreconditioner preconditioner (system_matrix, system_preconditioner_matrix, *Mp_preconditioner, *Amg_preconditioner, false); - SolverFGMRES + SolverFGMRES solver(solver_control_cheap, mem, - SolverFGMRES:: + SolverFGMRES:: AdditionalData(30, true)); solver.solve(stokes_block, distributed_stokes_solution, distributed_stokes_rhs, preconditioner); @@ -329,15 +329,15 @@ // the simple solver failed catch (SolverControl::NoConvergence) { - const internal::BlockSchurPreconditioner + const internal::BlockSchurPreconditioner preconditioner (system_matrix, system_preconditioner_matrix, *Mp_preconditioner, *Amg_preconditioner, true); - SolverFGMRES + SolverFGMRES solver(solver_control_expensive, mem, - SolverFGMRES:: + SolverFGMRES:: AdditionalData(50, true)); solver.solve(stokes_block, distributed_stokes_solution, distributed_stokes_rhs, preconditioner); Index: source/postprocess/interface.cc =================================================================== --- source/postprocess/interface.cc (revision 796) +++ source/postprocess/interface.cc (working copy) @@ -149,7 +149,7 @@ template - const TrilinosWrappers::MPI::BlockVector & + const LinearAlgebra::BlockVector & SimulatorAccess::get_solution () const { return simulator->solution; @@ -158,7 +158,7 @@ template - const TrilinosWrappers::MPI::BlockVector & + const LinearAlgebra::BlockVector & SimulatorAccess::get_old_solution () const { return simulator->old_solution;