7 for argument in "$@"; do
8 printf -v quoted '%q' "$argument"
9 quoted=${quoted//\\,/,}
10 printf ' %s' "$quoted"
15# Run from anywhere. An optional argument selects an existing CMake build.
16script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
17repo=$(cd "$script_dir/../../../.." && pwd)
18module=$(cd "$script_dir/.." && pwd)
19build_input=${1:-"$repo/build-darwin-macos-m1-tra7qus/core-build-Release-tra7qus"}
20if (( $# > 1 )) || [[ ! -f "$build_input/CMakeCache.txt" ]]; then
21 printf 'Usage: %s [configured-build-directory]\n' "$0" >&2
24build=$(cd "$build_input" && pwd)
25cmake_bin=$(sed -n 's/^CMAKE_COMMAND:INTERNAL=//p' "$build/CMakeCache.txt")
26moab_dir=$(sed -n 's/^MOAB_DIR:PATH=//p' "$build/CMakeCache.txt")
27mbconvert="$moab_dir/bin/mbconvert"
28if [[ ! -x "$cmake_bin" || ! -x "$mbconvert" ]]; then
29 printf 'CMake or mbconvert is missing from the configured build\n' >&2
33example="$build/users_modules/ageing_umat/nonlinear_elasticity_ageing_example"
34work="$example/cm_notes"
36build_command=("$cmake_bin" --build "$build"
37 --target ageing_field_tags nonlinear_elastic_ageing_umat_3d -j 2)
38printf '\n# Build the tag tool and one-hex solver; details: %s/build.log\n' "$work"
39print_command "${build_command[@]}"
40if ! "${build_command[@]}" >"$work/build.log" 2>&1; then
41 tail -n 80 "$work/build.log" >&2
44if [[ ! -f "$example/grumat.so" ]]; then
45 printf 'Missing UMAT library: %s\n' "$example/grumat.so" >&2
49# Run the built executables by name in a self-contained work area.
50ln -sfn "$build/users_modules/ageing_umat/tools/ageing_field_tags" \
51 "$work/ageing_field_tags"
52ln -sfn "$example/nonlinear_elastic_ageing_umat_3d" \
53 "$work/nonlinear_elastic_ageing_umat_3d"
54ln -sfn "$mbconvert" "$work/mbconvert"
55ln -sfn "$example/grumat.so" "$work/grumat.so"
56cp "$example/amentum_umat_props.inc" "$work/amentum_umat_props.inc"
57cp "$example/param_file.petsc" "$work/param_file.petsc"
58cp "$example/gdatv7" "$work/gdatv7"
59print_command cd "$work"
62# Sheet3's Abaqus base history: one startup increment, then 8 increments
63# of 0.25 years for each two-year dose interval. Every hex node has the
64# same field values; ageing_field_tags assigns the nodal MOAB history tags.
65doses=(0 0.003 7.25 14.5 21.75)
66temperatures=(20 20 450 450 450)
67printf '\n# Write uniform D_*, T_*, WL_* nodal files and aging_fpy_history.txt\n'
68for ((step = 0; step < ${#doses[@]}; ++step)); do
69 printf -v label '%03d' "$step"
70 : >"fvs/D_${label}.fvs"
71 : >"fvs/T_${label}.fvs"
72 : >"fvs/WL_${label}.fvs"
73 for node in {1..8}; do
74 printf '%d, %s\n' "$node" "${doses[$step]}" >>"fvs/D_${label}.fvs"
75 printf '%d, %s\n' "$node" "${temperatures[$step]}" >>"fvs/T_${label}.fvs"
76 printf '%d, 0\n' "$node" >>"fvs/WL_${label}.fvs"
79cat >aging_fpy_history.txt <<'HISTORY'
87tag_command=(./ageing_field_tags
88 -file_name "$module/meshes/one_hex_with_tags.h5m"
89 -output_file cm_notes_450t.h5m
90 -fvs_dir fvs -log_no_color)
91printf '\n# Create the tagged hex mesh; details: ageing_field_tags.log\n'
92print_command "${tag_command[@]}"
93if ! "${tag_command[@]}" >ageing_field_tags.log 2>&1; then
94 tail -n 80 ageing_field_tags.log >&2
98# The Fortran UMAT accepts a short relative grdata filename.
100rm -f out_vertices_*.h5m out_vertices_*.vtk
101solver_command=(./nonlinear_elastic_ageing_umat_3d
102 -file_name cm_notes_450t.h5m
103 -umat_library ./grumat.so
104 -umat_props_file ./amentum_umat_props.inc
105 -umat_nstatev 134 -umat_nprops 134
106 -umat_strain_type small
107 -umat_subtract_thermal_strain true
108 -umat_thermal_reference_temp 20
109 -ts_type beuler -ts_exact_final_time matchstep
110 -ts_adapt_type amentum -ts_dt 0.000001
111 -ts_adapt_dt_min 0.25
112 -ts_amentum_adapt_fixed_step_len true
113 -ts_max_time 6.000001 -ts_error_if_step_fails true -ts_monitor
114 -base demkowicz -order 1 -max_post_ho_nodes false
115 -save_every 1 -post_proc_vol false -post_proc_skin false
116 -output_sdv 0,1,2,3,4,6,7,22,57,79,80,115
118printf '\n# Solve the Abaqus base history; accepted step/time below; full log: nonlinear_elastic_ageing_umat_3d.log\n'
119print_command export grdata=gdatv7
120print_command "${solver_command[@]}"
121# PETSc's default monitor rounds times such as 6.000001 to "6.". Check its
122# reported time against this fixed schedule and print the full schedule time.
123if ! "${solver_command[@]}" 2>&1 |
124 tee nonlinear_elastic_ageing_umat_3d.log |
127 for (i = 2; i <= NF - 4; ++i)
128 if ($i == "TS" && $(i+1) == "dt" && $(i+3) == "time") {
129 accepted_step = $(i-1) + 0
130 scheduled_time = accepted_step == 0 ? 0 : 0.000001 + (accepted_step - 1) * 0.25
131 difference = $(i+4) - scheduled_time
132 if (difference < -0.000005 || difference > 0.000005) {
133 printf "Unexpected time at step %d: %s\n", accepted_step, $(i+4) > "/dev/stderr"
136 printf "step %d: time %.6f, dt %s\n", accepted_step, scheduled_time, $(i+2)
144 printf "Expected 26 TS monitor lines, found %d\n", count > "/dev/stderr"
149 tail -n 80 nonlinear_elastic_ageing_umat_3d.log >&2
153# One VTK point represents one physical integration point. The first value
154# after each SCALARS/LOOKUP_TABLE pair belongs to the first point.
155report=cm_notes_sheet3.md
157 printf '# MoFEM 450T base case\n\n'
158 printf 'First integration point of the one-hex mesh; SDV numbers are one-based.\n\n'
159 printf '| Time step | SDV116 | SDV23 | SDV8 | SDV80 | SDV81 | SDV4 | SDV5 | SDV3 | SDV58 |\n'
160 printf '| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |\n'
162cat >cm_notes_extract.awk <<'AWK'
164 n = split("115 22 7 79 80 3 4 2 57", indices, " ")
165 for (i = 1; i <= n; ++i)
166 column["UMAT_STATEV_" indices[i]] = i
168$1 == "POINT_DATA" { points = $2 }
169$1 == "SCALARS" && ($2 in column) {
171 if (getline <= 0 || $1 != "LOOKUP_TABLE") {
172 printf "Invalid VTK scalar %s at step %d\n", name, step > "/dev/stderr"
176 printf "Missing VTK value for %s at step %d\n", name, step > "/dev/stderr"
179 value[column[name]] = $1
183 printf "No VTK points at step %d\n", step > "/dev/stderr"
186 for (i = 1; i <= n; ++i)
188 printf "Missing SDV column %d at step %d\n", i, step > "/dev/stderr"
191 printf "| %d |", step
192 for (i = 1; i <= n; ++i) printf " %s |", value[i]
197printf '\n# Convert each integration-point mesh to VTK and extract its SDVs\n'
198for ((step = 0; step <= 25; ++step)); do
199 h5m="out_vertices_${step}.h5m"
200 vtk="out_vertices_${step}.vtk"
201 [[ -f "$h5m" ]] || { printf 'Missing solver output: %s\n' "$h5m" >&2; exit 1; }
202 print_command ./mbconvert "$h5m" "$vtk"
203 if ! ./mbconvert "$h5m" "$vtk" >>vtk_conversion.log 2>&1; then
204 tail -n 20 vtk_conversion.log >&2
207 # The initial output precedes the first UMAT call, so VTK has no SDV arrays.
208 if (( step == 0 )); then
209 printf '# Step 0 precedes the UMAT call; its SDVs are zero.\n'
210 printf '| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n' >>"$report"
213 extract_command=(awk -v "step=$step" -f cm_notes_extract.awk "$vtk")
214 print_command "${extract_command[@]}"
215 "${extract_command[@]}" >>"$report"
219printf '\nTagged mesh: %s\nReport: %s\n' "$work/cm_notes_450t.h5m" "$work/$report"