Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embedding the uwuw preprocessing in the plugin #62

Draft
wants to merge 23 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 54 additions & 1 deletion export_dagmc_cmd/DAGMCExportCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()); \
Expand All @@ -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;
Expand All @@ -70,6 +76,8 @@ std::vector<std::string> DAGMCExportCommand::get_syntax()
"[length_tolerance <value:label='length_tolerance',help='<length tolerance>'>] "
"[normal_tolerance <value:label='normal_tolerance',help='<normal tolerance>'>] "
"[make_watertight]"
"[pyne_mat_lib <string:label='pyne_mat_lib',help='<pyne_mat_lib>'>]"
"[hdf5_path <string:label='hdf5_path',help='<hdf5_path>'>]"
"[verbose] [fatal_on_curves]";

std::vector<std::string> syntax_list;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;

Expand Down
6 changes: 5 additions & 1 deletion export_dagmc_cmd/DAGMCExportCommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> failed_curves;

Expand Down
4 changes: 4 additions & 0 deletions script/build_plug_linux.sh
Original file line number Diff line number Diff line change
@@ -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"
119 changes: 119 additions & 0 deletions script/build_plugin.sh
Original file line number Diff line number Diff line change
@@ -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