Skip to content

Commit 4d95a7f

Browse files
prj-cmdoug
andauthored
Minor improvements to examples/douglas_2024 (#22)
* No need for FreeFem++ anymore * No need for MatConvert() with MUMPS * Avoid redundant evaluations in basecomputeaug.md --------- Co-authored-by: cmdoug <68232338+cmdoug@users.noreply.github.com>
1 parent 71c5210 commit 4d95a7f

3 files changed

Lines changed: 8 additions & 20 deletions

File tree

examples/douglas_2024/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ Note: this example does not make use of adaptive meshing.
5858
```sh
5959
FreeFem++-mpi -v 0 examples/douglas_2024/grabowski.md -mo $workdir/G
6060
```
61-
## Run the standalone serial FreeFEM code provided in the Supplementary Materials
61+
## Run the code provided in the Supplementary Materials
6262
```sh
63-
FreeFem++ -v 0 examples/douglas_2024/example1_suppmat.md
63+
FreeFem++-mpi -v 0 examples/douglas_2024/example1_suppmat.md
6464
```
6565

6666
## Perform parallel computations for Grabowski--Berger vortex flow using `ff-bifbox`

examples/douglas_2024/basecomputeaug.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,17 @@ sym = 0;
151151
real[int] ik(sym.n), ik2(sym.n), ik3(sym.n);
152152
real iomega = 0.0, iomega2 = 0.0, iomega3 = 0.0;
153153
include "eqns.idp" // load equations
154-
Mat Jp(J.n, mpirank == 0 ? 1 : 0); // Initialize Mat objects for bordered matrix
155-
Ja = [[J,Jp],[Jp',0]]; // make dummy Jacobian
154+
real[int] Jp, vaug = vJp(0, XMh, tgv = -10);
155+
ChangeNumbering(J, vaug, Jp);
156+
Ja = [[J, Jp], [Jp', 0]];
156157
// Function to build residual operator in PETSc numbering
157158
func real[int] funcR(real[int]& qPETSc) {
158159
ChangeNumbering(J, ub[], qPETSc(0:qPETSc.n - (mpirank == 0 ? 2 : 1)), inverse = true, exchange = true);
159160
if(mpirank == 0) c = qPETSc(qPETSc.n-1);
160161
broadcast(processor(0), c);
161162
real[int] RPETSc, R = vR(0, XMh, tgv = TGV);
162163
ChangeNumbering(J, R, RPETSc);
163-
ub[] .*= J.D;
164-
real pavg, pavgl = int2d(Th)( y*ubp );
165-
mpiAllReduce(pavgl, pavg, mpiCommWorld, mpiSUM);
164+
real pavg = J(vaug, ub[]);
166165
if(mpirank == 0) {
167166
RPETSc.resize(RPETSc.n+1); // Append 0 to residual vector on proc 0
168167
RPETSc(RPETSc.n-1) = pavg;
@@ -175,10 +174,6 @@ func int funcJ(real[int]& qPETSc) {
175174
if(mpirank == 0) c = qPETSc(qPETSc.n-1);
176175
broadcast(processor(0), c);
177176
J = vJ(XMh, XMh, tgv = TGV);
178-
real[int] vP, vaug = vJp(0, XMh, tgv = -10);
179-
ChangeNumbering(J, vaug, vP); // FreeFEM to PETSc
180-
matrix tempPms = [[vP]]; // dense array to sparse matrix
181-
ChangeOperator(Jp, tempPms, parent = Ja); // send to Mat
182177
return 0;
183178
}
184179
// set up Mat parameters

examples/douglas_2024/modecomputeaug.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ if (filein == "" && meshin != "") {
122122
ub[] = um[].re;
123123
filein = fileout + ".base";
124124
}
125-
Mat<complex> Jp(J.n, mpirank == 0 ? 1 : 0), ZZ(mpirank == 0 ? 1 : 0, mpirank == 0 ? 1 : 0); // Initialize Mat objects for bordered matrix
126125
127126
sym = parsesymstr(symstr);
128127
complex[int] ik(sym.n), ik2(sym.n), ik3(sym.n);
@@ -144,14 +143,8 @@ complex shiftf = string2complex(targetf);
144143
M = vM(XMh, XMh, tgv = -20);
145144
complex[int] vP, vaug = vJp(0, XMh, tgv = -20);
146145
ChangeNumbering(J, vaug, vP); // FreeFEM to PETSc
147-
matrix<complex> tempMx = [[vP]]; // dense array to sparse matrix
148-
ChangeOperator(Jp, tempMx); // send to Mat
149-
tempMx = [[0]];
150-
ChangeOperator(ZZ, tempMx); // send to Mat
151-
Mat<complex> Jatemp = [[J, Jp], [Jp', 0]]; // make dummy Jacobian
152-
Mat<complex> Matemp = [[M, 0], [0, ZZ]]; // make dummy Jacobian
153-
MatConvert(Jatemp, Ja);
154-
MatConvert(Matemp, Ma);
146+
Ja = [[J, vP], [vP', 0]];
147+
Ma = [[M, 0], [0, 0]];
155148
}
156149
for (int n = 0; n < ntarget; ++n){
157150
if (ntarget > 1) shift = shifts + (shiftf - shifts)*real(n)/real(ntarget - 1);

0 commit comments

Comments
 (0)