diff --git a/export_dagmc_cmd/DAGMCExportCommand.cpp b/export_dagmc_cmd/DAGMCExportCommand.cpp index 5907c6493..99f89ddfb 100644 --- a/export_dagmc_cmd/DAGMCExportCommand.cpp +++ b/export_dagmc_cmd/DAGMCExportCommand.cpp @@ -25,6 +25,9 @@ #include "moab/Interface.hpp" #include "moab/GeomTopoTool.hpp" +// DAGMC includes +#include "uwuw_preprocessor.hpp" + #define CHK_MB_ERR_RET(A,B) if (moab::MB_SUCCESS != (B)) { \ message << (A) << (B) << std::endl; \ CubitInterface::get_cubit_message_handler()->print_message(message.str().c_str()); \ @@ -46,6 +49,9 @@ DAGMCExportCommand::DAGMCExportCommand() : verbose_warnings = false; fatal_on_curves = false; + pyne_mat_lib = ""; + hdf5_path = "/materials"; + CubitMessageHandler *console = CubitInterface::get_cubit_message_handler(); if (console) { std::ostringstream load_message; @@ -70,6 +76,8 @@ std::vector DAGMCExportCommand::get_syntax() "[length_tolerance '>] " "[normal_tolerance '>] " "[make_watertight]" + "[pyne_mat_lib '>]" + "[hdf5_path '>]" "[verbose] [fatal_on_curves]"; std::vector syntax_list; @@ -156,6 +164,31 @@ bool DAGMCExportCommand::execute(CubitCommandData &data) rval = mdbImpl->write_file(filename.c_str()); CHK_MB_ERR_RET("Error writing file: ",rval); + + // if a PyNE material library is provided then try to process the mats + if(pyne_mat_lib != "") { + bool fatal_errors = false; + + uwuw_preprocessor* uwuw_preproc = new uwuw_preprocessor(pyne_mat_lib, mdbImpl, filename, hdf5_path, true, fatal_errors); + std::cout << __FILE__ << " : " << __LINE__ << std::endl; + // process the materials + uwuw_preproc->process_materials(); + std::cout << __FILE__ << " : " << __LINE__ << std::endl; + + // process the tallies + uwuw_preproc->process_tallies(); + std::cout << __FILE__ << " : " << __LINE__ << std::endl; + + // write the material data + uwuw_preproc->write_uwuw_materials(); + std::cout << __FILE__ << " : " << __LINE__ << std::endl; + + // write the tally data + uwuw_preproc->write_uwuw_tallies(); + std::cout << __FILE__ << " : " << __LINE__ << std::endl; + + } + rval = teardown(); CHK_MB_ERR_RET("Error tearing down export command.",rval); @@ -191,7 +224,27 @@ moab::ErrorCode DAGMCExportCommand::parse_options(CubitCommandData &data, moab:: verbose_warnings = data.find_keyword("verbose"); fatal_on_curves = data.find_keyword("fatal_on_curves"); make_watertight = data.find_keyword("make_watertight"); - + + // read parsed command for normal tolerance + data.get_string("pyne_mat_lib", pyne_mat_lib); + if (pyne_mat_lib != "") { + message << "Looking for the PyNE material Lib in " << pyne_mat_lib << std::endl; + data.get_string("hdf5_path",hdf5); + if (hdf5 != "") { + hdf5_path = hdf5; + } else { + message << "hdf5 path not provided, falling back on default path" + << std::endl; + } + + message << "hdf5 path set to " << hdf5 << std::endl; + } + else { + message + << "No Material Library set, material assignments will not be processed" + << std::endl; + } + if (verbose_warnings && fatal_on_curves) message << "This export will fail if curves fail to facet" << std::endl; diff --git a/export_dagmc_cmd/DAGMCExportCommand.hpp b/export_dagmc_cmd/DAGMCExportCommand.hpp index 29ce1e636..966c19fc2 100644 --- a/export_dagmc_cmd/DAGMCExportCommand.hpp +++ b/export_dagmc_cmd/DAGMCExportCommand.hpp @@ -70,7 +70,11 @@ class DAGMCExportCommand: public CubitCommand bool verbose_warnings; bool fatal_on_curves; bool make_watertight; - + std::string pyne_mat_lib; + std::string hdf5_path; + std::string hdf5; + + int failed_curve_count; std::vector failed_curves; diff --git a/script/build_plug_linux.sh b/script/build_plug_linux.sh new file mode 100755 index 000000000..afd0dfd1d --- /dev/null +++ b/script/build_plug_linux.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +SCRIPTPATH=`dirname $(dirname $(realpath $0))` +docker run -v "$SCRIPTPATH:/Trelis-plugin" -v "$2:/Trelis-sdk" -it $1 bash -c "/Trelis-plugin/script/build_plugin.sh $3; bash" diff --git a/script/build_plugin.sh b/script/build_plugin.sh new file mode 100755 index 000000000..15bbddc20 --- /dev/null +++ b/script/build_plugin.sh @@ -0,0 +1,119 @@ +#!/bin/bash + +cd /Trelis-sdk +dpkg -i Trelis-$1-Lin64.deb + +cd /opt +tar -xzvf /Trelis-sdk/Trelis-SDK-$1-Lin64.tar.gz +cd /opt/Trelis-16.5 +tar -xzvf /Trelis-sdk/Trelis-SDK-$1-Lin64.tar.gz + +apt-get update -y +apt-get install -y autogen autoconf libtool libeigen3-dev libhdf5-dev patchelf gfortran git cmake + +cd + +# Setup +CURRENT=$(pwd) +SCRIPTPATH=`dirname $(dirname $(realpath $0))` + +PLUGIN_DIR="plugin-build" + +mkdir ${PLUGIN_DIR} +PLUGIN_ABS_PATH=${CURRENT}/${PLUGIN_DIR} + +echo "Building the Trelis plugin in ${CURRENT}\\${PLUGIN_DIR}" + +unset LD_LIBRARY_PATH + +cd ${PLUGIN_ABS_PATH} +ln -s $SCRIPTPATH/ ./ + +mkdir -pv moab/bld +cd moab +git clone https://bitbucket.org/fathomteam/moab -b Version5.1.0 +cd moab +autoreconf -fi +cd ../bld +../moab/configure CXXFLAGS=-D_GLIBCXX_USE_CXX11_ABI=0 \ + --disable-blaslapack \ + --enable-shared \ + --enable-optimize \ + --disable-debug \ + --disable-blaslapack \ + --with-eigen3=/usr/include/eigen3 \ + --with-hdf5=/usr/lib/x86_64-linux-gnu/hdf5/serial \ + --prefix=${PLUGIN_ABS_PATH}/moab +make -j`grep -c processor /proc/cpuinfo` +make install + +cd ${PLUGIN_ABS_PATH} +mkdir -pv DAGMC/bld +cd DAGMC +git clone https://github.com/bam241/DAGMC -b preproc_plugin +cd bld +cmake ../DAGMC -DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0 \ + -DMOAB_DIR=${PLUGIN_ABS_PATH}/moab \ + -DBUILD_UWUW=ON \ + -DBUILD_TALLY=OFF \ + -DBUILD_BUILD_OBB=OFF \ + -DBUILD_MAKE_WATERTIGHT=ON \ + -DBUILD_SHARED_LIBS=ON \ + -DBUILD_STATIC_LIBS=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=${PLUGIN_ABS_PATH}/DAGMC +make -j`grep -c processor /proc/cpuinfo` +make install + + +cd ${PLUGIN_ABS_PATH}/Trelis-plugin +git submodule update --init + +cd ${PLUGIN_ABS_PATH} +mkdir -pv bld +cd bld +ls /opt/Trelis-${1::4} +ls /opt/Trelis-* +ls /opt +cmake ../Trelis-plugin -DCUBIT_ROOT=/opt/Trelis-${1::4} \ + -DDAGMC_DIR=${PLUGIN_ABS_PATH}/DAGMC \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=${PLUGIN_ABS_PATH} +make -j`grep -c processor /proc/cpuinfo` +make install +echo " cmake ../Trelis-plugin -DCubit_DIR=/opt/Trelis-${1::4} \ + -DCUBIT_ROOT=/opt/Trelis-${1::4} \ + -DDAGMC_DIR=${PLUGIN_ABS_PATH}/DAGMC \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=${PLUGIN_ABS_PATH} " + +cd ${PLUGIN_ABS_PATH} +mkdir -p pack/bin/plugins/svalinn +cd pack/bin/plugins/svalinn + +# Copy all needed libraries into current directory +cp -pPv ${PLUGIN_ABS_PATH}/lib/* . +cp -pPv ${PLUGIN_ABS_PATH}/moab/lib/libMOAB.so* . +cp -pPv ${PLUGIN_ABS_PATH}/DAGMC/lib/libdagmc.so* . +cp -pPv ${PLUGIN_ABS_PATH}/DAGMC/lib/libmakeWatertight.so* . +cp -pPv ${PLUGIN_ABS_PATH}/DAGMC/lib/libpyne_dagmc.so . +cp -pPv ${PLUGIN_ABS_PATH}/DAGMC/lib/libuwuw.so . +cp -pPv /usr/lib/x86_64-linux-gnu/libhdf5_serial.so.100* . +chmod 644 * + +# Set the RPATH to be the current directory for the DAGMC libraries +patchelf --set-rpath /opt/Trelis-${1::4}/bin/plugins/svalinn libMOAB.so +patchelf --set-rpath /opt/Trelis-${1::4}/bin/plugins/svalinn libdagmc.so +patchelf --set-rpath /opt/Trelis-${1::4}/bin/plugins/svalinn libmakeWatertight.so +patchelf --set-rpath /opt/Trelis-${1::4}/bin/plugins/svalinn libpyne_dagmc.so +patchelf --set-rpath /opt/Trelis-${1::4}/bin/plugins/svalinn libuwuw.so + +# Create the Svalinn plugin tarball +cd .. +ln -sv svalinn/libsvalinn_plugin.so . +cd ../.. +tar --sort=name -czvf svalinn-plugin_linux_$1.tgz bin +mv -v svalinn-plugin_linux_$1.tgz /Trelis-sdk +cd .. +rm -rf pack bld DAGMC lib moab +rm Trelis-plugin