diff --git a/papers/JFNK_highOrder/linearElastic/cantilever/Allrun b/papers/JFNK_highOrder/linearElastic/cantilever/Allrun index 0858adea..cc59f1fc 100755 --- a/papers/JFNK_highOrder/linearElastic/cantilever/Allrun +++ b/papers/JFNK_highOrder/linearElastic/cantilever/Allrun @@ -7,11 +7,11 @@ source solids4FoamScripts.sh solids4Foam::caseDoesNotRunWithFoamExtend # solids4Foam location path -export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib-highOrder +export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib/solids4foam-ib-2412/ echo "SOLIDS4FOAM_DIR = $SOLIDS4FOAM_DIR" # Compile the cantileverBeam library -(cd analyticalCantilever && ./Allwmake -j -s) +(cd src && ./Allwmake -j -s) # Segregated version require a lot of time to converge, I will skip it for # now. Tet mesh is not working with snes becouse of gradient at corner cells @@ -22,15 +22,15 @@ configs=( # "BASE=base/segregated NAME=hex.struct.seg GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0" # "BASE=base/segregated NAME=tet.struct.seg GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0" # "BASE=base/segregated NAME=tet.unstruct.seg GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0" - # "BASE=base/highOrder NAME=hex.struct.ho.N1 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.ksponly HOJAC=false HORES=true" - # "BASE=base/highOrder NAME=hex.struct.ho.N2 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true" - # "BASE=base/highOrder NAME=hex.struct.ho.N3 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.struct.ho.N1 GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.struct.ho.N2 GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.struct.ho.N3 GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.unstruct.ho.N1 GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.unstruct.ho.N2 GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.unstruct.ho.N3 GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true" + # "BASE=base/highOrder NAME=hex.struct.ho.N1 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.ksponly HOJAC=false HORES=true TYPE=movingLeastSquares" + # "BASE=base/highOrder NAME=hex.struct.ho.N2 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=movingLeastSquares" + # "BASE=base/highOrder NAME=hex.struct.ho.N3 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N1 GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N2 GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N3 GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N1 GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N2 GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N3 GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=movingLeastSquares" ) # Define start and end mesh indices @@ -68,7 +68,7 @@ cd "${RUN_DIR}" for config in "${configs[@]}" do # Reset variables in the case some variable is not used - unset GMSH_FILE PETSC_FILE order extraCells HOJAC HORES + unset GMSH_FILE PETSC_FILE order extraCells HOJAC HORES TYPE # Parse the configuration string eval $config @@ -118,6 +118,11 @@ do sed -i "/^\s*faceStencilExtraCells /s|^.*| faceStencilExtraCells ${extraCells};|" constant/solidProperties fi + # Update the least squares type + if [ -n "${TYPE}" ]; then + sed -i "/^\s*type \(movingLeastSquares\|kExactLeastSquares\);/s|^.*| type ${TYPE};|" constant/solidProperties + fi + # Update how Jacobian is calculated if [ -n "${HOJAC}" ]; then sed -i "/^\s*highOrderJacobian /s|^.*| highOrderJacobian ${HOJAC};|" constant/solidProperties diff --git a/papers/JFNK_highOrder/linearElastic/cantilever/Allrun.kExact b/papers/JFNK_highOrder/linearElastic/cantilever/Allrun.kExact new file mode 100755 index 00000000..7012c16c --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/cantilever/Allrun.kExact @@ -0,0 +1,218 @@ +#!/bin/bash + +# Source required functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions +source solids4FoamScripts.sh +# Extend version not supported +solids4Foam::caseDoesNotRunWithFoamExtend + +# solids4Foam location path +export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib/solids4foam-ib-2412/ +echo "SOLIDS4FOAM_DIR = $SOLIDS4FOAM_DIR" + +# Compile the cantileverBeam library +(cd src && ./Allwmake -j -s) + +# Segregated version require a lot of time to converge, I will skip it for +# now. Tet mesh is not working with snes becouse of gradient at corner cells + +# Define configurations as space-separated strings +configs=( + # "BASE=base/snes NAME=hex.struct.hypre-snes GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 PETSC_FILE=petscOptions.lu" + # "BASE=base/segregated NAME=hex.struct.seg GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0" + # "BASE=base/segregated NAME=tet.struct.seg GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0" + # "BASE=base/segregated NAME=tet.unstruct.seg GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0" + # "BASE=base/highOrder NAME=hex.struct.ho.N1 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.ksponly HOJAC=false HORES=true TYPE=kExactLeastSquares" + # "BASE=base/highOrder NAME=hex.struct.ho.N2 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=kExactLeastSquares" + # "BASE=base/highOrder NAME=hex.struct.ho.N3 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N1 GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N2 GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N3 GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N1 GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N2 GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N3 GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=kExactLeastSquares" +) + +# Define start and end mesh indices +# Mesh input files are defined from 1 to 15 +# END_MESH should be greater than START_MESH +START_MESH=1 +END_MESH=15 + + +# Detect the CPU type: we append this to the case name +if [[ "$OSTYPE" == "darwin"* ]] +then + # macOS + CPU_TYPE=$(sysctl -n machdep.cpu.brand_string | sed 's/[^a-zA-Z0-9]/_/g') +elif [[ -f /proc/cpuinfo ]] +then + # Linux + CPU_TYPE=$(grep -m 1 "model name" /proc/cpuinfo | awk -F': ' '{print $2}' | sed 's/[^a-zA-Z0-9]/_/g') +else + # Fallback if neither method works + CPU_TYPE="Unknown_CPU" +fi + + +# Create timestamped working directory for this run +DATE=$(date +%Y-%m-%d_%H-%M-%S) +RUN_DIR="run_${CPU_TYPE}_${DATE}" +echo "Creating ${RUN_DIR}" +mkdir "${RUN_DIR}" + +# Enter the run directory +cd "${RUN_DIR}" + +# Iterate through configurations +for config in "${configs[@]}" +do + # Reset variables in the case some variable is not used + unset GMSH_FILE PETSC_FILE order extraCells HOJAC HORES TYPE + + # Parse the configuration string + eval $config + echo; echo "***************************************" + echo "Running configuration: $config" + echo "***************************************" + + # Define results summary file name + SUMMARY="${NAME}.summary.txt" + echo "# Mesh Time Mem CellsNumber D_L2 D_Linf S_L2 S_Linf" > "${SUMMARY}" + + # Loop over mesh densities in each configuration + for i in `seq $START_MESH $END_MESH` + do + CASE="${NAME}.$i" + echo; echo "Processing case: $CASE" + + # Prepare the case + cp -rL "../${BASE}" "${CASE}" + cd "$CASE" + + # GMSH Mesh generation + cp "gmsh/meshSpacing/meshSpacing$i.geo" "gmsh/meshSpacing/meshSpacing.geo" + solids4Foam::runApplication gmsh -3 -format msh2 gmsh/"${GMSH_FILE}.geo" + solids4Foam::runApplication gmshToFoam gmsh/"${GMSH_FILE}.msh" + solids4Foam::runApplication changeDictionary + + # Optional mesh distortion + if [ "$USE_PERTURBMESHPOINTS" -eq 1 ] + then + solids4Foam::runApplication perturbMeshPoints + fi + solids4Foam::runApplication checkMesh + + # Update the PETSc options file + if [ -n "${PETSC_FILE}" ]; then + sed -i "/^\s*optionsFile /s|^.*| optionsFile ${PETSC_FILE};|" constant/solidProperties + fi + + # Update the order + if [ -n "${polyOrder}" ]; then + sed -i "/^\s*polynomialOrder /s|^.*| polynomialOrder ${polyOrder};|" constant/solidProperties + fi + + # Update number of stencil cells + if [ -n "${extraCells}" ]; then + sed -i "/^\s*faceStencilExtraCells /s|^.*| faceStencilExtraCells ${extraCells};|" constant/solidProperties + fi + + # Update the least squares type + if [ -n "${TYPE}" ]; then + sed -i "/^\s*type \(movingLeastSquares\|kExactLeastSquares\);/s|^.*| type ${TYPE};|" constant/solidProperties + fi + + # Update how Jacobian is calculated + if [ -n "${HOJAC}" ]; then + sed -i "/^\s*highOrderJacobian /s|^.*| highOrderJacobian ${HOJAC};|" constant/solidProperties + fi + + # Update how Residual is calculated + if [ -n "${HORES}" ]; then + sed -i "/^\s*highOrderResidual /s|^.*| highOrderResidual ${HORES};|" constant/solidProperties + fi + + # Run the solver + # If "gtime" is available (could be called "time" on Linux), use it to + # record the max memory usage + if command -v gtime &> /dev/null + then + echo "Running solids4Foam on ${CASE} with gtime" + gtime -f "gtime/time (wall clock) time: %e\nMaximum resident set size (kbytes): %M" solids4Foam &> log.solids4Foam + + elif [ -x /usr/bin/time ] + then + echo "Running solids4Foam on ${CASE} with /usr/bin/time" + /usr/bin/time -f "gtime/time (wall clock) time: %e\nMaximum resident set size (kbytes): %M" solids4Foam &> log.solids4Foam + + elif command -v time &> /dev/null + then + echo "Running solids4Foam on ${CASE} with shell builtin time (no max memory)" + time solids4Foam &> log.solids4Foam + + else + echo "Running solids4Foam on ${CASE}" + solids4Foam::runApplication solids4Foam + fi + + # Extract results from solver log and append them to a summary file + echo; echo "Appending results to ${SUMMARY}" + if grep -q "gtime/time" log.solids4Foam; then + CLOCK_TIME=$(grep "gtime/time" log.solids4Foam | awk '{print $5}') + else + # Record the time + CLOCK_TIME=$(grep "ClockTime" log.solids4Foam | awk '{print $7}') + fi + + # Extract results from solver log and append them to a summary file + if grep -q "Maximum resident" log.solids4Foam; then + MAX_MEMORY=$(grep "Maximum resident" log.solids4Foam | awk '{print int($6 / 1000)}') + else + MAX_MEMORY="NaN" + fi + + # Number of cells + CELLS=$(grep "cells:" log.checkMesh | awk '{print $2}') + + # Extract the L2 (average) error for displacement + DISP_L2_ERROR=$(grep "Writing DDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $3}') + + # Extract the LInfinity (max) error for displacement + DISP_LINF_ERROR=$(grep "Writing DDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $4}') + + # Extract the L2 (average) error for mag(sigma) + STRESS_L2_ERROR=$(grep "Writing sigmaDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $3}') + + # Extract the LInfinity (max) error for mag(sigma) + STRESS_LINF_ERROR=$(grep "Writing sigmaDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $4}') + + # Write data to file + echo "$i $CLOCK_TIME $MAX_MEMORY $CELLS $DISP_L2_ERROR $DISP_LINF_ERROR $STRESS_L2_ERROR $STRESS_LINF_ERROR" >> ../"${SUMMARY}" + + cd .. + done + + # Print summary file + echo; echo "${SUMMARY} file:"; cat "${SUMMARY}"; echo + +done + +# Create plots if gnuplot in installed +if command -v gnuplot &>/dev/null +then + # Copy gnuplot scripts + cp ../plotScripts/*gnuplot . + + # Run all scripts + for f in *gnuplot + do + echo "Running gnuplot on $f" + gnuplot "$f" 2>/dev/null + done +fi + +echo; echo; echo "Done!"; echo +echo "View the PDF files in ${RUN_DIR}" +echo; echo $(date) +echo; echo diff --git a/papers/JFNK_highOrder/linearElastic/cantilever/base/highOrder/constant/solidProperties b/papers/JFNK_highOrder/linearElastic/cantilever/base/highOrder/constant/solidProperties index 47170483..5f0e64db 100644 --- a/papers/JFNK_highOrder/linearElastic/cantilever/base/highOrder/constant/solidProperties +++ b/papers/JFNK_highOrder/linearElastic/cantilever/base/highOrder/constant/solidProperties @@ -33,6 +33,7 @@ linearGeometryTotalDisplacementCoeffs displacement { + type movingLeastSquares; polynomialOrder 2; faceStencilExtraCells 10; diff --git a/papers/JFNK_highOrder/linearElastic/cantilever/comparisonPlotScripts/dispErrors_movingVskExact.gnuplot b/papers/JFNK_highOrder/linearElastic/cantilever/comparisonPlotScripts/dispErrors_movingVskExact.gnuplot new file mode 100644 index 00000000..e265f6f0 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/cantilever/comparisonPlotScripts/dispErrors_movingVskExact.gnuplot @@ -0,0 +1,95 @@ +set term pdfcairo dashed enhanced size 3.25,2 + +set datafile separator " " + +if (ARGC < 1) { + print "Usage: gnuplot -c dispErrors_movingVskExact.gnuplot " + exit +} + +movingResults = ARG1 +movingFile(fileName) = sprintf("%s/%s", movingResults, fileName) + +beamArea = 0.2 + +set grid +set xrange [5:55] +set yrange [1e-13:1e-2] +set xtics +set xtics add (5, 25, 50) +set ytics +set logscale x +set logscale y +set format y "10^{%L}" +#set ytics 0.002 +set xlabel "Average cell edge (in mm)" +set ylabel "Error (in m)" +set key right bottom outside; +set rmargin 16 +set key spacing 1.2 + +# Polynomial guide lines (no title) +set style line 1 lc rgb "red" lt 2 lw 2 dt 2 +set style line 2 lc rgb "blue" lt 2 lw 2 dt 2 +set style line 3 lc rgb "violet" lt 2 lw 2 dt 2 + +# Data lines for each p-order (with titles) +set style line 11 lc rgb "red" pt 7 ps 0.5 lw 1 +set style line 12 lc rgb "red" pt 6 ps 0.5 lw 1 +set style line 21 lc rgb "blue" pt 5 ps 0.5 lw 1 +set style line 22 lc rgb "blue" pt 4 ps 0.5 lw 1 +set style line 31 lc rgb "violet" pt 9 ps 0.5 lw 1 +set style line 32 lc rgb "violet" pt 8 ps 0.5 lw 1 + +# Moving-least-squares data use the same colours with 50% transparency +set style line 111 lc rgb "#B3ff0000" pt 7 ps 0.5 lw 1 +set style line 112 lc rgb "#B3ff0000" pt 6 ps 0.5 lw 1 +set style line 121 lc rgb "#B30000ff" pt 5 ps 0.5 lw 1 +set style line 122 lc rgb "#B30000ff" pt 4 ps 0.5 lw 1 +set style line 131 lc rgb "#B3ee82ee" pt 9 ps 0.5 lw 1 +set style line 132 lc rgb "#B3ee82ee" pt 8 ps 0.5 lw 1 + +# set output "cantilever_dispErrors-hex.pdf" +# plot \ +# (2e-6 * x**2) w l ls 1 title "2^{nd} order", \ +# (4e-8 * x**3) w l ls 2 title "3^{rd} order", \ +# "hex.struct.ho.N1.summary.txt" u ((beamArea/$4)**0.5*1e3):($5) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ +# "hex.struct.ho.N1.summary.txt" u ((beamArea/$4)**0.5*1e3):($6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ +# "hex.struct.ho.N2.summary.txt" u ((beamArea/$4)**0.5*1e3):($5) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ +# "hex.struct.ho.N2.summary.txt" u ((beamArea/$4)**0.5*1e3):($6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ +# "hex.struct.ho.N3.summary.txt" u ((beamArea/$4)**0.5*1e3):($5) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ +# "hex.struct.ho.N3.summary.txt" u ((beamArea/$4)**0.5*1e3):($6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)" + +set output "cantilever_dispErrors_tet-struct_movingVskExact.pdf" +plot \ + (2e-6 * x**2) w l ls 1 title "2^{nd} order", \ + (4e-8 * x**3) w l ls 2 title "3^{rd} order", \ + "tet.struct.ho.N1.summary.txt" u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($5) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.struct.ho.N1.summary.txt" u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.struct.ho.N2.summary.txt" u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($5) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.struct.ho.N2.summary.txt" u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "tet.struct.ho.N3.summary.txt" u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($5) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "tet.struct.ho.N3.summary.txt" u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)" , \ + movingFile("tet.struct.ho.N1.summary.txt") u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($5) w lp ls 111 notitle , \ + movingFile("tet.struct.ho.N1.summary.txt") u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($6) w lp ls 112 notitle , \ + movingFile("tet.struct.ho.N2.summary.txt") u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($5) w lp ls 121 notitle , \ + movingFile("tet.struct.ho.N2.summary.txt") u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($6) w lp ls 122 notitle , \ + movingFile("tet.struct.ho.N3.summary.txt") u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($5) w lp ls 131 notitle , \ + movingFile("tet.struct.ho.N3.summary.txt") u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($6) w lp ls 132 notitle + +set output "cantilever_dispErrors_tet-unstruct_movingVskExact.pdf" +plot \ + (2e-6 * x**2) w l ls 1 title "2^{nd} order", \ + (4e-8 * x**3) w l ls 2 title "3^{rd} order", \ + "tet.unstruct.ho.N1.summary.txt" u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($5) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct.ho.N1.summary.txt" u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct.ho.N2.summary.txt" u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($5) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct.ho.N2.summary.txt" u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct.ho.N3.summary.txt" u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($5) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "tet.unstruct.ho.N3.summary.txt" u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)" , \ + movingFile("tet.unstruct.ho.N1.summary.txt") u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($5) w lp ls 111 notitle , \ + movingFile("tet.unstruct.ho.N1.summary.txt") u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($6) w lp ls 112 notitle , \ + movingFile("tet.unstruct.ho.N2.summary.txt") u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($5) w lp ls 121 notitle , \ + movingFile("tet.unstruct.ho.N2.summary.txt") u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($6) w lp ls 122 notitle , \ + movingFile("tet.unstruct.ho.N3.summary.txt") u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($5) w lp ls 131 notitle , \ + movingFile("tet.unstruct.ho.N3.summary.txt") u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($6) w lp ls 132 notitle \ No newline at end of file diff --git a/papers/JFNK_highOrder/linearElastic/cantilever/comparisonPlotScripts/stressErrors_movingVskExact.gnuplot b/papers/JFNK_highOrder/linearElastic/cantilever/comparisonPlotScripts/stressErrors_movingVskExact.gnuplot new file mode 100644 index 00000000..acfaac92 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/cantilever/comparisonPlotScripts/stressErrors_movingVskExact.gnuplot @@ -0,0 +1,86 @@ +set term pdfcairo dashed enhanced size 3.25,2 +set datafile separator " " + +if (ARGC < 1) { + print "Usage: gnuplot -c stressErrors_movingVskExact.gnuplot " + exit +} + +movingResults = ARG1 +movingFile(fileName) = sprintf("%s/%s", movingResults, fileName) + +#set size ratio 1 +beamArea= 0.2 + +set grid +set xrange [5:55] +set yrange [0.01:100] +set xtics +set xtics add (5, 25, 50) +set ytics +set logscale x +set logscale y +set format y "10^{%L}" +#set ytics 0.002 +set xlabel "Average cell edge (in mm)" +set ylabel "Error (in MPa)" +set key right bottom outside; +set rmargin 16 +set key spacing 1.2 + +# Polynomial guide lines (no title) +set style line 1 lc rgb "red" lt 2 lw 2 dt 2 +set style line 2 lc rgb "blue" lt 2 lw 2 dt 2 +set style line 3 lc rgb "violet" lt 2 lw 2 dt 2 + +# Data lines for each p-order (with titles) +set style line 11 lc rgb "red" pt 7 ps 0.5 lw 1 +set style line 12 lc rgb "red" pt 6 ps 0.5 lw 1 +set style line 21 lc rgb "blue" pt 5 ps 0.5 lw 1 +set style line 22 lc rgb "blue" pt 4 ps 0.5 lw 1 +set style line 31 lc rgb "violet" pt 9 ps 0.5 lw 1 +set style line 32 lc rgb "violet" pt 8 ps 0.5 lw 1 + +# Moving-least-squares data use the same colours with 50% transparency +set style line 111 lc rgb "#B3ff0000" pt 7 ps 0.5 lw 1 +set style line 112 lc rgb "#B3ff0000" pt 6 ps 0.5 lw 1 +set style line 121 lc rgb "#B30000ff" pt 5 ps 0.5 lw 1 +set style line 122 lc rgb "#B30000ff" pt 4 ps 0.5 lw 1 +set style line 131 lc rgb "#B3ee82ee" pt 9 ps 0.5 lw 1 +set style line 132 lc rgb "#B3ee82ee" pt 8 ps 0.5 lw 1 + +# set output "cantilever_stressErrors_hex.pdf" +# plot \ +# (0.2 * x**1) w l ls 1 title "1^{st} order", \ +# (2e-5 * x**2) w l ls 2 title "2^{nd} order", \ +# "hex.struct.ho.N1.summary.txt" u ((beamArea/$4)**0.5*1e3):($7*1e-6) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ +# "hex.struct.ho.N1.summary.txt" u ((beamArea/$4)**0.5*1e3):($8*1e-6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ +# "hex.struct.ho.N2.summary.txt" u ((beamArea/$4)**0.5*1e3):($7*1e-6) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ +# "hex.struct.ho.N2.summary.txt" u ((beamArea/$4)**0.5*1e3):($8*1e-6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)" + + +set output "cantilever_stressErrors_tet-struct_movingVskExact.pdf" +plot \ + (0.2 * x**1) w l ls 1 title "1^{st} order", \ + (2e-3 * x**2) w l ls 2 title "2^{nd} order", \ + "tet.struct.ho.N1.summary.txt" u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($7*1e-6) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.struct.ho.N1.summary.txt" u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($8*1e-6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.struct.ho.N2.summary.txt" u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($7*1e-6) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.struct.ho.N2.summary.txt" u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($8*1e-6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)" , \ + movingFile("tet.struct.ho.N1.summary.txt") u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($7*1e-6) w lp ls 111 notitle , \ + movingFile("tet.struct.ho.N1.summary.txt") u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($8*1e-6) w lp ls 112 notitle , \ + movingFile("tet.struct.ho.N2.summary.txt") u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($7*1e-6) w lp ls 121 notitle , \ + movingFile("tet.struct.ho.N2.summary.txt") u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($8*1e-6) w lp ls 122 notitle + +set output "cantilver_stressErrors_tet-unstruct_movingVskExact.pdf" +plot \ + (0.2 * x**1) w l ls 1 title "1^{st} order", \ + (2e-3 * x**2) w l ls 2 title "2^{nd} order", \ + "tet.unstruct.ho.N1.summary.txt" u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($7*1e-6) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct.ho.N1.summary.txt" u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($8*1e-6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct.ho.N2.summary.txt" u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($7*1e-6) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct.ho.N2.summary.txt" u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($8*1e-6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)" , \ + movingFile("tet.unstruct.ho.N1.summary.txt") u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($7*1e-6) w lp ls 111 notitle , \ + movingFile("tet.unstruct.ho.N1.summary.txt") u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($8*1e-6) w lp ls 112 notitle , \ + movingFile("tet.unstruct.ho.N2.summary.txt") u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($7*1e-6) w lp ls 121 notitle , \ + movingFile("tet.unstruct.ho.N2.summary.txt") u ((4*(beamArea/$4)/3**0.5)**0.5*1e3):($8*1e-6) w lp ls 122 notitle diff --git a/papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/Allwmake b/papers/JFNK_highOrder/linearElastic/cantilever/src/Allwmake similarity index 100% rename from papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/Allwmake rename to papers/JFNK_highOrder/linearElastic/cantilever/src/Allwmake diff --git a/papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/Make/files b/papers/JFNK_highOrder/linearElastic/cantilever/src/Make/files similarity index 100% rename from papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/Make/files rename to papers/JFNK_highOrder/linearElastic/cantilever/src/Make/files diff --git a/papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/Make/options b/papers/JFNK_highOrder/linearElastic/cantilever/src/Make/options similarity index 100% rename from papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/Make/options rename to papers/JFNK_highOrder/linearElastic/cantilever/src/Make/options diff --git a/papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/analyticalCantileverDisplacementFvPatchVectorField.C b/papers/JFNK_highOrder/linearElastic/cantilever/src/analyticalCantileverDisplacementFvPatchVectorField.C similarity index 98% rename from papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/analyticalCantileverDisplacementFvPatchVectorField.C rename to papers/JFNK_highOrder/linearElastic/cantilever/src/analyticalCantileverDisplacementFvPatchVectorField.C index 2d10789d..680ac6b4 100644 --- a/papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/analyticalCantileverDisplacementFvPatchVectorField.C +++ b/papers/JFNK_highOrder/linearElastic/cantilever/src/analyticalCantileverDisplacementFvPatchVectorField.C @@ -132,7 +132,7 @@ analyticalCantileverDisplacementFvPatchVectorField::evaluateQuadrature // faceQuadPoints is list for the whole mesh const CompactListList& faceQuadPoints = - solMod.displacementMLS().quadrature().faceQuadPoints(); + solMod.displacementLeastSquares().quadrature().faceQuadPoints(); // faceQuadPoints is list for whole mesh. labelList nQpPerFace(this->size(), 0); diff --git a/papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/analyticalCantileverDisplacementFvPatchVectorField.H b/papers/JFNK_highOrder/linearElastic/cantilever/src/analyticalCantileverDisplacementFvPatchVectorField.H similarity index 100% rename from papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/analyticalCantileverDisplacementFvPatchVectorField.H rename to papers/JFNK_highOrder/linearElastic/cantilever/src/analyticalCantileverDisplacementFvPatchVectorField.H diff --git a/papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/analyticalCantileverTractionFvPatchVectorField.C b/papers/JFNK_highOrder/linearElastic/cantilever/src/analyticalCantileverTractionFvPatchVectorField.C similarity index 98% rename from papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/analyticalCantileverTractionFvPatchVectorField.C rename to papers/JFNK_highOrder/linearElastic/cantilever/src/analyticalCantileverTractionFvPatchVectorField.C index 3dd3c92d..90e8c106 100644 --- a/papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/analyticalCantileverTractionFvPatchVectorField.C +++ b/papers/JFNK_highOrder/linearElastic/cantilever/src/analyticalCantileverTractionFvPatchVectorField.C @@ -157,7 +157,7 @@ analyticalCantileverTractionFvPatchVectorField::evaluateQuadrature // faceQuadPoints is list for the whole mesh const CompactListList& faceQuadPoints = - solMod.displacementMLS().quadrature().faceQuadPoints(); + solMod.displacementLeastSquares().quadrature().faceQuadPoints(); // faceQuadPoints is list for whole mesh. labelList nQpPerFace(this->size(), 0); diff --git a/papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/analyticalCantileverTractionFvPatchVectorField.H b/papers/JFNK_highOrder/linearElastic/cantilever/src/analyticalCantileverTractionFvPatchVectorField.H similarity index 100% rename from papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/analyticalCantileverTractionFvPatchVectorField.H rename to papers/JFNK_highOrder/linearElastic/cantilever/src/analyticalCantileverTractionFvPatchVectorField.H diff --git a/papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/cantileverAnalyticalSolution.C b/papers/JFNK_highOrder/linearElastic/cantilever/src/cantileverAnalyticalSolution.C similarity index 84% rename from papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/cantileverAnalyticalSolution.C rename to papers/JFNK_highOrder/linearElastic/cantilever/src/cantileverAnalyticalSolution.C index 11707cf1..9efe9aef 100644 --- a/papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/cantileverAnalyticalSolution.C +++ b/papers/JFNK_highOrder/linearElastic/cantilever/src/cantileverAnalyticalSolution.C @@ -22,6 +22,7 @@ License #include "volFields.H" #include "pointFields.H" #include "cantileverStressDisplacement.H" +#include "lookupSolidModel.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -40,6 +41,78 @@ namespace Foam // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +void Foam::cantileverAnalyticalSolution:: +calculateAnalyticalCellDisplacement +( + const fvMesh& mesh, + vectorField& analyticalD +) +{ + const solidModel& solMod = lookupSolidModel(mesh); + bool useCellAverage = false; + + if (solMod.highOrderResidual()) + { + const dictionary& displacementDict = + solMod.solidModelDict() + .subDict("highOrderCoeffs") + .subDict("displacement"); + useCellAverage = + displacementDict.lookupOrDefault + ( + "type", + "movingLeastSquares" + ) == "kExactLeastSquares"; + } + + if (useCellAverage) + { + const fvMeshQuadrature& quadrature = + solMod.displacementLeastSquares().quadrature(); + const CompactListList& cellQuadPoints = + quadrature.cellQuadPoints(); + const CompactListList& cellQuadWeights = + quadrature.cellQuadWeights(); + const scalarField& cellVolumes = mesh.V(); + + Info<< "Using cell-average analytical displacement" << endl; + + forAll(analyticalD, cellI) + { + analyticalD[cellI] = vector::zero; + + forAll(cellQuadPoints[cellI], pointI) + { + analyticalD[cellI] += + cellQuadWeights[cellI][pointI] + *cantileverDisplacement + ( + cellQuadPoints[cellI][pointI], + P_, E_, nu_, L_, D_, I_ + ); + } + + analyticalD[cellI] /= cellVolumes[cellI]; + } + } + else + { + Info<< "Using point-valued analytical displacement" << endl; + + const vectorField& cellCentres = mesh.C().internalField(); + + forAll(analyticalD, cellI) + { + analyticalD[cellI] = + cantileverDisplacement + ( + cellCentres[cellI], P_, E_, nu_, L_, D_, I_ + ); + } + } +} + + bool Foam::cantileverAnalyticalSolution::writeData() { // Lookup the solid mesh @@ -110,11 +183,11 @@ bool Foam::cantileverAnalyticalSolution::writeData() cantileverStress(CI[cellI], P_, E_, nu_, L_, D_, I_); } - if (cellDisplacement_) - { - aDI[cellI] = - cantileverDisplacement(CI[cellI], P_, E_, nu_, L_, D_, I_); - } + } + + if (cellDisplacement_) + { + calculateAnalyticalCellDisplacement(mesh, aDI); } forAll(analyticalStress.boundaryField(), patchI) diff --git a/papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/cantileverAnalyticalSolution.H b/papers/JFNK_highOrder/linearElastic/cantilever/src/cantileverAnalyticalSolution.H similarity index 95% rename from papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/cantileverAnalyticalSolution.H rename to papers/JFNK_highOrder/linearElastic/cantilever/src/cantileverAnalyticalSolution.H index 43a313b9..f46793e0 100644 --- a/papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/cantileverAnalyticalSolution.H +++ b/papers/JFNK_highOrder/linearElastic/cantilever/src/cantileverAnalyticalSolution.H @@ -101,6 +101,14 @@ class cantileverAnalyticalSolution // Private Member Functions + //- Calculate analytical cell displacement using the selected + // reconstruction semantics + void calculateAnalyticalCellDisplacement + ( + const fvMesh& mesh, + vectorField& analyticalD + ); + //- Write data bool writeData(); diff --git a/papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/cantileverStressDisplacement.C b/papers/JFNK_highOrder/linearElastic/cantilever/src/cantileverStressDisplacement.C similarity index 100% rename from papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/cantileverStressDisplacement.C rename to papers/JFNK_highOrder/linearElastic/cantilever/src/cantileverStressDisplacement.C diff --git a/papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/cantileverStressDisplacement.H b/papers/JFNK_highOrder/linearElastic/cantilever/src/cantileverStressDisplacement.H similarity index 100% rename from papers/JFNK_highOrder/linearElastic/cantilever/analyticalCantilever/cantileverStressDisplacement.H rename to papers/JFNK_highOrder/linearElastic/cantilever/src/cantileverStressDisplacement.H diff --git a/papers/JFNK_highOrder/linearElastic/cooksMembrane/Allrun b/papers/JFNK_highOrder/linearElastic/cooksMembrane/Allrun index 79b70895..94d0602b 100755 --- a/papers/JFNK_highOrder/linearElastic/cooksMembrane/Allrun +++ b/papers/JFNK_highOrder/linearElastic/cooksMembrane/Allrun @@ -6,13 +6,17 @@ source solids4FoamScripts.sh # Extend version not supported solids4Foam::caseDoesNotRunWithFoamExtend +# solids4foam location path +export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib/solids4foam-ib-2412/ +echo "SOLIDS4FOAM_DIR = $SOLIDS4FOAM_DIR" + # Define configurations as space-separated strings configs=( #"BASE=base/snes NAME=hex.lu PETSC_FILE=petscOptions.lu" - "BASE=base/segregated NAME=tet.seg GMSH_FILE=tet-unstructured" - "BASE=base/highOrder NAME=tet.ho.N1 polyOrder=1 extraCells=7 GMSH_FILE=tet-unstructured PETSC_FILE=petscOptions.lu HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.ho.N2 polyOrder=2 extraCells=10 GMSH_FILE=tet-unstructured PETSC_FILE=petscOptions.lu HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.ho.N3 polyOrder=3 extraCells=10 GMSH_FILE=tet-unstructured PETSC_FILE=petscOptions.lu HOJAC=false HORES=true" + #"BASE=base/segregated NAME=tet.seg GMSH_FILE=tet-unstructured" + "BASE=base/highOrder NAME=tet.ho.N1 polyOrder=1 extraCells=7 GMSH_FILE=tet-unstructured PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.ho.N2 polyOrder=2 extraCells=10 GMSH_FILE=tet-unstructured PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.ho.N3 polyOrder=3 extraCells=10 GMSH_FILE=tet-unstructured PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=movingLeastSquares" ) # SNES segregated approach # "BASE=base/snes NAME=hex.seg.lu PETSC_FILE=petscOptions.seg.lu" @@ -50,7 +54,7 @@ cd "${RUN_DIR}" for config in "${configs[@]}" do # Reset variables in the case some variable is not used - unset GMSH_FILE PETSC_FILE N Nn + unset GMSH_FILE PETSC_FILE N Nn TYPE # Parse the configuration string eval $config @@ -109,6 +113,11 @@ do sed -i "/^\s*optionsFile /s|^.*| optionsFile ${PETSC_FILE};|" constant/solidProperties fi + # Update the least squares type + if [ -n "${TYPE}" ]; then + sed -i "/^\s*type \(movingLeastSquares\|kExactLeastSquares\);/s|^.*| type ${TYPE};|" constant/solidProperties + fi + # Update how Jacobian is calculated if [ -n "${HOJAC}" ]; then sed -i "/^\s*highOrderJacobian /s|^.*| highOrderJacobian ${HOJAC};|" constant/solidProperties diff --git a/papers/JFNK_highOrder/linearElastic/cooksMembrane/Allrun.kExact b/papers/JFNK_highOrder/linearElastic/cooksMembrane/Allrun.kExact new file mode 100755 index 00000000..a5e5d307 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/cooksMembrane/Allrun.kExact @@ -0,0 +1,216 @@ +#!/bin/bash + +# Source required functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions +source solids4FoamScripts.sh +# Extend version not supported +solids4Foam::caseDoesNotRunWithFoamExtend + +# solids4foam location path +export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib/solids4foam-ib-2412/ +echo "SOLIDS4FOAM_DIR = $SOLIDS4FOAM_DIR" + +# Define configurations as space-separated strings +configs=( + #"BASE=base/snes NAME=hex.lu PETSC_FILE=petscOptions.lu" + #"BASE=base/segregated NAME=tet.seg GMSH_FILE=tet-unstructured" + "BASE=base/highOrder NAME=tet.ho.N1 polyOrder=1 extraCells=7 GMSH_FILE=tet-unstructured PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.ho.N2 polyOrder=2 extraCells=10 GMSH_FILE=tet-unstructured PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.ho.N3 polyOrder=3 extraCells=10 GMSH_FILE=tet-unstructured PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=kExactLeastSquares" +) +# SNES segregated approach +# "BASE=base/snes NAME=hex.seg.lu PETSC_FILE=petscOptions.seg.lu" + +# Define start and end mesh indices +# Mesh input files are defined from 1 to 8 +START_MESH=1 +END_MESH=8 + + +# Detect the CPU type: we append this to the case name +if [[ "$OSTYPE" == "darwin"* ]] +then + # macOS + CPU_TYPE=$(sysctl -n machdep.cpu.brand_string | sed 's/[^a-zA-Z0-9]/_/g') +elif [[ -f /proc/cpuinfo ]] +then + # Linux + CPU_TYPE=$(grep -m 1 "model name" /proc/cpuinfo | awk -F': ' '{print $2}' | sed 's/[^a-zA-Z0-9]/_/g') +else + # Fallback if neither method works + CPU_TYPE="Unknown_CPU" +fi + +# Create timestamped working directory for this run +DATE=$(date +%Y-%m-%d_%H-%M-%S) +RUN_DIR="run_${CPU_TYPE}_${DATE}" +echo "Creating ${RUN_DIR}" +mkdir "${RUN_DIR}" + +# Enter the run directory +cd "${RUN_DIR}" + +# Iterate through configurations +for config in "${configs[@]}" +do + # Reset variables in the case some variable is not used + unset GMSH_FILE PETSC_FILE N Nn TYPE + + # Parse the configuration string + eval $config + echo; echo "***************************************" + echo "Running configuration: $config" + echo "***************************************" + + # Define results summary file name + SUMMARY="${NAME}.summary.txt" + echo "# Mesh Time Mem CellsNumber D" > "${SUMMARY}" + + # Loop over mesh densities in each configuration + for i in `seq $START_MESH $END_MESH` + do + CASE="${NAME}.$i" + echo; echo "Processing case: $CASE" + + # Prepare the case + cp -r "../${BASE}" "${CASE}" + cd "$CASE" + + # Create the mesh + if [ -n "${GMSH_FILE}" ]; then + if command -v gmsh &> /dev/null + then + # Remporarily rename 0 to avoid issues + mv 0 0.tmp + cp "gmsh/meshSpacing/meshSpacing$i.geo" "gmsh/meshSpacing/meshSpacing.geo" + solids4Foam::runApplication gmsh -3 -format msh2 gmsh/"${GMSH_FILE}.geo" + solids4Foam::runApplication gmshToFoam gmsh/"${GMSH_FILE}.msh" + solids4Foam::runApplication changeDictionary + # Move 0 back + mv 0.tmp 0 + else + # Fail silently + echo; echo "Gmsh is required for tet meshes: please install it" + exit 0 + fi + else + # Replace the blockMeshDict + if [[ ! -f "system/blockMeshDict.$i" ]] + then + echo "Cannot find ${CASE}/system/blockMeshDict.$i: please add it to ${BASE}/meshes/"; echo + exit 1; + else + echo "Copying ${CASE}/system/blockMeshDict.$i to ${CASE}/system/blockMeshDict" + \cp "system/blockMeshDict.$i" system/blockMeshDict + rm -f constant/polyMesh/blockMeshDict + fi + solids4Foam::runApplication blockMesh + fi + solids4Foam::runApplication checkMesh + + # Update the PETSc options file + if [ -n "${PETSC_FILE}" ]; then + sed -i "/^\s*optionsFile /s|^.*| optionsFile ${PETSC_FILE};|" constant/solidProperties + fi + + # Update the least squares type + if [ -n "${TYPE}" ]; then + sed -i "/^\s*type \(movingLeastSquares\|kExactLeastSquares\);/s|^.*| type ${TYPE};|" constant/solidProperties + fi + + # Update how Jacobian is calculated + if [ -n "${HOJAC}" ]; then + sed -i "/^\s*highOrderJacobian /s|^.*| highOrderJacobian ${HOJAC};|" constant/solidProperties + fi + + # Update how Residual is calculated + if [ -n "${HORES}" ]; then + sed -i "/^\s*highOrderResidual /s|^.*| highOrderResidual ${HORES};|" constant/solidProperties + fi + + # Update the order + if [ -n "${polyOrder}" ]; then + sed -i "/^\s*polynomialOrder /s|^.*| polynomialOrder ${polyOrder};|" constant/solidProperties + fi + + # Update number of stencil cells + if [ -n "${extraCells}" ]; then + sed -i "/^\s*faceStencilExtraCells /s|^.*| faceStencilExtraCells ${extraCells};|" constant/solidProperties + fi + + # Run the solver + # If "gtime" is available (could be called "time" on Linux), use it to + # record the max memory usage + if command -v gtime &> /dev/null + then + echo "Running solids4Foam on ${CASE} with gtime" + gtime -f "gtime/time (wall clock) time: %e\nMaximum resident set size (kbytes): %M" solids4Foam &> log.solids4Foam + + elif [ -x /usr/bin/time ] + then + echo "Running solids4Foam on ${CASE} with /usr/bin/time" + /usr/bin/time -f "gtime/time (wall clock) time: %e\nMaximum resident set size (kbytes): %M" solids4Foam &> log.solids4Foam + + elif command -v time &> /dev/null + then + echo "Running solids4Foam on ${CASE} with shell builtin time (no max memory)" + time solids4Foam &> log.solids4Foam + + else + echo "Running solids4Foam on ${CASE}" + solids4Foam::runApplication solids4Foam + fi + + # Extract results from solver log and append them to a summary file + echo; echo "Appending results to ${SUMMARY}" + if grep -q "gtime/time" log.solids4Foam; then + CLOCK_TIME=$(grep "gtime/time" log.solids4Foam | awk '{print $5}') + else + # Record the time + CLOCK_TIME=$(grep "ClockTime" log.solids4Foam | awk '{print $7}') + fi + + # Extract results from solver log and append them to a summary file + if grep -q "Maximum resident" log.solids4Foam; then + MAX_MEMORY=$(grep "Maximum resident" log.solids4Foam | awk '{print int($6 / 1000)}') + else + MAX_MEMORY="NaN" + fi + + # Number of cells + CELLS=$(grep "cells:" log.checkMesh | awk '{print $2}') + + # Extract the reference point vertical displacement + DISP=$(tail -1 postProcessing/0/solidPointDisplacement_pointDisp.dat | awk '{print $3}') + + # Write data to file + echo "$i $CLOCK_TIME $MAX_MEMORY $CELLS $DISP" >> ../"${SUMMARY}" + + cd .. + done + + # Print summary file + echo; echo "${SUMMARY} file:"; cat "${SUMMARY}"; echo +done + +# Create plots if gnuplot in installed +if command -v gnuplot &>/dev/null +then + # Copy gnuplot scripts + cp ../plotScripts/* . + + # Run all scripts + for f in *gnuplot + do + echo "Running gnuplot on $f" + gnuplot "$f" 2>/dev/null + done +fi + +# Exit the run directory +cd .. + +echo; echo; echo "Done!"; echo +echo "View the PDF files in ${RUN_DIR}" +echo; echo $(date +%Y%m%d_%H%M%S) +echo; echo diff --git a/papers/JFNK_highOrder/linearElastic/cooksMembrane/base/highOrder/constant/solidProperties b/papers/JFNK_highOrder/linearElastic/cooksMembrane/base/highOrder/constant/solidProperties index fc91a36e..de726820 100644 --- a/papers/JFNK_highOrder/linearElastic/cooksMembrane/base/highOrder/constant/solidProperties +++ b/papers/JFNK_highOrder/linearElastic/cooksMembrane/base/highOrder/constant/solidProperties @@ -33,6 +33,7 @@ linearGeometryTotalDisplacementCoeffs displacement { + type movingLeastSquares; polynomialOrder 2; faceStencilExtraCells 10; diff --git a/papers/JFNK_highOrder/linearElastic/cooksMembrane/comparisonPlotScripts/dispVsLiterature_movingVskExact.gnuplot b/papers/JFNK_highOrder/linearElastic/cooksMembrane/comparisonPlotScripts/dispVsLiterature_movingVskExact.gnuplot new file mode 100644 index 00000000..5ddd146b --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/cooksMembrane/comparisonPlotScripts/dispVsLiterature_movingVskExact.gnuplot @@ -0,0 +1,64 @@ +set term pdfcairo dashed enhanced size 3.25,2 +set datafile separator " " + +if (ARGC < 1) { + print "Usage: gnuplot -c dispVsLiterature_movingVskExact.gnuplot " + exit +} + +movingResults = ARG1 +movingFile(fileName) = sprintf("%s/%s", movingResults, fileName) + +set grid +set xrange [0.099:20] +set yrange [14:34] +set xtics +#set ytics (0.7, 0.8, 0.9, 1) + +set logscale x +set format x "%g" + +#set logscale y +#set ytics 0.002 +set xlabel "Average cell spacing (in mm)" +set ylabel "Reference point vertical\n displacement (in µm)" +set key left b + +# Data lines for each p-order (with titles) +set style line 11 lc rgb "red" pt 7 ps 0.75 lw 1 +set style line 12 lc rgb "red" pt 6 ps 0.75 lw 1 +set style line 21 lc rgb "blue" pt 5 ps 0.75 lw 1 +set style line 22 lc rgb "blue" pt 4 ps 0.75 lw 1 +set style line 31 lc rgb "violet" pt 9 ps 0.75 lw 1 +set style line 32 lc rgb "violet" pt 8 ps 0.75 lw 1 + +# Moving-least-squares data use the same colours with 50% transparency +set style line 111 lc rgb "#80ff0000" pt 7 ps 0.5 lw 1 +set style line 112 lc rgb "#80ff0000" pt 6 ps 0.5 lw 1 +set style line 121 lc rgb "#800000ff" pt 5 ps 0.5 lw 1 +set style line 122 lc rgb "#800000ff" pt 4 ps 0.5 lw 1 +set style line 131 lc rgb "#80ee82ee" pt 9 ps 0.5 lw 1 +set style line 132 lc rgb "#80ee82ee" pt 8 ps 0.5 lw 1 + +# Average mesh spacing of mesh1 +# First mesh have 9 elements and one element area is then 0.00016. sqrt of that is 0.012649 +dx=12.649 + +#Average mesh spacing of mesh 1 for Zienkiewicz and Taylor results +dxZT = 18.973666 + +file = "hex.lu.summary.txt" +file_ZT = "ZienkiewiczAndTaylor.dat" +file_A = "Abaqus.dat" +area=1440 + +set output "CooksMembrane-tet-hookeanTipDispConvergence_movingVskExact.pdf" +plot \ + file_ZT u (dxZT/(2**($0))):($2) w lp pt 8 ps 1 lw 1.2 lc "gray" t "Zienkiewicz and Taylor (2000) - Q4",\ + file_A u 2:4 w lp pt 4 ps 1 lw 1.2 lc "purple" t "Abaqus (CPE4H)",\ + "tet.ho.N1.summary.txt" u ((4*(area/$4)/3**0.5)**0.5):($5*1000*1000) w lp ls 11 t"{/Times-Italic p}_{ }=1", \ + "tet.ho.N2.summary.txt" u ((4*(area/$4)/3**0.5)**0.5):($5*1000*1000) w lp ls 21 t"{/Times-Italic p}_{ }=2", \ + "tet.ho.N3.summary.txt" u ((4*(area/$4)/3**0.5)**0.5):($5*1000*1000) w lp ls 31 t"{/Times-Italic p}_{ }=3" , \ + movingFile("tet.ho.N1.summary.txt") u ((4*(area/$4)/3**0.5)**0.5):($5*1000*1000) w lp ls 111 notitle , \ + movingFile("tet.ho.N2.summary.txt") u ((4*(area/$4)/3**0.5)**0.5):($5*1000*1000) w lp ls 121 notitle , \ + movingFile("tet.ho.N3.summary.txt") u ((4*(area/$4)/3**0.5)**0.5):($5*1000*1000) w lp ls 131 notitle diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/Allrun b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/Allrun index b1ff03fe..68e7c06f 100755 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/Allrun +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/Allrun @@ -7,11 +7,11 @@ source solids4FoamScripts.sh solids4Foam::caseDoesNotRunWithFoamExtend # solids4Foam location path -export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib-highOrder +export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib/solids4foam-ib-2412/ echo "SOLIDS4FOAM_DIR = $SOLIDS4FOAM_DIR" # Compile the manucafturedSolution library -(cd manufacturedSolution && wclean libso && ./Allwmake -j -s) +(cd src && wclean libso && ./Allwmake -j -s) # Define configurations as space-separated strings configs=( @@ -25,21 +25,21 @@ configs=( # "BASE=base/segregated NAME=tet.unstruct_v1.seg GMSH_FILE=tet-unstructured_v1 USE_PERTURBMESHPOINTS=0" # "BASE=base/segregated NAME=tet.unstruct_v2.seg GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0" # "BASE=base/segregated NAME=poly.struct.seg GMSH_FILE=poly-structured USE_PERTURBMESHPOINTS=0" - "BASE=base/highOrder NAME=hex.struct.ho.N1 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 HOJAC=false HORES=true PETSC_FILE=petscOptions.lu" - "BASE=base/highOrder NAME=hex.struct.ho.N2 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 HOJAC=false HORES=true PETSC_FILE=petscOptions.lu" - "BASE=base/highOrder NAME=hex.struct.ho.N3 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 HOJAC=false HORES=true PETSC_FILE=petscOptions.lu" - "BASE=base/highOrder NAME=tet.struct.ho.N1 GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 HOJAC=false HORES=true PETSC_FILE=petscOptions.lu" - "BASE=base/highOrder NAME=tet.struct.ho.N2 GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 HOJAC=false HORES=true PETSC_FILE=petscOptions.lu" - "BASE=base/highOrder NAME=tet.struct.ho.N3 GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 HOJAC=false HORES=true PETSC_FILE=petscOptions.lu" - "BASE=base/highOrder NAME=tet.unstruct_v1.ho.N1 GMSH_FILE=tet-unstructured_v1 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 HOJAC=false HORES=true PETSC_FILE=petscOptions.lu" - "BASE=base/highOrder NAME=tet.unstruct_v1.ho.N2 GMSH_FILE=tet-unstructured_v1 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 HOJAC=false HORES=true PETSC_FILE=petscOptions.lu" - "BASE=base/highOrder NAME=tet.unstruct_v1.ho.N3 GMSH_FILE=tet-unstructured_v1 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 HOJAC=false HORES=true PETSC_FILE=petscOptions.lu" - "BASE=base/highOrder NAME=tet.unstruct_v2.ho.N1 GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 HOJAC=false HORES=true PETSC_FILE=petscOptions.lu" - "BASE=base/highOrder NAME=tet.unstruct_v2.ho.N2 GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 HOJAC=false HORES=true PETSC_FILE=petscOptions.lu" - "BASE=base/highOrder NAME=tet.unstruct_v2.ho.N3 GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 HOJAC=false HORES=true PETSC_FILE=petscOptions.lu" - "BASE=base/highOrder NAME=poly.struct.ho.N1 GMSH_FILE=poly-structured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 HOJAC=false HORES=true PETSC_FILE=petscOptions.lu" - "BASE=base/highOrder NAME=poly.struct.ho.N2 GMSH_FILE=poly-structured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 HOJAC=false HORES=true PETSC_FILE=petscOptions.lu" - "BASE=base/highOrder NAME=poly.struct.ho.N3 GMSH_FILE=poly-structured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 HOJAC=false HORES=true PETSC_FILE=petscOptions.lu" + "BASE=base/highOrder NAME=hex.struct.ho.N1 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=hex.struct.ho.N2 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=hex.struct.ho.N3 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N1 GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N2 GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N3 GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct_v1.ho.N1 GMSH_FILE=tet-unstructured_v1 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct_v1.ho.N2 GMSH_FILE=tet-unstructured_v1 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct_v1.ho.N3 GMSH_FILE=tet-unstructured_v1 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct_v2.ho.N1 GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct_v2.ho.N2 GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct_v2.ho.N3 GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=poly.struct.ho.N1 GMSH_FILE=poly-structured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=poly.struct.ho.N2 GMSH_FILE=poly-structured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=poly.struct.ho.N3 GMSH_FILE=poly-structured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 HOJAC=false HORES=true TYPE=movingLeastSquares" ) # SNES segregated approach @@ -82,7 +82,7 @@ cd "${RUN_DIR}" for config in "${configs[@]}" do # Reset variables in the case some variable is not used - unset GMSH_FILE PETSC_FILE order extraCells HOJAC HORES + unset GMSH_FILE polyOrder extraCells HOJAC HORES TYPE # Parse the configuration string eval $config @@ -132,21 +132,21 @@ do fi solids4Foam::runApplication checkMesh - # Update the PETSc options file - if [ -n "${PETSC_FILE}" ]; then - sed -i "/^\s*optionsFile /s|^.*| optionsFile ${PETSC_FILE};|" constant/solidProperties - fi - - # Update the order in the LRECoeffs + # Update the order if [ -n "${polyOrder}" ]; then sed -i "/^\s*polynomialOrder /s|^.*| polynomialOrder ${polyOrder};|" constant/solidProperties fi - # Update number of stencil cells in the LRECoeffs + # Update number of stencil cells in stencil if [ -n "${extraCells}" ]; then sed -i "/^\s*faceStencilExtraCells /s|^.*| faceStencilExtraCells ${extraCells};|" constant/solidProperties fi + # Update least-squares reconstruction type + if [ -n "${TYPE}" ]; then + sed -i "/^\s*type \(movingLeastSquares\|kExactLeastSquares\);/s|^.*| type ${TYPE};|" constant/solidProperties + fi + # Update how Jacobian is calculated if [ -n "${HOJAC}" ]; then sed -i "/^\s*highOrderJacobian /s|^.*| highOrderJacobian ${HOJAC};|" constant/solidProperties diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/Allrun.kExact b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/Allrun.kExact new file mode 100755 index 00000000..3c49cf81 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/Allrun.kExact @@ -0,0 +1,241 @@ +#!/bin/bash + +# Source required functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions +source solids4FoamScripts.sh +# Extend version not supported +solids4Foam::caseDoesNotRunWithFoamExtend + +# solids4Foam location path +export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib/solids4foam-ib-2412/ +echo "SOLIDS4FOAM_DIR = $SOLIDS4FOAM_DIR" + +# Compile the manucafturedSolution library +(cd src && wclean libso && ./Allwmake -j -s) + +# Define configurations as space-separated strings +configs=( + # "BASE=base/snes NAME=hex.struct.hypre-snes GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 PETSC_FILE=petscOptions.lu" + # "BASE=base/snes NAME=tet.struct.hypre-snes GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0 PETSC_FILE=petscOptions.lu" + # "BASE=base/snes NAME=tet.unstruct_v1.hypre-snes GMSH_FILE=tet-unstructured_v1 USE_PERTURBMESHPOINTS=0 PETSC_FILE=petscOptions.lu" + # "BASE=base/snes NAME=tet.unstruct_v2.hypre-snes GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0 PETSC_FILE=petscOptions.lu" + # "BASE=base/snes NAME=poly.struct.hypre-snes GMSH_FILE=poly-structured USE_PERTURBMESHPOINTS=0 PETSC_FILE=petscOptions.lu" + # "BASE=base/segregated NAME=hex.struct.seg GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0" + # "BASE=base/segregated NAME=tet.struct.seg GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0" + # "BASE=base/segregated NAME=tet.unstruct_v1.seg GMSH_FILE=tet-unstructured_v1 USE_PERTURBMESHPOINTS=0" + # "BASE=base/segregated NAME=tet.unstruct_v2.seg GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0" + # "BASE=base/segregated NAME=poly.struct.seg GMSH_FILE=poly-structured USE_PERTURBMESHPOINTS=0" + "BASE=base/highOrder NAME=hex.struct.ho.N1 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=hex.struct.ho.N2 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=hex.struct.ho.N3 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N1 GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N2 GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N3 GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct_v1.ho.N1 GMSH_FILE=tet-unstructured_v1 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct_v1.ho.N2 GMSH_FILE=tet-unstructured_v1 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct_v1.ho.N3 GMSH_FILE=tet-unstructured_v1 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct_v2.ho.N1 GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct_v2.ho.N2 GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct_v2.ho.N3 GMSH_FILE=tet-unstructured_v2 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=poly.struct.ho.N1 GMSH_FILE=poly-structured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=poly.struct.ho.N2 GMSH_FILE=poly-structured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=poly.struct.ho.N3 GMSH_FILE=poly-structured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 HOJAC=false HORES=true TYPE=kExactLeastSquares" +) + +# SNES segregated approach +# "BASE=base/snes NAME=hex.struct.hypre-snes-seg GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 PETSC_FILE=petscOptions.seg.hypre" +# "BASE=base/snes NAME=tet.struct.hypre-snes-seg GMSH_FILE=tet-structured USE_PERTURBMESHPOINTS=0 PETSC_FILE=petscOptions.seg.hypre" +# "BASE=base/snes NAME=tet.unstruct.hypre-snes-seg GMSH_FILE=tet-unstructured USE_PERTURBMESHPOINTS=0 PETSC_FILE=petscOptions.seg.hypre" + +# Define start and end mesh indices +# Mesh input files are defined from 1 to 32 +# END_MESH should be greater than START_MESH +START_MESH=1 +END_MESH=32 + + +# Detect the CPU type: we append this to the case name +if [[ "$OSTYPE" == "darwin"* ]] +then + # macOS + CPU_TYPE=$(sysctl -n machdep.cpu.brand_string | sed 's/[^a-zA-Z0-9]/_/g') +elif [[ -f /proc/cpuinfo ]] +then + # Linux + CPU_TYPE=$(grep -m 1 "model name" /proc/cpuinfo | awk -F': ' '{print $2}' | sed 's/[^a-zA-Z0-9]/_/g') +else + # Fallback if neither method works + CPU_TYPE="Unknown_CPU" +fi + + +# Create timestamped working directory for this run +DATE=$(date +%Y-%m-%d_%H-%M-%S) +RUN_DIR="run_${CPU_TYPE}_${DATE}" +echo "Creating ${RUN_DIR}" +mkdir "${RUN_DIR}" + +# Enter the run directory +cd "${RUN_DIR}" + +# Iterate through configurations +for config in "${configs[@]}" +do + # Reset variables in the case some variable is not used + unset GMSH_FILE polyOrder extraCells HOJAC HORES TYPE + + # Parse the configuration string + eval $config + echo; echo "***************************************" + echo "Running configuration: $config" + echo "***************************************" + + # Define results summary file name + SUMMARY="${NAME}.summary.txt" + echo "# Mesh Time Mem CellsNumber D_L2 D_Linf S_L2 S_Linf" > "${SUMMARY}" + + # Loop over mesh densities in each configuration + for i in `seq $START_MESH $END_MESH` + do + CASE="${NAME}.$i" + echo; echo "Processing case: $CASE" + + # Prepare the case + cp -rL "../${BASE}" "${CASE}" + cd "$CASE" + + # GMSH Mesh generation + if [[ "$GMSH_FILE" == "poly-structured" ]] + then + # Special prcedure for generating polyhedral mesh + cp "gmsh/meshSpacing/meshSpacing$i.geo" "gmsh/meshSpacing/meshSpacing.geo" + solids4Foam::runApplication gmsh -3 -format msh2 gmsh/"${GMSH_FILE}.geo" + solids4Foam::runApplication gmshToFoam gmsh/"${GMSH_FILE}.msh" + mv 0/ 0.tmp + solids4Foam::runApplication polyDualMesh 30 -overwrite + solids4Foam::runApplication combinePatchFaces 45 -overwrite + solids4Foam::runApplication extrudeMesh + solids4Foam::runApplication createPatch -overwrite + mv 0.tmp/ 0 + else + # Other types of meshes + cp "gmsh/meshSpacing/meshSpacing$i.geo" "gmsh/meshSpacing/meshSpacing.geo" + solids4Foam::runApplication gmsh -3 -format msh2 gmsh/"${GMSH_FILE}.geo" + solids4Foam::runApplication gmshToFoam gmsh/"${GMSH_FILE}.msh" + solids4Foam::runApplication changeDictionary + fi + + # Optional mesh distortion + if [ "$USE_PERTURBMESHPOINTS" -eq 1 ] + then + solids4Foam::runApplication perturbMeshPoints + fi + solids4Foam::runApplication checkMesh + + # Update the order + if [ -n "${polyOrder}" ]; then + sed -i "/^\s*polynomialOrder /s|^.*| polynomialOrder ${polyOrder};|" constant/solidProperties + fi + + # Update number of stencil cells in stencil + if [ -n "${extraCells}" ]; then + sed -i "/^\s*faceStencilExtraCells /s|^.*| faceStencilExtraCells ${extraCells};|" constant/solidProperties + fi + + # Update least-squares reconstruction type + if [ -n "${TYPE}" ]; then + sed -i "/^\s*type \(movingLeastSquares\|kExactLeastSquares\);/s|^.*| type ${TYPE};|" constant/solidProperties + fi + + # Update how Jacobian is calculated + if [ -n "${HOJAC}" ]; then + sed -i "/^\s*highOrderJacobian /s|^.*| highOrderJacobian ${HOJAC};|" constant/solidProperties + fi + + # Update how Residual is calculated + if [ -n "${HORES}" ]; then + sed -i "/^\s*highOrderResidual /s|^.*| highOrderResidual ${HORES};|" constant/solidProperties + fi + + # Run the solver + # If "gtime" is available (could be called "time" on Linux), use it to + # record the max memory usage + if command -v gtime &> /dev/null + then + echo "Running solids4Foam on ${CASE} with gtime" + gtime -f "Maximum resident set size (kbytes): %M" solids4Foam &> log.solids4Foam + + elif [ -x /usr/bin/time ] + then + echo "Running solids4Foam on ${CASE} with /usr/bin/time" + /usr/bin/time -f "Maximum resident set size (kbytes): %M" solids4Foam &> log.solids4Foam + + elif command -v time &> /dev/null + then + echo "Running solids4Foam on ${CASE} with shell builtin time (no max memory)" + time mpirun -np 1 solids4Foam &> log.solids4Foam + + else + solids4Foam::runApplication solids4Foam + fi + + # Extract results from solver log and append them to a summary file + echo; echo "Appending results to ${SUMMARY}" + if grep -q "Maximum resident" log.solids4Foam; then + MAX_MEMORY=$(grep "Maximum resident" log.solids4Foam | awk '{print int($6 / 1000)}') + else + MAX_MEMORY="NaN" + fi + + # Record the time + CLOCK_TIME=$(grep "ClockTime" log.solids4Foam | awk '{print $7}') + + # Number of cells + CELLS=$(grep "cells:" log.checkMesh | awk '{print $2}') + + # Extract the L2 (average) error for displacement + DISP_L2_ERROR=$(grep "Writing DDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $3}') + + # Extract the LInfinity (max) error for displacement + DISP_LINF_ERROR=$(grep "Writing DDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $4}') + + # Extract the L2 (average) error for mag(sigma) + STRESS_L2_ERROR=$(grep "Writing sigmaDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $3}') + + # Extract the LInfinity (max) error for mag(sigma) + STRESS_LINF_ERROR=$(grep "Writing sigmaDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $4}') + + # Write data to file + echo "$i $CLOCK_TIME $MAX_MEMORY $CELLS $DISP_L2_ERROR $DISP_LINF_ERROR $STRESS_L2_ERROR $STRESS_LINF_ERROR" >> ../"${SUMMARY}" + + cd .. + done + + # Print summary file + echo; echo "${SUMMARY} file:"; cat "${SUMMARY}"; echo + +done + +# Create plots if gnuplot in installed +if command -v gnuplot &>/dev/null +then + # Copy gnuplot scripts + cp ../plotScripts/*gnuplot . + + # Run all scripts + for f in *gnuplot + do + echo "Running gnuplot on $f" + gnuplot "$f" 2>/dev/null + done + + mkdir dispErrorComparisonMatlab/ + mkdir stressErrorComparisonMatlab/ + mv mms_dispErrorsComparison* dispErrorComparisonMatlab/ + mv mms_stressErrorsComparison* stressErrorComparisonMatlab/ +fi + +echo; echo; echo "Done!"; echo +echo "View the PDF files in ${RUN_DIR}" +echo; echo $(date) +echo; echo diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/base/highOrder/constant/solidProperties b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/base/highOrder/constant/solidProperties index 05c35020..6d839ba2 100644 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/base/highOrder/constant/solidProperties +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/base/highOrder/constant/solidProperties @@ -22,9 +22,7 @@ solidModel linearGeometryTotalDisplacement; linearGeometryTotalDisplacementCoeffs { // Solution algorithm - //solutionAlgorithm implicitCoupled; solutionAlgorithm PETScSNES; - optionsFile petscOptions.ksponly; highOrderCoeffs { @@ -33,6 +31,8 @@ linearGeometryTotalDisplacementCoeffs displacement { + type movingLeastSquares; + polynomialOrder 2; faceStencilExtraCells 10; diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/base/highOrder/petscOptions.ksponly b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/base/highOrder/petscOptions.ksponly deleted file mode 100644 index 8dcc7929..00000000 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/base/highOrder/petscOptions.ksponly +++ /dev/null @@ -1,97 +0,0 @@ -# # Nonlinear solver -# # The default line search may sometimes fail; in that case, switch to "basic" -# -snes_type newtonls -# -snes_linesearch_type basic -# -snes_rtol 1e-6 -# -snes_stol 1e-6 -# -snes_max_it 1000 -# -snes_monitor -# -snes_converged_reason - -# # Calculate the Jacobian using matrix-free finite differencing -# -snes_mf -# -snes_mf_operator - -# # Linear solver -# # Increase the restart (directions) if it is struggling to converged -# -ksp_type lgmres -# #-ksp_gmres_restart 100 -# #-ksp_rtol 1e-3 -# -ksp_monitor -# #-ksp_view -# -ksp_converged_reason - -# # Preconditioner - LU -# # Good for small/medium cases but will require large amounts of memory for -# # larger models -# -pc_type bjacobi -# -sub_pc_type lu - -# # Preconditioner - ILU -# # Less expensive than LU but not as good -# # Increasing the levels (fill-in) improves the preconditioning but is more -# # expensive -# #-pc_type asm -# #-sub_pc_type ilu -# #-sub_pc_factor_levels 1 - -# # Preconditioner - multigrid -# # Should perform better than LU for larger cases -# # -pc_type hypre -# # -pc_hypre_type boomeramg -# # -pc_hypre_boomeramg_max_iter 1 -# # #-pc_hypre_boomeramg_strong_threshold 0.25 -# # -pc_hypre_boomeramg_strong_threshold 0.7 -# # -pc_hypre_boomeramg_grid_sweeps_up 1 -# # -pc_hypre_boomeramg_grid_sweeps_down 1 -# # -pc_hypre_boomeramg_agg_nl 1 -# # -pc_hypre_boomeramg_agg_num_paths 1 -# # -pc_hypre_boomeramg_max_levels 25 -# # -pc_hypre_boomeramg_coarsen_type HMIS -# # -pc_hypre_boomeramg_interp_type ext+i -# # -pc_hypre_boomeramg_P_max 1 -# # -pc_hypre_boomeramg_truncfactor 0.3 - -# # Construct the precondioner once and store it since it does not change -# -snes_lag_preconditioner_persists true -# -snes_lag_preconditioner -2 - -# #-snes_test_jacobian -# #-snes_test_jacobian_view - - - --snes_type ksponly --snes_converged_reason - -# Linear solver --ksp_type lgmres --ksp_rtol 1e-8 --ksp_atol 0 --ksp_monitor --ksp_max_it 2000 --ksp_gmres_restart 100 -#-ksp_monitor_true_residual -#-ksp_converged_reason --ksp_error_if_not_converged -# (Avoid restarts at first; add -ksp_gmres_restart 200 only if memory becomes an issue) - -# Preconditioner - multigrid -# Should perform better than LU for larger cases --pc_type hypre --pc_hypre_type boomeramg --pc_hypre_boomeramg_max_iter 1 -#-pc_hypre_boomeramg_strong_threshold 0.25 --pc_hypre_boomeramg_strong_threshold 0.7 --pc_hypre_boomeramg_grid_sweeps_up 1 --pc_hypre_boomeramg_grid_sweeps_down 1 --pc_hypre_boomeramg_agg_nl 1 --pc_hypre_boomeramg_agg_num_paths 1 --pc_hypre_boomeramg_max_levels 25 --pc_hypre_boomeramg_coarsen_type HMIS --pc_hypre_boomeramg_interp_type ext+i --pc_hypre_boomeramg_P_max 1 --pc_hypre_boomeramg_truncfactor 0.3 - -#-pc_type bjacobi -#-sub_pc_type lu \ No newline at end of file diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/base/highOrder/petscOptions.lu b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/base/highOrder/petscOptions.lu deleted file mode 100644 index 34c09497..00000000 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/base/highOrder/petscOptions.lu +++ /dev/null @@ -1,57 +0,0 @@ -# Nonlinear solver -# The default line search may sometimes fail; in that case, switch to "basic" --snes_type newtonls --snes_linesearch_type basic --snes_rtol 1e-6 --snes_stol 1e-6 --snes_max_it 1000 --snes_monitor --snes_converged_reason - -# Calculate the Jacobian using matrix-free finite differencing --snes_mf --snes_mf_operator - -# Linear solver -# Increase the restart (directions) if it is struggling to converged --ksp_type lgmres -#-ksp_gmres_restart 100 -#-ksp_rtol 1e-3 -#-ksp_monitor -#-ksp_view -#-ksp_converged_reason - -# Preconditioner - LU -# Good for small/medium cases but will require large amounts of memory for -# larger models --pc_type bjacobi --sub_pc_type lu - -# Preconditioner - ILU -# Less expensive than LU but not as good -# Increasing the levels (fill-in) improves the preconditioning but is more -# expensive -#-pc_type asm -#-sub_pc_type ilu -#-sub_pc_factor_levels 1 - -# Preconditioner - multigrid -# Should perform better than LU for larger cases -# -pc_type hypre -# -pc_hypre_type boomeramg -# -pc_hypre_boomeramg_max_iter 1 -# #-pc_hypre_boomeramg_strong_threshold 0.25 -# -pc_hypre_boomeramg_strong_threshold 0.7 -# -pc_hypre_boomeramg_grid_sweeps_up 1 -# -pc_hypre_boomeramg_grid_sweeps_down 1 -# -pc_hypre_boomeramg_agg_nl 1 -# -pc_hypre_boomeramg_agg_num_paths 1 -# -pc_hypre_boomeramg_max_levels 25 -# -pc_hypre_boomeramg_coarsen_type HMIS -# -pc_hypre_boomeramg_interp_type ext+i -# -pc_hypre_boomeramg_P_max 1 -# -pc_hypre_boomeramg_truncfactor 0.3 - -# Construct the precondioner once and store it since it does not change --snes_lag_preconditioner_persists true --snes_lag_preconditioner -2 diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/base/highOrder/solidProperties b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/base/highOrder/solidProperties deleted file mode 100644 index 2f5f021e..00000000 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/base/highOrder/solidProperties +++ /dev/null @@ -1,54 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| solids4foam: solid mechanics and fluid-solid interaction simulations | -| Version: v2.0 | -| Web: https://solids4foam.github.io | -| Disclaimer: This offering is not approved or endorsed by OpenCFD Limited, | -| producer and distributor of the OpenFOAM software via | -| www.openfoam.com, and owner of the OPENFOAM® and OpenCFD® | -| trade marks. | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class dictionary; - location "constant"; - object solidProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -solidModel linearGeometryTotalDisplacement; - -linearGeometryTotalDisplacementCoeffs -{ - // Solution algorithm - //solutionAlgorithm implicitCoupled; - solutionAlgorithm PETScSNES; - optionsFile petscOptions.ksponly; - - highOrderCoeffs - { - highOrderJacobian false; - highOrderResidual true; - - LRECoeffs - { - N 1; - Nn 45; - weightFunction radiallySymmetricExponential; - k 6; - maxStencilSize 80; - useQRDecomposition true; - useGlobalStencils true; - calcConditionNumber false; - } - } - - stabilisation - { - type alpha; - scaleFactor 0.1; - } -} - -// ************************************************************************* // diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/base/snes/system/fvSolution b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/base/snes/system/fvSolution index 6cfa2e8e..5f496681 100644 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/base/snes/system/fvSolution +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/base/snes/system/fvSolution @@ -18,6 +18,29 @@ FoamFile // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // solvers -{} +{ + D + { + solver petsc; + + options + { + snes_type newtonls; + snes_monitor; + snes_converged_reason; + snes_mf; + snes_mf_operator; + + ksp_type lgmres; + ksp_gmres_restart "100"; + ksp_converged_reason; + + pc_type bjacobi; + sub_pc_type lu; + snes_lag_preconditioner_persists true; + snes_lag_preconditioner "-2"; + } + } +} // ************************************************************************* // diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/comparisonPlotScripts/dispErrors_movingVskExact.gnuplot b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/comparisonPlotScripts/dispErrors_movingVskExact.gnuplot new file mode 100644 index 00000000..b6f64b90 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/comparisonPlotScripts/dispErrors_movingVskExact.gnuplot @@ -0,0 +1,137 @@ +set term pdfcairo dashed enhanced size 3.25, 2 +set datafile separator " " + +if (ARGC < 1) { + print "Usage: gnuplot -c dispErrors_movingVskExact.gnuplot " + exit +} + +movingResults = ARG1 +movingFile(fileName) = sprintf("%s/%s", movingResults, fileName) + +set grid +set xrange [25:500] +set yrange [1e-7:1] +set xtics +set xtics add (5, 25, 50, 500) +set ytics +set logscale x +set logscale y +set format y "10^{%L}" +#set ytics 0.002 +set xlabel "Average cell edge (in mm)" +set ylabel "Error (in m)" +set key right bottom outside; +set rmargin 16 +set key spacing 1.2 + +# Polynomial guide lines (no title) +set style line 1 lc rgb "red" lt 2 lw 2 dt 2 +set style line 2 lc rgb "blue" lt 2 lw 2 dt 2 +set style line 3 lc rgb "violet" lt 2 lw 2 dt 2 + +# Data lines for each p-order (with titles) +set style line 11 lc rgb "red" pt 7 ps 0.5 lw 1 +set style line 12 lc rgb "red" pt 6 ps 0.5 lw 1 +set style line 21 lc rgb "blue" pt 5 ps 0.5 lw 1 +set style line 22 lc rgb "blue" pt 4 ps 0.5 lw 1 +set style line 31 lc rgb "violet" pt 9 ps 0.5 lw 1 +set style line 32 lc rgb "violet" pt 8 ps 0.5 lw 1 + +# Moving-least-squares data use the same colours with 50% transparency +set style line 111 lc rgb "#B3ff0000" pt 7 ps 0.5 lw 1 +set style line 112 lc rgb "#B3ff0000" pt 6 ps 0.5 lw 1 +set style line 121 lc rgb "#B30000ff" pt 5 ps 0.5 lw 1 +set style line 122 lc rgb "#B30000ff" pt 4 ps 0.5 lw 1 +set style line 131 lc rgb "#B3ee82ee" pt 9 ps 0.5 lw 1 +set style line 132 lc rgb "#B3ee82ee" pt 8 ps 0.5 lw 1 + +set output "mms_2D_dispErrors_hex_struct_movingVskExact.pdf" +plot \ + (3e-6 * x**2) w l ls 1 title "2^{nd} order", \ + (0.15e-08 * x**3) w l ls 2 title "3^{rd} order", \ + (0.8e-12 * x**4) w l ls 3 title "4^{th} order", \ + "hex.struct.ho.N1.summary.txt" u ((1/$4)**0.5*1e3):($5) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "hex.struct.ho.N1.summary.txt" u ((1/$4)**0.5*1e3):($6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "hex.struct.ho.N2.summary.txt" u ((1/$4)**0.5*1e3):($5) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "hex.struct.ho.N2.summary.txt" u ((1/$4)**0.5*1e3):($6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "hex.struct.ho.N3.summary.txt" u ((1/$4)**0.5*1e3):($5) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)" , \ + "hex.struct.ho.N3.summary.txt" u ((1/$4)**0.5*1e3):($6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)", \ + movingFile("hex.struct.ho.N1.summary.txt") u ((1/$4)**0.5*1e3):($5) w lp ls 111 notitle, \ + movingFile("hex.struct.ho.N1.summary.txt") u ((1/$4)**0.5*1e3):($6) w lp ls 112 notitle, \ + movingFile("hex.struct.ho.N2.summary.txt") u ((1/$4)**0.5*1e3):($5) w lp ls 121 notitle, \ + movingFile("hex.struct.ho.N2.summary.txt") u ((1/$4)**0.5*1e3):($6) w lp ls 122 notitle, \ + movingFile("hex.struct.ho.N3.summary.txt") u ((1/$4)**0.5*1e3):($5) w lp ls 131 notitle, \ + movingFile("hex.struct.ho.N3.summary.txt") u ((1/$4)**0.5*1e3):($6) w lp ls 132 notitle + +set output "mms_2D_dispErrors_ho-tet_struct_movingVskExact.pdf" +plot \ + (3e-6 * x**2) w l ls 1 title "2^{nd} order", \ + (0.15e-08 * x**3) w l ls 2 title "3^{rd} order", \ + (0.8e-12 * x**4) w l ls 3 title "4^{th} order", \ + "tet.struct.ho.N1.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($5) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.struct.ho.N1.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.struct.ho.N2.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($5) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.struct.ho.N2.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "tet.struct.ho.N3.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($5) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "tet.struct.ho.N3.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)", \ + movingFile("tet.struct.ho.N1.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($5) w lp ls 111 notitle, \ + movingFile("tet.struct.ho.N1.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($6) w lp ls 112 notitle, \ + movingFile("tet.struct.ho.N2.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($5) w lp ls 121 notitle, \ + movingFile("tet.struct.ho.N2.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($6) w lp ls 122 notitle, \ + movingFile("tet.struct.ho.N3.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($5) w lp ls 131 notitle, \ + movingFile("tet.struct.ho.N3.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($6) w lp ls 132 notitle + +set output "mms_2D_dispErrors_ho-tet_unstruct_v1_movingVskExact.pdf" +plot \ + (3e-6 * x**2) w l ls 1 title "2^{nd} order", \ + (0.15e-08 * x**3) w l ls 2 title "3^{rd} order", \ + (0.8e-12 * x**4) w l ls 3 title "4^{th} order", \ + "tet.unstruct_v1.ho.N1.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($5) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct_v1.ho.N1.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct_v1.ho.N2.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($5) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct_v1.ho.N2.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct_v1.ho.N3.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($5) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "tet.unstruct_v1.ho.N3.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)", \ + movingFile("tet.unstruct_v1.ho.N1.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($5) w lp ls 111 notitle, \ + movingFile("tet.unstruct_v1.ho.N1.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($6) w lp ls 112 notitle, \ + movingFile("tet.unstruct_v1.ho.N2.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($5) w lp ls 121 notitle, \ + movingFile("tet.unstruct_v1.ho.N2.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($6) w lp ls 122 notitle, \ + movingFile("tet.unstruct_v1.ho.N3.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($5) w lp ls 131 notitle, \ + movingFile("tet.unstruct_v1.ho.N3.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($6) w lp ls 132 notitle + +set output "mms_2D_dispErrors_ho-tet_unstruct_v2_movingVskExact.pdf" +plot \ + (3e-6 * x**2) w l ls 1 title "2^{nd} order", \ + (0.15e-08 * x**3) w l ls 2 title "3^{rd} order", \ + (0.8e-12 * x**4) w l ls 3 title "4^{th} order", \ + "tet.unstruct_v2.ho.N1.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($5) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct_v2.ho.N1.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct_v2.ho.N2.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($5) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct_v2.ho.N2.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct_v2.ho.N3.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($5) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "tet.unstruct_v2.ho.N3.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)", \ + movingFile("tet.unstruct_v2.ho.N1.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($5) w lp ls 111 notitle, \ + movingFile("tet.unstruct_v2.ho.N1.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($6) w lp ls 112 notitle, \ + movingFile("tet.unstruct_v2.ho.N2.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($5) w lp ls 121 notitle, \ + movingFile("tet.unstruct_v2.ho.N2.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($6) w lp ls 122 notitle, \ + movingFile("tet.unstruct_v2.ho.N3.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($5) w lp ls 131 notitle, \ + movingFile("tet.unstruct_v2.ho.N3.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($6) w lp ls 132 notitle + +set output "mms_2D_dispErrors_ho-poly_struct_movingVskExact.pdf" +plot \ + (3e-6 * x**2) w l ls 1 title "2^{nd} order", \ + (0.15e-08 * x**3) w l ls 2 title "3^{rd} order", \ + (0.8e-12 * x**4) w l ls 3 title "4^{th} order", \ + "poly.struct.ho.N1.summary.txt" u ((4*(1/$4)/pi)**0.5*1e3):($5) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "poly.struct.ho.N1.summary.txt" u ((4*(1/$4)/pi)**0.5*1e3):($6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "poly.struct.ho.N2.summary.txt" u ((4*(1/$4)/pi)**0.5*1e3):($5) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "poly.struct.ho.N2.summary.txt" u ((4*(1/$4)/pi)**0.5*1e3):($6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "poly.struct.ho.N3.summary.txt" u ((4*(1/$4)/pi)**0.5*1e3):($5) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "poly.struct.ho.N3.summary.txt" u ((4*(1/$4)/pi)**0.5*1e3):($6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)", \ + movingFile("poly.struct.ho.N1.summary.txt") u ((4*(1/$4)/pi)**0.5*1e3):($5) w lp ls 111 notitle, \ + movingFile("poly.struct.ho.N1.summary.txt") u ((4*(1/$4)/pi)**0.5*1e3):($6) w lp ls 112 notitle, \ + movingFile("poly.struct.ho.N2.summary.txt") u ((4*(1/$4)/pi)**0.5*1e3):($5) w lp ls 121 notitle, \ + movingFile("poly.struct.ho.N2.summary.txt") u ((4*(1/$4)/pi)**0.5*1e3):($6) w lp ls 122 notitle, \ + movingFile("poly.struct.ho.N3.summary.txt") u ((4*(1/$4)/pi)**0.5*1e3):($5) w lp ls 131 notitle, \ + movingFile("poly.struct.ho.N3.summary.txt") u ((4*(1/$4)/pi)**0.5*1e3):($6) w lp ls 132 notitle diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/comparisonPlotScripts/stressErrors_movingVskExact.gnuplot b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/comparisonPlotScripts/stressErrors_movingVskExact.gnuplot new file mode 100644 index 00000000..9b429539 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/comparisonPlotScripts/stressErrors_movingVskExact.gnuplot @@ -0,0 +1,137 @@ +set term pdfcairo dashed enhanced size 3.25, 2 +set datafile separator " " + +if (ARGC < 1) { + print "Usage: gnuplot -c stressErrors_movingVskExact.gnuplot " + exit +} + +movingResults = ARG1 +movingFile(fileName) = sprintf("%s/%s", movingResults, fileName) + +set grid +set xrange [25:500] +set yrange [1e-5:5] +set xtics +set xtics add (5, 25, 50, 500) +set ytics +set logscale x +set logscale y +set format y "10^{%L}" +#set ytics 0.002 +set xlabel "Average cell edge (in mm)" +set ylabel "Error (in Pa)" +set key right bottom outside; +set rmargin 16 +set key spacing 1.2 + +# Polynomial guide lines (no title) +set style line 1 lc rgb "red" lt 2 lw 2 dt 2 +set style line 2 lc rgb "blue" lt 2 lw 2 dt 2 +set style line 3 lc rgb "violet" lt 2 lw 2 dt 2 + +# Data lines for each p-order (with titles) +set style line 11 lc rgb "red" pt 7 ps 0.5 lw 1 +set style line 12 lc rgb "red" pt 6 ps 0.5 lw 1 +set style line 21 lc rgb "blue" pt 5 ps 0.5 lw 1 +set style line 22 lc rgb "blue" pt 4 ps 0.5 lw 1 +set style line 31 lc rgb "violet" pt 9 ps 0.5 lw 1 +set style line 32 lc rgb "violet" pt 8 ps 0.5 lw 1 + +# Moving-least-squares data use the same colours with 50% transparency +set style line 111 lc rgb "#B3ff0000" pt 7 ps 0.5 lw 1 +set style line 112 lc rgb "#B3ff0000" pt 6 ps 0.5 lw 1 +set style line 121 lc rgb "#B30000ff" pt 5 ps 0.5 lw 1 +set style line 122 lc rgb "#B30000ff" pt 4 ps 0.5 lw 1 +set style line 131 lc rgb "#B3ee82ee" pt 9 ps 0.5 lw 1 +set style line 132 lc rgb "#B3ee82ee" pt 8 ps 0.5 lw 1 + +set output "mms_2D_stressErrors_hex_struct_movingVskExact.pdf" +plot \ + (5e-3 * x) w l ls 1 title "1^{st} order", \ + (0.35e-5 * x**2) w l ls 2 title "2^{nd} order", \ + (0.2e-8 * x**3) w l ls 3 title "3^{rd} order", \ + "hex.struct.ho.N1.summary.txt" u ((1/$4)**0.5*1e3):($7) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "hex.struct.ho.N1.summary.txt" u ((1/$4)**0.5*1e3):($8) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "hex.struct.ho.N2.summary.txt" u ((1/$4)**0.5*1e3):($7) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "hex.struct.ho.N2.summary.txt" u ((1/$4)**0.5*1e3):($8) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "hex.struct.ho.N3.summary.txt" u ((1/$4)**0.5*1e3):($7) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "hex.struct.ho.N3.summary.txt" u ((1/$4)**0.5*1e3):($8) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)", \ + movingFile("hex.struct.ho.N1.summary.txt") u ((1/$4)**0.5*1e3):($7) w lp ls 111 notitle, \ + movingFile("hex.struct.ho.N1.summary.txt") u ((1/$4)**0.5*1e3):($8) w lp ls 112 notitle, \ + movingFile("hex.struct.ho.N2.summary.txt") u ((1/$4)**0.5*1e3):($7) w lp ls 121 notitle, \ + movingFile("hex.struct.ho.N2.summary.txt") u ((1/$4)**0.5*1e3):($8) w lp ls 122 notitle, \ + movingFile("hex.struct.ho.N3.summary.txt") u ((1/$4)**0.5*1e3):($7) w lp ls 131 notitle, \ + movingFile("hex.struct.ho.N3.summary.txt") u ((1/$4)**0.5*1e3):($8) w lp ls 132 notitle + +set output "mms_2D_stressErrors_ho-tet_struct_movingVskExact.pdf" +plot \ + (5e-3 * x) w l ls 1 title "1^{st} order", \ + (0.35e-5 * x**2) w l ls 2 title "2^{nd} order", \ + (0.2e-8 * x**3) w l ls 3 title "3^{rd} order", \ + "tet.struct.ho.N1.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($7) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.struct.ho.N1.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($8) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.struct.ho.N2.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($7) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.struct.ho.N2.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($8) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "tet.struct.ho.N3.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($7) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "tet.struct.ho.N3.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($8) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)", \ + movingFile("tet.struct.ho.N1.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($7) w lp ls 111 notitle, \ + movingFile("tet.struct.ho.N1.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($8) w lp ls 112 notitle, \ + movingFile("tet.struct.ho.N2.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($7) w lp ls 121 notitle, \ + movingFile("tet.struct.ho.N2.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($8) w lp ls 122 notitle, \ + movingFile("tet.struct.ho.N3.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($7) w lp ls 131 notitle, \ + movingFile("tet.struct.ho.N3.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($8) w lp ls 132 notitle + +set output "mms_2D_stressErrors_ho-tet_unstruct_v1_movingVskExact.pdf" +plot \ + (5e-3 * x) w l ls 1 title "1^{st} order", \ + (0.35e-5 * x**2) w l ls 2 title "2^{nd} order", \ + (0.2e-8 * x**3) w l ls 3 title "3^{rd} order", \ + "tet.unstruct_v1.ho.N1.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($7) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct_v1.ho.N1.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($8) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct_v1.ho.N2.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($7) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct_v1.ho.N2.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($8) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct_v1.ho.N3.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($7) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "tet.unstruct_v1.ho.N3.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($8) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)", \ + movingFile("tet.unstruct_v1.ho.N1.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($7) w lp ls 111 notitle, \ + movingFile("tet.unstruct_v1.ho.N1.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($8) w lp ls 112 notitle, \ + movingFile("tet.unstruct_v1.ho.N2.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($7) w lp ls 121 notitle, \ + movingFile("tet.unstruct_v1.ho.N2.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($8) w lp ls 122 notitle, \ + movingFile("tet.unstruct_v1.ho.N3.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($7) w lp ls 131 notitle, \ + movingFile("tet.unstruct_v1.ho.N3.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($8) w lp ls 132 notitle + +set output "mms_2D_stressErrors_ho-tet_unstruct_v2_movingVskExact.pdf" +plot \ + (5e-3 * x) w l ls 1 title "1^{st} order", \ + (0.35e-5 * x**2) w l ls 2 title "2^{nd} order", \ + (0.2e-8 * x**3) w l ls 3 title "3^{rd} order", \ + "tet.unstruct_v2.ho.N1.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($7) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct_v2.ho.N1.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($8) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct_v2.ho.N2.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($7) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct_v2.ho.N2.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($8) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct_v2.ho.N3.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($7) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "tet.unstruct_v2.ho.N3.summary.txt" u ((4*(1/$4)/3**0.5)**0.5*1e3):($8) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)", \ + movingFile("tet.unstruct_v2.ho.N1.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($7) w lp ls 111 notitle, \ + movingFile("tet.unstruct_v2.ho.N1.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($8) w lp ls 112 notitle, \ + movingFile("tet.unstruct_v2.ho.N2.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($7) w lp ls 121 notitle, \ + movingFile("tet.unstruct_v2.ho.N2.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($8) w lp ls 122 notitle, \ + movingFile("tet.unstruct_v2.ho.N3.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($7) w lp ls 131 notitle, \ + movingFile("tet.unstruct_v2.ho.N3.summary.txt") u ((4*(1/$4)/3**0.5)**0.5*1e3):($8) w lp ls 132 notitle + +set output "mms_2D_stressErrors_ho-poly_struct_movingVskExact.pdf" +plot \ + (5e-3 * x) w l ls 1 title "1^{st} order", \ + (0.35e-5 * x**2) w l ls 2 title "2^{nd} order", \ + (0.2e-8 * x**3) w l ls 3 title "3^{rd} order", \ + "poly.struct.ho.N1.summary.txt" u ((4*(1/$4)/pi)**0.5*1e3):($7) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "poly.struct.ho.N1.summary.txt" u ((4*(1/$4)/pi)**0.5*1e3):($8) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "poly.struct.ho.N2.summary.txt" u ((4*(1/$4)/pi)**0.5*1e3):($7) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "poly.struct.ho.N2.summary.txt" u ((4*(1/$4)/pi)**0.5*1e3):($8) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "poly.struct.ho.N3.summary.txt" u ((4*(1/$4)/pi)**0.5*1e3):($7) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "poly.struct.ho.N3.summary.txt" u ((4*(1/$4)/pi)**0.5*1e3):($8) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)", \ + movingFile("poly.struct.ho.N1.summary.txt") u ((4*(1/$4)/pi)**0.5*1e3):($7) w lp ls 111 notitle, \ + movingFile("poly.struct.ho.N1.summary.txt") u ((4*(1/$4)/pi)**0.5*1e3):($8) w lp ls 112 notitle, \ + movingFile("poly.struct.ho.N2.summary.txt") u ((4*(1/$4)/pi)**0.5*1e3):($7) w lp ls 121 notitle, \ + movingFile("poly.struct.ho.N2.summary.txt") u ((4*(1/$4)/pi)**0.5*1e3):($8) w lp ls 122 notitle, \ + movingFile("poly.struct.ho.N3.summary.txt") u ((4*(1/$4)/pi)**0.5*1e3):($7) w lp ls 131 notitle, \ + movingFile("poly.struct.ho.N3.summary.txt") u ((4*(1/$4)/pi)**0.5*1e3):($8) w lp ls 132 notitle diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/Allwmake b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/Allwmake similarity index 100% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/Allwmake rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/Allwmake diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/Make/files b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/Make/files similarity index 100% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/Make/files rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/Make/files diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/Make/options b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/Make/options similarity index 100% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/Make/options rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/Make/options diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/manufacturedSolution.C b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/manufacturedSolution.C similarity index 98% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/manufacturedSolution.C rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/manufacturedSolution.C index ab9b6798..a004dc28 100644 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/manufacturedSolution.C +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/manufacturedSolution.C @@ -74,7 +74,7 @@ void Foam::manufacturedSolution::calcBodyForces() const const solidModel& solMod = lookupSolidModel(mesh); const fvMeshQuadrature& quadrature = - solMod.displacementMLS().quadrature(); + solMod.displacementLeastSquares().quadrature(); const CompactListList& cellQuadPoints = quadrature.cellQuadPoints(); const CompactListList& cellQuadWeights = @@ -93,6 +93,8 @@ void Foam::manufacturedSolution::calcBodyForces() const bodyForcesI[cellI] += quadWeights[pointI]*calculateBodyForce(quadPoints[pointI]); } + + bodyForcesI[cellI] /= mesh_.V()[cellI]; } } else diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/manufacturedSolution.H b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/manufacturedSolution.H similarity index 100% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/manufacturedSolution.H rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/manufacturedSolution.H diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/manufacturedSolutionFunctionObject.C b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/manufacturedSolutionFunctionObject.C similarity index 76% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/manufacturedSolutionFunctionObject.C rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/manufacturedSolutionFunctionObject.C index 7b311bbf..29310244 100644 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/manufacturedSolutionFunctionObject.C +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/manufacturedSolutionFunctionObject.C @@ -22,6 +22,7 @@ License #include "volFields.H" #include "pointFields.H" #include "coordinateSystem.H" +#include "lookupSolidModel.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -40,6 +41,76 @@ namespace Foam // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +void Foam::manufacturedSolutionFunctionObject:: +calculateAnalyticalCellDisplacement +( + const fvMesh& mesh, + vectorField& analyticalD +) +{ + const solidModel& solMod = lookupSolidModel(mesh); + bool useCellAverage = false; + + if (solMod.highOrderResidual()) + { + const dictionary& highOrderDict = + solMod.solidModelDict().subDict("highOrderCoeffs"); + const dictionary& displacementDict = + highOrderDict.subDict("displacement"); + const word reconstructionType + ( + displacementDict.lookupOrDefault + ( + "type", + "movingLeastSquares" + ) + ); + + useCellAverage = reconstructionType == "kExactLeastSquares"; + } + + if (useCellAverage) + { + const fvMeshQuadrature& quadrature = + solMod.displacementLeastSquares().quadrature(); + const CompactListList& cellQuadPoints = + quadrature.cellQuadPoints(); + const CompactListList& cellQuadWeights = + quadrature.cellQuadWeights(); + const scalarField& cellVolumes = mesh.V(); + + Info<< "Using cell-average analytical displacement" << endl; + + forAll(analyticalD, cellI) + { + analyticalD[cellI] = vector::zero; + + forAll(cellQuadPoints[cellI], pointI) + { + analyticalD[cellI] += + cellQuadWeights[cellI][pointI] + *mmsPtr_->calculateDisplacement + ( + cellQuadPoints[cellI][pointI] + ); + } + + analyticalD[cellI] /= cellVolumes[cellI]; + } + } + else + { + Info<< "Using point-valued analytical displacement" << endl; + + const vectorField& cellCentres = mesh.C().internalField(); + forAll(analyticalD, cellI) + { + analyticalD[cellI] = + mmsPtr_->calculateDisplacement(cellCentres[cellI]); + } + } +} + bool Foam::manufacturedSolutionFunctionObject::writeData() { // Lookup the solid mesh @@ -99,9 +170,10 @@ bool Foam::manufacturedSolutionFunctionObject::writeData() forAll(sI, cellI) { sI[cellI] = mmsPtr_->calculateStress(CI[cellI]); - aDI[cellI] = mmsPtr_->calculateDisplacement(CI[cellI]); } + calculateAnalyticalCellDisplacement(mesh, aDI); + forAll(analyticalStress.boundaryField(), patchI) { #ifdef OPENFOAM_NOT_EXTEND diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/manufacturedSolutionFunctionObject.H b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/manufacturedSolutionFunctionObject.H similarity index 94% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/manufacturedSolutionFunctionObject.H rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/manufacturedSolutionFunctionObject.H index 3310ce65..789d1796 100644 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/manufacturedSolutionFunctionObject.H +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/manufacturedSolutionFunctionObject.H @@ -83,6 +83,14 @@ class manufacturedSolutionFunctionObject // Private Member Functions + //- Calculate analytical cell displacement using the selected + // reconstruction semantics + void calculateAnalyticalCellDisplacement + ( + const fvMesh& mesh, + vectorField& analyticalD + ); + //- Write data bool writeData(); diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/manufacturedSolutionFvPatchVectorField.C b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/manufacturedSolutionFvPatchVectorField.C similarity index 98% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/manufacturedSolutionFvPatchVectorField.C rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/manufacturedSolutionFvPatchVectorField.C index 241bcc16..18513286 100644 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/manufacturedSolutionFvPatchVectorField.C +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/manufacturedSolutionFvPatchVectorField.C @@ -129,7 +129,7 @@ manufacturedSolutionFvPatchVectorField::evaluateQuadrature // faceQuadPoints is list for the whole mesh const CompactListList& faceQuadPoints = - solMod.displacementMLS().quadrature().faceQuadPoints(); + solMod.displacementLeastSquares().quadrature().faceQuadPoints(); // faceQuadPoints is list for whole mesh. labelList nQpPerFace(this->size(), 0); diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/manufacturedSolutionFvPatchVectorField.H b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/manufacturedSolutionFvPatchVectorField.H similarity index 100% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/manufacturedSolutionFvPatchVectorField.H rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/manufacturedSolutionFvPatchVectorField.H diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/manufacturedSolutionSource.C b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/manufacturedSolutionSource.C similarity index 100% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/manufacturedSolutionSource.C rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/manufacturedSolutionSource.C diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/manufacturedSolutionSource.H b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/manufacturedSolutionSource.H similarity index 100% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/manufacturedSolution/manufacturedSolutionSource.H rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/mixed/src/manufacturedSolutionSource.H diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/Allrun b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/Allrun index 72c35edb..c7886e96 100755 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/Allrun +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/Allrun @@ -7,11 +7,11 @@ source solids4FoamScripts.sh solids4Foam::caseDoesNotRunWithFoamExtend # solids4Foam location path -export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib-highOrder +export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib/solids4foam-ib-2412/ echo "SOLIDS4FOAM_DIR = $SOLIDS4FOAM_DIR" # Compile the manucafturedSolution library -(cd manufacturedSolution && wclean libso && ./Allwmake -j -s) +(cd src && wclean libso && ./Allwmake -j -s) # Define configurations as space-separated strings configs=( @@ -23,25 +23,25 @@ configs=( # "BASE=base/segregated NAME=tet.struct.seg GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0" # "BASE=base/segregated NAME=tet.unstruct.seg GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0" # "BASE=base/segregated NAME=poly.seg GMSH_FILE=tet-unstructured USE_DUALMESH=1 USE_PERTURBMESHPOINTS=0" - # "BASE=base/highOrder NAME=hex.struct.ho.N1 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=25 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - # "BASE=base/highOrder NAME=hex.struct.ho.N2 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - # "BASE=base/highOrder NAME=hex.struct.ho.N3 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - # "BASE=base/highOrder NAME=tet.struct.ho.N1 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=25 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - # "BASE=base/highOrder NAME=tet.struct.ho.N2 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - # "BASE=base/highOrder NAME=tet.struct.ho.N3 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.unstruct.ho.N1 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=25 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.unstruct.ho.N2 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.unstruct.ho.N3 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - # "BASE=base/highOrder NAME=poly.ho.N1 GMSH_FILE=tet-structured USE_DUALMESH=1 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=25 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - # "BASE=base/highOrder NAME=poly.ho.N2 GMSH_FILE=tet-structured USE_DUALMESH=1 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - # "BASE=base/highOrder NAME=poly.ho.N3 GMSH_FILE=tet-structured USE_DUALMESH=1 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" + # "BASE=base/highOrder NAME=hex.struct.ho.N1 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + # "BASE=base/highOrder NAME=hex.struct.ho.N2 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + # "BASE=base/highOrder NAME=hex.struct.ho.N3 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + # "BASE=base/highOrder NAME=tet.struct.ho.N1 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + # "BASE=base/highOrder NAME=tet.struct.ho.N2 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + # "BASE=base/highOrder NAME=tet.struct.ho.N3 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N1 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N2 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + # "BASE=base/highOrder NAME=tet.unstruct.ho.N3 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + # "BASE=base/highOrder NAME=poly.ho.N1 GMSH_FILE=tet-structured USE_DUALMESH=1 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + # "BASE=base/highOrder NAME=poly.ho.N2 GMSH_FILE=tet-structured USE_DUALMESH=1 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + # "BASE=base/highOrder NAME=poly.ho.N3 GMSH_FILE=tet-structured USE_DUALMESH=1 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" ) # Define start and end mesh indices # Mesh input files are defined from 1 to 12 # END_MESH should be greater than START_MESH START_MESH=1 -END_MESH=4 # 12 +END_MESH=8 # Detect the CPU type: we append this to the case name @@ -71,6 +71,9 @@ cd "${RUN_DIR}" # Iterate through configurations for config in "${configs[@]}" do + # Reset variables in case a variable is not used + unset GMSH_FILE PETSC_FILE polyOrder extraCells HOJAC HORES TYPE + # Parse the configuration string eval $config echo; echo "***************************************" @@ -124,6 +127,11 @@ do sed -i "/^\s*faceStencilExtraCells /s|^.*| faceStencilExtraCells ${extraCells};|" constant/solidProperties fi + # Update the least squares type + if [ -n "${TYPE}" ]; then + sed -i "/^\s*type \(movingLeastSquares\|kExactLeastSquares\);/s|^.*| type ${TYPE};|" constant/solidProperties + fi + # Update how Jacobian is calculated if [ -n "${HOJAC}" ]; then sed -i "/^\s*highOrderJacobian /s|^.*| highOrderJacobian ${HOJAC};|" constant/solidProperties diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/base/highOrder/constant/solidProperties b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/base/highOrder/constant/solidProperties index 47170483..5f0e64db 100644 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/base/highOrder/constant/solidProperties +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/base/highOrder/constant/solidProperties @@ -33,6 +33,7 @@ linearGeometryTotalDisplacementCoeffs displacement { + type movingLeastSquares; polynomialOrder 2; faceStencilExtraCells 10; diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/Allwmake b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/Allwmake similarity index 100% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/Allwmake rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/Allwmake diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/Make/files b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/Make/files similarity index 100% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/Make/files rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/Make/files diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/Make/options b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/Make/options similarity index 100% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/Make/options rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/Make/options diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolution.C b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolution.C similarity index 97% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolution.C rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolution.C index 39404092..2ea532ba 100644 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolution.C +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolution.C @@ -19,6 +19,7 @@ License #include "manufacturedSolution.H" #include "mathematicalConstants.H" +#include "lookupSolidModel.H" #include "tetPoints.H" #include "tetQuadrature.H" #include "polyMeshTetDecomposition.H" @@ -71,7 +72,7 @@ void Foam::manufacturedSolution::calcBodyForces() const { const solidModel& solMod = lookupSolidModel(mesh); const fvMeshQuadrature& quadrature = - solMod.displacementMLS().quadrature(); + solMod.displacementLeastSquares().quadrature(); const CompactListList& cellQuadPoints = quadrature.cellQuadPoints(); const CompactListList& cellQuadWeights = @@ -88,7 +89,8 @@ void Foam::manufacturedSolution::calcBodyForces() const quadWeights[pointI]*calculateBodyForce(quadPoints[pointI]); } - totalBodyForce += quadVolume*bodyForcesI[cellI]; + bodyForcesI[cellI] /= mesh.V()[cellI]; + totalBodyForce += mesh.V()[cellI]*bodyForcesI[cellI]; } } else diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolution.H b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolution.H similarity index 100% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolution.H rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolution.H diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/manufacturedSolutionFunctionObject.C b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolutionFunctionObject.C similarity index 86% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/manufacturedSolutionFunctionObject.C rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolutionFunctionObject.C index 67df7fef..4e0fd3df 100644 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/manufacturedSolutionFunctionObject.C +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolutionFunctionObject.C @@ -22,6 +22,7 @@ License #include "volFields.H" #include "pointFields.H" #include "coordinateSystem.H" +#include "lookupSolidModel.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -40,6 +41,75 @@ namespace Foam // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +void Foam::manufacturedSolutionFunctionObject:: +calculateAnalyticalCellDisplacement +( + const fvMesh& mesh, + vectorField& analyticalD +) +{ + const solidModel& solMod = lookupSolidModel(mesh); + bool useCellAverage = false; + + if (solMod.highOrderResidual()) + { + const dictionary& displacementDict = + solMod.solidModelDict() + .subDict("highOrderCoeffs") + .subDict("displacement"); + + useCellAverage = + displacementDict.lookupOrDefault + ( + "type", + "movingLeastSquares" + ) == "kExactLeastSquares"; + } + + if (useCellAverage) + { + const fvMeshQuadrature& quadrature = + solMod.displacementLeastSquares().quadrature(); + const CompactListList& cellQuadPoints = + quadrature.cellQuadPoints(); + const CompactListList& cellQuadWeights = + quadrature.cellQuadWeights(); + const scalarField& cellVolumes = mesh.V(); + + Info<< "Using cell-average analytical displacement" << endl; + + forAll(analyticalD, cellI) + { + analyticalD[cellI] = vector::zero; + + forAll(cellQuadPoints[cellI], pointI) + { + analyticalD[cellI] += + cellQuadWeights[cellI][pointI] + *mmsPtr_->calculateDisplacement + ( + cellQuadPoints[cellI][pointI] + ); + } + + analyticalD[cellI] /= cellVolumes[cellI]; + } + } + else + { + Info<< "Using point-valued analytical displacement" << endl; + + const vectorField& cellCentres = mesh.C().internalField(); + + forAll(analyticalD, cellI) + { + analyticalD[cellI] = + mmsPtr_->calculateDisplacement(cellCentres[cellI]); + } + } +} + + bool Foam::manufacturedSolutionFunctionObject::writeData() { // Lookup the solid mesh @@ -138,9 +208,10 @@ bool Foam::manufacturedSolutionFunctionObject::writeData() forAll(sI, cellI) { sI[cellI] = mmsPtr_->calculateStress(CI[cellI]); - aDI[cellI] = mmsPtr_->calculateDisplacement(CI[cellI]); } + calculateAnalyticalCellDisplacement(mesh, aDI); + forAll(pEI, pointI) { pEI[pointI] = mmsPtr_->calculateStrain(points[pointI]); diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/manufacturedSolutionFunctionObject.H b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolutionFunctionObject.H similarity index 95% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/manufacturedSolutionFunctionObject.H rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolutionFunctionObject.H index 64f90c88..d2c092e2 100644 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/manufacturedSolutionFunctionObject.H +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolutionFunctionObject.H @@ -82,6 +82,13 @@ class manufacturedSolutionFunctionObject // Private Member Functions + //- Calculate point-valued or cell-average analytical displacement + void calculateAnalyticalCellDisplacement + ( + const fvMesh& mesh, + vectorField& analyticalD + ); + //- Write data bool writeData(); diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolutionFvPatchVectorField.C b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolutionFvPatchVectorField.C similarity index 98% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolutionFvPatchVectorField.C rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolutionFvPatchVectorField.C index 5bc15c7e..3c97c89b 100644 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolutionFvPatchVectorField.C +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolutionFvPatchVectorField.C @@ -129,7 +129,7 @@ manufacturedSolutionFvPatchVectorField::evaluateQuadrature // faceQuadPoints is list for the whole mesh const CompactListList& faceQuadPoints = - solMod.displacementMLS().quadrature().faceQuadPoints(); + solMod.displacementLeastSquares().quadrature().faceQuadPoints(); labelList nQpPerFace(this->size(), 0); const label start = this->patch().start(); diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolutionFvPatchVectorField.H b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolutionFvPatchVectorField.H similarity index 99% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolutionFvPatchVectorField.H rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolutionFvPatchVectorField.H index 5b996280..14e2f13f 100644 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolutionFvPatchVectorField.H +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolutionFvPatchVectorField.H @@ -37,6 +37,7 @@ Author #include "fixedDisplacementFvPatchVectorField.H" #include "manufacturedSolution.H" +#include "lookupSolidModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolutionSource.C b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolutionSource.C similarity index 100% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolutionSource.C rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolutionSource.C diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolutionSource.H b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolutionSource.H similarity index 100% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolutionSource.H rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/src/manufacturedSolutionSource.H diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/Allrun b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/Allrun index 0030f44b..1014be29 100755 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/Allrun +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/Allrun @@ -7,11 +7,11 @@ source solids4FoamScripts.sh solids4Foam::caseDoesNotRunWithFoamExtend # solids4Foam location path -export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib-highOrder +export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib/solids4foam-ib-2412/ echo "SOLIDS4FOAM_DIR = $SOLIDS4FOAM_DIR" # Compile the manucafturedSolution library -(cd manufacturedSolution && wclean libso && ./Allwmake -j -s) +(cd src && wclean libso && ./Allwmake -j -s) # Define configurations as space-separated strings configs=( @@ -22,18 +22,18 @@ configs=( "BASE=base/segregated NAME=tet.struct.seg GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0" "BASE=base/segregated NAME=tet.unstruct.seg GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0" "BASE=base/segregated NAME=poly.struct.seg GMSH_FILE=tet-structured USE_DUALMESH=1 USE_PERTURBMESHPOINTS=0" - "BASE=base/highOrder NAME=hex.struct.ho.N1 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - "BASE=base/highOrder NAME=hex.struct.ho.N2 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - "BASE=base/highOrder NAME=hex.struct.ho.N3 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.unstruct.ho.N1 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.unstruct.ho.N2 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.unstruct.ho.N3 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.struct.ho.N1 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.struct.ho.N2 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.struct.ho.N3 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - "BASE=base/highOrder NAME=poly.struct.ho.N1 GMSH_FILE=tet-structured USE_DUALMESH=1 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - "BASE=base/highOrder NAME=poly.struct.ho.N2 GMSH_FILE=tet-structured USE_DUALMESH=1 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - "BASE=base/highOrder NAME=poly.struct.ho.N3 GMSH_FILE=tet-structured USE_DUALMESH=1 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" + "BASE=base/highOrder NAME=hex.struct.ho.N1 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=hex.struct.ho.N2 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=hex.struct.ho.N3 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N1 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N2 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N3 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N1 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N2 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N3 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=poly.struct.ho.N1 GMSH_FILE=tet-structured USE_DUALMESH=1 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=poly.struct.ho.N2 GMSH_FILE=tet-structured USE_DUALMESH=1 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=poly.struct.ho.N3 GMSH_FILE=tet-structured USE_DUALMESH=1 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" ) # Define start and end mesh indices @@ -71,7 +71,7 @@ cd "${RUN_DIR}" for config in "${configs[@]}" do # Reset variables in the case some variable is not used - unset GMSH_FILE PETSC_FILE order extraCells HOJAC HORES + unset GMSH_FILE PETSC_FILE order extraCells HOJAC HORES TYPE # Parse the configuration string eval $config @@ -129,6 +129,11 @@ do sed -i "/^\s*faceStencilExtraCells /s|^.*| faceStencilExtraCells ${extraCells};|" constant/solidProperties fi + # Update the least squares type + if [ -n "${TYPE}" ]; then + sed -i "/^\s*type \(movingLeastSquares\|kExactLeastSquares\);/s|^.*| type ${TYPE};|" constant/solidProperties + fi + # Update how Jacobian is calculated if [ -n "${HOJAC}" ]; then sed -i "/^\s*highOrderJacobian /s|^.*| highOrderJacobian ${HOJAC};|" constant/solidProperties diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/Allrun.alphaAnalysis b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/Allrun.alphaAnalysis index 25b5df17..6b0a16d5 100755 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/Allrun.alphaAnalysis +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/Allrun.alphaAnalysis @@ -6,35 +6,39 @@ source solids4FoamScripts.sh # Extend version not supported solids4Foam::caseDoesNotRunWithFoamExtend +# solids4Foam location path +export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib/solids4foam-ib-2412/ +echo "SOLIDS4FOAM_DIR = $SOLIDS4FOAM_DIR" + # Compile the manucafturedSolution library -(cd manufacturedSolution && wclean libso && ./Allwmake -j -s) +(cd src && wclean libso && ./Allwmake -j -s) # Define configurations as space-separated strings configs=( - "BASE=base/highOrder NAME=hex.struct.ho.N1.alpha.0.001 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=1 Nn=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.001" - "BASE=base/highOrder NAME=hex.struct.ho.N2.alpha.0.001 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=2 Nn=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.001" - "BASE=base/highOrder NAME=hex.struct.ho.N3.alpha.0.001 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=3 Nn=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.001" - "BASE=base/highOrder NAME=tet.unstruct.ho.N1.alpha.0.001 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=1 Nn=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.001" - "BASE=base/highOrder NAME=tet.unstruct.ho.N2.alpha.0.001 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=2 Nn=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.001" - "BASE=base/highOrder NAME=tet.unstruct.ho.N3.alpha.0.001 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=3 Nn=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.001" - "BASE=base/highOrder NAME=hex.struct.ho.N1.alpha.0.01 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=1 Nn=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.01" - "BASE=base/highOrder NAME=hex.struct.ho.N1.alpha.0.1 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=1 Nn=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.1" - "BASE=base/highOrder NAME=hex.struct.ho.N1.alpha.1 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=1 Nn=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=1" - "BASE=base/highOrder NAME=hex.struct.ho.N2.alpha.0.01 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=2 Nn=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.01" - "BASE=base/highOrder NAME=hex.struct.ho.N2.alpha.0.1 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=2 Nn=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.1" - "BASE=base/highOrder NAME=hex.struct.ho.N2.alpha.1 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=2 Nn=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=1" - "BASE=base/highOrder NAME=hex.struct.ho.N3.alpha.0.01 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=3 Nn=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.01" - "BASE=base/highOrder NAME=hex.struct.ho.N3.alpha.0.1 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=3 Nn=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.1" - "BASE=base/highOrder NAME=hex.struct.ho.N3.alpha.1 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=3 Nn=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=1" - "BASE=base/highOrder NAME=tet.unstruct.ho.N1.alpha.0.01 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=1 Nn=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.01" - "BASE=base/highOrder NAME=tet.unstruct.ho.N1.alpha.0.1 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=1 Nn=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.1" - "BASE=base/highOrder NAME=tet.unstruct.ho.N1.alpha.1 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=1 Nn=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=1" - "BASE=base/highOrder NAME=tet.unstruct.ho.N2.alpha.0.01 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=2 Nn=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.01" - "BASE=base/highOrder NAME=tet.unstruct.ho.N2.alpha.0.1 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=2 Nn=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.1" - "BASE=base/highOrder NAME=tet.unstruct.ho.N2.alpha.1 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=2 Nn=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=1" - "BASE=base/highOrder NAME=tet.unstruct.ho.N3.alpha.0.01 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=3 Nn=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.01" - "BASE=base/highOrder NAME=tet.unstruct.ho.N3.alpha.0.1 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=3 Nn=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.1" - "BASE=base/highOrder NAME=tet.unstruct.ho.N3.alpha.1 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=3 Nn=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=1" + "BASE=base/highOrder NAME=hex.struct.ho.N1.alpha.0.001 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=1 Nn=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.001 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=hex.struct.ho.N2.alpha.0.001 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=2 Nn=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.001 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=hex.struct.ho.N3.alpha.0.001 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=3 Nn=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.001 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N1.alpha.0.001 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=1 Nn=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.001 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N2.alpha.0.001 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=2 Nn=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.001 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N3.alpha.0.001 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=3 Nn=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.001 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=hex.struct.ho.N1.alpha.0.01 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=1 Nn=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.01 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=hex.struct.ho.N1.alpha.0.1 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=1 Nn=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.1 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=hex.struct.ho.N1.alpha.1 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=1 Nn=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=1 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=hex.struct.ho.N2.alpha.0.01 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=2 Nn=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.01 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=hex.struct.ho.N2.alpha.0.1 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=2 Nn=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.1 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=hex.struct.ho.N2.alpha.1 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=2 Nn=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=1 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=hex.struct.ho.N3.alpha.0.01 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=3 Nn=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.01 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=hex.struct.ho.N3.alpha.0.1 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=3 Nn=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.1 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=hex.struct.ho.N3.alpha.1 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=3 Nn=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=1 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N1.alpha.0.01 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=1 Nn=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.01 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N1.alpha.0.1 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=1 Nn=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.1 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N1.alpha.1 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=1 Nn=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=1 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N2.alpha.0.01 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=2 Nn=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.01 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N2.alpha.0.1 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=2 Nn=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.1 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N2.alpha.1 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=2 Nn=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=1 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N3.alpha.0.01 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=3 Nn=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.01 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N3.alpha.0.1 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=3 Nn=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=0.1 TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N3.alpha.1 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 N=3 Nn=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true ALPHA=1 TYPE=movingLeastSquares" ) # Define start and end mesh indices @@ -72,7 +76,7 @@ cd "${RUN_DIR}" for config in "${configs[@]}" do # Reset variables in the case some variable is not used - unset GMSH_FILE PETSC_FILE order extraCells HOJAC HORES ALPHA + unset GMSH_FILE PETSC_FILE order extraCells HOJAC HORES ALPHA TYPE # Parse the configuration string eval $config @@ -133,6 +137,11 @@ do sed -i "/^\s*scaleFactor /s|^.*| scaleFactor ${ALPHA};|" constant/solidProperties fi + # Update the least squares type + if [ -n "${TYPE}" ]; then + sed -i "/^\s*type \(movingLeastSquares\|kExactLeastSquares\);/s|^.*| type ${TYPE};|" constant/solidProperties + fi + # Update how Jacobian is calculated if [ -n "${HOJAC}" ]; then sed -i "/^\s*highOrderJacobian /s|^.*| highOrderJacobian ${HOJAC};|" constant/solidProperties diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/Allrun.kExact b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/Allrun.kExact new file mode 100755 index 00000000..e818746d --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/Allrun.kExact @@ -0,0 +1,228 @@ +#!/bin/bash + +# Source required functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions +source solids4FoamScripts.sh +# Extend version not supported +solids4Foam::caseDoesNotRunWithFoamExtend + +# solids4Foam location path +export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib/solids4foam-ib-2412/ +echo "SOLIDS4FOAM_DIR = $SOLIDS4FOAM_DIR" + +# Compile the manucafturedSolution library +(cd src && wclean libso && ./Allwmake -j -s) + +# Define configurations as space-separated strings +configs=( + "BASE=base/snes NAME=hex.struct.hypre-snes GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 PETSC_FILE=petscOptions.hypre" + "BASE=base/snes NAME=tet.struct.hypre-snes GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 PETSC_FILE=petscOptions.hypre" + "BASE=base/snes NAME=poly.struct.hypre-snes GMSH_FILE=tet-structured USE_DUALMESH=1 USE_PERTURBMESHPOINTS=0 PETSC_FILE=petscOptions.hypre" + "BASE=base/segregated NAME=hex.struct.seg GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0" + "BASE=base/segregated NAME=tet.struct.seg GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0" + "BASE=base/segregated NAME=tet.unstruct.seg GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0" + "BASE=base/segregated NAME=poly.struct.seg GMSH_FILE=tet-structured USE_DUALMESH=1 USE_PERTURBMESHPOINTS=0" + "BASE=base/highOrder NAME=hex.struct.ho.N1 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=hex.struct.ho.N2 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=hex.struct.ho.N3 GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N1 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N2 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N3 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N1 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N2 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N3 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=poly.struct.ho.N1 GMSH_FILE=tet-structured USE_DUALMESH=1 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=poly.struct.ho.N2 GMSH_FILE=tet-structured USE_DUALMESH=1 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=poly.struct.ho.N3 GMSH_FILE=tet-structured USE_DUALMESH=1 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=kExactLeastSquares" +) + +# Define start and end mesh indices +# Mesh input files are defined from 1 to 19 +# END_MESH should be greater than START_MESH +START_MESH=1 +END_MESH=13 + + +# Detect the CPU type: we append this to the case name +if [[ "$OSTYPE" == "darwin"* ]] +then + # macOS + CPU_TYPE=$(sysctl -n machdep.cpu.brand_string | sed 's/[^a-zA-Z0-9]/_/g') +elif [[ -f /proc/cpuinfo ]] +then + # Linux + CPU_TYPE=$(grep -m 1 "model name" /proc/cpuinfo | awk -F': ' '{print $2}' | sed 's/[^a-zA-Z0-9]/_/g') +else + # Fallback if neither method works + CPU_TYPE="Unknown_CPU" +fi + + +# Create timestamped working directory for this run +DATE=$(date +%Y-%m-%d_%H-%M-%S) +RUN_DIR="run_${CPU_TYPE}_${DATE}" +echo "Creating ${RUN_DIR}" +mkdir "${RUN_DIR}" + +# Enter the run directory +cd "${RUN_DIR}" + +# Iterate through configurations +for config in "${configs[@]}" +do + # Reset variables in the case some variable is not used + unset GMSH_FILE PETSC_FILE order extraCells HOJAC HORES TYPE + + # Parse the configuration string + eval $config + echo; echo "***************************************" + echo "Running configuration: $config" + echo "***************************************" + + # Define results summary file name + SUMMARY="${NAME}.summary.txt" + echo "# Mesh Time Mem CellsNumber D_L2 D_Linf S_L2 S_Linf" > "${SUMMARY}" + + # Loop over mesh densities in each configuration + for i in `seq $START_MESH $END_MESH` + do + CASE="${NAME}.$i" + echo; echo "Processing case: $CASE" + + # Prepare the case + cp -rL "../${BASE}" "${CASE}" + cd "$CASE" + + # GMSH Mesh generation + cp "gmsh/meshSpacing/meshSpacing$i.geo" "gmsh/meshSpacing/meshSpacing.geo" + solids4Foam::runApplication gmsh -3 -format msh2 gmsh/"${GMSH_FILE}.geo" + solids4Foam::runApplication gmshToFoam gmsh/"${GMSH_FILE}.msh" + solids4Foam::runApplication createPatch -overwrite + if [ "$USE_DUALMESH" -eq 1 ]; then + cp -r 0 0.org + solids4Foam::runApplication polyDualMesh 30 -overwrite + solids4Foam::runApplication combinePatchFaces 45 -overwrite + rm -rf 0 + mv 0.org 0 + fi + + # Optional mesh distortion + if [ "$USE_PERTURBMESHPOINTS" -eq 1 ] + then + solids4Foam::runApplication perturbMeshPoints + mv 0/polyMesh/* constant/polyMesh/. + fi + solids4Foam::runApplication checkMesh + + # Update the PETSc options file + if [ -n "${PETSC_FILE}" ]; then + sed -i "/^\s*optionsFile /s|^.*| optionsFile ${PETSC_FILE};|" constant/solidProperties + fi + + # Update the order + if [ -n "${polyOrder}" ]; then + sed -i "/^\s*polynomialOrder /s|^.*| polynomialOrder ${polyOrder};|" constant/solidProperties + fi + + # Update number of stencil cells + if [ -n "${extraCells}" ]; then + sed -i "/^\s*faceStencilExtraCells /s|^.*| faceStencilExtraCells ${extraCells};|" constant/solidProperties + fi + + # Update the least squares type + if [ -n "${TYPE}" ]; then + sed -i "/^\s*type \(movingLeastSquares\|kExactLeastSquares\);/s|^.*| type ${TYPE};|" constant/solidProperties + fi + + # Update how Jacobian is calculated + if [ -n "${HOJAC}" ]; then + sed -i "/^\s*highOrderJacobian /s|^.*| highOrderJacobian ${HOJAC};|" constant/solidProperties + fi + + # Update how Residual is calculated + if [ -n "${HORES}" ]; then + sed -i "/^\s*highOrderResidual /s|^.*| highOrderResidual ${HORES};|" constant/solidProperties + fi + + # Run the solver + # If "gtime" is available (could be called "time" on Linux), use it to + # record the max memory usage + if command -v gtime &> /dev/null + then + echo "Running solids4Foam on ${CASE} with gtime" + gtime -f "gtime/time (wall clock) time: %e\nMaximum resident set size (kbytes): %M" solids4Foam &> log.solids4Foam + + elif [ -x /usr/bin/time ] + then + echo "Running solids4Foam on ${CASE} with /usr/bin/time" + /usr/bin/time -f "gtime/time (wall clock) time: %e\nMaximum resident set size (kbytes): %M" solids4Foam &> log.solids4Foam + + elif command -v time &> /dev/null + then + echo "Running solids4Foam on ${CASE} with shell builtin time (no max memory)" + time solids4Foam &> log.solids4Foam + + else + echo "Running solids4Foam on ${CASE}" + solids4Foam::runApplication solids4Foam + fi + + # Extract results from solver log and append them to a summary file + echo; echo "Appending results to ${SUMMARY}" + if grep -q "gtime/time" log.solids4Foam; then + CLOCK_TIME=$(grep "gtime/time" log.solids4Foam | awk '{print $5}') + else + # Record the time + CLOCK_TIME=$(grep "ClockTime" log.solids4Foam | awk '{print $7}') + fi + + if grep -q "Maximum resident" log.solids4Foam; then + MAX_MEMORY=$(grep "Maximum resident" log.solids4Foam | awk '{print int($6 / 1000)}') + else + MAX_MEMORY="NaN" + fi + + # Number of cells + CELLS=$(grep "cells:" log.checkMesh | awk '{print $2}') + + # Extract the L2 (average) error for displacement + DISP_L2_ERROR=$(grep "Writing DDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $3}') + + # Extract the LInfinity (max) error for displacement + DISP_LINF_ERROR=$(grep "Writing DDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $4}') + + # Extract the L2 (average) error for mag(sigma) + STRESS_L2_ERROR=$(grep "Writing sigmaDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $3}') + + # Extract the LInfinity (max) error for mag(sigma) + STRESS_LINF_ERROR=$(grep "Writing sigmaDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $4}') + + # Write data to file + echo "$i $CLOCK_TIME $MAX_MEMORY $CELLS $DISP_L2_ERROR $DISP_LINF_ERROR $STRESS_L2_ERROR $STRESS_LINF_ERROR" >> ../"${SUMMARY}" + + cd .. + done + + # Print summary file + echo; echo "${SUMMARY} file:"; cat "${SUMMARY}"; echo + +done + +# Create plots if gnuplot in installed +if command -v gnuplot &>/dev/null +then + # Copy gnuplot scripts + cp ../plotScripts/*gnuplot . + + # Run all scripts + for f in *gnuplot + do + echo "Running gnuplot on $f" + gnuplot "$f" 2>/dev/null + done +fi + +echo; echo; echo "Done!"; echo +echo "View the PDF files in ${RUN_DIR}" +echo; echo $(date) +echo; echo diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/base/highOrder/constant/solidProperties b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/base/highOrder/constant/solidProperties index fc91a36e..de726820 100644 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/base/highOrder/constant/solidProperties +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/base/highOrder/constant/solidProperties @@ -33,6 +33,7 @@ linearGeometryTotalDisplacementCoeffs displacement { + type movingLeastSquares; polynomialOrder 2; faceStencilExtraCells 10; diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/comparisonPlotScripts/dispErrors_movingVskExact.gnuplot b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/comparisonPlotScripts/dispErrors_movingVskExact.gnuplot new file mode 100644 index 00000000..360cca34 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/comparisonPlotScripts/dispErrors_movingVskExact.gnuplot @@ -0,0 +1,122 @@ +set term pdfcairo dashed enhanced size 3.25, 2 +set datafile separator " " + +if (ARGC < 1) { + print "Usage: gnuplot -c dispErrors_movingVskExact.gnuplot " + exit +} + +movingResults = ARG1 +movingFile(fileName) = sprintf("%s/%s", movingResults, fileName) + +volume = 0.2**3 + +set grid +set xrange [3:60] +set yrange [1e-9:0.2] +set xtics +set xtics add (5, 25, 50) +set ytics +set logscale x +set logscale y +set format y "10^{%L}" +#set ytics 0.002 +set xlabel "Average cell edge (in mm)" +set ylabel "Error (in μm)" +set key right bottom outside; +set rmargin 16 +set key spacing 1.2 + +# Polynomial guide lines (no title) +set style line 1 lc rgb "red" lt 2 lw 2 dt 2 +set style line 2 lc rgb "blue" lt 2 lw 2 dt 2 +set style line 3 lc rgb "violet" lt 2 lw 2 dt 2 + +# Data lines for each p-order (with titles) +set style line 11 lc rgb "red" pt 7 ps 0.5 lw 1 +set style line 12 lc rgb "red" pt 6 ps 0.5 lw 1 +set style line 21 lc rgb "blue" pt 5 ps 0.5 lw 1 +set style line 22 lc rgb "blue" pt 4 ps 0.5 lw 1 +set style line 31 lc rgb "violet" pt 9 ps 0.5 lw 1 +set style line 32 lc rgb "violet" pt 8 ps 0.5 lw 1 + +# Moving-least-squares data use the same colours with 50% transparency +set style line 111 lc rgb "#B3ff0000" pt 7 ps 0.5 lw 1 +set style line 112 lc rgb "#B3ff0000" pt 6 ps 0.5 lw 1 +set style line 121 lc rgb "#B30000ff" pt 5 ps 0.5 lw 1 +set style line 122 lc rgb "#B30000ff" pt 4 ps 0.5 lw 1 +set style line 131 lc rgb "#B3ee82ee" pt 9 ps 0.5 lw 1 +set style line 132 lc rgb "#B3ee82ee" pt 8 ps 0.5 lw 1 + +set output "mms_3D_dispErrors_hex_struct_movingVskExact.pdf" +plot \ + (1e-4 * x**2) w l ls 1 title "2^{nd} order", \ + (4e-07 * x**3) w l ls 2 title "3^{rd} order", \ + (5e-10 * x**4) w l ls 3 title "4^{th} order", \ + "hex.struct.ho.N1.summary.txt" u ((volume/$4)**(1.0/3.0)*1e3):($5*1e6) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "hex.struct.ho.N1.summary.txt" u ((volume/$4)**(1.0/3.0)*1e3):($6*1e6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "hex.struct.ho.N2.summary.txt" u ((volume/$4)**(1.0/3.0)*1e3):($5*1e6) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "hex.struct.ho.N2.summary.txt" u ((volume/$4)**(1.0/3.0)*1e3):($6*1e6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "hex.struct.ho.N3.summary.txt" u ((volume/$4)**(1.0/3.0)*1e3):($5*1e6) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "hex.struct.ho.N3.summary.txt" u ((volume/$4)**(1.0/3.0)*1e3):($6*1e6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)", \ + movingFile("hex.struct.ho.N1.summary.txt") u ((volume/$4)**(1.0/3.0)*1e3):($5*1e6) w lp ls 111 notitle, \ + movingFile("hex.struct.ho.N1.summary.txt") u ((volume/$4)**(1.0/3.0)*1e3):($6*1e6) w lp ls 112 notitle, \ + movingFile("hex.struct.ho.N2.summary.txt") u ((volume/$4)**(1.0/3.0)*1e3):($5*1e6) w lp ls 121 notitle, \ + movingFile("hex.struct.ho.N2.summary.txt") u ((volume/$4)**(1.0/3.0)*1e3):($6*1e6) w lp ls 122 notitle, \ + movingFile("hex.struct.ho.N3.summary.txt") u ((volume/$4)**(1.0/3.0)*1e3):($5*1e6) w lp ls 131 notitle, \ + movingFile("hex.struct.ho.N3.summary.txt") u ((volume/$4)**(1.0/3.0)*1e3):($6*1e6) w lp ls 132 notitle + +set output "mms_3D_dispErrors_ho-tet_struct_movingVskExact.pdf" +plot \ + (1e-4 * x**2) w l ls 1 title "2^{nd} order", \ + (4e-07 * x**3) w l ls 2 title "3^{rd} order", \ + (5e-10 * x**4) w l ls 3 title "4^{th} order", \ + "tet.struct.ho.N1.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($5*1e6) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.struct.ho.N1.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($6*1e6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.struct.ho.N2.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($5*1e6) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.struct.ho.N2.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($6*1e6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "tet.struct.ho.N3.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($5*1e6) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "tet.struct.ho.N3.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($6*1e6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)", \ + movingFile("tet.struct.ho.N1.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($5*1e6) w lp ls 111 notitle, \ + movingFile("tet.struct.ho.N1.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($6*1e6) w lp ls 112 notitle, \ + movingFile("tet.struct.ho.N2.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($5*1e6) w lp ls 121 notitle, \ + movingFile("tet.struct.ho.N2.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($6*1e6) w lp ls 122 notitle, \ + movingFile("tet.struct.ho.N3.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($5*1e6) w lp ls 131 notitle, \ + movingFile("tet.struct.ho.N3.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($6*1e6) w lp ls 132 notitle + +set output "mms_3D_dispErrors_ho-tet_unstruct_movingVskExact.pdf" +plot \ + (1e-4 * x**2) w l ls 1 title "2^{nd} order", \ + (4e-07 * x**3) w l ls 2 title "3^{rd} order", \ + (5e-10 * x**4) w l ls 3 title "4^{th} order", \ + "tet.unstruct.ho.N1.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($5*1e6) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct.ho.N1.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($6*1e6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct.ho.N2.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($5*1e6) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct.ho.N2.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($6*1e6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct.ho.N3.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($5*1e6) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "tet.unstruct.ho.N3.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($6*1e6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)", \ + movingFile("tet.unstruct.ho.N1.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($5*1e6) w lp ls 111 notitle, \ + movingFile("tet.unstruct.ho.N1.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($6*1e6) w lp ls 112 notitle, \ + movingFile("tet.unstruct.ho.N2.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($5*1e6) w lp ls 121 notitle, \ + movingFile("tet.unstruct.ho.N2.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($6*1e6) w lp ls 122 notitle, \ + movingFile("tet.unstruct.ho.N3.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($5*1e6) w lp ls 131 notitle, \ + movingFile("tet.unstruct.ho.N3.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($6*1e6) w lp ls 132 notitle + +set output "mms_3D_dispErrors_ho-poly_struct_movingVskExact.pdf" +plot \ + (1e-4 * x**2) w l ls 1 title "2^{nd} order", \ + (4e-07 * x**3) w l ls 2 title "3^{rd} order", \ + (5e-10 * x**4) w l ls 3 title "4^{th} order", \ + "poly.struct.ho.N1.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($5*1e6) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "poly.struct.ho.N1.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($6*1e6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "poly.struct.ho.N2.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($5*1e6) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "poly.struct.ho.N2.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($6*1e6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "poly.struct.ho.N3.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($5*1e6) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "poly.struct.ho.N3.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($6*1e6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)", \ + movingFile("poly.struct.ho.N1.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($5*1e6) w lp ls 111 notitle, \ + movingFile("poly.struct.ho.N1.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($6*1e6) w lp ls 112 notitle, \ + movingFile("poly.struct.ho.N2.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($5*1e6) w lp ls 121 notitle, \ + movingFile("poly.struct.ho.N2.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($6*1e6) w lp ls 122 notitle, \ + movingFile("poly.struct.ho.N3.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($5*1e6) w lp ls 131 notitle, \ + movingFile("poly.struct.ho.N3.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($6*1e6) w lp ls 132 notitle + diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/comparisonPlotScripts/efficiency_movingVskExact.gnuplot b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/comparisonPlotScripts/efficiency_movingVskExact.gnuplot new file mode 100644 index 00000000..8d543739 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/comparisonPlotScripts/efficiency_movingVskExact.gnuplot @@ -0,0 +1,183 @@ +set term pdfcairo dashed enhanced size 3.25, 2 +set datafile separator " " + +if (ARGC < 1) { + print "Usage: gnuplot -c efficiency_movingVskExact.gnuplot " + exit +} + +movingResults = ARG1 +movingFile(fileName) = sprintf("%s/%s", movingResults, fileName) + +volume = 0.2**3 + +set grid +set xrange [0:1000] +#set yrange [1e-9:0.2] +set xtics +#set xtics add (5, 25, 50) +set ytics +set logscale x +set logscale y +set format y "10^{%L}" +#set ytics 0.002 +set xlabel "Time (in s)" +set ylabel "{/Times-Italic L}_{ 2} error (in μm)" +set key right bottom outside; +set rmargin 15 +set key spacing 1.2 + +# Polynomial guide lines (no title) +set style line 1 lc rgb "red" lt 2 lw 2 dt 2 +set style line 2 lc rgb "blue" lt 2 lw 2 dt 2 +set style line 3 lc rgb "violet" lt 2 lw 2 dt 2 + +# Data lines for each p-order (with titles) +set style line 01 lc rgb "black" pt 7 ps 0.5 lw 1 +set style line 02 lc rgb "slategrey" pt 7 ps 0.5 lw 1 +set style line 11 lc rgb "red" pt 7 ps 0.5 lw 1 +set style line 12 lc rgb "red" pt 6 ps 0.5 lw 1 +set style line 21 lc rgb "blue" pt 5 ps 0.5 lw 1 +set style line 22 lc rgb "blue" pt 4 ps 0.5 lw 1 +set style line 31 lc rgb "violet" pt 9 ps 0.5 lw 1 +set style line 32 lc rgb "violet" pt 8 ps 0.5 lw 1 + +# Moving-least-squares data use the same colours with 30% opacity +set style line 111 lc rgb "#B3ff0000" pt 7 ps 0.5 lw 1 +set style line 121 lc rgb "#B30000ff" pt 5 ps 0.5 lw 1 +set style line 131 lc rgb "#B3ee82ee" pt 9 ps 0.5 lw 1 + +set output "mms_3D_dispEfficiency_hex_struct_movingVskExact.pdf" +plot \ + "hex.struct.seg.summary.txt" u 2:($5*1e6) w lp ls 01 title"S4F_{SEG}", \ + "hex.struct.hypre-snes.summary.txt" u 2:($5*1e6) w lp ls 02 title "S4F_{JFNK}", \ + "hex.struct.ho.N1.summary.txt" u 2:($5*1e6) w lp ls 11 title "{/Times-Italic p}_{ }=1", \ + "hex.struct.ho.N2.summary.txt" u 2:($5*1e6) w lp ls 21 title "{/Times-Italic p}_{ }=2", \ + "hex.struct.ho.N3.summary.txt" u 2:($5*1e6) w lp ls 31 title "{/Times-Italic p}_{ }=3", \ + movingFile("hex.struct.ho.N1.summary.txt") u 2:($5*1e6) w lp ls 111 notitle, \ + movingFile("hex.struct.ho.N2.summary.txt") u 2:($5*1e6) w lp ls 121 notitle, \ + movingFile("hex.struct.ho.N3.summary.txt") u 2:($5*1e6) w lp ls 131 notitle + +set output "mms_3D_dispEfficiency_tet_struct_movingVskExact.pdf" +plot \ + "tet.struct.seg.summary.txt" u 2:($5*1e6) w lp ls 01 title"S4F_{SEG}", \ + "tet.struct.hypre-snes.summary.txt" u 2:($5*1e6) w lp ls 02 title "S4F_{JFNK}", \ + "tet.struct.ho.N1.summary.txt" u 2:($5*1e6) w lp ls 11 title "{/Times-Italic p}_{ }=1", \ + "tet.struct.ho.N2.summary.txt" u 2:($5*1e6) w lp ls 21 title "{/Times-Italic p}_{ }=2", \ + "tet.struct.ho.N3.summary.txt" u 2:($5*1e6) w lp ls 31 title "{/Times-Italic p}_{ }=3", \ + movingFile("tet.struct.ho.N1.summary.txt") u 2:($5*1e6) w lp ls 111 notitle, \ + movingFile("tet.struct.ho.N2.summary.txt") u 2:($5*1e6) w lp ls 121 notitle, \ + movingFile("tet.struct.ho.N3.summary.txt") u 2:($5*1e6) w lp ls 131 notitle + +# set output "mms_3D_dispEfficiency_tet_unstruct_movingVskExact.pdf" +# plot \ +# "tet.unstruct.seg.summary.txt" u 2:($5*1e6) w lp ls 01 title"S4F_{SEG}", \ +# "tet.unstruct.hypre-snes.summary.txt" u 2:($5*1e6) w lp ls 02 title "S4F_{JFNK}", \ +# "tet.unstruct.ho.N1.summary.txt" u 2:($5*1e6) w lp ls 11 title "{/Times-Italic p}_{ }=1", \ +# "tet.unstruct.ho.N2.summary.txt" u 2:($5*1e6) w lp ls 21 title "{/Times-Italic p}_{ }=2", \ +# "tet.unstruct.ho.N3.summary.txt" u 2:($5*1e6) w lp ls 31 title "{/Times-Italic p}_{ }=3", \ +# movingFile("tet.unstruct.ho.N1.summary.txt") u 2:($5*1e6) w lp ls 111 notitle, \ +# movingFile("tet.unstruct.ho.N2.summary.txt") u 2:($5*1e6) w lp ls 121 notitle, \ +# movingFile("tet.unstruct.ho.N3.summary.txt") u 2:($5*1e6) w lp ls 131 notitle + +set output "mms_3D_dispEfficiency_poly_struct_movingVskExact.pdf" +plot \ + "poly.struct.seg.summary.txt" u 2:($5*1e6) w lp ls 01 title"S4F_{SEG}", \ + "poly.struct.hypre-snes.summary.txt" u 2:($5*1e6) w lp ls 02 title "S4F_{JFNK}", \ + "poly.struct.ho.N1.summary.txt" u 2:($5*1e6) w lp ls 11 title "{/Times-Italic p}_{ }=1", \ + "poly.struct.ho.N2.summary.txt" u 2:($5*1e6) w lp ls 21 title "{/Times-Italic p}_{ }=2", \ + "poly.struct.ho.N3.summary.txt" u 2:($5*1e6) w lp ls 31 title "{/Times-Italic p}_{ }=3", \ + movingFile("poly.struct.ho.N1.summary.txt") u 2:($5*1e6) w lp ls 111 notitle, \ + movingFile("poly.struct.ho.N2.summary.txt") u 2:($5*1e6) w lp ls 121 notitle, \ + movingFile("poly.struct.ho.N3.summary.txt") u 2:($5*1e6) w lp ls 131 notitle + +set output "mms_3D_stressEfficiency_hex_struct_movingVskExact.pdf" +plot \ + "hex.struct.seg.summary.txt" u 2:($7*1e-6) w lp ls 01 title"S4F_{SEG}", \ + "hex.struct.hypre-snes.summary.txt" u 2:($7*1e-6) w lp ls 02 title "S4F_{JFNK}", \ + "hex.struct.ho.N1.summary.txt" u 2:($7*1e-6) w lp ls 11 title "{/Times-Italic p}_{ }=1", \ + "hex.struct.ho.N2.summary.txt" u 2:($7*1e-6) w lp ls 21 title "{/Times-Italic p}_{ }=2", \ + "hex.struct.ho.N3.summary.txt" u 2:($7*1e-6) w lp ls 31 title "{/Times-Italic p}_{ }=3", \ + movingFile("hex.struct.ho.N1.summary.txt") u 2:($7*1e-6) w lp ls 111 notitle, \ + movingFile("hex.struct.ho.N2.summary.txt") u 2:($7*1e-6) w lp ls 121 notitle, \ + movingFile("hex.struct.ho.N3.summary.txt") u 2:($7*1e-6) w lp ls 131 notitle + +set output "mms_3D_stressEfficiency_tet_struct_movingVskExact.pdf" +plot \ + "tet.struct.seg.summary.txt" u 2:($7*1e-6) w lp ls 01 title"S4F_{SEG}", \ + "tet.struct.hypre-snes.summary.txt" u 2:($7*1e-6) w lp ls 02 title "S4F_{JFNK}", \ + "tet.struct.ho.N1.summary.txt" u 2:($7*1e-6) w lp ls 11 title "{/Times-Italic p}_{ }=1", \ + "tet.struct.ho.N2.summary.txt" u 2:($7*1e-6) w lp ls 21 title "{/Times-Italic p}_{ }=2", \ + "tet.struct.ho.N3.summary.txt" u 2:($7*1e-6) w lp ls 31 title "{/Times-Italic p}_{ }=3", \ + movingFile("tet.struct.ho.N1.summary.txt") u 2:($7*1e-6) w lp ls 111 notitle, \ + movingFile("tet.struct.ho.N2.summary.txt") u 2:($7*1e-6) w lp ls 121 notitle, \ + movingFile("tet.struct.ho.N3.summary.txt") u 2:($7*1e-6) w lp ls 131 notitle + +# set output "mms_3D_stressEfficiency_tet_unstruct_movingVskExact.pdf" +# plot \ +# "tet.unstruct.seg.summary.txt" u 2:($7*1e-6) w lp ls 01 title"S4F_{SEG}", \ +# "tet.unstruct.hypre-snes.summary.txt" u 2:($7*1e-6) w lp ls 02 title "S4F_{JFNK}", \ +# "tet.unstruct.ho.N1.summary.txt" u 2:($7*1e-6) w lp ls 11 title "{/Times-Italic p}_{ }=1", \ +# "tet.unstruct.ho.N2.summary.txt" u 2:($7*1e-6) w lp ls 21 title "{/Times-Italic p}_{ }=2", \ +# "tet.unstruct.ho.N3.summary.txt" u 2:($7*1e-6) w lp ls 31 title "{/Times-Italic p}_{ }=3", \ +# movingFile("tet.unstruct.ho.N1.summary.txt") u 2:($7*1e-6) w lp ls 111 notitle, \ +# movingFile("tet.unstruct.ho.N2.summary.txt") u 2:($7*1e-6) w lp ls 121 notitle, \ +# movingFile("tet.unstruct.ho.N3.summary.txt") u 2:($7*1e-6) w lp ls 131 notitle + +set output "mms_3D_stressEfficiency_poly_struct_movingVskExact.pdf" +plot \ + "poly.struct.seg.summary.txt" u 2:($7*1e-6) w lp ls 01 title"S4F_{SEG}", \ + "poly.struct.hypre-snes.summary.txt" u 2:($7*1e-6) w lp ls 02 title "S4F_{JFNK}", \ + "poly.struct.ho.N1.summary.txt" u 2:($7*1e-6) w lp ls 11 title "{/Times-Italic p}_{ }=1", \ + "poly.struct.ho.N2.summary.txt" u 2:($7*1e-6) w lp ls 21 title "{/Times-Italic p}_{ }=2", \ + "poly.struct.ho.N3.summary.txt" u 2:($7*1e-6) w lp ls 31 title "{/Times-Italic p}_{ }=3", \ + movingFile("poly.struct.ho.N1.summary.txt") u 2:($7*1e-6) w lp ls 111 notitle, \ + movingFile("poly.struct.ho.N2.summary.txt") u 2:($7*1e-6) w lp ls 121 notitle, \ + movingFile("poly.struct.ho.N3.summary.txt") u 2:($7*1e-6) w lp ls 131 notitle + +set output "mms_3D_memoryEfficiency_hex_struct_movingVskExact.pdf" +set xrange [0.05:10] +set xlabel "Memory (in MB)" + +plot \ + "hex.struct.seg.summary.txt" u ($3/1024):($5*1e6) w lp ls 01 title"S4F_{SEG}", \ + "hex.struct.hypre-snes.summary.txt" u ($3/1204):($5*1e6) w lp ls 02 title "S4F_{JFNK}", \ + "hex.struct.ho.N1.summary.txt" u ($3/1024):($5*1e6) w lp ls 11 title "{/Times-Italic p}_{ }=1", \ + "hex.struct.ho.N2.summary.txt" u ($3/1024):($5*1e6) w lp ls 21 title "{/Times-Italic p}_{ }=2", \ + "hex.struct.ho.N3.summary.txt" u ($3/1024):($5*1e6) w lp ls 31 title "{/Times-Italic p}_{ }=3", \ + movingFile("hex.struct.ho.N1.summary.txt") u ($3/1024):($5*1e6) w lp ls 111 notitle, \ + movingFile("hex.struct.ho.N2.summary.txt") u ($3/1024):($5*1e6) w lp ls 121 notitle, \ + movingFile("hex.struct.ho.N3.summary.txt") u ($3/1024):($5*1e6) w lp ls 131 notitle + +set output "mms_3D_memoryEfficiency_tet_struct_movingVskExact.pdf" +plot \ + "tet.struct.seg.summary.txt" u ($3/1024):($5*1e6) w lp ls 01 title"S4F_{SEG}", \ + "tet.struct.hypre-snes.summary.txt" u ($3/1024):($5*1e6) w lp ls 02 title "S4F_{JFNK}", \ + "tet.struct.ho.N1.summary.txt" u ($3/1024):($5*1e6) w lp ls 11 title "{/Times-Italic p}_{ }=1", \ + "tet.struct.ho.N2.summary.txt" u ($3/1024):($5*1e6) w lp ls 21 title "{/Times-Italic p}_{ }=2", \ + "tet.struct.ho.N3.summary.txt" u ($3/1024):($5*1e6) w lp ls 31 title "{/Times-Italic p}_{ }=3", \ + movingFile("tet.struct.ho.N1.summary.txt") u ($3/1024):($5*1e6) w lp ls 111 notitle, \ + movingFile("tet.struct.ho.N2.summary.txt") u ($3/1024):($5*1e6) w lp ls 121 notitle, \ + movingFile("tet.struct.ho.N3.summary.txt") u ($3/1024):($5*1e6) w lp ls 131 notitle + +# set output "mms_3D_memoryEfficiency_tet_unstruct_movingVskExact.pdf" +# plot \ +# "tet.unstruct.seg.summary.txt" u ($3/1024):($5*1e6) w lp ls 01 title"S4F_{SEG}", \ +# "tet.unstruct.hypre-snes.summary.txt" u ($3/1024):($5*1e6) w lp ls 02 title "S4F_{JFNK}", \ +# "tet.unstruct.ho.N1.summary.txt" u ($3/1024):($5*1e6) w lp ls 11 title "{/Times-Italic p}_{ }=1", \ +# "tet.unstruct.ho.N2.summary.txt" u ($3/1024):($5*1e6) w lp ls 21 title "{/Times-Italic p}_{ }=2", \ +# "tet.unstruct.ho.N3.summary.txt" u ($3/1024):($5*1e6) w lp ls 31 title "{/Times-Italic p}_{ }=3", \ +# movingFile("tet.unstruct.ho.N1.summary.txt") u ($3/1024):($5*1e6) w lp ls 111 notitle, \ +# movingFile("tet.unstruct.ho.N2.summary.txt") u ($3/1024):($5*1e6) w lp ls 121 notitle, \ +# movingFile("tet.unstruct.ho.N3.summary.txt") u ($3/1024):($5*1e6) w lp ls 131 notitle + +# set output "mms_3D_memoryEfficiency_poly_struct_movingVskExact.pdf" +# plot \ +# "poly.struct.seg.summary.txt" u ($3/1024):($5*1e6) w lp ls 01 title"S4F_{SEG}", \ +# "poly.struct.hypre-snes.summary.txt" u ($3/1024):($5*1e6) w lp ls 02 title "S4F_{JFNK}", \ +# "poly.struct.ho.N1.summary.txt" u ($3/1024):($5*1e6) w lp ls 11 title "{/Times-Italic p}_{ }=1", \ +# "poly.struct.ho.N2.summary.txt" u ($3/1024):($5*1e6) w lp ls 21 title "{/Times-Italic p}_{ }=2", \ +# "poly.struct.ho.N3.summary.txt" u ($3/1024):($5*1e6) w lp ls 31 title "{/Times-Italic p}_{ }=3", \ +# movingFile("poly.struct.ho.N1.summary.txt") u ($3/1024):($5*1e6) w lp ls 111 notitle, \ +# movingFile("poly.struct.ho.N2.summary.txt") u ($3/1024):($5*1e6) w lp ls 121 notitle, \ +# movingFile("poly.struct.ho.N3.summary.txt") u ($3/1024):($5*1e6) w lp ls 131 notitle diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/comparisonPlotScripts/stressErrors_movingVskExact.gnuplot b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/comparisonPlotScripts/stressErrors_movingVskExact.gnuplot new file mode 100644 index 00000000..fc932793 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/comparisonPlotScripts/stressErrors_movingVskExact.gnuplot @@ -0,0 +1,122 @@ +set term pdfcairo dashed enhanced size 3.25, 2 +set datafile separator " " + +if (ARGC < 1) { + print "Usage: gnuplot -c stressErrors_movingVskExact.gnuplot " + exit +} + +movingResults = ARG1 +movingFile(fileName) = sprintf("%s/%s", movingResults, fileName) + +volume = 0.2**3 + +set grid +set xrange [3:60] +set yrange [1e-8:10] +set xtics +set xtics add (5, 25, 50) +set ytics +set logscale x +set logscale y +set format y "10^{%L}" +#set ytics 0.002 +set xlabel "Average cell edge (in mm)" +set ylabel "Error (in MPa)" +set key right bottom outside; +set rmargin 16 +set key spacing 1.2 + +# Polynomial guide lines (no title) +set style line 1 lc rgb "red" lt 2 lw 2 dt 2 +set style line 2 lc rgb "blue" lt 2 lw 2 dt 2 +set style line 3 lc rgb "violet" lt 2 lw 2 dt 2 + +# Data lines for each p-order (with titles) +set style line 11 lc rgb "red" pt 7 ps 0.5 lw 1 +set style line 12 lc rgb "red" pt 6 ps 0.5 lw 1 +set style line 21 lc rgb "blue" pt 5 ps 0.5 lw 1 +set style line 22 lc rgb "blue" pt 4 ps 0.5 lw 1 +set style line 31 lc rgb "violet" pt 9 ps 0.5 lw 1 +set style line 32 lc rgb "violet" pt 8 ps 0.5 lw 1 + +# Moving-least-squares data use the same colours with 50% transparency +set style line 111 lc rgb "#B3ff0000" pt 7 ps 0.5 lw 1 +set style line 112 lc rgb "#B3ff0000" pt 6 ps 0.5 lw 1 +set style line 121 lc rgb "#B30000ff" pt 5 ps 0.5 lw 1 +set style line 122 lc rgb "#B30000ff" pt 4 ps 0.5 lw 1 +set style line 131 lc rgb "#B3ee82ee" pt 9 ps 0.5 lw 1 +set style line 132 lc rgb "#B3ee82ee" pt 8 ps 0.5 lw 1 + +set output "mms_3D_stressErrors_hex_struct_movingVskExact.pdf" +plot \ + (2e-2 * x) w l ls 1 title "1^{st} order", \ + (0.15e-3 * x**2) w l ls 2 title "2^{nd} order", \ + (0.4e-6 * x**3) w l ls 3 title "3^{rd} order", \ + "hex.struct.ho.N1.summary.txt" u ((volume/$4)**(1.0/3.0)*1e3):($7*1e-6) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "hex.struct.ho.N1.summary.txt" u ((volume/$4)**(1.0/3.0)*1e3):($8*1e-6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "hex.struct.ho.N2.summary.txt" u ((volume/$4)**(1.0/3.0)*1e3):($7*1e-6) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "hex.struct.ho.N2.summary.txt" u ((volume/$4)**(1.0/3.0)*1e3):($8*1e-6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "hex.struct.ho.N3.summary.txt" u ((volume/$4)**(1.0/3.0)*1e3):($7*1e-6) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "hex.struct.ho.N3.summary.txt" u ((volume/$4)**(1.0/3.0)*1e3):($8*1e-6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)", \ + movingFile("hex.struct.ho.N1.summary.txt") u ((volume/$4)**(1.0/3.0)*1e3):($7*1e-6) w lp ls 111 notitle, \ + movingFile("hex.struct.ho.N1.summary.txt") u ((volume/$4)**(1.0/3.0)*1e3):($8*1e-6) w lp ls 112 notitle, \ + movingFile("hex.struct.ho.N2.summary.txt") u ((volume/$4)**(1.0/3.0)*1e3):($7*1e-6) w lp ls 121 notitle, \ + movingFile("hex.struct.ho.N2.summary.txt") u ((volume/$4)**(1.0/3.0)*1e3):($8*1e-6) w lp ls 122 notitle, \ + movingFile("hex.struct.ho.N3.summary.txt") u ((volume/$4)**(1.0/3.0)*1e3):($7*1e-6) w lp ls 131 notitle, \ + movingFile("hex.struct.ho.N3.summary.txt") u ((volume/$4)**(1.0/3.0)*1e3):($8*1e-6) w lp ls 132 notitle + +set output "mms_3D_stressErrors_ho-tet_struct_movingVskExact.pdf" +plot \ + (2e-2 * x) w l ls 1 title "1^{st} order", \ + (0.15e-3 * x**2) w l ls 2 title "2^{nd} order", \ + (0.4e-6 * x**3) w l ls 3 title "3^{rd} order", \ + "tet.struct.ho.N1.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($7*1e-6) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.struct.ho.N1.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($8*1e-6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.struct.ho.N2.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($7*1e-6) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.struct.ho.N2.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($8*1e-6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "tet.struct.ho.N3.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($7*1e-6) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "tet.struct.ho.N3.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($8*1e-6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)", \ + movingFile("tet.struct.ho.N1.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($7*1e-6) w lp ls 111 notitle, \ + movingFile("tet.struct.ho.N1.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($8*1e-6) w lp ls 112 notitle, \ + movingFile("tet.struct.ho.N2.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($7*1e-6) w lp ls 121 notitle, \ + movingFile("tet.struct.ho.N2.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($8*1e-6) w lp ls 122 notitle, \ + movingFile("tet.struct.ho.N3.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($7*1e-6) w lp ls 131 notitle, \ + movingFile("tet.struct.ho.N3.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($8*1e-6) w lp ls 132 notitle + +set output "mms_3D_stressErrors_ho-tet_unstruct_movingVskExact.pdf" +plot \ + (2e-2 * x) w l ls 1 title "1^{st} order", \ + (0.15e-3 * x**2) w l ls 2 title "2^{nd} order", \ + (0.4e-6 * x**3) w l ls 3 title "3^{rd} order", \ + "tet.unstruct.ho.N1.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($7*1e-6) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct.ho.N1.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($8*1e-6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct.ho.N2.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($7*1e-6) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct.ho.N2.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($8*1e-6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct.ho.N3.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($7*1e-6) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "tet.unstruct.ho.N3.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($8*1e-6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)", \ + movingFile("tet.unstruct.ho.N1.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($7*1e-6) w lp ls 111 notitle, \ + movingFile("tet.unstruct.ho.N1.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($8*1e-6) w lp ls 112 notitle, \ + movingFile("tet.unstruct.ho.N2.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($7*1e-6) w lp ls 121 notitle, \ + movingFile("tet.unstruct.ho.N2.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($8*1e-6) w lp ls 122 notitle, \ + movingFile("tet.unstruct.ho.N3.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($7*1e-6) w lp ls 131 notitle, \ + movingFile("tet.unstruct.ho.N3.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($8*1e-6) w lp ls 132 notitle + +set output "mms_3D_stressErrors_ho-poly_struct_movingVskExact.pdf" +plot \ + (2e-2 * x) w l ls 1 title "1^{st} order", \ + (0.15e-3 * x**2) w l ls 2 title "2^{nd} order", \ + (0.4e-6 * x**3) w l ls 3 title "3^{rd} order", \ + "poly.struct.ho.N1.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($7*1e-6) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "poly.struct.ho.N1.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($8*1e-6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "poly.struct.ho.N2.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($7*1e-6) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "poly.struct.ho.N2.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($8*1e-6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "poly.struct.ho.N3.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($7*1e-6) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "poly.struct.ho.N3.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($8*1e-6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)", \ + movingFile("poly.struct.ho.N1.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($7*1e-6) w lp ls 111 notitle, \ + movingFile("poly.struct.ho.N1.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($8*1e-6) w lp ls 112 notitle, \ + movingFile("poly.struct.ho.N2.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($7*1e-6) w lp ls 121 notitle, \ + movingFile("poly.struct.ho.N2.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($8*1e-6) w lp ls 122 notitle, \ + movingFile("poly.struct.ho.N3.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($7*1e-6) w lp ls 131 notitle, \ + movingFile("poly.struct.ho.N3.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($8*1e-6) w lp ls 132 notitle + diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/Allwmake b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/Allwmake similarity index 100% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/Allwmake rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/Allwmake diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/Make/files b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/Make/files similarity index 100% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/Make/files rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/Make/files diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/Make/options b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/Make/options similarity index 100% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/Make/options rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/Make/options diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/manufacturedSolution.C b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/manufacturedSolution.C similarity index 99% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/manufacturedSolution.C rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/manufacturedSolution.C index 1fd6d5e5..1dddca06 100644 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/manufacturedSolution.C +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/manufacturedSolution.C @@ -70,7 +70,7 @@ void Foam::manufacturedSolution::calcBodyForces() const { const solidModel& solMod = lookupSolidModel(mesh); const fvMeshQuadrature& quadrature = - solMod.displacementMLS().quadrature(); + solMod.displacementLeastSquares().quadrature(); const CompactListList& cellQuadPoints = quadrature.cellQuadPoints(); const CompactListList& cellQuadWeights = @@ -86,6 +86,8 @@ void Foam::manufacturedSolution::calcBodyForces() const bodyForcesI[cellI] += quadWeights[pointI]*calculateBodyForce(quadPoints[pointI]); } + + bodyForcesI[cellI] /= mesh_.V()[cellI]; } } else diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/manufacturedSolution.H b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/manufacturedSolution.H similarity index 100% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/manufacturedSolution.H rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/manufacturedSolution.H diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolutionFunctionObject.C b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/manufacturedSolutionFunctionObject.C similarity index 85% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolutionFunctionObject.C rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/manufacturedSolutionFunctionObject.C index 67df7fef..2747a323 100644 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolutionFunctionObject.C +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/manufacturedSolutionFunctionObject.C @@ -22,6 +22,7 @@ License #include "volFields.H" #include "pointFields.H" #include "coordinateSystem.H" +#include "lookupSolidModel.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -40,6 +41,77 @@ namespace Foam // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +void Foam::manufacturedSolutionFunctionObject:: +calculateAnalyticalCellDisplacement +( + const fvMesh& mesh, + vectorField& analyticalD +) +{ + const solidModel& solMod = lookupSolidModel(mesh); + bool useCellAverage = false; + + if (solMod.highOrderResidual()) + { + const dictionary& highOrderDict = + solMod.solidModelDict().subDict("highOrderCoeffs"); + const dictionary& displacementDict = + highOrderDict.subDict("displacement"); + const word reconstructionType + ( + displacementDict.lookupOrDefault + ( + "type", + "movingLeastSquares" + ) + ); + + useCellAverage = reconstructionType == "kExactLeastSquares"; + } + + if (useCellAverage) + { + const fvMeshQuadrature& quadrature = + solMod.displacementLeastSquares().quadrature(); + const CompactListList& cellQuadPoints = + quadrature.cellQuadPoints(); + const CompactListList& cellQuadWeights = + quadrature.cellQuadWeights(); + const scalarField& cellVolumes = mesh.V(); + + Info<< "Using cell-average analytical displacement" << endl; + + forAll(analyticalD, cellI) + { + analyticalD[cellI] = vector::zero; + + forAll(cellQuadPoints[cellI], pointI) + { + analyticalD[cellI] += + cellQuadWeights[cellI][pointI] + *mmsPtr_->calculateDisplacement + ( + cellQuadPoints[cellI][pointI] + ); + } + + analyticalD[cellI] /= cellVolumes[cellI]; + } + } + else + { + Info<< "Using point-valued analytical displacement" << endl; + + const vectorField& cellCentres = mesh.C().internalField(); + forAll(analyticalD, cellI) + { + analyticalD[cellI] = + mmsPtr_->calculateDisplacement(cellCentres[cellI]); + } + } +} + + bool Foam::manufacturedSolutionFunctionObject::writeData() { // Lookup the solid mesh @@ -138,9 +210,10 @@ bool Foam::manufacturedSolutionFunctionObject::writeData() forAll(sI, cellI) { sI[cellI] = mmsPtr_->calculateStress(CI[cellI]); - aDI[cellI] = mmsPtr_->calculateDisplacement(CI[cellI]); } + calculateAnalyticalCellDisplacement(mesh, aDI); + forAll(pEI, pointI) { pEI[pointI] = mmsPtr_->calculateStrain(points[pointI]); diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolutionFunctionObject.H b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/manufacturedSolutionFunctionObject.H similarity index 94% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolutionFunctionObject.H rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/manufacturedSolutionFunctionObject.H index 64f90c88..babd147a 100644 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/polynomial/manufacturedSolution/manufacturedSolutionFunctionObject.H +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/manufacturedSolutionFunctionObject.H @@ -82,6 +82,14 @@ class manufacturedSolutionFunctionObject // Private Member Functions + //- Calculate analytical cell displacement using the selected + // reconstruction semantics + void calculateAnalyticalCellDisplacement + ( + const fvMesh& mesh, + vectorField& analyticalD + ); + //- Write data bool writeData(); diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/manufacturedSolutionFvPatchVectorField.C b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/manufacturedSolutionFvPatchVectorField.C similarity index 98% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/manufacturedSolutionFvPatchVectorField.C rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/manufacturedSolutionFvPatchVectorField.C index a486349e..7f964875 100644 --- a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/manufacturedSolutionFvPatchVectorField.C +++ b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/manufacturedSolutionFvPatchVectorField.C @@ -129,7 +129,7 @@ manufacturedSolutionFvPatchVectorField::evaluateQuadrature // faceQuadPoints is list for the whole mesh const CompactListList& faceQuadPoints = - solMod.displacementMLS().quadrature().faceQuadPoints(); + solMod.displacementLeastSquares().quadrature().faceQuadPoints(); // faceQuadPoints is list for whole mesh. labelList nQpPerFace(this->size(), 0); diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/manufacturedSolutionFvPatchVectorField.H b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/manufacturedSolutionFvPatchVectorField.H similarity index 100% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/manufacturedSolutionFvPatchVectorField.H rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/manufacturedSolutionFvPatchVectorField.H diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/manufacturedSolutionSource.C b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/manufacturedSolutionSource.C similarity index 100% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/manufacturedSolutionSource.C rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/manufacturedSolutionSource.C diff --git a/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/manufacturedSolutionSource.H b/papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/manufacturedSolutionSource.H similarity index 100% rename from papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/manufacturedSolution/manufacturedSolutionSource.H rename to papers/JFNK_highOrder/linearElastic/manufacturedSolution/trigonometric/src/manufacturedSolutionSource.H diff --git a/papers/JFNK_highOrder/linearElastic/plateHole/Allrun b/papers/JFNK_highOrder/linearElastic/plateHole/Allrun index 9a7cc9e7..a81b08be 100755 --- a/papers/JFNK_highOrder/linearElastic/plateHole/Allrun +++ b/papers/JFNK_highOrder/linearElastic/plateHole/Allrun @@ -7,11 +7,11 @@ source solids4FoamScripts.sh solids4Foam::caseDoesNotRunWithFoamExtend # solids4Foam location path -export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib-highOrder +export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib/solids4foam-ib-2412/ echo "SOLIDS4FOAM_DIR = $SOLIDS4FOAM_DIR" # Compile the analyticalPlateHole library -(cd analyticalPlateHole && ./Allwmake -j -s) +(cd src && ./Allwmake -j -s) # Define configurations as space-separated strings configs=( @@ -22,15 +22,15 @@ configs=( #"BASE=base/segregated NAME=hex.seg USE_TET=0 USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0" #"BASE=base/segregated NAME=tet.struct.seg GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0" #"BASE=base/segregated NAME=tet.unstruct.seg GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0" - #"BASE=base/highOrder NAME=hex.ho.N1 USE_TET=0 USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true" - #"BASE=base/highOrder NAME=hex.ho.N2 USE_TET=0 USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true" - #"BASE=base/highOrder NAME=hex.ho.N3 USE_TET=0 USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=20 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.unstruct.ho.N1 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.unstruct.ho.N2 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.unstruct.ho.N3 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true" - #"BASE=base/highOrder NAME=tet.struct.ho.N1 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true" - #"BASE=base/highOrder NAME=tet.struct.ho.N2 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true" - #"BASE=base/highOrder NAME=tet.struct.ho.N3 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true" + #"BASE=base/highOrder NAME=hex.ho.N1 USE_TET=0 USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=movingLeastSquares" + #"BASE=base/highOrder NAME=hex.ho.N2 USE_TET=0 USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=movingLeastSquares" + #"BASE=base/highOrder NAME=hex.ho.N3 USE_TET=0 USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=20 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N1 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N2 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N3 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N1 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N2 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N3 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=movingLeastSquares" ) # Define start and end mesh indices @@ -68,7 +68,7 @@ cd "${RUN_DIR}" for config in "${configs[@]}" do # Reset variables in the case some variable is not used - unset GMSH_FILE PETSC_FILE N Nn + unset GMSH_FILE PETSC_FILE N Nn TYPE # Parse the configuration string eval $config @@ -132,6 +132,11 @@ do sed -i "/^\s*faceStencilExtraCells /s|^.*| faceStencilExtraCells ${extraCells};|" constant/solidProperties fi + # Update the least squares type + if [ -n "${TYPE}" ]; then + sed -i "/^\s*type \(movingLeastSquares\|kExactLeastSquares\);/s|^.*| type ${TYPE};|" constant/solidProperties + fi + # Update how Jacobian is calculated if [ -n "${HOJAC}" ]; then sed -i "/^\s*highOrderJacobian /s|^.*| highOrderJacobian ${HOJAC};|" constant/solidProperties diff --git a/papers/JFNK_highOrder/linearElastic/plateHole/Allrun.conditioning b/papers/JFNK_highOrder/linearElastic/plateHole/Allrun.conditioning index 81b59e53..8b862c96 100755 --- a/papers/JFNK_highOrder/linearElastic/plateHole/Allrun.conditioning +++ b/papers/JFNK_highOrder/linearElastic/plateHole/Allrun.conditioning @@ -5,7 +5,9 @@ source solids4FoamScripts.sh # Extend version not supported solids4Foam::caseDoesNotRunWithFoamExtend -solids4Foam::caseDoesNotRunWithOpenFOAMOrg + +# Compile the src library +(cd src && ./Allwmake -j -s) # Define configurations as space-separated strings configs=( @@ -116,12 +118,12 @@ do sed -i "/^\s*Nn /s|^.*| Nn ${Nn};|" constant/solidProperties fi - # Update how Jacobian is calculated + # Update how Jacobian is calculated if [ -n "${HOJAC}" ]; then sed -i "/^\s*highOrderJacobian /s|^.*| highOrderJacobian ${HOJAC};|" constant/solidProperties fi - # Update how Residual is calculated + # Update how Residual is calculated if [ -n "${HORES}" ]; then sed -i "/^\s*highOrderResidual /s|^.*| highOrderResidual ${HORES};|" constant/solidProperties fi diff --git a/papers/JFNK_highOrder/linearElastic/plateHole/Allrun.kExact b/papers/JFNK_highOrder/linearElastic/plateHole/Allrun.kExact new file mode 100755 index 00000000..5734979e --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/plateHole/Allrun.kExact @@ -0,0 +1,231 @@ +#!/bin/bash + +# Source required functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions +source solids4FoamScripts.sh +# Extend version not supported +solids4Foam::caseDoesNotRunWithFoamExtend + +# solids4Foam location path +export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib/solids4foam-ib-2412/ +echo "SOLIDS4FOAM_DIR = $SOLIDS4FOAM_DIR" + +# Compile the analyticalPlateHole library +(cd src && ./Allwmake -j -s) + +# Define configurations as space-separated strings +configs=( + #"BASE=base/snes NAME=hex.struct.hypre-snes GMSH_FILE=hex-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 PETSC_FILE=petscOptions.lu" + #"BASE=base/snes NAME=tet.struct.hypre-snes GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 PETSC_FILE=petscOptions.lu" + #"BASE=base/snes NAME=poly.hypre-snes GMSH_FILE=tet-structured USE_DUALMESH=1 USE_PERTURBMESHPOINTS=0 PETSC_FILE=petscOptions.lu" + #"BASE=base/snes NAME=tet.unstruct.hypre-snes GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 PETSC_FILE=petscOptions.lu" + #"BASE=base/segregated NAME=hex.seg USE_TET=0 USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0" + #"BASE=base/segregated NAME=tet.struct.seg GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0" + #"BASE=base/segregated NAME=tet.unstruct.seg GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0" + #"BASE=base/highOrder NAME=hex.ho.N1 USE_TET=0 USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=kExactLeastSquares" + #"BASE=base/highOrder NAME=hex.ho.N2 USE_TET=0 USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=kExactLeastSquares" + #"BASE=base/highOrder NAME=hex.ho.N3 USE_TET=0 USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=20 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N1 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N2 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N3 GMSH_FILE=tet-unstructured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N1 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N2 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.struct.ho.N3 GMSH_FILE=tet-structured USE_DUALMESH=0 USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 PETSC_FILE=petscOptions.lu HOJAC=false HORES=true TYPE=kExactLeastSquares" +) + +# Define start and end mesh indices +# Mesh input files are defined from 1 to 6 +# END_MESH should be greater than START_MESH +START_MESH=1 +END_MESH=5 + + +# Detect the CPU type: we append this to the case name +if [[ "$OSTYPE" == "darwin"* ]] +then + # macOS + CPU_TYPE=$(sysctl -n machdep.cpu.brand_string | sed 's/[^a-zA-Z0-9]/_/g') +elif [[ -f /proc/cpuinfo ]] +then + # Linux + CPU_TYPE=$(grep -m 1 "model name" /proc/cpuinfo | awk -F': ' '{print $2}' | sed 's/[^a-zA-Z0-9]/_/g') +else + # Fallback if neither method works + CPU_TYPE="Unknown_CPU" +fi + + +# Create timestamped working directory for this run +DATE=$(date +%Y-%m-%d_%H-%M-%S) +RUN_DIR="run_${CPU_TYPE}_${DATE}" +echo "Creating ${RUN_DIR}" +mkdir "${RUN_DIR}" + +# Enter the run directory +cd "${RUN_DIR}" + +# Iterate through configurations +for config in "${configs[@]}" +do + # Reset variables in the case some variable is not used + unset GMSH_FILE PETSC_FILE N Nn TYPE + + # Parse the configuration string + eval $config + echo; echo "***************************************" + echo "Running configuration: $config" + echo "***************************************" + + # Define results summary file name + SUMMARY="${NAME}.summary.txt" + echo "# Mesh Time Mem CellsNumber D_L2 D_Linf S_L2 S_Linf" > "${SUMMARY}" + + # Loop over mesh densities in each configuration + for i in `seq $START_MESH $END_MESH` + do + CASE="${NAME}.$i" + echo; echo "Processing case: $CASE" + + # Prepare the case + cp -rL "../${BASE}" "${CASE}" + cd "$CASE" + + # Create mesh + if [[ "$GMSH_FILE" == "tet-structured" || "$GMSH_FILE" == "tet-unstructured" ]] + then + if command -v gmsh &>/dev/null; then + # GMSH Mesh generation + cp "gmsh/meshSpacing/meshSpacing$i.geo" "gmsh/meshSpacing/meshSpacing.geo" + solids4Foam::runApplication gmsh -3 -format msh2 gmsh/"${GMSH_FILE}.geo" + solids4Foam::runApplication gmshToFoam gmsh/"${GMSH_FILE}.msh" + solids4Foam::runApplication changeDictionary + if [ "$USE_DUALMESH" -eq 1 ]; then + solids4Foam::runApplication polyDualMesh 30 -overwrite + solids4Foam::runApplication combinePatchFaces 45 -overwrite + fi + fi + else + cp "system/blockMeshDict.$i" "system/blockMeshDict" + solids4Foam::runApplication blockMesh + fi + + # Optional mesh distortion + if [ "$USE_PERTURBMESHPOINTS" -eq 1 ] + then + solids4Foam::runApplication perturbMeshPoints + mv 0/polyMesh/* constant/polyMesh/. + fi + solids4Foam::runApplication checkMesh + + # Update the PETSc options file + if [ -n "${PETSC_FILE}" ]; then + sed -i "/^\s*optionsFile /s|^.*| optionsFile ${PETSC_FILE};|" constant/solidProperties + fi + + # Update the order + if [ -n "${polyOrder}" ]; then + sed -i "/^\s*polynomialOrder /s|^.*| polynomialOrder ${polyOrder};|" constant/solidProperties + fi + + # Update number of stencil cells + if [ -n "${extraCells}" ]; then + sed -i "/^\s*faceStencilExtraCells /s|^.*| faceStencilExtraCells ${extraCells};|" constant/solidProperties + fi + + # Update the least squares type + if [ -n "${TYPE}" ]; then + sed -i "/^\s*type \(movingLeastSquares\|kExactLeastSquares\);/s|^.*| type ${TYPE};|" constant/solidProperties + fi + + # Update how Jacobian is calculated + if [ -n "${HOJAC}" ]; then + sed -i "/^\s*highOrderJacobian /s|^.*| highOrderJacobian ${HOJAC};|" constant/solidProperties + fi + + # Update how Residual is calculated + if [ -n "${HORES}" ]; then + sed -i "/^\s*highOrderResidual /s|^.*| highOrderResidual ${HORES};|" constant/solidProperties + fi + + # Run the solver + # If "gtime" is available (could be called "time" on Linux), use it to + # record the max memory usage + if command -v gtime &> /dev/null + then + echo "Running solids4Foam on ${CASE} with gtime" + gtime -f "gtime/time (wall clock) time: %e\nMaximum resident set size (kbytes): %M" solids4Foam &> log.solids4Foam + + elif [ -x /usr/bin/time ] + then + echo "Running solids4Foam on ${CASE} with /usr/bin/time" + /usr/bin/time -f "gtime/time (wall clock) time: %e\nMaximum resident set size (kbytes): %M" solids4Foam &> log.solids4Foam + + elif command -v time &> /dev/null + then + echo "Running solids4Foam on ${CASE} with shell builtin time (no max memory)" + time solids4Foam &> log.solids4Foam + + else + echo "Running solids4Foam on ${CASE}" + solids4Foam::runApplication solids4Foam + fi + + # Extract results from solver log and append them to a summary file + echo; echo "Appending results to ${SUMMARY}" + if grep -q "gtime/time" log.solids4Foam; then + CLOCK_TIME=$(grep "gtime/time" log.solids4Foam | awk '{print $5}') + else + # Record the time + CLOCK_TIME=$(grep "ClockTime" log.solids4Foam | awk '{print $7}') + fi + + # Extract results from solver log and append them to a summary file + if grep -q "Maximum resident" log.solids4Foam; then + MAX_MEMORY=$(grep "Maximum resident" log.solids4Foam | awk '{print int($6 / 1000)}') + else + MAX_MEMORY="NaN" + fi + + # Number of cells + CELLS=$(grep "cells:" log.checkMesh | awk '{print $2}') + + # Extract the L2 (average) error for displacement + DISP_L2_ERROR=$(grep "Writing DDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $2}') + + # Extract the LInfinity (max) error for displacement + DISP_LINF_ERROR=$(grep "Writing DDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $3}') + + # Extract the L2 (average) error for mag(sigma) + STRESS_L2_ERROR=$(grep "Writing sigmaDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $3}') + + # Extract the LInfinity (max) error for mag(sigma) + STRESS_LINF_ERROR=$(grep "Writing sigmaDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $4}') + + # Write data to file + echo "$i $CLOCK_TIME $MAX_MEMORY $CELLS $DISP_L2_ERROR $DISP_LINF_ERROR $STRESS_L2_ERROR $STRESS_LINF_ERROR" >> ../"${SUMMARY}" + + cd .. + done + + # Print summary file + echo; echo "${SUMMARY} file:"; cat "${SUMMARY}"; echo +done + +# Create plots if gnuplot in installed +if command -v gnuplot &>/dev/null +then + # Copy gnuplot scripts + cp ../plotScripts/*gnuplot . + + # Run all scripts + for f in *gnuplot + do + echo "Running gnuplot on $f" + gnuplot "$f" 2>/dev/null + done +fi + +echo; echo; echo "Done!"; echo +echo "View the PDF files in ${RUN_DIR}" +echo; echo $(date) +echo; echo diff --git a/papers/JFNK_highOrder/linearElastic/plateHole/analyticalPlateHole/Make/options b/papers/JFNK_highOrder/linearElastic/plateHole/analyticalPlateHole/Make/options deleted file mode 100644 index c5b1801e..00000000 --- a/papers/JFNK_highOrder/linearElastic/plateHole/analyticalPlateHole/Make/options +++ /dev/null @@ -1,12 +0,0 @@ -sinclude $(SOLIDS4FOAM_DIR)/etc/wmake-options -sinclude $(SOLIDS4FOAM_DIR)/../etc/wmake-options - -EXE_INC = \ - $(VERSION_SPECIFIC_INC) \ - -I$(SOLIDS4FOAM_DIR)/src/solids4FoamModels/lnInclude \ - -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude - -LIB_LIBS = \ - -lfiniteVolume \ - -lmeshTools diff --git a/papers/JFNK_highOrder/linearElastic/plateHole/base/highOrder/constant/solidProperties b/papers/JFNK_highOrder/linearElastic/plateHole/base/highOrder/constant/solidProperties index 47170483..5f0e64db 100644 --- a/papers/JFNK_highOrder/linearElastic/plateHole/base/highOrder/constant/solidProperties +++ b/papers/JFNK_highOrder/linearElastic/plateHole/base/highOrder/constant/solidProperties @@ -33,6 +33,7 @@ linearGeometryTotalDisplacementCoeffs displacement { + type movingLeastSquares; polynomialOrder 2; faceStencilExtraCells 10; diff --git a/papers/JFNK_highOrder/linearElastic/plateHole/comparisonPlotScripts/dispErrors_movingVskExact.gnuplot b/papers/JFNK_highOrder/linearElastic/plateHole/comparisonPlotScripts/dispErrors_movingVskExact.gnuplot new file mode 100644 index 00000000..fc69e3ff --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/plateHole/comparisonPlotScripts/dispErrors_movingVskExact.gnuplot @@ -0,0 +1,106 @@ +set term pdfcairo dashed enhanced size 3.25,2 + +set datafile separator " " + +if (ARGC < 1) { + print "Usage: gnuplot -c dispErrors_movingVskExact.gnuplot " + exit +} + +movingResults = ARG1 +movingFile(fileName) = sprintf("%s/%s", movingResults, fileName) + +area = 3.803650459 + +set grid +set xrange [5:200] +set yrange [1e-8:1] +set xtics +set xtics add (5, 25, 50) +set ytics +set logscale x +set logscale y +set format y "10^{%L}" +#set ytics 0.002 +set xlabel "Average cell edge (in mm)" +set ylabel "Error (in μm)" +set key right bottom outside; +set rmargin 16 +set key spacing 1.2 + +# Polynomial guide lines (no title) +set style line 1 lc rgb "red" lt 2 lw 2 dt 2 +set style line 2 lc rgb "blue" lt 2 lw 2 dt 2 +set style line 3 lc rgb "violet" lt 2 lw 2 dt 2 + +# Data lines for each p-order (with titles) +set style line 11 lc rgb "red" pt 7 ps 0.5 lw 1 +set style line 12 lc rgb "red" pt 6 ps 0.5 lw 1 +set style line 21 lc rgb "blue" pt 5 ps 0.5 lw 1 +set style line 22 lc rgb "blue" pt 4 ps 0.5 lw 1 +set style line 31 lc rgb "violet" pt 9 ps 0.5 lw 1 +set style line 32 lc rgb "violet" pt 8 ps 0.5 lw 1 + +# Moving-least-squares data use the same colours with 50% transparency +set style line 111 lc rgb "#B3ff0000" pt 7 ps 0.5 lw 1 +set style line 112 lc rgb "#B3ff0000" pt 6 ps 0.5 lw 1 +set style line 121 lc rgb "#B30000ff" pt 5 ps 0.5 lw 1 +set style line 122 lc rgb "#B30000ff" pt 4 ps 0.5 lw 1 +set style line 131 lc rgb "#B3ee82ee" pt 9 ps 0.5 lw 1 +set style line 132 lc rgb "#B3ee82ee" pt 8 ps 0.5 lw 1 + +set output "plateHole_dispErrors_hex_movingVskExact.pdf" +#set title "Hexahedral structured mesh" +plot \ + (4e-6 * x**2) w l ls 1 title "2^{nd} order",\ + (2e-8 * x**3) w l ls 2 title "3^{rd} order",\ + (8e-11 * x**4) w l ls 3 title "4^{th} order",\ + "hex.struct.ho.N1.summary.txt" u ((area/$4)**0.5*1e3):($5*1e6) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "hex.struct.ho.N1.summary.txt" u ((area/$4)**0.5*1e3):($5*1e6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "hex.struct.ho.N2.summary.txt" u ((area/$4)**0.5*1e3):($5*1e6) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "hex.struct.ho.N2.summary.txt" u ((area/$4)**0.5*1e3):($6*1e6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "hex.struct.ho.N3.summary.txt" u ((area/$4)**0.5*1e3):($5*1e6) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "hex.struct.ho.N3.summary.txt" u ((area/$4)**0.5*1e3):($6*1e6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)" , \ + movingFile("hex.struct.ho.N1.summary.txt") u ((area/$4)**0.5*1e3):($5*1e6) w lp ls 111 notitle , \ + movingFile("hex.struct.ho.N1.summary.txt") u ((area/$4)**0.5*1e3):($5*1e6) w lp ls 112 notitle , \ + movingFile("hex.struct.ho.N2.summary.txt") u ((area/$4)**0.5*1e3):($5*1e6) w lp ls 121 notitle , \ + movingFile("hex.struct.ho.N2.summary.txt") u ((area/$4)**0.5*1e3):($6*1e6) w lp ls 122 notitle , \ + movingFile("hex.struct.ho.N3.summary.txt") u ((area/$4)**0.5*1e3):($5*1e6) w lp ls 131 notitle , \ + movingFile("hex.struct.ho.N3.summary.txt") u ((area/$4)**0.5*1e3):($6*1e6) w lp ls 132 notitle + + +set output "plateHole_dispErrors_tet-struct_movingVskExact.pdf" +plot \ + (4e-6 * x**2) w l ls 1 title "2^{nd} order",\ + (2e-8 * x**3) w l ls 2 title "3^{rd} order",\ + (8e-11 * x**4) w l ls 3 title "4^{th} order",\ + "tet.struct.ho.N1.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.struct.ho.N1.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.struct.ho.N2.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.struct.ho.N2.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "tet.struct.ho.N3.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "tet.struct.ho.N3.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)" , \ + movingFile("tet.struct.ho.N1.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 111 notitle , \ + movingFile("tet.struct.ho.N1.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 112 notitle , \ + movingFile("tet.struct.ho.N2.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 121 notitle , \ + movingFile("tet.struct.ho.N2.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 122 notitle , \ + movingFile("tet.struct.ho.N3.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 131 notitle , \ + movingFile("tet.struct.ho.N3.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 132 notitle + +set output "plateHole_dispErrors_tet-unstruct_movingVskExact.pdf" +plot \ + (4e-6 * x**2) w l ls 1 title "2^{nd} order",\ + (2e-8 * x**3) w l ls 2 title "3^{rd} order",\ + (8e-11 * x**4) w l ls 3 title "4^{th} order",\ + "tet.unstruct.ho.N1.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct.ho.N1.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct.ho.N2.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct.ho.N2.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct.ho.N3.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "tet.unstruct.ho.N3.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)" , \ + movingFile("tet.unstruct.ho.N1.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 111 notitle , \ + movingFile("tet.unstruct.ho.N1.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 112 notitle , \ + movingFile("tet.unstruct.ho.N2.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 121 notitle , \ + movingFile("tet.unstruct.ho.N2.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 122 notitle , \ + movingFile("tet.unstruct.ho.N3.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 131 notitle , \ + movingFile("tet.unstruct.ho.N3.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 132 notitle \ No newline at end of file diff --git a/papers/JFNK_highOrder/linearElastic/plateHole/comparisonPlotScripts/stressErrors_movingVskExact.gnuplot b/papers/JFNK_highOrder/linearElastic/plateHole/comparisonPlotScripts/stressErrors_movingVskExact.gnuplot new file mode 100644 index 00000000..e41d12ad --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/plateHole/comparisonPlotScripts/stressErrors_movingVskExact.gnuplot @@ -0,0 +1,106 @@ +set term pdfcairo dashed enhanced size 3.25,2 +set datafile separator " " + +if (ARGC < 1) { + print "Usage: gnuplot -c stressErrors_movingVskExact.gnuplot " + exit +} + +movingResults = ARG1 +movingFile(fileName) = sprintf("%s/%s", movingResults, fileName) + +area= 3.803650459 + +set grid +set xrange [4:130] +set yrange [1e-8:0.1] +set xtics +set xtics add (5, 25, 50) +set ytics +set logscale x +set logscale y +set format y "10^{%L}" +#set ytics 0.002 +set xlabel "Average cell edge (in mm)" +set ylabel "Error (in MPa)" +set key right bottom outside; +set rmargin 16 +set key spacing 1.2 + +# Polynomial guide lines (no title) +set style line 1 lc rgb "red" lt 2 lw 2 dt 2 +set style line 2 lc rgb "blue" lt 2 lw 2 dt 2 +set style line 3 lc rgb "violet" lt 2 lw 2 dt 2 + +# Data lines for each p-order (with titles) +set style line 11 lc rgb "red" pt 7 ps 0.5 lw 1 +set style line 12 lc rgb "red" pt 6 ps 0.5 lw 1 +set style line 21 lc rgb "blue" pt 5 ps 0.5 lw 1 +set style line 22 lc rgb "blue" pt 4 ps 0.5 lw 1 +set style line 31 lc rgb "violet" pt 9 ps 0.5 lw 1 +set style line 32 lc rgb "violet" pt 8 ps 0.5 lw 1 + +# Moving-least-squares data use the same colours with 50% transparency +set style line 111 lc rgb "#B3ff0000" pt 7 ps 0.5 lw 1 +set style line 112 lc rgb "#B3ff0000" pt 6 ps 0.5 lw 1 +set style line 121 lc rgb "#B30000ff" pt 5 ps 0.5 lw 1 +set style line 122 lc rgb "#B30000ff" pt 4 ps 0.5 lw 1 +set style line 131 lc rgb "#B3ee82ee" pt 9 ps 0.5 lw 1 +set style line 132 lc rgb "#B3ee82ee" pt 8 ps 0.5 lw 1 + + +set output "plateHole_stressErrors_hex_movingVskExact.pdf" +plot \ + (2e-4 * x**1) w l ls 1 title "1^{st} order", \ + (1e-6 * x**2) w l ls 2 title "2^{nd} order", \ + (5e-9 * x**3) w l ls 3 title "3^{rd} order", \ + "hex.struct.ho.N1.summary.txt" u ((area/$4)**0.5*1e3):($5*1e6) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "hex.struct.ho.N1.summary.txt" u ((area/$4)**0.5*1e3):($6*1e6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "hex.struct.ho.N2.summary.txt" u ((area/$4)**0.5*1e3):($5*1e6) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "hex.struct.ho.N2.summary.txt" u ((area/$4)**0.5*1e3):($6*1e6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "hex.struct.ho.N3.summary.txt" u ((area/$4)**0.5*1e3):($5*1e6) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "hex.struct.ho.N3.summary.txt" u ((area/$4)**0.5*1e3):($6*1e6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)" , \ + movingFile("hex.struct.ho.N1.summary.txt") u ((area/$4)**0.5*1e3):($5*1e6) w lp ls 111 notitle , \ + movingFile("hex.struct.ho.N1.summary.txt") u ((area/$4)**0.5*1e3):($6*1e6) w lp ls 112 notitle , \ + movingFile("hex.struct.ho.N2.summary.txt") u ((area/$4)**0.5*1e3):($5*1e6) w lp ls 121 notitle , \ + movingFile("hex.struct.ho.N2.summary.txt") u ((area/$4)**0.5*1e3):($6*1e6) w lp ls 122 notitle , \ + movingFile("hex.struct.ho.N3.summary.txt") u ((area/$4)**0.5*1e3):($5*1e6) w lp ls 131 notitle , \ + movingFile("hex.struct.ho.N3.summary.txt") u ((area/$4)**0.5*1e3):($6*1e6) w lp ls 132 notitle + + +set output "plateHole_stressErrors_tet-unstruct_movingVskExact.pdf" +plot \ + (2e-4 * x**1) w l ls 1 title "1^{st} order", \ + (0.4e-6 * x**2) w l ls 2 title "2^{nd} order", \ + (0.4e-9 * x**3) w l ls 3 title "3^{rd} order", \ + "tet.unstruct.ho.N1.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct.ho.N1.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct.ho.N2.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct.ho.N2.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct.ho.N3.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "tet.unstruct.ho.N3.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)" , \ + movingFile("tet.unstruct.ho.N1.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 111 notitle , \ + movingFile("tet.unstruct.ho.N1.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 112 notitle , \ + movingFile("tet.unstruct.ho.N2.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 121 notitle , \ + movingFile("tet.unstruct.ho.N2.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 122 notitle , \ + movingFile("tet.unstruct.ho.N3.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 131 notitle , \ + movingFile("tet.unstruct.ho.N3.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 132 notitle + + +set output "plateHole_stressErrors_tet-struct_movingVskExact.pdf" +plot \ + (2e-4 * x**1) w l ls 1 title "1^{st} order", \ + (1e-6 * x**2) w l ls 2 title "2^{nd} order", \ + (5e-9 * x**3) w l ls 3 title "3^{rd} order", \ + "tet.struct.ho.N1.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.struct.ho.N1.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.struct.ho.N2.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.struct.ho.N2.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "tet.struct.ho.N3.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "tet.struct.ho.N3.summary.txt" u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)" , \ + movingFile("tet.struct.ho.N1.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 111 notitle , \ + movingFile("tet.struct.ho.N1.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 112 notitle , \ + movingFile("tet.struct.ho.N2.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 121 notitle , \ + movingFile("tet.struct.ho.N2.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 122 notitle , \ + movingFile("tet.struct.ho.N3.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($5*1e6) w lp ls 131 notitle , \ + movingFile("tet.struct.ho.N3.summary.txt") u ((4*(area/$4)/3**0.5)**0.5*1e3):($6*1e6) w lp ls 132 notitle diff --git a/papers/JFNK_highOrder/linearElastic/plateHole/analyticalPlateHole/Allwmake b/papers/JFNK_highOrder/linearElastic/plateHole/src/Allwmake similarity index 100% rename from papers/JFNK_highOrder/linearElastic/plateHole/analyticalPlateHole/Allwmake rename to papers/JFNK_highOrder/linearElastic/plateHole/src/Allwmake diff --git a/papers/JFNK_highOrder/linearElastic/plateHole/analyticalPlateHole/Make/files b/papers/JFNK_highOrder/linearElastic/plateHole/src/Make/files similarity index 53% rename from papers/JFNK_highOrder/linearElastic/plateHole/analyticalPlateHole/Make/files rename to papers/JFNK_highOrder/linearElastic/plateHole/src/Make/files index 02d9700e..9538b6cd 100644 --- a/papers/JFNK_highOrder/linearElastic/plateHole/analyticalPlateHole/Make/files +++ b/papers/JFNK_highOrder/linearElastic/plateHole/src/Make/files @@ -1,3 +1,5 @@ +plateHoleAnalyticalFields.C +analyticalPlateHoleTractionFvPatchVectorField.C analyticalPlateHoleFunctionObject.C LIB = $(FOAM_USER_LIBBIN)/libanalyticalPlateHole diff --git a/papers/JFNK_highOrder/linearElastic/plateHole/src/Make/options b/papers/JFNK_highOrder/linearElastic/plateHole/src/Make/options new file mode 100644 index 00000000..03973818 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/plateHole/src/Make/options @@ -0,0 +1,27 @@ +sinclude $(SOLIDS4FOAM_DIR)/etc/wmake-options +sinclude $(SOLIDS4FOAM_DIR)/../etc/wmake-options + +EXE_INC = \ + -std=c++14 \ + -Wno-old-style-cast -Wno-deprecated-declarations \ + $(VERSION_SPECIFIC_INC) \ + -I$(SOLIDS4FOAM_DIR)/ThirdParty/eigen3 \ + -I$(SOLIDS4FOAM_DIR)/src/blockCoupledSolids4FoamTools/lnInclude \ + -I$(SOLIDS4FOAM_DIR)/src/solids4FoamModels/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/dynamicFvMesh/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/topoChangerFvMesh/lnInclude \ + -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +LIB_LIBS = \ + -lfiniteVolume \ + -ldynamicFvMesh \ + -ldynamicMesh \ + -lmeshTools \ + -ltopoChangerFvMesh \ + -L$(FOAM_USER_LIBBIN) \ + -lsolids4FoamModels \ + -lblockCoupledSolids4FoamTools diff --git a/papers/JFNK_highOrder/linearElastic/plateHole/analyticalPlateHole/analyticalPlateHoleFunctionObject.C b/papers/JFNK_highOrder/linearElastic/plateHole/src/analyticalPlateHoleFunctionObject.C similarity index 85% rename from papers/JFNK_highOrder/linearElastic/plateHole/analyticalPlateHole/analyticalPlateHoleFunctionObject.C rename to papers/JFNK_highOrder/linearElastic/plateHole/src/analyticalPlateHoleFunctionObject.C index 9bc11ac5..1af73660 100644 --- a/papers/JFNK_highOrder/linearElastic/plateHole/analyticalPlateHole/analyticalPlateHoleFunctionObject.C +++ b/papers/JFNK_highOrder/linearElastic/plateHole/src/analyticalPlateHoleFunctionObject.C @@ -22,6 +22,7 @@ License #include "volFields.H" #include "pointFields.H" #include "coordinateSystem.H" +#include "lookupSolidModel.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -121,6 +122,81 @@ Foam::vector Foam::analyticalPlateHole::plateHoleDisplacement ); } + +void Foam::analyticalPlateHole::calculateAnalyticalCellDisplacement +( + const fvMesh& mesh, + vectorField& analyticalD +) +{ + const solidModel& solMod = lookupSolidModel(mesh); + bool useCellAverage = false; + + if (solMod.highOrderResidual()) + { + const dictionary& displacementDict = + solMod.solidModelDict() + .subDict("highOrderCoeffs") + .subDict("displacement"); + useCellAverage = + displacementDict.lookupOrDefault + ( + "type", + "movingLeastSquares" + ) == "kExactLeastSquares"; + } + + if (useCellAverage) + { + const fvMeshQuadrature& quadrature = + solMod.displacementLeastSquares().quadrature(); + const CompactListList& cellQuadPoints = + quadrature.cellQuadPoints(); + const CompactListList& cellQuadWeights = + quadrature.cellQuadWeights(); + const scalarField& cellVolumes = mesh.V(); + + Info<< "Using cell-average analytical displacement" << endl; + + forAll(analyticalD, cellI) + { + analyticalD[cellI] = vector::zero; + + forAll(cellQuadPoints[cellI], pointI) + { + const point& quadPoint = cellQuadPoints[cellI][pointI]; + + analyticalD[cellI] += + cellQuadWeights[cellI][pointI] + *plateHoleDisplacement + ( + quadPoint, + plateHoleStress(quadPoint) + ); + } + + analyticalD[cellI] /= cellVolumes[cellI]; + } + } + else + { + Info<< "Using point-valued analytical displacement" << endl; + + const vectorField& cellCentres = mesh.C().internalField(); + + forAll(analyticalD, cellI) + { + analyticalD[cellI] = + plateHoleDisplacement + ( + cellCentres[cellI], + plateHoleStress(cellCentres[cellI]) + ); + } + } +} + + bool Foam::analyticalPlateHole::writeData() { // Lookup the solid mesh @@ -197,10 +273,11 @@ bool Foam::analyticalPlateHole::writeData() sI[cellI] = plateHoleStress(CI[cellI]); } - if (cellDisplacement_) - { - aDI[cellI] = plateHoleDisplacement(CI[cellI], sI[cellI]); - } + } + + if (cellDisplacement_) + { + calculateAnalyticalCellDisplacement(mesh, aDI); } forAll(analyticalStress.boundaryField(), patchI) diff --git a/papers/JFNK_highOrder/linearElastic/plateHole/analyticalPlateHole/analyticalPlateHoleFunctionObject.H b/papers/JFNK_highOrder/linearElastic/plateHole/src/analyticalPlateHoleFunctionObject.H similarity index 94% rename from papers/JFNK_highOrder/linearElastic/plateHole/analyticalPlateHole/analyticalPlateHoleFunctionObject.H rename to papers/JFNK_highOrder/linearElastic/plateHole/src/analyticalPlateHoleFunctionObject.H index f64d112b..e22d26af 100644 --- a/papers/JFNK_highOrder/linearElastic/plateHole/analyticalPlateHole/analyticalPlateHoleFunctionObject.H +++ b/papers/JFNK_highOrder/linearElastic/plateHole/src/analyticalPlateHoleFunctionObject.H @@ -101,6 +101,14 @@ class analyticalPlateHole //- Analytical displacement solution vector plateHoleDisplacement(const vector& C, const symmTensor& sigma); + //- Calculate analytical cell displacement using the selected + // reconstruction semantics + void calculateAnalyticalCellDisplacement + ( + const fvMesh& mesh, + vectorField& analyticalD + ); + //- Write data bool writeData(); diff --git a/papers/JFNK_highOrder/linearElastic/plateHole/src/analyticalPlateHoleTractionFvPatchVectorField.C b/papers/JFNK_highOrder/linearElastic/plateHole/src/analyticalPlateHoleTractionFvPatchVectorField.C new file mode 100644 index 00000000..cca5abcb --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/plateHole/src/analyticalPlateHoleTractionFvPatchVectorField.C @@ -0,0 +1,258 @@ +/*---------------------------------------------------------------------------*\ +License + This file is part of solids4foam. + + solids4foam is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + solids4foam is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solids4foam. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "analyticalPlateHoleTractionFvPatchVectorField.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" +#include "mechanicalModel.H" +#include "volFields.H" +#include "fvc.H" +#include "fixedValueFvPatchFields.H" +#include "lookupSolidModel.H" +#include "plateHoleAnalyticalFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * Private Member Functions * * * * * * * * * * * * * * // + +symmTensor analyticalPlateHoleTractionFvPatchVectorField::plateHoleSolution +( + const vector& C +) const +{ + return plateHoleAnalyticalFields::stress(C, T_, holeR_); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +analyticalPlateHoleTractionFvPatchVectorField:: +analyticalPlateHoleTractionFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF +) +: + solidTractionFvPatchVectorField(p, iF), + T_(0.0), + holeR_(0.0) +{} + + +analyticalPlateHoleTractionFvPatchVectorField:: +analyticalPlateHoleTractionFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + solidTractionFvPatchVectorField(p, iF), + T_(readScalar(dict.lookup("farFieldTractionX"))), + holeR_(readScalar(dict.lookup("holeRadius"))) +{} + + +analyticalPlateHoleTractionFvPatchVectorField:: +analyticalPlateHoleTractionFvPatchVectorField +( + const analyticalPlateHoleTractionFvPatchVectorField& stpvf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + solidTractionFvPatchVectorField(stpvf, p, iF, mapper), + T_(stpvf.T_), + holeR_(stpvf.holeR_) +{} + +#ifndef OPENFOAM_ORG +analyticalPlateHoleTractionFvPatchVectorField:: +analyticalPlateHoleTractionFvPatchVectorField +( + const analyticalPlateHoleTractionFvPatchVectorField& stpvf +) +: + solidTractionFvPatchVectorField(stpvf), + T_(stpvf.T_), + holeR_(stpvf.holeR_) +{} +#endif + +analyticalPlateHoleTractionFvPatchVectorField:: +analyticalPlateHoleTractionFvPatchVectorField +( + const analyticalPlateHoleTractionFvPatchVectorField& stpvf, + const DimensionedField& iF +) +: + solidTractionFvPatchVectorField(stpvf, iF), + T_(stpvf.T_), + holeR_(stpvf.holeR_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void analyticalPlateHoleTractionFvPatchVectorField::autoMap +( + const fvPatchFieldMapper& m +) +{ + solidTractionFvPatchVectorField::autoMap(m); +} + + +// Reverse-map the given fvPatchField onto this fvPatchField +void analyticalPlateHoleTractionFvPatchVectorField::rmap +( + const fvPatchVectorField& ptf, + const labelList& addr +) +{ + solidTractionFvPatchVectorField::rmap(ptf, addr); +} + + +// Update the coefficients associated with the patch field +void analyticalPlateHoleTractionFvPatchVectorField::updateCoeffs() +{ + if (updated()) + { + return; + } + + // Patch unit normals + vectorField n(patch().nf()); + + // Patch face centres + const vectorField& Cf = patch().Cf(); + + // Set the patch traction + + vectorField& trac = traction(); + + forAll(traction(), faceI) + { + vector curC(Cf[faceI].x(), Cf[faceI].y(), 0); + vector curN = n[faceI]; + + if (patch().name() == "hole") + { + curC /= mag(curC); + curC *= holeR_; + + curN = -curC/mag(curC); + } + + trac[faceI] = + plateHoleAnalyticalFields::traction(curC, curN, T_, holeR_); + } + + solidTractionFvPatchVectorField::updateCoeffs(); +} + +#ifndef FOAMEXTEND +autoPtr> +analyticalPlateHoleTractionFvPatchVectorField::evaluateQuadrature() const +{ + const fvMesh& mesh = patch().boundaryMesh().mesh(); + const solidModel& solMod = lookupSolidModel(mesh); + + // faceQuadPoints is list for the whole mesh + const CompactListList& faceQuadPoints = + solMod.displacementLeastSquares().quadrature().faceQuadPoints(); + + labelList nQpPerFace(this->size(), 0); + const label start = this->patch().start(); + forAll(nQpPerFace, faceI) + { + const label globalFaceID = faceI + start; + nQpPerFace[faceI]=faceQuadPoints[globalFaceID].size(); + } + + autoPtr> tQuadPointsValue + ( + new CompactListList(nQpPerFace) + ); + + // Get a reference to the actual data for easier access + CompactListList& quadPointsValue = tQuadPointsValue(); + + // Patch unit normals + vectorField n(patch().nf()); + + forAll(*this, faceI) + { + const label globalFaceID = faceI + start; + + // Get the number of quadrature points for this face + const label nPoints = faceQuadPoints[globalFaceID].size(); + + // Assign the same value to all quadrature points on this face + // We assume constant distribution of traction! + for (label pointI = 0; pointI < nPoints; ++pointI) + { + const point quadPoint = faceQuadPoints[globalFaceID][pointI]; + quadPointsValue[faceI][pointI] = + plateHoleAnalyticalFields::traction + ( + quadPoint, + n[faceI], + T_, + holeR_ + ); + } + } + + return tQuadPointsValue; +} +#endif + + +// Write +void analyticalPlateHoleTractionFvPatchVectorField::write(Ostream& os) const +{ + solidTractionFvPatchVectorField::write(os); + + os.writeKeyword("farFieldTractionX") + << T_ << token::END_STATEMENT << nl; + + os.writeKeyword("holeRadius") + << holeR_ << token::END_STATEMENT << nl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchVectorField, + analyticalPlateHoleTractionFvPatchVectorField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/papers/JFNK_highOrder/linearElastic/plateHole/src/analyticalPlateHoleTractionFvPatchVectorField.H b/papers/JFNK_highOrder/linearElastic/plateHole/src/analyticalPlateHoleTractionFvPatchVectorField.H new file mode 100644 index 00000000..dee1471b --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/plateHole/src/analyticalPlateHoleTractionFvPatchVectorField.H @@ -0,0 +1,185 @@ +/*---------------------------------------------------------------------------*\ +License + This file is part of solids4foam. + + solids4foam is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + solids4foam is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solids4foam. If not, see . + +Class + analyticalPlateHoleTractionFvPatchVectorField + +Description + Traction boundary condition for plateHole test case to enforce + analytical traction at the boundaries + +Author + Philip Cardiff, UCD. + Zeljko Tukovic, Zagreb. + +SourceFiles + analyticalPlateHoleTractionFvPatchVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef analyticalPlateHoleTractionFvPatchVectorField_H +#define analyticalPlateHoleTractionFvPatchVectorField_H + +#include "fvPatchFields.H" +#include "solidTractionFvPatchVectorField.H" +#include "Switch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class analyticalPlateHoleTractionFvPatchVectorField Declaration +\*---------------------------------------------------------------------------*/ + +class analyticalPlateHoleTractionFvPatchVectorField +: + public solidTractionFvPatchVectorField +{ +private: + + // Private Data + + //- Far field traction + // It is assumed that it acts in the positive X direction + const scalar T_; + + //- Hole radius + const scalar holeR_; + + + // Private Member Functions + + //- Analytical solution + symmTensor plateHoleSolution(const vector& C) const; + + +public: + + //- Runtime type information + TypeName("analyticalPlateHoleTraction"); + + + // Constructors + + //- Construct from patch and internal field + analyticalPlateHoleTractionFvPatchVectorField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + analyticalPlateHoleTractionFvPatchVectorField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // analyticalPlateHoleTractionFvPatchVectorField onto a new patch + analyticalPlateHoleTractionFvPatchVectorField + ( + const analyticalPlateHoleTractionFvPatchVectorField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + analyticalPlateHoleTractionFvPatchVectorField + ( + const analyticalPlateHoleTractionFvPatchVectorField& +#ifdef OPENFOAM_ORG + ) = delete; +#else + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new analyticalPlateHoleTractionFvPatchVectorField(*this) + ); + } +#endif + + //- Construct as copy setting internal field reference + analyticalPlateHoleTractionFvPatchVectorField + ( + const analyticalPlateHoleTractionFvPatchVectorField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new analyticalPlateHoleTractionFvPatchVectorField(*this, iF) + ); + } + + + // Member functions + +#ifndef FOAMEXTEND + //- Return face quadrature values + // Used for high order solvers, argument is position of points + virtual autoPtr> + evaluateQuadrature() const; +#endif + + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchVectorField&, + const labelList& + ); + + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/papers/JFNK_highOrder/linearElastic/plateHole/src/plateHoleAnalyticalFields.C b/papers/JFNK_highOrder/linearElastic/plateHole/src/plateHoleAnalyticalFields.C new file mode 100644 index 00000000..1b93b5e0 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/plateHole/src/plateHoleAnalyticalFields.C @@ -0,0 +1,142 @@ +/*---------------------------------------------------------------------------*\ +License + This file is part of solids4foam. + + solids4foam is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + solids4foam is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solids4foam. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "plateHoleAnalyticalFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::symmTensor Foam::plateHoleAnalyticalFields::stress +( + const vector& C, + const scalar farFieldTractionX, + const scalar holeRadius +) +{ + symmTensor sigma = symmTensor::zero; + + const scalar r = ::sqrt(sqr(C.x()) + sqr(C.y())); + const scalar theta = atan2(C.y(), C.x()); + + sigma.xx() = + farFieldTractionX + *( + 1.0 + - (sqr(holeRadius)/sqr(r))*(3*cos(2*theta)/2 + cos(4*theta)) + + (3*pow(holeRadius, 4)/(2*pow(r, 4)))*cos(4*theta) + ); + + sigma.yy() = + farFieldTractionX + *( + - (sqr(holeRadius)/sqr(r))*(cos(2*theta)/2 - cos(4*theta)) + - (3*pow(holeRadius, 4)/(2*pow(r, 4)))*cos(4*theta) + ); + + sigma.xy() = + farFieldTractionX + *( + - (sqr(holeRadius)/sqr(r))*(sin(2*theta)/2 + sin(4*theta)) + + (3*pow(holeRadius, 4)/(2*pow(r, 4)))*sin(4*theta) + ); + + return sigma; +} + + +Foam::vector Foam::plateHoleAnalyticalFields::displacement +( + const vector& C, + const scalar farFieldTractionX, + const scalar holeRadius, + const scalar mu, + const scalar kappa +) +{ + const scalar r = ::sqrt(sqr(C.x()) + sqr(C.y())); + const scalar theta = atan2(C.y(), C.x()); + + return vector + ( + (holeRadius*farFieldTractionX/(8*mu)) + *( + (r/holeRadius)*(kappa + 1)*cos(theta) + + (2*holeRadius/r)*((1 + kappa)*cos(theta) + cos(3*theta)) + - (2*pow(holeRadius, 3)/pow(r, 3))*cos(3*theta) + ), + (holeRadius*farFieldTractionX/(8*mu)) + *( + (r/holeRadius)*(kappa - 3)*sin(theta) + + (2*holeRadius/r)*((1 - kappa)*sin(theta) + sin(3*theta)) + - (2*pow(holeRadius, 3)/pow(r, 3))*sin(3*theta) + ), + 0.0 + ); +} + + +Foam::vector Foam::plateHoleAnalyticalFields::displacement +( + const vector& C, + const scalar farFieldTractionX, + const scalar holeRadius, + const scalar E, + const scalar nu, + const bool planeStress +) +{ + const scalar mu = E/(2*(1 + nu)); + scalar kappa = 3 - 4*nu; + + if (planeStress) + { + kappa = (3.0 - nu)/(1.0 + nu); + } + + return displacement(C, farFieldTractionX, holeRadius, mu, kappa); +} + + +Foam::scalar Foam::plateHoleAnalyticalFields::hydPressure +( + const vector& C, + const scalar farFieldTractionX, + const scalar holeRadius, + const scalar nu +) +{ + const symmTensor sigma = stress(C, farFieldTractionX, holeRadius); + const scalar sigmaZZ = nu*(sigma.xx() + sigma.yy()); + + return -(sigma.xx() + sigma.yy() + sigmaZZ)/3; +} + + +Foam::vector Foam::plateHoleAnalyticalFields::traction +( + const vector& C, + const vector& n, + const scalar farFieldTractionX, + const scalar holeRadius +) +{ + return n & stress(C, farFieldTractionX, holeRadius); +} + + +// ************************************************************************* // diff --git a/papers/JFNK_highOrder/linearElastic/plateHole/src/plateHoleAnalyticalFields.H b/papers/JFNK_highOrder/linearElastic/plateHole/src/plateHoleAnalyticalFields.H new file mode 100644 index 00000000..39541112 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/plateHole/src/plateHoleAnalyticalFields.H @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------------*\ +License + This file is part of solids4foam. + + solids4foam is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + solids4foam is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solids4foam. If not, see . + +Class + plateHoleAnalyticalFields + +Description + Shared Kirsch analytical stress, displacement, pressure and traction + helpers for the plate-hole tutorials. + +SourceFiles + plateHoleAnalyticalFields.C + +\*---------------------------------------------------------------------------*/ + +#ifndef plateHoleAnalyticalFields_H +#define plateHoleAnalyticalFields_H + +#include "scalar.H" +#include "symmTensor.H" +#include "vector.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class plateHoleAnalyticalFields Declaration +\*---------------------------------------------------------------------------*/ + +class plateHoleAnalyticalFields +{ +public: + + //- Analytical stress field + static symmTensor stress + ( + const vector& C, + const scalar farFieldTractionX, + const scalar holeRadius + ); + + //- Analytical displacement field + static vector displacement + ( + const vector& C, + const scalar farFieldTractionX, + const scalar holeRadius, + const scalar mu, + const scalar kappa + ); + + //- Analytical displacement field from E and nu + static vector displacement + ( + const vector& C, + const scalar farFieldTractionX, + const scalar holeRadius, + const scalar E, + const scalar nu, + const bool planeStress + ); + + //- Hydrostatic pressure from the analytical stress state + static scalar hydPressure + ( + const vector& C, + const scalar farFieldTractionX, + const scalar holeRadius, + const scalar nu + ); + + //- Analytical traction + static vector traction + ( + const vector& C, + const vector& n, + const scalar farFieldTractionX, + const scalar holeRadius + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/Allrun b/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/Allrun index 76231059..ab8c45b3 100755 --- a/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/Allrun +++ b/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/Allrun @@ -6,20 +6,24 @@ source solids4FoamScripts.sh # Extend version not supported solids4Foam::caseDoesNotRunWithFoamExtend +# solids4foam location path +export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib/solids4foam-ib-2412/ +echo "SOLIDS4FOAM_DIR = $SOLIDS4FOAM_DIR" + # Compile the cantileverBeam library -(cd analyticalPressurisedCylinder && ./Allwmake -j -s) +(cd src && ./Allwmake -j -s) # Define configurations as space-separated strings configs=( #"BASE=base/snes NAME=hex.struct.hypre-snes GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 PETSC_FILE=petscOptions.lu" #"BASE=base/segregated NAME=hex.struct.seg GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0" "BASE=base/segregated NAME=tet.unstruct.seg GMSH_FILE=tet-unstructured USE_PERTURBMESHPOINTS=0" - #"BASE=base/highOrder NAME=hex.struct.ho.N1 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.snes HOJAC=false HORES=true" - #"BASE=base/highOrder NAME=hex.struct.ho.N2 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.snes HOJAC=false HORES=true" - #"BASE=base/highOrder NAME=hex.struct.ho.N3 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=20 PETSC_FILE=petscOptions.snes HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.unstruct.ho.N1 GMSH_FILE=tet-unstructured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.snes HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.unstruct.ho.N2 GMSH_FILE=tet-unstructured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.snes HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.unstruct.ho.N3 GMSH_FILE=tet-unstructured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 PETSC_FILE=petscOptions.snes HOJAC=false HORES=true" + #"BASE=base/highOrder NAME=hex.struct.ho.N1 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.snes HOJAC=false HORES=true TYPE=movingLeastSquares" + #"BASE=base/highOrder NAME=hex.struct.ho.N2 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.snes HOJAC=false HORES=true TYPE=movingLeastSquares" + #"BASE=base/highOrder NAME=hex.struct.ho.N3 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=20 PETSC_FILE=petscOptions.snes HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N1 GMSH_FILE=tet-unstructured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.snes HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N2 GMSH_FILE=tet-unstructured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.snes HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N3 GMSH_FILE=tet-unstructured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 PETSC_FILE=petscOptions.snes HOJAC=false HORES=true TYPE=movingLeastSquares" ) # Define start and end mesh indices @@ -56,6 +60,9 @@ cd "${RUN_DIR}" # Iterate through configurations for config in "${configs[@]}" do + # Reset variables in case a variable is not used + unset GMSH_FILE PETSC_FILE polyOrder extraCells HOJAC HORES TYPE + # Parse the configuration string eval $config echo; echo "***************************************" @@ -104,6 +111,11 @@ do sed -i "/^\s*faceStencilExtraCells /s|^.*| faceStencilExtraCells ${extraCells};|" constant/solidProperties fi + # Update the least squares type + if [ -n "${TYPE}" ]; then + sed -i "/^\s*type \(movingLeastSquares\|kExactLeastSquares\);/s|^.*| type ${TYPE};|" constant/solidProperties + fi + # Update how Jacobian is calculated if [ -n "${HOJAC}" ]; then sed -i "/^\s*highOrderJacobian /s|^.*| highOrderJacobian ${HOJAC};|" constant/solidProperties diff --git a/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/Allrun.kExact b/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/Allrun.kExact new file mode 100755 index 00000000..824ef33d --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/Allrun.kExact @@ -0,0 +1,211 @@ +#!/bin/bash + +# Source required functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions +source solids4FoamScripts.sh +# Extend version not supported +solids4Foam::caseDoesNotRunWithFoamExtend + +# solids4foam location path +export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib/solids4foam-ib-2412/ +echo "SOLIDS4FOAM_DIR = $SOLIDS4FOAM_DIR" + +# Compile the cantileverBeam library +(cd src && ./Allwmake -j -s) + +# Define configurations as space-separated strings +configs=( + #"BASE=base/snes NAME=hex.struct.hypre-snes GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 PETSC_FILE=petscOptions.lu" + #"BASE=base/segregated NAME=hex.struct.seg GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0" + "BASE=base/segregated NAME=tet.unstruct.seg GMSH_FILE=tet-unstructured USE_PERTURBMESHPOINTS=0" + #"BASE=base/highOrder NAME=hex.struct.ho.N1 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.snes HOJAC=false HORES=true TYPE=kExactLeastSquares" + #"BASE=base/highOrder NAME=hex.struct.ho.N2 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.snes HOJAC=false HORES=true TYPE=kExactLeastSquares" + #"BASE=base/highOrder NAME=hex.struct.ho.N3 GMSH_FILE=hex-structured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=20 PETSC_FILE=petscOptions.snes HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N1 GMSH_FILE=tet-unstructured USE_PERTURBMESHPOINTS=0 polyOrder=1 extraCells=10 PETSC_FILE=petscOptions.snes HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N2 GMSH_FILE=tet-unstructured USE_PERTURBMESHPOINTS=0 polyOrder=2 extraCells=10 PETSC_FILE=petscOptions.snes HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N3 GMSH_FILE=tet-unstructured USE_PERTURBMESHPOINTS=0 polyOrder=3 extraCells=10 PETSC_FILE=petscOptions.snes HOJAC=false HORES=true TYPE=kExactLeastSquares" +) + +# Define start and end mesh indices +# Mesh input files are defined from 1 to 6 +# END_MESH should be greater than START_MESH +START_MESH=1 +END_MESH=6 + + +# Detect the CPU type: we append this to the case name +if [[ "$OSTYPE" == "darwin"* ]] +then + # macOS + CPU_TYPE=$(sysctl -n machdep.cpu.brand_string | sed 's/[^a-zA-Z0-9]/_/g') +elif [[ -f /proc/cpuinfo ]] +then + # Linux + CPU_TYPE=$(grep -m 1 "model name" /proc/cpuinfo | awk -F': ' '{print $2}' | sed 's/[^a-zA-Z0-9]/_/g') +else + # Fallback if neither method works + CPU_TYPE="Unknown_CPU" +fi + + +# Create timestamped working directory for this run +DATE=$(date +%Y-%m-%d_%H-%M-%S) +RUN_DIR="run_${CPU_TYPE}_${DATE}" +echo "Creating ${RUN_DIR}" +mkdir "${RUN_DIR}" + +# Enter the run directory +cd "${RUN_DIR}" + +# Iterate through configurations +for config in "${configs[@]}" +do + # Reset variables in case a variable is not used + unset GMSH_FILE PETSC_FILE polyOrder extraCells HOJAC HORES TYPE + + # Parse the configuration string + eval $config + echo; echo "***************************************" + echo "Running configuration: $config" + echo "***************************************" + + # Define results summary file name + SUMMARY="${NAME}.summary.txt" + echo "# Mesh Time Mem CellsNumber D_L2 D_Linf S_L2 S_Linf" > "${SUMMARY}" + + # Loop over mesh densities in each configuration + for i in `seq $START_MESH $END_MESH` + do + CASE="${NAME}.$i" + echo; echo "Processing case: $CASE" + + # Prepare the case + cp -rL "../${BASE}" "${CASE}" + cd "$CASE" + + # GMSH Mesh generation + cp "gmsh/meshSpacing/meshSpacing$i.geo" "gmsh/meshSpacing/meshSpacing.geo" + solids4Foam::runApplication gmsh -3 -format msh2 gmsh/"${GMSH_FILE}.geo" + solids4Foam::runApplication gmshToFoam gmsh/"${GMSH_FILE}.msh" + solids4Foam::runApplication changeDictionary + + # Optional mesh distortion + if [ "$USE_PERTURBMESHPOINTS" -eq 1 ] + then + solids4Foam::runApplication perturbMeshPoints + fi + solids4Foam::runApplication checkMesh + + # Update the PETSc options file + if [ -n "${PETSC_FILE}" ]; then + sed -i "/^\s*optionsFile /s|^.*| optionsFile ${PETSC_FILE};|" constant/solidProperties + fi + + # Update the order + if [ -n "${polyOrder}" ]; then + sed -i "/^\s*polynomialOrder /s|^.*| polynomialOrder ${polyOrder};|" constant/solidProperties + fi + + # Update number of stencil cells + if [ -n "${extraCells}" ]; then + sed -i "/^\s*faceStencilExtraCells /s|^.*| faceStencilExtraCells ${extraCells};|" constant/solidProperties + fi + + # Update the least squares type + if [ -n "${TYPE}" ]; then + sed -i "/^\s*type \(movingLeastSquares\|kExactLeastSquares\);/s|^.*| type ${TYPE};|" constant/solidProperties + fi + + # Update how Jacobian is calculated + if [ -n "${HOJAC}" ]; then + sed -i "/^\s*highOrderJacobian /s|^.*| highOrderJacobian ${HOJAC};|" constant/solidProperties + fi + + # Update how Residual is calculated + if [ -n "${HORES}" ]; then + sed -i "/^\s*highOrderResidual /s|^.*| highOrderResidual ${HORES};|" constant/solidProperties + fi + + # Run the solver + # If "gtime" is available (could be called "time" on Linux), use it to + # record the max memory usage + if command -v gtime &> /dev/null + then + echo "Running solids4Foam on ${CASE} with gtime" + gtime -f "gtime/time (wall clock) time: %e\nMaximum resident set size (kbytes): %M" solids4Foam &> log.solids4Foam + + elif [ -x /usr/bin/time ] + then + echo "Running solids4Foam on ${CASE} with /usr/bin/time" + /usr/bin/time -f "gtime/time (wall clock) time: %e\nMaximum resident set size (kbytes): %M" solids4Foam &> log.solids4Foam + + elif command -v time &> /dev/null + then + echo "Running solids4Foam on ${CASE} with shell builtin time (no max memory)" + time solids4Foam &> log.solids4Foam + + else + echo "Running solids4Foam on ${CASE}" + solids4Foam::runApplication solids4Foam + fi + + # Extract results from solver log and append them to a summary file + echo; echo "Appending results to ${SUMMARY}" + if grep -q "gtime/time" log.solids4Foam; then + CLOCK_TIME=$(grep "gtime/time" log.solids4Foam | awk '{print $5}') + else + # Record the time + CLOCK_TIME=$(grep "ClockTime" log.solids4Foam | awk '{print $7}') + fi + + # Extract results from solver log and append them to a summary file + if grep -q "Maximum resident" log.solids4Foam; then + MAX_MEMORY=$(grep "Maximum resident" log.solids4Foam | awk '{print int($6 / 1000)}') + else + MAX_MEMORY="NaN" + fi + + # Number of cells + CELLS=$(grep "cells:" log.checkMesh | awk '{print $2}') + + # Extract the L2 (average) error for displacement + DISP_L2_ERROR=$(grep "Writing DDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $2}') + + # Extract the LInfinity (max) error for displacement + DISP_LINF_ERROR=$(grep "Writing DDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $3}') + + # Extract the L2 (average) error for mag(sigma) + STRESS_L2_ERROR=$(grep "Writing sigmaDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $3}') + + # Extract the LInfinity (max) error for mag(sigma) + STRESS_LINF_ERROR=$(grep "Writing sigmaDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $4}') + + # Write data to file + echo "$i $CLOCK_TIME $MAX_MEMORY $CELLS $DISP_L2_ERROR $DISP_LINF_ERROR $STRESS_L2_ERROR $STRESS_LINF_ERROR" >> ../"${SUMMARY}" + + cd .. + done + + # Print summary file + echo; echo "${SUMMARY} file:"; cat "${SUMMARY}"; echo + +done + +# Create plots if gnuplot in installed +if command -v gnuplot &>/dev/null +then + # Copy gnuplot scripts + cp ../plotScripts/*gnuplot . + + # Run all scripts + for f in *gnuplot + do + echo "Running gnuplot on $f" + gnuplot "$f" 2>/dev/null + done +fi + +echo; echo; echo "Done!"; echo +echo "View the PDF files in ${RUN_DIR}" +echo; echo $(date) +echo; echo diff --git a/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/analyticalPressurisedCylinder/Make/options b/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/analyticalPressurisedCylinder/Make/options deleted file mode 100644 index c5b1801e..00000000 --- a/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/analyticalPressurisedCylinder/Make/options +++ /dev/null @@ -1,12 +0,0 @@ -sinclude $(SOLIDS4FOAM_DIR)/etc/wmake-options -sinclude $(SOLIDS4FOAM_DIR)/../etc/wmake-options - -EXE_INC = \ - $(VERSION_SPECIFIC_INC) \ - -I$(SOLIDS4FOAM_DIR)/src/solids4FoamModels/lnInclude \ - -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude - -LIB_LIBS = \ - -lfiniteVolume \ - -lmeshTools diff --git a/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/base/highOrder/constant/solidProperties b/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/base/highOrder/constant/solidProperties index 47170483..5f0e64db 100644 --- a/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/base/highOrder/constant/solidProperties +++ b/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/base/highOrder/constant/solidProperties @@ -33,6 +33,7 @@ linearGeometryTotalDisplacementCoeffs displacement { + type movingLeastSquares; polynomialOrder 2; faceStencilExtraCells 10; diff --git a/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/comparisonPlotScripts/dispErrors_movingVskExact.gnuplot b/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/comparisonPlotScripts/dispErrors_movingVskExact.gnuplot new file mode 100644 index 00000000..2a2e21b2 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/comparisonPlotScripts/dispErrors_movingVskExact.gnuplot @@ -0,0 +1,87 @@ +set term pdfcairo dashed enhanced size 3.25,2 + +set datafile separator " " + +if (ARGC < 1) { + print "Usage: gnuplot -c dispErrors_movingVskExact.gnuplot " + exit +} + +movingResults = ARG1 +movingFile(fileName) = sprintf("%s/%s", movingResults, fileName) + +area = 233.9627498 + +set grid +set xrange [0.05:3] +set yrange [1e-11:1e-3] +set xtics +set xtics add (0.1, 1, 2) +set ytics +set key r bottom +set logscale x +set logscale y +set format y "10^{%L}" +#set ytics 0.002 +set xlabel "Average cell edge (in m)" +set ylabel "Error (in m)" +set key right bottom outside; +set rmargin 16 +set key spacing 1.2 + +# Polynomial guide lines (no title) +set style line 1 lc rgb "red" lt 2 lw 2 dt 2 +set style line 2 lc rgb "blue" lt 2 lw 2 dt 2 +set style line 3 lc rgb "violet" lt 2 lw 2 dt 2 + +# Data lines for each p-order (with titles) +set style line 11 lc rgb "red" pt 7 ps 0.5 lw 1 +set style line 12 lc rgb "red" pt 6 ps 0.5 lw 1 +set style line 21 lc rgb "blue" pt 5 ps 0.5 lw 1 +set style line 22 lc rgb "blue" pt 4 ps 0.5 lw 1 +set style line 31 lc rgb "violet" pt 9 ps 0.5 lw 1 +set style line 32 lc rgb "violet" pt 8 ps 0.5 lw 1 + +# Moving-least-squares data use the same colours with 50% transparency +set style line 111 lc rgb "#B3ff0000" pt 7 ps 0.5 lw 1 +set style line 112 lc rgb "#B3ff0000" pt 6 ps 0.5 lw 1 +set style line 121 lc rgb "#B30000ff" pt 5 ps 0.5 lw 1 +set style line 122 lc rgb "#B30000ff" pt 4 ps 0.5 lw 1 +set style line 131 lc rgb "#B3ee82ee" pt 9 ps 0.5 lw 1 +set style line 132 lc rgb "#B3ee82ee" pt 8 ps 0.5 lw 1 + +set output "pressurisedCylinder-dispErrors_hex_movingVskExact.pdf" +plot \ + (2e-5 * x**2) w l ls 1 title "2^{nd} order", \ + (4e-6 * x**3) w l ls 2 title "3^{rd} order", \ + (6e-7 * x**4) w l ls 3 title "4^{th} order", \ + "hex.struct.ho.N1.summary.txt" u ((area/$4)**0.5):($5) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "hex.struct.ho.N1.summary.txt" u ((area/$4)**0.5):($6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "hex.struct.ho.N2.summary.txt" u ((area/$4)**0.5):($5) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "hex.struct.ho.N2.summary.txt" u ((area/$4)**0.5):($6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "hex.struct.ho.N3.summary.txt" u ((area/$4)**0.5):($5) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "hex.struct.ho.N3.summary.txt" u ((area/$4)**0.5):($6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)" , \ + movingFile("hex.struct.ho.N1.summary.txt") u ((area/$4)**0.5):($5) w lp ls 111 notitle , \ + movingFile("hex.struct.ho.N1.summary.txt") u ((area/$4)**0.5):($6) w lp ls 112 notitle , \ + movingFile("hex.struct.ho.N2.summary.txt") u ((area/$4)**0.5):($5) w lp ls 121 notitle , \ + movingFile("hex.struct.ho.N2.summary.txt") u ((area/$4)**0.5):($6) w lp ls 122 notitle , \ + movingFile("hex.struct.ho.N3.summary.txt") u ((area/$4)**0.5):($5) w lp ls 131 notitle , \ + movingFile("hex.struct.ho.N3.summary.txt") u ((area/$4)**0.5):($6) w lp ls 132 notitle + +set output "pressurisedCylinder-dispErrors_tet_movingVskExact.pdf" +plot \ + (2e-5 * x**2) w l ls 1 title "2^{nd} order", \ + (4e-6 * x**3) w l ls 2 title "3^{rd} order", \ + (6e-7 * x**4) w l ls 3 title "4^{th} order", \ + "tet.unstruct.ho.N1.summary.txt" u ((4*(area/$4)/3**0.5)**0.5):($5) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct.ho.N1.summary.txt" u ((4*(area/$4)/3**0.5)**0.5):($6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct.ho.N2.summary.txt" u ((4*(area/$4)/3**0.5)**0.5):($5) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct.ho.N2.summary.txt" u ((4*(area/$4)/3**0.5)**0.5):($6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct.ho.N3.summary.txt" u ((4*(area/$4)/3**0.5)**0.5):($5) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "tet.unstruct.ho.N3.summary.txt" u ((4*(area/$4)/3**0.5)**0.5):($6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)" , \ + movingFile("tet.unstruct.ho.N1.summary.txt") u ((4*(area/$4)/3**0.5)**0.5):($5) w lp ls 111 notitle , \ + movingFile("tet.unstruct.ho.N1.summary.txt") u ((4*(area/$4)/3**0.5)**0.5):($6) w lp ls 112 notitle , \ + movingFile("tet.unstruct.ho.N2.summary.txt") u ((4*(area/$4)/3**0.5)**0.5):($5) w lp ls 121 notitle , \ + movingFile("tet.unstruct.ho.N2.summary.txt") u ((4*(area/$4)/3**0.5)**0.5):($6) w lp ls 122 notitle , \ + movingFile("tet.unstruct.ho.N3.summary.txt") u ((4*(area/$4)/3**0.5)**0.5):($5) w lp ls 131 notitle , \ + movingFile("tet.unstruct.ho.N3.summary.txt") u ((4*(area/$4)/3**0.5)**0.5):($6) w lp ls 132 notitle \ No newline at end of file diff --git a/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/comparisonPlotScripts/stressErrors_movingVskExact.gnuplot b/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/comparisonPlotScripts/stressErrors_movingVskExact.gnuplot new file mode 100644 index 00000000..a5c8abb7 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/comparisonPlotScripts/stressErrors_movingVskExact.gnuplot @@ -0,0 +1,87 @@ +set term pdfcairo dashed enhanced size 3.25,2 + +set datafile separator " " + +if (ARGC < 1) { + print "Usage: gnuplot -c dispErrors_movingVskExact.gnuplot " + exit +} + +movingResults = ARG1 +movingFile(fileName) = sprintf("%s/%s", movingResults, fileName) + +area = 233.9627498 + +set grid +set xrange [0.05:3] +set yrange [1e-11:1e-3] +set xtics +set xtics add (0.1, 1, 2) +set ytics +set key r bottom +set logscale x +set logscale y +set format y "10^{%L}" +#set ytics 0.002 +set xlabel "Average cell edge (in m)" +set ylabel "Error (in m)" +set key right bottom outside; +set rmargin 16 +set key spacing 1.2 + +# Polynomial guide lines (no title) +set style line 1 lc rgb "red" lt 2 lw 2 dt 2 +set style line 2 lc rgb "blue" lt 2 lw 2 dt 2 +set style line 3 lc rgb "violet" lt 2 lw 2 dt 2 + +# Data lines for each p-order (with titles) +set style line 11 lc rgb "red" pt 7 ps 0.5 lw 1 +set style line 12 lc rgb "red" pt 6 ps 0.5 lw 1 +set style line 21 lc rgb "blue" pt 5 ps 0.5 lw 1 +set style line 22 lc rgb "blue" pt 4 ps 0.5 lw 1 +set style line 31 lc rgb "violet" pt 9 ps 0.5 lw 1 +set style line 32 lc rgb "violet" pt 8 ps 0.5 lw 1 + +# Moving-least-squares data use the same colours with 50% transparency +set style line 111 lc rgb "#B3ff0000" pt 7 ps 0.5 lw 1 +set style line 112 lc rgb "#B3ff0000" pt 6 ps 0.5 lw 1 +set style line 121 lc rgb "#B30000ff" pt 5 ps 0.5 lw 1 +set style line 122 lc rgb "#B30000ff" pt 4 ps 0.5 lw 1 +set style line 131 lc rgb "#B3ee82ee" pt 9 ps 0.5 lw 1 +set style line 132 lc rgb "#B3ee82ee" pt 8 ps 0.5 lw 1 + +set output "pressurisedCylinder-stressErrors_hex_movingVskExact.pdf" +plot \ + (2e-5 * x**2) w l ls 1 title "2^{nd} order", \ + (4e-6 * x**3) w l ls 2 title "3^{rd} order", \ + (6e-7 * x**4) w l ls 3 title "4^{th} order", \ + "hex.struct.ho.N1.summary.txt" u ((area/$4)**0.5):($5) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "hex.struct.ho.N1.summary.txt" u ((area/$4)**0.5):($6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "hex.struct.ho.N2.summary.txt" u ((area/$4)**0.5):($5) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "hex.struct.ho.N2.summary.txt" u ((area/$4)**0.5):($6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "hex.struct.ho.N3.summary.txt" u ((area/$4)**0.5):($5) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "hex.struct.ho.N3.summary.txt" u ((area/$4)**0.5):($6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)" , \ + movingFile("hex.struct.ho.N1.summary.txt") u ((area/$4)**0.5):($5) w lp ls 111 notitle , \ + movingFile("hex.struct.ho.N1.summary.txt") u ((area/$4)**0.5):($6) w lp ls 112 notitle , \ + movingFile("hex.struct.ho.N2.summary.txt") u ((area/$4)**0.5):($5) w lp ls 121 notitle , \ + movingFile("hex.struct.ho.N2.summary.txt") u ((area/$4)**0.5):($6) w lp ls 122 notitle , \ + movingFile("hex.struct.ho.N3.summary.txt") u ((area/$4)**0.5):($5) w lp ls 131 notitle , \ + movingFile("hex.struct.ho.N3.summary.txt") u ((area/$4)**0.5):($6) w lp ls 132 notitle + +set output "pressurisedCylinder-stressErrors_tet_movingVskExact.pdf" +plot \ + (2e-5 * x**2) w l ls 1 title "2^{nd} order", \ + (4e-6 * x**3) w l ls 2 title "3^{rd} order", \ + (6e-7 * x**4) w l ls 3 title "4^{th} order", \ + "tet.unstruct.ho.N1.summary.txt" u ((4*(area/$4)/3**0.5)**0.5):($5) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct.ho.N1.summary.txt" u ((4*(area/$4)/3**0.5)**0.5):($6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct.ho.N2.summary.txt" u ((4*(area/$4)/3**0.5)**0.5):($5) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct.ho.N2.summary.txt" u ((4*(area/$4)/3**0.5)**0.5):($6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct.ho.N3.summary.txt" u ((4*(area/$4)/3**0.5)**0.5):($5) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "tet.unstruct.ho.N3.summary.txt" u ((4*(area/$4)/3**0.5)**0.5):($6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)" , \ + movingFile("tet.unstruct.ho.N1.summary.txt") u ((4*(area/$4)/3**0.5)**0.5):($5) w lp ls 111 notitle , \ + movingFile("tet.unstruct.ho.N1.summary.txt") u ((4*(area/$4)/3**0.5)**0.5):($6) w lp ls 112 notitle , \ + movingFile("tet.unstruct.ho.N2.summary.txt") u ((4*(area/$4)/3**0.5)**0.5):($5) w lp ls 121 notitle , \ + movingFile("tet.unstruct.ho.N2.summary.txt") u ((4*(area/$4)/3**0.5)**0.5):($6) w lp ls 122 notitle , \ + movingFile("tet.unstruct.ho.N3.summary.txt") u ((4*(area/$4)/3**0.5)**0.5):($5) w lp ls 131 notitle , \ + movingFile("tet.unstruct.ho.N3.summary.txt") u ((4*(area/$4)/3**0.5)**0.5):($6) w lp ls 132 notitle \ No newline at end of file diff --git a/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/analyticalPressurisedCylinder/Allwmake b/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/src/Allwmake similarity index 100% rename from papers/JFNK_highOrder/linearElastic/pressurisedCylinder/analyticalPressurisedCylinder/Allwmake rename to papers/JFNK_highOrder/linearElastic/pressurisedCylinder/src/Allwmake diff --git a/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/analyticalPressurisedCylinder/Make/files b/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/src/Make/files similarity index 100% rename from papers/JFNK_highOrder/linearElastic/pressurisedCylinder/analyticalPressurisedCylinder/Make/files rename to papers/JFNK_highOrder/linearElastic/pressurisedCylinder/src/Make/files diff --git a/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/src/Make/options b/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/src/Make/options new file mode 100644 index 00000000..03973818 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/src/Make/options @@ -0,0 +1,27 @@ +sinclude $(SOLIDS4FOAM_DIR)/etc/wmake-options +sinclude $(SOLIDS4FOAM_DIR)/../etc/wmake-options + +EXE_INC = \ + -std=c++14 \ + -Wno-old-style-cast -Wno-deprecated-declarations \ + $(VERSION_SPECIFIC_INC) \ + -I$(SOLIDS4FOAM_DIR)/ThirdParty/eigen3 \ + -I$(SOLIDS4FOAM_DIR)/src/blockCoupledSolids4FoamTools/lnInclude \ + -I$(SOLIDS4FOAM_DIR)/src/solids4FoamModels/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/dynamicFvMesh/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/topoChangerFvMesh/lnInclude \ + -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +LIB_LIBS = \ + -lfiniteVolume \ + -ldynamicFvMesh \ + -ldynamicMesh \ + -lmeshTools \ + -ltopoChangerFvMesh \ + -L$(FOAM_USER_LIBBIN) \ + -lsolids4FoamModels \ + -lblockCoupledSolids4FoamTools diff --git a/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/analyticalPressurisedCylinder/analyticalPressurisedCylinderFunctionObject.C b/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/src/analyticalPressurisedCylinderFunctionObject.C similarity index 84% rename from papers/JFNK_highOrder/linearElastic/pressurisedCylinder/analyticalPressurisedCylinder/analyticalPressurisedCylinderFunctionObject.C rename to papers/JFNK_highOrder/linearElastic/pressurisedCylinder/src/analyticalPressurisedCylinderFunctionObject.C index cf048caf..619659d9 100644 --- a/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/analyticalPressurisedCylinder/analyticalPressurisedCylinderFunctionObject.C +++ b/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/src/analyticalPressurisedCylinderFunctionObject.C @@ -22,6 +22,7 @@ License #include "volFields.H" #include "pointFields.H" #include "coordinateSystem.H" +#include "lookupSolidModel.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -96,6 +97,70 @@ stress(const Foam::vector& pos) const } +void Foam::analyticalPressurisedCylinderFunctionObject:: +calculateAnalyticalCellDisplacement +( + const fvMesh& mesh, + vectorField& analyticalD +) +{ + const solidModel& solMod = lookupSolidModel(mesh); + bool useCellAverage = false; + + if (solMod.highOrderResidual()) + { + const dictionary& displacementDict = + solMod.solidModelDict() + .subDict("highOrderCoeffs") + .subDict("displacement"); + useCellAverage = + displacementDict.lookupOrDefault + ( + "type", + "movingLeastSquares" + ) == "kExactLeastSquares"; + } + + if (useCellAverage) + { + const fvMeshQuadrature& quadrature = + solMod.displacementLeastSquares().quadrature(); + const CompactListList& cellQuadPoints = + quadrature.cellQuadPoints(); + const CompactListList& cellQuadWeights = + quadrature.cellQuadWeights(); + const scalarField& cellVolumes = mesh.V(); + + Info<< "Using cell-average analytical displacement" << endl; + + forAll(analyticalD, cellI) + { + analyticalD[cellI] = vector::zero; + + forAll(cellQuadPoints[cellI], pointI) + { + analyticalD[cellI] += + cellQuadWeights[cellI][pointI] + *displacement(cellQuadPoints[cellI][pointI]); + } + + analyticalD[cellI] /= cellVolumes[cellI]; + } + } + else + { + Info<< "Using point-valued analytical displacement" << endl; + + const vectorField& cellCentres = mesh.C().internalField(); + + forAll(analyticalD, cellI) + { + analyticalD[cellI] = displacement(cellCentres[cellI]); + } + } +} + + bool Foam::analyticalPressurisedCylinderFunctionObject::writeData() { // Lookup the solid mesh @@ -151,9 +216,10 @@ bool Foam::analyticalPressurisedCylinderFunctionObject::writeData() forAll(sI, cellI) { sI[cellI] = stress(CI[cellI]); - aDI[cellI] = displacement(CI[cellI]); } + calculateAnalyticalCellDisplacement(mesh, aDI); + forAll(analyticalStress.boundaryField(), patchI) { if (mesh.boundary()[patchI].type() != "empty") diff --git a/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/analyticalPressurisedCylinder/analyticalPressurisedCylinderFunctionObject.H b/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/src/analyticalPressurisedCylinderFunctionObject.H similarity index 94% rename from papers/JFNK_highOrder/linearElastic/pressurisedCylinder/analyticalPressurisedCylinder/analyticalPressurisedCylinderFunctionObject.H rename to papers/JFNK_highOrder/linearElastic/pressurisedCylinder/src/analyticalPressurisedCylinderFunctionObject.H index 2da37a01..da419db2 100644 --- a/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/analyticalPressurisedCylinder/analyticalPressurisedCylinderFunctionObject.H +++ b/papers/JFNK_highOrder/linearElastic/pressurisedCylinder/src/analyticalPressurisedCylinderFunctionObject.H @@ -100,6 +100,14 @@ class analyticalPressurisedCylinderFunctionObject //- Analytical stress for point symmTensor stress(const vector& pos) const; + //- Calculate analytical cell displacement using the selected + // reconstruction semantics + void calculateAnalyticalCellDisplacement + ( + const fvMesh& mesh, + vectorField& analyticalD + ); + //- Write data bool writeData(); diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/Allrun b/papers/JFNK_highOrder/linearElastic/sphericalCavity/Allrun index a6189d4a..940aea6c 100755 --- a/papers/JFNK_highOrder/linearElastic/sphericalCavity/Allrun +++ b/papers/JFNK_highOrder/linearElastic/sphericalCavity/Allrun @@ -6,18 +6,23 @@ source solids4FoamScripts.sh # Extend version not supported solids4Foam::caseDoesNotRunWithFoamExtend +export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib/solids4foam-ib-2412/ + +# Compile local analytical library +(cd src && ./Allwmake -s) + # Define configurations as space-separated strings configs=( #"BASE=base/snes NAME=tet.hypre PETSC_FILE=petscOptions.hypre GMSH_FILE=tet" "BASE=base/segregated NAME=tet.unstruct.seg GMSH_FILE=tet" "BASE=base/segregated NAME=poly.unstruct.seg GMSH_FILE=poly" "BASE=base/snes NAME=poly.unstruct.hypre PETSC_FILE=petscOptions.hypre GMSH_FILE=poly" - "BASE=base/highOrder NAME=tet.unstruct.ho.N1 GMSH_FILE=tet polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.unstruct.ho.N2 GMSH_FILE=tet polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - "BASE=base/highOrder NAME=tet.unstruct.ho.N3 GMSH_FILE=tet polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - "BASE=base/highOrder NAME=poly.unstruct.ho.N1 GMSH_FILE=poly polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - "BASE=base/highOrder NAME=poly.unstruct.ho.N2 GMSH_FILE=poly polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" - "BASE=base/highOrder NAME=poly.unstruct.ho.N3 GMSH_FILE=poly polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" + "BASE=base/highOrder NAME=tet.unstruct.ho.N1 GMSH_FILE=tet polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N2 GMSH_FILE=tet polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N3 GMSH_FILE=tet polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=poly.unstruct.ho.N1 GMSH_FILE=poly polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=poly.unstruct.ho.N2 GMSH_FILE=poly polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" + "BASE=base/highOrder NAME=poly.unstruct.ho.N3 GMSH_FILE=poly polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=movingLeastSquares" ) # Define start and end mesh indices @@ -60,7 +65,7 @@ cd "${RUN_DIR}" for config in "${configs[@]}" do # Reset variables in the case some variable is not used - unset GMSH_FILE PETSC_FILE order extraCells HOJAC HORES + unset GMSH_FILE PETSC_FILE order extraCells HOJAC HORES TYPE # Parse the configuration string eval $config @@ -134,6 +139,11 @@ do sed -i "/^\s*faceStencilExtraCells /s|^.*| faceStencilExtraCells ${extraCells};|" constant/solidProperties fi + # Update the least squares type + if [ -n "${TYPE}" ]; then + sed -i "/^\s*type \(movingLeastSquares\|kExactLeastSquares\);/s|^.*| type ${TYPE};|" constant/solidProperties + fi + # Update how Jacobian is calculated if [ -n "${HOJAC}" ]; then sed -i "/^\s*highOrderJacobian /s|^.*| highOrderJacobian ${HOJAC};|" constant/solidProperties diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/Allrun.jacChoice b/papers/JFNK_highOrder/linearElastic/sphericalCavity/Allrun.jacChoice index c73fd399..898acf68 100755 --- a/papers/JFNK_highOrder/linearElastic/sphericalCavity/Allrun.jacChoice +++ b/papers/JFNK_highOrder/linearElastic/sphericalCavity/Allrun.jacChoice @@ -6,6 +6,12 @@ source solids4FoamScripts.sh # Extend version not supported solids4Foam::caseDoesNotRunWithFoamExtend +SCRIPT_DIR="$(cd "${0%/*}" && pwd -P)" +export SOLIDS4FOAM_DIR="${SOLIDS4FOAM_DIR:-${SCRIPT_DIR}/../../../../../solids4foam-ib-2412}" + +# Compile local analytical library +(cd src && ./Allwmake -s) + # Define configurations as space-separated strings configs=( "BASE=base/highOrder NAME=tet.unstruct.ho.N1 GMSH_FILE=tet N=1 Nn=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true" diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/Allrun.kExact b/papers/JFNK_highOrder/linearElastic/sphericalCavity/Allrun.kExact new file mode 100755 index 00000000..eee85b2b --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/sphericalCavity/Allrun.kExact @@ -0,0 +1,239 @@ +#!/bin/bash + +# Source required functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions +source solids4FoamScripts.sh +# Extend version not supported +solids4Foam::caseDoesNotRunWithFoamExtend + +export SOLIDS4FOAM_DIR=/Users/ivanbatistic/work/solids4foam-ib/solids4foam-ib-2412/ + +# Compile local analytical library +(cd src && ./Allwmake -s) + +# Define configurations as space-separated strings +configs=( + #"BASE=base/snes NAME=tet.hypre PETSC_FILE=petscOptions.hypre GMSH_FILE=tet" + "BASE=base/segregated NAME=tet.unstruct.seg GMSH_FILE=tet" + "BASE=base/segregated NAME=poly.unstruct.seg GMSH_FILE=poly" + "BASE=base/snes NAME=poly.unstruct.hypre PETSC_FILE=petscOptions.hypre GMSH_FILE=poly" + "BASE=base/highOrder NAME=tet.unstruct.ho.N1 GMSH_FILE=tet polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N2 GMSH_FILE=tet polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=tet.unstruct.ho.N3 GMSH_FILE=tet polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=poly.unstruct.ho.N1 GMSH_FILE=poly polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=poly.unstruct.ho.N2 GMSH_FILE=poly polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=kExactLeastSquares" + "BASE=base/highOrder NAME=poly.unstruct.ho.N3 GMSH_FILE=poly polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true TYPE=kExactLeastSquares" +) + +# Define start and end mesh indices +# Mesh input files are defined from 1 to 6 +# END_MESH should be greater than START_MESH +START_MESH=1 +END_MESH=6 + +# Compile projectPoitnToSphere +cd projectPointsToSphere +wclean +wmake +cd .. + +# Detect the CPU type: we append this to the case name +if [[ "$OSTYPE" == "darwin"* ]] +then + # macOS + CPU_TYPE=$(sysctl -n machdep.cpu.brand_string | sed 's/[^a-zA-Z0-9]/_/g') +elif [[ -f /proc/cpuinfo ]] +then + # Linux + CPU_TYPE=$(grep -m 1 "model name" /proc/cpuinfo | awk -F': ' '{print $2}' | sed 's/[^a-zA-Z0-9]/_/g') +else + # Fallback if neither method works + CPU_TYPE="Unknown_CPU" +fi + + +# Create timestamped working directory for this run +DATE=$(date +%Y-%m-%d_%H-%M-%S) +RUN_DIR="run_${CPU_TYPE}_${DATE}" +echo "Creating ${RUN_DIR}" +mkdir "${RUN_DIR}" + +# Enter the run directory +cd "${RUN_DIR}" + +# Iterate through configurations +for config in "${configs[@]}" +do + # Reset variables in the case some variable is not used + unset GMSH_FILE PETSC_FILE order extraCells HOJAC HORES TYPE + + # Parse the configuration string + eval $config + echo; echo "***************************************" + echo "Running configuration: $config" + echo "***************************************" + + # Define results summary file name + SUMMARY="${NAME}.summary.txt" + echo "# Mesh Time Mem CellsNumber D_L2 D_Linf S_L2 S_Linf" > "${SUMMARY}" + + # Loop over mesh densities in each configuration + for i in `seq $START_MESH $END_MESH` + do + CASE="${NAME}.$i" + echo; echo "Processing case: $CASE" + + # Prepare the case + cp -r "../${BASE}" "${CASE}" + cd "$CASE" + + # Create the mesh + if command -v gmsh &> /dev/null + then + # Remporarily rename 0 to avoid issues + mv 0 0.tmp + + # Create mesh with gmsh + if [[ "$GMSH_FILE" == "tet" ]] + then + cp "gmsh/tet-meshSpacing/meshSpacing$i.geo" "gmsh/tet-meshSpacing/meshSpacing.geo" + solids4Foam::runApplication gmsh -3 -format msh2 gmsh/tet.geo + solids4Foam::runApplication gmshToFoam gmsh/tet.msh + fi + + if [[ "$GMSH_FILE" == "poly" ]] + then + cp "gmsh/poly-meshSpacing/meshSpacing$i.geo" "gmsh/poly-meshSpacing/meshSpacing.geo" + solids4Foam::runApplication gmsh -3 -format msh2 gmsh/poly.geo + solids4Foam::runApplication gmshToFoam gmsh/poly.msh + solids4Foam::runApplication polyDualMesh 30 -overwrite + solids4Foam::runApplication combinePatchFaces 45 -overwrite + fi + solids4Foam::runApplication changeDictionary + solids4Foam::runApplication checkMesh + + # Move 0 back + mv 0.tmp 0 + else + echo; echo "Gmsh is required to run this case: please install it" + exit 1 + fi + + # Project the cavity patch to a sphere to avoid write precision issue + solids4Foam::runApplication projectPointsToSphere cavity "(0 0 0)" 0.2 + mv 1/polyMesh/points constant/polyMesh/points + rm -rf 1/meshPhi 1/pointMotion 1/polyMesh + + # Update the PETSc options file + if [ -n "${PETSC_FILE}" ]; then + sed -i "/^\s*optionsFile /s|^.*| optionsFile ${PETSC_FILE};|" constant/solidProperties + fi + + # Update the order + if [ -n "${polyOrder}" ]; then + sed -i "/^\s*polynomialOrder /s|^.*| polynomialOrder ${polyOrder};|" constant/solidProperties + fi + + # Update number of stencil cells + if [ -n "${extraCells}" ]; then + sed -i "/^\s*faceStencilExtraCells /s|^.*| faceStencilExtraCells ${extraCells};|" constant/solidProperties + fi + + # Update the least squares type + if [ -n "${TYPE}" ]; then + sed -i "/^\s*type \(movingLeastSquares\|kExactLeastSquares\);/s|^.*| type ${TYPE};|" constant/solidProperties + fi + + # Update how Jacobian is calculated + if [ -n "${HOJAC}" ]; then + sed -i "/^\s*highOrderJacobian /s|^.*| highOrderJacobian ${HOJAC};|" constant/solidProperties + fi + + # Update how Residual is calculated + if [ -n "${HORES}" ]; then + sed -i "/^\s*highOrderResidual /s|^.*| highOrderResidual ${HORES};|" constant/solidProperties + fi + + # Run the solver + # If "gtime" is available (could be called "time" on Linux), use it to + # record the max memory usage + if command -v gtime &> /dev/null + then + echo "Running solids4Foam on ${CASE} with gtime" + gtime -f "gtime/time (wall clock) time: %e\nMaximum resident set size (kbytes): %M" solids4Foam &> log.solids4Foam + + elif [ -x /usr/bin/time ] + then + echo "Running solids4Foam on ${CASE} with /usr/bin/time" + /usr/bin/time -f "gtime/time (wall clock) time: %e\nMaximum resident set size (kbytes): %M" solids4Foam &> log.solids4Foam + + elif command -v time &> /dev/null + then + echo "Running solids4Foam on ${CASE} with shell builtin time (no max memory)" + time solids4Foam &> log.solids4Foam + + else + echo "Running solids4Foam on ${CASE}" + solids4Foam::runApplication solids4Foam + fi + + # Extract results from solver log and append them to a summary file + echo; echo "Appending results to ${SUMMARY}" + if grep -q "gtime/time" log.solids4Foam; then + CLOCK_TIME=$(grep "gtime/time" log.solids4Foam | awk '{print $5}') + else + # Record the time + CLOCK_TIME=$(grep "ClockTime" log.solids4Foam | awk '{print $7}') + fi + + # Extract results from solver log and append them to a summary file + if grep -q "Maximum resident" log.solids4Foam; then + MAX_MEMORY=$(grep "Maximum resident" log.solids4Foam | awk '{print int($6 / 1000)}') + else + MAX_MEMORY="NaN" + fi + + # Number of cells + CELLS=$(grep "cells:" log.checkMesh | awk '{print $2}') + + # Extract the L2 (average) error for displacement + DISP_L2_ERROR=$(grep "Writing DDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $2}') + + # Extract the LInfinity (max) error for displacement + DISP_LINF_ERROR=$(grep "Writing DDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $3}') + + # Extract the L2 (average) error for sigma_zz + STRESS_L2_ERROR=$(grep "Component: 5" -A 2 log.solids4Foam | tail -1 | awk '{print $2}') + + # Extract the LInfinity (max) error for sigma_zz + STRESS_LINF_ERROR=$(grep "Component: 5" -A 2 log.solids4Foam | tail -1 | awk '{print $3}') + + # Write data to file + echo "$i $CLOCK_TIME $MAX_MEMORY $CELLS $DISP_L2_ERROR $DISP_LINF_ERROR $STRESS_L2_ERROR $STRESS_LINF_ERROR" >> ../"${SUMMARY}" + + cd .. + done + + # Print summary file + echo; echo "${SUMMARY} file:"; cat "${SUMMARY}"; echo + +done + +# Create plots if gnuplot in installed +if command -v gnuplot &>/dev/null +then + # Copy gnuplot scripts + cp ../plotScripts/*gnuplot . + + # Run all scripts + for f in *gnuplot + do + echo "Running gnuplot on $f" + gnuplot "$f" 2>/dev/null + done +fi + +echo; echo; echo "Done!"; echo +echo "View the PDF files in ${RUN_DIR}" +echo; echo $(date) +echo; echo diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/Allrun.parallelScaling b/papers/JFNK_highOrder/linearElastic/sphericalCavity/Allrun.parallelScaling new file mode 100755 index 00000000..6b28e385 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/sphericalCavity/Allrun.parallelScaling @@ -0,0 +1,304 @@ +#!/bin/bash + +# Source required functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions +source solids4FoamScripts.sh +# Extend version not supported +solids4Foam::caseDoesNotRunWithFoamExtend + +SCRIPT_DIR="$(cd "${0%/*}" && pwd -P)" +export SOLIDS4FOAM_DIR="${SOLIDS4FOAM_DIR:-${SCRIPT_DIR}/../../../../../solids4foam-ib-2412}" + +# Compile local analytical library +(cd src && ./Allwmake -s) + +# Defaults can be overridden, e.g. +# MESHES="3 4 5" NP_LIST="1 2 4 8" ./Allrun.parallelScaling +MESHES="${MESHES:-4 5 6}" +NP_LIST="${NP_LIST:-1 2 4 6 8 12}" +MESH_FAMILIES="${MESH_FAMILIES:-tet}" + +set -- ${NP_LIST} +if [ "$1" -ne 1 ] +then + echo "NP_LIST must start with 1 so speedup and efficiency have a serial baseline" + exit 1 +fi + +configs=() +for meshFamily in ${MESH_FAMILIES} +do + if [[ "${meshFamily}" == "tet" ]] + then + configs+=("BASE=base/highOrder NAME=tet.unstruct.ho.N1 GMSH_FILE=tet polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true") + configs+=("BASE=base/highOrder NAME=tet.unstruct.ho.N2 GMSH_FILE=tet polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true") + configs+=("BASE=base/highOrder NAME=tet.unstruct.ho.N3 GMSH_FILE=tet polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true") + elif [[ "${meshFamily}" == "poly" ]] + then + configs+=("BASE=base/highOrder NAME=poly.unstruct.ho.N1 GMSH_FILE=poly polyOrder=1 extraCells=45 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true") + configs+=("BASE=base/highOrder NAME=poly.unstruct.ho.N2 GMSH_FILE=poly polyOrder=2 extraCells=55 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true") + configs+=("BASE=base/highOrder NAME=poly.unstruct.ho.N3 GMSH_FILE=poly polyOrder=3 extraCells=65 PETSC_FILE=petscOptions.hypre HOJAC=false HORES=true") + else + echo "Unknown mesh family: ${meshFamily}" + echo "Supported values: tet poly" + exit 1 + fi +done + +runTimed() +{ + local logFile="$1" + shift + + if command -v gtime &> /dev/null + then + gtime \ + -f "gtime/time (wall clock) time: %e\nMaximum resident set size (kbytes): %M" \ + "$@" &> "${logFile}" + return $? + elif [ -x /usr/bin/time ] && /usr/bin/time -f "%e" true &> /dev/null + then + /usr/bin/time \ + -f "gtime/time (wall clock) time: %e\nMaximum resident set size (kbytes): %M" \ + "$@" &> "${logFile}" + return $? + else + local startTime endTime status + startTime=$(date +%s) + "$@" &> "${logFile}" + status=$? + endTime=$(date +%s) + echo "gtime/time (wall clock) time: $((endTime - startTime))" >> "${logFile}" + return ${status} + fi +} + +extractOrNaN() +{ + local value="$1" + + if [ -n "${value}" ] + then + echo "${value}" + else + echo "NaN" + fi +} + +calcSpeedup() +{ + local serialTime="$1" + local currentTime="$2" + + awk -v s="${serialTime}" -v t="${currentTime}" \ + 'BEGIN { if (s > 0 && t > 0) printf "%.6g", s/t; else printf "NaN" }' +} + +calcEfficiency() +{ + local speedup="$1" + local nProc="$2" + + awk -v sp="${speedup}" -v np="${nProc}" \ + 'BEGIN { if (sp > 0 && np > 0) printf "%.6g", sp/np; else printf "NaN" }' +} + +copyCase() +{ + local source="$1" + local target="$2" + local brokenLinks + + cp -aL "${source}" "${target}" + + brokenLinks=$(find "${target}" -xtype l -print) + if [ -n "${brokenLinks}" ] + then + echo "Broken symbolic links remain in ${target}:" + echo "${brokenLinks}" + exit 1 + fi +} + +# Compile projectPointsToSphere +cd projectPointsToSphere +wclean +wmake +cd .. + +if [[ "$OSTYPE" == "darwin"* ]] +then + CPU_TYPE=$(sysctl -n machdep.cpu.brand_string | sed 's/[^a-zA-Z0-9]/_/g') +elif [[ -f /proc/cpuinfo ]] +then + CPU_TYPE=$(grep -m 1 "model name" /proc/cpuinfo | awk -F': ' '{print $2}' | sed 's/[^a-zA-Z0-9]/_/g') +else + CPU_TYPE="Unknown_CPU" +fi + +DATE=$(date +%Y-%m-%d_%H-%M-%S) +RUN_DIR="run_parallelScaling_${CPU_TYPE}_${DATE}" +echo "Creating ${RUN_DIR}" +mkdir "${RUN_DIR}" + +cd "${RUN_DIR}" + +GLOBAL_SUMMARY="parallelScaling.summary.txt" +echo "# Case Mesh Processors Time Speedup Efficiency Mem Cells D_L2 D_Linf S_L2 S_Linf Status" > "${GLOBAL_SUMMARY}" + +for config in "${configs[@]}" +do + unset GMSH_FILE PETSC_FILE polyOrder extraCells HOJAC HORES + + eval ${config} + echo; echo "***************************************" + echo "Running configuration: ${config}" + echo "Meshes: ${MESHES}" + echo "Processors: ${NP_LIST}" + echo "***************************************" + + SUMMARY="${NAME}.parallelScaling.summary.txt" + echo "# Mesh Processors Time Speedup Efficiency Mem Cells D_L2 D_Linf S_L2 S_Linf Status" > "${SUMMARY}" + + for i in ${MESHES} + do + MESH_CASE="${NAME}.${i}.mesh" + echo; echo "Preparing mesh case: ${MESH_CASE}" + + copyCase "../${BASE}" "${MESH_CASE}" + cd "${MESH_CASE}" + + if command -v gmsh &> /dev/null + then + mv 0 0.tmp + + if [[ "${GMSH_FILE}" == "tet" ]] + then + cp "gmsh/tet-meshSpacing/meshSpacing${i}.geo" "gmsh/tet-meshSpacing/meshSpacing.geo" + solids4Foam::runApplication gmsh -3 -format msh2 gmsh/tet.geo + solids4Foam::runApplication gmshToFoam gmsh/tet.msh + fi + + if [[ "${GMSH_FILE}" == "poly" ]] + then + cp "gmsh/poly-meshSpacing/meshSpacing${i}.geo" "gmsh/poly-meshSpacing/meshSpacing.geo" + solids4Foam::runApplication gmsh -3 -format msh2 gmsh/poly.geo + solids4Foam::runApplication gmshToFoam gmsh/poly.msh + solids4Foam::runApplication polyDualMesh 30 -overwrite + solids4Foam::runApplication combinePatchFaces 45 -overwrite + fi + + solids4Foam::runApplication changeDictionary + solids4Foam::runApplication checkMesh + mv 0.tmp 0 + else + echo; echo "Gmsh is required to run this case: please install it" + exit 1 + fi + + solids4Foam::runApplication projectPointsToSphere cavity "(0 0 0)" 0.2 + mv 1/polyMesh/points constant/polyMesh/points + rm -rf 1/meshPhi 1/pointMotion 1/polyMesh + + if [ -n "${PETSC_FILE}" ]; then + sed -i "/^\s*optionsFile /s|^.*| optionsFile ${PETSC_FILE};|" constant/solidProperties + fi + + if [ -n "${polyOrder}" ]; then + sed -i "/^\s*polynomialOrder /s|^.*| polynomialOrder ${polyOrder};|" constant/solidProperties + fi + + if [ -n "${extraCells}" ]; then + sed -i "/^\s*faceStencilExtraCells /s|^.*| faceStencilExtraCells ${extraCells};|" constant/solidProperties + fi + + if [ -n "${HOJAC}" ]; then + sed -i "/^\s*highOrderJacobian /s|^.*| highOrderJacobian ${HOJAC};|" constant/solidProperties + fi + + if [ -n "${HORES}" ]; then + sed -i "/^\s*highOrderResidual /s|^.*| highOrderResidual ${HORES};|" constant/solidProperties + fi + + CELLS=$(grep "cells:" log.checkMesh | awk '{print $2}') + cd .. + + SERIAL_TIME="NaN" + + for nProc in ${NP_LIST} + do + CASE="${NAME}.${i}.np${nProc}" + echo; echo "Processing case: ${CASE}" + + copyCase "${MESH_CASE}" "${CASE}" + cd "${CASE}" + + STATUS="OK" + if [ "${nProc}" -eq 1 ] + then + echo "Running solids4Foam on ${CASE}" + runTimed log.solids4Foam solids4Foam || STATUS="FAIL" + else + if ! command -v mpirun &> /dev/null + then + echo "mpirun is required for parallel runs" + STATUS="FAIL" + else + sed -i "/^\s*numberOfSubdomains /s|^.*|numberOfSubdomains ${nProc};|" system/decomposeParDict + solids4Foam::runApplication decomposePar -force + echo "Running solids4Foam on ${CASE} with ${nProc} processors" + runTimed log.solids4Foam mpirun -np "${nProc}" solids4Foam -parallel || STATUS="FAIL" + fi + fi + + CLOCK_TIME=$(grep "gtime/time" log.solids4Foam | tail -1 | awk '{print $5}') + CLOCK_TIME=$(extractOrNaN "${CLOCK_TIME}") + + if grep -q "Maximum resident" log.solids4Foam + then + MAX_MEMORY=$(grep "Maximum resident" log.solids4Foam | tail -1 | awk '{print int($6 / 1000)}') + else + MAX_MEMORY="NaN" + fi + + DISP_L2_ERROR=$(grep "Writing DDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $2}') + DISP_L2_ERROR=$(extractOrNaN "${DISP_L2_ERROR}") + + DISP_LINF_ERROR=$(grep "Writing DDifference field" -A 2 log.solids4Foam | tail -1 | awk '{print $3}') + DISP_LINF_ERROR=$(extractOrNaN "${DISP_LINF_ERROR}") + + STRESS_L2_ERROR=$(grep "Component: 5" -A 2 log.solids4Foam | tail -1 | awk '{print $2}') + STRESS_L2_ERROR=$(extractOrNaN "${STRESS_L2_ERROR}") + + STRESS_LINF_ERROR=$(grep "Component: 5" -A 2 log.solids4Foam | tail -1 | awk '{print $3}') + STRESS_LINF_ERROR=$(extractOrNaN "${STRESS_LINF_ERROR}") + + if [ "${nProc}" -eq 1 ] + then + SERIAL_TIME="${CLOCK_TIME}" + fi + + SPEEDUP=$(calcSpeedup "${SERIAL_TIME}" "${CLOCK_TIME}") + EFFICIENCY=$(calcEfficiency "${SPEEDUP}" "${nProc}") + + echo "${i} ${nProc} ${CLOCK_TIME} ${SPEEDUP} ${EFFICIENCY} ${MAX_MEMORY} ${CELLS} ${DISP_L2_ERROR} ${DISP_LINF_ERROR} ${STRESS_L2_ERROR} ${STRESS_LINF_ERROR} ${STATUS}" >> ../"${SUMMARY}" + echo "${NAME} ${i} ${nProc} ${CLOCK_TIME} ${SPEEDUP} ${EFFICIENCY} ${MAX_MEMORY} ${CELLS} ${DISP_L2_ERROR} ${DISP_LINF_ERROR} ${STRESS_L2_ERROR} ${STRESS_LINF_ERROR} ${STATUS}" >> ../"${GLOBAL_SUMMARY}" + + cd .. + done + done + + echo; echo "${SUMMARY} file:"; cat "${SUMMARY}"; echo +done + +echo; echo "${GLOBAL_SUMMARY} file:"; cat "${GLOBAL_SUMMARY}"; echo +if command -v gnuplot &> /dev/null +then + cp ../plotScripts/parallelScaling.gnuplot . + gnuplot parallelScaling.gnuplot +fi + +echo; echo; echo "Done!"; echo +echo "View the results in ${RUN_DIR}" +echo; echo $(date) +echo; echo diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/base/highOrder/constant/solidProperties b/papers/JFNK_highOrder/linearElastic/sphericalCavity/base/highOrder/constant/solidProperties index dfa3965f..87b8c182 100644 --- a/papers/JFNK_highOrder/linearElastic/sphericalCavity/base/highOrder/constant/solidProperties +++ b/papers/JFNK_highOrder/linearElastic/sphericalCavity/base/highOrder/constant/solidProperties @@ -33,6 +33,7 @@ linearGeometryTotalDisplacementCoeffs displacement { + type movingLeastSquares; polynomialOrder 2; faceStencilExtraCells 10; diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/base/snes/Allrun b/papers/JFNK_highOrder/linearElastic/sphericalCavity/base/snes/Allrun index 4026d587..65c65e3d 100755 --- a/papers/JFNK_highOrder/linearElastic/sphericalCavity/base/snes/Allrun +++ b/papers/JFNK_highOrder/linearElastic/sphericalCavity/base/snes/Allrun @@ -9,6 +9,15 @@ source solids4FoamScripts.sh solids4Foam::caseDoesNotRunWithFoamExtend solids4Foam::caseDoesNotRunWithOpenFOAMOrg +SCRIPT_DIR="$(cd "${0%/*}" && pwd -P)" +export SOLIDS4FOAM_DIR="${SOLIDS4FOAM_DIR:-${SCRIPT_DIR}/../../../../../../../solids4foam-ib-2412}" + +# Compile local analytical library when running from the benchmark base case +if [ -d ../../src ] +then + (cd ../../src && ./Allwmake -s) +fi + # Use poly (1) or tet (0) volumes USE_POLY=0 diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/base/snes/system/controlDict b/papers/JFNK_highOrder/linearElastic/sphericalCavity/base/snes/system/controlDict index 2cb05c32..7035d6a9 100644 --- a/papers/JFNK_highOrder/linearElastic/sphericalCavity/base/snes/system/controlDict +++ b/papers/JFNK_highOrder/linearElastic/sphericalCavity/base/snes/system/controlDict @@ -17,7 +17,7 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -libs ("libsphericalCavity.so"); +libs ("libsphericalCavityAnalytical.so"); application solids4Foam; diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/comparisonPlotScripts/dispErrors_movingVskExact.gnuplot b/papers/JFNK_highOrder/linearElastic/sphericalCavity/comparisonPlotScripts/dispErrors_movingVskExact.gnuplot new file mode 100644 index 00000000..c3feb56c --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/sphericalCavity/comparisonPlotScripts/dispErrors_movingVskExact.gnuplot @@ -0,0 +1,88 @@ +set term pdfcairo dashed enhanced size 3.25, 2 + +set datafile separator " " + +if (ARGC < 1) { + print "Usage: gnuplot -c dispErrors_movingVskExact.gnuplot " + exit +} + +movingResults = ARG1 +movingFile(fileName) = sprintf("%s/%s", movingResults, fileName) + +volume = 0.104056049 + +set grid +set xrange [20:80] +set yrange [1e-12:1e-07] +set xtics +set xtics add (5, 25, 50) +set ytics +set logscale x +set logscale y +set format y "10^{%L}" +#set ytics 0.002 +set xlabel "Average cell edge (in mm)" +set ylabel "Error (in m)" +set key right bottom outside; +set rmargin 16 +set key spacing 1.2 + +# Polynomial guide lines (no title) +set style line 1 lc rgb "red" lt 2 lw 2 dt 2 +set style line 2 lc rgb "blue" lt 2 lw 2 dt 2 +set style line 3 lc rgb "violet" lt 2 lw 2 dt 2 + +# Data lines for each p-order (with titles) +set style line 11 lc rgb "red" pt 7 ps 0.5 lw 1 +set style line 12 lc rgb "red" pt 6 ps 0.5 lw 1 +set style line 21 lc rgb "blue" pt 5 ps 0.5 lw 1 +set style line 22 lc rgb "blue" pt 4 ps 0.5 lw 1 +set style line 31 lc rgb "violet" pt 9 ps 0.5 lw 1 +set style line 32 lc rgb "violet" pt 8 ps 0.5 lw 1 + +# Moving-least-squares data use the same colours with 50% transparency +set style line 111 lc rgb "#B3ff0000" pt 7 ps 0.5 lw 1 +set style line 112 lc rgb "#B3ff0000" pt 6 ps 0.5 lw 1 +set style line 121 lc rgb "#B30000ff" pt 5 ps 0.5 lw 1 +set style line 122 lc rgb "#B30000ff" pt 4 ps 0.5 lw 1 +set style line 131 lc rgb "#B3ee82ee" pt 9 ps 0.5 lw 1 +set style line 132 lc rgb "#B3ee82ee" pt 8 ps 0.5 lw 1 + +#set xrange [25:85] +set output "sphericalCavity_dispErrors_tet_movingVskExact.pdf" +plot \ + (5e-12 * x**2) w l ls 1 title "2^{nd} order",\ + (0.8e-14 * x**3) w l ls 2 title "3^{rd} order",\ + (0.8e-16 * x**4) w l ls 3 title "4^{th} order",\ + "tet.unstruct.ho.N1.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($5) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct.ho.N1.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct.ho.N2.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($5) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct.ho.N2.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct.ho.N3.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($5) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "tet.unstruct.ho.N3.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)" , \ + movingFile("tet.unstruct.ho.N1.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($5) w lp ls 111 notitle , \ + movingFile("tet.unstruct.ho.N1.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($6) w lp ls 112 notitle , \ + movingFile("tet.unstruct.ho.N2.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($5) w lp ls 121 notitle , \ + movingFile("tet.unstruct.ho.N2.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($6) w lp ls 122 notitle , \ + movingFile("tet.unstruct.ho.N3.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($5) w lp ls 131 notitle , \ + movingFile("tet.unstruct.ho.N3.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($6) w lp ls 132 notitle + +set output "sphericalCavity_dispErrors_poly_movingVskExact.pdf" +set xrange [15:80] +plot \ + (5e-12 * x**2) w l ls 1 title "2^{nd} order",\ + (0.8e-14 * x**3) w l ls 2 title "3^{rd} order",\ + (0.8e-16 * x**4) w l ls 3 title "4^{th} order",\ + "poly.unstruct.ho.N1.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($5) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "poly.unstruct.ho.N1.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "poly.unstruct.ho.N2.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($5) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "poly.unstruct.ho.N2.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "poly.unstruct.ho.N3.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($5) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "poly.unstruct.ho.N3.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)" , \ + movingFile("poly.unstruct.ho.N1.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($5) w lp ls 111 notitle , \ + movingFile("poly.unstruct.ho.N1.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($6) w lp ls 112 notitle , \ + movingFile("poly.unstruct.ho.N2.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($5) w lp ls 121 notitle , \ + movingFile("poly.unstruct.ho.N2.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($6) w lp ls 122 notitle , \ + movingFile("poly.unstruct.ho.N3.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($5) w lp ls 131 notitle , \ + movingFile("poly.unstruct.ho.N3.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($6) w lp ls 132 notitle diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/comparisonPlotScripts/stressErrors_movingVskExact.gnuplot b/papers/JFNK_highOrder/linearElastic/sphericalCavity/comparisonPlotScripts/stressErrors_movingVskExact.gnuplot new file mode 100644 index 00000000..b083604a --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/sphericalCavity/comparisonPlotScripts/stressErrors_movingVskExact.gnuplot @@ -0,0 +1,90 @@ +set term pdfcairo dashed enhanced size 3.25, 2 +set datafile separator " " + +if (ARGC < 1) { + print "Usage: gnuplot -c stressErrors_movingVskExact.gnuplot " + exit +} + +movingResults = ARG1 +movingFile(fileName) = sprintf("%s/%s", movingResults, fileName) + +volume = 0.104056049 + +set grid +set xrange [20:80] +#set yrange [1e-3:100] +set xtics +set xtics add (5, 25, 50) +set ytics +set logscale x +set logscale y +set format y "10^{%L}" +#set ytics 0.002 +set xlabel "Average cell edge (in mm)" +set ylabel "Error (in MPa)" +set key right bottom outside; +set rmargin 16 +set key spacing 1.2 + +# Polynomial guide lines (no title) +set style line 1 lc rgb "red" lt 2 lw 2 dt 2 +set style line 2 lc rgb "blue" lt 2 lw 2 dt 2 +set style line 3 lc rgb "violet" lt 2 lw 2 dt 2 + +# Data lines for each p-order (with titles) +set style line 11 lc rgb "red" pt 7 ps 0.5 lw 1 +set style line 12 lc rgb "red" pt 6 ps 0.5 lw 1 +set style line 21 lc rgb "blue" pt 5 ps 0.5 lw 1 +set style line 22 lc rgb "blue" pt 4 ps 0.5 lw 1 +set style line 31 lc rgb "violet" pt 9 ps 0.5 lw 1 +set style line 32 lc rgb "violet" pt 8 ps 0.5 lw 1 + +# Moving-least-squares data use the same colours with 50% transparency +set style line 111 lc rgb "#B3ff0000" pt 7 ps 0.5 lw 1 +set style line 112 lc rgb "#B3ff0000" pt 6 ps 0.5 lw 1 +set style line 121 lc rgb "#B30000ff" pt 5 ps 0.5 lw 1 +set style line 122 lc rgb "#B30000ff" pt 4 ps 0.5 lw 1 +set style line 131 lc rgb "#B3ee82ee" pt 9 ps 0.5 lw 1 +set style line 132 lc rgb "#B3ee82ee" pt 8 ps 0.5 lw 1 + +set style line 50 lc rgb "orange" pt 11 ps 0.5 lw 1 + +set output "sphericalCavity_stressErrors_tet_movingVskExact.pdf" +plot \ + (5e-4 * x) w l ls 1 title "1^{st} order",\ + (11e-7 * x**2) w l ls 2 title "2^{nd} order",\ + (1e-8 * x**3) w l ls 3 title "3^{rd} order",\ + "tet.unstruct.ho.N1.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($7*1e-6) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct.ho.N1.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($8*1e-6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "tet.unstruct.ho.N2.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($7*1e-6) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct.ho.N2.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($8*1e-6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "tet.unstruct.ho.N3.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($7*1e-6) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "tet.unstruct.ho.N3.summary.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($8*1e-6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)", \ + NaN w l lc rgb "white" title " ", \ + "tet.unstruct.ho.N3.summary.zeroTraction.txt" u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($7*1e-6) w lp ls 50 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}^{_*}_{ }=3)" , \ + movingFile("tet.unstruct.ho.N1.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($7*1e-6) w lp ls 111 notitle , \ + movingFile("tet.unstruct.ho.N1.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($8*1e-6) w lp ls 112 notitle , \ + movingFile("tet.unstruct.ho.N2.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($7*1e-6) w lp ls 121 notitle , \ + movingFile("tet.unstruct.ho.N2.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($8*1e-6) w lp ls 122 notitle , \ + movingFile("tet.unstruct.ho.N3.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($7*1e-6) w lp ls 131 notitle , \ + movingFile("tet.unstruct.ho.N3.summary.txt") u ((8.48528*(volume/$4))**(1.0/3.0)*1e3):($8*1e-6) w lp ls 132 notitle + +set output "sphericalCavity_stressErrors_poly_movingVskExact.pdf" +set xrange [15:80] +plot \ + (5e-4 * x) w l ls 1 title "1^{st} order",\ + (11e-7 * x**2) w l ls 2 title "2^{nd} order",\ + (1e-8 * x**3) w l ls 3 title "3^{rd} order",\ + "poly.unstruct.ho.N1.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($7*1e-6) w lp ls 11 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=1)", \ + "poly.unstruct.ho.N1.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($8*1e-6) w lp ls 12 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=1)", \ + "poly.unstruct.ho.N2.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($7*1e-6) w lp ls 21 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=2)", \ + "poly.unstruct.ho.N2.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($8*1e-6) w lp ls 22 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=2)", \ + "poly.unstruct.ho.N3.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($7*1e-6) w lp ls 31 title "{/Times-Italic L}_{ 2} ({/Times-Italic p}_{ }=3)", \ + "poly.unstruct.ho.N3.summary.txt" u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($8*1e-6) w lp ls 32 title "{/Times-Italic L}_{ ∞} ({/Times-Italic p}_{ }=3)" , \ + movingFile("poly.unstruct.ho.N1.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($7*1e-6) w lp ls 111 notitle , \ + movingFile("poly.unstruct.ho.N1.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($8*1e-6) w lp ls 112 notitle , \ + movingFile("poly.unstruct.ho.N2.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($7*1e-6) w lp ls 121 notitle , \ + movingFile("poly.unstruct.ho.N2.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($8*1e-6) w lp ls 122 notitle , \ + movingFile("poly.unstruct.ho.N3.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($7*1e-6) w lp ls 131 notitle , \ + movingFile("poly.unstruct.ho.N3.summary.txt") u ((6*(volume/$4)/pi)**(1.0/3.0)*1e3):($8*1e-6) w lp ls 132 notitle diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/plotScripts/parallelScaling.gnuplot b/papers/JFNK_highOrder/linearElastic/sphericalCavity/plotScripts/parallelScaling.gnuplot new file mode 100644 index 00000000..55e4ac68 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/sphericalCavity/plotScripts/parallelScaling.gnuplot @@ -0,0 +1,34 @@ +set term pdfcairo dashed enhanced size 3.25, 2 +set datafile separator " " + +dataFile = "parallelScaling.summary.txt" + +set grid +set xrange [1:*] +set yrange [0:*] +set xtics 1 +set ytics +set xlabel "Number of processors" +set ylabel "Speedup" +set key left top +set key spacing 1.2 + +set style line 11 lc rgb "red" pt 7 ps 0.5 lw 1 +set style line 21 lc rgb "blue" pt 5 ps 0.5 lw 1 +set style line 31 lc rgb "violet" pt 9 ps 0.5 lw 1 +set style line 41 lc rgb "black" lt 2 lw 1 dt 2 + +meshes = system("awk 'NF && $1 !~ /^#/ {print $2}' ".dataFile." | sort -n | uniq") + +do for [i=1:words(meshes)] { + mesh = word(meshes, i) + 0 + + set output sprintf("sphericalCavity_parallelScaling_mesh%d.pdf", mesh) + set title sprintf("Mesh %d", mesh) + + plot \ + x w l ls 41 title "ideal", \ + dataFile u (($2 == mesh && strstrt(strcol(1), ".N1") > 0) ? $3 : 1/0):5 w lp ls 11 title "{/Times-Italic p}_{ }=1", \ + dataFile u (($2 == mesh && strstrt(strcol(1), ".N2") > 0) ? $3 : 1/0):5 w lp ls 21 title "{/Times-Italic p}_{ }=2", \ + dataFile u (($2 == mesh && strstrt(strcol(1), ".N3") > 0) ? $3 : 1/0):5 w lp ls 31 title "{/Times-Italic p}_{ }=3" +} diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/sphericalCavity/Allwmake b/papers/JFNK_highOrder/linearElastic/sphericalCavity/sphericalCavity/Allwmake deleted file mode 100755 index 5a57e73b..00000000 --- a/papers/JFNK_highOrder/linearElastic/sphericalCavity/sphericalCavity/Allwmake +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -cd "${0%/*}" || exit # Run from this directory - -# Stop at first error -set -e - -# Check if OpenFOAM/FOAM has been sourced -if [[ -z "${WM_PROJECT}" ]] -then - echo "Please source the OpenFOAM/FOAM bashrc first!" - exit 1 -fi - -# Check if the solids4foam installation directory has been set -if [[ -z "${SOLIDS4FOAM_DIR}" ]] -then - echo "Please set SOLIDS4FOAM_DIR, e.g." - echo " export SOLIDS4FOAM_DIR=/Users/philipc/OpenFOAM/philipc-v2312/solids4foam" - exit 1 -fi - -# Compile library -wmake $* libso 2>&1 | tee log.wmake - -# Check if the build succeeded -echo "Checking if the installation was a success:" -N_ERRORS_1=$(find . -name log.wmake | xargs grep " Error " | wc -l) -N_ERRORS_2=$(find . -name log.wmake | xargs grep " Stop." | wc -l) -if [[ $N_ERRORS_1 -gt 0 ]] || [[ $N_ERRORS_2 -gt 0 ]] -then - echo "** BUILD ERROR **" - echo "There were build errors in the following logs:" - echo $(find . -name log.wmake | xargs grep -l " Error ") - echo $(find . -name log.wmake | xargs grep -l " Stop.") - echo; echo "Please examine these logs for additional details"; echo - exit 1 -else - echo "There were no build errors: enjoy!"; echo -fi -echo - -#------------------------------------------------------------------------------ diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/sphericalCavity/Make/files b/papers/JFNK_highOrder/linearElastic/sphericalCavity/sphericalCavity/Make/files deleted file mode 100644 index fde6d5d1..00000000 --- a/papers/JFNK_highOrder/linearElastic/sphericalCavity/sphericalCavity/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -analyticalSphericalCavityDisplacementFvPatchVectorField.C - -LIB = $(FOAM_USER_LIBBIN)/libsphericalCavity diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/sphericalCavity/Make/options b/papers/JFNK_highOrder/linearElastic/sphericalCavity/sphericalCavity/Make/options deleted file mode 100644 index c5b1801e..00000000 --- a/papers/JFNK_highOrder/linearElastic/sphericalCavity/sphericalCavity/Make/options +++ /dev/null @@ -1,12 +0,0 @@ -sinclude $(SOLIDS4FOAM_DIR)/etc/wmake-options -sinclude $(SOLIDS4FOAM_DIR)/../etc/wmake-options - -EXE_INC = \ - $(VERSION_SPECIFIC_INC) \ - -I$(SOLIDS4FOAM_DIR)/src/solids4FoamModels/lnInclude \ - -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude - -LIB_LIBS = \ - -lfiniteVolume \ - -lmeshTools diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/sphericalCavity/analyticalSphericalCavityDisplacementFvPatchVectorField.C b/papers/JFNK_highOrder/linearElastic/sphericalCavity/sphericalCavity/analyticalSphericalCavityDisplacementFvPatchVectorField.C deleted file mode 100644 index b0e38ffa..00000000 --- a/papers/JFNK_highOrder/linearElastic/sphericalCavity/sphericalCavity/analyticalSphericalCavityDisplacementFvPatchVectorField.C +++ /dev/null @@ -1,213 +0,0 @@ -/*---------------------------------------------------------------------------*\ -License - This file is part of solids4foam. - - solids4foam is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation, either version 3 of the License, or (at your - option) any later version. - - solids4foam is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with solids4foam. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "analyticalSphericalCavityDisplacementFvPatchVectorField.H" -#include "addToRunTimeSelectionTable.H" -#include "sphericalCavityStressDisplacement.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -analyticalSphericalCavityDisplacementFvPatchVectorField:: -analyticalSphericalCavityDisplacementFvPatchVectorField -( - const fvPatch& p, - const DimensionedField& iF -) -: - fixedDisplacementFvPatchVectorField(p, iF), - T0_(0.0), - cavityR_(0.0), - nu_(0.0), - E_(0.0), - dict_() -{} - - -analyticalSphericalCavityDisplacementFvPatchVectorField:: -analyticalSphericalCavityDisplacementFvPatchVectorField -( - const analyticalSphericalCavityDisplacementFvPatchVectorField& ptf, - const fvPatch& p, - const DimensionedField& iF, - const fvPatchFieldMapper& mapper -) -: - fixedDisplacementFvPatchVectorField(ptf, p, iF, mapper), - T0_(ptf.T0_), - cavityR_(ptf.cavityR_), - nu_(ptf.nu_), - E_(ptf.E_), - dict_(ptf.dict_) -{} - - -analyticalSphericalCavityDisplacementFvPatchVectorField:: -analyticalSphericalCavityDisplacementFvPatchVectorField -( - const fvPatch& p, - const DimensionedField& iF, - const dictionary& dict -) -: - fixedDisplacementFvPatchVectorField(p, iF, dict), - T0_(readScalar(dict.lookup("farFieldTractionZ"))), - cavityR_(readScalar(dict.lookup("cavityRadius"))), - nu_(readScalar(dict.lookup("nu"))), - E_(readScalar(dict.lookup("E"))), - dict_(dict) -{} - -#ifndef OPENFOAM_ORG -analyticalSphericalCavityDisplacementFvPatchVectorField:: -analyticalSphericalCavityDisplacementFvPatchVectorField -( - const analyticalSphericalCavityDisplacementFvPatchVectorField& pivpvf -) -: - fixedDisplacementFvPatchVectorField(pivpvf), - T0_(pivpvf.T0_), - cavityR_(pivpvf.cavityR_), - nu_(pivpvf.nu_), - E_(pivpvf.E_), - dict_(pivpvf.dict_) -{} -#endif - -analyticalSphericalCavityDisplacementFvPatchVectorField:: -analyticalSphericalCavityDisplacementFvPatchVectorField -( - const analyticalSphericalCavityDisplacementFvPatchVectorField& pivpvf, - const DimensionedField& iF -) -: - fixedDisplacementFvPatchVectorField(pivpvf, iF), - T0_(pivpvf.T0_), - cavityR_(pivpvf.cavityR_), - nu_(pivpvf.nu_), - E_(pivpvf.E_), - dict_(pivpvf.dict_) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - - -void analyticalSphericalCavityDisplacementFvPatchVectorField::updateCoeffs() -{ - if (this->updated()) - { - return; - } - - // Set the displacement at each patch face - vectorField& disp = totalDisp(); - const vectorField& Cf = patch().Cf(); - forAll(disp, faceI) - { - disp[faceI] = - sphericalCavityDisplacement - ( - nu_, - T0_, - E_, - cavityR_, - Cf[faceI] - ); - } - - fixedDisplacementFvPatchVectorField::updateCoeffs(); -} - - -autoPtr> -analyticalSphericalCavityDisplacementFvPatchVectorField::evaluateQuadrature -( - const CompactListList& faceQuadPoints -) const -{ - // faceQuadPoints is list for whole mesh. - labelList nQpPerFace(this->size(), 0); - const label start = this->patch().start(); - forAll(nQpPerFace, faceI) - { - const label globalFaceID = faceI + start; - nQpPerFace[faceI]=faceQuadPoints[globalFaceID].size(); - } - - autoPtr> tQuadPointsValue - ( - new CompactListList(nQpPerFace) - ); - - // Get a reference to the actual data for easier access - CompactListList& quadPointsValue = tQuadPointsValue(); - - // Loop over faces - forAll(*this, faceI) - { - const label globalFaceID = faceI + start; - - // Get the number of quadrature points for this face - const label nPoints = faceQuadPoints[globalFaceID].size(); - - // Assign the values to face quadrature points - for (label pointI = 0; pointI < nPoints; ++pointI) - { - const point quadPoint = faceQuadPoints[globalFaceID][pointI]; - quadPointsValue[faceI][pointI] = - sphericalCavityDisplacement - ( - nu_, - T0_, - E_, - cavityR_, - quadPoint - ); - } - } - - return tQuadPointsValue; -} - - -void analyticalSphericalCavityDisplacementFvPatchVectorField:: -write(Ostream& os) const -{ - fixedDisplacementFvPatchVectorField::write(os); -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -makePatchTypeField -( - fvPatchVectorField, - analyticalSphericalCavityDisplacementFvPatchVectorField -); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/Allwmake b/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/Allwmake new file mode 100755 index 00000000..45b4cad2 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/Allwmake @@ -0,0 +1,10 @@ +#!/bin/bash +cd "${0%/*}" || exit # Run from this directory + +if [[ -n "${S4F_NO_USE_EIGEN:-}" ]]; then + echo "Eigen is required to compile this local library" + echo "Unset S4F_NO_USE_EIGEN and rebuild solids4foam" + exit 1 +fi + +wmake $* libso diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/Make/files b/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/Make/files new file mode 100644 index 00000000..d6e72e68 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/Make/files @@ -0,0 +1,6 @@ +analyticalSphericalCavityTraction/analyticalSphericalCavityTractionFvPatchVectorField.C + +sphericalCavityAnalyticalSolution/sphericalCavityAnalyticalSolution.C +sphericalCavityAnalyticalSolution/sphericalCavityStressDisplacement.C + +LIB = $(FOAM_MODULE_LIBBIN)/libsphericalCavityAnalytical diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/Make/options b/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/Make/options new file mode 100644 index 00000000..fc4fd0ab --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/Make/options @@ -0,0 +1,46 @@ +SOLIDS4FOAM_ROOT := $(shell d="$(CURDIR)"; while [ "$$d" != "/" ]; do if [ -f "$$d/etc/wmake-options" ] && [ -d "$$d/src/solids4FoamModels" ]; then echo "$$d"; exit 0; fi; if [ -f "$$d/solids4foam-ib-2412/etc/wmake-options" ] && [ -d "$$d/solids4foam-ib-2412/src/solids4FoamModels" ]; then echo "$$d/solids4foam-ib-2412"; exit 0; fi; d="$$(dirname "$$d")"; done) + +ifeq ($(SOLIDS4FOAM_ROOT),) +SOLIDS4FOAM_ROOT := $(SOLIDS4FOAM_DIR) +endif + +sinclude $(SOLIDS4FOAM_ROOT)/etc/wmake-options +sinclude $(SOLIDS4FOAM_ROOT)/../etc/wmake-options + +EXE_INC = \ + -Wno-old-style-cast -Wno-deprecated-declarations \ + $(VERSION_SPECIFIC_INC) \ + -I$(SOLIDS4FOAM_ROOT)/ThirdParty/eigen3 \ + -I$(SOLIDS4FOAM_ROOT)/src/blockCoupledSolids4FoamTools/lnInclude \ + -I$(SOLIDS4FOAM_ROOT)/src/RBFMeshMotionSolver/lnInclude \ + -I$(SOLIDS4FOAM_ROOT)/src/solids4FoamModels/lnInclude \ + -I$(SOLIDS4FOAM_ROOT)/src/solids4FoamModels/numerics/compatibilityFunctions \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/finiteArea/lnInclude \ + -I$(LIB_SRC)/lagrangian/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/dynamicFvMesh/lnInclude \ + -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/topoChangerFvMesh/lnInclude \ + -I$(LIB_SRC)/fvMotionSolver/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/surfMesh/lnInclude \ + -I$(LIB_SRC)/postProcessing/foamCalcFunctions/lnInclude \ + -I$(LIB_SRC)/postProcessing/functionObjects/forces/lnInclude \ + -I$(LIB_SRC)/errorEstimation/lnInclude \ + -I$(LIB_SRC)/mesh/cfMesh/lnInclude \ + -I$(LIB_SRC)/tetFiniteElement/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/meshMotion/fvMotionSolver/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/meshMotion/tetMotionSolver/lnInclude \ + -I$(LIB_SRC)/overset/oversetMesh/lnInclude + +LIB_INC = $(EXE_INC) + +LIB_LIBS = \ + -lfiniteVolume \ + -L$(FOAM_MODULE_LIBBIN) \ + -lblockCoupledSolids4FoamTools \ + -lRBFMeshMotionSolver \ + -lsolids4FoamModels diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/analyticalSphericalCavityTraction/analyticalSphericalCavityTractionFvPatchVectorField.C b/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/analyticalSphericalCavityTraction/analyticalSphericalCavityTractionFvPatchVectorField.C new file mode 100644 index 00000000..d4680bcf --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/analyticalSphericalCavityTraction/analyticalSphericalCavityTractionFvPatchVectorField.C @@ -0,0 +1,237 @@ +/*---------------------------------------------------------------------------*\ +License + This file is part of solids4foam. + + solids4foam is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + solids4foam is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solids4foam. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "analyticalSphericalCavityTractionFvPatchVectorField.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" +#include "sphericalCavityStressDisplacement.H" +#include "lookupSolidModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +analyticalSphericalCavityTractionFvPatchVectorField:: +analyticalSphericalCavityTractionFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF +) +: + solidTractionFvPatchVectorField(p, iF), + T0_(0.0), + cavityR_(0.0), + nu_(0.0) +{} + + +analyticalSphericalCavityTractionFvPatchVectorField:: +analyticalSphericalCavityTractionFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + solidTractionFvPatchVectorField(p, iF), + T0_(readScalar(dict.lookup("farFieldTractionZ"))), + cavityR_(readScalar(dict.lookup("cavityRadius"))), + nu_(readScalar(dict.lookup("nu"))) +{} + + +analyticalSphericalCavityTractionFvPatchVectorField:: +analyticalSphericalCavityTractionFvPatchVectorField +( + const analyticalSphericalCavityTractionFvPatchVectorField& stpvf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + solidTractionFvPatchVectorField(stpvf, p, iF, mapper), + T0_(stpvf.T0_), + cavityR_(stpvf.cavityR_), + nu_(stpvf.nu_) +{} + +#ifndef OPENFOAM_ORG +analyticalSphericalCavityTractionFvPatchVectorField:: +analyticalSphericalCavityTractionFvPatchVectorField +( + const analyticalSphericalCavityTractionFvPatchVectorField& stpvf +) +: + solidTractionFvPatchVectorField(stpvf), + T0_(stpvf.T0_), + cavityR_(stpvf.cavityR_), + nu_(stpvf.nu_) +{} +#endif + +analyticalSphericalCavityTractionFvPatchVectorField:: +analyticalSphericalCavityTractionFvPatchVectorField +( + const analyticalSphericalCavityTractionFvPatchVectorField& stpvf, + const DimensionedField& iF +) +: + solidTractionFvPatchVectorField(stpvf, iF), + T0_(stpvf.T0_), + cavityR_(stpvf.cavityR_), + nu_(stpvf.nu_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void analyticalSphericalCavityTractionFvPatchVectorField::autoMap +( + const fvPatchFieldMapper& m +) +{ + solidTractionFvPatchVectorField::autoMap(m); +} + + +// Reverse-map the given fvPatchField onto this fvPatchField +void analyticalSphericalCavityTractionFvPatchVectorField::rmap +( + const fvPatchVectorField& ptf, + const labelList& addr +) +{ + solidTractionFvPatchVectorField::rmap(ptf, addr); +} + + +// Update the coefficients associated with the patch field +void analyticalSphericalCavityTractionFvPatchVectorField::updateCoeffs() +{ + if (updated()) + { + return; + } + + // Patch unit normals + vectorField n(patch().nf()); + + // Patch face centres + const vectorField& Cf = patch().Cf(); + + // Set the patch traction + + vectorField& trac = traction(); + + forAll(traction(), faceI) + { + trac[faceI] = + ( + n[faceI] & sphericalCavityStress(T0_, nu_, cavityR_, Cf[faceI]) + ); + } + + solidTractionFvPatchVectorField::updateCoeffs(); +} + + +#ifndef FOAMEXTEND +autoPtr> +analyticalSphericalCavityTractionFvPatchVectorField::evaluateQuadrature() const +{ + const fvMesh& mesh = patch().boundaryMesh().mesh(); + const solidModel& solMod = lookupSolidModel(mesh); + + // faceQuadPoints is list for the whole mesh + const CompactListList& faceQuadPoints = + solMod.displacementLeastSquares().quadrature().faceQuadPoints(); + + labelList nQpPerFace(this->size(), 0); + const label start = this->patch().start(); + forAll(nQpPerFace, faceI) + { + const label globalFaceID = faceI + start; + nQpPerFace[faceI]=faceQuadPoints[globalFaceID].size(); + } + + autoPtr> tQuadPointsValue + ( + new CompactListList(nQpPerFace) + ); + + // Get a reference to the actual data for easier access + CompactListList& quadPointsValue = tQuadPointsValue(); + + // Patch unit normals + vectorField n(patch().nf()); + + forAll(*this, faceI) + { + const label globalFaceID = faceI + start; + + // Get the number of quadrature points for this face + const label nPoints = faceQuadPoints[globalFaceID].size(); + + // Assign the same value to all quadrature points on this face + // We assume constant distribution of traction! + for (label pointI = 0; pointI < nPoints; ++pointI) + { + const point quadPoint = faceQuadPoints[globalFaceID][pointI]; + quadPointsValue[faceI][pointI] = + n[faceI] & sphericalCavityStress(T0_, nu_, cavityR_, quadPoint); + } + } + + return tQuadPointsValue; +} +#endif + + +// Write +void analyticalSphericalCavityTractionFvPatchVectorField::write(Ostream& os) const +{ + solidTractionFvPatchVectorField::write(os); + + os.writeKeyword("farFieldTractionZ") + << T0_ << token::END_STATEMENT << nl; + + os.writeKeyword("cavityRadius") + << cavityR_ << token::END_STATEMENT << nl; + + os.writeKeyword("nu") + << nu_ << token::END_STATEMENT << nl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchVectorField, + analyticalSphericalCavityTractionFvPatchVectorField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/sphericalCavity/analyticalSphericalCavityDisplacementFvPatchVectorField.H b/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/analyticalSphericalCavityTraction/analyticalSphericalCavityTractionFvPatchVectorField.H similarity index 61% rename from papers/JFNK_highOrder/linearElastic/sphericalCavity/sphericalCavity/analyticalSphericalCavityDisplacementFvPatchVectorField.H rename to papers/JFNK_highOrder/linearElastic/sphericalCavity/src/analyticalSphericalCavityTraction/analyticalSphericalCavityTractionFvPatchVectorField.H index 54c3a0da..d5451b28 100644 --- a/papers/JFNK_highOrder/linearElastic/sphericalCavity/sphericalCavity/analyticalSphericalCavityDisplacementFvPatchVectorField.H +++ b/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/analyticalSphericalCavityTraction/analyticalSphericalCavityTractionFvPatchVectorField.H @@ -16,7 +16,7 @@ License along with solids4foam. If not, see . Class - Foam::analyticalSphericalCavityDisplacementFvPatchVectorField + analyticalSphericalCavityTractionFvPatchVectorField Description Traction boundary condition for a spherical cavity in an infinite elastic @@ -25,20 +25,17 @@ Description Author Philip Cardiff, UCD. - Ivan Batistic, UCD. SourceFiles - analyticalSphericalCavityDisplacementFvPatchVectorField.C - -Author - Philip Cardiff, UCD. All rights reserved. + analyticalSphericalCavityTractionFvPatchVectorField.C \*---------------------------------------------------------------------------*/ -#ifndef analyticalSphericalCavityDisplacementFvPatchVectorField_H -#define analyticalSphericalCavityDisplacementFvPatchVectorField_H +#ifndef analyticalSphericalCavityTractionFvPatchVectorField_H +#define analyticalSphericalCavityTractionFvPatchVectorField_H -#include "fixedDisplacementFvPatchVectorField.H" +#include "fvPatchFields.H" +#include "solidTractionFvPatchVectorField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -46,13 +43,15 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class analyticalSphericalCavityDisplacementFvPatch Declaration + Class analyticalSphericalCavityTractionFvPatchVectorField Declaration \*---------------------------------------------------------------------------*/ -class analyticalSphericalCavityDisplacementFvPatchVectorField +class analyticalSphericalCavityTractionFvPatchVectorField : - public fixedDisplacementFvPatchVectorField + public solidTractionFvPatchVectorField { +private: + // Private Data //- Far field traction @@ -65,50 +64,44 @@ class analyticalSphericalCavityDisplacementFvPatchVectorField //- Poisson's ration const scalar nu_; - //- Young modulus - const scalar E_; - - //- A copy of the constructor dict - const dictionary dict_; - public: //- Runtime type information - TypeName("analyticalSphericalCavityDisplacement"); + TypeName("analyticalSphericalCavityTraction"); // Constructors //- Construct from patch and internal field - analyticalSphericalCavityDisplacementFvPatchVectorField + analyticalSphericalCavityTractionFvPatchVectorField ( const fvPatch&, const DimensionedField& ); //- Construct from patch, internal field and dictionary - analyticalSphericalCavityDisplacementFvPatchVectorField + analyticalSphericalCavityTractionFvPatchVectorField ( const fvPatch&, const DimensionedField&, const dictionary& ); - //- Construct by mapping given analyticalSphericalCavityDisplacementFvPatchVectorField - // onto a new patch - analyticalSphericalCavityDisplacementFvPatchVectorField + //- Construct by mapping given + // analyticalSphericalCavityTractionFvPatchVectorField onto a new patch + analyticalSphericalCavityTractionFvPatchVectorField ( - const analyticalSphericalCavityDisplacementFvPatchVectorField&, + const analyticalSphericalCavityTractionFvPatchVectorField&, const fvPatch&, const DimensionedField&, const fvPatchFieldMapper& ); //- Construct as copy - analyticalSphericalCavityDisplacementFvPatchVectorField + analyticalSphericalCavityTractionFvPatchVectorField ( - const analyticalSphericalCavityDisplacementFvPatchVectorField& + const analyticalSphericalCavityTractionFvPatchVectorField& #ifdef OPENFOAM_ORG ) = delete; #else @@ -119,15 +112,15 @@ public: { return tmp ( - new analyticalSphericalCavityDisplacementFvPatchVectorField(*this) + new analyticalSphericalCavityTractionFvPatchVectorField(*this) ); } #endif //- Construct as copy setting internal field reference - analyticalSphericalCavityDisplacementFvPatchVectorField + analyticalSphericalCavityTractionFvPatchVectorField ( - const analyticalSphericalCavityDisplacementFvPatchVectorField&, + const analyticalSphericalCavityTractionFvPatchVectorField&, const DimensionedField& ); @@ -139,26 +132,37 @@ public: { return tmp ( - new analyticalSphericalCavityDisplacementFvPatchVectorField(*this, iF) + new analyticalSphericalCavityTractionFvPatchVectorField(*this, iF) ); } - // Member functions + // Mapping functions - // Evaluation functions - - //- Update the coefficients associated with the patch field - virtual void updateCoeffs(); + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); - //- Return face quadrature values. - // Used for high order solvers, input is position of points - virtual autoPtr> evaluateQuadrature + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap ( - const CompactListList& faceQuadPoints - ) const; + const fvPatchVectorField&, + const labelList& + ); + + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + +#ifndef FOAMEXTEND + //- Return face quadrature values, used for high order solvers + virtual autoPtr> + evaluateQuadrature() const; +#endif //- Write virtual void write(Ostream&) const; diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/sphericalCavityAnalyticalSolution/sphericalCavityAnalyticalSolution.C b/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/sphericalCavityAnalyticalSolution/sphericalCavityAnalyticalSolution.C new file mode 100644 index 00000000..7ded938e --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/sphericalCavityAnalyticalSolution/sphericalCavityAnalyticalSolution.C @@ -0,0 +1,564 @@ +/*---------------------------------------------------------------------------*\ +License + This file is part of solids4foam. + + solids4foam is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + solids4foam is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solids4foam. If not, see . + +\*----------------------------------------------------------------------------*/ + +#include "sphericalCavityAnalyticalSolution.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" +#include "pointFields.H" +#include "sphericalCavityStressDisplacement.H" +#include "OSspecific.H" +#include "compatibilityFunctions.H" +#include "lookupSolidModel.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(sphericalCavityAnalyticalSolution, 0); + + addToRunTimeSelectionTable + ( + functionObject, + sphericalCavityAnalyticalSolution, + dictionary + ); +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::sphericalCavityAnalyticalSolution:: +calculateAnalyticalCellDisplacement +( + const fvMesh& mesh, + vectorField& analyticalD +) +{ + const solidModel& solMod = lookupSolidModel(mesh); + bool useCellAverage = false; + + if (solMod.highOrderResidual()) + { + const dictionary& displacementDict = + solMod.solidModelDict() + .subDict("highOrderCoeffs") + .subDict("displacement"); + useCellAverage = + displacementDict.lookupOrDefault + ( + "type", + "movingLeastSquares" + ) == "kExactLeastSquares"; + } + + if (useCellAverage) + { + const fvMeshQuadrature& quadrature = + solMod.displacementLeastSquares().quadrature(); + const CompactListList& cellQuadPoints = + quadrature.cellQuadPoints(); + const CompactListList& cellQuadWeights = + quadrature.cellQuadWeights(); + const scalarField& cellVolumes = mesh.V(); + + Info<< "Using cell-average analytical displacement" << endl; + + forAll(analyticalD, cellI) + { + analyticalD[cellI] = vector::zero; + + forAll(cellQuadPoints[cellI], pointI) + { + analyticalD[cellI] += + cellQuadWeights[cellI][pointI] + *sphericalCavityDisplacement + ( + nu_, + T0_, + E_, + cavityR_, + cellQuadPoints[cellI][pointI] + ); + } + + analyticalD[cellI] /= cellVolumes[cellI]; + } + } + else + { + Info<< "Using point-valued analytical displacement" << endl; + + const vectorField& cellCentres = mesh.C().internalField(); + + forAll(analyticalD, cellI) + { + analyticalD[cellI] = + sphericalCavityDisplacement + ( + nu_, T0_, E_, cavityR_, cellCentres[cellI] + ); + } + } +} + + +bool Foam::sphericalCavityAnalyticalSolution::writeData() +{ + // Lookup the solid mesh + const fvMesh* meshPtr = NULL; + if (time_.foundObject("solid")) + { + meshPtr = &(time_.lookupObject("solid")); + } + else + { + meshPtr = &(time_.lookupObject("region0")); + } + const fvMesh& mesh = *meshPtr; + + // Lookup the point mesh + const pointMesh& pMesh = mesh.lookupObject("pointMesh"); + + // Cell-centres coordinates + const volVectorField& C = mesh.C(); + const vectorField& CI = C; + + // Point coordinates + const pointField& points = mesh.points(); + + if (gMin(mag(points)) < -SMALL) + { + FatalErrorIn + ( + "bool Foam::sphericalCavityAnalyticalSolution::writeData()" + ) << "The cavity should be centred on the origin!" << endl + << "gMin(mag(points)) = " << gMin(mag(points)) + << abort(FatalError); + } + + // Cell analytical fields + if (cellDisplacement_ || cellStress_) + { + // Analytical stress field + volSymmTensorField analyticalStress + ( + IOobject + ( + "analyticalCellStress", + time_.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedSymmTensor("zero", dimPressure, symmTensor::zero), + "calculated" + ); + + // Analytical displacement field + volVectorField analyticalD + ( + IOobject + ( + "analyticalD", + time_.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedVector("zero", dimLength, vector::zero), + "calculated" + ); + + symmTensorField& sI = analyticalStress; + vectorField& aDI = analyticalD; + + forAll(sI, cellI) + { + if (cellStress_) + { + sI[cellI] = + sphericalCavityStress(T0_, nu_, cavityR_, CI[cellI]); + } + + } + + if (cellDisplacement_) + { + calculateAnalyticalCellDisplacement(mesh, aDI); + } + + forAll(analyticalStress.boundaryField(), patchI) + { + if (mesh.boundary()[patchI].type() != "empty") + { + symmTensorField& sP = boundaryFieldRef(analyticalStress)[patchI]; + vectorField& aDP = boundaryFieldRef(analyticalD)[patchI]; + const vectorField& CP = C.boundaryField()[patchI]; + + forAll(sP, faceI) + { + if (cellStress_) + { + sP[faceI] = + sphericalCavityStress + ( + T0_, nu_, cavityR_, CP[faceI] + ); + } + + if (cellDisplacement_) + { + aDP[faceI] = + sphericalCavityDisplacement + ( + nu_, T0_, E_, cavityR_, CP[faceI] + ); + } + } + } + } + + // Write out the cell analytical field + if (cellStress_) + { + Info<< "Writing analyticalCellStress field" + << nl << endl; + analyticalStress.write(); + + // Calculate and write the equivalent (von Mises) stress + Info<< "Writing analyticalCellStressEq field" + << nl << endl; + volScalarField analyticalStressEq + ( + IOobject + ( + "analyticalCellStressEq", + time_.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + sqrt((3.0/2.0)*magSqr(dev(analyticalStress))) + ); + analyticalStressEq.write(); + } + + if (cellDisplacement_) + { + Info<< "Writing analyticalD field" + << nl << endl; + analyticalD.write(); + } + + + if (cellStress_ && mesh.foundObject("sigma")) + { + const volSymmTensorField& sigma = + mesh.lookupObject("sigma"); + + const volSymmTensorField diff + ( + "cellStressDifference", analyticalStress - sigma + ); + Info<< "Writing cellStressDifference field" << endl; + diff.write(); + + if (Pstream::master()) + { + historyFilePtr_() + << time_.time().value(); + } + + for (int cmpt = 0; cmpt < pTraits::nComponents; cmpt++) + { + const symmTensorField& diffI = diff; + const scalarField diffIcmptI(diffI.component(cmpt)); + const scalar l1 = gAverage(mag(diffIcmptI)); + const scalar l2 = Foam::sqrt(gAverage(magSqr(diffIcmptI))); + const scalar lInf = gMax(mag(diffIcmptI)); + + Info<< " Component: " << cmpt << endl; + Info<< " Norms: mean L1, mean L2, LInf: " << nl + << " " << l1 + << " " << l2 + << " " << lInf + << nl << endl; + + if (Pstream::master()) + { + historyFilePtr_() + << " " << l1 << " " << l2 << " " << lInf; + } + } + + if (Pstream::master()) + { + historyFilePtr_() + << endl; + } + } + + if (cellDisplacement_ && mesh.foundObject("D")) + { + const volVectorField& D = + mesh.lookupObject("D"); + + const volVectorField diff + ( + "DDifference", analyticalD - D + ); + Info<< "Writing DDifference field" << endl; + diff.write(); + + const vectorField& diffI = diff; + Info<< " Norms: mean L1, mean L2, LInf: " << nl + << " " << gAverage(mag(diffI)) + << " " << Foam::sqrt(gAverage(magSqr(diffI))) + << " " << gMax(mag(diffI)) + << nl << endl; + } + } + + // Point analytical fields + if (pointDisplacement_ || pointStress_) + { + pointSymmTensorField analyticalStress + ( + IOobject + ( + "analyticalPointStress", + time_.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + pMesh, + dimensionedSymmTensor("zero", dimPressure, symmTensor::zero) + ); + + pointVectorField analyticalD + ( + IOobject + ( + "analyticalPointD", + time_.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + pMesh, + dimensionedVector("zero", dimLength, vector::zero) + ); + + symmTensorField& sI = analyticalStress; + vectorField& aDI = analyticalD; + + forAll(sI, pointI) + { + if (pointStress_) + { + sI[pointI] = + sphericalCavityStress(T0_, nu_, cavityR_, points[pointI]); + } + + if (pointDisplacement_) + { + aDI[pointI] = + sphericalCavityDisplacement + ( + nu_, T0_, E_, cavityR_, points[pointI] + ); + } + } + + // Write point analytical fields + if (pointStress_) + { + Info<< "Writing analyticalPointStress" + << nl << endl; + analyticalStress.write(); + } + + if (pointDisplacement_) + { + Info<< "Writing analyticalPointDisplacement" + << nl << endl; + analyticalD.write(); + } + + if + ( + pointDisplacement_ + && mesh.foundObject("pointD") + ) + { + const pointVectorField& pointD = + mesh.lookupObject("pointD"); + + const pointVectorField diff + ( + "pointDDifference", analyticalD - pointD + ); + Info<< "Writing pointDDifference field" << endl; + diff.write(); + + const vectorField& diffI = diff; + Info<< " Norms: mean L1, mean L2, LInf: " << nl + << " " << gAverage(mag(diffI)) + << " " << Foam::sqrt(gAverage(magSqr(diffI))) + << " " << gMax(mag(diffI)) + << nl << endl; + } + } + + return true; +} + +//** * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::sphericalCavityAnalyticalSolution::sphericalCavityAnalyticalSolution +( + const word& name, + const Time& t, + const dictionary& dict +) +: + functionObject(name), + name_(name), + time_(t), + cellDisplacement_ + ( + dict.lookupOrDefault("cellDisplacement", true) + ), + pointDisplacement_ + ( + dict.lookupOrDefault("pointDisplacement", true) + ), + cellStress_ + ( + dict.lookupOrDefault("cellStress", true) + ), + pointStress_ + ( + dict.lookupOrDefault("pointStress", true) + ), + historyFilePtr_(), + T0_(readScalar(dict.lookup("farFieldTractionZ"))), + cavityR_(readScalar(dict.lookup("cavityRadius"))), + E_(readScalar(dict.lookup("E"))), + nu_(readScalar(dict.lookup("nu"))) +{ + Info<< "Creating " << this->name() << " function object" << endl; + + if (cavityR_ < SMALL) + { + FatalErrorIn(this->name() + " function object constructor") + << "cavityRadius should be greater than 0!" + << abort(FatalError); + } + + if (E_ < SMALL || nu_ < SMALL) + { + FatalErrorIn(this->name() + " function object constructor") + << "E and nu should be positive!" + << abort(FatalError); + } + + // Create history file if not already created + if (historyFilePtr_.empty()) + { + // File update + if (Pstream::master()) + { + fileName historyDir; + + word startTimeName = + time_.timeName(time_.startTime().value()); + + if (Pstream::parRun()) + { + // Put in undecomposed case (Note: gives problems for + // distributed data running) + historyDir = time_.path()/".."/"postProcessing"/startTimeName; + } + else + { + historyDir = time_.path()/"postProcessing"/startTimeName; + } + + // Create directory if does not exist. + mkDir(historyDir); + + // Open new file at start up + OStringStream FileName; + FileName() + << "sphericalCavityStressErrors.dat"; + + historyFilePtr_.reset + ( + new OFstream(historyDir/word(FileName.str())) + ); + + // Add headers to output data + if (historyFilePtr_.valid()) + { + historyFilePtr_() + << "# Time" << " " + << "Stress Errors (l1, l2, lInfinity) for each component " + << "(XX XY XZ YY YZ ZZ)" << endl; + } + } + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::sphericalCavityAnalyticalSolution::start() +{ + return true; +} + + +#if FOAMEXTEND + bool Foam::sphericalCavityAnalyticalSolution::execute(const bool forceWrite) +#else + bool Foam::sphericalCavityAnalyticalSolution::execute() +#endif +{ + return writeData(); +} + + +bool Foam::sphericalCavityAnalyticalSolution::read(const dictionary& dict) +{ + return true; +} + + +#ifdef OPENFOAM_NOT_EXTEND +bool Foam::sphericalCavityAnalyticalSolution::write() +{ + return false; +} +#endif + +// ************************************************************************* // diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/sphericalCavityAnalyticalSolution/sphericalCavityAnalyticalSolution.H b/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/sphericalCavityAnalyticalSolution/sphericalCavityAnalyticalSolution.H new file mode 100644 index 00000000..819daf64 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/sphericalCavityAnalyticalSolution/sphericalCavityAnalyticalSolution.H @@ -0,0 +1,200 @@ +/*---------------------------------------------------------------------------*\ +License + This file is part of solids4foam. + + solids4foam is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + solids4foam is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solids4foam. If not, see . + +Class + sphericalCavityAnalyticalSolution + +Description + FunctionObject that generates the analytical displacement and stress fields + for the spherical cavity (radius = a) in an infinite linear elastic solid + (Young's modulus of E and Poisson's ration of nu) subjected to a distant + uniaxial stress T0 applied in the positive Z direction. + + The analytical solution requires the following inputs: + - farFieldTractionZ : far-field traction in the positive Z direction + - cavityRadius : radius of the cavity centred on the origin + - E : Young's modulus + - nu : Poisson's ratio + + The analytical solution for stress is taken from: + + R.V. Southwell M.A. F.R.S. & H.J. Gough M.B.E. B.Sc. (1926) VI. On the + concentration of stress in the neighbourhood of a small spherical flaw; + and on the propagation of fatigue fractures in “Statistically Isotropic” + materials , The London, Edinburgh, and Dublin Philosophical Magazine and + Journal of Science: Series 7, 1:1, 71-97, DOI: 10.1080/14786442608633614 + + The analytical solution for displacement is taken from: + + Allan F. Bower (2009) Applied Mechanics of Solids, CRC Press, Taylor and + Francis Group. + + Note: Bower also gives the stress solutions but they seem to have errors + as the axial (zz) stress formula does not provide the correct stress + concentration factor at the edge of the cavity. + +Author + Philip Cardiff, UCD. + +SourceFiles + sphericalCavityAnalyticalSolution.C + +\*---------------------------------------------------------------------------*/ + +#ifndef sphericalCavityAnalyticalSolution_H +#define sphericalCavityAnalyticalSolution_H + +#include "functionObject.H" +#include "dictionary.H" +#include "fvMesh.H" +#include "OFstream.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class sphericalCavityAnalyticalSolution Declaration +\*---------------------------------------------------------------------------*/ + +class sphericalCavityAnalyticalSolution +: + public functionObject +{ + // Private data + + //- Name + const word name_; + + //- Reference to main object registry + const Time& time_; + + //- Calculate cell displacement fields + const Switch cellDisplacement_; + + //- Calculate point displacement fields + const Switch pointDisplacement_; + + //- Calculate cell stress fields + const Switch cellStress_; + + //- Calculate point stress fields + const Switch pointStress_; + + //- Optional history file for writing the errors + autoPtr historyFilePtr_; + + //- Far field traction + // It is assumed that it acts in the positive Z direction + const scalar T0_; + + //- Cavity radius + const scalar cavityR_; + + //- Young's modulus + const scalar E_; + + //- Poisson's ratio + const scalar nu_; + + + // Private Member Functions + + //- Calculate analytical cell displacement using the selected + // reconstruction semantics + void calculateAnalyticalCellDisplacement + ( + const fvMesh& mesh, + vectorField& analyticalD + ); + + //- Write data + bool writeData(); + + //- Disallow default bitwise copy construct + sphericalCavityAnalyticalSolution + ( + const sphericalCavityAnalyticalSolution& + ); + + //- Disallow default bitwise assignment + void operator=(const sphericalCavityAnalyticalSolution&); + + +public: + + //- Runtime type information + TypeName("sphericalCavityAnalyticalSolution"); + + + // Constructors + + //- Construct from components + sphericalCavityAnalyticalSolution + ( + const word& name, + const Time&, + const dictionary& + ); + + + // Member Functions + + //- start is called at the start of the time-loop + virtual bool start(); + + //- execute is called at each ++ or += of the time-loop +#if FOAMEXTEND + virtual bool execute(const bool forceWrite); +#else + virtual bool execute(); +#endif + + //- Called when time was set at the end of the Time::operator++ + virtual bool timeSet() + { + return true; + } + + //- Read and set the function object if its data has changed + virtual bool read(const dictionary& dict); + +#ifdef OPENFOAM_NOT_EXTEND + //- Write + virtual bool write(); +#else + //- Update for changes of mesh + virtual void updateMesh(const mapPolyMesh&) + {} + + //- Update for changes of mesh + virtual void movePoints(const pointField&) + {} +#endif +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/sphericalCavityAnalyticalSolution/sphericalCavityStressDisplacement.C b/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/sphericalCavityAnalyticalSolution/sphericalCavityStressDisplacement.C new file mode 100644 index 00000000..415b7db1 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/sphericalCavityAnalyticalSolution/sphericalCavityStressDisplacement.C @@ -0,0 +1,209 @@ +/*---------------------------------------------------------------------------*\ +License + This file is part of solids4foam. + + solids4foam is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + solids4foam is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solids4foam. If not, see . + +\*----------------------------------------------------------------------------*/ + +#include "sphericalCavityStressDisplacement.H" +#include "coordinateSystem.H" +#include "transform.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::scalar Foam::KroneckerDelta(const int i, const int j) +{ + return (i == j) ? 1.0 : 0.0; +} + +Foam::scalar Foam::sphericalCavityDisplacementComponent +( + const int i, + const scalar nu, + const scalar sigma_0, + const scalar E, + const scalar a, + const vector& x +) +{ + const scalar R = mag(x); + const scalar x_3 = x[vector::Z]; + + const scalar term1 = + 2 + + (5*(5 - 4*nu)*pow(a, 3))/((7 - 5*nu)*pow(R, 3)) + + (6*pow(a, 5))/((7 - 5*nu)*pow(R, 5)); + const scalar term2 = + (-2*nu)/(1 + nu) + + (5*nu - 6)*pow(a, 3)/((7 - 5*nu)*pow(R, 3)) + + 3*pow(a, 5)/((7 - 5*nu)*pow(R, 5)); + const scalar common_factor = (1 + nu)*sigma_0/(2*E); + + return + common_factor + *( + term1*x_3*KroneckerDelta(i, 2) + + term2*x[i]*(1 - 5*pow(x_3, 2)/pow(R, 2)) + ); +} + + +Foam::vector Foam::sphericalCavityDisplacement +( + const scalar nu, + const scalar T, + const scalar E, + const scalar a, + const vector& x +) +{ + // Bower 2009 approach - not correct + // vector disp = vector::zero; + // for (int i = 0; i < 3; ++i) + // { + // disp[i] = + // sphericalCavityDisplacementComponent(i, nu, T, E, a, x); + // } + + // Goodier 1933 + + // Shear modulus + const scalar mu = E/(2*(1 + nu)); + + // Constants for a spherical cavity + const scalar A = -pow3(a)*(T/(8*mu))*(13 - 10*nu)/(7 - 5*nu); + const scalar B = pow5(a)*(T/(8*mu))*(1/(7 - 5*nu)); + const scalar C = pow3(a)*(T/(8*mu))*((5*(1 - 2*nu))/(7 - 5*nu)); + + // Calculate the spherical polar coordinates + const scalar r = mag(x); + if (r < SMALL) + { + FatalError + << "r is less than SMALL. " + << "Are you sure the cavity is centred on the origin?" + << abort(FatalError); + } + const scalar theta = Foam::acos(x.z()/r); + const scalar phi = Foam::atan2(x.y(), x.x()); + + // Radial displacement + const scalar ur = + - A/sqr(r) - 3*B/pow4(r) + + ( + ((5 - 4*nu)/(1 - 2*nu))*C/sqr(r) - 9*B/pow4(r) + )*cos(2*theta); + + // Theta displacement + const scalar utheta = -(2*C/sqr(r) + 6*B/pow4(r))*sin(2*theta); + + // Spherical polar displacement vector (r, theta, phi) + const vector dispPolar(ur, utheta, 0); + + // Calculate the Cartesian displacement vector + const vector dispCart + ( + ur*sin(theta)*cos(phi) + utheta*cos(theta)*cos(phi), + ur*sin(theta)*sin(phi) + utheta*cos(theta)*sin(phi), + ur*cos(theta) - utheta*sin(theta) + ); + + // Calculate the displacement field called by a uniform uniaxial T when + // there is no cavity + const vector dispUni(-nu*T*x.x()/E, -nu*T*x.y()/E, T*x.z()/E); + + // Return the total Cartesian displacement vector + return dispCart + dispUni; +} + + +Foam::symmTensor Foam::sphericalCavityStress +( + const scalar T, + const scalar nu, + const scalar a, + const vector& x +) +{ + // Stress formulae from Southwell et al, 1926, On the concentration of + // stress in the neighbourhood of a small spherical flaw; and on the + // propagation of fatigue fractures in Statistically Isotropic materials + + // Polar radial coordinate + // Take care: in general, R != r + const scalar R = mag(x); + + // Cylindrical radial coordinate + const scalar r = sqrt(sqr(x.x()) + sqr(x.y())); + + // Cylindrical axial coordinate + const scalar z = x.z(); + + // Initialise stress tensor + // We will place rr in xx, thetaTheta in yy, zz in zz, and zr in xz + // We will late rotate this stress tensor to the Cartesian coordinate system + symmTensor sigmaCylindrical = symmTensor::zero; + + // Radial (rr) component + sigmaCylindrical.xx() = + (T/(14 - 10*nu))*(pow3(a)/pow3(R)) + *( + 9 - 15*nu - 12*(sqr(a)/sqr(R)) + - (sqr(r)/sqr(R))*(72 - 15*nu - 105*(sqr(a)/sqr(R))) + + 15*(pow4(r)/pow4(R))*(5 - 7*(sqr(a)/sqr(R))) + ); + + // Hoop (thetaTheta) component + sigmaCylindrical.yy() = + (T/(14 - 10*nu))*(pow3(a)/pow3(R)) + *( + 9 - 15*nu - 12*(sqr(a)/sqr(R)) + - 15*(sqr(r)/sqr(R))*(1 - 2*nu - (sqr(a)/sqr(R))) + ); + + // Axial (zz) component + sigmaCylindrical.zz() = + T + *( + 1 + - (1/(14 - 10*nu))*(pow3(a)/pow3(R)) + *( + 38 - 10*nu - 24*sqr(a)/sqr(R) + - (sqr(r)/sqr(R))*(117 - 15*nu - 120*sqr(a)/sqr(R)) + + 15*(pow4(r)/pow4(R))*(5 - 7*sqr(a)/sqr(R)) + ) + ); + + // Radial-axial shear (rz) component + sigmaCylindrical.xz() = + (T/(14 - 10*nu))*(pow3(a)*z*r/pow5(R)) + *( + - 3*(19 - 5*nu) + 60*(sqr(a)/sqr(R)) + + 15*(sqr(r)/sqr(R))*(5 - 7*(sqr(a)/sqr(R))) + ); + + // Rotate the cylindrical stress to Cartesian coordinates + const coordinateSystem cs("cylindrical", x, vector(0, 0, 1), x/mag(x)); +#ifdef OPENFOAM_COM + const symmTensor sigmaCartesian = transform(cs.R(), sigmaCylindrical); +#else + const symmTensor sigmaCartesian = transform(cs.R().R(), sigmaCylindrical); +#endif + + return sigmaCartesian; +} + + +// ************************************************************************* // diff --git a/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/sphericalCavityAnalyticalSolution/sphericalCavityStressDisplacement.H b/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/sphericalCavityAnalyticalSolution/sphericalCavityStressDisplacement.H new file mode 100644 index 00000000..8139c579 --- /dev/null +++ b/papers/JFNK_highOrder/linearElastic/sphericalCavity/src/sphericalCavityAnalyticalSolution/sphericalCavityStressDisplacement.H @@ -0,0 +1,116 @@ +/*---------------------------------------------------------------------------*\ +License + This file is part of solids4foam. + + solids4foam is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + solids4foam is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solids4foam. If not, see . + +Functions + sphericalCavityStressDisplacement + +Description + Functions that generates the analytical displacement and stress fields + for the spherical cavity (radius = a) in an infinite linear elastic solid + (Young's modulus of E and Poisson's ration of nu) subjected to a distant + uniaxial stress T0 applied in the positive Z direction. + + The analytical solution requires the following inputs: + - farFieldTractionZ : far-field traction in the positive Z direction + - cavityRadius : radius of the cavity centred on the origin + - E : Young's modulus + - nu : Poisson's ratio + + The analytical solution for stress is taken from: + + R.V. Southwell M.A. F.R.S. & H.J. Gough M.B.E. B.Sc. (1926) VI. On the + concentration of stress in the neighbourhood of a small spherical flaw; + and on the propagation of fatigue fractures in “Statistically Isotropic” + materials , The London, Edinburgh, and Dublin Philosophical Magazine and + Journal of Science: Series 7, 1:1, 71-97, DOI: 10.1080/14786442608633614 + + The analytical solution for displacement is taken from: + + Allan F. Bower (2009) Applied Mechanics of Solids, CRC Press, Taylor and + Francis Group. + + Note: Bower also gives the stress solutions but they seem to have errors + as the axial (zz) stress formula does not provide the correct stress + concentration factor at the edge of the cavity. + +Author + Philip Cardiff, UCD. + +SourceFiles + sphericalCavityStressDisplacement.C + +\*---------------------------------------------------------------------------*/ + +#ifndef sphericalCavityStressDisplacement_H +#define sphericalCavityStressDisplacement_H + +#include "vector.H" +#include "symmTensor.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + + //- Kronecker delta function + scalar KroneckerDelta + ( + const int i, const int j + ); + + //- Calculate the displacement component i at a coordinate x + // From Bower (2009) + scalar sphericalCavityDisplacementComponent + ( + const int i, + const scalar nu, + const scalar sigma_0, + const scalar E, + const scalar a, + const vector& x + ); + + //- Calculate the displacement vector at a coordinate x + // From Bower (2009) + vector sphericalCavityDisplacement + ( + const scalar nu, + const scalar sigma_0, + const scalar E, + const scalar a, + const vector& x + ); + + //- Calculate the stress at point x + // From Southwell (1926) + symmTensor sphericalCavityStress + ( + const scalar T, // distant ZZ stress + const scalar nu, // Poisson's ratio + const scalar a, // Sphere radius + const vector& x // Position + ); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //