Skip to content

Commit bc43539

Browse files
committed
convection
1 parent 251cec5 commit bc43539

File tree

3 files changed

+162
-164
lines changed

3 files changed

+162
-164
lines changed

user/fomels/Mcnvd.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,20 @@ int main (int argc, char* argv[])
4747
sf_floatread(conv[0][0],n12*nw,cnv);
4848

4949
for (i2=0; i2 < n2-1; i2++) {
50-
resd[i2][0] = 0.0f;
51-
for (i1=1; i1 < n1-1; i1++) {
50+
for (i1=0; i1 < nw; i1++) {
51+
resd[i2][i1] = 0.0f;
52+
}
53+
for (i1=nw; i1 < n1-nw; i1++) {
5254
dif = data[i2+1][i1] - data[i2][i1];
53-
resd[i2][i1] = -dif;
55+
resd[i2][i1] = dif;
5456
for (iw=1; iw <= order; iw++) {
55-
resd[i2][i1] += conv[i2][2*iw-2][i1]*(dif - data[i2+1][i1+iw] + data[i2][i1-iw]);
56-
resd[i2][i1] += conv[i2][2*iw-1][i1]*(dif - data[i2+1][i1-iw] + data[i2][i1+iw]);
57+
resd[i2][i1] -= conv[i2][2*iw-2][i1]*(dif - data[i2+1][i1+iw] + data[i2][i1-iw]);
58+
resd[i2][i1] -= conv[i2][2*iw-1][i1]*(dif - data[i2+1][i1-iw] + data[i2][i1+iw]);
5759
}
5860
}
59-
resd[i2][n1-1] = 0.0f;
61+
for (i1=n1-nw; i1 < n1; i1++) {
62+
resd[i2][i1] = 0.0f;
63+
}
6064
}
6165
for (i1=0; i1 < n1; i1++) {
6266
resd[n2-1][i1] = 0.0f;

user/fomels/Mcnvpaint.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/* Conection painting. */
1+
/* Convection painting. */
22
/*
3-
Copyright (C) 2004 University of Texas at Austin
3+
Copyright (C) 2025 University of Texas at Austin
44
55
This program is free software; you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -24,7 +24,6 @@
2424
int main (int argc, char* argv[])
2525
{
2626
int order, n1, n2, n12, i1, i2, i0, nw;
27-
char *label, *unit;
2827
float **u, ***conv, *trace;
2928
float o1, d1, o2, d2, eps, *time;
3029
sf_file cnv, out, seed;
@@ -43,17 +42,10 @@ int main (int argc, char* argv[])
4342
n12 = n1*n2;
4443

4544
if (!sf_histint(cnv,"n2",&nw)) sf_error("Need n2= in input");
46-
47-
sf_putint(out,"n2",n2);
48-
sf_putfloat(out,"d2",d2);
49-
sf_putfloat(out,"o2",o2);
50-
if (NULL != (label= sf_histstring(cnv,"label3"))) sf_putstring(out,"label2",label);
51-
if (NULL != (unit= sf_histstring(cnv,"unit3"))) sf_putstring(out,"unit2",unit);
52-
53-
sf_putint(out,"n3",1);
54-
5545
order = nw/2;
5646

47+
sf_unshiftdim(cnv,out,2);
48+
5749
if (NULL != sf_getstring("seed")) {
5850
seed = sf_input("seed");
5951
time = NULL;
@@ -98,6 +90,7 @@ int main (int argc, char* argv[])
9890
u[i2][i1] = trace[i1];
9991
}
10092
}
93+
10194
for (i1=0; i1 < n1; i1++) {
10295
trace[i1] = u[i0][i1];
10396
}
@@ -107,6 +100,7 @@ int main (int argc, char* argv[])
107100
u[i2][i1] = trace[i1];
108101
}
109102
}
103+
110104
sf_floatwrite(u[0],n1*n2,out);
111105

112106
exit(0);

0 commit comments

Comments
 (0)