# Residual based adaptive FreeFem++ code of the Laplace equation (Code is running fine but good results not coming)

**URL:** <https://community.freefem.org/t/residual-based-adaptive-freefem-code-of-the-laplace-equation-code-is-running-fine-but-good-results-not-coming/3815>\
**Category:** General Discussion\
**Created:** [March 20, 2025, 5:06pm UTC](https://community.freefem.org/t/residual-based-adaptive-freefem-code-of-the-laplace-equation-code-is-running-fine-but-good-results-not-coming/3815 "2025-03-20T17:06:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Monirul25](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/monirul25/32/3287_2.png) [@Monirul25](https://community.freefem.org/u/Monirul25)\
**Post date:** [March 20, 2025, 5:06pm UTC](https://community.freefem.org/t/residual-based-adaptive-freefem-code-of-the-laplace-equation-code-is-running-fine-but-good-results-not-coming/3815/1 "2025-03-20T17:06:51Z")

</div>

Dear all experts, i am trying to compute **data oscillations of poisson equation in FreeFem++**. Here, is the formula\>

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/b/b9918fe191b55354251750b1af8d1fe747e98e83.png)  
( **My doubt is how to compute osc^2(f, \tau\_h) in FreeFem++ ?? and does last term of (3.2) contains only intalledges term??**).

I have used adaptive code of poisson equation of the FreeFem++ tutorial. Here, is the code\>  
[Poisson\_adapt\_my\_code.edp](https://community.freefem.org/uploads/short-url/uFlVxlNFExGzBuqhWPjpOErf3Fx.edp) (4.7 KB)  
( I have rewritten the code to compute the errors and indicator)  
**I have to use the following adaptive algorithm** \>

 ![Adaptive Poisson](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/4/4b422a85e84a1c1c659e826827784c731b6a54d4.png)

**Is the above code following the above adaptive algorithm??. If not, then how to modify the code to follow the above adaptive algorithm.**

I am very grateful if i get any suggestion regarding this. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Monirul25](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/monirul25/32/3287_2.png) [@Monirul25](https://community.freefem.org/u/Monirul25)\
**Post date:** [March 26, 2025, 8:11am UTC](https://community.freefem.org/t/residual-based-adaptive-freefem-code-of-the-laplace-equation-code-is-running-fine-but-good-results-not-coming/3815/2 "2025-03-26T08:11:03Z")

</div>

Dear all experts and respected professors, i have done the code still good results is not coming.  
Here, is my code\>( latest code of Adaptive Poisson DG)  
[Poisson\_adapt\_refine.edp](https://community.freefem.org/uploads/short-url/dyyAPKBQrc5HWCWQ4JCMq5xJFOY.edp) (5.3 KB)

I need results as in the following table\>

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/4/4186866fb12ca5bf35df789d5ca3ac06f164d4f8.png)

**I am trying to verify the results of the first Example of the following paper:**  
[Numerical Methods Partial - 2019 - Cui - A posteriori error estimate for discontinuous Galerkin finite element method on.pdf](https://community.freefem.org/uploads/short-url/5FNZWOdzewHmkju8mFj3U4ndUZN.pdf) (1.7 MB)

I have used the following tutorial code:

> **[Static problems](https://doc.freefem.org/models/static-problems.html#metric-adaptation-and-residual-error-indicator)**

Any help is this regard will be useful for me. I am not getting why good results not coming as in the above table.  
Thanks in advance!.
