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 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.

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.

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.

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 ).

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(uu)) ; 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 )

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.

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

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 ).

– 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

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.