Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
simoneponcioni authored Jun 25, 2024
2 parents 30ab67d + ff3de3e commit 5b74470
Show file tree
Hide file tree
Showing 14 changed files with 672 additions and 34 deletions.
4 changes: 2 additions & 2 deletions 02_CODE/Dockerfile.ubuntu24.04.ifort
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# https://pythonspeed.com/articles/activate-conda-dockerfile/

FROM ubuntu:24.04

ENV DEBIAN_FRONTEND noninteractive
Expand Down Expand Up @@ -64,5 +66,3 @@ ENV PATH="/opt/cargo/bin:${PATH}"
# conda init, source .bashrc, conda activate
RUN conda init bash
RUN echo "conda activate hfe-essentials" >> ~/.bashrc

# https://pythonspeed.com/articles/activate-conda-dockerfile/
68 changes: 68 additions & 0 deletions 02_CODE/Dockerfile.ubuntu24.04.ifort.thrusections
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
FROM ubuntu:24.04

ENV DEBIAN_FRONTEND noninteractive
ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8

RUN apt-get update && apt-get install -y \
apt-utils cargo clang clang-tidy cmake \
fonts-cmu ftp gcc gcovr \
git g++ gfortran libboost-dev libcgns-dev \
libfltk1.3-dev libfreetype6-dev libgl1-mesa-dev libgl1-mesa-dri libhdf5-dev \
libocct-data-exchange-dev libocct-foundation-dev libocct-ocaf-dev libopenblas-dev libopenmpi-dev \
libpetsc-complex-dev libxfixes-dev libxcursor-dev libxft-dev libxi-dev \
libxinerama-dev libxmu-dev libslepc-complex3.19-dev mesa-common-dev python3-pip \
swig tcl-dev tk-dev valgrind vim wget \
sudo locales \
&& apt-get clean

RUN locale-gen en_US.UTF-8

# install ifort compiler
RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
RUN echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
RUN sudo apt update && sudo apt upgrade -y
RUN sudo apt-get install -y intel-basekit intel-hpckit
RUN /bin/bash -c "source /opt/intel/oneapi/setvars.sh"
RUN unset PYTHONPATH

# Install miniconda
RUN wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh && \
bash ~/miniconda.sh -b -p /opt/miniconda && rm ~/miniconda.sh
ENV PATH="/opt/miniconda/bin:$PATH"

# Create a conda environment
RUN conda create -n hfe-essentials python=3.12
SHELL ["conda", "run", "-n", "hfe-essentials", "/bin/bash", "-c"]
# Copy hfe requirements.txt and install requirements
COPY ./requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install -U scikit-image
RUN pip install imutils

# Set GitHub username and personal access token
ARG GITHUB_USERNAME
ARG GITHUB_TOKEN
ARG USER_UID=1000
ARG USER_GID=1000

# Install the meshing package
RUN git clone -b ThruSections --single-branch https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@github.com/artorg-unibe-ch/spline_mesher.git ./pyhexspline/spline_mesher
WORKDIR ./pyhexspline/spline_mesher
RUN pip install -e .

# Change ownership of the conda environment to the hfe user
RUN useradd -ms /bin/bash hfe
RUN chown -R hfe:hfe /opt/miniconda/envs/hfe-essentials

USER hfe
WORKDIR /home/hfe
RUN mkdir -p ~/.ssh
RUN chmod 700 ~/.ssh
ENV PATH="/opt/cargo/bin:${PATH}"

# conda init, source .bashrc, conda activate
RUN conda init bash
RUN echo "conda activate hfe-essentials" >> ~/.bashrc

# https://pythonspeed.com/articles/activate-conda-dockerfile/
1 change: 1 addition & 0 deletions 02_CODE/cfg/hfe-tibia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ hydra:
mode: MULTIRUN
sweeper:
params:

simulations.grayscale_filenames: C0000000

# C0003093, C0003096
Expand Down
8 changes: 4 additions & 4 deletions 02_CODE/cfg/mesh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ meshing_settings:
outside_val: 1 # threshold value for the outside of the mask
lower_thresh: 0 # lower threshold for the mask
upper_thresh: 0.9 # upper threshold for the mask
s: 400 # smoothing factor of the spline
s: 1000 # smoothing factor of the spline
k: 3 # degree of the spline
interp_points: 350 # number of points to interpolate the spline
thickness_tol: 0.50 # minimum cortical thickness tolerance: 3 * XCTII voxel size
phases: 2 # 1: only external contour, 2: external and internal contour
center_square_length_factor: 0.4 # size ratio of the refinement square: 0 < l_f < 1
mesh_order: 1 # set order of the mesh (1: linear, 2: quadratic)
sweep_factor: 1 # factor for the sweep used in hydra for the sensitivity analysis
n_elms_longitudinal: 6
n_elms_transverse_trab: 12
n_elms_longitudinal: 60
n_elms_transverse_trab: 15
n_elms_transverse_cort: 3
n_elms_radial: 15 # ! Should be 10 if trab_refinement is True
n_elms_radial: 20 # ! Should be 10 if trab_refinement is True
ellipsoid_fitting: True
show_plots: False # show plots during construction
show_gmsh: False # show gmsh GUI
Expand Down
27 changes: 11 additions & 16 deletions 02_CODE/cfg/socket.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
solver:
site: remote # local or remote
# abaqus: /var/DassaultSystemes/SIMULIA/Commands/abq2021hf4 # monterosa (Abaqus 2021)
# abaqus: /var/DassaultSystemes/SIMULIA/Commands/abq2021hf6 # simone-kubuntu
abaqus: /storage/workspaces/artorg_msb/hpc_abaqus/Software/DassaultSystemes/SIMULIA/Commands/abq2024 # ubelix
socket_paths: # paths that are socket specific (you might need to change them)
# SIMONE-KUBUNTU
# workdir: /home/simoneponcioni/Documents/01_PHD/03_Methods/HFE
# scratchdir: /home/simoneponcioni/.SCRATCH
# odb2vtk: "/home/simoneponcioni/Documents/04_TOOLS/ODB2VTK/python/odb2vtk.py"
# MONTEROSA
# workdir: /home/sp20q110/HFE
# scratchdir: /home/sp20q110/.SCRATCH
# odb2vtk: "/home/sp20q110/TOOLS/ODB2VTK/python/odb2vtk.py"
# UBELIX
workdir: /storage/workspaces/artorg_msb/hpc_abaqus/poncioni/HFE
scratchdir: /storage/workspaces/artorg_msb/hpc_abaqus/poncioni/.SCRATCH
odb2vtk: /storage/workspaces/artorg_msb/hpc_abaqus/poncioni/TOOLS/ODB2VTK/python/odb2vtk.py

# abaqus: /var/DassaultSystemes/SIMULIA/Commands/abq2021hf4 # monterosa (Abaqus 2021)
abaqus: /var/DassaultSystemes/SIMULIA/Commands/abq2021hf6 # simone-kubuntu

socket_paths: # paths that are socket specific (you might need to change them)
# workdir: /Users/msb/Documents/01_PHD/03_Methods/CLEAN-HFE-ACCURATE # simone-macbook
workdir: /home/simoneponcioni/Documents/01_PHD/03_Methods/HFE # simone-kubuntu
scratchdir: /home/simoneponcioni/.SCRATCH # simone-kubuntu
odb2vtk: "/home/simoneponcioni/Documents/04_TOOLS/ODB2VTK/python/odb2vtk.py" # simone-kubuntu
# workdir: /home/sp20q110/HFE # monterosa
# scratchdir: /home/sp20q110/.SCRATCH # monterosa
# odb2vtk: "/home/sp20q110/TOOLS/ODB2VTK/python/odb2vtk.py" # monterosa
10 changes: 8 additions & 2 deletions 02_CODE/src/hfe_abq/aim2fe.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,11 @@ def aim2fe_psl(cfg, sample):
bone = imutils.read_aim_mask_combined("MASK", filenames, bone)

# image_list = ["BMD", "SEG", "CORTMASK", "TRABMASK"]
for _, item in enumerate(image_list):
bone = imutils.adjust_image_size(item, bone, cfg, imutils.CropType.crop)
if cfg.registration.registration is True:
for _, item in enumerate(image_list):
bone = imutils.adjust_image_size(item, bone, cfg, imutils.CropType.crop)
else:
pass

# Save images with colorbar
imutils.save_images_with_colorbar(cfg, sample, bone)
Expand Down Expand Up @@ -263,7 +266,10 @@ def aim2fe_psl(cfg, sample):
"""

bone["elsets"] = []
if "FEelSize" not in bone or bone["FEelSize"]:
bone["FEelSize"] = int(round(cfg.mesher.element_size / spacing[0])) * bone["Spacing"]
CoarseFactor = bone["FEelSize"][0] / bone["Spacing"][0]
bone["CoarseFactor"] = CoarseFactor
BVTVscaled_shape = bone["BVTVscaled"].shape
bone["MESH"] = np.ones(
([int(dim) for dim in np.floor(np.array(BVTVscaled_shape) / CoarseFactor)])
Expand Down
4 changes: 2 additions & 2 deletions 02_CODE/src/hfe_accurate/hfe_accurate.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
def pipeline_hfe(cfg, folder_id, grayscale_filename):
'''
# TODO: reactivate this for mesh sensitivity analysis
n_sim = int(15) # has to match sweep in config
# n_sim = int(15) # has to match sweep in config
# min = 5, 5, 2, 7
# max = 20, 50, 10, 50 did not work, reducing to 20, 40, 10, 40
n_elms_longitudinal = np.linspace(1, 20, n_sim, dtype=int)
Expand All @@ -61,7 +61,7 @@ def pipeline_hfe(cfg, folder_id, grayscale_filename):
)
cfg.meshing_settings.n_elms_radial = int(n_radial[sweep - 1].item())
'''

# timing
time_record = {}
start_full = time()
Expand Down
3 changes: 2 additions & 1 deletion 02_CODE/src/hfe_accurate/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ def write_data_summary(
"max_force_FZ_MAX",
"disp_at_max_force_FZ_MAX",
"stiffness_1D_FZ_MAX",
"yield_force_FZ_MAX" "yield_disp_FZ_MAX",
"yield_force_FZ_MAX",
"yield_disp_FZ_MAX",
]

def append_list_as_row(filename: str, list_of_elem: list) -> None:
Expand Down
1 change: 1 addition & 0 deletions 02_CODE/src/hfe_utils/imutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ def adjust_image_size(name, bone, cfg, croptype=CropType.crop):
Expansions in x and y dimension,
will probably not affect strength, but will lower stiffness.
"""
logger.info(f"Adjust image size for {name}")
# get bone values
img_array = bone[name + "_array"]
spacing = bone["Spacing"]
Expand Down
2 changes: 2 additions & 0 deletions 02_CODE/src/pipeline_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
# this code creates a list of executables to run in parallel


import json
import logging
import warnings
import os
from enum import Enum
from pprint import pprint
from time import time

import json
from pathlib import Path

Expand Down
56 changes: 56 additions & 0 deletions QMSKI/convergence_study/convergence_radius.csv.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Sample,DOFs,simulation_time,n_elms_longitudinal,n_elms_transverse_trab,n_elms_transverse_cort,n_elms_radial,max_force_FZ_MAX,disp_at_max_force_FZ_MAX,stiffness_1D_FZ_MAX,yield_force_FZ_MAX,yield_disp_FZ_MAX
C0002211,1188,164.56627488136292,1,3,1,3,-719.84124,-0.06,11997.354,2464.1391387240838,0.24435942444446346
C0002214,1188,201.47952461242676,1,3,1,3,-705.52511,-0.06,11758.751833333334,2008.571117560214,0.21026980027803
C0002224,1188,280.7424781322479,1,3,1,3,-3091.7441,-0.06,51529.068333333336,7325.367584014664,0.18112911510049312
C0002231,1188,225.22625494003296,1,3,1,3,-1145.6966,-0.06,19094.943333333333,3469.726149246288,0.2209211706465814
C0002236,1188,344.3748724460602,1,3,1,3,-1228.8986,-0.06,20481.643333333333,3591.9698055295808,0.21446568663053164
C0002211,5616,133.47015142440796,2,6,1,6,-1236.128,-0.06,20602.13333333333,4397.601037448608,0.25242288093854115
C0002214,5616,129.50553107261658,2,6,1,6,-977.72067,-0.06,16295.344500000001,3284.041831475544,0.24098732620706087
C0002224,5616,167.37361788749695,2,6,1,6,-4136.409,-0.06,68940.15,11194.820767617737,0.2013538379132302
C0002231,5616,117.41219735145569,2,6,1,6,-1521.166,-0.06,25352.766666666666,5238.863895633051,0.24585075395543868
C0002236,5616,144.79491233825684,2,6,1,6,-1805.4235,-0.06,30090.39166666667,5899.694368693689,0.23515633016760368
C0002211,24354,155.27164030075073,3,9,2,9,-1223.9867,-0.06,20399.778333333332,4042.704468195697,0.23714314869194417
C0002214,24354,160.24841046333313,3,9,2,9,-939.93669,-0.06,15665.6115,2895.856755050235,0.22430917748728013
C0002224,24354,198.50739693641663,3,9,2,9,-4061.2246,-0.06,67687.07666666668,11042.732911844174,0.2021130965179353
C0002231,24354,154.44014716148376,3,9,2,9,-1465.4583,-0.06,24424.305,4761.495764655892,0.23416108775391156
C0002236,24354,188.68646883964539,3,9,2,9,-1808.6812,-0.06,30144.68666666667,5704.864662609309,0.2283400346856667
C0002211,99918,392.7510221004486,5,13,2,13,-1210.0449,-0.06,20167.415,3849.939694761712,0.22986822446792213
C0002214,99918,330.0326089859009,5,13,2,13,-909.68055,-0.06,15161.3425,2670.9409717923445,0.21562264760955557
C0002224,99918,386.72703766822815,5,13,2,13,-4002.9214,-0.06,66715.35666666667,10963.276412238967,0.20329833607914788
C0002231,99918,331.3824031352997,5,13,2,13,-1435.2071,-0.06,23920.118333333336,4332.160084561556,0.2203214842378766
C0002236,99918,357.44678497314453,5,13,2,13,-1802.0873,-0.06,30034.788333333334,5534.25909784049,0.2233522396476755
C0002211,199056,700.9591152667999,6,16,3,16,-1230.8356,-0.06,20513.92666666667,3950.366609138833,0.2315391955315648
C0002214,199056,587.1639711856842,6,16,3,16,-916.20945,-0.06,15270.1575,2708.3673843366087,0.21681822852922528
C0002224,199056,643.8600363731384,6,16,3,16,-3942.6775,-0.06,65711.29166666667,10900.833740410526,0.20485901844817395
C0002231,199056,589.405469417572,6,16,3,16,-1444.4294,-0.06,24073.823333333334,4445.329322488726,0.2238660730778179
C0002236,199056,709.422290802002,6,16,3,16,-1819.1429,-0.06,30319.048333333336,5573.514103964922,0.2229194026599904
C0002211,348378,1406.7665519714355,7,19,4,19,-1230.5275,-0.06,20508.791666666668,3943.554503472064,0.23125525590058127
C0002214,348378,1104.5540237426758,7,19,4,19,-912.87869,-0.06,15214.644833333334,2674.6191792812024,0.21524722317169126
C0002224,348378,1166.6818957328796,7,19,4,19,-3930.5832,-0.06,65509.72,10874.29375985666,0.20496432656458607
C0002231,348378,1342.5923595428467,7,19,4,19,-1440.4279,-0.06,24007.131666666664,4451.228247487003,0.22462475649883892
C0002236,348378,1481.6669945716858,7,19,4,19,-1811.0298,-0.06,30183.83,5502.820945666311,0.22140083676657465
C0002211,671334,2925.61093044281,9,23,4,23,-1228.2834,-0.06,20471.39,3954.371948100286,0.23213498430732932
C0002214,671334,3474.312791109085,9,23,4,23,-908.02362,-0.06,15133.727,2634.8022606544855,0.21355615413241283
C0002224,671334,3149.4745025634766,9,23,4,23,-3920.6552,-0.06,65344.25333333334,10819.826391400728,0.20455111946414653
C0002231,671334,4385.488255739212,9,23,4,23,-1433.3476,-0.06,23889.126666666667,4339.78917127348,0.22087579379429848
C0002236,671334,4538.487810373306,9,23,4,23,-1809.6493,-0.06,30160.821666666667,5465.532263442161,0.22030358457359864
C0002211,986976,5250.873509645462,10,26,5,26,-1228.0846,-0.06,20468.076666666664,3948.4188781068374,0.2318754070403372
C0002214,986976,6889.14343547821,10,26,5,26,-907.09119,-0.06,15118.1865,2629.278417522052,0.21336974148664495
C0002224,986976,5486.8557958602905,10,26,5,26,-3911.1158,-0.06,65185.263333333336,10772.58274127802,0.20423022205658695
C0002231,986976,9863.633207559586,10,26,5,26,-1432.4617,-0.06,23874.361666666668,4263.035299590662,0.2177732351960219
C0002236,986976,11427.949367761612,10,26,5,26,-1808.6039,-0.06,30143.398333333334,5435.404193905037,0.219408836899037
C0002211,1388322,10460.726221561432,11,29,6,29,-1227.1772,-0.06,20452.953333333335,3931.2252665634164,0.23117740384535437
C0002214,1388322,14195.274369001389,11,29,6,29,-905.90751,-0.06,15098.4585,2614.663104943376,0.21262898250471338
C0002224,1388322,13208.653208494186,11,29,6,29,-3902.3782,-0.06,65039.63666666667,10724.626296816781,0.2038629070624738
# C0002211,1388322,10827.971837043762,11,29,6,29,-1227.1569,-0.06,20452.615,3931.137186048556,0.23117627684642753
# C0002214,1388322,14858.701694965363,11,29,6,29,-905.85528,-0.06,15097.588,2614.600257877109,0.21263480469655438
# C0002224,1388322,13552.094338655472,11,29,6,29,-3902.339,-0.06,65038.98333333334,10724.499879766252,0.20386261975016814
C0002231,1388322,17720.548528671265,11,29,6,29,-1429.7003,-0.06,23828.338333333333,4289.123508704826,0.21921295758241013
C0002236,1388322,19175.415147781372,11,29,6,29,-1805.8063,-0.06,30096.771666666667,5443.6230884888155,0.2199612726495127
C0002211,2131950,58632.795172691345,13,33,6,33,-1226.271,-0.06,20437.85,3857.317574389772,0.22770322687872235
C0002214,2131950,34948.27955698967,13,33,6,33,-904.15322,-0.06,15069.220333333335,2600.4911885031934,0.21202453046091282
C0002224,2131950,61175.879356622696,13,33,6,33,-3901.7788,-0.06,65029.64666666667,10681.260385996018,0.20322137470143056
C0002231,2131950,43406.73288726807,13,33,6,33,-1428.4828,-0.06,23808.04666666667,4258.661683144499,0.21808689685669724
C0002236,2131950,107984.5685069561,13,33,6,33,-1804.8707,-0.06,30081.178333333333,5391.598488939102,0.21832555803608145
# C0002211,2786256,123426.55494379997,14,36,7,36,-1225.7786,-0.06,20429.643333333337,3850.6456616120768,0.22745246207008635
# C0002214,2786256,71593.53161430359,14,36,7,36,-904.23644,-0.06,15070.607333333333,2610.4318638832565,0.2126682551351063
Loading

0 comments on commit 5b74470

Please sign in to comment.