Skip to content

Commit cdc1f42

Browse files
Merge pull request #741 from baagaard-usgs/fix-examples
Small fixes to strikeslip-2d and reverse-2d examples
2 parents b3bd749 + 0e159d2 commit cdc1f42

File tree

8 files changed

+1369
-359
lines changed

8 files changed

+1369
-359
lines changed

docs/user/examples/reverse-2d/step01-gravity.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ Increasing the basis order reduces the maximum shear stress by about 10 orders o
312312

313313
1. The displacement field is very similar for the three different discretizations.
314314
2. In this case, we know the vertical displacement in the exact solution depends on the square of the depth, so we expect the numerical accuracy to be limited when we use a basis order of 1 for the displacement solution subfield.
315-
3. In the exact solution, the axial components of the Cauchy stress tensor vary linear with depth, and the xy component of the Cauchy stress is zero.
315+
3. In the exact solution, the axial components of the Cauchy stress tensor increase linearly with depth, and the xy component of the Cauchy stress is zero.
316316
4. With the coarse mesh, the shear stress is close to 10 MPa throughout the mesh.
317317
5. Refining the mesh decreases the magnitude shear stress by about a factor of 2.
318318
6. Using a basis order of 2 for the solution subfields reduces the magnitude of the shear stress by nearly 10 orders of magnitude.
-487 Bytes
Binary file not shown.

docs/user/examples/strikeslip-2d/figs/step06-solution.svg

Lines changed: 1284 additions & 342 deletions
Loading

docs/user/examples/strikeslip-2d/step04-varslip.md

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,29 @@ Boundary conditions for static coseismic slip.
2424
We set the x and y displacement to zero on the +x and -x boundaries and prescribe left-lateral slip that varies along strike.
2525
:::
2626

27+
For greater accuracy in modeling the spatial variation in slip, we use a basis order of 2 for the solution subfields.
28+
29+
```{code-block} cfg
30+
---
31+
caption: Parameters related to increasing the basis order of the solution subfields to 2.
32+
---
33+
[pylithapp.problem]
34+
defaults.quadrature_order = 2
35+
36+
[pylithapp.problem.solution.subfields]
37+
displacement.basis_order = 2
38+
lagrange_multiplier_fault.basis_order = 2
39+
40+
41+
[pylithapp.problem.materials.elastic_xneg]
42+
derived_subfields.cauchy_strain.basis_order = 1
43+
derived_subfields.cauchy_stress.basis_order = 1
44+
45+
[pylithapp.problem.materials.elastic_xpos]
46+
derived_subfields.cauchy_strain.basis_order = 1
47+
derived_subfields.cauchy_stress.basis_order = 1
48+
```
49+
2750
We also add output of the solution at fake GNSS stations given in the file `gnss_stations.txt`.
2851
You can use the Python script `generate_gnssstations.py` to generate a different random set of stations; the default parameters will generate the provided `gnss_stations.txt` file.
2952

@@ -47,6 +70,20 @@ reader.filename = gnss_stations.txt
4770
reader.coordsys.space_dim = 2
4871
```
4972

73+
```{code-block} cfg
74+
---
75+
caption: Solution and output parameters for Step 4. We add output of the solution at fake GNSS stations.
76+
---
77+
[pylithapp.problem]
78+
solution_observers = [domain, top_boundary, bot_boundary, gnss_stations]
79+
solution_observers.gnss_stations = pylith.meshio.OutputSolnPoints
80+
81+
[pylithapp.problem.solution_observers.gnss_stations]
82+
label = gnss_stations
83+
reader.filename = gnss_stations.txt
84+
reader.coordsys.space_dim = 2
85+
```
86+
5087
The earthquake rupture occurs along the central portion of the fault with spatially variable slip.
5188

5289
:::{figure-md} fig:example:strikeslip:2d:step04:slip
@@ -96,10 +133,10 @@ $ pylith step04_varslip.cfg
96133
-- timedependent(info)
97134
-- Solving problem.
98135
0 TS dt 0.01 time 0.
99-
0 SNES Function norm 3.786132692381e-03
100-
Linear solve converged due to CONVERGED_ATOL iterations 61
101-
1 SNES Function norm 2.070681594908e-12
102-
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
136+
0 SNES Function norm 5.220560316093e-03
137+
Linear solve converged due to CONVERGED_ATOL iterations 27
138+
1 SNES Function norm 1.523809186100e-12
139+
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
103140
1 TS dt 0.01 time 0.01
104141
>> /software/unix/py3.12-venv/pylith-debug/lib/python3.12/site-packages/pylith/problems/Problem.py:199:finalize
105142
-- timedependent(info)
@@ -108,7 +145,7 @@ $ pylith step04_varslip.cfg
108145

109146
The beginning of the output written to the terminal matches that in our previous simulations.
110147
At the end of the output written to the terminal, we see that the solver advanced the solution one time step (static simulation).
111-
The linear solve converged after 61 iterations and the norm of the residual met the absolute convergence tolerance (`ksp_atol`).
148+
The linear solve converged after 27 iterations and the norm of the residual met the absolute convergence tolerance (`ksp_atol`).
112149
The nonlinear solve converged in 1 iteration, which we expect because this is a linear problem, and the residual met the absolute convergence tolerance (`snes_atol`).
113150

114151
## Visualizing the results

examples/strikeslip-2d/pylithapp.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ label = boundary_xpos
164164
label_value = 11
165165
constrained_dof = [0, 1]
166166
db_auxiliary_field = pylith.bc.ZeroDB
167-
db_auxiliary_field.description = Dirichlet BC +x boundary
167+
db_auxiliary_field.description = Dirichlet BC on +x boundary
168168

169169
[pylithapp.problem.bc.bc_xneg]
170170
label = boundary_xneg
171171
label_value = 10
172172
constrained_dof = [0, 1]
173173
db_auxiliary_field = pylith.bc.ZeroDB
174-
db_auxiliary_field.description = Dirichlet BC -x boundary
174+
db_auxiliary_field.description = Dirichlet BC on -x boundary
175175

176176

177177
# End of file

examples/strikeslip-2d/step04_varslip.cfg

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
base = [pylithapp.cfg]
2323
description = Coseismic prescribed slip with zero displacement Dirichlet boundary conditions.
2424
authors = [Brad Aagaard]
25-
keywords = [prescribed slip]
25+
keywords = [prescribed slip, basis order 2]
2626
arguments = [step04_varslip.cfg]
2727
version = 1.0.0
2828
pylith_version = [>=4.0, <5.0]
@@ -44,15 +44,33 @@ problem.progress_monitor.filename = output/step04_varslip-progress.txt
4444
# output filenames. The default directory for output is 'output'.
4545
problem.defaults.name = step04_varslip
4646

47-
# ----------------------------------------------------------------------
48-
# mesh_generator
49-
# ----------------------------------------------------------------------
50-
[pylithapp.mesh_generator]
51-
refiner = pylith.topology.RefineUniform
52-
5347
# ----------------------------------------------------------------------
5448
# problem
5549
# ----------------------------------------------------------------------
50+
# Update the parameters to use a basis order of 2 for the solution fields.
51+
#
52+
# The accuracy of the stress and strain will be 1 order lower than the basis
53+
# order of the displacement field. Consequently, we use a basis order of 1
54+
# (rather than 0) for the output of the Cauchy stress and strain.
55+
#
56+
# We do not change the basis order of the output of the displacement field,
57+
# because many visualization tools do not know how to display fields with
58+
# a basis order of 2.
59+
60+
[pylithapp.problem]
61+
# Set the default quadrature order for all subfields. We want to set it
62+
# to the maximum of the basis order of the solution subfields.
63+
#
64+
# IMPORTANT: The quadrature order *must* the same for all solution and
65+
# auxiliary subfields. PyLith will verify that this requirement is met.
66+
# This requirement may be relaxed in the future.
67+
defaults.quadrature_order = 2
68+
69+
[pylithapp.problem.solution.subfields]
70+
displacement.basis_order = 2
71+
lagrange_multiplier_fault.basis_order = 2
72+
73+
5674
[pylithapp.problem]
5775
# We add output at our fake GNSS stations that we will use a fake observations.
5876
solution_observers = [domain, top_boundary, bot_boundary, gnss_stations]
@@ -65,6 +83,18 @@ reader.filename = gnss_stations.txt
6583
reader.coordsys.space_dim = 2
6684

6785

86+
# ----------------------------------------------------------------------
87+
# materials
88+
# ----------------------------------------------------------------------
89+
[pylithapp.problem.materials.elastic_xneg]
90+
derived_subfields.cauchy_strain.basis_order = 1
91+
derived_subfields.cauchy_stress.basis_order = 1
92+
93+
[pylithapp.problem.materials.elastic_xpos]
94+
derived_subfields.cauchy_strain.basis_order = 1
95+
derived_subfields.cauchy_stress.basis_order = 1
96+
97+
6898
# ----------------------------------------------------------------------
6999
# fault
70100
# ----------------------------------------------------------------------

examples/strikeslip-2d/viz/plot_inversion_results.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class PlotApp:
2020

2121

2222
COLOR_OBSERVED = "black"
23-
COLORS_MODEL = ["blue", "orange", "purple", "red", "cyan"]
23+
COLORS_MODEL = ["orange", "purple", "red", "cyan"]
2424
XLIM = (-25.0, 25.0)
2525

2626
def main(self, filename_models: str=None, filename_observed: str=None, observed_only: bool=False, show_plot: bool=False):
@@ -78,7 +78,7 @@ def _plot_models(self, axes):
7878
nmodels = self.models_slip.shape[1]
7979
coords = self.models_coords / 1.0e+3
8080
for imodel in range(nmodels):
81-
axes.plot(coords, self.models_slip[:,imodel], color=self.COLORS_MODEL[imodel], label=f"Model penalty={self.models_penalty[imodel]}")
81+
axes.plot(coords, self.models_slip[:,imodel], "--", color=self.COLORS_MODEL[imodel], label=f"Model penalty={self.models_penalty[imodel]}")
8282

8383

8484
def cli():

release-notes/checklist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ DISTRIBUTIONS
3737
* Generate binaries using pylith_installer packager/build.py.
3838
Check on various platforms.
3939
Check trapping of errors.
40+
Check macOSX minos `for i in lib*.dylib; do otool -l $i | grep -E -A4 '(LC_VERSION_MIN_MACOSX|LC_BUILD_VERSION)' | grep -B1 sdk; done`
4041

4142
TAG
4243

0 commit comments

Comments
 (0)