# Old example of Newton3D Using Boussinesq hypothesis gives seg-fault

**URL:** <https://community.freefem.org/t/old-example-of-newton3d-using-boussinesq-hypothesis-gives-seg-fault/3457>\
**Category:** General Discussion\
**Created:** [August 26, 2024, 2:33pm UTC](https://community.freefem.org/t/old-example-of-newton3d-using-boussinesq-hypothesis-gives-seg-fault/3457 "2024-08-26T14:33:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![isharma25](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/isharma25/32/2624_2.png) [@isharma25](https://community.freefem.org/u/isharma25)\
**Post date:** [August 26, 2024, 2:33pm UTC](https://community.freefem.org/t/old-example-of-newton3d-using-boussinesq-hypothesis-gives-seg-fault/3457/1 "2024-08-26T14:33:05Z")

</div>

Hello,

The example code from: [FreeFem++ users | Main \>\> Newton3D](https://www.um.es/freefem/ff++/pmwiki.php?n=Main.Newton3D) is giving a seg-fault in the while loop, specifically the int3d(Th) functions are not working properly.

I would like to solve this, any pointers would be appreciated.

Best,  
Isha

---

<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:** [August 27, 2024, 9:43am UTC](https://community.freefem.org/t/old-example-of-newton3d-using-boussinesq-hypothesis-gives-seg-fault/3457/2 "2024-08-27T09:43:22Z")

</div>

I have try the example, the converge is bad and test test explose but the code works.

cd /Users/hecht/Downloads ; FreeFem+±CoCoa /Users/hecht/Downloads/boussinesq3d.edp  
MBP-M2-FH:~ hecht$ cd /Users/hecht/Downloads ; FreeFem+±CoCoa /Users/hecht/Downloads/boussinesq3d.edp  
do script " cd ‘/Users/hecht/Downloads’; /Applications/FreeFem++.app/Contents/ff-4.14-dev/bin/FreeFem++ ‘boussinesq3d.edp’ -glut ‘/Applications/FreeFem++.app/Contents/ff-4.14-dev/bin/ffglut’ ;"  
– FreeFem++ v4.14 (Ven 7 jui 2024 11:35:37 CEST - git v4.14-60-g660dbd36)  
file : boussinesq3d.edp  
Load: lg\_fem lg\_mesh lg\_mesh3 eigenvalue  
1 : ////  
2 : //// Adapted in April 2014 from a code by F. Hecht  
3 : ////  
4 : /\*\*  
5 : Incompressible steady Navier Stokes + boussinesq coupled system  
6 : with Taylor-Hood Finite element  
7 : Non-linearity : Newton method  
8 : continuation on Rayleigh Number  
9 : Solution computed on a cube [0,1]^3  
10 :  
11 : Problem: Navier-Sokes and Temperature on vertical direccion (Boussinesq hyp.)  
12 :  
13 : Equations:  
14 :  
15 : (u.grad)u-nu_Lap(u) +Grad p = -c_T\*(0,0,1)’ in the cube  
16 : (u.grad)T-k_Lap(T) = 0 in the cube  
17 :  
18 : Boundary Conditions:  
19 :  
20 : u=0 on boundary of cube  
21 : T=0 on opposite sidewalls 2 and 4  
22 : (d/dn)T=0 on the rest of walls  
23 :  
24 : /  
25 :  
26 : ////  
27 : //// 2D mesh  
28 : ////  
29 : int nn=10;  
30 : mesh th2d=square(nn,nn);  
31 : ////  
32 : //// labels for the cube 3d mesh  
33 : ////  
34 : int[int] rup=[0,1]; ////top of the cube labelled by cero  
35 : int[int] rdown=[0,1];////bottom of the cube labelled by cero  
36 : int[int] rmid=[1,1,2,2,3,3,4,4];//// sidewalls labelled as the 2d edges they stand on  
37 : ////  
38 : //// 3D mesh  
39 : ////  
40 : load “msh3”  
41 : mesh3 Th=buildlayers(square(nn,nn),nn, zbound=[0.,1.],  
42 : labelmid=rmid, labelup = rup, labeldown = rdown);  
43 : real errm=1e-2;  
44 : ////  
45 : //// MACROS…they mean  
46 : ////  
47 : //// for a scalar u grad(u) computes the gradient  
48 : ////  
49 : macro grad(u) [dx(u),dy(u),dz(u)] ) ////  
50 : ////  
51 : //// For a vector u of componentes u#1,u#2,u#3  
52 : //// here # acts as wildcar character  
53 : //// Grad(u) compute the matrix of the gradients  
54 : ////  
55 : macro Grad(u) [grad(u#1),grad(u#2),grad(u#3)] ) ////  
56 : ////  
57 : //// For a vector u of componentes u#1,u#2,u#3  
58 : //// div(u) compute the divergence  
59 : ////  
60 : macro div(u) (dx(u#1)+dy(u#2)+dz(u#3)) ) ////  
61 : ////  
62 : //// for a vector u of componentes u#1,u#2,u#3 a scalar v  
63 : //// ugrad(u,v) compute a scalar (u.Grad)v  
64 : ////  
65 : macro ugrad(u,v) ([u#1,u#2,u#3]'grad(v) ) ) ////  
66 : ////  
67 : //// for a vector u of componentes u#1,u#2,u#3  
68 : //// for a vector v of componentes v#1,v#2,v#3  
69 : //// the temperature T  
70 : //// UgradV(u,v,T) gives a vector of componente  
71 : //// (u.grad)v#1, (u.grad)v#2, (u.grad)v#3, (u.grad)T  
72 : ////  
73 : //// This is a non linear term when u=v  
74 : ////  
75 : macro UgradV(u,v,T) [ugrad(u,v#1),ugrad(u,v#2),ugrad(u,v#3),ugrad(u,T)] ) ////  
76 : ////  
77 : //// Finite element spaces for computations  
78 : ////  
79 : //// Taylor-Hood P2-P1 pair for better precision. Migth be a bit expensive and  
80 : //// could be better to use P1b-P1  
81 : ////  
82 : fespace XXXMh(Th,[P2,P2,P2,P1,P1]);////vectorial FE space for velocity and pressure  
83 :  
84 : XXXMh [u1,u2,u3,p,T]; ////  
85 : XXXMh [uw1,uw2,uw3,pw,Tw]; ////increments during the Newton iteration  
86 : XXXMh [v1,v2,v3,q,TT]; //// test functions  
87 : XXXMh [uc1,uc2,uc3,pc,Tc]; //// Current computed values out of the Newton iterate  
88 : ////  
89 : //// Physical constants  
90 : ////  
91 : real nu= 1./100; //// starting viscosity  
92 : real nufinal=1/1000.; //// wanted final viscosity  
93 : ////  
94 : //// cnu reducing factor for viscosity  
95 : //// We reduce viscosity by dividing by cnu  
96 : ////  
97 : real cnu=2;  
98 : ////  
99 : //// Number of reductions on viscosity  
100 : ////  
101 : int countermax=10;  
102 : int counter=0;  
103 : ////  
104 : real Pr = 56.2; //// Prandtl number  
105 : real k = 1. / Pr ; //// Heat diffusion, inverse of Prandtl  
106 : ////  
107 : ////  
108 : verbosity=0;  
109 : real err=0;  
110 : //// stop test for Newton  
111 : real eps=1e-6;  
112 :  
113 : real nuc=nu;//// current viscosity  
114 : cout \<\< " ---------------------------- " \<\< endl;  
115 : cout \<\< " — START COMPUTATIONS — " \<\< endl;  
116 : cout \<\< " ---------------------------- " \<\< endl;  
117 : ////  
118 : bool adaptation=1;  
119 : int one =adaptation; //// to perform mesh adaptation  
120 : ////  
121 : //// initial data for Newton process  
122 : ////  
123 : [u1,u2,u3,p,T]=[0,0,0,0,x]; //// cero velocity and heating from above  
124 : plot(T,wait=0,cmm=“Initial temperature T=x”, coef=0.3,fill=1,value=1,nbiso=20);  
125 : ////  
126 : //// Continuation on viscosity number  
127 : //// Compute first for a given viscosity and then after convergence of  
128 : //// Newton method reduce the viscosity number until nufinal  
129 : ////  
130 : while((nuc\>nufinal) && (counter\<countermax)&&(cnu\>1.05))  
131 : { //// start loop on viscosity  
132 : counter =counter+1;  
133 : real rey=1./nuc;  
134 : real c= - rey/Pr; //// ratio Reynolds/Prandtl  
135 :  
136 : int n; //// counter for Newton iteration  
137 : for (n=0;n\<=20;n++)//// nonlinear Newton iteration  
138 : {  
139 : //// initial data very first iteration is  
140 : ////[u1,u2,u3,p,T]=[0,0,0,0,1-x];  
141 : ////  
142 : //// variables uw1,uw2,uw3,pw,Tw contain the increments computed by  
143 : //// using the Gateaux o Frechet derivative  
144 : ////  
145 : //// v represents—\> [v1,v2,v3] (test functions)  
146 : //// TT test function for temperature  
147 : ////  
148 : solve BoussinesqNL([uw1,uw2,uw3,pw,Tw],[v1,v2,v3,q,TT])  
149 : =  
150 : //// start now with the term  
151 : //// \<dF(u,T),(uw,Tw)\>  
152 : ////  
153 : int3d(Th) (  
154 : ////  
155 : ////result of the nonlinear parts on the differential mappping  
156 : ////nonlinear parts (ugrad)uw+(uwgrad)u+(u_grad)Tw+(uw\*grad)T  
157 : ////  
158 : ////  
159 : //// u represents—\> [u1,u2,u3]  
160 : //// uw represents—\> [uw1,uw2,uw3]  
161 : ////  
162 : //// Solving \<dF(u,T),(uw,Tw)\>=-F(u,T) using variational formulation  
163 : //// and then  
164 : //// u:=u+uw  
165 : //// T:=T+Tw  
166 : ////  
167 : UgradV(u,uw,Tw) [ugrad(u,uw1) ([u1,u2,u3]'\*grad(uw1) [dx(uw1),dy(uw1),dz(uw1)] ) ,ugrad(u,uw2) ([u1,u2,u3]‘_grad(uw2) [dx(uw2),dy(uw2),dz(uw2)] ) ,ugrad(u,uw3) ([u1,u2,u3]'grad(uw3) [dx(uw3),dy(uw3),dz(uw3)] ) ,ugrad(u,Tw) ([u1,u2,u3]'grad(Tw) [dx(Tw),dy(Tw),dz(Tw)] ) ]’ \* [v1,v2,v3,TT]  
168 : + UgradV(uw,u,T) [ugrad(uw,u1) ([uw1,uw2,uw3]'grad(u1) [dx(u1),dy(u1),dz(u1)] ) ,ugrad(uw,u2) ([uw1,uw2,uw3]'grad(u2) [dx(u2),dy(u2),dz(u2)] ) ,ugrad(uw,u3) ([uw1,uw2,uw3]‘grad(u3) [dx(u3),dy(u3),dz(u3)] ) ,ugrad(uw,T) ([uw1,uw2,uw3]'grad(T) [dx(T),dy(T),dz(T)] ) ]’ \* [v1,v2,v3,TT]  
169 : ////  
170 : //// nuLap(uw)v (here uw represents—\> [uw1,uw2,uw3])  
171 : ////  
172 : + ( Grad(uw) [grad(uw1) [dx(uw1),dy(uw1),dz(uw1)],grad(uw2) [dx(uw2),dy(uw2),dz(uw2)],grad(uw3) [dx(uw3),dy(uw3),dz(uw3)]]:Grad(v) [grad(v1) [dx(v1),dy(v1),dz(v1)],grad(v2) [dx(v2),dy(v2),dz(v2)],grad(v3) [dx(v3),dy(v3),dz(v3)]]) \* nuc  
173 : ////  
174 : //// effect of Boussinesq hypothesis body force is -cT(0,0,1)’  
175 : ////  
176 : + cTwv3  
177 : ////  
178 : ////-kLap(Tw)  
179 : + grad(Tw) [dx(Tw),dy(Tw),dz(Tw)]'grad(TT) [dx(TT),dy(TT),dz(TT)]k  
180 : ////  
181 : //// incompressibility for uw  
182 : ////  
183 : - div(uw) (dx(uw1)+dy(uw2)+dz(uw3)) q  
184 : ////  
185 : //// grad(pw)  
186 : ////  
187 : -div(v) (dx(v1)+dy(v2)+dz(v3)) pw  
188 : ////  
189 : //// stabilization term  
190 : ////  
191 : + 1e-8pwq  
192 : )  
193 : ////  
194 : //// Now the -F(u,T) term goes +F(u,T) on left hand side  
195 : + int3d(Th)(  
196 : ////  
197 : //// non linear term on data (u,T)  
198 : //// (ugrad)u+(ugrad)T  
199 : ////  
200 : UgradV(u,u,T) [ugrad(u,u1) ([u1,u2,u3]'grad(u1) [dx(u1),dy(u1),dz(u1)] ) ,ugrad(u,u2) ([u1,u2,u3]‘grad(u2) [dx(u2),dy(u2),dz(u2)] ) ,ugrad(u,u3) ([u1,u2,u3]'grad(u3) [dx(u3),dy(u3),dz(u3)] ) ,ugrad(u,T) ([u1,u2,u3]'grad(T) [dx(T),dy(T),dz(T)] ) ]’ \* [v1,v2,v3,TT] //// non linear term on data (u,T)  
201 : ////  
202 : ////the -nuLap(u)  
203 : ////  
204 : + ( Grad(u) [grad(u1) [dx(u1),dy(u1),dz(u1)],grad(u2) [dx(u2),dy(u2),dz(u2)],grad(u3) [dx(u3),dy(u3),dz(u3)]]:Grad(v) [grad(v1) [dx(v1),dy(v1),dz(v1)],grad(v2) [dx(v2),dy(v2),dz(v2)],grad(v3) [dx(v3),dy(v3),dz(v3)]] ) \* nuc  
205 : ////  
206 : //// the body force cT(0,0,1)’  
207 : ////  
208 : + cTv3  
209 : ////  
210 : //// the -k_Lap(T)  
211 : ////  
212 : + grad(T) [dx(T),dy(T),dz(T)]’\*grad(TT) [dx(TT),dy(TT),dz(TT)]_k  
213 : ////  
214 : //// the incompressibility condition  
215 : ////  
216 : - div(u) (dx(u1)+dy(u2)+dz(u3)) q  
217 : ////  
218 : //// the grad(p)  
219 : ////  
220 : -div(v) (dx(v1)+dy(v2)+dz(v3)) p  
221 : //// the stabilization term  
222 : + 1e-8pq  
223 : )  
224 : //// Boundary Conditions for velocity field  
225 : + on(1,2,3,4, uw1=0,uw2=0,uw3=0)//// velocity cero top, bottom and sidewalls  
226 : //// Boundary Conditions for Temperature field  
227 : + on(2,4,Tw=0);//// Temperature cero opposite sidewalls 2 and 4  
228 : //// on the rest…normal derivative of T is cero.  
229 : ////  
230 : //// update all the fields…velocities and temperature whithin Newton iteration  
231 : ////  
232 : ////  
233 : //// update values to compute again  
234 : ////  
235 : u1[] += uw1[]; ////u1[]=u1[]+uw1[] an update the rest in the same way  
236 :  
237 : //// u2[] += uw2[]; //u2[]=u2[]+uw2[]  
238 : //// u3[] += uw3[]; //u3[]=u3[]+uw3[]  
239 : //// p[] += pw[]; //p[]=p[]+pw[]  
240 : //// T[] += Tw[]; //T[]=T[]+Tw[]  
241 :  
242 :  
243 : ////  
244 : //// computation of norms for the increments, takes five components at the same time  
245 : ////  
246 : real solutionl2=u1[].l2; //// l2 norm of all components [u1,u2,u3,p,T]  
247 : real incrementl2=uw1[].l2; //// l2 norm of all components [uw1,uw2,uw3,pw,Tw]  
248 : ////  
249 : //// normalization of the norms  
250 : ////  
251 : err= incrementl2/solutionl2;  
252 :  
253 : cout \<\< " iter = "\<\< n \<\< " norm l2 of the solution is = " \<\< solutionl2  
254 : \<\< " nu = " \<\< nuc \<\< endl;  
255 : cout \<\< " iter = "\<\< n \<\< " norm l2 of the increment is = " \<\< incrementl2  
256 : \<\< " nu = " \<\< nuc \<\< endl;  
257 :  
258 : cout \<\< " iter = "\<\< n \<\< " err " \<\<err  
259 : \<\< " nu = " \<\< nuc \<\< endl;  
260 : ////  
261 : //// plot iterate  
262 : ////  
263 : plot(T,wait=0,cmm=“Temperature using Newton Method for viscosity = " + nuc +”, it = "+ n+ ", err = “+err, coef=0.3,fill=1,value=1,nbiso=20);  
264 : ////  
265 : ////–\> In case of no convergence…  
266 : //// (n\>3 AND err\>2) is blowup  
267 : //// (n\>12 AND err\>eps) is lack of convergence or very slow  
268 : ////  
269 : if( (n\>3 && err \> 2.) || (n\>12 && err \> 1) ) //// (n\>3 AND err\>2) or (n\>12 AND err\>eps)  
270 : {//// start —\> if  
271 : cout\<\<” NO convergence for nu = "+nuc+ ", it = "+ n+ ", err = "+err \<\<endl;  
272 : nuc=nuc_cnu; //// get back to previous nu  
273 : cout \<\< " LAST viscosity TO CONVERGE = " \<\< nuc\<\< endl;  
274 : ////  
275 : //// take computed values for previous nuc to start again  
276 : ////  
277 : u1=uc1;  
278 : ////  
279 : //// New reduction for cnu  
280 : ////  
281 : cnu= cnu^(0.6); //// no conv. =\> change lower (cnu^(0.6) makes cnu smaller)  
282 : nuc = nuc/cnu; //// new vicosity  
283 : cout \<\< " RESTART with NEW viscosity = " \<\< nuc \<\< endl;  
284 : cout \<\< " Using as Inital Data the solution for PREVIOUS v  
… : iscosity " \<\< endl;  
285 : break; //// Blowup ??? —\>out of for loop go to while loop  
286 : }//// end —\> if( n\>3 && err \> 2.)  
287 : ////  
288 : ////–\>In case of Convergence then…  
289 : ////  
290 : if(err \< eps)  
291 : {//// start —\> if(err \< eps)  
292 : cout \<\< " CONVERGENCE for viscosity = " \<\< nuc \<\< " on iters = “\<\< n \<\<”, err = “+err \<\< endl;  
293 : ////uc1=u1; uc2=u2; uc3=u3; pc=p; Tc=T; // save computed values of this convergent solution  
294 : uc1=u1;  
295 : plot(T,wait=0,cmm=“Solution for viscosity = " + nuc,coef=0.3,fill=1,value=1,nbiso=20);  
296 :  
297 : if( n \< 4) cnu=cnu^1.5; //// fast converge =\> change faster ( cnu^ 1.5 makes bigger cnu)  
298 : nuc = max(nufinal, nuc/cnu); //// reduce to a new vicosity  
299 : cout \<\< " Continuation to new viscosity = " \<\< nuc \<\<” (dividing factor “\<\<cnu\<\<”)”\<\< endl;  
300 : cout \<\< " Initial data IS the FINAL computation for previ  
… : ous viscosity " \<\< endl;  
301 : break; //// converge —\> out of for loop. Start again with u1,u2,p and new nuc  
302 : }//// end —\> if(err \< eps)  
303 : }////end —\> for loop  
304 : } //// end while loop on viscosity  
305 : plot(T,cmm=“Temperature Last converge of Newton Method for nu  
… : = " + nuc,coef=0.3,wait=0,fill=1,value=1,nbiso=10);  
306 : cout \<\< " LAST viscosity TO CONVERGE nu = " \<\< nuc \<\< endl;  
307 : plot(coef=0.2,cmm=” Temperature for viscosity "+nuc,T,fill=1,value=1,nbiso=20); sizestack + 1024 =8456 ( 7432 )

## – Square mesh : nb vertices =121 , nb triangles = 200 , nb boundary edges 40 rmdup= 0 – Square mesh : nb vertices =121 , nb triangles = 200 , nb boundary edges 40 rmdup= 0 – Build Nodes/DF on mesh : n.v. 1331, n. elmt. 6000, n b. elmt. 1200 nb of Nodes 9261 nb of DoF 30445 DFon=5300 – FESpace: Nb of Nodes 9261 Nb of DoF 30445

## — START COMPUTATIONS —

FALLBACK (log once): Fallback to SW vertex for line stipple  
FALLBACK (log once): Fallback to SW vertex processing, m\_disable\_code: 2000  
FALLBACK (log once): Fallback to SW vertex processing in drawCore, m\_disable\_code: 2000  
iter = 0 norm l2 of the solution is = 54.5936 nu = 0.01  
iter = 0 norm l2 of the increment is = 50.1886 nu = 0.01  
iter = 0 err 0.919313 nu = 0.01  
iter = 1 norm l2 of the solution is = 36.0245 nu = 0.01  
iter = 1 norm l2 of the increment is = 24.0584 nu = 0.01  
iter = 1 err 0.667836 nu = 0.01  
iter = 2 norm l2 of the solution is = 30.3662 nu = 0.01  
iter = 2 norm l2 of the increment is = 9.25408 nu = 0.01  
iter = 2 err 0.30475 nu = 0.01  
iter = 3 norm l2 of the solution is = 28.8534 nu = 0.01  
iter = 3 norm l2 of the increment is = 2.88402 nu = 0.01  
iter = 3 err 0.0999543 nu = 0.01  
iter = 4 norm l2 of the solution is = 28.775 nu = 0.01  
iter = 4 norm l2 of the increment is = 0.252122 nu = 0.01  
iter = 4 err 0.00876183 nu = 0.01  
iter = 5 norm l2 of the solution is = 28.7755 nu = 0.01  
iter = 5 norm l2 of the increment is = 0.00210796 nu = 0.01  
iter = 5 err 7.32553e-05 nu = 0.01  
iter = 6 norm l2 of the solution is = 28.7755 nu = 0.01  
iter = 6 norm l2 of the increment is = 8.17775e-08 nu = 0.01  
iter = 6 err 2.84191e-09 nu = 0.01  
CONVERGENCE for viscosity = 0.01 on iters = 6, err = 2.84191e-09  
Continuation to new viscosity = 0.005 (dividing factor 2)  
Initial data IS the FINAL computation for previous viscosity  
iter = 0 norm l2 of the solution is = 41.6728 nu = 0.005  
iter = 0 norm l2 of the increment is = 18.7846 nu = 0.005  
iter = 0 err 0.450764 nu = 0.005  
iter = 1 norm l2 of the solution is = 41.504 nu = 0.005  
iter = 1 norm l2 of the increment is = 4.46038 nu = 0.005  
iter = 1 err 0.107469 nu = 0.005  
iter = 2 norm l2 of the solution is = 41.7005 nu = 0.005  
iter = 2 norm l2 of the increment is = 0.755348 nu = 0.005  
iter = 2 err 0.0181136 nu = 0.005  
iter = 3 norm l2 of the solution is = 41.7012 nu = 0.005  
iter = 3 norm l2 of the increment is = 0.0127765 nu = 0.005  
iter = 3 err 0.000306383 nu = 0.005  
iter = 4 norm l2 of the solution is = 41.7012 nu = 0.005  
iter = 4 norm l2 of the increment is = 6.72466e-06 nu = 0.005  
iter = 4 err 1.61258e-07 nu = 0.005  
CONVERGENCE for viscosity = 0.005 on iters = 4, err = 1.61258e-07  
Continuation to new viscosity = 0.0025 (dividing factor 2)  
Initial data IS the FINAL computation for previous viscosity  
iter = 0 norm l2 of the solution is = 66.0549 nu = 0.0025  
iter = 0 norm l2 of the increment is = 31.8274 nu = 0.0025  
iter = 0 err 0.481832 nu = 0.0025  
iter = 1 norm l2 of the solution is = 65.3784 nu = 0.0025  
iter = 1 norm l2 of the increment is = 7.43208 nu = 0.0025  
iter = 1 err 0.113678 nu = 0.0025  
iter = 2 norm l2 of the solution is = 65.4833 nu = 0.0025  
iter = 2 norm l2 of the increment is = 1.6268 nu = 0.0025  
iter = 2 err 0.0248429 nu = 0.0025  
iter = 3 norm l2 of the solution is = 65.4821 nu = 0.0025  
iter = 3 norm l2 of the increment is = 0.147724 nu = 0.0025  
iter = 3 err 0.00225594 nu = 0.0025  
iter = 4 norm l2 of the solution is = 65.4822 nu = 0.0025  
iter = 4 norm l2 of the increment is = 0.00298921 nu = 0.0025  
iter = 4 err 4.56493e-05 nu = 0.0025  
iter = 5 norm l2 of the solution is = 65.4822 nu = 0.0025  
iter = 5 norm l2 of the increment is = 1.44427e-06 nu = 0.0025  
iter = 5 err 2.2056e-08 nu = 0.0025  
CONVERGENCE for viscosity = 0.0025 on iters = 5, err = 2.2056e-08  
Continuation to new viscosity = 0.00125 (dividing factor 2)  
Initial data IS the FINAL computation for previous viscosity  
iter = 0 norm l2 of the solution is = 113.327 nu = 0.00125  
iter = 0 norm l2 of the increment is = 61.1883 nu = 0.00125  
iter = 0 err 0.539928 nu = 0.00125  
iter = 1 norm l2 of the solution is = 138.326 nu = 0.00125  
iter = 1 norm l2 of the increment is = 83.6301 nu = 0.00125  
iter = 1 err 0.604589 nu = 0.00125  
iter = 2 norm l2 of the solution is = 327.972 nu = 0.00125  
iter = 2 norm l2 of the increment is = 309.394 nu = 0.00125  
iter = 2 err 0.943356 nu = 0.00125  
iter = 3 norm l2 of the solution is = 5173.89 nu = 0.00125  
iter = 3 norm l2 of the increment is = 5173 nu = 0.00125  
iter = 3 err 0.999828 nu = 0.00125  
iter = 4 norm l2 of the solution is = 43883.1 nu = 0.00125  
iter = 4 norm l2 of the increment is = 43792.8 nu = 0.00125  
iter = 4 err 0.997941 nu = 0.00125  
iter = 5 norm l2 of the solution is = 51760.5 nu = 0.00125  
iter = 5 norm l2 of the increment is = 64390.4 nu = 0.00125  
iter = 5 err 1.24401 nu = 0.00125  
iter = 6 norm l2 of the solution is = 652427 nu = 0.00125  
iter = 6 norm l2 of the increment is = 657325 nu = 0.00125  
iter = 6 err 1.00751 nu = 0.00125  
iter = 7 norm l2 of the solution is = 6.52001e+06 nu = 0.00125  
iter = 7 norm l2 of the increment is = 6.57713e+06 nu = 0.00125  
iter = 7 err 1.00876 nu = 0.00125  
iter = 8 norm l2 of the solution is = 1.40046e+07 nu = 0.00125  
iter = 8 norm l2 of the increment is = 1.52788e+07 nu = 0.00125  
iter = 8 err 1.09099 nu = 0.00125  
iter = 9 norm l2 of the solution is = 4.62e+08 nu = 0.00125  
iter = 9 norm l2 of the increment is = 4.61924e+08 nu = 0.00125  
iter = 9 err 0.999836 nu = 0.00125  
iter = 10 norm l2 of the solution is = 1.45225e+09 nu = 0.00125  
iter = 10 norm l2 of the increment is = 1.47547e+09 nu = 0.00125  
iter = 10 err 1.01599 nu = 0.00125  
iter = 11 norm l2 of the solution is = 3.73892e+10 nu = 0.00125  
iter = 11 norm l2 of the increment is = 3.71997e+10 nu = 0.00125  
iter = 11 err 0.994932 nu = 0.00125  
iter = 12 norm l2 of the solution is = 1.17798e+11 nu = 0.00125  
iter = 12 norm l2 of the increment is = 1.2022e+11 nu = 0.00125  
iter = 12 err 1.02056 nu = 0.00125  
iter = 13 norm l2 of the solution is = 3.50408e+11 nu = 0.00125  
iter = 13 norm l2 of the increment is = 3.74938e+11 nu = 0.00125  
iter = 13 err 1.07 nu = 0.00125  
NO convergence for nu = 0.00125, it = 13, err = 1.07  
LAST viscosity TO CONVERGE = 0.0025  
RESTART with NEW viscosity = 0.00164938  
Using as Inital Data the solution for PREVIOUS viscosity  
iter = 0 norm l2 of the solution is = 88.8106 nu = 0.00164938  
iter = 0 norm l2 of the increment is = 30.0889 nu = 0.00164938  
iter = 0 err 0.338799 nu = 0.00164938  
iter = 1 norm l2 of the solution is = 88.0441 nu = 0.00164938  
iter = 1 norm l2 of the increment is = 6.9484 nu = 0.00164938  
iter = 1 err 0.0789195 nu = 0.00164938  
iter = 2 norm l2 of the solution is = 88.1804 nu = 0.00164938  
iter = 2 norm l2 of the increment is = 5.63273 nu = 0.00164938  
iter = 2 err 0.0638774 nu = 0.00164938  
iter = 3 norm l2 of the solution is = 88.0055 nu = 0.00164938  
iter = 3 norm l2 of the increment is = 1.63483 nu = 0.00164938  
iter = 3 err 0.0185764 nu = 0.00164938  
iter = 4 norm l2 of the solution is = 88.0043 nu = 0.00164938  
iter = 4 norm l2 of the increment is = 0.14972 nu = 0.00164938  
iter = 4 err 0.00170128 nu = 0.00164938  
iter = 5 norm l2 of the solution is = 88.0042 nu = 0.00164938  
iter = 5 norm l2 of the increment is = 0.00183785 nu = 0.00164938  
iter = 5 err 2.08837e-05 nu = 0.00164938  
iter = 6 norm l2 of the solution is = 88.0042 nu = 0.00164938  
iter = 6 norm l2 of the increment is = 5.67813e-07 nu = 0.00164938  
iter = 6 err 6.45211e-09 nu = 0.00164938  
CONVERGENCE for viscosity = 0.00164938 on iters = 6, err = 6.45211e-09  
Continuation to new viscosity = 0.00108819 (dividing factor 1.51572)  
Initial data IS the FINAL computation for previous viscosity  
iter = 0 norm l2 of the solution is = 133.75 nu = 0.00108819  
iter = 0 norm l2 of the increment is = 68.0884 nu = 0.00108819  
iter = 0 err 0.509074 nu = 0.00108819  
iter = 1 norm l2 of the solution is = 163.842 nu = 0.00108819  
iter = 1 norm l2 of the increment is = 108.07 nu = 0.00108819  
iter = 1 err 0.6596 nu = 0.00108819  
iter = 2 norm l2 of the solution is = 772.998 nu = 0.00108819  
iter = 2 norm l2 of the increment is = 759.157 nu = 0.00108819  
iter = 2 err 0.982095 nu = 0.00108819  
iter = 3 norm l2 of the solution is = 1561.14 nu = 0.00108819  
iter = 3 norm l2 of the increment is = 1555.72 nu = 0.00108819  
iter = 3 err 0.996531 nu = 0.00108819  
iter = 4 norm l2 of the solution is = 10970.7 nu = 0.00108819  
iter = 4 norm l2 of the increment is = 11042.6 nu = 0.00108819  
iter = 4 err 1.00656 nu = 0.00108819  
iter = 5 norm l2 of the solution is = 1.81488e+06 nu = 0.00108819  
iter = 5 norm l2 of the increment is = 1.81507e+06 nu = 0.00108819  
iter = 5 err 1.00011 nu = 0.00108819  
iter = 6 norm l2 of the solution is = 6.91653e+06 nu = 0.00108819  
iter = 6 norm l2 of the increment is = 7.1665e+06 nu = 0.00108819  
iter = 6 err 1.03614 nu = 0.00108819  
iter = 7 norm l2 of the solution is = 8.98585e+06 nu = 0.00108819  
iter = 7 norm l2 of the increment is = 1.06925e+07 nu = 0.00108819  
iter = 7 err 1.18993 nu = 0.00108819  
iter = 8 norm l2 of the solution is = 3.07881e+07 nu = 0.00108819  
iter = 8 norm l2 of the increment is = 3.19718e+07 nu = 0.00108819  
iter = 8 err 1.03845 nu = 0.00108819  
iter = 9 norm l2 of the solution is = 6.88865e+07 nu = 0.00108819  
iter = 9 norm l2 of the increment is = 7.16418e+07 nu = 0.00108819  
iter = 9 err 1.04 nu = 0.00108819  
iter = 10 norm l2 of the solution is = 6.74559e+08 nu = 0.00108819  
iter = 10 norm l2 of the increment is = 6.71772e+08 nu = 0.00108819  
iter = 10 err 0.995868 nu = 0.00108819  
iter = 11 norm l2 of the solution is = 4.34913e+09 nu = 0.00108819  
iter = 11 norm l2 of the increment is = 4.40264e+09 nu = 0.00108819  
iter = 11 err 1.0123 nu = 0.00108819  
iter = 12 norm l2 of the solution is = 1.39342e+10 nu = 0.00108819  
iter = 12 norm l2 of the increment is = 1.44947e+10 nu = 0.00108819  
iter = 12 err 1.04023 nu = 0.00108819  
iter = 13 norm l2 of the solution is = 8.43101e+11 nu = 0.00108819  
iter = 13 norm l2 of the increment is = 8.43635e+11 nu = 0.00108819  
iter = 13 err 1.00063 nu = 0.00108819  
NO convergence for nu = 0.00108819, it = 13, err = 1.00063  
LAST viscosity TO CONVERGE = 0.00164938  
RESTART with NEW viscosity = 0.00128514  
Using as Inital Data the solution for PREVIOUS viscosity  
iter = 0 norm l2 of the solution is = 107.797 nu = 0.00128514  
iter = 0 norm l2 of the increment is = 27.2448 nu = 0.00128514  
iter = 0 err 0.252743 nu = 0.00128514  
iter = 1 norm l2 of the solution is = 108.026 nu = 0.00128514  
iter = 1 norm l2 of the increment is = 20.6578 nu = 0.00128514  
iter = 1 err 0.191231 nu = 0.00128514  
iter = 2 norm l2 of the solution is = 107.749 nu = 0.00128514  
iter = 2 norm l2 of the increment is = 12.5265 nu = 0.00128514  
iter = 2 err 0.116256 nu = 0.00128514  
iter = 3 norm l2 of the solution is = 112.77 nu = 0.00128514  
iter = 3 norm l2 of the increment is = 33.9331 nu = 0.00128514  
iter = 3 err 0.300905 nu = 0.00128514  
iter = 4 norm l2 of the solution is = 109.131 nu = 0.00128514  
iter = 4 norm l2 of the increment is = 26.5275 nu = 0.00128514  
iter = 4 err 0.243078 nu = 0.00128514  
iter = 5 norm l2 of the solution is = 1384.5 nu = 0.00128514  
iter = 5 norm l2 of the increment is = 1382.35 nu = 0.00128514  
iter = 5 err 0.998452 nu = 0.00128514  
iter = 6 norm l2 of the solution is = 1188 nu = 0.00128514  
iter = 6 norm l2 of the increment is = 1178.22 nu = 0.00128514  
iter = 6 err 0.99177 nu = 0.00128514  
iter = 7 norm l2 of the solution is = 15670.2 nu = 0.00128514  
iter = 7 norm l2 of the increment is = 15673.3 nu = 0.00128514  
iter = 7 err 1.0002 nu = 0.00128514  
iter = 8 norm l2 of the solution is = 32865 nu = 0.00128514  
iter = 8 norm l2 of the increment is = 34103.6 nu = 0.00128514  
iter = 8 err 1.03769 nu = 0.00128514  
iter = 9 norm l2 of the solution is = 229752 nu = 0.00128514  
iter = 9 norm l2 of the increment is = 231107 nu = 0.00128514  
iter = 9 err 1.0059 nu = 0.00128514  
iter = 10 norm l2 of the solution is = 1.7383e+06 nu = 0.00128514  
iter = 10 norm l2 of the increment is = 1.78141e+06 nu = 0.00128514  
iter = 10 err 1.0248 nu = 0.00128514  
iter = 11 norm l2 of the solution is = 4.5312e+06 nu = 0.00128514  
iter = 11 norm l2 of the increment is = 5.00278e+06 nu = 0.00128514  
iter = 11 err 1.10407 nu = 0.00128514  
iter = 12 norm l2 of the solution is = 7.86183e+07 nu = 0.00128514  
iter = 12 norm l2 of the increment is = 7.84382e+07 nu = 0.00128514  
iter = 12 err 0.997709 nu = 0.00128514  
iter = 13 norm l2 of the solution is = 1.34233e+08 nu = 0.00128514  
iter = 13 norm l2 of the increment is = 1.39051e+08 nu = 0.00128514  
iter = 13 err 1.03589 nu = 0.00128514  
NO convergence for nu = 0.00128514, it = 13, err = 1.03589  
LAST viscosity TO CONVERGE = 0.00164938  
RESTART with NEW viscosity = 0.00142004  
Using as Inital Data the solution for PREVIOUS viscosity  
iter = 0 norm l2 of the solution is = 99.0145 nu = 0.00142004  
iter = 0 norm l2 of the increment is = 14.6384 nu = 0.00142004  
iter = 0 err 0.147841 nu = 0.00142004  
iter = 1 norm l2 of the solution is = 99.0791 nu = 0.00142004  
iter = 1 norm l2 of the increment is = 5.42687 nu = 0.00142004  
iter = 1 err 0.0547731 nu = 0.00142004  
iter = 2 norm l2 of the solution is = 98.8848 nu = 0.00142004  
iter = 2 norm l2 of the increment is = 1.85827 nu = 0.00142004  
iter = 2 err 0.0187923 nu = 0.00142004  
iter = 3 norm l2 of the solution is = 98.8679 nu = 0.00142004  
iter = 3 norm l2 of the increment is = 0.50027 nu = 0.00142004  
iter = 3 err 0.00505999 nu = 0.00142004  
iter = 4 norm l2 of the solution is = 98.8675 nu = 0.00142004  
iter = 4 norm l2 of the increment is = 0.0185601 nu = 0.00142004  
iter = 4 err 0.000187727 nu = 0.00142004  
iter = 5 norm l2 of the solution is = 98.8675 nu = 0.00142004  
iter = 5 norm l2 of the increment is = 3.41836e-05 nu = 0.00142004  
iter = 5 err 3.45751e-07 nu = 0.00142004  
CONVERGENCE for viscosity = 0.00142004 on iters = 5, err = 3.45751e-07  
Continuation to new viscosity = 0.00122258 (dividing factor 1.16151)  
Initial data IS the FINAL computation for previous viscosity  
iter = 0 norm l2 of the solution is = 112.495 nu = 0.00122258  
iter = 0 norm l2 of the increment is = 21.4033 nu = 0.00122258  
iter = 0 err 0.19026 nu = 0.00122258  
iter = 1 norm l2 of the solution is = 115.015 nu = 0.00122258  
iter = 1 norm l2 of the increment is = 30.1166 nu = 0.00122258  
iter = 1 err 0.261848 nu = 0.00122258  
iter = 2 norm l2 of the solution is = 1952.41 nu = 0.00122258  
iter = 2 norm l2 of the increment is = 1958 nu = 0.00122258  
iter = 2 err 1.00287 nu = 0.00122258  
iter = 3 norm l2 of the solution is = 979.026 nu = 0.00122258  
iter = 3 norm l2 of the increment is = 981.707 nu = 0.00122258  
iter = 3 err 1.00274 nu = 0.00122258  
iter = 4 norm l2 of the solution is = 1362.15 nu = 0.00122258  
iter = 4 norm l2 of the increment is = 1363.92 nu = 0.00122258  
iter = 4 err 1.0013 nu = 0.00122258  
iter = 5 norm l2 of the solution is = 15041.9 nu = 0.00122258  
iter = 5 norm l2 of the increment is = 15045.3 nu = 0.00122258  
iter = 5 err 1.00022 nu = 0.00122258  
iter = 6 norm l2 of the solution is = 31833.9 nu = 0.00122258  
iter = 6 norm l2 of the increment is = 32619.8 nu = 0.00122258  
iter = 6 err 1.02469 nu = 0.00122258  
iter = 7 norm l2 of the solution is = 122936 nu = 0.00122258  
iter = 7 norm l2 of the increment is = 128315 nu = 0.00122258  
iter = 7 err 1.04376 nu = 0.00122258  
iter = 8 norm l2 of the solution is = 1.69228e+06 nu = 0.00122258  
iter = 8 norm l2 of the increment is = 1.69446e+06 nu = 0.00122258  
iter = 8 err 1.00129 nu = 0.00122258  
iter = 9 norm l2 of the solution is = 5.27616e+06 nu = 0.00122258  
iter = 9 norm l2 of the increment is = 5.33833e+06 nu = 0.00122258  
iter = 9 err 1.01178 nu = 0.00122258  
iter = 10 norm l2 of the solution is = 5.51745e+07 nu = 0.00122258  
iter = 10 norm l2 of the increment is = 5.5605e+07 nu = 0.00122258  
iter = 10 err 1.0078 nu = 0.00122258

---

<div class="post-metadata">

**Author:** ![isharma25](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/isharma25/32/2624_2.png) [@isharma25](https://community.freefem.org/u/isharma25)\
**Post date:** [August 28, 2024, 8:14am UTC](https://community.freefem.org/t/old-example-of-newton3d-using-boussinesq-hypothesis-gives-seg-fault/3457/3 "2024-08-28T08:14:46Z")

</div>

Thank you for trying out the example, I am not using the cocoa executable. I installed it on a RHEL(Oracle linux version 9) and with that binary I get a seg-fault.  
More specifically I am getting an exception of “Broken pipe” at the following line:  
‘fwrite(ptr,size,nmemb,stream);’ in ffapi.cpp line 198

The call stack looks like:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/8/82261fee0481d496613625125c00142d9d888402.png)

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [August 28, 2024, 11:44am UTC](https://community.freefem.org/t/old-example-of-newton3d-using-boussinesq-hypothesis-gives-seg-fault/3457/4 "2024-08-28T11:44:38Z")

</div>

You should deactivate plotting, probably by using the additional command line parameter `-nw`, then the code will run fine.

---

<div class="post-metadata">

**Author:** ![isharma25](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/isharma25/32/2624_2.png) [@isharma25](https://community.freefem.org/u/isharma25)\
**Post date:** [August 28, 2024, 12:10pm UTC](https://community.freefem.org/t/old-example-of-newton3d-using-boussinesq-hypothesis-gives-seg-fault/3457/5 "2024-08-28T12:10:53Z")

</div>

Maybe these are two different problems indeed but similar outcome. Without plotting, I am getting a seg fault exception somewhere in the UMF\_kernel, GEMV function. Probably one of the column vectors is unfound, one symbol is optimised out so can’t say for sure.

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

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [August 28, 2024, 12:35pm UTC](https://community.freefem.org/t/old-example-of-newton3d-using-boussinesq-hypothesis-gives-seg-fault/3457/6 "2024-08-28T12:35:47Z")

</div>

There is something wrong with your installation. How did you compile FreeFEM? What version are you using?

---

<div class="post-metadata">

**Author:** ![isharma25](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/isharma25/32/2624_2.png) [@isharma25](https://community.freefem.org/u/isharma25)\
**Post date:** [August 28, 2024, 3:21pm UTC](https://community.freefem.org/t/old-example-of-newton3d-using-boussinesq-hypothesis-gives-seg-fault/3457/7 "2024-08-28T15:21:48Z")

</div>

I compiled the develop branch of FreeFem-sources, because there were issues related to 3rd-party downloads on the master branch. Some checks are indeed failing when I run make check:

[test-suite.log](https://community.freefem.org/uploads/short-url/lXQYtdCfEBJQZvbNBWQ4mSlrVsc.log) (173.2 KB)

The only little hack I made to get it all compiled was commenting out a couple of lines in plugin mpi:

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