From 6dc5d92a01bed1ade99edf29da464aa648096c62 Mon Sep 17 00:00:00 2001 From: kronbichler Date: Fri, 12 Sep 2008 11:38:13 +0000 Subject: [PATCH] Added some more reasonable calls to LocalVector. git-svn-id: https://svn.dealii.org/trunk@16816 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/trilinos_vector.h | 28 +++++++++------ deal.II/lac/source/trilinos_vector.cc | 44 +++++++++++++++++++---- 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/deal.II/lac/include/lac/trilinos_vector.h b/deal.II/lac/include/lac/trilinos_vector.h index 41ad01a263..a3f9c2c1de 100755 --- a/deal.II/lac/include/lac/trilinos_vector.h +++ b/deal.II/lac/include/lac/trilinos_vector.h @@ -446,7 +446,7 @@ namespace TrilinosWrappers * be disallowed in the future. */ Vector & - operator= (const TrilinosScalar s); + operator = (const TrilinosScalar s); /** * Copy the given vector. Resize @@ -454,7 +454,7 @@ namespace TrilinosWrappers * necessary. */ Vector & - operator= (const Vector &v); + operator = (const Vector &v); /** * Another copy function. This @@ -480,7 +480,7 @@ namespace TrilinosWrappers * deal.II vector. */ Vector & - operator= (const ::dealii::Vector &v); + operator = (const ::dealii::Vector &v); /** * Test for equality. This @@ -555,7 +555,7 @@ namespace TrilinosWrappers * element, both read and write. */ reference - operator () (const unsigned int index); + operator () (const unsigned int index); /** * Provide read-only access to an @@ -564,7 +564,7 @@ namespace TrilinosWrappers * command. */ TrilinosScalar - operator () (const unsigned int index) const; + operator () (const unsigned int index) const; /** * Return the value of the vector @@ -1019,11 +1019,11 @@ namespace TrilinosWrappers LocalizedVector (); /** - * This constructor takes an - * Epetra_LocalMap that already knows - * the number of elements in the vector. + * This constructor takes as + * input the number of elements + * in the vector. */ - LocalizedVector (const Epetra_LocalMap &InputMap); + LocalizedVector (const unsigned int n); /** * This constructor takes a @@ -1039,7 +1039,15 @@ namespace TrilinosWrappers * LocalizedVector based on a * LocalizedVector input. */ - LocalizedVector (const LocalizedVector &V); + LocalizedVector (const LocalizedVector &V, + const bool fast); + + /** + * Reinit function that resizes + * the vector to the size + * specified by n. + */ + void reinit (unsigned int n); /** * Reinit function. Takes the diff --git a/deal.II/lac/source/trilinos_vector.cc b/deal.II/lac/source/trilinos_vector.cc index 3a8243dae9..d59d0235c3 100755 --- a/deal.II/lac/source/trilinos_vector.cc +++ b/deal.II/lac/source/trilinos_vector.cc @@ -897,12 +897,16 @@ namespace TrilinosWrappers - LocalizedVector::LocalizedVector (const Epetra_LocalMap &InputMap) + LocalizedVector::LocalizedVector (const unsigned int n) : - map (InputMap), - vector (std::auto_ptr - (new Epetra_MultiVector(map,1))) - {} +#ifdef DEAL_II_COMPILER_SUPPORTS_MPI + map ((int)n, 0, Epetra_MpiComm(MPI_COMM_WORLD)) +#else + map ((int)n, 0, Epetra_SerialComm()) +#endif + { + reinit (n); + } @@ -919,11 +923,39 @@ namespace TrilinosWrappers + LocalizedVector::LocalizedVector (const LocalizedVector &v, + const bool fast) + : + map (v.map), + vector (std::auto_ptr + (new Epetra_MultiVector(map,1,!fast))) + {} + + + + void + LocalizedVector::reinit (unsigned int n) + { + + if (map.NumGlobalElements() != (int)n) + { +#ifdef DEAL_II_COMPILER_SUPPORTS_MPI + map = Epetra_LocalMap ((int)n, 0, Epetra_MpiComm(MPI_COMM_WORLD)); +#else + map = Epetra_LocalMap ((int)n, 0, Epetra_SerialComm()); +#endif + } + + vector = std::auto_ptr + (new Epetra_MultiVector (map,1,true)); + } + void LocalizedVector::reinit (const Vector &v) { map = Epetra_LocalMap (v.size(),0,v.vector->Comm()); - vector = std::auto_ptr (new Epetra_MultiVector (map,1,false)); + vector = std::auto_ptr + (new Epetra_MultiVector (map,1,false)); *vector = *v.vector; } -- 2.39.5