-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathChem_transport.c
190 lines (132 loc) · 4.92 KB
/
Chem_transport.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
/*
Copyright (C) 1995 The GeoFramework Consortium
This file is part of Ellipsis3D.
Ellipsis3D is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2,
as published by the Free Software Foundation.
Ellipsis3D is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Author:
Louis Moresi <[email protected]>
*/
#include <math.h>
#include "element_definitions.h"
#include "global_defs.h"
#include "function_prototypes.h"
/* Functions to handle Hans' chemical transport model based on
mobile + immobile phase pseudo-porous flow */
/* 1. get stress normal to layering at tracers */
void update_sigma_n(
struct All_variables *E
)
{
int m,i,j,k;
standard_precision tau[7][7];
standard_precision D[7][7];
standard_precision pressure;
standard_precision Dkk,*divU;
standard_precision Hvisc;
divU = (standard_precision *) Malloc0((E->mesh.nel+1) * sizeof(standard_precision));
assemble_div_us3(E,E->V[1],E->V[2],E->V[3],divU,E->mesh.levmax);
for(m=1;m<=E->tracer.NUM_TRACERS;m++) {
if(E->tracer.visc[E->tracer.property_group[m]].mobile_phase_ratio == 1.0) {
E->tracer.sigma_n[m] = 0.0;
continue;
}
/* If elastic, then this is already available, essentially, in S11 etc */
tracer_deviatoric_stress_and_pressure(E,tau,D,&pressure,&Dkk,&Hvisc,m,E->mesh.levmax);
E->tracer.sigma_n[m] =
E->tracer.n1[m] * E->tracer.n1[m] * tau[1][1] +
E->tracer.n2[m] * E->tracer.n2[m] * tau[2][2] +
2.0 * E->tracer.n2[m] * E->tracer.n1[m] * tau[1][2] -
(pressure - E->tracer.visc[E->tracer.property_group[m]].Pen_bulk*E->tracer.Visc[m] * divU[E->tracer.tracer_elt[E->mesh.levmax][m]]) ;
if(fabs(E->tracer.sigma_n[m]) > 1.0e10)
fprintf(stderr,"Tracer %d, sigma_n = %g (%g,%g,%g,%g,%g)\n",
m,E->tracer.sigma_n[m],E->tracer.n1[m],E->tracer.n2[m],
tau[1][1],tau[2][2],tau[1][2]);
}
free((void *) divU) ;
return;
}
void update_porosity(
struct All_variables *E
)
{
standard_precision eltk[9][9];
standard_precision S[4][4];
standard_precision dOmega;
standard_precision lN[ELNMAX+1];
standard_precision lNx[4][ELNMAX+1];
standard_precision time1;
standard_precision eta1,eta2,eta3;
standard_precision *dphi_n;
standard_precision *dphi_t;
standard_precision *sigman_n;
standard_precision dphi_e[9];
int el,a,b,i,j,m;
const int level = E->mesh.levmax;
const int dims=E->mesh.nsd;
const int dofs=E->mesh.dof;
const int ends=enodes[dims];
dphi_n = (standard_precision *) Malloc0((E->mesh.nno + 1) * sizeof(standard_precision));
dphi_t = (standard_precision *) Malloc0((E->tracer.NUM_TRACERS + 1) * sizeof(standard_precision));
sigman_n = (standard_precision *) Malloc0((E->mesh.nno + 1) * sizeof(standard_precision));
gs_tracers_to_nodes(E,sigman_n,NULL,NULL,NULL,E->tracer.sigma_n,level,0);
for(i=1;i<=E->mesh.nno;i++) {
fprintf(stderr,"Sigman[%d] = %g\n",i,sigman_n[i]);
dphi_n[i] = 0.0;
}
for(el=1;el<=E->mesh.nel;el++) {
for(i=0;i<E->tracer.tr_in_element_number[level][el];i++) {
m = E->tracer.tr_in_element[level][i+E->tracer.tr_in_element_offset[level][el]];
eta1 = E->tracer.eta1[level][m];
eta2 = E->tracer.eta2[level][m];
get_global_v_x_shape_fn(E,el,lNx,&dOmega,eta1,eta2,NULL,level);
dOmega =
E->tracer.tracer_weight_fn[level][m]
* E->tracer.tracer_jacobian[level][m] *
E->tracer.permeability_factor[E->tracer.property_group[m]];
S[1][1] = 1.0 - E->tracer.n1[m] * E->tracer.n1[m];
S[2][2] = 1.0 - E->tracer.n2[m] * E->tracer.n2[m];
S[1][2] = - E->tracer.n2[m] * E->tracer.n1[m];
for(a=1;a<=ends;a++) {
dphi_e[a] = 0.0;
for(b=1;b<=ends;b++)
eltk[a][b] = 0.0;
}
for(a=1;a<=ends;a++) {
for(b=1;b<=ends;b++) {
eltk[a][b] += dOmega * ( lNx[1][a] * S[1][1] * lNx[1][b] +
lNx[2][a] * S[1][2] * lNx[1][b] +
lNx[1][a] * S[1][2] * lNx[2][b] +
lNx[2][a] * S[2][2] * lNx[2][b] );
}
}
}
for(a=1;a<=ends;a++)
for(b=1;b<=ends;b++)
dphi_e[a] += eltk[a][b] * sigman_n[E->ien[el].node[b]];
for(a=1;a<=ends;a++) {
dphi_n[E->ien[el].node[a]] += dphi_e[a];
}
} /* Next element */
time1 = E->advection.timestep;
for(i=1;i<=E->mesh.nno;i++) {
dphi_n[i] = - time1 * dphi_n[i] / E->mass[i];
}
/* Tracer value of delta phi */
nodes_to_tracers(E,dphi_n,dphi_t,level);
for(m=1;m<=E->tracer.NUM_TRACERS;m++) {
E->tracer.volfraction[m] += dphi_t[m];
if(E->tracer.volfraction[m] > 1.0)
E->tracer.volfraction[m] = 1.0;
if(E->tracer.volfraction[m] < 0.0)
E->tracer.volfraction[m] = 0.0;
}
free((void *) dphi_n);
free((void *) dphi_t);
free((void *) sigman_n);
return;
}