Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ProfugusMC
ProfugusMC
Commits
2f892e67
Commit
2f892e67
authored
Mar 02, 2018
by
Hamilton, Steven P
Browse files
Adding new driver.
parent
eb80d641
Changes
6
Show whitespace changes
Inline
Side-by-side
packages/MC/CMakeLists.txt
View file @
2f892e67
...
...
@@ -127,7 +127,6 @@ SET(DRIVER_SOURCES
mc_driver/Manager_Builder.cc
mc_driver/Problem_Builder.pt.cc
mc_driver/Geometry_Builder.pt.cc
mc_driver/mc.cc
)
LIST
(
APPEND HEADERS
${
DRIVER_HEADERS
}
)
LIST
(
APPEND SOURCES
${
DRIVER_SOURCES
}
)
...
...
@@ -205,12 +204,19 @@ TRIBITS_ADD_EXECUTABLE(
INSTALLABLE
)
TRIBITS_ADD_EXECUTABLE
(
profugus
NOEXESUFFIX
NOEXEPREFIX
SOURCES mc_driver/profugus.cc
INSTALLABLE
)
##---------------------------------------------------------------------------##
# Add tests to this package
TRIBITS_ADD_TEST_DIRECTORIES
(
geometry/test
sim_ce/test
mc/test
)
IF
(
USE_CUDA
)
...
...
packages/MC/cmake/config.h.in
View file @
2f892e67
...
...
@@ -21,12 +21,6 @@
/* PARALLEL MPI ENVIRONMENT VARIABLES */
#include <Utils/config.h>
#ifdef COMM_MPI
#include "Epetra_MpiComm.h"
#else
#include "Epetra_SerialComm.h"
#endif
/* FORTRAN WRAPPERS */
#define FC_FUNC@F77_FUNC@
#define FC_FUNC_@F77_FUNC_@
...
...
packages/MC/mc_driver/Manager_Builder.cc
View file @
2f892e67
...
...
@@ -16,9 +16,6 @@
#include "geometry/RTK_Geometry.hh"
#include "geometry/Mesh_Geometry.hh"
#include "Teuchos_DefaultComm.hpp"
#include "Teuchos_XMLParameterListHelpers.hpp"
#ifdef USE_CUDA
#include "cuda_mc/Manager_Builder_Cuda.hh"
#endif
...
...
@@ -26,18 +23,9 @@
namespace
mc
{
auto
Manager_Builder
::
build
(
const
std
::
string
&
xml_file
)
->
SP_Manager_Base
auto
Manager_Builder
::
build
(
Teuchos
::
RCP
<
Teuchos
::
ParameterList
>
&
master
)
->
SP_Manager_Base
{
SCREEN_MSG
(
"Reading xml file -> "
<<
xml_file
);
// make the master parameterlist
auto
master
=
Teuchos
::
rcp
(
new
Teuchos
::
ParameterList
(
""
));
// read the data on every domain
auto
comm
=
Teuchos
::
DefaultComm
<
int
>::
getComm
();
Teuchos
::
updateParametersFromXmlFileAndBroadcast
(
xml_file
.
c_str
(),
master
.
ptr
(),
*
comm
);
SP_Manager_Base
manager
;
auto
problem_db
=
Teuchos
::
sublist
(
master
,
"PROBLEM"
);
...
...
packages/MC/mc_driver/Manager_Builder.hh
View file @
2f892e67
...
...
@@ -31,7 +31,7 @@ class Manager_Builder
typedef
std
::
shared_ptr
<
Manager_Base
>
SP_Manager_Base
;
static
SP_Manager_Base
build
(
const
std
::
string
&
xml_file
);
static
SP_Manager_Base
build
(
Teuchos
::
RCP
<
Teuchos
::
ParameterList
>
&
pl
);
//! Output messages in a common format.
#define SCREEN_MSG(stream) \
...
...
packages/MC/mc_driver/mc.cc
View file @
2f892e67
...
...
@@ -21,6 +21,9 @@
#include "Manager_Base.hh"
#include "Manager_Builder.hh"
#include "Teuchos_DefaultComm.hpp"
#include "Teuchos_XMLParameterListHelpers.hpp"
// Parallel specs.
int
node
=
0
;
int
nodes
=
0
;
...
...
@@ -111,8 +114,18 @@ int main(int argc, char *argv[])
try
{
std
::
cout
<<
"Reading XML file "
<<
xml_file
<<
std
::
endl
;
// build parameter list
auto
master
=
Teuchos
::
rcp
(
new
Teuchos
::
ParameterList
(
""
));
// read the data on every domain
auto
comm
=
Teuchos
::
DefaultComm
<
int
>::
getComm
();
Teuchos
::
updateParametersFromXmlFileAndBroadcast
(
xml_file
.
c_str
(),
master
.
ptr
(),
*
comm
);
// make the manager
auto
manager
=
mc
::
Manager_Builder
::
build
(
xml_file
);
auto
manager
=
mc
::
Manager_Builder
::
build
(
master
);
// solve the problem
manager
->
solve
();
...
...
packages/MC/mc_driver/profugus.cc
0 → 100644
View file @
2f892e67
//----------------------------------*-C++-*----------------------------------//
/*!
* \file mc_driver/profugus.cc
* \author Thomas M. Evans
* \date Wed Mar 12 22:24:55 2014
* \brief MC Mini-App executable.
* \note Copyright (C) 2014 Oak Ridge National Laboratory, UT-Battelle, LLC.
*/
//---------------------------------------------------------------------------//
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <Utils/config.h>
#include "harness/DBC.hh"
#include "comm/Timer.hh"
#include "comm/global.hh"
#include "comm/Timing_Diagnostics.hh"
#include "comm/P_Stream.hh"
#include "utils/Definitions.hh"
#include "Manager_Base.hh"
#include "Manager_Builder.hh"
#include "Teuchos_DefaultComm.hpp"
#include "Teuchos_XMLParameterListHelpers.hpp"
// Parallel specs.
int
node
=
0
;
int
nodes
=
0
;
//---------------------------------------------------------------------------//
// Print instructions on how to run the neutronics executable
void
print_usage
()
{
if
(
node
==
0
)
{
std
::
cout
<<
"Usage: profugus "
<<
std
::
endl
;
std
::
cout
<<
"Executes the profugus executable using N "
<<
"particle histories."
<<
std
::
endl
;
exit
(
1
);
}
}
//---------------------------------------------------------------------------//
// Parse the input arguments
std
::
tuple
<
std
::
string
,
def
::
size_type
>
parse_input_arguments
(
const
def
::
Vec_String
&
arguments
)
{
// First, search for "-h" or "--help"
if
(
std
::
find
(
arguments
.
begin
(),
arguments
.
end
(),
"-h"
)
!=
arguments
.
end
()
||
std
::
find
(
arguments
.
begin
(),
arguments
.
end
(),
"--help"
)
!=
arguments
.
end
())
{
print_usage
();
}
// Determine architecture
std
::
string
arch
=
"cpu"
;
auto
iter
=
std
::
find
(
arguments
.
begin
(),
arguments
.
end
(),
"-arch"
);
if
(
iter
==
arguments
.
end
()
||
iter
==
arguments
.
end
()
-
1
)
{
if
(
node
==
0
)
{
std
::
cout
<<
"Using default compute architecture "
<<
arch
<<
std
::
endl
;
}
}
else
{
arch
=
*
(
iter
+
1
);
if
(
arch
!=
"cpu"
&&
arch
!=
"gpu"
)
{
if
(
node
==
0
)
{
std
::
cout
<<
"Undefined arch "
<<
arch
<<
std
::
endl
<<
"Options are `cpu` or `gpu`."
<<
std
::
endl
;
}
exit
(
1
);
}
if
(
node
==
0
)
std
::
cout
<<
"Executing with arch = "
<<
arch
<<
std
::
endl
;
}
// Determine number of particles
def
::
size_type
Np
=
1e5
;
iter
=
std
::
find
(
arguments
.
begin
(),
arguments
.
end
(),
"-np"
);
if
(
iter
==
arguments
.
end
()
||
iter
==
arguments
.
end
()
-
1
)
{
if
(
node
==
0
)
{
std
::
cout
<<
"Using default particle count "
<<
Np
<<
std
::
endl
;
}
}
else
{
std
::
stringstream
np_stream
(
*
(
iter
+
1
));
np_stream
>>
Np
;
if
(
Np
<
0
)
{
if
(
node
==
0
)
{
std
::
cout
<<
"Invalid particle count "
<<
Np
<<
std
::
endl
<<
"Particle count must be positive."
<<
std
::
endl
;
}
exit
(
1
);
}
if
(
node
==
0
)
std
::
cout
<<
"Executing with Np = "
<<
Np
<<
std
::
endl
;
}
return
std
::
make_tuple
(
arch
,
1e6
);
}
//---------------------------------------------------------------------------//
int
main
(
int
argc
,
char
*
argv
[])
{
profugus
::
initialize
(
argc
,
argv
);
// start timing
profugus
::
global_barrier
();
profugus
::
Timer
timer
;
timer
.
start
();
// nodes
node
=
profugus
::
node
();
nodes
=
profugus
::
nodes
();
profugus
::
pcout
<<
"=======================================
\n
"
<<
" Profugus MC Mini-APP
\n
"
<<
" (C) ORNL, Battelle, 2014
\n
"
<<
"=======================================
\n
"
<<
profugus
::
endl
;
// process input arguments
def
::
Vec_String
arguments
(
argc
-
1
);
for
(
int
c
=
1
;
c
<
argc
;
c
++
)
{
arguments
[
c
-
1
]
=
argv
[
c
];
}
std
::
string
arch
;
def
::
size_type
Np
;
std
::
tie
(
arch
,
Np
)
=
parse_input_arguments
(
arguments
);
try
{
std
::
string
install_dir
=
CMAKE_INSTALL_PREFIX
;
std
::
string
data_dir
=
install_dir
+
"/data"
;
std
::
string
xml_file
=
data_dir
+
"/c5g7_3d.xml"
;
std
::
string
xs_file
=
data_dir
+
"/c5g7_252g.xml"
;
if
(
node
==
0
)
{
std
::
cout
<<
"Reading XML file "
<<
xml_file
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
;
}
// build parameter list
auto
master
=
Teuchos
::
rcp
(
new
Teuchos
::
ParameterList
(
""
));
// read the data on every domain
auto
comm
=
Teuchos
::
DefaultComm
<
int
>::
getComm
();
Teuchos
::
updateParametersFromXmlFileAndBroadcast
(
xml_file
.
c_str
(),
master
.
ptr
(),
*
comm
);
// Set Np on parameter list
auto
problem_db
=
Teuchos
::
sublist
(
master
,
"PROBLEM"
);
problem_db
->
set
(
"Np"
,
Np
);
// Set arch
problem_db
->
set
(
"arch"
,
arch
);
// Set cross section file
auto
mat_db
=
Teuchos
::
sublist
(
master
,
"MATERIAL"
);
mat_db
->
set
(
"xs library"
,
xs_file
);
// make the manager
auto
manager
=
mc
::
Manager_Builder
::
build
(
master
);
// solve the problem
manager
->
solve
();
// output
manager
->
output
();
}
catch
(
const
profugus
::
assertion
&
a
)
{
std
::
cout
<<
"Caught profugus assertion "
<<
a
.
what
()
<<
std
::
endl
;
exit
(
1
);
}
catch
(
const
std
::
exception
&
a
)
{
std
::
cout
<<
"Caught standard assertion "
<<
a
.
what
()
<<
std
::
endl
;
exit
(
1
);
}
catch
(...)
{
std
::
cout
<<
"Caught assertion of unknown origin."
<<
std
::
endl
;
exit
(
1
);
}
// process and output timing diagnostics
profugus
::
global_barrier
();
timer
.
stop
();
double
total
=
timer
.
TIMER_CLOCK
();
profugus
::
Timing_Diagnostics
::
report
(
std
::
cout
,
total
);
// output final timing
profugus
::
pcout
<<
"
\n
"
<<
"Total execution time : "
<<
profugus
::
scientific
<<
profugus
::
setprecision
(
4
)
<<
total
<<
" seconds."
<<
profugus
::
endl
;
profugus
::
finalize
();
return
0
;
}
//---------------------------------------------------------------------------//
// end of profugus.cc
//---------------------------------------------------------------------------//
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment