# mesh of a right paving stone and a cube

**URL:** https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394
**Category:** General Discussion
**Created:** [April 13, 2023, 12:04pm UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394 "2023-04-13T12:04:44Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![aweni](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@aweni](https://community.freefem.org/u/aweni)
#### Post date: [April 13, 2023, 12:04pm UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394/1 "2023-04-13T12:04:44Z")

</div>

Hello to all  
I am a beginner in freefem .  
I am working in 3D.  
I would like to understand how to build and make a mesh of a cube or a right block.  
I have taken the code cube.idp but I did not understand much. especially the idea of each line.

I would like to have your help.  
I would be happy if someone could help me to understand the cube.idp code.

Thank you in advance.

---

<div class="post-metadata">

### Author: ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)
#### Post date: [April 14, 2023, 8:35am UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394/2 "2023-04-14T08:35:47Z")

</div>

The simple way to make a mesh of cube ]0,2[^3 is:

```auto
load "msh3"
mesh3 Th=cune(10,10,10,[x*2,y*2,z*2]);
plot(Th,wait=1); 

```

remark the label of the 6 face are

1,2,3,4 for the vertical face with equation y=0, x=2, y =2, x = 0  
5 for z= 0  
6 for z= 2;

---

<div class="post-metadata">

### Author: ![aweni](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@aweni](https://community.freefem.org/u/aweni)
#### Post date: [April 14, 2023, 10:20am UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394/3 "2023-04-14T10:20:10Z")

</div>

Thank you very much professor.I have understood. I have understood well.  
Out of curiosity is it possible to construct the cube (]-1,1[)^3 with freefem++. If so what will change.  
I have noticed that freefem++ has several solvers for solving PDEs, for example UMFPACK, CG, LU. How to identify what we need. I have tried all of them and either it reports an error or the results are different. I would like to have a clear idea about these solvers.

---

<div class="post-metadata">

### Author: ![aweni](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@aweni](https://community.freefem.org/u/aweni)
#### Post date: [April 14, 2023, 11:28am UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394/4 "2023-04-14T11:28:03Z")

</div>

Bonjour Professeur.  
Lorsque j’ai compilé le code ça signale des erreurs.

load “msh3”  
mesh3 Th=cune(10,10,10,[x_2,y_2,z\*2]); plot(Th,wait=1);

– FreeFem++ v 3.260003 (date jeu. 16 janv. 2014 15:52:04)  
Load: lg\_fem lg\_mesh lg\_mesh3 eigenvalue  
1 : load “msh3”(load: loadLibary C:\Program Files (x86)\FreeFem+±cs-14.3\Contents\Windows\msh3 = 0) load: msh3

2 : mesh3 Th= cube The Identifier cube does not exist

Error line number 2, in file C:\Users\ADMIN\AppData\Local\Temp.ffcs16852.edp, before token cube

current line = 2  
Compile error :  
line number :2, cube  
error Compile error :  
line number :2, cube  
code = 1 mpirank: 0  
FreeFem++ returned error 1

---

<div class="post-metadata">

### Author: ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)
#### Post date: [April 17, 2023, 12:47pm UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394/5 "2023-04-17T12:47:06Z")

</div>

you freefem version is to oold

FreeFem++ v 3.260003 (date jeu. 16 janv. 2014 15:52:04)

---

<div class="post-metadata">

### Author: ![aweni](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@aweni](https://community.freefem.org/u/aweni)
#### Post date: [April 17, 2023, 3:57pm UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394/6 "2023-04-17T15:57:17Z")

</div>

okay i see Professor.  
Please give me the link to download the new version.

---

<div class="post-metadata">

### Author: ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)
#### Post date: [April 17, 2023, 4:39pm UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394/7 "2023-04-17T16:39:33Z")

</div>

> **[Releases · FreeFem/FreeFem-sources](https://github.com/FreeFem/FreeFem-sources/releases)**
>
> FreeFEM source code. Contribute to FreeFem/FreeFem-sources development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![aweni](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@aweni](https://community.freefem.org/u/aweni)
#### Post date: [May 1, 2023, 1:35pm UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394/8 "2023-05-01T13:35:21Z")

</div>

Hello Professor  
Hello to all  
I would like to know how to implement this part in freefem++, especially the non linear part:

\partial\_t v -\Delta v + \| v \| \_{L^2(\Omega)} v =0 , v=0 on $$partial \Omega, v(0)=v\_0, \Omega a bounded open of \mathbb{R}^3

Variational formulation:  
\int\_\Omega \partial\_t v \cdot u + \int\_\Omega \nabla v : \nabla u + \| v \| \_{L^2(\Omega)} \int\_\Omega v \cdot u =0, \forall u \in H^1\_0 (\Omega) .

v depends on the variable t and x.  
Please, I need your help to implement this part | v \| \_{L^2(\Omega)} \int\_\Omega v \cdot u.  
Thank you in advance.

---

<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: [May 1, 2023, 2:12pm UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394/9 "2023-05-01T14:12:45Z")

</div>

I’m pretty new to FF but here is how I might look at it  
both to get answers and questions 🙂  
if you express it as a varf you can extract the matrix and rhs  
and use a nonlinear solver. You may hvae some freedom on how  
you linearize the nonlinear part  
Grep the examples or tutorials for “SNESSolve.” I would suggest  
however plotting the guesses as they come up as if you give  
it the wrong jacobian it can find some bizarre solutions.

If I’m reading this correctly, you have a parameter which is the  
global integral of the function. Someone may know a better  
way to express this - you may be able to add equations to  
the linear matrix for example but that would likely involve  
a lot of terms and it would just be easier for you to calculate  
that in a nonlinear loop using the FF int2d or int3d functions.

fwiw.

---

<div class="post-metadata">

### Author: ![aweni](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@aweni](https://community.freefem.org/u/aweni)
#### Post date: [May 1, 2023, 3:59pm UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394/10 "2023-05-01T15:59:17Z")

</div>

yes the parameter is the global integral of the function.

---

<div class="post-metadata">

### Author: ![aweni](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@aweni](https://community.freefem.org/u/aweni)
#### Post date: [May 1, 2023, 4:21pm UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394/11 "2023-05-01T16:21:40Z")

</div>

I am also new to this and if you have a tutorial on this kind of non-linearity that could help me it would be great.

---

<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: [May 1, 2023, 9:14pm UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394/12 "2023-05-01T21:14:26Z")

</div>

I’m working on a set of macro’s to reduce it to just two varf’s  
but the one example I found with that search is all I’m working  
with. The hard part is probably making sure the jacobian is right  
and per the example using the default tgv appears to confusee  
the solver ( how any of the other ones deal with it is beyond me lol ).

---

<div class="post-metadata">

### Author: ![aweni](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@aweni](https://community.freefem.org/u/aweni)
#### Post date: [May 1, 2023, 9:29pm UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394/13 "2023-05-01T21:29:35Z")

</div>

ok if I want to do a semi-linearisation or linearisation of the non-linear term how do I do it then

---

<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: [May 1, 2023, 9:53pm UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394/14 "2023-05-01T21:53:55Z")

</div>

If you just take the initial and boundary conditions you already know  
enough to calculate the time derivative so I guess you just just  
time step it in the forward direction - there is nothing to really invert  
or solve. Take your given initial condition and some mesh you can write  
things like dxx() + dyy() for example and maybe something  
like real c= sqrt(int2d(u_u)) ; deltau= dt_(dxx(u)+dyy(u)+c\*u))

(I’m using “u” for your “v” just because that seems to be more common  
for illustration )

---

<div class="post-metadata">

### Author: ![aweni](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@aweni](https://community.freefem.org/u/aweni)
#### Post date: [May 1, 2023, 10:41pm UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394/15 "2023-05-01T22:41:13Z")

</div>

I have already tried this method but the result does not reflect what I obtained in theory.

---

<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: [May 1, 2023, 11:09pm UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394/16 "2023-05-01T23:09:21Z")

</div>

There are several examples of time stepping using FF but other  
than searching for “dt” it would take me a while to see which  
ones I used 🙂 The code I think posted before, I was doing drif-diffusion  
of multiple species in a liquid, more or less illustrates  
the issue of using the solver to find the time derivative  
and then updating solution that is a parameter for the next solve.  
You can just write out something like u=u0+dt\*( expression for du/dt)  
and figure out where to use the unknown to be solved and the known  
prior solution.

If I got the signs right, the steady state solutions ( d/dt=0),  
are exponential rather than oscillatory with a magnitude  
dependent length scale. In the spatially uniform case, which  
I guess you don’t have if you insist on u==0 on the boundary,  
you also get a simple decaying solution.

---

<div class="post-metadata">

### Author: ![aweni](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@aweni](https://community.freefem.org/u/aweni)
#### Post date: [May 2, 2023, 8:40am UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394/17 "2023-05-02T08:40:24Z")

</div>

THANK YOU VERY MUCH FOR YOUR ANSWERS.

I understand, I’ll try again  
Another question please how can i implement the boundary conditions below:  
 curl v \times n=- \partial\_t v on \Gamma\_1 and c \nabla v n- p \partial\_t v=0 on \Gamma\_2, n is the unit normal vector and curl the rotational operator, c ,p are a scalar

---

<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: [May 2, 2023, 9:08am UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394/18 "2023-05-02T09:08:56Z")

</div>

For anything involving curl, look at the electromagnetics or helmholtz  
examples. Or you can probably just search for curl as they often have  
macro for that. Look in the manual for Robin conditions  
I’m still struggling with some basics there and in particular trying  
to set u and u’ on the same boundary in a one D case ( kind of like  
you might do a shooting method to see what I can get at the other  
end ).

---

<div class="post-metadata">

### Author: ![aweni](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@aweni](https://community.freefem.org/u/aweni)
#### Post date: [May 2, 2023, 3:47pm UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394/19 "2023-05-02T15:47:49Z")

</div>

Please, how can I correct this kind of error ?

– Solve :  
min -3.1614e+062 max 4.3762e+061  
min -5.74377e+051 max 1.06277e+052  
min -1.44389e-035 max 1.0276e-035  
min -1.36806e-031 max 1.35136e-032  
min -2.52405e+068 max 5.90191e+067  
min -2.80804e+058 max 4.36283e+057  
min -9.51105e+027 max 3.19924e+027  
– Solve :  
min -8.76884e+148 max 4.22085e+148  
min -1.79635e+055 max 4.69869e+055  
min -1.29941e+048 max 1.01918e+048  
min -1.73498e-032 max 9.59017e-033  
min -4.51908e+154 max 1.06344e+155  
min -1.19388e+061 max 7.26516e+061  
min -1.6597e+115 max 1.7004e+115  
– Solve :  
min -1.36184e+150 max 8.88903e+149  
min -1.05526e+057 max 7.06632e+056  
min -7.26832e-125 max 1.00988e-124  
min -5.49556e-204 max 2.72059e-203  
min -3.9518e+155 max 1.6452e+155  
min -2.5509e+063 max 4.70567e+062  
min -1.18452e+116 max 2.37591e+116  
-1.#IND != -1.#IND =\> Sorry error in Optimization (b) add: int2d(Th,optimize=0)(…)  
current line = 158  
Exec error : In Optimized version  
– number :1  
Exec error : In Optimized version  
– number :1  
err code 7 , mpirank 0  
FreeFem++ returned error 7

---

<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: [May 2, 2023, 4:32pm UTC](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394/20 "2023-05-02T16:32:48Z")

</div>

Why do you think that is an error? lol.  
It usually turns out to be obvious once you find it but probably the  
best thing to do is, " do the math" and actually write out  
what you think it is doing. Sign mistakes are common but IIRC  
you easily could have exponential spatial growth if the L2  
is too big ( and remember this is exponential ) - I would just  
watch the iterations with plot or medit. With your equation you  
could also do it in finite difference AFAICT and that may be easier  
to sort out.

If you "do the math " you may just find the time step is too big.  
I guess you could also try setting tgv to something to zero  
the non-diagonal elements ( search the docs for tgv ).  
If because of the equation it iterates into a place with values that high  
it could get confused.

[Next page](https://community.freefem.org/t/mesh-of-a-right-paving-stone-and-a-cube/2394.md?page=2)
