165876a83SMatthew G. Knepley static char help[] = "Time dependent Biot Poroelasticity problem with finite elements.\n\
265876a83SMatthew G. Knepley We solve three field, quasi-static poroelasticity in a rectangular\n\
365876a83SMatthew G. Knepley domain, using a parallel unstructured mesh (DMPLEX) to discretize it.\n\
465876a83SMatthew G. Knepley Contributed by: Robert Walker <rwalker6@buffalo.edu>\n\n\n";
565876a83SMatthew G. Knepley
665876a83SMatthew G. Knepley #include <petscdmplex.h>
765876a83SMatthew G. Knepley #include <petscsnes.h>
865876a83SMatthew G. Knepley #include <petscts.h>
965876a83SMatthew G. Knepley #include <petscds.h>
1065876a83SMatthew G. Knepley #include <petscbag.h>
1165876a83SMatthew G. Knepley
1265876a83SMatthew G. Knepley #include <petsc/private/tsimpl.h>
1365876a83SMatthew G. Knepley
1465876a83SMatthew G. Knepley /* This presentation of poroelasticity is taken from
1565876a83SMatthew G. Knepley
1665876a83SMatthew G. Knepley @book{Cheng2016,
1765876a83SMatthew G. Knepley title={Poroelasticity},
1865876a83SMatthew G. Knepley author={Cheng, Alexander H-D},
1965876a83SMatthew G. Knepley volume={27},
2065876a83SMatthew G. Knepley year={2016},
2165876a83SMatthew G. Knepley publisher={Springer}
2265876a83SMatthew G. Knepley }
2365876a83SMatthew G. Knepley
2465876a83SMatthew G. Knepley For visualization, use
2565876a83SMatthew G. Knepley
2665876a83SMatthew G. Knepley -dm_view hdf5:${PETSC_DIR}/sol.h5 -monitor_solution hdf5:${PETSC_DIR}/sol.h5::append
2765876a83SMatthew G. Knepley
2865876a83SMatthew G. Knepley The weak form would then be, using test function $(v, q, \tau)$,
2965876a83SMatthew G. Knepley
3065876a83SMatthew G. Knepley (q, \frac{1}{M} \frac{dp}{dt}) + (q, \alpha \frac{d\varepsilon}{dt}) + (\nabla q, \kappa \nabla p) = (q, g)
3165876a83SMatthew G. Knepley -(\nabla v, 2 G \epsilon) - (\nabla\cdot v, \frac{2 G \nu}{1 - 2\nu} \varepsilon) + \alpha (\nabla\cdot v, p) = (v, f)
3265876a83SMatthew G. Knepley (\tau, \nabla \cdot u - \varepsilon) = 0
3365876a83SMatthew G. Knepley */
3465876a83SMatthew G. Knepley
359371c9d4SSatish Balay typedef enum {
369371c9d4SSatish Balay SOL_QUADRATIC_LINEAR,
379371c9d4SSatish Balay SOL_QUADRATIC_TRIG,
389371c9d4SSatish Balay SOL_TRIG_LINEAR,
399371c9d4SSatish Balay SOL_TERZAGHI,
409371c9d4SSatish Balay SOL_MANDEL,
419371c9d4SSatish Balay SOL_CRYER,
429371c9d4SSatish Balay NUM_SOLUTION_TYPES
439371c9d4SSatish Balay } SolutionType;
4465876a83SMatthew G. Knepley const char *solutionTypes[NUM_SOLUTION_TYPES + 1] = {"quadratic_linear", "quadratic_trig", "trig_linear", "terzaghi", "mandel", "cryer", "unknown"};
4565876a83SMatthew G. Knepley
4665876a83SMatthew G. Knepley typedef struct {
4765876a83SMatthew G. Knepley PetscScalar mu; /* shear modulus */
4865876a83SMatthew G. Knepley PetscScalar K_u; /* undrained bulk modulus */
4965876a83SMatthew G. Knepley PetscScalar alpha; /* Biot effective stress coefficient */
5065876a83SMatthew G. Knepley PetscScalar M; /* Biot modulus */
5165876a83SMatthew G. Knepley PetscScalar k; /* (isotropic) permeability */
5265876a83SMatthew G. Knepley PetscScalar mu_f; /* fluid dynamic viscosity */
5365876a83SMatthew G. Knepley PetscScalar P_0; /* magnitude of vertical stress */
5465876a83SMatthew G. Knepley } Parameter;
5565876a83SMatthew G. Knepley
5665876a83SMatthew G. Knepley typedef struct {
5765876a83SMatthew G. Knepley /* Domain and mesh definition */
5830602db0SMatthew G. Knepley PetscReal xmin[3]; /* Lower left bottom corner of bounding box */
5930602db0SMatthew G. Knepley PetscReal xmax[3]; /* Upper right top corner of bounding box */
6065876a83SMatthew G. Knepley /* Problem definition */
6165876a83SMatthew G. Knepley SolutionType solType; /* Type of exact solution */
6265876a83SMatthew G. Knepley PetscBag bag; /* Problem parameters */
6365876a83SMatthew G. Knepley PetscReal t_r; /* Relaxation time: 4 L^2 / c */
6424b15d09SMatthew G. Knepley PetscReal dtInitial; /* Override the choice for first timestep */
6565876a83SMatthew G. Knepley /* Exact solution terms */
6665876a83SMatthew G. Knepley PetscInt niter; /* Number of series term iterations in exact solutions */
6765876a83SMatthew G. Knepley PetscReal eps; /* Precision value for root finding */
6865876a83SMatthew G. Knepley PetscReal *zeroArray; /* Array of root locations */
6965876a83SMatthew G. Knepley } AppCtx;
7065876a83SMatthew G. Knepley
zero(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)71*2a8381b2SBarry Smith static PetscErrorCode zero(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
72d71ae5a4SJacob Faibussowitsch {
7365876a83SMatthew G. Knepley PetscInt c;
7465876a83SMatthew G. Knepley for (c = 0; c < Nc; ++c) u[c] = 0.0;
753ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
7665876a83SMatthew G. Knepley }
7765876a83SMatthew G. Knepley
7865876a83SMatthew G. Knepley /* Quadratic space and linear time solution
7965876a83SMatthew G. Knepley
8065876a83SMatthew G. Knepley 2D:
8165876a83SMatthew G. Knepley u = x^2
8265876a83SMatthew G. Knepley v = y^2 - 2xy
8365876a83SMatthew G. Knepley p = (x + y) t
8465876a83SMatthew G. Knepley e = 2y
8565876a83SMatthew G. Knepley f = <2 G, 4 G + 2 \lambda > - <alpha t, alpha t>
8665876a83SMatthew G. Knepley g = 0
8765876a83SMatthew G. Knepley \epsilon = / 2x -y \
8865876a83SMatthew G. Knepley \ -y 2y - 2x /
8965876a83SMatthew G. Knepley Tr(\epsilon) = e = div u = 2y
9065876a83SMatthew G. Knepley div \sigma = \partial_i 2 G \epsilon_{ij} + \partial_i \lambda \varepsilon \delta_{ij} - \partial_i \alpha p \delta_{ij}
9165876a83SMatthew G. Knepley = 2 G < 2-1, 2 > + \lambda <0, 2> - alpha <t, t>
9265876a83SMatthew G. Knepley = <2 G, 4 G + 2 \lambda> - <alpha t, alpha t>
9365876a83SMatthew G. Knepley \frac{1}{M} \frac{dp}{dt} + \alpha \frac{d\varepsilon}{dt} - \nabla \cdot \kappa \nabla p
9465876a83SMatthew G. Knepley = \frac{1}{M} \frac{dp}{dt} + \kappa \Delta p
9565876a83SMatthew G. Knepley = (x + y)/M
9665876a83SMatthew G. Knepley
9765876a83SMatthew G. Knepley 3D:
9865876a83SMatthew G. Knepley u = x^2
9965876a83SMatthew G. Knepley v = y^2 - 2xy
10065876a83SMatthew G. Knepley w = z^2 - 2yz
10165876a83SMatthew G. Knepley p = (x + y + z) t
10265876a83SMatthew G. Knepley e = 2z
10365876a83SMatthew G. Knepley f = <2 G, 4 G + 2 \lambda > - <alpha t, alpha t, alpha t>
10465876a83SMatthew G. Knepley g = 0
10565876a83SMatthew G. Knepley \varepsilon = / 2x -y 0 \
10665876a83SMatthew G. Knepley | -y 2y - 2x -z |
10765876a83SMatthew G. Knepley \ 0 -z 2z - 2y/
10865876a83SMatthew G. Knepley Tr(\varepsilon) = div u = 2z
10965876a83SMatthew G. Knepley div \sigma = \partial_i 2 G \epsilon_{ij} + \partial_i \lambda \varepsilon \delta_{ij} - \partial_i \alpha p \delta_{ij}
11065876a83SMatthew G. Knepley = 2 G < 2-1, 2-1, 2 > + \lambda <0, 0, 2> - alpha <t, t, t>
11165876a83SMatthew G. Knepley = <2 G, 2G, 4 G + 2 \lambda> - <alpha t, alpha t, alpha t>
11265876a83SMatthew G. Knepley */
quadratic_u(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)113*2a8381b2SBarry Smith static PetscErrorCode quadratic_u(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
114d71ae5a4SJacob Faibussowitsch {
11565876a83SMatthew G. Knepley PetscInt d;
11665876a83SMatthew G. Knepley
117ad540459SPierre Jolivet for (d = 0; d < dim; ++d) u[d] = PetscSqr(x[d]) - (d > 0 ? 2.0 * x[d - 1] * x[d] : 0.0);
1183ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
11965876a83SMatthew G. Knepley }
12065876a83SMatthew G. Knepley
linear_eps(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)121*2a8381b2SBarry Smith static PetscErrorCode linear_eps(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
122d71ae5a4SJacob Faibussowitsch {
12365876a83SMatthew G. Knepley u[0] = 2.0 * x[dim - 1];
1243ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
12565876a83SMatthew G. Knepley }
12665876a83SMatthew G. Knepley
linear_linear_p(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)127*2a8381b2SBarry Smith static PetscErrorCode linear_linear_p(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
128d71ae5a4SJacob Faibussowitsch {
12965876a83SMatthew G. Knepley PetscReal sum = 0.0;
13065876a83SMatthew G. Knepley PetscInt d;
13165876a83SMatthew G. Knepley
13265876a83SMatthew G. Knepley for (d = 0; d < dim; ++d) sum += x[d];
13365876a83SMatthew G. Knepley u[0] = sum * time;
1343ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
13565876a83SMatthew G. Knepley }
13665876a83SMatthew G. Knepley
linear_linear_p_t(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)137*2a8381b2SBarry Smith static PetscErrorCode linear_linear_p_t(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
138d71ae5a4SJacob Faibussowitsch {
13965876a83SMatthew G. Knepley PetscReal sum = 0.0;
14065876a83SMatthew G. Knepley PetscInt d;
14165876a83SMatthew G. Knepley
14265876a83SMatthew G. Knepley for (d = 0; d < dim; ++d) sum += x[d];
14365876a83SMatthew G. Knepley u[0] = sum;
1443ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
14565876a83SMatthew G. Knepley }
14665876a83SMatthew G. Knepley
f0_quadratic_linear_u(PetscInt dim,PetscInt Nf,PetscInt NfAux,const PetscInt uOff[],const PetscInt uOff_x[],const PetscScalar u[],const PetscScalar u_t[],const PetscScalar u_x[],const PetscInt aOff[],const PetscInt aOff_x[],const PetscScalar a[],const PetscScalar a_t[],const PetscScalar a_x[],PetscReal t,const PetscReal x[],PetscInt numConstants,const PetscScalar constants[],PetscScalar f0[])147d71ae5a4SJacob Faibussowitsch static void f0_quadratic_linear_u(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
148d71ae5a4SJacob Faibussowitsch {
14965876a83SMatthew G. Knepley const PetscReal G = PetscRealPart(constants[0]);
15065876a83SMatthew G. Knepley const PetscReal K_u = PetscRealPart(constants[1]);
15165876a83SMatthew G. Knepley const PetscReal alpha = PetscRealPart(constants[2]);
15265876a83SMatthew G. Knepley const PetscReal M = PetscRealPart(constants[3]);
15365876a83SMatthew G. Knepley const PetscReal K_d = K_u - alpha * alpha * M;
15465876a83SMatthew G. Knepley const PetscReal lambda = K_d - (2.0 * G) / 3.0;
15565876a83SMatthew G. Knepley PetscInt d;
15665876a83SMatthew G. Knepley
157ad540459SPierre Jolivet for (d = 0; d < dim - 1; ++d) f0[d] -= 2.0 * G - alpha * t;
15865876a83SMatthew G. Knepley f0[dim - 1] -= 2.0 * lambda + 4.0 * G - alpha * t;
15965876a83SMatthew G. Knepley }
16065876a83SMatthew G. Knepley
f0_quadratic_linear_p(PetscInt dim,PetscInt Nf,PetscInt NfAux,const PetscInt uOff[],const PetscInt uOff_x[],const PetscScalar u[],const PetscScalar u_t[],const PetscScalar u_x[],const PetscInt aOff[],const PetscInt aOff_x[],const PetscScalar a[],const PetscScalar a_t[],const PetscScalar a_x[],PetscReal t,const PetscReal x[],PetscInt numConstants,const PetscScalar constants[],PetscScalar f0[])161d71ae5a4SJacob Faibussowitsch static void f0_quadratic_linear_p(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
162d71ae5a4SJacob Faibussowitsch {
16365876a83SMatthew G. Knepley const PetscReal alpha = PetscRealPart(constants[2]);
16465876a83SMatthew G. Knepley const PetscReal M = PetscRealPart(constants[3]);
16565876a83SMatthew G. Knepley PetscReal sum = 0.0;
16665876a83SMatthew G. Knepley PetscInt d;
16765876a83SMatthew G. Knepley
16865876a83SMatthew G. Knepley for (d = 0; d < dim; ++d) sum += x[d];
16965876a83SMatthew G. Knepley f0[0] += u_t ? alpha * u_t[uOff[1]] : 0.0;
17065876a83SMatthew G. Knepley f0[0] += u_t ? u_t[uOff[2]] / M : 0.0;
17165876a83SMatthew G. Knepley f0[0] -= sum / M;
17265876a83SMatthew G. Knepley }
17365876a83SMatthew G. Knepley
17465876a83SMatthew G. Knepley /* Quadratic space and trigonometric time solution
17565876a83SMatthew G. Knepley
17665876a83SMatthew G. Knepley 2D:
17765876a83SMatthew G. Knepley u = x^2
17865876a83SMatthew G. Knepley v = y^2 - 2xy
17965876a83SMatthew G. Knepley p = (x + y) cos(t)
18065876a83SMatthew G. Knepley e = 2y
18165876a83SMatthew G. Knepley f = <2 G, 4 G + 2 \lambda > - <alpha cos(t), alpha cos(t)>
18265876a83SMatthew G. Knepley g = 0
18365876a83SMatthew G. Knepley \epsilon = / 2x -y \
18465876a83SMatthew G. Knepley \ -y 2y - 2x /
18565876a83SMatthew G. Knepley Tr(\epsilon) = e = div u = 2y
18665876a83SMatthew G. Knepley div \sigma = \partial_i 2 G \epsilon_{ij} + \partial_i \lambda \varepsilon \delta_{ij} - \partial_i \alpha p \delta_{ij}
18765876a83SMatthew G. Knepley = 2 G < 2-1, 2 > + \lambda <0, 2> - alpha <cos(t), cos(t)>
18865876a83SMatthew G. Knepley = <2 G, 4 G + 2 \lambda> - <alpha cos(t), alpha cos(t)>
18965876a83SMatthew G. Knepley \frac{1}{M} \frac{dp}{dt} + \alpha \frac{d\varepsilon}{dt} - \nabla \cdot \kappa \nabla p
19065876a83SMatthew G. Knepley = \frac{1}{M} \frac{dp}{dt} + \kappa \Delta p
19165876a83SMatthew G. Knepley = -(x + y)/M sin(t)
19265876a83SMatthew G. Knepley
19365876a83SMatthew G. Knepley 3D:
19465876a83SMatthew G. Knepley u = x^2
19565876a83SMatthew G. Knepley v = y^2 - 2xy
19665876a83SMatthew G. Knepley w = z^2 - 2yz
19765876a83SMatthew G. Knepley p = (x + y + z) cos(t)
19865876a83SMatthew G. Knepley e = 2z
19965876a83SMatthew G. Knepley f = <2 G, 4 G + 2 \lambda > - <alpha cos(t), alpha cos(t), alpha cos(t)>
20065876a83SMatthew G. Knepley g = 0
20165876a83SMatthew G. Knepley \varepsilon = / 2x -y 0 \
20265876a83SMatthew G. Knepley | -y 2y - 2x -z |
20365876a83SMatthew G. Knepley \ 0 -z 2z - 2y/
20465876a83SMatthew G. Knepley Tr(\varepsilon) = div u = 2z
20565876a83SMatthew G. Knepley div \sigma = \partial_i 2 G \epsilon_{ij} + \partial_i \lambda \varepsilon \delta_{ij} - \partial_i \alpha p \delta_{ij}
20665876a83SMatthew G. Knepley = 2 G < 2-1, 2-1, 2 > + \lambda <0, 0, 2> - alpha <cos(t), cos(t), cos(t)>
20765876a83SMatthew G. Knepley = <2 G, 2G, 4 G + 2 \lambda> - <alpha cos(t), alpha cos(t), alpha cos(t)>
20865876a83SMatthew G. Knepley */
linear_trig_p(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)209*2a8381b2SBarry Smith static PetscErrorCode linear_trig_p(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
210d71ae5a4SJacob Faibussowitsch {
21165876a83SMatthew G. Knepley PetscReal sum = 0.0;
21265876a83SMatthew G. Knepley PetscInt d;
21365876a83SMatthew G. Knepley
21465876a83SMatthew G. Knepley for (d = 0; d < dim; ++d) sum += x[d];
21565876a83SMatthew G. Knepley u[0] = sum * PetscCosReal(time);
2163ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
21765876a83SMatthew G. Knepley }
21865876a83SMatthew G. Knepley
linear_trig_p_t(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)219*2a8381b2SBarry Smith static PetscErrorCode linear_trig_p_t(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
220d71ae5a4SJacob Faibussowitsch {
22165876a83SMatthew G. Knepley PetscReal sum = 0.0;
22265876a83SMatthew G. Knepley PetscInt d;
22365876a83SMatthew G. Knepley
22465876a83SMatthew G. Knepley for (d = 0; d < dim; ++d) sum += x[d];
22565876a83SMatthew G. Knepley u[0] = -sum * PetscSinReal(time);
2263ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
22765876a83SMatthew G. Knepley }
22865876a83SMatthew G. Knepley
f0_quadratic_trig_u(PetscInt dim,PetscInt Nf,PetscInt NfAux,const PetscInt uOff[],const PetscInt uOff_x[],const PetscScalar u[],const PetscScalar u_t[],const PetscScalar u_x[],const PetscInt aOff[],const PetscInt aOff_x[],const PetscScalar a[],const PetscScalar a_t[],const PetscScalar a_x[],PetscReal t,const PetscReal x[],PetscInt numConstants,const PetscScalar constants[],PetscScalar f0[])229d71ae5a4SJacob Faibussowitsch static void f0_quadratic_trig_u(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
230d71ae5a4SJacob Faibussowitsch {
23165876a83SMatthew G. Knepley const PetscReal G = PetscRealPart(constants[0]);
23265876a83SMatthew G. Knepley const PetscReal K_u = PetscRealPart(constants[1]);
23365876a83SMatthew G. Knepley const PetscReal alpha = PetscRealPart(constants[2]);
23465876a83SMatthew G. Knepley const PetscReal M = PetscRealPart(constants[3]);
23565876a83SMatthew G. Knepley const PetscReal K_d = K_u - alpha * alpha * M;
23665876a83SMatthew G. Knepley const PetscReal lambda = K_d - (2.0 * G) / 3.0;
23765876a83SMatthew G. Knepley PetscInt d;
23865876a83SMatthew G. Knepley
239ad540459SPierre Jolivet for (d = 0; d < dim - 1; ++d) f0[d] -= 2.0 * G - alpha * PetscCosReal(t);
24065876a83SMatthew G. Knepley f0[dim - 1] -= 2.0 * lambda + 4.0 * G - alpha * PetscCosReal(t);
24165876a83SMatthew G. Knepley }
24265876a83SMatthew G. Knepley
f0_quadratic_trig_p(PetscInt dim,PetscInt Nf,PetscInt NfAux,const PetscInt uOff[],const PetscInt uOff_x[],const PetscScalar u[],const PetscScalar u_t[],const PetscScalar u_x[],const PetscInt aOff[],const PetscInt aOff_x[],const PetscScalar a[],const PetscScalar a_t[],const PetscScalar a_x[],PetscReal t,const PetscReal x[],PetscInt numConstants,const PetscScalar constants[],PetscScalar f0[])243d71ae5a4SJacob Faibussowitsch static void f0_quadratic_trig_p(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
244d71ae5a4SJacob Faibussowitsch {
24565876a83SMatthew G. Knepley const PetscReal alpha = PetscRealPart(constants[2]);
24665876a83SMatthew G. Knepley const PetscReal M = PetscRealPart(constants[3]);
24765876a83SMatthew G. Knepley PetscReal sum = 0.0;
24865876a83SMatthew G. Knepley PetscInt d;
24965876a83SMatthew G. Knepley
25065876a83SMatthew G. Knepley for (d = 0; d < dim; ++d) sum += x[d];
25165876a83SMatthew G. Knepley
25265876a83SMatthew G. Knepley f0[0] += u_t ? alpha * u_t[uOff[1]] : 0.0;
25365876a83SMatthew G. Knepley f0[0] += u_t ? u_t[uOff[2]] / M : 0.0;
25465876a83SMatthew G. Knepley f0[0] += PetscSinReal(t) * sum / M;
25565876a83SMatthew G. Knepley }
25665876a83SMatthew G. Knepley
25765876a83SMatthew G. Knepley /* Trigonometric space and linear time solution
25865876a83SMatthew G. Knepley
25965876a83SMatthew G. Knepley u = sin(2 pi x)
26065876a83SMatthew G. Knepley v = sin(2 pi y) - 2xy
26165876a83SMatthew G. Knepley \varepsilon = / 2 pi cos(2 pi x) -y \
26265876a83SMatthew G. Knepley \ -y 2 pi cos(2 pi y) - 2x /
26365876a83SMatthew G. Knepley Tr(\varepsilon) = div u = 2 pi (cos(2 pi x) + cos(2 pi y)) - 2 x
26465876a83SMatthew G. Knepley div \sigma = \partial_i \lambda \delta_{ij} \varepsilon_{kk} + \partial_i 2\mu\varepsilon_{ij}
26565876a83SMatthew G. Knepley = \lambda \partial_j 2 pi (cos(2 pi x) + cos(2 pi y)) + 2\mu < -4 pi^2 sin(2 pi x) - 1, -4 pi^2 sin(2 pi y) >
26665876a83SMatthew G. Knepley = \lambda < -4 pi^2 sin(2 pi x) - 2, -4 pi^2 sin(2 pi y) > + \mu < -8 pi^2 sin(2 pi x) - 2, -8 pi^2 sin(2 pi y) >
26765876a83SMatthew G. Knepley
26865876a83SMatthew G. Knepley 2D:
26965876a83SMatthew G. Knepley u = sin(2 pi x)
27065876a83SMatthew G. Knepley v = sin(2 pi y) - 2xy
27165876a83SMatthew G. Knepley p = (cos(2 pi x) + cos(2 pi y)) t
27265876a83SMatthew G. Knepley e = 2 pi (cos(2 pi x) + cos(2 pi y)) - 2 x
27365876a83SMatthew G. Knepley f = < -4 pi^2 sin(2 pi x) (2 G + lambda) - (2 G - 2 lambda), -4 pi^2 sin(2 pi y) (2G + lambda) > + 2 pi alpha t <sin(2 pi x), sin(2 pi y)>
27465876a83SMatthew G. Knepley g = 0
27565876a83SMatthew G. Knepley \varepsilon = / 2 pi cos(2 pi x) -y \
27665876a83SMatthew G. Knepley \ -y 2 pi cos(2 pi y) - 2x /
27765876a83SMatthew G. Knepley Tr(\varepsilon) = div u = 2 pi (cos(2 pi x) + cos(2 pi y)) - 2 x
27865876a83SMatthew G. Knepley div \sigma = \partial_i 2 G \epsilon_{ij} + \partial_i \lambda \varepsilon \delta_{ij} - \partial_i \alpha p \delta_{ij}
27965876a83SMatthew G. Knepley = 2 G < -4 pi^2 sin(2 pi x) - 1, -4 pi^2 sin(2 pi y) > + \lambda <-4 pi^2 sin(2 pi x) - 2, -4 pi^2 sin(2 pi y)> - alpha <-2 pi sin(2 pi x) t, -2 pi sin(2 pi y) t>
28065876a83SMatthew G. Knepley = < -4 pi^2 sin(2 pi x) (2 G + lambda) - (2 G + 2 lambda), -4 pi^2 sin(2 pi y) (2G + lambda) > + 2 pi alpha t <sin(2 pi x), sin(2 pi y)>
28165876a83SMatthew G. Knepley \frac{1}{M} \frac{dp}{dt} + \alpha \frac{d\varepsilon}{dt} - \nabla \cdot \kappa \nabla p
28265876a83SMatthew G. Knepley = \frac{1}{M} \frac{dp}{dt} + \kappa \Delta p
28365876a83SMatthew G. Knepley = (cos(2 pi x) + cos(2 pi y))/M - 4 pi^2 \kappa (cos(2 pi x) + cos(2 pi y)) t
28465876a83SMatthew G. Knepley
28565876a83SMatthew G. Knepley 3D:
28665876a83SMatthew G. Knepley u = sin(2 pi x)
28765876a83SMatthew G. Knepley v = sin(2 pi y) - 2xy
28865876a83SMatthew G. Knepley v = sin(2 pi y) - 2yz
28965876a83SMatthew G. Knepley p = (cos(2 pi x) + cos(2 pi y) + cos(2 pi z)) t
29065876a83SMatthew G. Knepley e = 2 pi (cos(2 pi x) + cos(2 pi y) + cos(2 pi z)) - 2 x - 2y
29165876a83SMatthew G. Knepley f = < -4 pi^2 sin(2 pi x) (2 G + lambda) - (2 G + 2 lambda), -4 pi^2 sin(2 pi y) (2 G + lambda) - (2 G + 2 lambda), -4 pi^2 sin(2 pi z) (2G + lambda) > + 2 pi alpha t <sin(2 pi x), sin(2 pi y), , sin(2 pi z)>
29265876a83SMatthew G. Knepley g = 0
29365876a83SMatthew G. Knepley \varepsilon = / 2 pi cos(2 pi x) -y 0 \
29465876a83SMatthew G. Knepley | -y 2 pi cos(2 pi y) - 2x -z |
29565876a83SMatthew G. Knepley \ 0 -z 2 pi cos(2 pi z) - 2y /
29665876a83SMatthew G. Knepley Tr(\varepsilon) = div u = 2 pi (cos(2 pi x) + cos(2 pi y) + cos(2 pi z)) - 2 x - 2 y
29765876a83SMatthew G. Knepley div \sigma = \partial_i 2 G \epsilon_{ij} + \partial_i \lambda \varepsilon \delta_{ij} - \partial_i \alpha p \delta_{ij}
29865876a83SMatthew G. Knepley = 2 G < -4 pi^2 sin(2 pi x) - 1, -4 pi^2 sin(2 pi y) - 1, -4 pi^2 sin(2 pi z) > + \lambda <-4 pi^2 sin(2 pi x) - 2, 4 pi^2 sin(2 pi y) - 2, -4 pi^2 sin(2 pi y)> - alpha <-2 pi sin(2 pi x) t, -2 pi sin(2 pi y) t, -2 pi sin(2 pi z) t>
29965876a83SMatthew G. Knepley = < -4 pi^2 sin(2 pi x) (2 G + lambda) - (2 G + 2 lambda), -4 pi^2 sin(2 pi y) (2 G + lambda) - (2 G + 2 lambda), -4 pi^2 sin(2 pi z) (2G + lambda) > + 2 pi alpha t <sin(2 pi x), sin(2 pi y), , sin(2 pi z)>
30065876a83SMatthew G. Knepley \frac{1}{M} \frac{dp}{dt} + \alpha \frac{d\varepsilon}{dt} - \nabla \cdot \kappa \nabla p
30165876a83SMatthew G. Knepley = \frac{1}{M} \frac{dp}{dt} + \kappa \Delta p
30265876a83SMatthew G. Knepley = (cos(2 pi x) + cos(2 pi y) + cos(2 pi z))/M - 4 pi^2 \kappa (cos(2 pi x) + cos(2 pi y) + cos(2 pi z)) t
30365876a83SMatthew G. Knepley */
trig_u(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)304*2a8381b2SBarry Smith static PetscErrorCode trig_u(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
305d71ae5a4SJacob Faibussowitsch {
30665876a83SMatthew G. Knepley PetscInt d;
30765876a83SMatthew G. Knepley
308ad540459SPierre Jolivet for (d = 0; d < dim; ++d) u[d] = PetscSinReal(2. * PETSC_PI * x[d]) - (d > 0 ? 2.0 * x[d - 1] * x[d] : 0.0);
3093ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
31065876a83SMatthew G. Knepley }
31165876a83SMatthew G. Knepley
trig_eps(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)312*2a8381b2SBarry Smith static PetscErrorCode trig_eps(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
313d71ae5a4SJacob Faibussowitsch {
31465876a83SMatthew G. Knepley PetscReal sum = 0.0;
31565876a83SMatthew G. Knepley PetscInt d;
31665876a83SMatthew G. Knepley
31765876a83SMatthew G. Knepley for (d = 0; d < dim; ++d) sum += 2. * PETSC_PI * PetscCosReal(2. * PETSC_PI * x[d]) - (d < dim - 1 ? 2. * x[d] : 0.0);
31865876a83SMatthew G. Knepley u[0] = sum;
3193ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
32065876a83SMatthew G. Knepley }
32165876a83SMatthew G. Knepley
trig_linear_p(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)322*2a8381b2SBarry Smith static PetscErrorCode trig_linear_p(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
323d71ae5a4SJacob Faibussowitsch {
32465876a83SMatthew G. Knepley PetscReal sum = 0.0;
32565876a83SMatthew G. Knepley PetscInt d;
32665876a83SMatthew G. Knepley
32765876a83SMatthew G. Knepley for (d = 0; d < dim; ++d) sum += PetscCosReal(2. * PETSC_PI * x[d]);
32865876a83SMatthew G. Knepley u[0] = sum * time;
3293ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
33065876a83SMatthew G. Knepley }
33165876a83SMatthew G. Knepley
trig_linear_p_t(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)332*2a8381b2SBarry Smith static PetscErrorCode trig_linear_p_t(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
333d71ae5a4SJacob Faibussowitsch {
33465876a83SMatthew G. Knepley PetscReal sum = 0.0;
33565876a83SMatthew G. Knepley PetscInt d;
33665876a83SMatthew G. Knepley
33765876a83SMatthew G. Knepley for (d = 0; d < dim; ++d) sum += PetscCosReal(2. * PETSC_PI * x[d]);
33865876a83SMatthew G. Knepley u[0] = sum;
3393ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
34065876a83SMatthew G. Knepley }
34165876a83SMatthew G. Knepley
f0_trig_linear_u(PetscInt dim,PetscInt Nf,PetscInt NfAux,const PetscInt uOff[],const PetscInt uOff_x[],const PetscScalar u[],const PetscScalar u_t[],const PetscScalar u_x[],const PetscInt aOff[],const PetscInt aOff_x[],const PetscScalar a[],const PetscScalar a_t[],const PetscScalar a_x[],PetscReal t,const PetscReal x[],PetscInt numConstants,const PetscScalar constants[],PetscScalar f0[])342d71ae5a4SJacob Faibussowitsch static void f0_trig_linear_u(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
343d71ae5a4SJacob Faibussowitsch {
34465876a83SMatthew G. Knepley const PetscReal G = PetscRealPart(constants[0]);
34565876a83SMatthew G. Knepley const PetscReal K_u = PetscRealPart(constants[1]);
34665876a83SMatthew G. Knepley const PetscReal alpha = PetscRealPart(constants[2]);
34765876a83SMatthew G. Knepley const PetscReal M = PetscRealPart(constants[3]);
34865876a83SMatthew G. Knepley const PetscReal K_d = K_u - alpha * alpha * M;
34965876a83SMatthew G. Knepley const PetscReal lambda = K_d - (2.0 * G) / 3.0;
35065876a83SMatthew G. Knepley PetscInt d;
35165876a83SMatthew G. Knepley
352ad540459SPierre Jolivet for (d = 0; d < dim - 1; ++d) f0[d] += PetscSqr(2. * PETSC_PI) * PetscSinReal(2. * PETSC_PI * x[d]) * (2. * G + lambda) + 2.0 * (G + lambda) - 2. * PETSC_PI * alpha * PetscSinReal(2. * PETSC_PI * x[d]) * t;
35365876a83SMatthew G. Knepley f0[dim - 1] += PetscSqr(2. * PETSC_PI) * PetscSinReal(2. * PETSC_PI * x[dim - 1]) * (2. * G + lambda) - 2. * PETSC_PI * alpha * PetscSinReal(2. * PETSC_PI * x[dim - 1]) * t;
35465876a83SMatthew G. Knepley }
35565876a83SMatthew G. Knepley
f0_trig_linear_p(PetscInt dim,PetscInt Nf,PetscInt NfAux,const PetscInt uOff[],const PetscInt uOff_x[],const PetscScalar u[],const PetscScalar u_t[],const PetscScalar u_x[],const PetscInt aOff[],const PetscInt aOff_x[],const PetscScalar a[],const PetscScalar a_t[],const PetscScalar a_x[],PetscReal t,const PetscReal x[],PetscInt numConstants,const PetscScalar constants[],PetscScalar f0[])356d71ae5a4SJacob Faibussowitsch static void f0_trig_linear_p(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
357d71ae5a4SJacob Faibussowitsch {
35865876a83SMatthew G. Knepley const PetscReal alpha = PetscRealPart(constants[2]);
35965876a83SMatthew G. Knepley const PetscReal M = PetscRealPart(constants[3]);
36065876a83SMatthew G. Knepley const PetscReal kappa = PetscRealPart(constants[4]);
36165876a83SMatthew G. Knepley PetscReal sum = 0.0;
36265876a83SMatthew G. Knepley PetscInt d;
36365876a83SMatthew G. Knepley
36465876a83SMatthew G. Knepley for (d = 0; d < dim; ++d) sum += PetscCosReal(2. * PETSC_PI * x[d]);
36565876a83SMatthew G. Knepley f0[0] += u_t ? alpha * u_t[uOff[1]] : 0.0;
36665876a83SMatthew G. Knepley f0[0] += u_t ? u_t[uOff[2]] / M : 0.0;
36765876a83SMatthew G. Knepley f0[0] -= sum / M - 4 * PetscSqr(PETSC_PI) * kappa * sum * t;
36865876a83SMatthew G. Knepley }
36965876a83SMatthew G. Knepley
37065876a83SMatthew G. Knepley /* Terzaghi Solutions */
37165876a83SMatthew G. Knepley /* The analytical solutions given here are drawn from chapter 7, section 3, */
37265876a83SMatthew G. Knepley /* "One-Dimensional Consolidation Problem," from Poroelasticity, by Cheng. */
terzaghi_drainage_pressure(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)373*2a8381b2SBarry Smith static PetscErrorCode terzaghi_drainage_pressure(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
374d71ae5a4SJacob Faibussowitsch {
37565876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
37665876a83SMatthew G. Knepley Parameter *param;
37765876a83SMatthew G. Knepley
378*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
37965876a83SMatthew G. Knepley if (time <= 0.0) {
38065876a83SMatthew G. Knepley PetscScalar alpha = param->alpha; /* - */
38165876a83SMatthew G. Knepley PetscScalar K_u = param->K_u; /* Pa */
38265876a83SMatthew G. Knepley PetscScalar M = param->M; /* Pa */
38365876a83SMatthew G. Knepley PetscScalar G = param->mu; /* Pa */
38465876a83SMatthew G. Knepley PetscScalar P_0 = param->P_0; /* Pa */
38565876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M; /* Pa, Cheng (B.5) */
38665876a83SMatthew G. Knepley PetscScalar eta = (3.0 * alpha * G) / (3.0 * K_d + 4.0 * G); /* -, Cheng (B.11) */
38765876a83SMatthew G. Knepley PetscScalar S = (3.0 * K_u + 4.0 * G) / (M * (3.0 * K_d + 4.0 * G)); /* Pa^{-1}, Cheng (B.14) */
38865876a83SMatthew G. Knepley
38965876a83SMatthew G. Knepley u[0] = ((P_0 * eta) / (G * S));
39065876a83SMatthew G. Knepley } else {
39165876a83SMatthew G. Knepley u[0] = 0.0;
39265876a83SMatthew G. Knepley }
3933ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
39465876a83SMatthew G. Knepley }
39565876a83SMatthew G. Knepley
terzaghi_initial_u(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)396*2a8381b2SBarry Smith static PetscErrorCode terzaghi_initial_u(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
397d71ae5a4SJacob Faibussowitsch {
39865876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
39965876a83SMatthew G. Knepley Parameter *param;
40065876a83SMatthew G. Knepley
401*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
40265876a83SMatthew G. Knepley {
40365876a83SMatthew G. Knepley PetscScalar K_u = param->K_u; /* Pa */
40465876a83SMatthew G. Knepley PetscScalar G = param->mu; /* Pa */
40565876a83SMatthew G. Knepley PetscScalar P_0 = param->P_0; /* Pa */
40630602db0SMatthew G. Knepley PetscReal L = user->xmax[1] - user->xmin[1]; /* m */
40765876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G)); /* -, Cheng (B.9) */
40865876a83SMatthew G. Knepley PetscReal zstar = x[1] / L; /* - */
40965876a83SMatthew G. Knepley
41065876a83SMatthew G. Knepley u[0] = 0.0;
41165876a83SMatthew G. Knepley u[1] = ((P_0 * L * (1.0 - 2.0 * nu_u)) / (2.0 * G * (1.0 - nu_u))) * (1.0 - zstar);
41265876a83SMatthew G. Knepley }
4133ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
41465876a83SMatthew G. Knepley }
41565876a83SMatthew G. Knepley
terzaghi_initial_eps(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)416*2a8381b2SBarry Smith static PetscErrorCode terzaghi_initial_eps(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
417d71ae5a4SJacob Faibussowitsch {
41865876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
41965876a83SMatthew G. Knepley Parameter *param;
42065876a83SMatthew G. Knepley
421*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
42265876a83SMatthew G. Knepley {
42365876a83SMatthew G. Knepley PetscScalar K_u = param->K_u; /* Pa */
42465876a83SMatthew G. Knepley PetscScalar G = param->mu; /* Pa */
42565876a83SMatthew G. Knepley PetscScalar P_0 = param->P_0; /* Pa */
42665876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G)); /* -, Cheng (B.9) */
42765876a83SMatthew G. Knepley
42865876a83SMatthew G. Knepley u[0] = -(P_0 * (1.0 - 2.0 * nu_u)) / (2.0 * G * (1.0 - nu_u));
42965876a83SMatthew G. Knepley }
4303ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
43165876a83SMatthew G. Knepley }
43265876a83SMatthew G. Knepley
terzaghi_2d_u(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)433*2a8381b2SBarry Smith static PetscErrorCode terzaghi_2d_u(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
434d71ae5a4SJacob Faibussowitsch {
43565876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
43665876a83SMatthew G. Knepley Parameter *param;
43765876a83SMatthew G. Knepley
438*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
43965876a83SMatthew G. Knepley if (time < 0.0) {
4409566063dSJacob Faibussowitsch PetscCall(terzaghi_initial_u(dim, time, x, Nc, u, ctx));
44165876a83SMatthew G. Knepley } else {
44265876a83SMatthew G. Knepley PetscScalar alpha = param->alpha; /* - */
44365876a83SMatthew G. Knepley PetscScalar K_u = param->K_u; /* Pa */
44465876a83SMatthew G. Knepley PetscScalar M = param->M; /* Pa */
44565876a83SMatthew G. Knepley PetscScalar G = param->mu; /* Pa */
44665876a83SMatthew G. Knepley PetscScalar P_0 = param->P_0; /* Pa */
44765876a83SMatthew G. Knepley PetscScalar kappa = param->k / param->mu_f; /* m^2 / (Pa s) */
44830602db0SMatthew G. Knepley PetscReal L = user->xmax[1] - user->xmin[1]; /* m */
44965876a83SMatthew G. Knepley PetscInt N = user->niter, m;
45065876a83SMatthew G. Knepley
45165876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M; /* Pa, Cheng (B.5) */
45265876a83SMatthew G. Knepley PetscScalar nu = (3.0 * K_d - 2.0 * G) / (2.0 * (3.0 * K_d + G)); /* -, Cheng (B.8) */
45365876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G)); /* -, Cheng (B.9) */
45465876a83SMatthew G. Knepley PetscScalar S = (3.0 * K_u + 4.0 * G) / (M * (3.0 * K_d + 4.0 * G)); /* Pa^{-1}, Cheng (B.14) */
45565876a83SMatthew G. Knepley PetscScalar c = kappa / S; /* m^2 / s, Cheng (B.16) */
45665876a83SMatthew G. Knepley
45765876a83SMatthew G. Knepley PetscReal zstar = x[1] / L; /* - */
45865876a83SMatthew G. Knepley PetscReal tstar = PetscRealPart(c * time) / PetscSqr(2.0 * L); /* - */
45965876a83SMatthew G. Knepley PetscScalar F2 = 0.0;
46065876a83SMatthew G. Knepley
46165876a83SMatthew G. Knepley for (m = 1; m < 2 * N + 1; ++m) {
462ad540459SPierre Jolivet if (m % 2 == 1) F2 += (8.0 / PetscSqr(m * PETSC_PI)) * PetscCosReal(0.5 * m * PETSC_PI * zstar) * (1.0 - PetscExpReal(-PetscSqr(m * PETSC_PI) * tstar));
46365876a83SMatthew G. Knepley }
46465876a83SMatthew G. Knepley u[0] = 0.0;
46565876a83SMatthew G. Knepley u[1] = ((P_0 * L * (1.0 - 2.0 * nu_u)) / (2.0 * G * (1.0 - nu_u))) * (1.0 - zstar) + ((P_0 * L * (nu_u - nu)) / (2.0 * G * (1.0 - nu_u) * (1.0 - nu))) * F2; /* m */
46665876a83SMatthew G. Knepley }
4673ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
46865876a83SMatthew G. Knepley }
46965876a83SMatthew G. Knepley
terzaghi_2d_eps(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)470*2a8381b2SBarry Smith static PetscErrorCode terzaghi_2d_eps(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
471d71ae5a4SJacob Faibussowitsch {
47265876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
47365876a83SMatthew G. Knepley Parameter *param;
47465876a83SMatthew G. Knepley
475*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
47665876a83SMatthew G. Knepley if (time < 0.0) {
4779566063dSJacob Faibussowitsch PetscCall(terzaghi_initial_eps(dim, time, x, Nc, u, ctx));
47865876a83SMatthew G. Knepley } else {
47965876a83SMatthew G. Knepley PetscScalar alpha = param->alpha; /* - */
48065876a83SMatthew G. Knepley PetscScalar K_u = param->K_u; /* Pa */
48165876a83SMatthew G. Knepley PetscScalar M = param->M; /* Pa */
48265876a83SMatthew G. Knepley PetscScalar G = param->mu; /* Pa */
48365876a83SMatthew G. Knepley PetscScalar P_0 = param->P_0; /* Pa */
48465876a83SMatthew G. Knepley PetscScalar kappa = param->k / param->mu_f; /* m^2 / (Pa s) */
48530602db0SMatthew G. Knepley PetscReal L = user->xmax[1] - user->xmin[1]; /* m */
48665876a83SMatthew G. Knepley PetscInt N = user->niter, m;
48765876a83SMatthew G. Knepley
48865876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M; /* Pa, Cheng (B.5) */
48965876a83SMatthew G. Knepley PetscScalar nu = (3.0 * K_d - 2.0 * G) / (2.0 * (3.0 * K_d + G)); /* -, Cheng (B.8) */
49065876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G)); /* -, Cheng (B.9) */
49165876a83SMatthew G. Knepley PetscScalar S = (3.0 * K_u + 4.0 * G) / (M * (3.0 * K_d + 4.0 * G)); /* Pa^{-1}, Cheng (B.14) */
49265876a83SMatthew G. Knepley PetscScalar c = kappa / S; /* m^2 / s, Cheng (B.16) */
49365876a83SMatthew G. Knepley
49465876a83SMatthew G. Knepley PetscReal zstar = x[1] / L; /* - */
49565876a83SMatthew G. Knepley PetscReal tstar = PetscRealPart(c * time) / PetscSqr(2.0 * L); /* - */
49665876a83SMatthew G. Knepley PetscScalar F2_z = 0.0;
49765876a83SMatthew G. Knepley
49865876a83SMatthew G. Knepley for (m = 1; m < 2 * N + 1; ++m) {
499ad540459SPierre Jolivet if (m % 2 == 1) F2_z += (-4.0 / (m * PETSC_PI * L)) * PetscSinReal(0.5 * m * PETSC_PI * zstar) * (1.0 - PetscExpReal(-PetscSqr(m * PETSC_PI) * tstar));
50065876a83SMatthew G. Knepley }
50165876a83SMatthew G. Knepley u[0] = -((P_0 * L * (1.0 - 2.0 * nu_u)) / (2.0 * G * (1.0 - nu_u) * L)) + ((P_0 * L * (nu_u - nu)) / (2.0 * G * (1.0 - nu_u) * (1.0 - nu))) * F2_z; /* - */
50265876a83SMatthew G. Knepley }
5033ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
50465876a83SMatthew G. Knepley }
50565876a83SMatthew G. Knepley
50665876a83SMatthew G. Knepley // Pressure
terzaghi_2d_p(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)507*2a8381b2SBarry Smith static PetscErrorCode terzaghi_2d_p(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
508d71ae5a4SJacob Faibussowitsch {
50965876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
51065876a83SMatthew G. Knepley Parameter *param;
51165876a83SMatthew G. Knepley
512*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
51365876a83SMatthew G. Knepley if (time <= 0.0) {
5149566063dSJacob Faibussowitsch PetscCall(terzaghi_drainage_pressure(dim, time, x, Nc, u, ctx));
51565876a83SMatthew G. Knepley } else {
51665876a83SMatthew G. Knepley PetscScalar alpha = param->alpha; /* - */
51765876a83SMatthew G. Knepley PetscScalar K_u = param->K_u; /* Pa */
51865876a83SMatthew G. Knepley PetscScalar M = param->M; /* Pa */
51965876a83SMatthew G. Knepley PetscScalar G = param->mu; /* Pa */
52065876a83SMatthew G. Knepley PetscScalar P_0 = param->P_0; /* Pa */
52165876a83SMatthew G. Knepley PetscScalar kappa = param->k / param->mu_f; /* m^2 / (Pa s) */
52230602db0SMatthew G. Knepley PetscReal L = user->xmax[1] - user->xmin[1]; /* m */
52365876a83SMatthew G. Knepley PetscInt N = user->niter, m;
52465876a83SMatthew G. Knepley
52565876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M; /* Pa, Cheng (B.5) */
52665876a83SMatthew G. Knepley PetscScalar eta = (3.0 * alpha * G) / (3.0 * K_d + 4.0 * G); /* -, Cheng (B.11) */
52765876a83SMatthew G. Knepley PetscScalar S = (3.0 * K_u + 4.0 * G) / (M * (3.0 * K_d + 4.0 * G)); /* Pa^{-1}, Cheng (B.14) */
52865876a83SMatthew G. Knepley PetscScalar c = kappa / S; /* m^2 / s, Cheng (B.16) */
52965876a83SMatthew G. Knepley
53065876a83SMatthew G. Knepley PetscReal zstar = x[1] / L; /* - */
53165876a83SMatthew G. Knepley PetscReal tstar = PetscRealPart(c * time) / PetscSqr(2.0 * L); /* - */
53265876a83SMatthew G. Knepley PetscScalar F1 = 0.0;
53365876a83SMatthew G. Knepley
53463a3b9bcSJacob Faibussowitsch PetscCheck(PetscAbsScalar((1 / M + (alpha * eta) / G) - S) <= 1.0e-10, PETSC_COMM_SELF, PETSC_ERR_PLIB, "S %g != check %g", (double)PetscAbsScalar(S), (double)PetscAbsScalar(1 / M + (alpha * eta) / G));
53565876a83SMatthew G. Knepley
53665876a83SMatthew G. Knepley for (m = 1; m < 2 * N + 1; ++m) {
537ad540459SPierre Jolivet if (m % 2 == 1) F1 += (4.0 / (m * PETSC_PI)) * PetscSinReal(0.5 * m * PETSC_PI * zstar) * PetscExpReal(-PetscSqr(m * PETSC_PI) * tstar);
53865876a83SMatthew G. Knepley }
53965876a83SMatthew G. Knepley u[0] = ((P_0 * eta) / (G * S)) * F1; /* Pa */
54065876a83SMatthew G. Knepley }
5413ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
54265876a83SMatthew G. Knepley }
54365876a83SMatthew G. Knepley
terzaghi_2d_u_t(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)544*2a8381b2SBarry Smith static PetscErrorCode terzaghi_2d_u_t(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
545d71ae5a4SJacob Faibussowitsch {
54665876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
54765876a83SMatthew G. Knepley Parameter *param;
54865876a83SMatthew G. Knepley
549*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
55065876a83SMatthew G. Knepley if (time <= 0.0) {
55165876a83SMatthew G. Knepley u[0] = 0.0;
55265876a83SMatthew G. Knepley u[1] = 0.0;
55365876a83SMatthew G. Knepley } else {
55465876a83SMatthew G. Knepley PetscScalar alpha = param->alpha; /* - */
55565876a83SMatthew G. Knepley PetscScalar K_u = param->K_u; /* Pa */
55665876a83SMatthew G. Knepley PetscScalar M = param->M; /* Pa */
55765876a83SMatthew G. Knepley PetscScalar G = param->mu; /* Pa */
55865876a83SMatthew G. Knepley PetscScalar P_0 = param->P_0; /* Pa */
55965876a83SMatthew G. Knepley PetscScalar kappa = param->k / param->mu_f; /* m^2 / (Pa s) */
56030602db0SMatthew G. Knepley PetscReal L = user->xmax[1] - user->xmin[1]; /* m */
56165876a83SMatthew G. Knepley PetscInt N = user->niter, m;
56265876a83SMatthew G. Knepley
56365876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M; /* Pa, Cheng (B.5) */
56465876a83SMatthew G. Knepley PetscScalar nu = (3.0 * K_d - 2.0 * G) / (2.0 * (3.0 * K_d + G)); /* -, Cheng (B.8) */
56565876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G)); /* -, Cheng (B.9) */
56665876a83SMatthew G. Knepley PetscScalar S = (3.0 * K_u + 4.0 * G) / (M * (3.0 * K_d + 4.0 * G)); /* Pa^{-1}, Cheng (B.14) */
56765876a83SMatthew G. Knepley PetscScalar c = kappa / S; /* m^2 / s, Cheng (B.16) */
56865876a83SMatthew G. Knepley
56965876a83SMatthew G. Knepley PetscReal zstar = x[1] / L; /* - */
57065876a83SMatthew G. Knepley PetscReal tstar = PetscRealPart(c * time) / PetscSqr(2.0 * L); /* - */
57165876a83SMatthew G. Knepley PetscScalar F2_t = 0.0;
57265876a83SMatthew G. Knepley
57365876a83SMatthew G. Knepley for (m = 1; m < 2 * N + 1; ++m) {
574ad540459SPierre Jolivet if (m % 2 == 1) F2_t += (2.0 * c / PetscSqr(L)) * PetscCosReal(0.5 * m * PETSC_PI * zstar) * PetscExpReal(-PetscSqr(m * PETSC_PI) * tstar);
57565876a83SMatthew G. Knepley }
57665876a83SMatthew G. Knepley u[0] = 0.0;
57765876a83SMatthew G. Knepley u[1] = ((P_0 * L * (nu_u - nu)) / (2.0 * G * (1.0 - nu_u) * (1.0 - nu))) * F2_t; /* m / s */
57865876a83SMatthew G. Knepley }
5793ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
58065876a83SMatthew G. Knepley }
58165876a83SMatthew G. Knepley
terzaghi_2d_eps_t(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)582*2a8381b2SBarry Smith static PetscErrorCode terzaghi_2d_eps_t(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
583d71ae5a4SJacob Faibussowitsch {
58465876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
58565876a83SMatthew G. Knepley Parameter *param;
58665876a83SMatthew G. Knepley
587*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
58865876a83SMatthew G. Knepley if (time <= 0.0) {
58965876a83SMatthew G. Knepley u[0] = 0.0;
59065876a83SMatthew G. Knepley } else {
59165876a83SMatthew G. Knepley PetscScalar alpha = param->alpha; /* - */
59265876a83SMatthew G. Knepley PetscScalar K_u = param->K_u; /* Pa */
59365876a83SMatthew G. Knepley PetscScalar M = param->M; /* Pa */
59465876a83SMatthew G. Knepley PetscScalar G = param->mu; /* Pa */
59565876a83SMatthew G. Knepley PetscScalar P_0 = param->P_0; /* Pa */
59665876a83SMatthew G. Knepley PetscScalar kappa = param->k / param->mu_f; /* m^2 / (Pa s) */
59730602db0SMatthew G. Knepley PetscReal L = user->xmax[1] - user->xmin[1]; /* m */
59865876a83SMatthew G. Knepley PetscInt N = user->niter, m;
59965876a83SMatthew G. Knepley
60065876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M; /* Pa, Cheng (B.5) */
60165876a83SMatthew G. Knepley PetscScalar nu = (3.0 * K_d - 2.0 * G) / (2.0 * (3.0 * K_d + G)); /* -, Cheng (B.8) */
60265876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G)); /* -, Cheng (B.9) */
60365876a83SMatthew G. Knepley PetscScalar S = (3.0 * K_u + 4.0 * G) / (M * (3.0 * K_d + 4.0 * G)); /* Pa^{-1}, Cheng (B.14) */
60465876a83SMatthew G. Knepley PetscScalar c = kappa / S; /* m^2 / s, Cheng (B.16) */
60565876a83SMatthew G. Knepley
60665876a83SMatthew G. Knepley PetscReal zstar = x[1] / L; /* - */
60765876a83SMatthew G. Knepley PetscReal tstar = PetscRealPart(c * time) / PetscSqr(2.0 * L); /* - */
60865876a83SMatthew G. Knepley PetscScalar F2_zt = 0.0;
60965876a83SMatthew G. Knepley
61065876a83SMatthew G. Knepley for (m = 1; m < 2 * N + 1; ++m) {
611ad540459SPierre Jolivet if (m % 2 == 1) F2_zt += ((-m * PETSC_PI * c) / (L * L * L)) * PetscSinReal(0.5 * m * PETSC_PI * zstar) * PetscExpReal(-PetscSqr(m * PETSC_PI) * tstar);
61265876a83SMatthew G. Knepley }
61365876a83SMatthew G. Knepley u[0] = ((P_0 * L * (nu_u - nu)) / (2.0 * G * (1.0 - nu_u) * (1.0 - nu))) * F2_zt; /* 1 / s */
61465876a83SMatthew G. Knepley }
6153ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
61665876a83SMatthew G. Knepley }
61765876a83SMatthew G. Knepley
terzaghi_2d_p_t(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)618*2a8381b2SBarry Smith static PetscErrorCode terzaghi_2d_p_t(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
619d71ae5a4SJacob Faibussowitsch {
62065876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
62165876a83SMatthew G. Knepley Parameter *param;
62265876a83SMatthew G. Knepley
623*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
62465876a83SMatthew G. Knepley if (time <= 0.0) {
62565876a83SMatthew G. Knepley PetscScalar alpha = param->alpha; /* - */
62665876a83SMatthew G. Knepley PetscScalar K_u = param->K_u; /* Pa */
62765876a83SMatthew G. Knepley PetscScalar M = param->M; /* Pa */
62865876a83SMatthew G. Knepley PetscScalar G = param->mu; /* Pa */
62965876a83SMatthew G. Knepley PetscScalar P_0 = param->P_0; /* Pa */
63065876a83SMatthew G. Knepley PetscScalar kappa = param->k / param->mu_f; /* m^2 / (Pa s) */
63130602db0SMatthew G. Knepley PetscReal L = user->xmax[1] - user->xmin[1]; /* m */
63265876a83SMatthew G. Knepley
63365876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M; /* Pa, Cheng (B.5) */
63465876a83SMatthew G. Knepley PetscScalar eta = (3.0 * alpha * G) / (3.0 * K_d + 4.0 * G); /* -, Cheng (B.11) */
63565876a83SMatthew G. Knepley PetscScalar S = (3.0 * K_u + 4.0 * G) / (M * (3.0 * K_d + 4.0 * G)); /* Pa^{-1}, Cheng (B.14) */
63665876a83SMatthew G. Knepley PetscScalar c = kappa / S; /* m^2 / s, Cheng (B.16) */
63765876a83SMatthew G. Knepley
63865876a83SMatthew G. Knepley u[0] = -((P_0 * eta) / (G * S)) * PetscSqr(0 * PETSC_PI) * c / PetscSqr(2.0 * L); /* Pa / s */
63965876a83SMatthew G. Knepley } else {
64065876a83SMatthew G. Knepley PetscScalar alpha = param->alpha; /* - */
64165876a83SMatthew G. Knepley PetscScalar K_u = param->K_u; /* Pa */
64265876a83SMatthew G. Knepley PetscScalar M = param->M; /* Pa */
64365876a83SMatthew G. Knepley PetscScalar G = param->mu; /* Pa */
64465876a83SMatthew G. Knepley PetscScalar P_0 = param->P_0; /* Pa */
64565876a83SMatthew G. Knepley PetscScalar kappa = param->k / param->mu_f; /* m^2 / (Pa s) */
64630602db0SMatthew G. Knepley PetscReal L = user->xmax[1] - user->xmin[1]; /* m */
64765876a83SMatthew G. Knepley PetscInt N = user->niter, m;
64865876a83SMatthew G. Knepley
64965876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M; /* Pa, Cheng (B.5) */
65065876a83SMatthew G. Knepley PetscScalar eta = (3.0 * alpha * G) / (3.0 * K_d + 4.0 * G); /* -, Cheng (B.11) */
65165876a83SMatthew G. Knepley PetscScalar S = (3.0 * K_u + 4.0 * G) / (M * (3.0 * K_d + 4.0 * G)); /* Pa^{-1}, Cheng (B.14) */
65265876a83SMatthew G. Knepley PetscScalar c = kappa / S; /* m^2 / s, Cheng (B.16) */
65365876a83SMatthew G. Knepley
65465876a83SMatthew G. Knepley PetscReal zstar = x[1] / L; /* - */
65565876a83SMatthew G. Knepley PetscReal tstar = PetscRealPart(c * time) / PetscSqr(2.0 * L); /* - */
65665876a83SMatthew G. Knepley PetscScalar F1_t = 0.0;
65765876a83SMatthew G. Knepley
65863a3b9bcSJacob Faibussowitsch PetscCheck(PetscAbsScalar((1 / M + (alpha * eta) / G) - S) <= 1.0e-10, PETSC_COMM_SELF, PETSC_ERR_PLIB, "S %g != check %g", (double)PetscAbsScalar(S), (double)PetscAbsScalar(1 / M + (alpha * eta) / G));
65965876a83SMatthew G. Knepley
66065876a83SMatthew G. Knepley for (m = 1; m < 2 * N + 1; ++m) {
661ad540459SPierre Jolivet if (m % 2 == 1) F1_t += ((-m * PETSC_PI * c) / PetscSqr(L)) * PetscSinReal(0.5 * m * PETSC_PI * zstar) * PetscExpReal(-PetscSqr(m * PETSC_PI) * tstar);
66265876a83SMatthew G. Knepley }
66365876a83SMatthew G. Knepley u[0] = ((P_0 * eta) / (G * S)) * F1_t; /* Pa / s */
66465876a83SMatthew G. Knepley }
6653ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
66665876a83SMatthew G. Knepley }
66765876a83SMatthew G. Knepley
66865876a83SMatthew G. Knepley /* Mandel Solutions */
mandel_drainage_pressure(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)669*2a8381b2SBarry Smith static PetscErrorCode mandel_drainage_pressure(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
670d71ae5a4SJacob Faibussowitsch {
67165876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
67265876a83SMatthew G. Knepley Parameter *param;
67365876a83SMatthew G. Knepley
674*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
67565876a83SMatthew G. Knepley if (time <= 0.0) {
67665876a83SMatthew G. Knepley PetscScalar alpha = param->alpha; /* - */
67765876a83SMatthew G. Knepley PetscScalar K_u = param->K_u; /* Pa */
67865876a83SMatthew G. Knepley PetscScalar M = param->M; /* Pa */
67965876a83SMatthew G. Knepley PetscScalar G = param->mu; /* Pa */
68065876a83SMatthew G. Knepley PetscScalar P_0 = param->P_0; /* Pa */
68165876a83SMatthew G. Knepley PetscScalar kappa = param->k / param->mu_f; /* m^2 / (Pa s) */
68230602db0SMatthew G. Knepley PetscReal a = 0.5 * (user->xmax[0] - user->xmin[0]); /* m */
68365876a83SMatthew G. Knepley PetscInt N = user->niter, n;
68465876a83SMatthew G. Knepley
68565876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M; /* Pa, Cheng (B.5) */
68665876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G)); /* -, Cheng (B.9) */
68765876a83SMatthew G. Knepley PetscScalar B = alpha * M / K_u; /* -, Cheng (B.12) */
68865876a83SMatthew G. Knepley PetscScalar S = (3.0 * K_u + 4.0 * G) / (M * (3.0 * K_d + 4.0 * G)); /* Pa^{-1}, Cheng (B.14) */
68965876a83SMatthew G. Knepley PetscScalar c = kappa / S; /* m^2 / s, Cheng (B.16) */
69065876a83SMatthew G. Knepley
69165876a83SMatthew G. Knepley PetscScalar A1 = 3.0 / (B * (1.0 + nu_u));
69265876a83SMatthew G. Knepley PetscReal aa = 0.0;
69365876a83SMatthew G. Knepley PetscReal p = 0.0;
69465876a83SMatthew G. Knepley PetscReal time = 0.0;
69565876a83SMatthew G. Knepley
69665876a83SMatthew G. Knepley for (n = 1; n < N + 1; ++n) {
69765876a83SMatthew G. Knepley aa = user->zeroArray[n - 1];
69865876a83SMatthew G. Knepley p += (PetscSinReal(aa) / (aa - PetscSinReal(aa) * PetscCosReal(aa))) * (PetscCosReal((aa * x[0]) / a) - PetscCosReal(aa)) * PetscExpReal(-1.0 * (aa * aa * PetscRealPart(c) * time) / (a * a));
69965876a83SMatthew G. Knepley }
70065876a83SMatthew G. Knepley u[0] = ((2.0 * P_0) / (a * A1)) * p;
70165876a83SMatthew G. Knepley } else {
70265876a83SMatthew G. Knepley u[0] = 0.0;
70365876a83SMatthew G. Knepley }
7043ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
70565876a83SMatthew G. Knepley }
70665876a83SMatthew G. Knepley
mandel_initial_u(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)707*2a8381b2SBarry Smith static PetscErrorCode mandel_initial_u(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
708d71ae5a4SJacob Faibussowitsch {
70965876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
71065876a83SMatthew G. Knepley Parameter *param;
71165876a83SMatthew G. Knepley
712*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
71365876a83SMatthew G. Knepley {
71465876a83SMatthew G. Knepley PetscScalar alpha = param->alpha; /* - */
71565876a83SMatthew G. Knepley PetscScalar K_u = param->K_u; /* Pa */
71665876a83SMatthew G. Knepley PetscScalar M = param->M; /* Pa */
71765876a83SMatthew G. Knepley PetscScalar G = param->mu; /* Pa */
71865876a83SMatthew G. Knepley PetscScalar P_0 = param->P_0; /* Pa */
71965876a83SMatthew G. Knepley PetscScalar kappa = param->k / param->mu_f; /* m^2 / (Pa s) */
7209fa27a79SStefano Zampini PetscReal a = 0.5 * (user->xmax[0] - user->xmin[0]); /* m */
72165876a83SMatthew G. Knepley PetscInt N = user->niter, n;
72265876a83SMatthew G. Knepley
72365876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M; /* Pa, Cheng (B.5) */
72465876a83SMatthew G. Knepley PetscScalar nu = (3.0 * K_d - 2.0 * G) / (2.0 * (3.0 * K_d + G)); /* -, Cheng (B.8) */
72565876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G)); /* -, Cheng (B.9) */
72665876a83SMatthew G. Knepley PetscScalar S = (3.0 * K_u + 4.0 * G) / (M * (3.0 * K_d + 4.0 * G)); /* Pa^{-1}, Cheng (B.14) */
7279fa27a79SStefano Zampini PetscReal c = PetscRealPart(kappa / S); /* m^2 / s, Cheng (B.16) */
72865876a83SMatthew G. Knepley
7299fa27a79SStefano Zampini PetscReal A_s = 0.0;
7309fa27a79SStefano Zampini PetscReal B_s = 0.0;
73165876a83SMatthew G. Knepley for (n = 1; n < N + 1; ++n) {
7329fa27a79SStefano Zampini PetscReal alpha_n = user->zeroArray[n - 1];
73365876a83SMatthew G. Knepley A_s += ((PetscSinReal(alpha_n) * PetscCosReal(alpha_n)) / (alpha_n - PetscSinReal(alpha_n) * PetscCosReal(alpha_n))) * PetscExpReal(-1 * (alpha_n * alpha_n * c * time) / (a * a));
73465876a83SMatthew G. Knepley B_s += (PetscCosReal(alpha_n) / (alpha_n - PetscSinReal(alpha_n) * PetscCosReal(alpha_n))) * PetscSinReal((alpha_n * x[0]) / a) * PetscExpReal(-1 * (alpha_n * alpha_n * c * time) / (a * a));
73565876a83SMatthew G. Knepley }
73665876a83SMatthew G. Knepley u[0] = ((P_0 * nu) / (2.0 * G * a) - (P_0 * nu_u) / (G * a) * A_s) * x[0] + P_0 / G * B_s;
73765876a83SMatthew G. Knepley u[1] = (-1 * (P_0 * (1.0 - nu)) / (2 * G * a) + (P_0 * (1 - nu_u)) / (G * a) * A_s) * x[1];
73865876a83SMatthew G. Knepley }
7393ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
74065876a83SMatthew G. Knepley }
74165876a83SMatthew G. Knepley
mandel_initial_eps(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)742*2a8381b2SBarry Smith static PetscErrorCode mandel_initial_eps(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
743d71ae5a4SJacob Faibussowitsch {
74465876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
74565876a83SMatthew G. Knepley Parameter *param;
74665876a83SMatthew G. Knepley
747*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
74865876a83SMatthew G. Knepley {
74965876a83SMatthew G. Knepley PetscScalar alpha = param->alpha; /* - */
75065876a83SMatthew G. Knepley PetscScalar K_u = param->K_u; /* Pa */
75165876a83SMatthew G. Knepley PetscScalar M = param->M; /* Pa */
75265876a83SMatthew G. Knepley PetscScalar G = param->mu; /* Pa */
75365876a83SMatthew G. Knepley PetscScalar P_0 = param->P_0; /* Pa */
75465876a83SMatthew G. Knepley PetscScalar kappa = param->k / param->mu_f; /* m^2 / (Pa s) */
75530602db0SMatthew G. Knepley PetscReal a = 0.5 * (user->xmax[0] - user->xmin[0]); /* m */
75665876a83SMatthew G. Knepley PetscInt N = user->niter, n;
75765876a83SMatthew G. Knepley
75865876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M; /* Pa, Cheng (B.5) */
75965876a83SMatthew G. Knepley PetscScalar nu = (3.0 * K_d - 2.0 * G) / (2.0 * (3.0 * K_d + G)); /* -, Cheng (B.8) */
76065876a83SMatthew G. Knepley PetscScalar S = (3.0 * K_u + 4.0 * G) / (M * (3.0 * K_d + 4.0 * G)); /* Pa^{-1}, Cheng (B.14) */
76165876a83SMatthew G. Knepley PetscReal c = PetscRealPart(kappa / S); /* m^2 / s, Cheng (B.16) */
76265876a83SMatthew G. Knepley
76365876a83SMatthew G. Knepley PetscReal aa = 0.0;
76465876a83SMatthew G. Knepley PetscReal eps_A = 0.0;
76565876a83SMatthew G. Knepley PetscReal eps_B = 0.0;
76665876a83SMatthew G. Knepley PetscReal eps_C = 0.0;
76765876a83SMatthew G. Knepley PetscReal time = 0.0;
76865876a83SMatthew G. Knepley
76965876a83SMatthew G. Knepley for (n = 1; n < N + 1; ++n) {
77065876a83SMatthew G. Knepley aa = user->zeroArray[n - 1];
77165876a83SMatthew G. Knepley eps_A += (aa * PetscExpReal((-1.0 * aa * aa * c * time) / (a * a)) * PetscCosReal(aa) * PetscCosReal((aa * x[0]) / a)) / (a * (aa - PetscSinReal(aa) * PetscCosReal(aa)));
77265876a83SMatthew G. Knepley eps_B += (PetscExpReal((-1.0 * aa * aa * c * time) / (a * a)) * PetscSinReal(aa) * PetscCosReal(aa)) / (aa - PetscSinReal(aa) * PetscCosReal(aa));
77365876a83SMatthew G. Knepley eps_C += (PetscExpReal((-1.0 * aa * aa * c * time) / (aa * aa)) * PetscSinReal(aa) * PetscCosReal(aa)) / (aa - PetscSinReal(aa) * PetscCosReal(aa));
77465876a83SMatthew G. Knepley }
77565876a83SMatthew G. Knepley u[0] = (P_0 / G) * eps_A + ((P_0 * nu) / (2.0 * G * a)) - eps_B / (G * a) - (P_0 * (1 - nu)) / (2 * G * a) + eps_C / (G * a);
77665876a83SMatthew G. Knepley }
7773ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
77865876a83SMatthew G. Knepley }
77965876a83SMatthew G. Knepley
78065876a83SMatthew G. Knepley // Displacement
mandel_2d_u(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)781*2a8381b2SBarry Smith static PetscErrorCode mandel_2d_u(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
782d71ae5a4SJacob Faibussowitsch {
78365876a83SMatthew G. Knepley Parameter *param;
78465876a83SMatthew G. Knepley
78565876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
78665876a83SMatthew G. Knepley
787*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
78865876a83SMatthew G. Knepley if (time <= 0.0) {
7899566063dSJacob Faibussowitsch PetscCall(mandel_initial_u(dim, time, x, Nc, u, ctx));
79065876a83SMatthew G. Knepley } else {
79165876a83SMatthew G. Knepley PetscInt NITER = user->niter;
79265876a83SMatthew G. Knepley PetscScalar alpha = param->alpha;
79365876a83SMatthew G. Knepley PetscScalar K_u = param->K_u;
79465876a83SMatthew G. Knepley PetscScalar M = param->M;
79565876a83SMatthew G. Knepley PetscScalar G = param->mu;
79665876a83SMatthew G. Knepley PetscScalar k = param->k;
79765876a83SMatthew G. Knepley PetscScalar mu_f = param->mu_f;
79865876a83SMatthew G. Knepley PetscScalar F = param->P_0;
79965876a83SMatthew G. Knepley
80065876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M;
80165876a83SMatthew G. Knepley PetscScalar nu = (3.0 * K_d - 2.0 * G) / (2.0 * (3.0 * K_d + G));
80265876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G));
80365876a83SMatthew G. Knepley PetscScalar kappa = k / mu_f;
80430602db0SMatthew G. Knepley PetscReal a = (user->xmax[0] - user->xmin[0]) / 2.0;
80565876a83SMatthew G. Knepley PetscReal c = PetscRealPart(((2.0 * kappa * G) * (1.0 - nu) * (nu_u - nu)) / (alpha * alpha * (1.0 - 2.0 * nu) * (1.0 - nu_u)));
80665876a83SMatthew G. Knepley
80765876a83SMatthew G. Knepley // Series term
80865876a83SMatthew G. Knepley PetscScalar A_x = 0.0;
80965876a83SMatthew G. Knepley PetscScalar B_x = 0.0;
81065876a83SMatthew G. Knepley
81165876a83SMatthew G. Knepley for (PetscInt n = 1; n < NITER + 1; n++) {
81265876a83SMatthew G. Knepley PetscReal alpha_n = user->zeroArray[n - 1];
81365876a83SMatthew G. Knepley
81465876a83SMatthew G. Knepley A_x += ((PetscSinReal(alpha_n) * PetscCosReal(alpha_n)) / (alpha_n - PetscSinReal(alpha_n) * PetscCosReal(alpha_n))) * PetscExpReal(-1 * (alpha_n * alpha_n * c * time) / (a * a));
81565876a83SMatthew G. Knepley B_x += (PetscCosReal(alpha_n) / (alpha_n - PetscSinReal(alpha_n) * PetscCosReal(alpha_n))) * PetscSinReal((alpha_n * x[0]) / a) * PetscExpReal(-1 * (alpha_n * alpha_n * c * time) / (a * a));
81665876a83SMatthew G. Knepley }
81765876a83SMatthew G. Knepley u[0] = ((F * nu) / (2.0 * G * a) - (F * nu_u) / (G * a) * A_x) * x[0] + F / G * B_x;
81865876a83SMatthew G. Knepley u[1] = (-1 * (F * (1.0 - nu)) / (2 * G * a) + (F * (1 - nu_u)) / (G * a) * A_x) * x[1];
81965876a83SMatthew G. Knepley }
8203ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
82165876a83SMatthew G. Knepley }
82265876a83SMatthew G. Knepley
82365876a83SMatthew G. Knepley // Trace strain
mandel_2d_eps(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)824*2a8381b2SBarry Smith static PetscErrorCode mandel_2d_eps(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
825d71ae5a4SJacob Faibussowitsch {
82665876a83SMatthew G. Knepley Parameter *param;
82765876a83SMatthew G. Knepley
82865876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
82965876a83SMatthew G. Knepley
830*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
83165876a83SMatthew G. Knepley if (time <= 0.0) {
8329566063dSJacob Faibussowitsch PetscCall(mandel_initial_eps(dim, time, x, Nc, u, ctx));
83365876a83SMatthew G. Knepley } else {
83465876a83SMatthew G. Knepley PetscInt NITER = user->niter;
83565876a83SMatthew G. Knepley PetscScalar alpha = param->alpha;
83665876a83SMatthew G. Knepley PetscScalar K_u = param->K_u;
83765876a83SMatthew G. Knepley PetscScalar M = param->M;
83865876a83SMatthew G. Knepley PetscScalar G = param->mu;
83965876a83SMatthew G. Knepley PetscScalar k = param->k;
84065876a83SMatthew G. Knepley PetscScalar mu_f = param->mu_f;
84165876a83SMatthew G. Knepley PetscScalar F = param->P_0;
84265876a83SMatthew G. Knepley
84365876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M;
84465876a83SMatthew G. Knepley PetscScalar nu = (3.0 * K_d - 2.0 * G) / (2.0 * (3.0 * K_d + G));
84565876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G));
84665876a83SMatthew G. Knepley PetscScalar kappa = k / mu_f;
84765876a83SMatthew G. Knepley //const PetscScalar B = (alpha*M)/(K_d + alpha*alpha * M);
84865876a83SMatthew G. Knepley
84965876a83SMatthew G. Knepley //const PetscScalar b = (YMAX - YMIN) / 2.0;
8509fa27a79SStefano Zampini PetscReal a = (user->xmax[0] - user->xmin[0]) / 2.0;
85165876a83SMatthew G. Knepley PetscReal c = PetscRealPart(((2.0 * kappa * G) * (1.0 - nu) * (nu_u - nu)) / (alpha * alpha * (1.0 - 2.0 * nu) * (1.0 - nu_u)));
85265876a83SMatthew G. Knepley
85365876a83SMatthew G. Knepley // Series term
8549fa27a79SStefano Zampini PetscReal eps_A = 0.0;
8559fa27a79SStefano Zampini PetscReal eps_B = 0.0;
8569fa27a79SStefano Zampini PetscReal eps_C = 0.0;
85765876a83SMatthew G. Knepley
8589371c9d4SSatish Balay for (PetscInt n = 1; n < NITER + 1; n++) {
85965876a83SMatthew G. Knepley PetscReal aa = user->zeroArray[n - 1];
86065876a83SMatthew G. Knepley
86165876a83SMatthew G. Knepley eps_A += (aa * PetscExpReal((-1.0 * aa * aa * c * time) / (a * a)) * PetscCosReal(aa) * PetscCosReal((aa * x[0]) / a)) / (a * (aa - PetscSinReal(aa) * PetscCosReal(aa)));
86265876a83SMatthew G. Knepley
86365876a83SMatthew G. Knepley eps_B += (PetscExpReal((-1.0 * aa * aa * c * time) / (a * a)) * PetscSinReal(aa) * PetscCosReal(aa)) / (aa - PetscSinReal(aa) * PetscCosReal(aa));
86465876a83SMatthew G. Knepley
86565876a83SMatthew G. Knepley eps_C += (PetscExpReal((-1.0 * aa * aa * c * time) / (aa * aa)) * PetscSinReal(aa) * PetscCosReal(aa)) / (aa - PetscSinReal(aa) * PetscCosReal(aa));
86665876a83SMatthew G. Knepley }
86765876a83SMatthew G. Knepley
86865876a83SMatthew G. Knepley u[0] = (F / G) * eps_A + ((F * nu) / (2.0 * G * a)) - eps_B / (G * a) - (F * (1 - nu)) / (2 * G * a) + eps_C / (G * a);
86965876a83SMatthew G. Knepley }
8703ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
87165876a83SMatthew G. Knepley }
87265876a83SMatthew G. Knepley
87365876a83SMatthew G. Knepley // Pressure
mandel_2d_p(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)874*2a8381b2SBarry Smith static PetscErrorCode mandel_2d_p(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
875d71ae5a4SJacob Faibussowitsch {
87665876a83SMatthew G. Knepley Parameter *param;
87765876a83SMatthew G. Knepley
87865876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
87965876a83SMatthew G. Knepley
880*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
88165876a83SMatthew G. Knepley if (time <= 0.0) {
8829566063dSJacob Faibussowitsch PetscCall(mandel_drainage_pressure(dim, time, x, Nc, u, ctx));
88365876a83SMatthew G. Knepley } else {
88465876a83SMatthew G. Knepley PetscInt NITER = user->niter;
88565876a83SMatthew G. Knepley
88665876a83SMatthew G. Knepley PetscScalar alpha = param->alpha;
88765876a83SMatthew G. Knepley PetscScalar K_u = param->K_u;
88865876a83SMatthew G. Knepley PetscScalar M = param->M;
88965876a83SMatthew G. Knepley PetscScalar G = param->mu;
89065876a83SMatthew G. Knepley PetscScalar k = param->k;
89165876a83SMatthew G. Knepley PetscScalar mu_f = param->mu_f;
89265876a83SMatthew G. Knepley PetscScalar F = param->P_0;
89365876a83SMatthew G. Knepley
89465876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M;
89565876a83SMatthew G. Knepley PetscScalar nu = (3.0 * K_d - 2.0 * G) / (2.0 * (3.0 * K_d + G));
89665876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G));
89765876a83SMatthew G. Knepley PetscScalar kappa = k / mu_f;
89865876a83SMatthew G. Knepley PetscScalar B = (alpha * M) / (K_d + alpha * alpha * M);
89965876a83SMatthew G. Knepley
90030602db0SMatthew G. Knepley PetscReal a = (user->xmax[0] - user->xmin[0]) / 2.0;
90165876a83SMatthew G. Knepley PetscReal c = PetscRealPart(((2.0 * kappa * G) * (1.0 - nu) * (nu_u - nu)) / (alpha * alpha * (1.0 - 2.0 * nu) * (1.0 - nu_u)));
90265876a83SMatthew G. Knepley PetscScalar A1 = 3.0 / (B * (1.0 + nu_u));
90365876a83SMatthew G. Knepley //PetscScalar A2 = (alpha * (1.0 - 2.0*nu)) / (1.0 - nu);
90465876a83SMatthew G. Knepley
90565876a83SMatthew G. Knepley // Series term
9069fa27a79SStefano Zampini PetscReal p = 0.0;
90765876a83SMatthew G. Knepley
9089371c9d4SSatish Balay for (PetscInt n = 1; n < NITER + 1; n++) {
9099fa27a79SStefano Zampini PetscReal aa = user->zeroArray[n - 1];
91065876a83SMatthew G. Knepley p += (PetscSinReal(aa) / (aa - PetscSinReal(aa) * PetscCosReal(aa))) * (PetscCosReal((aa * x[0]) / a) - PetscCosReal(aa)) * PetscExpReal(-1.0 * (aa * aa * c * time) / (a * a));
91165876a83SMatthew G. Knepley }
91265876a83SMatthew G. Knepley u[0] = ((2.0 * F) / (a * A1)) * p;
91365876a83SMatthew G. Knepley }
9143ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
91565876a83SMatthew G. Knepley }
91665876a83SMatthew G. Knepley
91765876a83SMatthew G. Knepley // Time derivative of displacement
mandel_2d_u_t(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)918*2a8381b2SBarry Smith static PetscErrorCode mandel_2d_u_t(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
919d71ae5a4SJacob Faibussowitsch {
92065876a83SMatthew G. Knepley Parameter *param;
92165876a83SMatthew G. Knepley
92265876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
92365876a83SMatthew G. Knepley
924*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
92565876a83SMatthew G. Knepley
92665876a83SMatthew G. Knepley PetscInt NITER = user->niter;
92765876a83SMatthew G. Knepley PetscScalar alpha = param->alpha;
92865876a83SMatthew G. Knepley PetscScalar K_u = param->K_u;
92965876a83SMatthew G. Knepley PetscScalar M = param->M;
93065876a83SMatthew G. Knepley PetscScalar G = param->mu;
93165876a83SMatthew G. Knepley PetscScalar F = param->P_0;
93265876a83SMatthew G. Knepley
93365876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M;
93465876a83SMatthew G. Knepley PetscScalar nu = (3.0 * K_d - 2.0 * G) / (2.0 * (3.0 * K_d + G));
93565876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G));
93665876a83SMatthew G. Knepley PetscScalar kappa = param->k / param->mu_f;
93730602db0SMatthew G. Knepley PetscReal a = (user->xmax[0] - user->xmin[0]) / 2.0;
93865876a83SMatthew G. Knepley PetscReal c = PetscRealPart(((2.0 * kappa * G) * (1.0 - nu) * (nu_u - nu)) / (alpha * alpha * (1.0 - 2.0 * nu) * (1.0 - nu_u)));
93965876a83SMatthew G. Knepley
94065876a83SMatthew G. Knepley // Series term
94165876a83SMatthew G. Knepley PetscScalar A_s_t = 0.0;
94265876a83SMatthew G. Knepley PetscScalar B_s_t = 0.0;
94365876a83SMatthew G. Knepley
9449371c9d4SSatish Balay for (PetscInt n = 1; n < NITER + 1; n++) {
94565876a83SMatthew G. Knepley PetscReal alpha_n = user->zeroArray[n - 1];
94665876a83SMatthew G. Knepley
94765876a83SMatthew G. Knepley A_s_t += (-1.0 * alpha_n * alpha_n * c * PetscExpReal((-1.0 * alpha_n * alpha_n * time) / (a * a)) * PetscSinReal((alpha_n * x[0]) / a) * PetscCosReal(alpha_n)) / (a * a * (alpha_n - PetscSinReal(alpha_n) * PetscCosReal(alpha_n)));
94865876a83SMatthew G. Knepley B_s_t += (-1.0 * alpha_n * alpha_n * c * PetscExpReal((-1.0 * alpha_n * alpha_n * time) / (a * a)) * PetscSinReal(alpha_n) * PetscCosReal(alpha_n)) / (a * a * (alpha_n - PetscSinReal(alpha_n) * PetscCosReal(alpha_n)));
94965876a83SMatthew G. Knepley }
95065876a83SMatthew G. Knepley
95165876a83SMatthew G. Knepley u[0] = (F / G) * A_s_t - ((F * nu_u * x[0]) / (G * a)) * B_s_t;
95265876a83SMatthew G. Knepley u[1] = ((F * x[1] * (1 - nu_u)) / (G * a)) * B_s_t;
95365876a83SMatthew G. Knepley
9543ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
95565876a83SMatthew G. Knepley }
95665876a83SMatthew G. Knepley
95765876a83SMatthew G. Knepley // Time derivative of trace strain
mandel_2d_eps_t(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)958*2a8381b2SBarry Smith static PetscErrorCode mandel_2d_eps_t(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
959d71ae5a4SJacob Faibussowitsch {
96065876a83SMatthew G. Knepley Parameter *param;
96165876a83SMatthew G. Knepley
96265876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
96365876a83SMatthew G. Knepley
964*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
96565876a83SMatthew G. Knepley
96665876a83SMatthew G. Knepley PetscInt NITER = user->niter;
96765876a83SMatthew G. Knepley PetscScalar alpha = param->alpha;
96865876a83SMatthew G. Knepley PetscScalar K_u = param->K_u;
96965876a83SMatthew G. Knepley PetscScalar M = param->M;
97065876a83SMatthew G. Knepley PetscScalar G = param->mu;
97165876a83SMatthew G. Knepley PetscScalar k = param->k;
97265876a83SMatthew G. Knepley PetscScalar mu_f = param->mu_f;
97365876a83SMatthew G. Knepley PetscScalar F = param->P_0;
97465876a83SMatthew G. Knepley
97565876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M;
97665876a83SMatthew G. Knepley PetscScalar nu = (3.0 * K_d - 2.0 * G) / (2.0 * (3.0 * K_d + G));
97765876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G));
97865876a83SMatthew G. Knepley PetscScalar kappa = k / mu_f;
97965876a83SMatthew G. Knepley //const PetscScalar B = (alpha*M)/(K_d + alpha*alpha * M);
98065876a83SMatthew G. Knepley
98165876a83SMatthew G. Knepley //const PetscScalar b = (YMAX - YMIN) / 2.0;
98230602db0SMatthew G. Knepley PetscReal a = (user->xmax[0] - user->xmin[0]) / 2.0;
98365876a83SMatthew G. Knepley PetscReal c = PetscRealPart(((2.0 * kappa * G) * (1.0 - nu) * (nu_u - nu)) / (alpha * alpha * (1.0 - 2.0 * nu) * (1.0 - nu_u)));
98465876a83SMatthew G. Knepley
98565876a83SMatthew G. Knepley // Series term
98665876a83SMatthew G. Knepley PetscScalar eps_As = 0.0;
98765876a83SMatthew G. Knepley PetscScalar eps_Bs = 0.0;
98865876a83SMatthew G. Knepley PetscScalar eps_Cs = 0.0;
98965876a83SMatthew G. Knepley
9909371c9d4SSatish Balay for (PetscInt n = 1; n < NITER + 1; n++) {
99165876a83SMatthew G. Knepley PetscReal alpha_n = user->zeroArray[n - 1];
99265876a83SMatthew G. Knepley
99365876a83SMatthew G. Knepley eps_As += (-1.0 * alpha_n * alpha_n * alpha_n * c * PetscExpReal((-1.0 * alpha_n * alpha_n * c * time) / (a * a)) * PetscCosReal(alpha_n) * PetscCosReal((alpha_n * x[0]) / a)) / (alpha_n * alpha_n * alpha_n * (alpha_n - PetscSinReal(alpha_n) * PetscCosReal(alpha_n)));
99465876a83SMatthew G. Knepley eps_Bs += (-1.0 * alpha_n * alpha_n * c * PetscExpReal((-1.0 * alpha_n * alpha_n * c * time) / (a * a)) * PetscSinReal(alpha_n) * PetscCosReal(alpha_n)) / (alpha_n * alpha_n * (alpha_n - PetscSinReal(alpha_n) * PetscCosReal(alpha_n)));
99565876a83SMatthew G. Knepley eps_Cs += (-1.0 * alpha_n * alpha_n * c * PetscExpReal((-1.0 * alpha_n * alpha_n * c * time) / (a * a)) * PetscSinReal(alpha_n) * PetscCosReal(alpha_n)) / (alpha_n * alpha_n * (alpha_n - PetscSinReal(alpha_n) * PetscCosReal(alpha_n)));
99665876a83SMatthew G. Knepley }
99765876a83SMatthew G. Knepley
99865876a83SMatthew G. Knepley u[0] = (F / G) * eps_As - ((F * nu_u) / (G * a)) * eps_Bs + ((F * (1 - nu_u)) / (G * a)) * eps_Cs;
9993ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
100065876a83SMatthew G. Knepley }
100165876a83SMatthew G. Knepley
100265876a83SMatthew G. Knepley // Time derivative of pressure
mandel_2d_p_t(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)1003*2a8381b2SBarry Smith static PetscErrorCode mandel_2d_p_t(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
1004d71ae5a4SJacob Faibussowitsch {
100565876a83SMatthew G. Knepley Parameter *param;
100665876a83SMatthew G. Knepley
100765876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
100865876a83SMatthew G. Knepley
1009*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
101065876a83SMatthew G. Knepley
101165876a83SMatthew G. Knepley PetscScalar alpha = param->alpha;
101265876a83SMatthew G. Knepley PetscScalar K_u = param->K_u;
101365876a83SMatthew G. Knepley PetscScalar M = param->M;
101465876a83SMatthew G. Knepley PetscScalar G = param->mu;
101565876a83SMatthew G. Knepley PetscScalar F = param->P_0;
101665876a83SMatthew G. Knepley
101765876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M;
101865876a83SMatthew G. Knepley PetscScalar nu = (3.0 * K_d - 2.0 * G) / (2.0 * (3.0 * K_d + G));
101965876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G));
102065876a83SMatthew G. Knepley
102130602db0SMatthew G. Knepley PetscReal a = (user->xmax[0] - user->xmin[0]) / 2.0;
102265876a83SMatthew G. Knepley //PetscScalar A1 = 3.0 / (B * (1.0 + nu_u));
102365876a83SMatthew G. Knepley //PetscScalar A2 = (alpha * (1.0 - 2.0*nu)) / (1.0 - nu);
102465876a83SMatthew G. Knepley
102565876a83SMatthew G. Knepley u[0] = ((2.0 * F * (-2.0 * nu + 3.0 * nu_u)) / (3.0 * a * alpha * (1.0 - 2.0 * nu)));
102665876a83SMatthew G. Knepley
10273ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
102865876a83SMatthew G. Knepley }
102965876a83SMatthew G. Knepley
103065876a83SMatthew G. Knepley /* Cryer Solutions */
cryer_drainage_pressure(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)1031*2a8381b2SBarry Smith static PetscErrorCode cryer_drainage_pressure(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
1032d71ae5a4SJacob Faibussowitsch {
103365876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
103465876a83SMatthew G. Knepley Parameter *param;
103565876a83SMatthew G. Knepley
1036*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
103765876a83SMatthew G. Knepley if (time <= 0.0) {
103865876a83SMatthew G. Knepley PetscScalar alpha = param->alpha; /* - */
103965876a83SMatthew G. Knepley PetscScalar K_u = param->K_u; /* Pa */
104065876a83SMatthew G. Knepley PetscScalar M = param->M; /* Pa */
104165876a83SMatthew G. Knepley PetscScalar P_0 = param->P_0; /* Pa */
104265876a83SMatthew G. Knepley PetscScalar B = alpha * M / K_u; /* -, Cheng (B.12) */
104365876a83SMatthew G. Knepley
104465876a83SMatthew G. Knepley u[0] = P_0 * B;
104565876a83SMatthew G. Knepley } else {
104665876a83SMatthew G. Knepley u[0] = 0.0;
104765876a83SMatthew G. Knepley }
10483ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
104965876a83SMatthew G. Knepley }
105065876a83SMatthew G. Knepley
cryer_initial_u(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)1051*2a8381b2SBarry Smith static PetscErrorCode cryer_initial_u(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
1052d71ae5a4SJacob Faibussowitsch {
105365876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
105465876a83SMatthew G. Knepley Parameter *param;
105565876a83SMatthew G. Knepley
1056*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
105765876a83SMatthew G. Knepley {
105865876a83SMatthew G. Knepley PetscScalar K_u = param->K_u; /* Pa */
105965876a83SMatthew G. Knepley PetscScalar G = param->mu; /* Pa */
106065876a83SMatthew G. Knepley PetscScalar P_0 = param->P_0; /* Pa */
106130602db0SMatthew G. Knepley PetscReal R_0 = user->xmax[1]; /* m */
106265876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G)); /* -, Cheng (B.9) */
106365876a83SMatthew G. Knepley
106465876a83SMatthew G. Knepley PetscScalar u_0 = -P_0 * R_0 * (1. - 2. * nu_u) / (2. * G * (1. + nu_u)); /* Cheng (7.407) */
106565876a83SMatthew G. Knepley PetscReal u_sc = PetscRealPart(u_0) / R_0;
106665876a83SMatthew G. Knepley
106765876a83SMatthew G. Knepley u[0] = u_sc * x[0];
106865876a83SMatthew G. Knepley u[1] = u_sc * x[1];
106965876a83SMatthew G. Knepley u[2] = u_sc * x[2];
107065876a83SMatthew G. Knepley }
10713ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
107265876a83SMatthew G. Knepley }
107365876a83SMatthew G. Knepley
cryer_initial_eps(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)1074*2a8381b2SBarry Smith static PetscErrorCode cryer_initial_eps(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
1075d71ae5a4SJacob Faibussowitsch {
107665876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
107765876a83SMatthew G. Knepley Parameter *param;
107865876a83SMatthew G. Knepley
1079*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
108065876a83SMatthew G. Knepley {
108165876a83SMatthew G. Knepley PetscScalar K_u = param->K_u; /* Pa */
108265876a83SMatthew G. Knepley PetscScalar G = param->mu; /* Pa */
108365876a83SMatthew G. Knepley PetscScalar P_0 = param->P_0; /* Pa */
108430602db0SMatthew G. Knepley PetscReal R_0 = user->xmax[1]; /* m */
108565876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G)); /* -, Cheng (B.9) */
108665876a83SMatthew G. Knepley
108765876a83SMatthew G. Knepley PetscScalar u_0 = -P_0 * R_0 * (1. - 2. * nu_u) / (2. * G * (1. + nu_u)); /* Cheng (7.407) */
108865876a83SMatthew G. Knepley PetscReal u_sc = PetscRealPart(u_0) / R_0;
108965876a83SMatthew G. Knepley
109065876a83SMatthew G. Knepley /* div R = 1/R^2 d/dR R^2 R = 3 */
109165876a83SMatthew G. Knepley u[0] = 3. * u_sc;
109265876a83SMatthew G. Knepley u[1] = 3. * u_sc;
109365876a83SMatthew G. Knepley u[2] = 3. * u_sc;
109465876a83SMatthew G. Knepley }
10953ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
109665876a83SMatthew G. Knepley }
109765876a83SMatthew G. Knepley
109865876a83SMatthew G. Knepley // Displacement
cryer_3d_u(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)1099*2a8381b2SBarry Smith static PetscErrorCode cryer_3d_u(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
1100d71ae5a4SJacob Faibussowitsch {
110165876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
110265876a83SMatthew G. Knepley Parameter *param;
110365876a83SMatthew G. Knepley
1104*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
110565876a83SMatthew G. Knepley if (time <= 0.0) {
11069566063dSJacob Faibussowitsch PetscCall(cryer_initial_u(dim, time, x, Nc, u, ctx));
110765876a83SMatthew G. Knepley } else {
110865876a83SMatthew G. Knepley PetscScalar alpha = param->alpha; /* - */
110965876a83SMatthew G. Knepley PetscScalar K_u = param->K_u; /* Pa */
111065876a83SMatthew G. Knepley PetscScalar M = param->M; /* Pa */
111165876a83SMatthew G. Knepley PetscScalar G = param->mu; /* Pa */
111265876a83SMatthew G. Knepley PetscScalar P_0 = param->P_0; /* Pa */
111365876a83SMatthew G. Knepley PetscScalar kappa = param->k / param->mu_f; /* m^2 / (Pa s) */
111430602db0SMatthew G. Knepley PetscReal R_0 = user->xmax[1]; /* m */
111565876a83SMatthew G. Knepley PetscInt N = user->niter, n;
111665876a83SMatthew G. Knepley
111765876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M; /* Pa, Cheng (B.5) */
111865876a83SMatthew G. Knepley PetscScalar nu = (3.0 * K_d - 2.0 * G) / (2.0 * (3.0 * K_d + G)); /* -, Cheng (B.8) */
111965876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G)); /* -, Cheng (B.9) */
112065876a83SMatthew G. Knepley PetscScalar S = (3.0 * K_u + 4.0 * G) / (M * (3.0 * K_d + 4.0 * G)); /* Pa^{-1}, Cheng (B.14) */
112165876a83SMatthew G. Knepley PetscScalar c = kappa / S; /* m^2 / s, Cheng (B.16) */
112265876a83SMatthew G. Knepley PetscScalar u_inf = -P_0 * R_0 * (1. - 2. * nu) / (2. * G * (1. + nu)); /* m, Cheng (7.388) */
112365876a83SMatthew G. Knepley
112465876a83SMatthew G. Knepley PetscReal R = PetscSqrtReal(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
112565876a83SMatthew G. Knepley PetscReal R_star = R / R_0;
112665876a83SMatthew G. Knepley PetscReal tstar = PetscRealPart(c * time) / PetscSqr(R_0); /* - */
112765876a83SMatthew G. Knepley PetscReal A_n = 0.0;
112865876a83SMatthew G. Knepley PetscScalar u_sc;
112965876a83SMatthew G. Knepley
113065876a83SMatthew G. Knepley for (n = 1; n < N + 1; ++n) {
113165876a83SMatthew G. Knepley const PetscReal x_n = user->zeroArray[n - 1];
113265876a83SMatthew G. Knepley const PetscReal E_n = PetscRealPart(PetscSqr(1 - nu) * PetscSqr(1 + nu_u) * x_n - 18.0 * (1 + nu) * (nu_u - nu) * (1 - nu_u));
113365876a83SMatthew G. Knepley
113465876a83SMatthew G. Knepley /* m , Cheng (7.404) */
1135dd0d747aSMatthew G. Knepley if (R_star != 0) {
11369371c9d4SSatish Balay A_n += PetscRealPart((12.0 * (1.0 + nu) * (nu_u - nu)) / ((1.0 - 2.0 * nu) * E_n * PetscSqr(R_star) * x_n * PetscSinReal(PetscSqrtReal(x_n))) * (3.0 * (nu_u - nu) * (PetscSinReal(R_star * PetscSqrtReal(x_n)) - R_star * PetscSqrtReal(x_n) * PetscCosReal(R_star * PetscSqrtReal(x_n))) + (1.0 - nu) * (1.0 - 2.0 * nu) * PetscPowRealInt(R_star, 3) * x_n * PetscSinReal(PetscSqrtReal(x_n))) * PetscExpReal(-x_n * tstar));
113765876a83SMatthew G. Knepley }
1138dd0d747aSMatthew G. Knepley }
1139dd0d747aSMatthew G. Knepley if (R_star != 0) u_sc = PetscRealPart(u_inf) * (R_star - A_n) / R;
1140dd0d747aSMatthew G. Knepley else u_sc = PetscRealPart(u_inf) / R_0;
1141dd0d747aSMatthew G. Knepley u[0] = u_sc * x[0];
1142dd0d747aSMatthew G. Knepley u[1] = u_sc * x[1];
1143dd0d747aSMatthew G. Knepley u[2] = u_sc * x[2];
114465876a83SMatthew G. Knepley }
11453ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
114665876a83SMatthew G. Knepley }
114765876a83SMatthew G. Knepley
114865876a83SMatthew G. Knepley // Volumetric Strain
cryer_3d_eps(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)1149*2a8381b2SBarry Smith static PetscErrorCode cryer_3d_eps(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
1150d71ae5a4SJacob Faibussowitsch {
115165876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
115265876a83SMatthew G. Knepley Parameter *param;
115365876a83SMatthew G. Knepley
1154*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
115565876a83SMatthew G. Knepley if (time <= 0.0) {
11569566063dSJacob Faibussowitsch PetscCall(cryer_initial_eps(dim, time, x, Nc, u, ctx));
115765876a83SMatthew G. Knepley } else {
115865876a83SMatthew G. Knepley PetscScalar alpha = param->alpha; /* - */
115965876a83SMatthew G. Knepley PetscScalar K_u = param->K_u; /* Pa */
116065876a83SMatthew G. Knepley PetscScalar M = param->M; /* Pa */
116165876a83SMatthew G. Knepley PetscScalar G = param->mu; /* Pa */
116265876a83SMatthew G. Knepley PetscScalar P_0 = param->P_0; /* Pa */
116365876a83SMatthew G. Knepley PetscScalar kappa = param->k / param->mu_f; /* m^2 / (Pa s) */
116430602db0SMatthew G. Knepley PetscReal R_0 = user->xmax[1]; /* m */
116565876a83SMatthew G. Knepley PetscInt N = user->niter, n;
116665876a83SMatthew G. Knepley
116765876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M; /* Pa, Cheng (B.5) */
116865876a83SMatthew G. Knepley PetscScalar nu = (3.0 * K_d - 2.0 * G) / (2.0 * (3.0 * K_d + G)); /* -, Cheng (B.8) */
116965876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G)); /* -, Cheng (B.9) */
117065876a83SMatthew G. Knepley PetscScalar S = (3.0 * K_u + 4.0 * G) / (M * (3.0 * K_d + 4.0 * G)); /* Pa^{-1}, Cheng (B.14) */
117165876a83SMatthew G. Knepley PetscScalar c = kappa / S; /* m^2 / s, Cheng (B.16) */
117265876a83SMatthew G. Knepley PetscScalar u_inf = -P_0 * R_0 * (1. - 2. * nu) / (2. * G * (1. + nu)); /* m, Cheng (7.388) */
117365876a83SMatthew G. Knepley
117465876a83SMatthew G. Knepley PetscReal R = PetscSqrtReal(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
117565876a83SMatthew G. Knepley PetscReal R_star = R / R_0;
117665876a83SMatthew G. Knepley PetscReal tstar = PetscRealPart(c * time) / PetscSqr(R_0); /* - */
117765876a83SMatthew G. Knepley PetscReal divA_n = 0.0;
117865876a83SMatthew G. Knepley
117965876a83SMatthew G. Knepley if (R_star < PETSC_SMALL) {
118065876a83SMatthew G. Knepley for (n = 1; n < N + 1; ++n) {
118165876a83SMatthew G. Knepley const PetscReal x_n = user->zeroArray[n - 1];
118265876a83SMatthew G. Knepley const PetscReal E_n = PetscRealPart(PetscSqr(1 - nu) * PetscSqr(1 + nu_u) * x_n - 18.0 * (1 + nu) * (nu_u - nu) * (1 - nu_u));
118365876a83SMatthew G. Knepley
11849371c9d4SSatish Balay divA_n += PetscRealPart((12.0 * (1.0 + nu) * (nu_u - nu)) / ((1.0 - 2.0 * nu) * E_n * PetscSqr(R_star) * x_n * PetscSinReal(PetscSqrtReal(x_n))) * (3.0 * (nu_u - nu) * PetscSqrtReal(x_n) * ((2.0 + PetscSqr(R_star * PetscSqrtReal(x_n))) - 2.0 * PetscCosReal(R_star * PetscSqrtReal(x_n))) + 5.0 * (1.0 - nu) * (1.0 - 2.0 * nu) * PetscPowRealInt(R_star, 2) * x_n * PetscSinReal(PetscSqrtReal(x_n))) * PetscExpReal(-x_n * tstar));
118565876a83SMatthew G. Knepley }
118665876a83SMatthew G. Knepley } else {
118765876a83SMatthew G. Knepley for (n = 1; n < N + 1; ++n) {
118865876a83SMatthew G. Knepley const PetscReal x_n = user->zeroArray[n - 1];
118965876a83SMatthew G. Knepley const PetscReal E_n = PetscRealPart(PetscSqr(1 - nu) * PetscSqr(1 + nu_u) * x_n - 18.0 * (1 + nu) * (nu_u - nu) * (1 - nu_u));
119065876a83SMatthew G. Knepley
11919371c9d4SSatish Balay divA_n += PetscRealPart((12.0 * (1.0 + nu) * (nu_u - nu)) / ((1.0 - 2.0 * nu) * E_n * PetscSqr(R_star) * x_n * PetscSinReal(PetscSqrtReal(x_n))) * (3.0 * (nu_u - nu) * PetscSqrtReal(x_n) * ((2.0 / (R_star * PetscSqrtReal(x_n)) + R_star * PetscSqrtReal(x_n)) * PetscSinReal(R_star * PetscSqrtReal(x_n)) - 2.0 * PetscCosReal(R_star * PetscSqrtReal(x_n))) + 5.0 * (1.0 - nu) * (1.0 - 2.0 * nu) * PetscPowRealInt(R_star, 2) * x_n * PetscSinReal(PetscSqrtReal(x_n))) * PetscExpReal(-x_n * tstar));
119265876a83SMatthew G. Knepley }
119365876a83SMatthew G. Knepley }
11943ba16761SJacob Faibussowitsch if (PetscAbsReal(divA_n) > 1e3) PetscCall(PetscPrintf(PETSC_COMM_SELF, "(%g, %g, %g) divA_n: %g\n", (double)x[0], (double)x[1], (double)x[2], (double)divA_n));
119565876a83SMatthew G. Knepley u[0] = PetscRealPart(u_inf) / R_0 * (3.0 - divA_n);
119665876a83SMatthew G. Knepley }
11973ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
119865876a83SMatthew G. Knepley }
119965876a83SMatthew G. Knepley
120065876a83SMatthew G. Knepley // Pressure
cryer_3d_p(PetscInt dim,PetscReal time,const PetscReal x[],PetscInt Nc,PetscScalar * u,PetscCtx ctx)1201*2a8381b2SBarry Smith static PetscErrorCode cryer_3d_p(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, PetscCtx ctx)
1202d71ae5a4SJacob Faibussowitsch {
120365876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
120465876a83SMatthew G. Knepley Parameter *param;
120565876a83SMatthew G. Knepley
1206*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
120765876a83SMatthew G. Knepley if (time <= 0.0) {
12089566063dSJacob Faibussowitsch PetscCall(cryer_drainage_pressure(dim, time, x, Nc, u, ctx));
120965876a83SMatthew G. Knepley } else {
121065876a83SMatthew G. Knepley PetscScalar alpha = param->alpha; /* - */
121165876a83SMatthew G. Knepley PetscScalar K_u = param->K_u; /* Pa */
121265876a83SMatthew G. Knepley PetscScalar M = param->M; /* Pa */
121365876a83SMatthew G. Knepley PetscScalar G = param->mu; /* Pa */
121465876a83SMatthew G. Knepley PetscScalar P_0 = param->P_0; /* Pa */
121530602db0SMatthew G. Knepley PetscReal R_0 = user->xmax[1]; /* m */
121665876a83SMatthew G. Knepley PetscScalar kappa = param->k / param->mu_f; /* m^2 / (Pa s) */
121765876a83SMatthew G. Knepley PetscInt N = user->niter, n;
121865876a83SMatthew G. Knepley
121965876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M; /* Pa, Cheng (B.5) */
122065876a83SMatthew G. Knepley PetscScalar eta = (3.0 * alpha * G) / (3.0 * K_d + 4.0 * G); /* -, Cheng (B.11) */
122165876a83SMatthew G. Knepley PetscScalar nu = (3.0 * K_d - 2.0 * G) / (2.0 * (3.0 * K_d + G)); /* -, Cheng (B.8) */
122265876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G)); /* -, Cheng (B.9) */
122365876a83SMatthew G. Knepley PetscScalar S = (3.0 * K_u + 4.0 * G) / (M * (3.0 * K_d + 4.0 * G)); /* Pa^{-1}, Cheng (B.14) */
122465876a83SMatthew G. Knepley PetscScalar c = kappa / S; /* m^2 / s, Cheng (B.16) */
12259fa27a79SStefano Zampini PetscReal R = PetscSqrtReal(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
122665876a83SMatthew G. Knepley
12279fa27a79SStefano Zampini PetscReal R_star = R / R_0;
12289fa27a79SStefano Zampini PetscReal t_star = PetscRealPart(c * time) / PetscSqr(R_0);
122965876a83SMatthew G. Knepley PetscReal A_x = 0.0;
123065876a83SMatthew G. Knepley
123165876a83SMatthew G. Knepley for (n = 1; n < N + 1; ++n) {
123265876a83SMatthew G. Knepley const PetscReal x_n = user->zeroArray[n - 1];
123365876a83SMatthew G. Knepley const PetscReal E_n = PetscRealPart(PetscSqr(1 - nu) * PetscSqr(1 + nu_u) * x_n - 18.0 * (1 + nu) * (nu_u - nu) * (1 - nu_u));
123465876a83SMatthew G. Knepley
123565876a83SMatthew G. Knepley A_x += PetscRealPart(((18.0 * PetscSqr(nu_u - nu)) / (eta * E_n)) * (PetscSinReal(R_star * PetscSqrtReal(x_n)) / (R_star * PetscSinReal(PetscSqrtReal(x_n))) - 1.0) * PetscExpReal(-x_n * t_star)); /* Cheng (7.395) */
123665876a83SMatthew G. Knepley }
123765876a83SMatthew G. Knepley u[0] = P_0 * A_x;
123865876a83SMatthew G. Knepley }
12393ba16761SJacob Faibussowitsch return PETSC_SUCCESS;
124065876a83SMatthew G. Knepley }
124165876a83SMatthew G. Knepley
124265876a83SMatthew G. Knepley /* Boundary Kernels */
f0_terzaghi_bd_u(PetscInt dim,PetscInt Nf,PetscInt NfAux,const PetscInt uOff[],const PetscInt uOff_x[],const PetscScalar u[],const PetscScalar u_t[],const PetscScalar u_x[],const PetscInt aOff[],const PetscInt aOff_x[],const PetscScalar a[],const PetscScalar a_t[],const PetscScalar a_x[],PetscReal t,const PetscReal x[],const PetscReal n[],PetscInt numConstants,const PetscScalar constants[],PetscScalar f0[])1243d71ae5a4SJacob Faibussowitsch static void f0_terzaghi_bd_u(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
1244d71ae5a4SJacob Faibussowitsch {
124565876a83SMatthew G. Knepley const PetscReal P = PetscRealPart(constants[5]);
124665876a83SMatthew G. Knepley
124765876a83SMatthew G. Knepley f0[0] = 0.0;
124865876a83SMatthew G. Knepley f0[1] = P;
124965876a83SMatthew G. Knepley }
125065876a83SMatthew G. Knepley
125145480ffeSMatthew G. Knepley #if 0
125265876a83SMatthew G. Knepley static void f0_mandel_bd_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
125365876a83SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
125465876a83SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
125565876a83SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
125665876a83SMatthew G. Knepley {
125765876a83SMatthew G. Knepley // Uniform stress distribution
125865876a83SMatthew G. Knepley /* PetscScalar xmax = 0.5;
125965876a83SMatthew G. Knepley PetscScalar xmin = -0.5;
126065876a83SMatthew G. Knepley PetscScalar ymax = 0.5;
126165876a83SMatthew G. Knepley PetscScalar ymin = -0.5;
126265876a83SMatthew G. Knepley PetscScalar P = constants[5];
126365876a83SMatthew G. Knepley PetscScalar aL = (xmax - xmin) / 2.0;
126465876a83SMatthew G. Knepley PetscScalar sigma_zz = -1.0*P / aL; */
126565876a83SMatthew G. Knepley
126665876a83SMatthew G. Knepley // Analytical (parabolic) stress distribution
126765876a83SMatthew G. Knepley PetscReal a1, a2, am;
126865876a83SMatthew G. Knepley PetscReal y1, y2, ym;
126965876a83SMatthew G. Knepley
127065876a83SMatthew G. Knepley PetscInt NITER = 500;
127165876a83SMatthew G. Knepley PetscReal EPS = 0.000001;
127265876a83SMatthew G. Knepley PetscReal zeroArray[500]; /* NITER */
127365876a83SMatthew G. Knepley PetscReal xmax = 1.0;
127465876a83SMatthew G. Knepley PetscReal xmin = 0.0;
127565876a83SMatthew G. Knepley PetscReal ymax = 0.1;
127665876a83SMatthew G. Knepley PetscReal ymin = 0.0;
127765876a83SMatthew G. Knepley PetscReal lower[2], upper[2];
127865876a83SMatthew G. Knepley
127965876a83SMatthew G. Knepley lower[0] = xmin - (xmax - xmin) / 2.0;
128065876a83SMatthew G. Knepley lower[1] = ymin - (ymax - ymin) / 2.0;
128165876a83SMatthew G. Knepley upper[0] = xmax - (xmax - xmin) / 2.0;
128265876a83SMatthew G. Knepley upper[1] = ymax - (ymax - ymin) / 2.0;
128365876a83SMatthew G. Knepley
128465876a83SMatthew G. Knepley xmin = lower[0];
128565876a83SMatthew G. Knepley ymin = lower[1];
128665876a83SMatthew G. Knepley xmax = upper[0];
128765876a83SMatthew G. Knepley ymax = upper[1];
128865876a83SMatthew G. Knepley
128965876a83SMatthew G. Knepley PetscScalar G = constants[0];
129065876a83SMatthew G. Knepley PetscScalar K_u = constants[1];
129165876a83SMatthew G. Knepley PetscScalar alpha = constants[2];
129265876a83SMatthew G. Knepley PetscScalar M = constants[3];
129365876a83SMatthew G. Knepley PetscScalar kappa = constants[4];
129465876a83SMatthew G. Knepley PetscScalar F = constants[5];
129565876a83SMatthew G. Knepley
129665876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha*alpha*M;
129765876a83SMatthew G. Knepley PetscScalar nu = (3.0*K_d - 2.0*G) / (2.0*(3.0*K_d + G));
129865876a83SMatthew G. Knepley PetscScalar nu_u = (3.0*K_u - 2.0*G) / (2.0*(3.0*K_u + G));
129965876a83SMatthew G. Knepley PetscReal aL = (xmax - xmin) / 2.0;
130065876a83SMatthew G. Knepley PetscReal c = PetscRealPart(((2.0*kappa*G) * (1.0 - nu) * (nu_u - nu)) / (alpha*alpha * (1.0 - 2.0*nu) * (1.0 - nu_u)));
130165876a83SMatthew G. Knepley PetscScalar B = (3.0 * (nu_u - nu)) / ( alpha * (1.0 - 2.0*nu) * (1.0 + nu_u));
130265876a83SMatthew G. Knepley PetscScalar A1 = 3.0 / (B * (1.0 + nu_u));
130365876a83SMatthew G. Knepley PetscScalar A2 = (alpha * (1.0 - 2.0*nu)) / (1.0 - nu);
130465876a83SMatthew G. Knepley
130565876a83SMatthew G. Knepley // Generate zero values
130665876a83SMatthew G. Knepley for (PetscInt i=1; i < NITER+1; i++)
130765876a83SMatthew G. Knepley {
130865876a83SMatthew G. Knepley a1 = ((PetscReal) i - 1.0) * PETSC_PI * PETSC_PI / 4.0 + EPS;
130965876a83SMatthew G. Knepley a2 = a1 + PETSC_PI/2;
131065876a83SMatthew G. Knepley for (PetscInt j=0; j<NITER; j++)
131165876a83SMatthew G. Knepley {
131265876a83SMatthew G. Knepley y1 = PetscTanReal(a1) - PetscRealPart(A1/A2)*a1;
131365876a83SMatthew G. Knepley y2 = PetscTanReal(a2) - PetscRealPart(A1/A2)*a2;
131465876a83SMatthew G. Knepley am = (a1 + a2)/2.0;
131565876a83SMatthew G. Knepley ym = PetscTanReal(am) - PetscRealPart(A1/A2)*am;
131665876a83SMatthew G. Knepley if ((ym*y1) > 0)
131765876a83SMatthew G. Knepley {
131865876a83SMatthew G. Knepley a1 = am;
131965876a83SMatthew G. Knepley } else {
132065876a83SMatthew G. Knepley a2 = am;
132165876a83SMatthew G. Knepley }
132265876a83SMatthew G. Knepley if (PetscAbsReal(y2) < EPS)
132365876a83SMatthew G. Knepley {
132465876a83SMatthew G. Knepley am = a2;
132565876a83SMatthew G. Knepley }
132665876a83SMatthew G. Knepley }
132765876a83SMatthew G. Knepley zeroArray[i-1] = am;
132865876a83SMatthew G. Knepley }
132965876a83SMatthew G. Knepley
133065876a83SMatthew G. Knepley // Solution for sigma_zz
133165876a83SMatthew G. Knepley PetscScalar A_x = 0.0;
133265876a83SMatthew G. Knepley PetscScalar B_x = 0.0;
133365876a83SMatthew G. Knepley
133465876a83SMatthew G. Knepley for (PetscInt n=1; n < NITER+1; n++)
133565876a83SMatthew G. Knepley {
133665876a83SMatthew G. Knepley PetscReal alpha_n = zeroArray[n-1];
133765876a83SMatthew G. Knepley
133865876a83SMatthew G. Knepley A_x += ( PetscSinReal(alpha_n) / (alpha_n - PetscSinReal(alpha_n) * PetscCosReal(alpha_n))) * PetscCosReal( (alpha_n * x[0]) / aL) * PetscExpReal( -1.0*( (alpha_n*alpha_n*c*t)/(aL*aL)));
133965876a83SMatthew G. Knepley B_x += ( (PetscSinReal(alpha_n) * PetscCosReal(alpha_n))/(alpha_n - PetscSinReal(alpha_n) * PetscCosReal(alpha_n))) * PetscExpReal( -1.0*( (alpha_n*alpha_n*c*t)/(aL*aL)));
134065876a83SMatthew G. Knepley }
134165876a83SMatthew G. Knepley
134265876a83SMatthew G. Knepley PetscScalar sigma_zz = -1.0*(F/aL) - ((2.0*F)/aL) * (A2/A1) * A_x + ((2.0*F)/aL) * B_x;
134365876a83SMatthew G. Knepley
134465876a83SMatthew G. Knepley if (x[1] == ymax) {
134565876a83SMatthew G. Knepley f0[1] += sigma_zz;
134665876a83SMatthew G. Knepley } else if (x[1] == ymin) {
134765876a83SMatthew G. Knepley f0[1] -= sigma_zz;
134865876a83SMatthew G. Knepley }
134965876a83SMatthew G. Knepley }
135045480ffeSMatthew G. Knepley #endif
135165876a83SMatthew G. Knepley
f0_cryer_bd_u(PetscInt dim,PetscInt Nf,PetscInt NfAux,const PetscInt uOff[],const PetscInt uOff_x[],const PetscScalar u[],const PetscScalar u_t[],const PetscScalar u_x[],const PetscInt aOff[],const PetscInt aOff_x[],const PetscScalar a[],const PetscScalar a_t[],const PetscScalar a_x[],PetscReal t,const PetscReal x[],const PetscReal n[],PetscInt numConstants,const PetscScalar constants[],PetscScalar f0[])1352d71ae5a4SJacob Faibussowitsch static void f0_cryer_bd_u(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
1353d71ae5a4SJacob Faibussowitsch {
135465876a83SMatthew G. Knepley const PetscReal P_0 = PetscRealPart(constants[5]);
135565876a83SMatthew G. Knepley PetscInt d;
135665876a83SMatthew G. Knepley
135765876a83SMatthew G. Knepley for (d = 0; d < dim; ++d) f0[d] = -P_0 * n[d];
135865876a83SMatthew G. Knepley }
135965876a83SMatthew G. Knepley
136065876a83SMatthew G. Knepley /* Standard Kernels - Residual */
136165876a83SMatthew G. Knepley /* f0_e */
f0_epsilon(PetscInt dim,PetscInt Nf,PetscInt NfAux,const PetscInt uOff[],const PetscInt uOff_x[],const PetscScalar u[],const PetscScalar u_t[],const PetscScalar u_x[],const PetscInt aOff[],const PetscInt aOff_x[],const PetscScalar a[],const PetscScalar a_t[],const PetscScalar a_x[],PetscReal t,const PetscReal x[],PetscInt numConstants,const PetscScalar constants[],PetscScalar f0[])1362d71ae5a4SJacob Faibussowitsch static void f0_epsilon(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
1363d71ae5a4SJacob Faibussowitsch {
136465876a83SMatthew G. Knepley PetscInt d;
136565876a83SMatthew G. Knepley
1366ad540459SPierre Jolivet for (d = 0; d < dim; ++d) f0[0] += u_x[d * dim + d];
136765876a83SMatthew G. Knepley f0[0] -= u[uOff[1]];
136865876a83SMatthew G. Knepley }
136965876a83SMatthew G. Knepley
137065876a83SMatthew G. Knepley /* f0_p */
f0_p(PetscInt dim,PetscInt Nf,PetscInt NfAux,const PetscInt uOff[],const PetscInt uOff_x[],const PetscScalar u[],const PetscScalar u_t[],const PetscScalar u_x[],const PetscInt aOff[],const PetscInt aOff_x[],const PetscScalar a[],const PetscScalar a_t[],const PetscScalar a_x[],PetscReal t,const PetscReal x[],PetscInt numConstants,const PetscScalar constants[],PetscScalar f0[])1371d71ae5a4SJacob Faibussowitsch static void f0_p(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
1372d71ae5a4SJacob Faibussowitsch {
137365876a83SMatthew G. Knepley const PetscReal alpha = PetscRealPart(constants[2]);
137465876a83SMatthew G. Knepley const PetscReal M = PetscRealPart(constants[3]);
137565876a83SMatthew G. Knepley
137665876a83SMatthew G. Knepley f0[0] += alpha * u_t[uOff[1]];
137765876a83SMatthew G. Knepley f0[0] += u_t[uOff[2]] / M;
137830602db0SMatthew G. Knepley if (f0[0] != f0[0]) abort();
137965876a83SMatthew G. Knepley }
138065876a83SMatthew G. Knepley
138165876a83SMatthew G. Knepley /* f1_u */
f1_u(PetscInt dim,PetscInt Nf,PetscInt NfAux,const PetscInt uOff[],const PetscInt uOff_x[],const PetscScalar u[],const PetscScalar u_t[],const PetscScalar u_x[],const PetscInt aOff[],const PetscInt aOff_x[],const PetscScalar a[],const PetscScalar a_t[],const PetscScalar a_x[],PetscReal t,const PetscReal x[],PetscInt numConstants,const PetscScalar constants[],PetscScalar f1[])1382d71ae5a4SJacob Faibussowitsch static void f1_u(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])
1383d71ae5a4SJacob Faibussowitsch {
138465876a83SMatthew G. Knepley const PetscInt Nc = dim;
138565876a83SMatthew G. Knepley const PetscReal G = PetscRealPart(constants[0]);
138665876a83SMatthew G. Knepley const PetscReal K_u = PetscRealPart(constants[1]);
138765876a83SMatthew G. Knepley const PetscReal alpha = PetscRealPart(constants[2]);
138865876a83SMatthew G. Knepley const PetscReal M = PetscRealPart(constants[3]);
138965876a83SMatthew G. Knepley const PetscReal K_d = K_u - alpha * alpha * M;
139065876a83SMatthew G. Knepley const PetscReal lambda = K_d - (2.0 * G) / 3.0;
139165876a83SMatthew G. Knepley PetscInt c, d;
139265876a83SMatthew G. Knepley
13939371c9d4SSatish Balay for (c = 0; c < Nc; ++c) {
1394ad540459SPierre Jolivet for (d = 0; d < dim; ++d) f1[c * dim + d] -= G * (u_x[c * dim + d] + u_x[d * dim + c]);
139565876a83SMatthew G. Knepley f1[c * dim + c] -= lambda * u[uOff[1]];
139665876a83SMatthew G. Knepley f1[c * dim + c] += alpha * u[uOff[2]];
139765876a83SMatthew G. Knepley }
139865876a83SMatthew G. Knepley }
139965876a83SMatthew G. Knepley
140065876a83SMatthew G. Knepley /* f1_p */
f1_p(PetscInt dim,PetscInt Nf,PetscInt NfAux,const PetscInt uOff[],const PetscInt uOff_x[],const PetscScalar u[],const PetscScalar u_t[],const PetscScalar u_x[],const PetscInt aOff[],const PetscInt aOff_x[],const PetscScalar a[],const PetscScalar a_t[],const PetscScalar a_x[],PetscReal t,const PetscReal x[],PetscInt numConstants,const PetscScalar constants[],PetscScalar f1[])1401d71ae5a4SJacob Faibussowitsch static void f1_p(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])
1402d71ae5a4SJacob Faibussowitsch {
140365876a83SMatthew G. Knepley const PetscReal kappa = PetscRealPart(constants[4]);
140465876a83SMatthew G. Knepley PetscInt d;
140565876a83SMatthew G. Knepley
1406ad540459SPierre Jolivet for (d = 0; d < dim; ++d) f1[d] += kappa * u_x[uOff_x[2] + d];
140765876a83SMatthew G. Knepley }
140865876a83SMatthew G. Knepley
140965876a83SMatthew G. Knepley /*
141065876a83SMatthew G. Knepley \partial_df \phi_fc g_{fc,gc,df,dg} \partial_dg \phi_gc
141165876a83SMatthew G. Knepley
141265876a83SMatthew G. Knepley \partial_df \phi_fc \lambda \delta_{fc,df} \sum_gc \partial_dg \phi_gc \delta_{gc,dg}
141365876a83SMatthew G. Knepley = \partial_fc \phi_fc \sum_gc \partial_gc \phi_gc
141465876a83SMatthew G. Knepley */
141565876a83SMatthew G. Knepley
141665876a83SMatthew G. Knepley /* Standard Kernels - Jacobian */
141765876a83SMatthew G. Knepley /* g0_ee */
g0_ee(PetscInt dim,PetscInt Nf,PetscInt NfAux,const PetscInt uOff[],const PetscInt uOff_x[],const PetscScalar u[],const PetscScalar u_t[],const PetscScalar u_x[],const PetscInt aOff[],const PetscInt aOff_x[],const PetscScalar a[],const PetscScalar a_t[],const PetscScalar a_x[],PetscReal t,PetscReal u_tShift,const PetscReal x[],PetscInt numConstants,const PetscScalar constants[],PetscScalar g0[])1418d71ae5a4SJacob Faibussowitsch static void g0_ee(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[])
1419d71ae5a4SJacob Faibussowitsch {
142065876a83SMatthew G. Knepley g0[0] = -1.0;
142165876a83SMatthew G. Knepley }
142265876a83SMatthew G. Knepley
142365876a83SMatthew G. Knepley /* g0_pe */
g0_pe(PetscInt dim,PetscInt Nf,PetscInt NfAux,const PetscInt uOff[],const PetscInt uOff_x[],const PetscScalar u[],const PetscScalar u_t[],const PetscScalar u_x[],const PetscInt aOff[],const PetscInt aOff_x[],const PetscScalar a[],const PetscScalar a_t[],const PetscScalar a_x[],PetscReal t,PetscReal u_tShift,const PetscReal x[],PetscInt numConstants,const PetscScalar constants[],PetscScalar g0[])1424d71ae5a4SJacob Faibussowitsch static void g0_pe(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[])
1425d71ae5a4SJacob Faibussowitsch {
142665876a83SMatthew G. Knepley const PetscReal alpha = PetscRealPart(constants[2]);
142765876a83SMatthew G. Knepley
142865876a83SMatthew G. Knepley g0[0] = u_tShift * alpha;
142965876a83SMatthew G. Knepley }
143065876a83SMatthew G. Knepley
143165876a83SMatthew G. Knepley /* g0_pp */
g0_pp(PetscInt dim,PetscInt Nf,PetscInt NfAux,const PetscInt uOff[],const PetscInt uOff_x[],const PetscScalar u[],const PetscScalar u_t[],const PetscScalar u_x[],const PetscInt aOff[],const PetscInt aOff_x[],const PetscScalar a[],const PetscScalar a_t[],const PetscScalar a_x[],PetscReal t,PetscReal u_tShift,const PetscReal x[],PetscInt numConstants,const PetscScalar constants[],PetscScalar g0[])1432d71ae5a4SJacob Faibussowitsch static void g0_pp(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[])
1433d71ae5a4SJacob Faibussowitsch {
143465876a83SMatthew G. Knepley const PetscReal M = PetscRealPart(constants[3]);
143565876a83SMatthew G. Knepley
143665876a83SMatthew G. Knepley g0[0] = u_tShift / M;
143765876a83SMatthew G. Knepley }
143865876a83SMatthew G. Knepley
143965876a83SMatthew G. Knepley /* g1_eu */
g1_eu(PetscInt dim,PetscInt Nf,PetscInt NfAux,const PetscInt uOff[],const PetscInt uOff_x[],const PetscScalar u[],const PetscScalar u_t[],const PetscScalar u_x[],const PetscInt aOff[],const PetscInt aOff_x[],const PetscScalar a[],const PetscScalar a_t[],const PetscScalar a_x[],PetscReal t,PetscReal u_tShift,const PetscReal x[],PetscInt numConstants,const PetscScalar constants[],PetscScalar g1[])1440d71ae5a4SJacob Faibussowitsch static void g1_eu(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[])
1441d71ae5a4SJacob Faibussowitsch {
144265876a83SMatthew G. Knepley PetscInt d;
144365876a83SMatthew G. Knepley for (d = 0; d < dim; ++d) g1[d * dim + d] = 1.0; /* \frac{\partial\phi^{u_d}}{\partial x_d} */
144465876a83SMatthew G. Knepley }
144565876a83SMatthew G. Knepley
144665876a83SMatthew G. Knepley /* g2_ue */
g2_ue(PetscInt dim,PetscInt Nf,PetscInt NfAux,const PetscInt uOff[],const PetscInt uOff_x[],const PetscScalar u[],const PetscScalar u_t[],const PetscScalar u_x[],const PetscInt aOff[],const PetscInt aOff_x[],const PetscScalar a[],const PetscScalar a_t[],const PetscScalar a_x[],PetscReal t,PetscReal u_tShift,const PetscReal x[],PetscInt numConstants,const PetscScalar constants[],PetscScalar g2[])1447d71ae5a4SJacob Faibussowitsch static void g2_ue(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[])
1448d71ae5a4SJacob Faibussowitsch {
144965876a83SMatthew G. Knepley const PetscReal G = PetscRealPart(constants[0]);
145065876a83SMatthew G. Knepley const PetscReal K_u = PetscRealPart(constants[1]);
145165876a83SMatthew G. Knepley const PetscReal alpha = PetscRealPart(constants[2]);
145265876a83SMatthew G. Knepley const PetscReal M = PetscRealPart(constants[3]);
145365876a83SMatthew G. Knepley const PetscReal K_d = K_u - alpha * alpha * M;
145465876a83SMatthew G. Knepley const PetscReal lambda = K_d - (2.0 * G) / 3.0;
145565876a83SMatthew G. Knepley PetscInt d;
145665876a83SMatthew G. Knepley
1457ad540459SPierre Jolivet for (d = 0; d < dim; ++d) g2[d * dim + d] -= lambda;
145865876a83SMatthew G. Knepley }
145965876a83SMatthew G. Knepley /* g2_up */
g2_up(PetscInt dim,PetscInt Nf,PetscInt NfAux,const PetscInt uOff[],const PetscInt uOff_x[],const PetscScalar u[],const PetscScalar u_t[],const PetscScalar u_x[],const PetscInt aOff[],const PetscInt aOff_x[],const PetscScalar a[],const PetscScalar a_t[],const PetscScalar a_x[],PetscReal t,PetscReal u_tShift,const PetscReal x[],PetscInt numConstants,const PetscScalar constants[],PetscScalar g2[])1460d71ae5a4SJacob Faibussowitsch static void g2_up(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[])
1461d71ae5a4SJacob Faibussowitsch {
146265876a83SMatthew G. Knepley const PetscReal alpha = PetscRealPart(constants[2]);
146365876a83SMatthew G. Knepley PetscInt d;
146465876a83SMatthew G. Knepley
1465ad540459SPierre Jolivet for (d = 0; d < dim; ++d) g2[d * dim + d] += alpha;
146665876a83SMatthew G. Knepley }
146765876a83SMatthew G. Knepley
146865876a83SMatthew G. Knepley /* g3_uu */
g3_uu(PetscInt dim,PetscInt Nf,PetscInt NfAux,const PetscInt uOff[],const PetscInt uOff_x[],const PetscScalar u[],const PetscScalar u_t[],const PetscScalar u_x[],const PetscInt aOff[],const PetscInt aOff_x[],const PetscScalar a[],const PetscScalar a_t[],const PetscScalar a_x[],PetscReal t,PetscReal u_tShift,const PetscReal x[],PetscInt numConstants,const PetscScalar constants[],PetscScalar g3[])1469d71ae5a4SJacob Faibussowitsch static void g3_uu(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])
1470d71ae5a4SJacob Faibussowitsch {
147165876a83SMatthew G. Knepley const PetscInt Nc = dim;
147265876a83SMatthew G. Knepley const PetscReal G = PetscRealPart(constants[0]);
147365876a83SMatthew G. Knepley PetscInt c, d;
147465876a83SMatthew G. Knepley
147565876a83SMatthew G. Knepley for (c = 0; c < Nc; ++c) {
147665876a83SMatthew G. Knepley for (d = 0; d < dim; ++d) {
147765876a83SMatthew G. Knepley g3[((c * Nc + c) * dim + d) * dim + d] -= G;
147865876a83SMatthew G. Knepley g3[((c * Nc + d) * dim + d) * dim + c] -= G;
147965876a83SMatthew G. Knepley }
148065876a83SMatthew G. Knepley }
148165876a83SMatthew G. Knepley }
148265876a83SMatthew G. Knepley
148365876a83SMatthew G. Knepley /* g3_pp */
g3_pp(PetscInt dim,PetscInt Nf,PetscInt NfAux,const PetscInt uOff[],const PetscInt uOff_x[],const PetscScalar u[],const PetscScalar u_t[],const PetscScalar u_x[],const PetscInt aOff[],const PetscInt aOff_x[],const PetscScalar a[],const PetscScalar a_t[],const PetscScalar a_x[],PetscReal t,PetscReal u_tShift,const PetscReal x[],PetscInt numConstants,const PetscScalar constants[],PetscScalar g3[])1484d71ae5a4SJacob Faibussowitsch static void g3_pp(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])
1485d71ae5a4SJacob Faibussowitsch {
148665876a83SMatthew G. Knepley const PetscReal kappa = PetscRealPart(constants[4]);
148765876a83SMatthew G. Knepley PetscInt d;
148865876a83SMatthew G. Knepley
148965876a83SMatthew G. Knepley for (d = 0; d < dim; ++d) g3[d * dim + d] += kappa;
149065876a83SMatthew G. Knepley }
149165876a83SMatthew G. Knepley
ProcessOptions(MPI_Comm comm,AppCtx * options)1492d71ae5a4SJacob Faibussowitsch static PetscErrorCode ProcessOptions(MPI_Comm comm, AppCtx *options)
1493d71ae5a4SJacob Faibussowitsch {
149465876a83SMatthew G. Knepley PetscInt sol;
149565876a83SMatthew G. Knepley
149665876a83SMatthew G. Knepley PetscFunctionBeginUser;
149765876a83SMatthew G. Knepley options->solType = SOL_QUADRATIC_TRIG;
149865876a83SMatthew G. Knepley options->niter = 500;
149965876a83SMatthew G. Knepley options->eps = PETSC_SMALL;
150024b15d09SMatthew G. Knepley options->dtInitial = -1.0;
1501d0609cedSBarry Smith PetscOptionsBegin(comm, "", "Biot Poroelasticity Options", "DMPLEX");
15029566063dSJacob Faibussowitsch PetscCall(PetscOptionsInt("-niter", "Number of series term iterations in exact solutions", "ex53.c", options->niter, &options->niter, NULL));
150365876a83SMatthew G. Knepley sol = options->solType;
15049566063dSJacob Faibussowitsch PetscCall(PetscOptionsEList("-sol_type", "Type of exact solution", "ex53.c", solutionTypes, NUM_SOLUTION_TYPES, solutionTypes[options->solType], &sol, NULL));
150565876a83SMatthew G. Knepley options->solType = (SolutionType)sol;
15069566063dSJacob Faibussowitsch PetscCall(PetscOptionsReal("-eps", "Precision value for root finding", "ex53.c", options->eps, &options->eps, NULL));
15079566063dSJacob Faibussowitsch PetscCall(PetscOptionsReal("-dt_initial", "Override the initial timestep", "ex53.c", options->dtInitial, &options->dtInitial, NULL));
1508d0609cedSBarry Smith PetscOptionsEnd();
15093ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
151065876a83SMatthew G. Knepley }
151165876a83SMatthew G. Knepley
mandelZeros(MPI_Comm comm,AppCtx * ctx,Parameter * param)1512d71ae5a4SJacob Faibussowitsch static PetscErrorCode mandelZeros(MPI_Comm comm, AppCtx *ctx, Parameter *param)
1513d71ae5a4SJacob Faibussowitsch {
151465876a83SMatthew G. Knepley //PetscBag bag;
151565876a83SMatthew G. Knepley PetscReal a1, a2, am;
151665876a83SMatthew G. Knepley PetscReal y1, y2, ym;
151765876a83SMatthew G. Knepley
151865876a83SMatthew G. Knepley PetscFunctionBeginUser;
1519*2a8381b2SBarry Smith //PetscCall(PetscBagGetData(ctx->bag, ¶m));
152065876a83SMatthew G. Knepley PetscInt NITER = ctx->niter;
152165876a83SMatthew G. Knepley PetscReal EPS = ctx->eps;
152265876a83SMatthew G. Knepley //const PetscScalar YMAX = param->ymax;
152365876a83SMatthew G. Knepley //const PetscScalar YMIN = param->ymin;
152465876a83SMatthew G. Knepley PetscScalar alpha = param->alpha;
152565876a83SMatthew G. Knepley PetscScalar K_u = param->K_u;
152665876a83SMatthew G. Knepley PetscScalar M = param->M;
152765876a83SMatthew G. Knepley PetscScalar G = param->mu;
152865876a83SMatthew G. Knepley //const PetscScalar k = param->k;
152965876a83SMatthew G. Knepley //const PetscScalar mu_f = param->mu_f;
153065876a83SMatthew G. Knepley //const PetscScalar P_0 = param->P_0;
153165876a83SMatthew G. Knepley
153265876a83SMatthew G. Knepley PetscScalar K_d = K_u - alpha * alpha * M;
153365876a83SMatthew G. Knepley PetscScalar nu = (3.0 * K_d - 2.0 * G) / (2.0 * (3.0 * K_d + G));
153465876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G));
153565876a83SMatthew G. Knepley //const PetscScalar kappa = k / mu_f;
153665876a83SMatthew G. Knepley
153765876a83SMatthew G. Knepley // Generate zero values
15389371c9d4SSatish Balay for (PetscInt i = 1; i < NITER + 1; i++) {
153965876a83SMatthew G. Knepley a1 = ((PetscReal)i - 1.0) * PETSC_PI * PETSC_PI / 4.0 + EPS;
154065876a83SMatthew G. Knepley a2 = a1 + PETSC_PI / 2;
154165876a83SMatthew G. Knepley am = a1;
15429371c9d4SSatish Balay for (PetscInt j = 0; j < NITER; j++) {
154365876a83SMatthew G. Knepley y1 = PetscTanReal(a1) - PetscRealPart((1.0 - nu) / (nu_u - nu)) * a1;
154465876a83SMatthew G. Knepley y2 = PetscTanReal(a2) - PetscRealPart((1.0 - nu) / (nu_u - nu)) * a2;
154565876a83SMatthew G. Knepley am = (a1 + a2) / 2.0;
154665876a83SMatthew G. Knepley ym = PetscTanReal(am) - PetscRealPart((1.0 - nu) / (nu_u - nu)) * am;
15479371c9d4SSatish Balay if ((ym * y1) > 0) {
154865876a83SMatthew G. Knepley a1 = am;
154965876a83SMatthew G. Knepley } else {
155065876a83SMatthew G. Knepley a2 = am;
155165876a83SMatthew G. Knepley }
1552ad540459SPierre Jolivet if (PetscAbsReal(y2) < EPS) am = a2;
155365876a83SMatthew G. Knepley }
155465876a83SMatthew G. Knepley ctx->zeroArray[i - 1] = am;
155565876a83SMatthew G. Knepley }
15563ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
155765876a83SMatthew G. Knepley }
155865876a83SMatthew G. Knepley
CryerFunction(PetscReal nu_u,PetscReal nu,PetscReal x)1559d71ae5a4SJacob Faibussowitsch static PetscReal CryerFunction(PetscReal nu_u, PetscReal nu, PetscReal x)
1560d71ae5a4SJacob Faibussowitsch {
156165876a83SMatthew G. Knepley return PetscTanReal(PetscSqrtReal(x)) * (6.0 * (nu_u - nu) - (1.0 - nu) * (1.0 + nu_u) * x) - (6.0 * (nu_u - nu) * PetscSqrtReal(x));
156265876a83SMatthew G. Knepley }
156365876a83SMatthew G. Knepley
cryerZeros(MPI_Comm comm,AppCtx * ctx,Parameter * param)1564d71ae5a4SJacob Faibussowitsch static PetscErrorCode cryerZeros(MPI_Comm comm, AppCtx *ctx, Parameter *param)
1565d71ae5a4SJacob Faibussowitsch {
156665876a83SMatthew G. Knepley PetscReal alpha = PetscRealPart(param->alpha); /* - */
156765876a83SMatthew G. Knepley PetscReal K_u = PetscRealPart(param->K_u); /* Pa */
156865876a83SMatthew G. Knepley PetscReal M = PetscRealPart(param->M); /* Pa */
156965876a83SMatthew G. Knepley PetscReal G = PetscRealPart(param->mu); /* Pa */
157065876a83SMatthew G. Knepley PetscInt N = ctx->niter, n;
157165876a83SMatthew G. Knepley
157265876a83SMatthew G. Knepley PetscReal K_d = K_u - alpha * alpha * M; /* Pa, Cheng (B.5) */
157365876a83SMatthew G. Knepley PetscReal nu = (3.0 * K_d - 2.0 * G) / (2.0 * (3.0 * K_d + G)); /* -, Cheng (B.8) */
157465876a83SMatthew G. Knepley PetscReal nu_u = (3.0 * K_u - 2.0 * G) / (2.0 * (3.0 * K_u + G)); /* -, Cheng (B.9) */
157565876a83SMatthew G. Knepley
157665876a83SMatthew G. Knepley PetscFunctionBeginUser;
157765876a83SMatthew G. Knepley for (n = 1; n < N + 1; ++n) {
157865876a83SMatthew G. Knepley PetscReal tol = PetscPowReal(n, 1.5) * ctx->eps;
157965876a83SMatthew G. Knepley PetscReal a1 = 0., a2 = 0., am = 0.;
158065876a83SMatthew G. Knepley PetscReal y1, y2, ym;
158165876a83SMatthew G. Knepley PetscInt j, k = n - 1;
158265876a83SMatthew G. Knepley
158365876a83SMatthew G. Knepley y1 = y2 = 1.;
158465876a83SMatthew G. Knepley while (y1 * y2 > 0) {
158565876a83SMatthew G. Knepley ++k;
158665876a83SMatthew G. Knepley a1 = PetscSqr(n * PETSC_PI) - k * PETSC_PI;
158765876a83SMatthew G. Knepley a2 = PetscSqr(n * PETSC_PI) + k * PETSC_PI;
158865876a83SMatthew G. Knepley y1 = CryerFunction(nu_u, nu, a1);
158965876a83SMatthew G. Knepley y2 = CryerFunction(nu_u, nu, a2);
159065876a83SMatthew G. Knepley }
159165876a83SMatthew G. Knepley for (j = 0; j < 50000; ++j) {
159265876a83SMatthew G. Knepley y1 = CryerFunction(nu_u, nu, a1);
159365876a83SMatthew G. Knepley y2 = CryerFunction(nu_u, nu, a2);
159463a3b9bcSJacob Faibussowitsch PetscCheck(y1 * y2 <= 0, comm, PETSC_ERR_PLIB, "Invalid root finding initialization for root %" PetscInt_FMT ", (%g, %g)--(%g, %g)", n, (double)a1, (double)y1, (double)a2, (double)y2);
159565876a83SMatthew G. Knepley am = (a1 + a2) / 2.0;
159665876a83SMatthew G. Knepley ym = CryerFunction(nu_u, nu, am);
159765876a83SMatthew G. Knepley if ((ym * y1) < 0) a2 = am;
159865876a83SMatthew G. Knepley else a1 = am;
159963a3b9bcSJacob Faibussowitsch if (PetscAbsReal(ym) < tol) break;
160065876a83SMatthew G. Knepley }
160163a3b9bcSJacob Faibussowitsch PetscCheck(PetscAbsReal(ym) < tol, comm, PETSC_ERR_PLIB, "Root finding did not converge for root %" PetscInt_FMT " (%g)", n, (double)PetscAbsReal(ym));
160265876a83SMatthew G. Knepley ctx->zeroArray[n - 1] = am;
160365876a83SMatthew G. Knepley }
16043ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
160565876a83SMatthew G. Knepley }
160665876a83SMatthew G. Knepley
SetupParameters(MPI_Comm comm,AppCtx * ctx)1607d71ae5a4SJacob Faibussowitsch static PetscErrorCode SetupParameters(MPI_Comm comm, AppCtx *ctx)
1608d71ae5a4SJacob Faibussowitsch {
160965876a83SMatthew G. Knepley PetscBag bag;
161065876a83SMatthew G. Knepley Parameter *p;
161165876a83SMatthew G. Knepley
161265876a83SMatthew G. Knepley PetscFunctionBeginUser;
161365876a83SMatthew G. Knepley /* setup PETSc parameter bag */
1614*2a8381b2SBarry Smith PetscCall(PetscBagGetData(ctx->bag, &p));
16159566063dSJacob Faibussowitsch PetscCall(PetscBagSetName(ctx->bag, "par", "Poroelastic Parameters"));
161665876a83SMatthew G. Knepley bag = ctx->bag;
161765876a83SMatthew G. Knepley if (ctx->solType == SOL_TERZAGHI) {
161865876a83SMatthew G. Knepley // Realistic values - Terzaghi
16199566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->mu, 3.0, "mu", "Shear Modulus, Pa"));
16209566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->K_u, 9.76, "K_u", "Undrained Bulk Modulus, Pa"));
16219566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->alpha, 0.6, "alpha", "Biot Effective Stress Coefficient, -"));
16229566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->M, 16.0, "M", "Biot Modulus, Pa"));
16239566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->k, 1.5, "k", "Isotropic Permeability, m**2"));
16249566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->mu_f, 1.0, "mu_f", "Fluid Dynamic Viscosity, Pa*s"));
16259566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->P_0, 1.0, "P_0", "Magnitude of Vertical Stress, Pa"));
162665876a83SMatthew G. Knepley } else if (ctx->solType == SOL_MANDEL) {
162765876a83SMatthew G. Knepley // Realistic values - Mandel
16289566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->mu, 0.75, "mu", "Shear Modulus, Pa"));
16299566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->K_u, 2.6941176470588233, "K_u", "Undrained Bulk Modulus, Pa"));
16309566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->alpha, 0.6, "alpha", "Biot Effective Stress Coefficient, -"));
16319566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->M, 4.705882352941176, "M", "Biot Modulus, Pa"));
16329566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->k, 1.5, "k", "Isotropic Permeability, m**2"));
16339566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->mu_f, 1.0, "mu_f", "Fluid Dynamic Viscosity, Pa*s"));
16349566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->P_0, 1.0, "P_0", "Magnitude of Vertical Stress, Pa"));
163565876a83SMatthew G. Knepley } else if (ctx->solType == SOL_CRYER) {
163665876a83SMatthew G. Knepley // Realistic values - Mandel
16379566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->mu, 0.75, "mu", "Shear Modulus, Pa"));
16389566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->K_u, 2.6941176470588233, "K_u", "Undrained Bulk Modulus, Pa"));
16399566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->alpha, 0.6, "alpha", "Biot Effective Stress Coefficient, -"));
16409566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->M, 4.705882352941176, "M", "Biot Modulus, Pa"));
16419566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->k, 1.5, "k", "Isotropic Permeability, m**2"));
16429566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->mu_f, 1.0, "mu_f", "Fluid Dynamic Viscosity, Pa*s"));
16439566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->P_0, 1.0, "P_0", "Magnitude of Vertical Stress, Pa"));
164465876a83SMatthew G. Knepley } else {
164565876a83SMatthew G. Knepley // Nonsense values
16469566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->mu, 1.0, "mu", "Shear Modulus, Pa"));
16479566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->K_u, 1.0, "K_u", "Undrained Bulk Modulus, Pa"));
16489566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->alpha, 1.0, "alpha", "Biot Effective Stress Coefficient, -"));
16499566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->M, 1.0, "M", "Biot Modulus, Pa"));
16509566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->k, 1.0, "k", "Isotropic Permeability, m**2"));
16519566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->mu_f, 1.0, "mu_f", "Fluid Dynamic Viscosity, Pa*s"));
16529566063dSJacob Faibussowitsch PetscCall(PetscBagRegisterScalar(bag, &p->P_0, 1.0, "P_0", "Magnitude of Vertical Stress, Pa"));
165365876a83SMatthew G. Knepley }
16549566063dSJacob Faibussowitsch PetscCall(PetscBagSetFromOptions(bag));
165565876a83SMatthew G. Knepley {
165665876a83SMatthew G. Knepley PetscScalar K_d = p->K_u - p->alpha * p->alpha * p->M;
165765876a83SMatthew G. Knepley PetscScalar nu_u = (3.0 * p->K_u - 2.0 * p->mu) / (2.0 * (3.0 * p->K_u + p->mu));
165865876a83SMatthew G. Knepley PetscScalar nu = (3.0 * K_d - 2.0 * p->mu) / (2.0 * (3.0 * K_d + p->mu));
165965876a83SMatthew G. Knepley PetscScalar S = (3.0 * p->K_u + 4.0 * p->mu) / (p->M * (3.0 * K_d + 4.0 * p->mu));
166065876a83SMatthew G. Knepley PetscReal c = PetscRealPart((p->k / p->mu_f) / S);
166165876a83SMatthew G. Knepley
166265876a83SMatthew G. Knepley PetscViewer viewer;
166365876a83SMatthew G. Knepley PetscViewerFormat format;
166465876a83SMatthew G. Knepley PetscBool flg;
166565876a83SMatthew G. Knepley
166665876a83SMatthew G. Knepley switch (ctx->solType) {
166765876a83SMatthew G. Knepley case SOL_QUADRATIC_LINEAR:
166865876a83SMatthew G. Knepley case SOL_QUADRATIC_TRIG:
1669d71ae5a4SJacob Faibussowitsch case SOL_TRIG_LINEAR:
1670d71ae5a4SJacob Faibussowitsch ctx->t_r = PetscSqr(ctx->xmax[0] - ctx->xmin[0]) / c;
1671d71ae5a4SJacob Faibussowitsch break;
1672d71ae5a4SJacob Faibussowitsch case SOL_TERZAGHI:
1673d71ae5a4SJacob Faibussowitsch ctx->t_r = PetscSqr(2.0 * (ctx->xmax[1] - ctx->xmin[1])) / c;
1674d71ae5a4SJacob Faibussowitsch break;
1675d71ae5a4SJacob Faibussowitsch case SOL_MANDEL:
1676d71ae5a4SJacob Faibussowitsch ctx->t_r = PetscSqr(2.0 * (ctx->xmax[1] - ctx->xmin[1])) / c;
1677d71ae5a4SJacob Faibussowitsch break;
1678d71ae5a4SJacob Faibussowitsch case SOL_CRYER:
1679d71ae5a4SJacob Faibussowitsch ctx->t_r = PetscSqr(ctx->xmax[1]) / c;
1680d71ae5a4SJacob Faibussowitsch break;
1681d71ae5a4SJacob Faibussowitsch default:
1682d71ae5a4SJacob Faibussowitsch SETERRQ(comm, PETSC_ERR_ARG_WRONG, "Invalid solution type: %s (%d)", solutionTypes[PetscMin(ctx->solType, NUM_SOLUTION_TYPES)], ctx->solType);
168365876a83SMatthew G. Knepley }
1684648c30bcSBarry Smith PetscCall(PetscOptionsCreateViewer(comm, NULL, NULL, "-param_view", &viewer, &format, &flg));
168565876a83SMatthew G. Knepley if (flg) {
16869566063dSJacob Faibussowitsch PetscCall(PetscViewerPushFormat(viewer, format));
16879566063dSJacob Faibussowitsch PetscCall(PetscBagView(bag, viewer));
16889566063dSJacob Faibussowitsch PetscCall(PetscViewerFlush(viewer));
16899566063dSJacob Faibussowitsch PetscCall(PetscViewerPopFormat(viewer));
1690648c30bcSBarry Smith PetscCall(PetscViewerDestroy(&viewer));
1691300f1712SStefano Zampini PetscCall(PetscPrintf(comm, " Max displacement: %g %g\n", (double)PetscRealPart(p->P_0 * (ctx->xmax[1] - ctx->xmin[1]) * (1 - 2 * nu_u) / (2 * p->mu * (1 - nu_u))), (double)PetscRealPart(p->P_0 * (ctx->xmax[1] - ctx->xmin[1]) * (1 - 2 * nu) / (2 * p->mu * (1 - nu)))));
169263a3b9bcSJacob Faibussowitsch PetscCall(PetscPrintf(comm, " Relaxation time: %g\n", (double)ctx->t_r));
169365876a83SMatthew G. Knepley }
169465876a83SMatthew G. Knepley }
16953ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
169665876a83SMatthew G. Knepley }
169765876a83SMatthew G. Knepley
CreateMesh(MPI_Comm comm,AppCtx * user,DM * dm)1698d71ae5a4SJacob Faibussowitsch static PetscErrorCode CreateMesh(MPI_Comm comm, AppCtx *user, DM *dm)
1699d71ae5a4SJacob Faibussowitsch {
170065876a83SMatthew G. Knepley PetscFunctionBeginUser;
17019566063dSJacob Faibussowitsch PetscCall(DMCreate(comm, dm));
17029566063dSJacob Faibussowitsch PetscCall(DMSetType(*dm, DMPLEX));
17039566063dSJacob Faibussowitsch PetscCall(DMSetFromOptions(*dm));
17049566063dSJacob Faibussowitsch PetscCall(DMSetApplicationContext(*dm, user));
17059566063dSJacob Faibussowitsch PetscCall(DMViewFromOptions(*dm, NULL, "-dm_view"));
17069566063dSJacob Faibussowitsch PetscCall(DMGetBoundingBox(*dm, user->xmin, user->xmax));
17073ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
170865876a83SMatthew G. Knepley }
170965876a83SMatthew G. Knepley
SetupPrimalProblem(DM dm,AppCtx * user)1710d71ae5a4SJacob Faibussowitsch static PetscErrorCode SetupPrimalProblem(DM dm, AppCtx *user)
1711d71ae5a4SJacob Faibussowitsch {
171265876a83SMatthew G. Knepley PetscErrorCode (*exact[3])(PetscInt, PetscReal, const PetscReal[], PetscInt, PetscScalar *, void *);
171365876a83SMatthew G. Knepley PetscErrorCode (*exact_t[3])(PetscInt, PetscReal, const PetscReal[], PetscInt, PetscScalar *, void *);
171445480ffeSMatthew G. Knepley PetscDS ds;
171545480ffeSMatthew G. Knepley DMLabel label;
171645480ffeSMatthew G. Knepley PetscWeakForm wf;
171765876a83SMatthew G. Knepley Parameter *param;
171865876a83SMatthew G. Knepley PetscInt id_mandel[2];
171965876a83SMatthew G. Knepley PetscInt comp[1];
172065876a83SMatthew G. Knepley PetscInt comp_mandel[2];
172145480ffeSMatthew G. Knepley PetscInt dim, id, bd, f;
172265876a83SMatthew G. Knepley
172365876a83SMatthew G. Knepley PetscFunctionBeginUser;
17249566063dSJacob Faibussowitsch PetscCall(DMGetLabel(dm, "marker", &label));
17259566063dSJacob Faibussowitsch PetscCall(DMGetDS(dm, &ds));
17269566063dSJacob Faibussowitsch PetscCall(PetscDSGetSpatialDimension(ds, &dim));
1727*2a8381b2SBarry Smith PetscCall(PetscBagGetData(user->bag, ¶m));
172865876a83SMatthew G. Knepley exact_t[0] = exact_t[1] = exact_t[2] = zero;
172965876a83SMatthew G. Knepley
173065876a83SMatthew G. Knepley /* Setup Problem Formulation and Boundary Conditions */
173165876a83SMatthew G. Knepley switch (user->solType) {
173265876a83SMatthew G. Knepley case SOL_QUADRATIC_LINEAR:
17339566063dSJacob Faibussowitsch PetscCall(PetscDSSetResidual(ds, 0, f0_quadratic_linear_u, f1_u));
17349566063dSJacob Faibussowitsch PetscCall(PetscDSSetResidual(ds, 1, f0_epsilon, NULL));
17359566063dSJacob Faibussowitsch PetscCall(PetscDSSetResidual(ds, 2, f0_quadratic_linear_p, f1_p));
17369566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 0, 0, NULL, NULL, NULL, g3_uu));
17379566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 0, 1, NULL, NULL, g2_ue, NULL));
17389566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 0, 2, NULL, NULL, g2_up, NULL));
17399566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 1, 0, NULL, g1_eu, NULL, NULL));
17409566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 1, 1, g0_ee, NULL, NULL, NULL));
17419566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 2, 1, g0_pe, NULL, NULL, NULL));
17429566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 2, 2, g0_pp, NULL, NULL, g3_pp));
174365876a83SMatthew G. Knepley exact[0] = quadratic_u;
174465876a83SMatthew G. Knepley exact[1] = linear_eps;
174565876a83SMatthew G. Knepley exact[2] = linear_linear_p;
174665876a83SMatthew G. Knepley exact_t[2] = linear_linear_p_t;
174765876a83SMatthew G. Knepley
174865876a83SMatthew G. Knepley id = 1;
174957d50842SBarry Smith PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "wall displacement", label, 1, &id, 0, 0, NULL, (PetscVoidFn *)exact[0], NULL, user, NULL));
175057d50842SBarry Smith PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "wall pressure", label, 1, &id, 2, 0, NULL, (PetscVoidFn *)exact[2], (PetscVoidFn *)exact_t[2], user, NULL));
175165876a83SMatthew G. Knepley break;
175265876a83SMatthew G. Knepley case SOL_TRIG_LINEAR:
17539566063dSJacob Faibussowitsch PetscCall(PetscDSSetResidual(ds, 0, f0_trig_linear_u, f1_u));
17549566063dSJacob Faibussowitsch PetscCall(PetscDSSetResidual(ds, 1, f0_epsilon, NULL));
17559566063dSJacob Faibussowitsch PetscCall(PetscDSSetResidual(ds, 2, f0_trig_linear_p, f1_p));
17569566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 0, 0, NULL, NULL, NULL, g3_uu));
17579566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 0, 1, NULL, NULL, g2_ue, NULL));
17589566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 0, 2, NULL, NULL, g2_up, NULL));
17599566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 1, 0, NULL, g1_eu, NULL, NULL));
17609566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 1, 1, g0_ee, NULL, NULL, NULL));
17619566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 2, 1, g0_pe, NULL, NULL, NULL));
17629566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 2, 2, g0_pp, NULL, NULL, g3_pp));
176365876a83SMatthew G. Knepley exact[0] = trig_u;
176465876a83SMatthew G. Knepley exact[1] = trig_eps;
176565876a83SMatthew G. Knepley exact[2] = trig_linear_p;
176665876a83SMatthew G. Knepley exact_t[2] = trig_linear_p_t;
176765876a83SMatthew G. Knepley
176865876a83SMatthew G. Knepley id = 1;
176957d50842SBarry Smith PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "wall displacement", label, 1, &id, 0, 0, NULL, (PetscVoidFn *)exact[0], NULL, user, NULL));
177057d50842SBarry Smith PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "wall pressure", label, 1, &id, 2, 0, NULL, (PetscVoidFn *)exact[2], (PetscVoidFn *)exact_t[2], user, NULL));
177165876a83SMatthew G. Knepley break;
177265876a83SMatthew G. Knepley case SOL_QUADRATIC_TRIG:
17739566063dSJacob Faibussowitsch PetscCall(PetscDSSetResidual(ds, 0, f0_quadratic_trig_u, f1_u));
17749566063dSJacob Faibussowitsch PetscCall(PetscDSSetResidual(ds, 1, f0_epsilon, NULL));
17759566063dSJacob Faibussowitsch PetscCall(PetscDSSetResidual(ds, 2, f0_quadratic_trig_p, f1_p));
17769566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 0, 0, NULL, NULL, NULL, g3_uu));
17779566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 0, 1, NULL, NULL, g2_ue, NULL));
17789566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 0, 2, NULL, NULL, g2_up, NULL));
17799566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 1, 0, NULL, g1_eu, NULL, NULL));
17809566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 1, 1, g0_ee, NULL, NULL, NULL));
17819566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 2, 1, g0_pe, NULL, NULL, NULL));
17829566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 2, 2, g0_pp, NULL, NULL, g3_pp));
178365876a83SMatthew G. Knepley exact[0] = quadratic_u;
178465876a83SMatthew G. Knepley exact[1] = linear_eps;
178565876a83SMatthew G. Knepley exact[2] = linear_trig_p;
178665876a83SMatthew G. Knepley exact_t[2] = linear_trig_p_t;
178765876a83SMatthew G. Knepley
178865876a83SMatthew G. Knepley id = 1;
178957d50842SBarry Smith PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "wall displacement", label, 1, &id, 0, 0, NULL, (PetscVoidFn *)exact[0], NULL, user, NULL));
179057d50842SBarry Smith PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "wall pressure", label, 1, &id, 2, 0, NULL, (PetscVoidFn *)exact[2], (PetscVoidFn *)exact_t[2], user, NULL));
179165876a83SMatthew G. Knepley break;
179265876a83SMatthew G. Knepley case SOL_TERZAGHI:
17939566063dSJacob Faibussowitsch PetscCall(PetscDSSetResidual(ds, 0, NULL, f1_u));
17949566063dSJacob Faibussowitsch PetscCall(PetscDSSetResidual(ds, 1, f0_epsilon, NULL));
17959566063dSJacob Faibussowitsch PetscCall(PetscDSSetResidual(ds, 2, f0_p, f1_p));
17969566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 0, 0, NULL, NULL, NULL, g3_uu));
17979566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 0, 1, NULL, NULL, g2_ue, NULL));
17989566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 0, 2, NULL, NULL, g2_up, NULL));
17999566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 1, 0, NULL, g1_eu, NULL, NULL));
18009566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 1, 1, g0_ee, NULL, NULL, NULL));
18019566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 2, 1, g0_pe, NULL, NULL, NULL));
18029566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 2, 2, g0_pp, NULL, NULL, g3_pp));
180365876a83SMatthew G. Knepley
180465876a83SMatthew G. Knepley exact[0] = terzaghi_2d_u;
180565876a83SMatthew G. Knepley exact[1] = terzaghi_2d_eps;
180665876a83SMatthew G. Knepley exact[2] = terzaghi_2d_p;
180765876a83SMatthew G. Knepley exact_t[0] = terzaghi_2d_u_t;
180865876a83SMatthew G. Knepley exact_t[1] = terzaghi_2d_eps_t;
180965876a83SMatthew G. Knepley exact_t[2] = terzaghi_2d_p_t;
181065876a83SMatthew G. Knepley
181165876a83SMatthew G. Knepley id = 1;
18129566063dSJacob Faibussowitsch PetscCall(DMAddBoundary(dm, DM_BC_NATURAL, "vertical stress", label, 1, &id, 0, 0, NULL, NULL, NULL, user, &bd));
18139566063dSJacob Faibussowitsch PetscCall(PetscDSGetBoundary(ds, bd, &wf, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL));
18149566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexBdResidual(wf, label, id, 0, 0, 0, f0_terzaghi_bd_u, 0, NULL));
181545480ffeSMatthew G. Knepley
181665876a83SMatthew G. Knepley id = 3;
181765876a83SMatthew G. Knepley comp[0] = 1;
181857d50842SBarry Smith PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "fixed base", label, 1, &id, 0, 1, comp, (PetscVoidFn *)zero, NULL, user, NULL));
181965876a83SMatthew G. Knepley id = 2;
182065876a83SMatthew G. Knepley comp[0] = 0;
182157d50842SBarry Smith PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "fixed side", label, 1, &id, 0, 1, comp, (PetscVoidFn *)zero, NULL, user, NULL));
182265876a83SMatthew G. Knepley id = 4;
182365876a83SMatthew G. Knepley comp[0] = 0;
182457d50842SBarry Smith PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "fixed side", label, 1, &id, 0, 1, comp, (PetscVoidFn *)zero, NULL, user, NULL));
182565876a83SMatthew G. Knepley id = 1;
182657d50842SBarry Smith PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "drained surface", label, 1, &id, 2, 0, NULL, (PetscVoidFn *)terzaghi_drainage_pressure, NULL, user, NULL));
182765876a83SMatthew G. Knepley break;
182865876a83SMatthew G. Knepley case SOL_MANDEL:
18299566063dSJacob Faibussowitsch PetscCall(PetscDSSetResidual(ds, 0, NULL, f1_u));
18309566063dSJacob Faibussowitsch PetscCall(PetscDSSetResidual(ds, 1, f0_epsilon, NULL));
18319566063dSJacob Faibussowitsch PetscCall(PetscDSSetResidual(ds, 2, f0_p, f1_p));
18329566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 0, 0, NULL, NULL, NULL, g3_uu));
18339566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 0, 1, NULL, NULL, g2_ue, NULL));
18349566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 0, 2, NULL, NULL, g2_up, NULL));
18359566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 1, 0, NULL, g1_eu, NULL, NULL));
18369566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 1, 1, g0_ee, NULL, NULL, NULL));
18379566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 2, 1, g0_pe, NULL, NULL, NULL));
18389566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 2, 2, g0_pp, NULL, NULL, g3_pp));
183965876a83SMatthew G. Knepley
18409566063dSJacob Faibussowitsch PetscCall(mandelZeros(PETSC_COMM_WORLD, user, param));
184165876a83SMatthew G. Knepley
184265876a83SMatthew G. Knepley exact[0] = mandel_2d_u;
184365876a83SMatthew G. Knepley exact[1] = mandel_2d_eps;
184465876a83SMatthew G. Knepley exact[2] = mandel_2d_p;
184565876a83SMatthew G. Knepley exact_t[0] = mandel_2d_u_t;
184665876a83SMatthew G. Knepley exact_t[1] = mandel_2d_eps_t;
184765876a83SMatthew G. Knepley exact_t[2] = mandel_2d_p_t;
184865876a83SMatthew G. Knepley
184965876a83SMatthew G. Knepley id_mandel[0] = 3;
185065876a83SMatthew G. Knepley id_mandel[1] = 1;
185165876a83SMatthew G. Knepley //comp[0] = 1;
185265876a83SMatthew G. Knepley comp_mandel[0] = 0;
185365876a83SMatthew G. Knepley comp_mandel[1] = 1;
185457d50842SBarry Smith PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "vertical stress", label, 2, id_mandel, 0, 2, comp_mandel, (PetscVoidFn *)mandel_2d_u, NULL, user, NULL));
18559566063dSJacob Faibussowitsch //PetscCall(DMAddBoundary(dm, DM_BC_NATURAL, "vertical stress", "marker", 0, 1, comp, NULL, 2, id_mandel, user));
185657d50842SBarry Smith //PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "fixed base", "marker", 0, 1, comp, (PetscVoidFn *) zero, 2, id_mandel, user));
18579566063dSJacob Faibussowitsch //PetscCall(PetscDSSetBdResidual(ds, 0, f0_mandel_bd_u, NULL));
185865876a83SMatthew G. Knepley
185965876a83SMatthew G. Knepley id_mandel[0] = 2;
186065876a83SMatthew G. Knepley id_mandel[1] = 4;
186157d50842SBarry Smith PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "drained surface", label, 2, id_mandel, 2, 0, NULL, (PetscVoidFn *)zero, NULL, user, NULL));
186265876a83SMatthew G. Knepley break;
186365876a83SMatthew G. Knepley case SOL_CRYER:
18649566063dSJacob Faibussowitsch PetscCall(PetscDSSetResidual(ds, 0, NULL, f1_u));
18659566063dSJacob Faibussowitsch PetscCall(PetscDSSetResidual(ds, 1, f0_epsilon, NULL));
18669566063dSJacob Faibussowitsch PetscCall(PetscDSSetResidual(ds, 2, f0_p, f1_p));
18679566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 0, 0, NULL, NULL, NULL, g3_uu));
18689566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 0, 1, NULL, NULL, g2_ue, NULL));
18699566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 0, 2, NULL, NULL, g2_up, NULL));
18709566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 1, 0, NULL, g1_eu, NULL, NULL));
18719566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 1, 1, g0_ee, NULL, NULL, NULL));
18729566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 2, 1, g0_pe, NULL, NULL, NULL));
18739566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(ds, 2, 2, g0_pp, NULL, NULL, g3_pp));
187465876a83SMatthew G. Knepley
18759566063dSJacob Faibussowitsch PetscCall(cryerZeros(PETSC_COMM_WORLD, user, param));
187665876a83SMatthew G. Knepley
187765876a83SMatthew G. Knepley exact[0] = cryer_3d_u;
187865876a83SMatthew G. Knepley exact[1] = cryer_3d_eps;
187965876a83SMatthew G. Knepley exact[2] = cryer_3d_p;
188065876a83SMatthew G. Knepley
188165876a83SMatthew G. Knepley id = 1;
18829566063dSJacob Faibussowitsch PetscCall(DMAddBoundary(dm, DM_BC_NATURAL, "normal stress", label, 1, &id, 0, 0, NULL, NULL, NULL, user, &bd));
18839566063dSJacob Faibussowitsch PetscCall(PetscDSGetBoundary(ds, bd, &wf, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL));
18849566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexBdResidual(wf, label, id, 0, 0, 0, f0_cryer_bd_u, 0, NULL));
188545480ffeSMatthew G. Knepley
188657d50842SBarry Smith PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "drained surface", label, 1, &id, 2, 0, NULL, (PetscVoidFn *)cryer_drainage_pressure, NULL, user, NULL));
188765876a83SMatthew G. Knepley break;
1888d71ae5a4SJacob Faibussowitsch default:
1889d71ae5a4SJacob Faibussowitsch SETERRQ(PetscObjectComm((PetscObject)ds), PETSC_ERR_ARG_WRONG, "Invalid solution type: %s (%d)", solutionTypes[PetscMin(user->solType, NUM_SOLUTION_TYPES)], user->solType);
189065876a83SMatthew G. Knepley }
189165876a83SMatthew G. Knepley for (f = 0; f < 3; ++f) {
18929566063dSJacob Faibussowitsch PetscCall(PetscDSSetExactSolution(ds, f, exact[f], user));
18939566063dSJacob Faibussowitsch PetscCall(PetscDSSetExactSolutionTimeDerivative(ds, f, exact_t[f], user));
189465876a83SMatthew G. Knepley }
189565876a83SMatthew G. Knepley
189665876a83SMatthew G. Knepley /* Setup constants */
189765876a83SMatthew G. Knepley {
189865876a83SMatthew G. Knepley PetscScalar constants[6];
189965876a83SMatthew G. Knepley constants[0] = param->mu; /* shear modulus, Pa */
190065876a83SMatthew G. Knepley constants[1] = param->K_u; /* undrained bulk modulus, Pa */
190165876a83SMatthew G. Knepley constants[2] = param->alpha; /* Biot effective stress coefficient, - */
190265876a83SMatthew G. Knepley constants[3] = param->M; /* Biot modulus, Pa */
190365876a83SMatthew G. Knepley constants[4] = param->k / param->mu_f; /* Darcy coefficient, m**2 / Pa*s */
190465876a83SMatthew G. Knepley constants[5] = param->P_0; /* Magnitude of Vertical Stress, Pa */
19059566063dSJacob Faibussowitsch PetscCall(PetscDSSetConstants(ds, 6, constants));
190665876a83SMatthew G. Knepley }
19073ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
190865876a83SMatthew G. Knepley }
190965876a83SMatthew G. Knepley
CreateElasticityNullSpace(DM dm,PetscInt origField,PetscInt field,MatNullSpace * nullspace)1910d71ae5a4SJacob Faibussowitsch static PetscErrorCode CreateElasticityNullSpace(DM dm, PetscInt origField, PetscInt field, MatNullSpace *nullspace)
1911d71ae5a4SJacob Faibussowitsch {
19127510d9b0SBarry Smith PetscFunctionBeginUser;
19139566063dSJacob Faibussowitsch PetscCall(DMPlexCreateRigidBody(dm, origField, nullspace));
19143ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
191565876a83SMatthew G. Knepley }
191665876a83SMatthew G. Knepley
SetupFE(DM dm,PetscInt Nf,PetscInt Nc[],const char * name[],PetscErrorCode (* setup)(DM,AppCtx *),PetscCtx ctx)1917*2a8381b2SBarry Smith static PetscErrorCode SetupFE(DM dm, PetscInt Nf, PetscInt Nc[], const char *name[], PetscErrorCode (*setup)(DM, AppCtx *), PetscCtx ctx)
1918d71ae5a4SJacob Faibussowitsch {
191965876a83SMatthew G. Knepley AppCtx *user = (AppCtx *)ctx;
192065876a83SMatthew G. Knepley DM cdm = dm;
192165876a83SMatthew G. Knepley PetscFE fe;
19222456a0d3SMatthew G. Knepley PetscQuadrature q = NULL, fq = NULL;
192365876a83SMatthew G. Knepley char prefix[PETSC_MAX_PATH_LEN];
192465876a83SMatthew G. Knepley PetscInt dim, f;
192530602db0SMatthew G. Knepley PetscBool simplex;
192665876a83SMatthew G. Knepley
19277510d9b0SBarry Smith PetscFunctionBeginUser;
192865876a83SMatthew G. Knepley /* Create finite element */
19299566063dSJacob Faibussowitsch PetscCall(DMGetDimension(dm, &dim));
19309566063dSJacob Faibussowitsch PetscCall(DMPlexIsSimplex(dm, &simplex));
193165876a83SMatthew G. Knepley for (f = 0; f < Nf; ++f) {
19329566063dSJacob Faibussowitsch PetscCall(PetscSNPrintf(prefix, PETSC_MAX_PATH_LEN, "%s_", name[f]));
19339566063dSJacob Faibussowitsch PetscCall(PetscFECreateDefault(PETSC_COMM_SELF, dim, Nc[f], simplex, name[f] ? prefix : NULL, -1, &fe));
19349566063dSJacob Faibussowitsch PetscCall(PetscObjectSetName((PetscObject)fe, name[f]));
19359566063dSJacob Faibussowitsch if (!q) PetscCall(PetscFEGetQuadrature(fe, &q));
19362456a0d3SMatthew G. Knepley if (!fq) PetscCall(PetscFEGetFaceQuadrature(fe, &fq));
19379566063dSJacob Faibussowitsch PetscCall(PetscFESetQuadrature(fe, q));
19382456a0d3SMatthew G. Knepley PetscCall(PetscFESetFaceQuadrature(fe, fq));
19399566063dSJacob Faibussowitsch PetscCall(DMSetField(dm, f, NULL, (PetscObject)fe));
19409566063dSJacob Faibussowitsch PetscCall(PetscFEDestroy(&fe));
194165876a83SMatthew G. Knepley }
19429566063dSJacob Faibussowitsch PetscCall(DMCreateDS(dm));
19439566063dSJacob Faibussowitsch PetscCall((*setup)(dm, user));
194465876a83SMatthew G. Knepley while (cdm) {
19459566063dSJacob Faibussowitsch PetscCall(DMCopyDisc(dm, cdm));
19469566063dSJacob Faibussowitsch if (0) PetscCall(DMSetNearNullSpaceConstructor(cdm, 0, CreateElasticityNullSpace));
194765876a83SMatthew G. Knepley /* TODO: Check whether the boundary of coarse meshes is marked */
19489566063dSJacob Faibussowitsch PetscCall(DMGetCoarseDM(cdm, &cdm));
194965876a83SMatthew G. Knepley }
19509566063dSJacob Faibussowitsch PetscCall(PetscFEDestroy(&fe));
19513ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
195265876a83SMatthew G. Knepley }
195365876a83SMatthew G. Knepley
SetInitialConditions(TS ts,Vec u)1954d71ae5a4SJacob Faibussowitsch static PetscErrorCode SetInitialConditions(TS ts, Vec u)
1955d71ae5a4SJacob Faibussowitsch {
195665876a83SMatthew G. Knepley DM dm;
195765876a83SMatthew G. Knepley PetscReal t;
195865876a83SMatthew G. Knepley
19597510d9b0SBarry Smith PetscFunctionBeginUser;
19609566063dSJacob Faibussowitsch PetscCall(TSGetDM(ts, &dm));
19619566063dSJacob Faibussowitsch PetscCall(TSGetTime(ts, &t));
196265876a83SMatthew G. Knepley if (t <= 0.0) {
196365876a83SMatthew G. Knepley PetscErrorCode (*funcs[3])(PetscInt, PetscReal, const PetscReal[], PetscInt, PetscScalar *, void *);
196465876a83SMatthew G. Knepley void *ctxs[3];
196565876a83SMatthew G. Knepley AppCtx *ctx;
196665876a83SMatthew G. Knepley
19679566063dSJacob Faibussowitsch PetscCall(DMGetApplicationContext(dm, &ctx));
196865876a83SMatthew G. Knepley switch (ctx->solType) {
196965876a83SMatthew G. Knepley case SOL_TERZAGHI:
19709371c9d4SSatish Balay funcs[0] = terzaghi_initial_u;
19719371c9d4SSatish Balay ctxs[0] = ctx;
19729371c9d4SSatish Balay funcs[1] = terzaghi_initial_eps;
19739371c9d4SSatish Balay ctxs[1] = ctx;
19749371c9d4SSatish Balay funcs[2] = terzaghi_drainage_pressure;
19759371c9d4SSatish Balay ctxs[2] = ctx;
19769566063dSJacob Faibussowitsch PetscCall(DMProjectFunction(dm, t, funcs, ctxs, INSERT_VALUES, u));
197765876a83SMatthew G. Knepley break;
197865876a83SMatthew G. Knepley case SOL_MANDEL:
19799371c9d4SSatish Balay funcs[0] = mandel_initial_u;
19809371c9d4SSatish Balay ctxs[0] = ctx;
19819371c9d4SSatish Balay funcs[1] = mandel_initial_eps;
19829371c9d4SSatish Balay ctxs[1] = ctx;
19839371c9d4SSatish Balay funcs[2] = mandel_drainage_pressure;
19849371c9d4SSatish Balay ctxs[2] = ctx;
19859566063dSJacob Faibussowitsch PetscCall(DMProjectFunction(dm, t, funcs, ctxs, INSERT_VALUES, u));
198665876a83SMatthew G. Knepley break;
198765876a83SMatthew G. Knepley case SOL_CRYER:
19889371c9d4SSatish Balay funcs[0] = cryer_initial_u;
19899371c9d4SSatish Balay ctxs[0] = ctx;
19909371c9d4SSatish Balay funcs[1] = cryer_initial_eps;
19919371c9d4SSatish Balay ctxs[1] = ctx;
19929371c9d4SSatish Balay funcs[2] = cryer_drainage_pressure;
19939371c9d4SSatish Balay ctxs[2] = ctx;
19949566063dSJacob Faibussowitsch PetscCall(DMProjectFunction(dm, t, funcs, ctxs, INSERT_VALUES, u));
199565876a83SMatthew G. Knepley break;
1996d71ae5a4SJacob Faibussowitsch default:
1997d71ae5a4SJacob Faibussowitsch PetscCall(DMComputeExactSolution(dm, t, u, NULL));
199865876a83SMatthew G. Knepley }
199965876a83SMatthew G. Knepley } else {
20009566063dSJacob Faibussowitsch PetscCall(DMComputeExactSolution(dm, t, u, NULL));
200165876a83SMatthew G. Knepley }
20023ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
200365876a83SMatthew G. Knepley }
200465876a83SMatthew G. Knepley
200565876a83SMatthew G. Knepley /* Need to create Viewer each time because HDF5 can get corrupted */
SolutionMonitor(TS ts,PetscInt steps,PetscReal time,Vec u,void * mctx)2006d71ae5a4SJacob Faibussowitsch static PetscErrorCode SolutionMonitor(TS ts, PetscInt steps, PetscReal time, Vec u, void *mctx)
2007d71ae5a4SJacob Faibussowitsch {
200865876a83SMatthew G. Knepley DM dm;
200965876a83SMatthew G. Knepley Vec exact;
201065876a83SMatthew G. Knepley PetscViewer viewer;
201165876a83SMatthew G. Knepley PetscViewerFormat format;
201265876a83SMatthew G. Knepley PetscOptions options;
201365876a83SMatthew G. Knepley const char *prefix;
201465876a83SMatthew G. Knepley
20157510d9b0SBarry Smith PetscFunctionBeginUser;
20169566063dSJacob Faibussowitsch PetscCall(TSGetDM(ts, &dm));
20179566063dSJacob Faibussowitsch PetscCall(PetscObjectGetOptions((PetscObject)ts, &options));
20189566063dSJacob Faibussowitsch PetscCall(PetscObjectGetOptionsPrefix((PetscObject)ts, &prefix));
2019648c30bcSBarry Smith PetscCall(PetscOptionsCreateViewer(PetscObjectComm((PetscObject)ts), options, prefix, "-monitor_solution", &viewer, &format, NULL));
20209566063dSJacob Faibussowitsch PetscCall(DMGetGlobalVector(dm, &exact));
20219566063dSJacob Faibussowitsch PetscCall(DMComputeExactSolution(dm, time, exact, NULL));
20229566063dSJacob Faibussowitsch PetscCall(DMSetOutputSequenceNumber(dm, steps, time));
20239566063dSJacob Faibussowitsch PetscCall(VecView(exact, viewer));
20249566063dSJacob Faibussowitsch PetscCall(VecView(u, viewer));
20259566063dSJacob Faibussowitsch PetscCall(DMRestoreGlobalVector(dm, &exact));
202665876a83SMatthew G. Knepley {
2027*2a8381b2SBarry Smith PetscErrorCode (**exacts)(PetscInt, PetscReal, const PetscReal x[], PetscInt, PetscScalar *u, PetscCtx ctx);
202865876a83SMatthew G. Knepley void **ectxs;
202965876a83SMatthew G. Knepley PetscReal *err;
203065876a83SMatthew G. Knepley PetscInt Nf, f;
203165876a83SMatthew G. Knepley
20329566063dSJacob Faibussowitsch PetscCall(DMGetNumFields(dm, &Nf));
20339566063dSJacob Faibussowitsch PetscCall(PetscCalloc3(Nf, &exacts, Nf, &ectxs, PetscMax(1, Nf), &err));
203465876a83SMatthew G. Knepley {
203565876a83SMatthew G. Knepley PetscInt Nds, s;
203665876a83SMatthew G. Knepley
20379566063dSJacob Faibussowitsch PetscCall(DMGetNumDS(dm, &Nds));
203865876a83SMatthew G. Knepley for (s = 0; s < Nds; ++s) {
203965876a83SMatthew G. Knepley PetscDS ds;
204065876a83SMatthew G. Knepley DMLabel label;
204165876a83SMatthew G. Knepley IS fieldIS;
204265876a83SMatthew G. Knepley const PetscInt *fields;
204365876a83SMatthew G. Knepley PetscInt dsNf, f;
204465876a83SMatthew G. Knepley
204507218a29SMatthew G. Knepley PetscCall(DMGetRegionNumDS(dm, s, &label, &fieldIS, &ds, NULL));
20469566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(ds, &dsNf));
20479566063dSJacob Faibussowitsch PetscCall(ISGetIndices(fieldIS, &fields));
204865876a83SMatthew G. Knepley for (f = 0; f < dsNf; ++f) {
204965876a83SMatthew G. Knepley const PetscInt field = fields[f];
20509566063dSJacob Faibussowitsch PetscCall(PetscDSGetExactSolution(ds, field, &exacts[field], &ectxs[field]));
205165876a83SMatthew G. Knepley }
20529566063dSJacob Faibussowitsch PetscCall(ISRestoreIndices(fieldIS, &fields));
205365876a83SMatthew G. Knepley }
205465876a83SMatthew G. Knepley }
20559566063dSJacob Faibussowitsch PetscCall(DMComputeL2FieldDiff(dm, time, exacts, ectxs, u, err));
205663a3b9bcSJacob Faibussowitsch PetscCall(PetscPrintf(PetscObjectComm((PetscObject)ts), "Time: %g L_2 Error: [", (double)time));
205765876a83SMatthew G. Knepley for (f = 0; f < Nf; ++f) {
20589566063dSJacob Faibussowitsch if (f) PetscCall(PetscPrintf(PetscObjectComm((PetscObject)ts), ", "));
20599566063dSJacob Faibussowitsch PetscCall(PetscPrintf(PetscObjectComm((PetscObject)ts), "%g", (double)err[f]));
206065876a83SMatthew G. Knepley }
20619566063dSJacob Faibussowitsch PetscCall(PetscPrintf(PetscObjectComm((PetscObject)ts), "]\n"));
20629566063dSJacob Faibussowitsch PetscCall(PetscFree3(exacts, ectxs, err));
206365876a83SMatthew G. Knepley }
2064648c30bcSBarry Smith PetscCall(PetscViewerDestroy(&viewer));
20653ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
206665876a83SMatthew G. Knepley }
206765876a83SMatthew G. Knepley
SetupMonitor(TS ts,AppCtx * ctx)2068d71ae5a4SJacob Faibussowitsch static PetscErrorCode SetupMonitor(TS ts, AppCtx *ctx)
2069d71ae5a4SJacob Faibussowitsch {
207065876a83SMatthew G. Knepley PetscViewer viewer;
207165876a83SMatthew G. Knepley PetscViewerFormat format;
207265876a83SMatthew G. Knepley PetscOptions options;
207365876a83SMatthew G. Knepley const char *prefix;
207465876a83SMatthew G. Knepley PetscBool flg;
207565876a83SMatthew G. Knepley
20767510d9b0SBarry Smith PetscFunctionBeginUser;
20779566063dSJacob Faibussowitsch PetscCall(PetscObjectGetOptions((PetscObject)ts, &options));
20789566063dSJacob Faibussowitsch PetscCall(PetscObjectGetOptionsPrefix((PetscObject)ts, &prefix));
2079648c30bcSBarry Smith PetscCall(PetscOptionsCreateViewer(PetscObjectComm((PetscObject)ts), options, prefix, "-monitor_solution", &viewer, &format, &flg));
20809566063dSJacob Faibussowitsch if (flg) PetscCall(TSMonitorSet(ts, SolutionMonitor, ctx, NULL));
2081648c30bcSBarry Smith PetscCall(PetscViewerDestroy(&viewer));
20823ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
208365876a83SMatthew G. Knepley }
208465876a83SMatthew G. Knepley
TSAdaptChoose_Terzaghi(TSAdapt adapt,TS ts,PetscReal h,PetscInt * next_sc,PetscReal * next_h,PetscBool * accept,PetscReal * wlte,PetscReal * wltea,PetscReal * wlter)2085d71ae5a4SJacob Faibussowitsch static PetscErrorCode TSAdaptChoose_Terzaghi(TSAdapt adapt, TS ts, PetscReal h, PetscInt *next_sc, PetscReal *next_h, PetscBool *accept, PetscReal *wlte, PetscReal *wltea, PetscReal *wlter)
2086d71ae5a4SJacob Faibussowitsch {
208765876a83SMatthew G. Knepley static PetscReal dtTarget = -1.0;
208865876a83SMatthew G. Knepley PetscReal dtInitial;
208965876a83SMatthew G. Knepley DM dm;
209065876a83SMatthew G. Knepley AppCtx *ctx;
209165876a83SMatthew G. Knepley PetscInt step;
209265876a83SMatthew G. Knepley
20937510d9b0SBarry Smith PetscFunctionBeginUser;
20949566063dSJacob Faibussowitsch PetscCall(TSGetDM(ts, &dm));
20959566063dSJacob Faibussowitsch PetscCall(DMGetApplicationContext(dm, &ctx));
20969566063dSJacob Faibussowitsch PetscCall(TSGetStepNumber(ts, &step));
209724b15d09SMatthew G. Knepley dtInitial = ctx->dtInitial < 0.0 ? 1.0e-4 * ctx->t_r : ctx->dtInitial;
209865876a83SMatthew G. Knepley if (!step) {
209965876a83SMatthew G. Knepley if (PetscAbsReal(dtInitial - h) > PETSC_SMALL) {
210065876a83SMatthew G. Knepley *accept = PETSC_FALSE;
210165876a83SMatthew G. Knepley *next_h = dtInitial;
210265876a83SMatthew G. Knepley dtTarget = h;
210365876a83SMatthew G. Knepley } else {
210465876a83SMatthew G. Knepley *accept = PETSC_TRUE;
210565876a83SMatthew G. Knepley *next_h = dtTarget < 0.0 ? dtInitial : dtTarget;
210665876a83SMatthew G. Knepley dtTarget = -1.0;
210765876a83SMatthew G. Knepley }
210865876a83SMatthew G. Knepley } else {
210965876a83SMatthew G. Knepley *accept = PETSC_TRUE;
211065876a83SMatthew G. Knepley *next_h = h;
211165876a83SMatthew G. Knepley }
211265876a83SMatthew G. Knepley *next_sc = 0; /* Reuse the same order scheme */
211365876a83SMatthew G. Knepley *wlte = -1; /* Weighted local truncation error was not evaluated */
211465876a83SMatthew G. Knepley *wltea = -1; /* Weighted absolute local truncation error was not evaluated */
211565876a83SMatthew G. Knepley *wlter = -1; /* Weighted relative local truncation error was not evaluated */
21163ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
211765876a83SMatthew G. Knepley }
211865876a83SMatthew G. Knepley
main(int argc,char ** argv)2119d71ae5a4SJacob Faibussowitsch int main(int argc, char **argv)
2120d71ae5a4SJacob Faibussowitsch {
212165876a83SMatthew G. Knepley AppCtx ctx; /* User-defined work context */
212265876a83SMatthew G. Knepley DM dm; /* Problem specification */
212365876a83SMatthew G. Knepley TS ts; /* Time Series / Nonlinear solver */
212465876a83SMatthew G. Knepley Vec u; /* Solutions */
212565876a83SMatthew G. Knepley const char *name[3] = {"displacement", "tracestrain", "pressure"};
212665876a83SMatthew G. Knepley PetscReal t;
212730602db0SMatthew G. Knepley PetscInt dim, Nc[3];
212865876a83SMatthew G. Knepley
2129327415f7SBarry Smith PetscFunctionBeginUser;
21309566063dSJacob Faibussowitsch PetscCall(PetscInitialize(&argc, &argv, NULL, help));
21319566063dSJacob Faibussowitsch PetscCall(ProcessOptions(PETSC_COMM_WORLD, &ctx));
21329566063dSJacob Faibussowitsch PetscCall(PetscBagCreate(PETSC_COMM_SELF, sizeof(Parameter), &ctx.bag));
21339566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(ctx.niter, &ctx.zeroArray));
21349566063dSJacob Faibussowitsch PetscCall(CreateMesh(PETSC_COMM_WORLD, &ctx, &dm));
21359566063dSJacob Faibussowitsch PetscCall(SetupParameters(PETSC_COMM_WORLD, &ctx));
213665876a83SMatthew G. Knepley /* Primal System */
21379566063dSJacob Faibussowitsch PetscCall(TSCreate(PETSC_COMM_WORLD, &ts));
21389566063dSJacob Faibussowitsch PetscCall(DMSetApplicationContext(dm, &ctx));
21399566063dSJacob Faibussowitsch PetscCall(TSSetDM(ts, dm));
214065876a83SMatthew G. Knepley
21419566063dSJacob Faibussowitsch PetscCall(DMGetDimension(dm, &dim));
214230602db0SMatthew G. Knepley Nc[0] = dim;
214365876a83SMatthew G. Knepley Nc[1] = 1;
214465876a83SMatthew G. Knepley Nc[2] = 1;
214565876a83SMatthew G. Knepley
21469566063dSJacob Faibussowitsch PetscCall(SetupFE(dm, 3, Nc, name, SetupPrimalProblem, &ctx));
21479566063dSJacob Faibussowitsch PetscCall(DMCreateGlobalVector(dm, &u));
21489566063dSJacob Faibussowitsch PetscCall(DMTSSetBoundaryLocal(dm, DMPlexTSComputeBoundary, &ctx));
21499566063dSJacob Faibussowitsch PetscCall(DMTSSetIFunctionLocal(dm, DMPlexTSComputeIFunctionFEM, &ctx));
21509566063dSJacob Faibussowitsch PetscCall(DMTSSetIJacobianLocal(dm, DMPlexTSComputeIJacobianFEM, &ctx));
21519566063dSJacob Faibussowitsch PetscCall(TSSetExactFinalTime(ts, TS_EXACTFINALTIME_MATCHSTEP));
21529566063dSJacob Faibussowitsch PetscCall(TSSetFromOptions(ts));
21539566063dSJacob Faibussowitsch PetscCall(TSSetComputeInitialCondition(ts, SetInitialConditions));
21549566063dSJacob Faibussowitsch PetscCall(SetupMonitor(ts, &ctx));
215565876a83SMatthew G. Knepley
215665876a83SMatthew G. Knepley if (ctx.solType != SOL_QUADRATIC_TRIG) {
215765876a83SMatthew G. Knepley TSAdapt adapt;
215865876a83SMatthew G. Knepley
21599566063dSJacob Faibussowitsch PetscCall(TSGetAdapt(ts, &adapt));
216065876a83SMatthew G. Knepley adapt->ops->choose = TSAdaptChoose_Terzaghi;
216165876a83SMatthew G. Knepley }
216265876a83SMatthew G. Knepley if (ctx.solType == SOL_CRYER) {
216365876a83SMatthew G. Knepley Mat J;
216465876a83SMatthew G. Knepley MatNullSpace sp;
216565876a83SMatthew G. Knepley
21669566063dSJacob Faibussowitsch PetscCall(TSSetUp(ts));
21679566063dSJacob Faibussowitsch PetscCall(TSGetIJacobian(ts, &J, NULL, NULL, NULL));
21689566063dSJacob Faibussowitsch PetscCall(DMPlexCreateRigidBody(dm, 0, &sp));
21699566063dSJacob Faibussowitsch PetscCall(MatSetNullSpace(J, sp));
21709566063dSJacob Faibussowitsch PetscCall(MatNullSpaceDestroy(&sp));
217165876a83SMatthew G. Knepley }
21729566063dSJacob Faibussowitsch PetscCall(TSGetTime(ts, &t));
21739566063dSJacob Faibussowitsch PetscCall(DMSetOutputSequenceNumber(dm, 0, t));
21749566063dSJacob Faibussowitsch PetscCall(DMTSCheckFromOptions(ts, u));
21759566063dSJacob Faibussowitsch PetscCall(SetInitialConditions(ts, u));
21769566063dSJacob Faibussowitsch PetscCall(PetscObjectSetName((PetscObject)u, "solution"));
21779566063dSJacob Faibussowitsch PetscCall(TSSolve(ts, u));
21789566063dSJacob Faibussowitsch PetscCall(DMTSCheckFromOptions(ts, u));
21799566063dSJacob Faibussowitsch PetscCall(TSGetSolution(ts, &u));
21809566063dSJacob Faibussowitsch PetscCall(VecViewFromOptions(u, NULL, "-sol_vec_view"));
218165876a83SMatthew G. Knepley
218265876a83SMatthew G. Knepley /* Cleanup */
21839566063dSJacob Faibussowitsch PetscCall(VecDestroy(&u));
21849566063dSJacob Faibussowitsch PetscCall(TSDestroy(&ts));
21859566063dSJacob Faibussowitsch PetscCall(DMDestroy(&dm));
21869566063dSJacob Faibussowitsch PetscCall(PetscBagDestroy(&ctx.bag));
21879566063dSJacob Faibussowitsch PetscCall(PetscFree(ctx.zeroArray));
21889566063dSJacob Faibussowitsch PetscCall(PetscFinalize());
2189b122ec5aSJacob Faibussowitsch return 0;
219065876a83SMatthew G. Knepley }
219165876a83SMatthew G. Knepley
219265876a83SMatthew G. Knepley /*TEST
219365876a83SMatthew G. Knepley
219465876a83SMatthew G. Knepley test:
219565876a83SMatthew G. Knepley suffix: 2d_quad_linear
219665876a83SMatthew G. Knepley requires: triangle
219765876a83SMatthew G. Knepley args: -sol_type quadratic_linear -dm_refine 2 \
219865876a83SMatthew G. Knepley -displacement_petscspace_degree 2 -tracestrain_petscspace_degree 1 -pressure_petscspace_degree 1 \
219965876a83SMatthew G. Knepley -dmts_check .0001 -ts_max_steps 5 -ts_monitor_extreme
220065876a83SMatthew G. Knepley
220165876a83SMatthew G. Knepley test:
220265876a83SMatthew G. Knepley suffix: 3d_quad_linear
220365876a83SMatthew G. Knepley requires: ctetgen
220430602db0SMatthew G. Knepley args: -dm_plex_dim 3 -sol_type quadratic_linear -dm_refine 1 \
220565876a83SMatthew G. Knepley -displacement_petscspace_degree 2 -tracestrain_petscspace_degree 1 -pressure_petscspace_degree 1 \
220665876a83SMatthew G. Knepley -dmts_check .0001 -ts_max_steps 5 -ts_monitor_extreme
220765876a83SMatthew G. Knepley
220865876a83SMatthew G. Knepley test:
220965876a83SMatthew G. Knepley suffix: 2d_trig_linear
221065876a83SMatthew G. Knepley requires: triangle
221165876a83SMatthew G. Knepley args: -sol_type trig_linear -dm_refine 1 \
221265876a83SMatthew G. Knepley -displacement_petscspace_degree 2 -tracestrain_petscspace_degree 1 -pressure_petscspace_degree 1 \
2213188af4bfSBarry Smith -dmts_check .0001 -ts_max_steps 5 -ts_time_step 0.00001 -ts_monitor_extreme
221465876a83SMatthew G. Knepley
221565876a83SMatthew G. Knepley test:
221665876a83SMatthew G. Knepley # -dm_refine 2 -convest_num_refine 3 get L_2 convergence rate: [1.9, 2.1, 1.8]
221765876a83SMatthew G. Knepley suffix: 2d_trig_linear_sconv
221865876a83SMatthew G. Knepley requires: triangle
221965876a83SMatthew G. Knepley args: -sol_type trig_linear -dm_refine 1 \
222065876a83SMatthew G. Knepley -displacement_petscspace_degree 2 -tracestrain_petscspace_degree 1 -pressure_petscspace_degree 1 \
2221188af4bfSBarry Smith -convest_num_refine 1 -ts_convergence_estimate -ts_convergence_temporal 0 -ts_max_steps 1 -ts_time_step 0.00001 -pc_type lu
222265876a83SMatthew G. Knepley
222365876a83SMatthew G. Knepley test:
222465876a83SMatthew G. Knepley suffix: 3d_trig_linear
222565876a83SMatthew G. Knepley requires: ctetgen
222630602db0SMatthew G. Knepley args: -dm_plex_dim 3 -sol_type trig_linear -dm_refine 1 \
222765876a83SMatthew G. Knepley -displacement_petscspace_degree 2 -tracestrain_petscspace_degree 1 -pressure_petscspace_degree 1 \
222865876a83SMatthew G. Knepley -dmts_check .0001 -ts_max_steps 2 -ts_monitor_extreme
222965876a83SMatthew G. Knepley
223065876a83SMatthew G. Knepley test:
223165876a83SMatthew G. Knepley # -dm_refine 1 -convest_num_refine 2 gets L_2 convergence rate: [2.0, 2.1, 1.9]
223265876a83SMatthew G. Knepley suffix: 3d_trig_linear_sconv
223365876a83SMatthew G. Knepley requires: ctetgen
223430602db0SMatthew G. Knepley args: -dm_plex_dim 3 -sol_type trig_linear -dm_refine 1 \
223565876a83SMatthew G. Knepley -displacement_petscspace_degree 2 -tracestrain_petscspace_degree 1 -pressure_petscspace_degree 1 \
223665876a83SMatthew G. Knepley -convest_num_refine 1 -ts_convergence_estimate -ts_convergence_temporal 0 -ts_max_steps 1 -pc_type lu
223765876a83SMatthew G. Knepley
223865876a83SMatthew G. Knepley test:
223965876a83SMatthew G. Knepley suffix: 2d_quad_trig
224065876a83SMatthew G. Knepley requires: triangle
224165876a83SMatthew G. Knepley args: -sol_type quadratic_trig -dm_refine 2 \
224265876a83SMatthew G. Knepley -displacement_petscspace_degree 2 -tracestrain_petscspace_degree 1 -pressure_petscspace_degree 1 \
224365876a83SMatthew G. Knepley -dmts_check .0001 -ts_max_steps 5 -ts_monitor_extreme
224465876a83SMatthew G. Knepley
224565876a83SMatthew G. Knepley test:
224665876a83SMatthew G. Knepley # Using -dm_refine 4 gets the convergence rates to [0.95, 0.97, 0.90]
224765876a83SMatthew G. Knepley suffix: 2d_quad_trig_tconv
224865876a83SMatthew G. Knepley requires: triangle
224965876a83SMatthew G. Knepley args: -sol_type quadratic_trig -dm_refine 1 \
225065876a83SMatthew G. Knepley -displacement_petscspace_degree 2 -tracestrain_petscspace_degree 1 -pressure_petscspace_degree 1 \
225165876a83SMatthew G. Knepley -convest_num_refine 3 -ts_convergence_estimate -ts_max_steps 5 -pc_type lu
225265876a83SMatthew G. Knepley
225365876a83SMatthew G. Knepley test:
225465876a83SMatthew G. Knepley suffix: 3d_quad_trig
225565876a83SMatthew G. Knepley requires: ctetgen
225630602db0SMatthew G. Knepley args: -dm_plex_dim 3 -sol_type quadratic_trig -dm_refine 1 \
225765876a83SMatthew G. Knepley -displacement_petscspace_degree 2 -tracestrain_petscspace_degree 1 -pressure_petscspace_degree 1 \
225865876a83SMatthew G. Knepley -dmts_check .0001 -ts_max_steps 5 -ts_monitor_extreme
225965876a83SMatthew G. Knepley
226065876a83SMatthew G. Knepley test:
226165876a83SMatthew G. Knepley # Using -dm_refine 2 -convest_num_refine 3 gets the convergence rates to [1.0, 1.0, 1.0]
226265876a83SMatthew G. Knepley suffix: 3d_quad_trig_tconv
226365876a83SMatthew G. Knepley requires: ctetgen
226430602db0SMatthew G. Knepley args: -dm_plex_dim 3 -sol_type quadratic_trig -dm_refine 1 \
226565876a83SMatthew G. Knepley -displacement_petscspace_degree 2 -tracestrain_petscspace_degree 1 -pressure_petscspace_degree 1 \
226665876a83SMatthew G. Knepley -convest_num_refine 1 -ts_convergence_estimate -ts_max_steps 5 -pc_type lu
226765876a83SMatthew G. Knepley
226830602db0SMatthew G. Knepley testset:
226930602db0SMatthew G. Knepley args: -sol_type terzaghi -dm_plex_simplex 0 -dm_plex_box_faces 1,8 -dm_plex_box_lower 0,0 -dm_plex_box_upper 10,10 -dm_plex_separate_marker \
227030602db0SMatthew G. Knepley -displacement_petscspace_degree 2 -tracestrain_petscspace_degree 1 -pressure_petscspace_degree 1 -niter 16000 \
227130602db0SMatthew G. Knepley -pc_type lu
227230602db0SMatthew G. Knepley
227365876a83SMatthew G. Knepley test:
227465876a83SMatthew G. Knepley suffix: 2d_terzaghi
227530602db0SMatthew G. Knepley requires: double
2276188af4bfSBarry Smith args: -ts_time_step 0.0028666667 -ts_max_steps 2 -ts_monitor -dmts_check .0001
227765876a83SMatthew G. Knepley
227865876a83SMatthew G. Knepley test:
227965876a83SMatthew G. Knepley # -dm_plex_box_faces 1,64 -ts_max_steps 4 -convest_num_refine 3 gives L_2 convergence rate: [1.1, 1.1, 1.1]
228065876a83SMatthew G. Knepley suffix: 2d_terzaghi_tconv
2281188af4bfSBarry Smith args: -ts_time_step 0.023 -ts_max_steps 2 -ts_convergence_estimate -convest_num_refine 1
228265876a83SMatthew G. Knepley
228365876a83SMatthew G. Knepley test:
228424b15d09SMatthew G. Knepley # -dm_plex_box_faces 1,16 -convest_num_refine 4 gives L_2 convergence rate: [1.7, 1.2, 1.1]
228530602db0SMatthew G. Knepley # if we add -displacement_petscspace_degree 3 -tracestrain_petscspace_degree 2 -pressure_petscspace_degree 2, we get [2.1, 1.6, 1.5]
228624b15d09SMatthew G. Knepley suffix: 2d_terzaghi_sconv
2287188af4bfSBarry Smith args: -ts_time_step 1e-5 -dt_initial 1e-5 -ts_max_steps 2 -ts_convergence_estimate -ts_convergence_temporal 0 -convest_num_refine 1
228830602db0SMatthew G. Knepley
228930602db0SMatthew G. Knepley testset:
229030602db0SMatthew G. Knepley args: -sol_type mandel -dm_plex_simplex 0 -dm_plex_box_lower -0.5,-0.125 -dm_plex_box_upper 0.5,0.125 -dm_plex_separate_marker -dm_refine 1 \
229130602db0SMatthew G. Knepley -displacement_petscspace_degree 2 -tracestrain_petscspace_degree 1 -pressure_petscspace_degree 1 \
229230602db0SMatthew G. Knepley -pc_type lu
229324b15d09SMatthew G. Knepley
229424b15d09SMatthew G. Knepley test:
229565876a83SMatthew G. Knepley suffix: 2d_mandel
229630602db0SMatthew G. Knepley requires: double
2297188af4bfSBarry Smith args: -ts_time_step 0.0028666667 -ts_max_steps 2 -ts_monitor -dmts_check .0001
229865876a83SMatthew G. Knepley
229965876a83SMatthew G. Knepley test:
2300f30e7d8cSMatthew G. Knepley # -dm_refine 3 -ts_max_steps 4 -convest_num_refine 3 gives L_2 convergence rate: [1.6, 0.93, 1.2]
2301f30e7d8cSMatthew G. Knepley suffix: 2d_mandel_sconv
2302188af4bfSBarry Smith args: -ts_time_step 1e-5 -dt_initial 1e-5 -ts_max_steps 2 -ts_convergence_estimate -ts_convergence_temporal 0 -convest_num_refine 1
2303f30e7d8cSMatthew G. Knepley
2304f30e7d8cSMatthew G. Knepley test:
230565876a83SMatthew G. Knepley # -dm_refine 5 -ts_max_steps 4 -convest_num_refine 3 gives L_2 convergence rate: [0.26, -0.0058, 0.26]
230665876a83SMatthew G. Knepley suffix: 2d_mandel_tconv
2307188af4bfSBarry Smith args: -ts_time_step 0.023 -ts_max_steps 2 -ts_convergence_estimate -convest_num_refine 1
230830602db0SMatthew G. Knepley
230930602db0SMatthew G. Knepley testset:
231030602db0SMatthew G. Knepley requires: ctetgen !complex
231130602db0SMatthew G. Knepley args: -sol_type cryer -dm_plex_dim 3 -dm_plex_shape ball \
231230602db0SMatthew G. Knepley -displacement_petscspace_degree 2 -tracestrain_petscspace_degree 1 -pressure_petscspace_degree 1
231365876a83SMatthew G. Knepley
231465876a83SMatthew G. Knepley test:
231565876a83SMatthew G. Knepley suffix: 3d_cryer
2316188af4bfSBarry Smith args: -ts_time_step 0.0028666667 -ts_max_time 0.014333 -ts_max_steps 2 -dmts_check .0001 \
231730602db0SMatthew G. Knepley -pc_type svd
231865876a83SMatthew G. Knepley
231965876a83SMatthew G. Knepley test:
232014bf6794SMatthew G. Knepley # -bd_dm_refine 3 -dm_refine_volume_limit_pre 0.004 -convest_num_refine 2 gives L_2 convergence rate: []
232114bf6794SMatthew G. Knepley suffix: 3d_cryer_sconv
232214bf6794SMatthew G. Knepley args: -bd_dm_refine 1 -dm_refine_volume_limit_pre 0.00666667 \
2323188af4bfSBarry Smith -ts_time_step 1e-5 -dt_initial 1e-5 -ts_max_steps 2 \
232414bf6794SMatthew G. Knepley -ts_convergence_estimate -ts_convergence_temporal 0 -convest_num_refine 1 \
232514bf6794SMatthew G. Knepley -pc_type lu -pc_factor_shift_type nonzero
232614bf6794SMatthew G. Knepley
232714bf6794SMatthew G. Knepley test:
232865876a83SMatthew G. Knepley # Displacement and Pressure converge. The analytic expression for trace strain is inaccurate at the origin
232965876a83SMatthew G. Knepley # -bd_dm_refine 3 -ref_limit 0.00666667 -ts_max_steps 5 -convest_num_refine 2 gives L_2 convergence rate: [0.47, -0.43, 1.5]
233065876a83SMatthew G. Knepley suffix: 3d_cryer_tconv
233130602db0SMatthew G. Knepley args: -bd_dm_refine 1 -dm_refine_volume_limit_pre 0.00666667 \
2332188af4bfSBarry Smith -ts_time_step 0.023 -ts_max_time 0.092 -ts_max_steps 2 -ts_convergence_estimate -convest_num_refine 1 \
233330602db0SMatthew G. Knepley -pc_type lu -pc_factor_shift_type nonzero
233465876a83SMatthew G. Knepley
233565876a83SMatthew G. Knepley TEST*/
2336