# Can it possible to find L^2-error and order of convergence in Heat-3d PETSc code (parrallel computing)

**URL:** <https://community.freefem.org/t/can-it-possible-to-find-l-2-error-and-order-of-convergence-in-heat-3d-petsc-code-parrallel-computing/3766>\
**Category:** General Discussion\
**Created:** [February 23, 2025, 4:11am UTC](https://community.freefem.org/t/can-it-possible-to-find-l-2-error-and-order-of-convergence-in-heat-3d-petsc-code-parrallel-computing/3766 "2025-02-23T04:11:04Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)\
**Post date:** [February 26, 2025, 11:38am UTC](https://community.freefem.org/t/can-it-possible-to-find-l-2-error-and-order-of-convergence-in-heat-3d-petsc-code-parrallel-computing/3766/8 "2025-02-26T11:38:08Z")

</div>

Here [PETSc example (heat-TS-2d-PETSc.edp) incorrectly imlpemented? - #11 by fb77](https://community.freefem.org/t/petsc-example-heat-ts-2d-petsc-edp-incorrectly-imlpemented/3704/11)  
you can find the computation of L2 error (2d) as

```auto
//build partition of unity
fespace Vhpart(Th, P0); // P0 elements for partition function
Vhpart part; // Partition function
PartitionCreate(Th, part[], P0); // Create partition using the mesh Th, part[] takes values 0 or 1

real localerr=int2d(Th)(part*(w-uexT)^2);
real globalerr;
mpiAllReduce(localerr, globalerr, mpiCommWorld, mpiSUM);
globalerr=sqrt(globalerr);
if (mpirank==0) cout << "t=" << t << " global L2 error " << globalerr << endl;

```

The order of convergence can be computed as in sequential codes.

---

_[View the full topic](https://community.freefem.org/t/can-it-possible-to-find-l-2-error-and-order-of-convergence-in-heat-3d-petsc-code-parrallel-computing/3766)._
