Skip to content

Commit

Permalink
Merge branch 'add_tally' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
scopatz committed Apr 17, 2014
2 parents a2e3f4c + a080cde commit ae37f19
Show file tree
Hide file tree
Showing 9 changed files with 552 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cpp/CMakeLists.txt
Expand Up @@ -44,6 +44,13 @@ set_target_properties(pyne_enrichment PROPERTIES
target_link_libraries(pyne_enrichment pyne_material)
install_lib(pyne_enrichment)

# pyne_tally
add_library(pyne_tally tally.cpp)
set_target_properties(pyne_tally PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/pyne/lib")
install_lib(pyne_tally)


# Print include dir
get_property(inc_dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
message("-- C_INCLUDE_PATH for ${CMAKE_CURRENT_SOURCE_DIR}: ${inc_dirs}")
Expand Down
61 changes: 61 additions & 0 deletions cpp/tally.cpp
@@ -0,0 +1,61 @@
// Tally.cpp
// Central Tally Class
// -- Andrew Davis

#include <string>
#include <vector>

#ifndef PYNE_IS_AMALGAMATED
#include "tally.h"
#endif


/***************************/
/*** Protected Functions ***/
/***************************/

/// there are no protected functions currently
/// fool.

/************************/
/*** Public Functions ***/
/************************/

/*--- Constructors ---*/
pyne::Tally::Tally()
{
// Empty Tally Constructor
tally_type = "";
particle_name = "";
entity_id = -1;
entity_type = "";
entity_name = "";
}

pyne::Tally::Tally(std::string type, std::string part_name,
int ent, std::string ent_type,
std::string ent_name)
{
// Empty Tally Constructor
tally_type = type;
particle_name = part_name;
entity_id = ent;
entity_type = ent_type;
entity_name = ent_name;
}

// Destructor
pyne::Tally::~Tally()
{
};

/*--- Method definitions ---*/

std::ostream& operator<<(std::ostream& os, pyne::Tally tal)
{
//print the Tally to ostream
os << "\t---------\n";
os << "\t Tallying " << tal.particle_name << " " << tal.tally_type << "\n";
os << "\t in/on " << tal.entity_type << " " << tal.entity_id << "\n";
return os;
};
65 changes: 65 additions & 0 deletions cpp/tally.h
@@ -0,0 +1,65 @@
#ifndef PYNE_IQ4M73STINHJDPRV6KWUZZXOYE
#define PYNE_IQ4M73STINHJDPRV6KWUZZXOYE
/// \file tally.h
/// \author Andrew Davis (davisa\@engr.wisc.edu)
///
/// \brief The tally class and helper functions
///
/// The tally class is in essesence a structure containing attributes
/// related to tallies

#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <set>
#include <stdio.h>
#include <stdlib.h>

namespace pyne
{
class Tally
{
public:
// Tally Constructors
Tally (); ///< empty constructor

/// Constructor from passed in vars
/// \param type the type of tally (flux or current)
/// \param particle_name the name of the particle type
/// \param entity the entity id of the tally (eg. surface index,
/// volume number)
/// \param entity_type (volume or surface)
/// \param entity_name string identifying the entity
Tally(std::string type, std::string particle_name, int entity,
std::string entity_type, std::string entity_name);

~Tally (); ///< default destructor

// fundamental tally variables
std::string entity_type; // the type of entity (volume,surface)
std::string entity_name; // the name of the entity (optional)
std::string particle_name; // particle name string
std::string tally_type; // type of tally flux or current
int entity_id; // id number of the entity being tallied upon
};

/// Converts a Tally to a string stream representation.
std::ostream& operator<< (std::ostream& os, Tally tally);


/// A stuct for reprensenting fundemental data in a tally
/// Maybe Useful for HDF5 representations.
/// following scoptaz's lead here
typedef struct tally_struct {
std::string tally_type;
std::string particle_name;
int entity_id;
std::string entity_type;
std::string entity_name;
} tally_struct;

// End pyne namespace
};

#endif
6 changes: 6 additions & 0 deletions pyne/CMakeLists.txt
Expand Up @@ -90,3 +90,9 @@ set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/enrichment.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(enrichment enrichment.pyx)
target_link_libraries(enrichment pyne_enrichment pyne_material)

# tally
set_source_files_properties("${PROJECT_SOURCE_DIR}/pyne/tally.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(tally tally.pyx)
target_link_libraries(tally pyne pyne_tally)
38 changes: 38 additions & 0 deletions pyne/cpp_tally.pxd
@@ -0,0 +1,38 @@
################################################
# WARNING! #
# This file has been auto-generated by xdress. #
# Do not modify!!! #
# #
# #
# Come on, guys. I mean it! #
################################################


from libcpp.string cimport string as std_string

cdef extern from "tally.h" namespace "pyne":

cdef cppclass Tally:
# constructors
Tally() except +
Tally(std_string) except +
Tally(std_string, std_string) except +
Tally(std_string, std_string, int) except +
Tally(std_string, std_string, int, std_string) except +
Tally(std_string, std_string, int, std_string, std_string) except +

# attributes
int entity_id
std_string entity_name
std_string entity_type
std_string particle_name
std_string tally_type

# methods

pass




{'cpppxd_footer': '', 'pyx_header': '', 'pxd_header': '', 'pxd_footer': '', 'cpppxd_header': '', 'pyx_footer': ''}
23 changes: 23 additions & 0 deletions pyne/tally.pxd
@@ -0,0 +1,23 @@
################################################
# WARNING! #
# This file has been auto-generated by xdress. #
# Do not modify!!! #
# #
# #
# Come on, guys. I mean it! #
################################################


from pyne cimport cpp_tally



cdef class Tally:
cdef void * _inst
cdef public bint _free_inst
pass




{'cpppxd_footer': '', 'pyx_header': '', 'pxd_header': '', 'pxd_footer': '', 'cpppxd_header': '', 'pyx_footer': ''}

0 comments on commit ae37f19

Please sign in to comment.