Skip to content

Commit

Permalink
Merge pull request #239 from lanl/DanielJ2quick
Browse files Browse the repository at this point in the history
added LS-EVPFFT-J2 to the source directory. Will merge with other LS-…
  • Loading branch information
djdunning authored Dec 4, 2024
2 parents 1640139 + f26a95b commit d02e43b
Show file tree
Hide file tree
Showing 88 changed files with 461,235 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ src/LS-EVPFFT/scripts/** linguist-documentation
src/Mesh-Builder/examples/** linguist-documentation
src/Parallel-Solvers/Implicit-Lagrange/Mesh_Examples/** linguist-documentation
src/Parallel-Solvers/Implicit-Lagrange/MueLu_XML_Examples/** linguist-documentation
src/Parallel-Solvers/Parallel-Explicit/Example_Yaml_Scripts/** linguist-documentation
src/Parallel-Solvers/Parallel-Explicit/Example_Yaml_Scripts/** linguist-documentation
src/LS-EVPFFT-J2/example_lattice_run/** linguist-documentation
Binary file not shown.
2 changes: 2 additions & 0 deletions src/LS-EVPFFT-J2/example_lattice_run/elastic_parameters.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1 ISO
119800. 0.35 YOUNG(MPa),NU (V+R/2)
5 changes: 5 additions & 0 deletions src/LS-EVPFFT-J2/example_lattice_run/plastic_parameters.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SLIP SYSTEMS FOR CUBIC CRYSTAL
CUBIC icryst
1. 1. 1. crystal axes (cdim(i))
0 nmodesx (total # of modes listed in the file)
0 nmodes (# of modes to be used in the calculation)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PLASTICITY
J2 icryst
10 1.0 nrs, edot0
10.0 10.0 50.0 2.0 sigma0, sigma1, theta0, theta1
48 changes: 48 additions & 0 deletions src/LS-EVPFFT-J2/example_lattice_run/tension_33.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
2 0 0 0 NPHMX, NMODMX, NTWMMX, NSYSMX
84 84 64 x-dim, y-dim, z-dim
2 number of phases (nph)
1. 1. 1. RVE dimensions (delt)
* name and path of microstructure file (filetext)
txfft_gas
*INFORMATION ABOUT PHASE #1
1 igas(iph)
* name and path of single crystal files (filecryspl, filecrysel) (dummy if igas(iph)=1)
dummy
dummy
*INFORMATION ABOUT PHASE #2
0 igas(iph)
* name and path of single crystal files (filecryspl, filecrysel) (dummy if igas(iph)=1)
plastic_parameters_j2.txt
elastic_parameters.txt
*INFORMATION ABOUT TEST CONDITIONS
* boundary conditions
1 1 1 iudot | flag for vel.grad.
1 1 1 | (0:unknown-1:known)
1 1 1 |
|
0.0 0.0 0.0 udot | vel.grad
0.0 0.0 0.0 |
0.0 0.0 1.0 |
|
0 0 0 iscau | flag for Cauchy
0 0 |
0 |
|
0. 0. 0. scauchy | Cauchy stress
0. 0. |
0. @
* other
0.001 eqincr (if ictrl>=0) or tdot (if ictrl=-1)
-1 ictrl (1-6: strain comp, 0: VM eq, -1: tdot)
*INFORMATION ABOUT RUN CONDITIONS
10 nsteps
0.00001 err
100 itmax
0 IRECOVER read grain states from STRESS.IN (1) or not (0)?
0 ISAVE write grain states in STRESS.OUT (1) or not (0)?
1 IUPDATE update tex & RVE dim (1) or not (0)?
1 IUPHARD
1 IWTEX
1 10 IWFIELDS,IWSTEP
0 ITHERMO (if ithermo=1, next line is filethermo)
dummy
451,584 changes: 451,584 additions & 0 deletions src/LS-EVPFFT-J2/example_lattice_run/txfft_gas

Large diffs are not rendered by default.

Binary file added src/LS-EVPFFT-J2/scripts/.DS_Store
Binary file not shown.
180 changes: 180 additions & 0 deletions src/LS-EVPFFT-J2/scripts/build_scripts/build_ls-evpfft.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
#!/bin/bash -e

show_help() {
echo "Usage: source $(basename "$BASH_SOURCE") [OPTION]"
echo "Required arguments:"
echo " --heffte_build_type=<fftw|cufft|rocfft>"
echo " --kokkos_build_type=<serial|openmp|pthreads|cuda|hip>"
echo " "
echo "Optional arguments:"
echo " --build_fftw: builds fftw from scratch"
echo " --build_hdf5: builds hdf5 from scratch"
echo " --machine=<darwin|chicoma|linux|mac> (default: none)"
echo " --num_jobs=<number>: Number of jobs for 'make' (default: 1, on Mac use 1)"
echo " --help: Display this help message"
echo " "
return 1
}

# Initialize variables with default values
heffte_build_type=""
kokkos_build_type=""
machine=""
num_jobs=1
build_fftw=0
build_hdf5=0

# Define arrays of valid options
valid_heffte_build_types=("fftw" "cufft" "rocfft")
valid_kokkos_build_types=("serial" "openmp" "cuda" "cuda-ampere" "hip")
valid_machines=("darwin" "chicoma" "linux" "mac")

# Parse command line arguments
for arg in "$@"; do
case "$arg" in
--heffte_build_type=*)
option="${arg#*=}"
if [[ " ${valid_heffte_build_types[*]} " == *" $option "* ]]; then
heffte_build_type="$option"
else
echo "Error: Invalid --heffte_build_type specified."
show_help
return 1
fi
;;
--kokkos_build_type=*)
option="${arg#*=}"
if [[ " ${valid_kokkos_build_types[*]} " == *" $option "* ]]; then
kokkos_build_type="$option"
else
echo "Error: Invalid --kokkos_build_type specified."
show_help
return 1
fi
;;
--build_fftw)
build_fftw=1
;;
--build_hdf5)
build_hdf5=1
;;
--machine=*)
option="${arg#*=}"
if [[ " ${valid_machines[*]} " == *" $option "* ]]; then
machine="$option"
else
echo "Error: Invalid --machine specified."
show_help
return 1
fi
;;
--num_jobs=*)
num_jobs="${arg#*=}"
if ! [[ "$num_jobs" =~ ^[0-9]+$ ]]; then
echo "Error: Invalid --num_jobs value. Must be a positive integer."
show_help
return 1
fi
;;
--help)
show_help
return 1
;;
*)
echo "Error: Invalid argument or value specified."
show_help
return 1
;;
esac
done

# Check if required options are specified
if [ -z "$heffte_build_type" ] || [ -z "$kokkos_build_type" ]; then
echo "Error: --heffte_build_type and --kokkos_build_type are required options."
show_help
return 1
fi

# If both arguments are valid, you can use them in your script as needed
echo "Heffte Build Type: $heffte_build_type"
echo "Kokkos Build Type: $kokkos_build_type"

# Determine the directory of the current script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "Script directory: ${SCRIPT_DIR}"

# Determine the parent directory of the script's directory
PARENT_DIR=$(dirname $(dirname "${SCRIPT_DIR}"))

# make lib directory to store all dependencies
LIB_DIR="$PARENT_DIR/lib"
mkdir -p "$LIB_DIR"

# --------setup env for machine
if [ -n "$machine" ]; then
MACHINE_SCRIPT="$PARENT_DIR/scripts/machines/${machine}-env.sh"
source "$MACHINE_SCRIPT" --env_type=$kokkos_build_type
fi

# --------building heffte
build_fftw_option=""
if [ "$build_fftw" -eq 1 ]; then
build_fftw_option="--build_fftw"
fi
HEFFTE_INSTALL_SCRIPT="$PARENT_DIR/scripts/install_scripts/install_heffte.sh"
source "$HEFFTE_INSTALL_SCRIPT" --heffte_build_type=$heffte_build_type --num_jobs=$num_jobs $build_fftw_option

# --------building kokkos
KOKKOS_INSTALL_SCRIPT="$PARENT_DIR/scripts/install_scripts/install_kokkos.sh"
source "$KOKKOS_INSTALL_SCRIPT" --kokkos_build_type=$kokkos_build_type --num_jobs=$num_jobs

# --------building hdf5
if [ "$build_hdf5" -eq 1 ]; then
HDF5_INSTALL_SCRIPT="$PARENT_DIR/scripts/install_scripts/install_hdf5.sh"
source "$HDF5_INSTALL_SCRIPT" --num_jobs=$num_jobs
fi

# --------building matar
MATAR_INSTALL_SCRIPT="$PARENT_DIR/scripts/install_scripts/install_matar.sh"
source "$MATAR_INSTALL_SCRIPT" --kokkos_build_type=$kokkos_build_type --num_jobs=$num_jobs

# --------building LS-EVPFFT
LS_EVPFFT_SOURCE_DIR="$PARENT_DIR/src"
LS_EVPFFT_BUILD_DIR="$PARENT_DIR/ls-evpfft_${heffte_build_type}_${kokkos_build_type}"

# set dependencies directories
HEFFTE_INSTALL_DIR="$LIB_DIR/heffte/install_heffte_$heffte_build_type"
KOKKOS_INSTALL_DIR="$LIB_DIR/kokkos/install_kokkos_$kokkos_build_type"
MATAR_INSTALL_DIR="$LIB_DIR/MATAR/install_MATAR_$kokkos_build_type"
if [ "$build_hdf5" -eq 1 ]; then
HDF5_INSTALL_DIR="$LIB_DIR/hdf5/install_hdf5"
fi

# Configure LS-EVPFFT using CMake
cmake_options=(
-D CMAKE_BUILD_TYPE=Release
-D CMAKE_PREFIX_PATH="$HEFFTE_INSTALL_DIR;$KOKKOS_INSTALL_DIR;$HDF5_INSTALL_DIR;$MATAR_INSTALL_DIR"
-D ENABLE_PROFILING=ON
)

if [ "$heffte_build_type" = "fftw" ]; then
cmake_options+=(
-D USE_FFTW=ON
)
elif [ "$heffte_build_type" = "cufft" ]; then
cmake_options+=(
-D USE_CUFFT=ON
)
elif [ "$heffte_build_type" = "rocfft" ]; then
cmake_options+=(
-D USE_ROCFFT=ON
)
fi

# Configure LS-EVPFFT
cmake "${cmake_options[@]}" -B "$LS_EVPFFT_BUILD_DIR" -S "$LS_EVPFFT_SOURCE_DIR"

# Build kokkos
echo "Building LS-EVPFFT..."
make -C "$LS_EVPFFT_BUILD_DIR" -j"$num_jobs"

116 changes: 116 additions & 0 deletions src/LS-EVPFFT-J2/scripts/install_scripts/install_fftw.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/bin/bash -e

show_help() {
echo "Usage: source $(basename "$BASH_SOURCE") [OPTION]"
echo "Valid options:"
echo " --num_jobs=<number>: Number of jobs for 'make' (default: 1, on Mac use 1)"
echo " --help: Display this help message"
return 1
}

# Initialize variables with default values
num_jobs=1

# Parse command line arguments
for arg in "$@"; do
case "$arg" in
--num_jobs=*)
num_jobs="${arg#*=}"
if ! [[ "$num_jobs" =~ ^[0-9]+$ ]]; then
echo "Error: Invalid --num_jobs value. Must be a positive integer."
show_help
return 1
fi
;;
--help)
show_help
return 1
;;
*)
echo "Error: Invalid argument or value specified."
show_help
return 1
;;
esac
done

# Determine the script's directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "Script location: $SCRIPT_DIR"

# Determine the parent directory of the script's directory
PARENT_DIR=$(dirname $(dirname "${SCRIPT_DIR}"))

# make lib directory to store all dependencies
LIB_DIR="$PARENT_DIR/lib"
mkdir -p "$LIB_DIR"

# Define FFTW directories
FFTW_SOURCE_DIR="$LIB_DIR/fftw-3.3.10"
FFTW_INSTALL_DIR="$LIB_DIR/fftw-3.3.10/install_fftw"
FFTW_BUILD_DIR="$LIB_DIR/fftw-3.3.10/build_fftw"

# Check if the 'fftw-3.3.10' directory exists in the lib directory; if not, clone it
if [ ! -d "$FFTW_SOURCE_DIR" ]; then
echo "Directory 'fftw' does not exist in '$LIB_DIR', downloading 'fftw'...."
wget -P "$LIB_DIR" "http://www.fftw.org/fftw-3.3.10.tar.gz"
tar -C "$LIB_DIR" -zxvf "$LIB_DIR/fftw-3.3.10.tar.gz"
else
echo "Directory 'fftw' exists in '$LIB_DIR', skipping 'fftw' download"
fi

# Check to avoid reinstalling FFTW which might take time
if [ -d "$FFTW_INSTALL_DIR" ]; then
echo "FFTW already installed, to reinstall FFTW delete $FFTW_INSTALL_DIR and $FFTW_BUILD_DIR"
return 0
fi

# Configure fftw
config_options=(
CFLAGS='-O3 -DNDEBUG -fPIC'
--prefix=${FFTW_INSTALL_DIR}
--enable-mpi
--enable-threads
--enable-openmp
#--enable-avx
#--enable-avx2
#--enable-avx512
)

current_dir=$(pwd)
# have to mkdir and cd because configure does not provide option for build_dir
mkdir -p "$FFTW_BUILD_DIR"
cd "$FFTW_BUILD_DIR"
# Run configure
"$FFTW_SOURCE_DIR/configure" "${config_options[@]}"

echo "Building double precision fftw..."
make -C "$FFTW_BUILD_DIR" -j"$num_jobs"

echo "Installing double precision fftw..."
make -C "$FFTW_BUILD_DIR" install

# cleanup before installing single precision
make distclean

# Configure for single precision
config_options+=(
--enable-float
)

# Run configure for single precision
"$FFTW_SOURCE_DIR/configure" "${config_options[@]}"

echo "Building single precision fftw..."
make -C "$FFTW_BUILD_DIR" -j"$num_jobs"

echo "Installing single precision fftw..."
make -C "$FFTW_BUILD_DIR" install

#cleanup
make distclean

cd "$current_dir"

echo "fftw installation complete."

Loading

0 comments on commit d02e43b

Please sign in to comment.