[petsc-users] Internal product through a matrix norm

Jeremy Theler jeremy at seamplex.com
Wed Jan 22 12:27:43 CST 2020


Sorry for the basic question, but here it goes.
Say I have a vector u and a matrix K and I want to compute the scalar

    e = u^T K u

(for example the strain energy if u are displacements a K is the
stiffness matrix).

Is there anything better (both in elegance and efficiency) than doing
this?

    PetscScalar e;
    Vec Kx;
  
    VecDuplicate(x, &Kx);
    MatMult(K, x, Kx);
    VecDot(x, Kx, &e);


--
jeremy theler
www.seamplex.com




More information about the petsc-users mailing list