Skip to content

Commit e018357

Browse files
committed
update transient simulation
1 parent 697598f commit e018357

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

Example1-Stenosis/ReferNS_transient_parallel.edp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ for(int sample = 0; sample<500; sample++){
8787

8888
real dt = 0.002;
8989
real t = 0;
90-
real T = 0.3; // (s)
90+
real T = 0.6; // (s)
9191
int tstep = 0;
9292
int saveEach = 10;
9393
int[int] orderOut = [1, 1, 1, 1];
@@ -124,6 +124,8 @@ for(int sample = 0; sample<500; sample++){
124124
fespace SpaceVector(Mesh, PkVector);
125125
fespace Uh(Mesh,P2);
126126

127+
Uh umagdelta, umagsquare;
128+
127129
SpaceVector [ucx, ucy, pc] = [-umax*(y-1)^2+umax, 0, 0];
128130
SpaceVector [uckx, ucky, pck];
129131
SpaceVector [ucxold, ucyold, pcold];
@@ -218,6 +220,19 @@ for(int sample = 0; sample<500; sample++){
218220
ChangeNumbering(J, ucx[], xPETSc);
219221
SNESSolve(J, funcJ, funcRes, xPETSc, sparams = "-snes_monitor ");
220222
ChangeNumbering(J, ucx[], xPETSc, inverse = true, exchange = true);
223+
224+
umagsquare = ucx^2+ucy^2;
225+
umagdelta = (sqrt(ucx^2+ucy^2) - sqrt(ucxold^2+ucyold^2))^2;
226+
real err = sqrt(umagdelta[].sum)/sqrt(umagsquare[].sum);
227+
228+
// Find the maximum error on all mpirank
229+
real finalerr;
230+
mpiAllReduce(err, finalerr, mpiCommWorld, mpiMAX);
231+
232+
if(mpirank == 0)
233+
cout<<"Final error: "<<finalerr<<endl;
234+
235+
if(finalerr<1e-3) break;
221236

222237
[ucxold, ucyold, pcold]=[ucx, ucy, pc];
223238

Example2-Bifurcation/ReferNS_transient_parallel.edp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ for(int sample = 0; sample<500; sample++){
8686
mesh Mesh = readmesh("data/reference/reference.msh");
8787
mesh MeshBackup = readmesh("data/reference/reference.msh");
8888

89-
real dt = 1e-3;
89+
real dt = 5e-4;
9090
real t = 0;
91-
real T = 1.5e-1; // (s)
91+
real T = 5.0e-1; // (s)
9292
int tstep = 0;
9393

9494
int[int] orderOut = [1, 1, 1, 1];
@@ -126,6 +126,8 @@ for(int sample = 0; sample<500; sample++){
126126
fespace SpaceVector(Mesh, PkVector);
127127
fespace Uh(Mesh,P2);
128128

129+
Uh umagdelta, umagsquare;
130+
129131
SpaceVector [ucx, ucy, pc] = [-umax*(y-1)^2+umax, 0, 0];
130132
SpaceVector [uckx, ucky, pck];
131133
SpaceVector [ucxold, ucyold, pcold];
@@ -218,6 +220,19 @@ for(int sample = 0; sample<500; sample++){
218220
ChangeNumbering(J, ucx[], xPETSc);
219221
SNESSolve(J, funcJ, funcRes, xPETSc, sparams = "-snes_monitor ");
220222
ChangeNumbering(J, ucx[], xPETSc, inverse = true, exchange = true);
223+
224+
umagsquare = ucx^2+ucy^2;
225+
umagdelta = (sqrt(ucx^2+ucy^2) - sqrt(ucxold^2+ucyold^2))^2;
226+
real err = sqrt(umagdelta[].sum)/sqrt(umagsquare[].sum);
227+
228+
// Find the maximum error on all mpirank
229+
real finalerr;
230+
mpiAllReduce(err, finalerr, mpiCommWorld, mpiMAX);
231+
232+
if(mpirank == 0)
233+
cout<<"Final error: "<<finalerr<<endl;
234+
235+
if(finalerr<1e-3) break;
221236

222237
[ucxold, ucyold, pcold]=[ucx, ucy, pc];
223238

0 commit comments

Comments
 (0)