Vector ();
/**
* One of the constructors that
- * actually build a vector. This
+ * actually builds a vector. This
* one requires prior knowledge
* of the size of the vector and
* a communicator from
* from the beginning to the end,
* so you might want to use some
* more advanced mapping and the
- * third constructor with argument
+ * constructor with argument
* Epetra_Map.
*/
Vector (unsigned int GlobalSize, Epetra_Comm &Comm);
/**
- * Third constructor. It takes an
+ * This constructor takes an
* Epetra_Map that already knows how
* to distribute the individual
- * components among the MPI processors.
+ * components among the MPI processors,
+ * including the size of the vector.
*/
Vector (const Epetra_Map &InputMap);
* Copy constructor. Sets the dimension
* to that of the given vector and uses
* the map of that vector, but
- * does not copies any element. Instead,
+ * does not copy any element. Instead,
* the memory will remain untouched
* in case <tt>fast</tt> is false and
* initialized with zero otherwise.
* a pair (i,i+n), where
* <tt>n=local_size()</tt>.
*/
- std::pair<unsigned int, unsigned int>
- local_range () const;
+ std::pair<unsigned int, unsigned int> local_range () const;
/**
* Return whether @p index is
* function takes a deal.II vector
* of values.
*/
- void set (const std::vector<unsigned int> &indices,
- const dealii::Vector<TrilinosScalar> &values);
+ void set (const std::vector<unsigned int> &indices,
+ const ::dealii::Vector<TrilinosScalar> &values);
/**
* This collective set operation is
* stored in @p values to the vector
* components specified by @p indices.
*/
- void add (const std::vector<unsigned int> &indices,
- const std::vector<TrilinosScalar> &values);
+ void add (const std::vector<unsigned int> &indices,
+ const std::vector<TrilinosScalar> &values);
+ /**
+ * This is a second collective add
+ * operation. As a difference, this
+ * function takes a deal.II vector
+ * of values.
+ */
+ void add (const std::vector<unsigned int> &indices,
+ const ::dealii::Vector<TrilinosScalar> &values);
+
+ /**
+ * Take an address where n_elements
+ * are stored contiguously and add
+ * them into the vector.
+ */
void add (const unsigned int n_elements,
const unsigned int *indices,
const TrilinosScalar *values);
/**
- * Return the scalar/inner product of two
- * vectors. The vectors must have the
+ * Return the scalar (inner) product of
+ * two vectors. The vectors must have the
* same size.
*/
TrilinosScalar operator * (const Vector &vec) const;
/**
* Simple vector addition, equal to the
- * <tt>operator =</tt>.
+ * <tt>operator +=</tt>.
*/
void add (const Vector &V);
std::auto_ptr<Epetra_FEVector> vector;
+ private:
/**
* Trilinos doesn't allow to mix additions
* to matrix entries and overwriting
{
vector.reset();
map = input_map;
-
+
vector = std::auto_ptr<Epetra_FEVector> (new Epetra_FEVector(input_map));
last_action = Insert;
}
const bool fast)
{
vector.reset();
-
+
if (!map.SameAs(v.map))
map = v.map;
-
+
vector = std::auto_ptr<Epetra_FEVector> (new Epetra_FEVector(v.map,!fast));
last_action = Insert;
}
{
Assert (numbers::is_finite(s),
- ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)"));
+ ExcMessage("The given value is not finite but either "
+ "infinite or Not A Number (NaN)"));
const int ierr = vector->PutScalar(s);
ExcDimensionMismatch(size(), v.size()));
unsigned int i;
for (i=0; i<size(); i++)
- if ((*(v.vector))[i]!=(*vector)[i]) return false;
+ if ((*(v.vector))[0][i]!=(*vector)[0][i]) return false;
+
return true;
}
}
else
value = (*vector)[0][trilinos_i];
-
+
return value;
}
+
void
Vector::set (const std::vector<unsigned int> &indices,
const std::vector<TrilinosScalar> &values)
{
Assert (indices.size() == values.size(),
- ExcMessage ("Function called with arguments of different sizes"));
-
+ ExcDimensionMismatch(indices.size(),values.size()));
+
set (indices.size(), &indices[0], &values[0]);
}
-
+
+
+ void
+ Vector::set (const std::vector<unsigned int> &indices,
+ const ::dealii::Vector<TrilinosScalar> &values)
+ {
+ Assert (indices.size() == values.size(),
+ ExcDimensionMismatch(indices.size(),values.size()));
+
+ set (indices.size(), &indices[0], values.begin());
+ }
+
+
+
void
Vector::set (const unsigned int n_elements,
const unsigned int *indices,
}
-
+
void
Vector::add (const std::vector<unsigned int> &indices,
const std::vector<TrilinosScalar> &values)
{
Assert (indices.size() == values.size(),
- ExcMessage ("Function called with arguments of different sizes"));
-
+ ExcDimensionMismatch(indices.size(),values.size()));
+
add (indices.size(), &indices[0], &values[0]);
}
-
-
+
+
+ void
+ Vector::add (const std::vector<unsigned int> &indices,
+ const ::dealii::Vector<TrilinosScalar> &values)
+ {
+ Assert (indices.size() == values.size(),
+ ExcDimensionMismatch(indices.size(),values.size()));
+
+ add (indices.size(), &indices[0], values.begin());
+ }
+
+
+
void
Vector::add (const unsigned int n_elements,
const unsigned int *indices,
TrilinosScalar
Vector::mean_value () const
{
-
TrilinosScalar mean;
- int ierr;
- ierr = vector->MeanValue (&mean);
+ const int ierr = vector->MeanValue (&mean);
AssertThrow (ierr == 0, ExcTrilinosError(ierr));
return mean;