# Error face midpoint problem

**URL:** <https://community.geodynamics.org/t/error-face-midpoint-problem/300>\
**Category:** SPECFEM\
**Created:** [December 20, 2018, 5:10pm UTC](https://community.geodynamics.org/t/error-face-midpoint-problem/300 "2018-12-20T17:10:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ljhwang](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/ljhwang/32/8_2.png) [@ljhwang](https://community.geodynamics.org/u/ljhwang)\
**Post date:** [December 20, 2018, 5:10pm UTC](https://community.geodynamics.org/t/error-face-midpoint-problem/300/1 "2018-12-20T17:10:38Z")

</div>

Dear all,

I’m trying to run a model with topology and CPML in SPECFEM3D\_Cartesian.But some problems came to me when I was run database generation. The error is as follow:

error element face midpoint distance : 6.640625E-02 594.957275

error corner: 1 xyz 523625.188 3602220 1297.69434

error corner: 2 xyz 523644.656 3602220.25 1283.00208

error corner: 3 xyz 523637 3602199.50 1275.03577

error corner: 4 xyz 523617 3602199.25 1288.56860

xcoord : 523644.656 523625.188 523617.562 523637.438

ycoord : 3602220.25 3602220 3602199.25 3602199.50

zcoord : 1283.00208 1297.69434 1288.56860 1275.03577

STOP error element face midpoint.

This problem has been bothering me for a long time. Maybe the edge curve is too fluctuating? Could you please help me to figure out how to solve this problem?

I would really appreciate your help,

Thanks,

Zixuan Wan | Chengdu university of technology

---

<div class="post-metadata">

**Author:** ![pokayoke](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@pokayoke](https://community.geodynamics.org/u/pokayoke)\
**Post date:** [February 26, 2019, 8:36am UTC](https://community.geodynamics.org/t/error-face-midpoint-problem/300/2 "2019-02-26T08:36:01Z")

</div>

I also have the same problem  
when I mesh a very small scale mesh model,  
for example 4x4km 192x192 maybe ok  
but 256x256 I will receive the error like this  
Does anyone know what’s this error mean?

I will be grateful for any help you can provide.

---

<div class="post-metadata">

**Author:** ![istoneuw](https://avatars.discourse-cdn.com/v4/letter/i/8e7dd6/32.png) [@istoneuw](https://community.geodynamics.org/u/istoneuw)\
**Post date:** [March 19, 2019, 10:37pm UTC](https://community.geodynamics.org/t/error-face-midpoint-problem/300/3 "2019-03-19T22:37:07Z")

</div>

Hello,

I am not an expert in the code, but have run into similar issues in the past (i.e., similar error invoking the element face midpoint distance). How I ultimately was able to get around the problem was by changing the TOL\_DIST variable in specfem3d/src/shared/get\_element\_face.f90. This value is typically set to 1.e-4, which I found was too small for the higher resolution topography meshes I was building. Changing this value to 1.e-3 fixed the error and (seemingly) did not cause any instabilities in the code or my outputs.

So I would suggest trying to increase your TOL\_DIST value, and seeing if that avoids the error.

Ian

---

<div class="post-metadata">

**Author:** ![pokayoke](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@pokayoke](https://community.geodynamics.org/u/pokayoke)\
**Post date:** [September 24, 2019, 2:35am UTC](https://community.geodynamics.org/t/error-face-midpoint-problem/300/4 "2019-09-24T02:35:46Z")

</div>

I really appreciate your answer.  
This solution works for me.

---

<div class="post-metadata">

**Author:** ![kaoutar](https://avatars.discourse-cdn.com/v4/letter/k/7c8e57/32.png) [@kaoutar](https://community.geodynamics.org/u/kaoutar)\
**Post date:** [June 10, 2020, 10:25am UTC](https://community.geodynamics.org/t/error-face-midpoint-problem/300/5 "2020-06-10T10:25:44Z")

</div>

Hello,  
I just started using specfem3d, and I want to simulate wave propagation on a homogenous medium with 5 sides PML and a free surface at the top of the model.  
But I am facing a problem with it : when I use the codes “xadd\_CPML\_layers\_to\_an\_existing\_mesh” and “xconvert\_external\_layers\_of\_a\_given\_mesh\_to\_CPML\_layers” it generates a “free\_or\_absorbing\_surface\_file\_zmax” which contains only “0” value.  
What I did, is replace it with the “free\_or\_absorbing\_surface\_file\_zmax” that I had before using the CPML codes.  
But when I ran the xspecfem3d code, I have the error :  
error element face midpoint distance: 3.4609373E+10 - edge length:  
5.4250000E+10 tolerance: 5.4250004E+07  
I tried to change the TOL\_DIST variable like you said, but it didn’t work for me.  
Do you have an idea on how I can fix this problem ?

Thank you 🙂  
Kaoutar

---

<div class="post-metadata">

**Author:** ![istoneuw](https://avatars.discourse-cdn.com/v4/letter/i/8e7dd6/32.png) [@istoneuw](https://community.geodynamics.org/u/istoneuw)\
**Post date:** [June 10, 2020, 9:05pm UTC](https://community.geodynamics.org/t/error-face-midpoint-problem/300/6 "2020-06-10T21:05:16Z")

</div>

Hello Kaoutar,

Unfortunately, I have never been able to successfully run Specfem using PML boundary conditions, so I cannot directly address your issue. One important thing, though: I do not think the free\_or\_absorbing\_surface\_file\_zmax would be the same between the CPML and original version of your mesh. The node and element ID’s do not stay the same between the two meshes, so the values listed in the free surface file for one will be different from the values listed in the other. I think your best bet would be to try and figure out why “xadd\_CPML\_layers\_to\_an\_existing\_mesh” and “xconvert\_external\_layers\_of\_a\_given\_mesh\_to\_CPML\_layers” are not producing a proper free surface file. Or, if your mesh is not too complicated and does not have topography, you may be able to write a script yourself to find the ID’s of nodes and elements at the top surface of the PML mesh and writes a free surface file.

Sorry I can’t be of more help!

Ian

---

<div class="post-metadata">

**Author:** ![kaoutar](https://avatars.discourse-cdn.com/v4/letter/k/7c8e57/32.png) [@kaoutar](https://community.geodynamics.org/u/kaoutar)\
**Post date:** [June 29, 2020, 9:17am UTC](https://community.geodynamics.org/t/error-face-midpoint-problem/300/7 "2020-06-29T09:17:49Z")

</div>

Dear Ian,

Finally the cpml worked for me.  
It actually works when I enter the pml thickness manually, but not when I use the code “add\_\_CPML\_layers\_to\_an\_existing\_mesh”.  
In another subject, do you know how to implement a pressure source in an acoustic or elastic domain using SPECFEM3D ?  
I have read the manual, but I only find FORCESOLUTION or CMTSOLUTION sources.

Thank you in advance , and have a nice day

Kaoutar
