15 using namespace navier;
28 Orthogonalize(b, b_ortho);
31 oper->
Mult(b_ortho, x);
37 void OrthoSolver::Orthogonalize(
const Vector &v,
Vector &v_ortho)
const
39 double loc_sum = v.
Sum();
40 double global_sum = 0.0;
41 int loc_size = v.
Size();
44 MPI_Allreduce(&loc_sum, &global_sum, 1, MPI_DOUBLE, MPI_SUM, mycomm);
45 MPI_Allreduce(&loc_size, &global_size, 1, MPI_INT, MPI_SUM, mycomm);
47 double ratio = global_sum /
static_cast<double>(global_size);
51 for (
int i = 0; i < v_ortho.
Size(); ++i)
53 v_ortho(i) = v(i) - ratio;
void SetSize(int s)
Resize the vector to size s.
virtual double * HostWrite()
Shortcut for mfem::Write(vec.GetMemory(), vec.Size(), false).
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.
OrthoSolver(MPI_Comm mycomm_)
virtual const double * HostRead() const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), false).
void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
double Sum() const
Return the sum of the vector entries.