-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathi2mart.c
executable file
·191 lines (186 loc) · 4.11 KB
/
i2mart.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <mkl.h>
/*
#include <omp.h>
*/
/* --------------------- INCLUDE PARTS --------------------- */
#include"headmart.c"
#include"loadmart.c"
#include"movemart.c"
#include"markmart.c"
#include"gausmart.c"
#include"heatmart.c"
#include"impact.c"
#include"core.c"
#include"grain.c"
/* --------------------- INCLUDE PARTS --------------------- */
/* Solve differencial equations by MARKER-IN-CELL + FINITE-DIFFERENCES method */
int main()
{
/* Counters */
int n0,n1,f0,fln3;
long int pos0cur0,m1,m2,m3;
/**/
/**/
/**/
/* Load data from input file */
fln3=loadconf()+1;
/**/
/**/
/**/
/* Load data from input file */
loader();
/**/
/* Read impact history */
impactread();
/**/
/**/
/* Output File Cycle */
for (f0=fln3;f0<fl0num;f0++)
{
/* Reload Cur Output File Name, Type */
for (n1=0;n1<50;n1++) fl1out[n1]=fl0out[f0][n1];
fl1otp=fl0otp[f0];
/**/
/* Reload cyc0max_maxxystep_maxtkstep_maxtmstep */
cyc0max=fl0cyc[f0];
maxxystep=fl0stp[f0][0];
maxtkstep=fl0stp[f0][1];
maxtmstep=fl0stp[f0][2];
/**/
/* General Cycle */
for (n0=0;n0<cyc0max;n0++)
{
if (printmod) printf("\n! FILE %s KRUG ! %d\n",fl1out,n0+1);
/**/
/**/
/**/
/* Set initial time step */
timestep=maxtmstep;
maxvelstep();
if (printmod) printf("\n !!! INITIAL TIME STEP FOR CYCLE %e YEARS !!! \n",timestep/3.15576e+7);
/**/
/**/
/**/
/* vX,vY recalc after Stokes+Continuity equation */
if(movemod)
{
if (printmod) printf("\n EPS, SIG, P, VX, VY CALCULATION...\n");
viterate(n0);
if (printmod) printf("EPS, SIG, P, VX, VY OK!\n");
}
/**/
/**/
/**/
/* Time step for marker displacement definition using FD stabilization upgrade [T. Duretz et al., Geochem. Geophys. Geosyst., 12, Q07004, 2011] */
timestep=maxtmstep;
maxvelstep();
if (printmod) printf("\n !!! FINAL TIME STEP FOR CYCLE %e YEARS !!! \n",timestep/3.15576e+7);
/**/
/**/
/**/
/* Tk recalc after Heat transport equation */
if(timedir>0 && tempmod && timestep)
{
if (printmod) printf("\n TEMPERATURE CALCULATION...\n");
titerate(n0);
if (printmod) printf("TEMPERATURE OK!\n");
}
/**/
/**/
/**/
/* Move marker */
if(markmod && timestep)
{
/* Time step for markers definition */
if(timedir<0 && timestep>0) timestep=-timestep;
if (printmod) printf("\n CURRENT VALID TIME STEP %e YEARS IN CYCLE\n",timestep/3.15576e+7);
if (printmod) printf("MARKERS MOVE...");
movemark();
if (printmod) printf("MARKERS OK!\n");
}
/**/
/**/
/**/
/* Reset Vx, Vy, P values */
if(ratemod)
{
if (printmod) printf("VX, VY, P RESET ...");
/* Vx, Vy Reset Cycle */
for (m1=0;m1<nodenum;m1++)
{
vx[m1]=vy[m1]=0;
}
/**/
/* Pressure in cells Reset Cycle */
for (m1=0;m1<xnumx1;m1++)
for (m2=0;m2<ynumy1;m2++)
{
/* Pos in pr[] */
m3=m1*ynumy1+m2;
/* Recalc P */
pr[m3]=pinit+((double)(m2)+0.5)*ystpy*GYKOEF*pkf[0];
}
if (printmod) printf("VX, VY, P OK!");
}
/**/
/**/
/* Impact takes place */
impact();
/**/
/* Handle pebble accretion event(s) since last timestep, Tim (2017-04-11) */
pebbleaccr();
/**/
/* ro[],nu[] Recalc */
if(gridmod)
{
if (printmod) printf("\n RO, NU, CP etc RECALC AFTER NEW MARKERS POSITIONS...");
ronurecalc();
if (printmod) printf("RO, NU, CP etc OK!\n");
}
/**/
/**/
/**/
/* Increase Timesum */
timesum+=timestep;
/* 1year=3.15576*10^7sek */
if (printmod) printf("\n %e YEARS IN CYCLE %e YEARS FROM START\n\n",timestep/3.15576e+7,timesum/3.15576e+7);
/**/
/**/
/**/
/* Print Results */
/*
if(n0<cyc0max-1) saver(f0+1,n0);
*/
/* Print Results */
}
/**/
/**/
/**/
/* Print Results */
saver(f0+1,n0-1);
/**/
/* Exit if final time is reached */
if(timesum>timeexit) {printf("Reached timeexit (timesum %e yr > timeexit %e yr) >>> QUIT\n",timesum/3.15576e+7,timeexit/3.15576e+7); exit(0);}
/**/
/* Check core evolution (Greg addition) */
core();
/**/
/* Check grain site evolution (Greg addition) */
grain();
/**/
/* Save impact and core history */
impactsave();
/**/
/**/
/* Print Results */
/**/
/* End Output file Names Cycle */
}
/* End Program */
return 0;
}
/* Solve differential equations by MARKER-IN-CELL + FINITE-DIFFERENCES method */