# Changing mesh name from Th to Th3 appears to generate problems

**URL:** https://community.freefem.org/t/changing-mesh-name-from-th-to-th3-appears-to-generate-problems/2364
**Category:** General Discussion
**Created:** [March 30, 2023, 10:55am UTC](https://community.freefem.org/t/changing-mesh-name-from-th-to-th3-appears-to-generate-problems/2364 "2023-03-30T10:55:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)
#### Post date: [March 30, 2023, 10:55am UTC](https://community.freefem.org/t/changing-mesh-name-from-th-to-th3-appears-to-generate-problems/2364/1 "2023-03-30T10:55:03Z")

</div>

I’m trying to convert some code to use PETSc. I tried to copy an example but got  
various compile errors and then seg faults at run time. I isolated a problem upstream  
but have not verified to is a problem later. At issue seems tobe the name of the mesh and  
requirement for macro defs that are suspcious later on. For example, the two attached files  
differ only in Th vs Th3 for the mesh name but Th3 fails at compile without the defs for def and  
init lol. What is the deal here? Am I missing something simple? Thanks.  
[mwe\_defs3.edp](https://community.freefem.org/uploads/short-url/aNuQNZ21dd7IXhtwBGj9FjUm22x.edp) (1.6 KB)  
[mwe\_defs.edp](https://community.freefem.org/uploads/short-url/7SDBcTZg779dAyoaaGUKC3hmHhI.edp) (1.5 KB)

```auto
 diff mwe*
32c32
< mesh3 Th3 = cube(Xpts,Ypts,Tpts);
---
> mesh3 Th = cube(Xpts,Ypts,Tpts);
34c34
< Th3=change(Th3,refface=chlab);
---
> Th=change(Th,refface=chlab);
39c39
< buildDmesh(Th3)
---
> buildDmesh(Th)
41d40
< // need to uncomment naming mesh Th3 and then it bombs during run ???
46c45
< createMat(Th3, AP, Pk)
---
> createMat(Th, AP, Pk)

```

```auto

 4967 ff-mpirun -np 1 mwe_defs.edp -wg 
 4968 vi mwe_defs.edp 
 4969 cp mwe_defs.edp mwe_defs3.edp 
 4970 vi mwe_defs3.edp 
 4971 ff-mpirun -np 1 mwe_defs3.edp -wg 

```

---

<div class="post-metadata">

### Author: ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)
#### Post date: [March 30, 2023, 12:44pm UTC](https://community.freefem.org/t/changing-mesh-name-from-th-to-th3-appears-to-generate-problems/2364/2 "2023-03-30T12:44:07Z")

</div>

I went back and changed the full code and it now appears to run although the solution  
is not correct it no longer seg faults and I dont need the macro defs for def and init 🙂

I have a bunch of little issues like this that take forever to track down but now I want  
to get the results and see if the math/analysis makes any sense. I had to scale down to  
a 2+1D electrmagnetics problem with the z dimension as time. I’m using the last result  
for the initial conditions of a new solve so I have some more detais  
to check.

---

<div class="post-metadata">

### Author: ![henkel](https://avatars.discourse-cdn.com/v4/letter/h/b77776/32.png) [@henkel](https://community.freefem.org/u/henkel)
#### Post date: [March 30, 2023, 3:02pm UTC](https://community.freefem.org/t/changing-mesh-name-from-th-to-th3-appears-to-generate-problems/2364/3 "2023-03-30T15:02:20Z")

</div>

You neglected to update the name of the mesh in the macro definitions. Change `ThN2O` to `Th3N2O` and `ThPkPart` to `Th3PkPart`.

---

<div class="post-metadata">

### Author: ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)
#### Post date: [March 30, 2023, 4:23pm UTC](https://community.freefem.org/t/changing-mesh-name-from-th-to-th3-appears-to-generate-problems/2364/4 "2023-03-30T16:23:23Z")

</div>

Thanks. I’m kind of curious what kind of code it generated now 🙂 I guess it was easy to  
overlook as I would expect a compile time error. The scoped macro idea, kind of  
like c++ templates, is powerful but apparently takes dome getitng used to.
