15 using namespace navier;
27 Orthogonalize(b, b_ortho);
30 oper->
Mult(b_ortho, x);
36 void OrthoSolver::Orthogonalize(
const Vector &v,
Vector &v_ortho)
const
38 double loc_sum = v.
Sum();
39 double global_sum = 0.0;
40 int loc_size = v.
Size();
43 MPI_Allreduce(&loc_sum, &global_sum, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
44 MPI_Allreduce(&loc_size, &global_size, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
46 double ratio = global_sum /
static_cast<double>(global_size);
48 for (
int i = 0; i < v_ortho.
Size(); ++i)
50 v_ortho(i) = v(i) - ratio;
void SetSize(int s)
Resize the vector to size s.
int Size() const
Returns the size of the vector.
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
double Sum() const
Return the sum of the vector entries.