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

Fixed to reflect FLUKA-CERN #677

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
6 changes: 3 additions & 3 deletions cmake/FindFluka.cmake
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
find_path(FLUKA_LIBRARIES
NAMES libflukahp.a
HINTS ${FLUKA_DIR}
NAMES libfluka.a
HINTS ${FLUKA_DIR} ${FLUKA_DIR}/lib
PATHS ENV FLUKA_DIR
NO_DEFAULT_PATH
)
if (FLUKA_LIBRARIES)
get_filename_component(FLUKA_LIBRARIES ${FLUKA_LIBRARIES} ABSOLUTE)
endif ()

set(FLUKA_LIBRARIES ${FLUKA_LIBRARIES}/libflukahp.a gfortran)
set(FLUKA_LIBRARIES ${FLUKA_LIBRARIES}/libfluka.a gfortran)

message(STATUS "FLUKA_LIBRARIES: ${FLUKA_LIBRARIES}")

Expand Down
6 changes: 5 additions & 1 deletion doc/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Next version
**Changed:**

* Update hdf5 to v1.14.3 from v1.10.4 (#931 #933)
* Ensure implicit complement handle is placed at the back of DAGMC volume indices (#935)
* Update MOAB to 5.5.1 from 5.3.0 (#939 #940)
* Update README regarding OpenMC (#938)
* Simplify Housekeeping Process for DAGMC (#943)
Expand All @@ -19,6 +18,11 @@ Next version
* Streamline dependencies of docker CI images (#951 #952)
* Update github actions to newer versions as necessary (#958)

**Fixed:**

* Ensure implicit complement handle is placed at the back of DAGMC volume indices (#935)
* Fixed to reflect FLUKA-CERN (#677)

v3.2.3
====================

Expand Down
21 changes: 13 additions & 8 deletions doc/install/fludag.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,24 @@ Install FLUKA
~~~~~~~~~~~~~

FluDAG uses FLUKA_ from CERN/INFN. In order to download FLUKA you need to become
a registered user, which you can do at the `FLUKA registration
<FLUKA_register_>`_ page.
a registered user, which you can do at the `FLUKA-INFN registration
<FLUKA_infn_register_>`_ page for FLUKA-INFN and `FLUKA-CERN registration page <FLUKA_cern_register>`_.

Save your user ID and password for future FLUKA updates. We recommend an x64
worfklow and thus you should download the 64-bit executable. The name of the
downloaded tarball is of the form ``fluka20xx.xx-linux-gfor64bitAA.tar.gz``.
Refer to the `installation instructions <FLUKA_install_>`_ when building FLUKA.
worfklow and thus you should download the 64-bit executable. For FLUKA-INFN, the
name of the downloaded tarball is of the form ``fluka20xx.xx-linux-gfor64bitAA.tar.gz``.
Refer to the `installation instructions <FLUKA_infn_install_>`_ when building FLUKA.

For FLUKA-CERN, x64 is the only option and refer to `installation instructions <FLUKA_cern_install_>`_

Take care to follow the FLUKA site instructions when setting the ``$FLUPRO`` and
``$FLUFOR`` environment variables.

.. include:: configure_dag-code_header.txt

The following CMake command will build FluDAG. Note that ``$FLUPRO`` should have
previously been defined as part of the FLUKA install.
previously been defined as part of the FLUKA install. FLUPRO can also be set explictly
to the base path of FLUKA, for example ``/home/user/fluka-cern/fluka4.01``
::

$ cmake ../src -DMOAB_DIR=$HOME/dagmc_bld/MOAB \
Expand Down Expand Up @@ -60,5 +63,7 @@ like this:
.. include:: test_dagmc.txt

.. _FLUKA: http://www.fluka.org/fluka.php
.. _FLUKA_register: https://www.fluka.org/fluka.php?id=secured_intro
.. _FLUKA_install: http://www.fluka.org/fluka.php?id=ins_run
.. _FLUKA_infn_register: https://www.fluka.org/fluka.php?id=secured_intro
.. _FLUKA_cern_register: https://fluka.cern/home
.. _FLUKA_infn_install: http://www.fluka.org/fluka.php?id=ins_run
.. _FLUKA_cern_install: https://fluka.cern/documentation/installation
4 changes: 2 additions & 2 deletions doc/usersguide/codes/fludag.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ material assignment data from the CAD geometry we must first
subsequently-defined geometry file, the user must produce the ``mat.inp`` file.
::

$ /path/to/fludag/executable/mainfludag geom.h5m
$ /path/to/fludag/executable/mainfludag --dagmc geom.h5m

This will load the named .h5m file and produce the material assignment
information. This information should then be pasted into the FLUKA input file,
Expand All @@ -165,5 +165,5 @@ geometry file to a fixed file called ``dagmc.h5m``.
The problem can then be run with
::

$ $FLUPRO/flutil/rfluka -e <path/to/fludag/executable/mainfludag> \
$ rfluka -e <path/to/fludag/executable/mainfludag> \
++{standard fluka options}++ <fludag_input_file>
2 changes: 1 addition & 1 deletion doc/usersguide/uw2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ run the ``mainfludag`` executable to produce the ``mat.inp`` file which contains
all the detailed material assignments and compound descriptions.
::

$ mainfludag geom.h5m
$ mainfludag --dagmc geom.h5m

The user should then paste the contents of ``mat.inp`` into the main FLUKA input
deck. Now the user must make a symbolic link to the geometry file named
Expand Down
16 changes: 16 additions & 0 deletions news/PR-0677.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
**Added:**
Fixes to allow compilation against FLUKA-CERN

**Changed:**

- Fixes to allow compilation against FLUKA-CERN

**Deprecated:** None

**Removed:** None

**Fixed:**

Now allows compilation against FLUKA-CERN

**Security:** None
74 changes: 50 additions & 24 deletions src/fluka/app/mainFluDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
* \brief Functions called by fluka
* \note Unittested
*/
//--------------------------ß-------------------------//
//----------------------------------------------------//
#include <time.h> // for timing the routine

#include <cstdlib>
#include <cstring>
#include <fstream>

//---------------------------------------------------------------------------//
#include "DagMC.hpp"
#include "dagmcmetadata.hpp"
#include "fluka_funcs.h"
#include "moab/ProgOptions.hpp"

#define flukam flukam_

Expand All @@ -39,37 +42,40 @@ int main(int argc, char* argv[]) {

// Default h5m filename is for fluka runs
std::string infile = "dagmc.h5m";

if (argc == 1) { // then its a fluka run
// fluka creates a run dir one lvl higher
infile = "../" + infile;
std::string dagmc_file = "";

// form the inputs and determine if this is a true calculation or a preprocess
// run
ProgOptions po("mainfludag: a DAGMC enabled version of FLUKA-CERN");
po.addOpt<std::string>("dagmc", "Path to h5m DAGMC file to proccess",
&dagmc_file);
po.addOptionalArgs<std::string>(0, "", "");
po.parseCommandLine(argc, argv);

// if no string has been provided, dagmc command not applied
// we assume that its a FLUKA run
if (dagmc_file.empty()) {
flukarun = true;
} else if (argc > 2) {
std::cout << "run as main_fludag <facet_file> to produce"
<< " material assignments" << std::endl;
std::cout << "too many arguments provided" << std::endl;
exit(1);
} else { // its a pre process run
infile = argv[1]; // must be the 2nd argument
// fluka creates a run dir one lvl higher than cwd
infile = "../" + infile;
} else {
// dagmc command has been set do the its a process run
infile = dagmc_file;
}

// test to see if the file exists
std::ifstream h5mfile(infile.c_str()); // filestream for mesh geom
if (!h5mfile.good()) {
std::cout << "h5m file does not exist" << std::endl;
exit(1);
}

int max_pbl = 1;

// get the current time
time(&time_before); /* get current time; same as: timer = time(NULL) */

// DAG call to load the file
std::cout << "Loading the faceted geometry file " << infile << "..."
<< std::endl;
error = DAG->load_file(
infile.c_str()); // load the dag file takeing the faceting from h5m

if (error != moab::MB_SUCCESS) {
std::cerr << "DAGMC failed to read input file: " << infile << std::endl;
exit(EXIT_FAILURE);
Expand All @@ -79,9 +85,7 @@ int main(int argc, char* argv[]) {

double seconds = difftime(
time_after, time_before); // get the time in seconds to load file

time_before = time_after; // reset time to now for the next call

time_before = time_after; // reset time to now for the next call
std::cout << "Time to load the h5m file = " << seconds << " seconds"
<< std::endl;

Expand All @@ -92,21 +96,22 @@ int main(int argc, char* argv[]) {
error = DAG->init_OBBTree();
} else {
// otherwise this is a preprocess run
// no need to build the tree
// no need to build the tree - its faster
error = DAG->setup_impl_compl();
error = DAG->setup_indices();
}

// check
if (error != moab::MB_SUCCESS) {
std::cerr << "DAGMC failed to initialize geometry and create OBB tree"
<< std::endl;
exit(EXIT_FAILURE);
}

time(&time_after);

seconds = difftime(time_after, time_before);
std::cout << "Time to initialise the geometry" << seconds << std::endl;

// if fluka preprocess run then create mat file to paste into input deck
if (!flukarun) {
std::string lcad = "mat.inp";
Expand All @@ -119,8 +124,29 @@ int main(int argc, char* argv[]) {
fludag_write_ididx(vol_id);
} else {
// call fluka run
// flugg mode is flag = 1
const int flag = 1;

// check for the input file argument
// get it from the command line
if (argc >= 1) {
// convert to std::string
std::string chinpf_s(argv[1]);
char chinpf[256] = "";
memset(chinpf, ' ', 256);
std::copy(chinpf_s.begin(), chinpf_s.end(), chinpf);
strcpy(chcmpt_.chinpf, chinpf);
} else {
// get it from the environment
std::cout << "from env" << std::endl;
char* env = std::getenv("INPF");
std::cout << env << std::endl;
strncpy(env, chcmpt_.chinpf, sizeof(env));
if (chcmpt_.chinpf[0] == 0) {
// flabrt("FLUKAM","FLUDAG NO INPUT SPECIFIED");
return 1;
}
}
const int flag = 2;
std::cout << "running fluka" << std::endl;
flukam(flag);
}

Expand Down
18 changes: 18 additions & 0 deletions src/fluka/fluka_funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,24 @@ extern struct {
} mulbou_;
}

// the CHCMPT struct for
// setting the input name
extern "C" {
extern struct {
char comptr[50];
char inpfil[200];
char pwddir[200];
char hlfdir[200];
char homdir[200];
char hostnm[200];
char usrflk[200];
char grpflk[200];
char inpnam[200];
char chinpf[256];
char hfpath[200];
} chcmpt_;
}

// struct to hold particle state
struct particle_state {
moab::DagMC::RayHistory history;
Expand Down
Loading