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

Expanded Test Suite Templated Input Models #251

Merged
merged 26 commits into from
Jan 29, 2016
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
05aba54
Removed unnecessary args for sector test
Jan 22, 2016
8d77a56
Added new options to store # tracks or segments in test suite.
Jan 22, 2016
04c0d39
Added fluxes for pin cell and simple lattice test suite problems
Jan 22, 2016
bfc6d42
Added homogeneous infinite medium test problem
Jan 22, 2016
7486857
Added 1D and 2D gradient test cases
Jan 23, 2016
dba18ab
Added README file for test suite
Jan 23, 2016
c3ba1d2
Now running tests with 1 and 4 thread configurations
Jan 23, 2016
c4e342c
This adds clang as a compiler to the test suite
Jan 23, 2016
01204fd
Added clang version to .travis.yml to debug Travis
Jan 23, 2016
229b08a
Removed clang from default build config for Travis
Jan 23, 2016
387f073
Refactored and simplified TestingHarness and added fixed source tests
Jan 23, 2016
ebf42ac
Added new adjoint mode tests
Jan 23, 2016
6c03127
Fixed thisown bug with Cmfd and added new CMFD test to suite
Jan 23, 2016
0718be7
Added class attribute to Test class to cache prevous build configurat…
Jan 24, 2016
ab6b9b6
Moved CMFD initialization from PWRAssemblyInput to CmfdPwrAssembyHarness
Jan 24, 2016
034bb04
Fixed merge conflicts with develop branch
Jan 24, 2016
53f61e9
Refactored to defer fixed source assignment by Cell or Material to FS…
Jan 24, 2016
ae13f20
Cleaned up deferred fixed source allocation to FSRs algorithm
Jan 24, 2016
b123445
Added commented out icpc tests to suite
Jan 24, 2016
cfd768e
Further consolidation of .gitignore file
Jan 25, 2016
64b2698
Merge remote-tracking branch 'upstream/develop' into input-sets
Jan 25, 2016
14492f5
Updated this per comments by @samuelshaner
Jan 25, 2016
121f5f5
Now hashing results for simple lattice test case
Jan 25, 2016
07c5f81
Seeting Cmfd.thisown use a boolean rather than integer
Jan 25, 2016
6cd64fd
Removed materials fomr Geometry::toString() to improve track binary f…
Jan 27, 2016
e55d1a3
Fixed typo with double starred comment
Jan 28, 2016
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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ openmoc/cuda/openmoc_cuda_wrap.cpp
# output files
log
tracks
tracks
plots
fission-rates
simulation-state
Expand Down Expand Up @@ -75,7 +74,7 @@ profile/models/homogeneous/homogeneous-one-group.o
# IPython Notebook
.ipynb_checkpoints/

# OpenMC input files
# OpenMC input/output files
*.xml
statepoint*
summary*
Expand Down
5 changes: 3 additions & 2 deletions openmoc/materialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,9 @@ def load_openmc_mgxs_lib(mgxs_lib, geometry=None):
# If the user filled multiple Cells with the same Material,
# the Material must be cloned for each unique Cell
if material != None:
old_materials[material.getId()] = material
material = material.clone()
if len(domains) > geometry.getNumMaterials():
old_materials[material.getId()] = material
material = material.clone()

# If the Cell does not contain a Material, create one for it
else:
Expand Down
18 changes: 18 additions & 0 deletions openmoc/thisown.i
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,21 @@

track_generator.thisown = False
%}


/* A Geometry owns the memory for its Cmfd (if any) */
%pythonappend Geometry::setCmfd %{
# SWIG 3
if 'cmfd' in locals():
cmfd = locals()['cmfd']
elif 'args' in locals() and 'cmfd' in locals()['args']:
cmfd = locals()['args']['cmfd']
elif 'kwargs' in locals() and 'cmfd' in locals()['kwargs']:
cmfd = locals()['kwargs']['cmfd']

# SWIG 2
else:
cmfd = locals()['args'][0]

cmfd.thisown = False
%}
2 changes: 1 addition & 1 deletion sample-input/benchmarks/c5g7/c5g7-3d-rodded-B.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@
geometry = openmoc.Geometry()
geometry.setRootUniverse(root_universe)
geometry.setCmfd(cmfd)
geometry.initializeFlatSourceRegions()


###############################################################################
######################## Creating the TrackGenerator ######################
Expand Down
101 changes: 41 additions & 60 deletions sample-input/ipython-notebook/mox-assembly.ipynb

Large diffs are not rendered by default.

62 changes: 39 additions & 23 deletions src/CPUSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,38 +194,54 @@ void CPUSolver::initializeSourceArrays() {
if (_fixed_sources != NULL)
delete [] _fixed_sources;

int size = _num_FSRs * _num_groups;

/* Allocate memory for all source arrays */
try{
int size = _num_FSRs * _num_groups;
_reduced_sources = new FP_PRECISION[size];
_fixed_sources = new FP_PRECISION[size];
}
catch(std::exception &e) {
log_printf(ERROR, "Could not allocate memory for FSR sources");
}

/* Initialize fixed sources to zero */
memset(_fixed_sources, 0.0, sizeof(FP_PRECISION) * size);
/* Initialize fixed sources to zero */
memset(_fixed_sources, 0.0, sizeof(FP_PRECISION) * size);

/* Populate fixed source array with any user-defined sources */
std::map< std::pair<int, int>, FP_PRECISION >::iterator iter;
std::pair<int, int> fsr_group_key;
int fsr_id, group;
for (iter = _fixed_sources_map.begin();
iter != _fixed_sources_map.end(); ++iter) {
fsr_group_key = iter->first;
fsr_id = fsr_group_key.first;
group = fsr_group_key.second;
/* Populate fixed source array with any user-defined sources */
initializeFixedSources();
}

if (group <= 0 || group > _num_groups)
log_printf(ERROR,"Unable to use fixed source for group %d in "
"a %d energy group problem", group, _num_groups);

if (fsr_id < 0 || fsr_id >= _num_FSRs)
log_printf(ERROR,"Unable to use fixed source for FSR %d with only "
"%d FSRs in the geometry", fsr_id, _num_FSRs);
/**
* @brief Populates array of fixed sources assigned by FSR.
*/
void CPUSolver::initializeFixedSources() {

_fixed_sources(fsr_id, group-1) = _fixed_sources_map[fsr_group_key];
}
}
catch(std::exception &e) {
log_printf(ERROR, "Could not allocate memory for FSR sources");
Solver::initializeFixedSources();

int fsr_id, group;
std::pair<int, int> fsr_group_key;
std::map< std::pair<int, int>, FP_PRECISION >::iterator fsr_iter;

/* Populate fixed source array with any user-defined sources */
for (fsr_iter = _fix_src_FSR_map.begin();
fsr_iter != _fix_src_FSR_map.end(); ++fsr_iter) {

/* Get the FSR with an assigned fixed source */
fsr_group_key = fsr_iter->first;
fsr_id = fsr_group_key.first;
group = fsr_group_key.second;

if (group <= 0 || group > _num_groups)
log_printf(ERROR,"Unable to use fixed source for group %d in "
"a %d energy group problem", group, _num_groups);

if (fsr_id < 0 || fsr_id >= _num_FSRs)
log_printf(ERROR,"Unable to use fixed source for FSR %d with only "
"%d FSRs in the geometry", fsr_id, _num_FSRs);

_fixed_sources(fsr_id, group-1) = _fix_src_FSR_map[fsr_group_key];
}
}

Expand Down
1 change: 1 addition & 0 deletions src/CPUSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class CPUSolver : public Solver {

void initializeFluxArrays();
void initializeSourceArrays();
void initializeFixedSources();
void initializeFSRs();

void zeroTrackFluxes();
Expand Down
49 changes: 39 additions & 10 deletions src/Geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,13 +749,15 @@ void Geometry::subdivideCells() {
* source iteration. This method first subdivides all Cells by calling
* the Geometry::subdivideCells() method. Then it initializes the CMFD
* object.
* @brief neighbor_cells whether to use neighbor cell optimizations
*/
void Geometry::initializeFSRs() {
void Geometry::initializeFSRs(bool neighbor_cells) {
/* Subdivide Cells into sectors and rings */
subdivideCells();

/* Build collections of neighbor Cells for optimized ray tracing */
_root_universe->buildNeighbors();
if (neighbor_cells)
_root_universe->buildNeighbors();
}


Expand Down Expand Up @@ -979,27 +981,54 @@ void Geometry::computeFissionability(Universe* univ) {

/**
* @brief Converts this Geometry's attributes to a character array.
* @details This method calls the toString() method for all Materials,
* Surfaces, Cell, Universes and Lattices contained by the Geometry.
* @details This method calls the toString() method for all Surfaces,
* Cells, Universes and Lattices contained by the Geometry.
* Since this routine provides the metadata used by the
* TrackGenerator to discriminate between geometries when
* exporting / importing binary track files.
* @return a character array of this Geometry's class attributes
*/
std::string Geometry::toString() {

std::stringstream string;

std::map<int, Cell*> all_cells = getAllCells();
std::map<int, Universe*> all_universes = getAllUniverses();
std::map<int, Cell*> cells = getAllCells();
std::map<int, Universe*> universes = getAllUniverses();
std::map<int, surface_halfspace*> surfaces;

std::map<int, Cell*>::iterator cell_iter;
std::map<int, Universe*>::iterator univ_iter;
std::map<int, surface_halfspace*>::iterator surf_iter;

/** Add string data for all Cells */
string << "\n\tCells:\n\t\t";
for (cell_iter = all_cells.begin(); cell_iter != all_cells.end(); ++cell_iter)
string << cell_iter->second->toString() << "\n\t\t";
for (cell_iter = cells.begin(); cell_iter != cells.end(); ++cell_iter) {
string << "Cell ID = " << cell_iter->second->getId();
string << ", name = " << cell_iter->second->getName();

if (cell_iter->second->isRotated()) {
string << ", (rotation = " << cell_iter->second->getPhi() << ", ";
string << cell_iter->second->getTheta() << ", ";
string << cell_iter->second->getPsi() << ")";
}
if (cell_iter->second->isTranslated()) {
double* translation = cell_iter->second->getTranslation();
string << ", (translation = " << translation[0] << ", ";
string << translation[1] << ", " << translation[2] << ")";
}

string << ", # surfaces = " << cell_iter->second->getNumSurfaces();

/** Add string data for the Surfaces in this Cell */
surfaces = cell_iter->second->getSurfaces();
string << ", Surfaces: ";
for (surf_iter = surfaces.begin(); surf_iter != surfaces.end(); ++surf_iter)
string << surf_iter->second->_surface->toString() << ", ";
}

/** Add string data for all Universes */
string << "\n\tUniverses:\n\t\t";
for (univ_iter = all_universes.begin();
univ_iter != all_universes.end(); ++univ_iter)
for (univ_iter = universes.begin(); univ_iter != universes.end(); ++univ_iter)
string << univ_iter->second->toString() << "\n\t\t";

std::string formatted_string = string.str();
Expand Down
2 changes: 1 addition & 1 deletion src/Geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Geometry {

/* Other worker methods */
void subdivideCells();
void initializeFSRs();
void initializeFSRs(bool neighbor_cells=false);
void segmentize(Track* track);
void initializeFSRVectors();
void computeFissionability(Universe* univ=NULL);
Expand Down
85 changes: 55 additions & 30 deletions src/Solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,23 +414,18 @@ void Solver::setConvergenceThreshold(FP_PRECISION threshold) {

/**
* @brief Assign a fixed source for a flat source region and energy group.
* @details This is a helper routine to perform error checking for the
* subclasses which store the source in the appropriate array.
* @param fsr_id the flat source region ID
* @param group the energy group
* @param source the volume-averaged source in this group
*/
void Solver::setFixedSourceByFSR(int fsr_id, int group, FP_PRECISION source) {
/* Insert fixed source into map */
_fixed_sources_map[std::pair<int, int>(fsr_id, group)] = source;
_fix_src_FSR_map[std::pair<int, int>(fsr_id, group)] = source;
}


/**
* @brief Assign a fixed source for a Cell and energy group.
* @details This routine will add the fixed source to all instances of the
* Cell in the geometry (e.g., all FSRs for this Cell).
* @param fsr_id the Cell of interest
* @param cell the Cell of interest
* @param group the energy group
* @param source the volume-averaged source in this group
*/
Expand All @@ -443,39 +438,20 @@ void Solver::setFixedSourceByCell(Cell* cell, int group, FP_PRECISION source) {
for (iter = cells.begin(); iter != cells.end(); ++iter)
setFixedSourceByCell(iter->second, group, source);
}

/* Aadd the source to all FSRs for this MATERIAL type Cell */
else {
Cell* fsr_cell;

for (int r=0; r < _num_FSRs; r++) {
fsr_cell = _geometry->findCellContainingFSR(r);
if (cell->getId() == fsr_cell->getId())
setFixedSourceByFSR(r, group, source);
}
}
else
_fix_src_cell_map[std::pair<Cell*, int>(cell, group)] = source;
}


/**
* @brief Assign a fixed source for a Material and energy group.
* @details This routine will add the fixed source to all instances of the
* Material in the geometry (e.g., all FSRs with this Material).
* @param fsr_id the Material of interest
* @param material the Material of interest
* @param group the energy group
* @param source the volume-averaged source in this group
*/
void Solver::setFixedSourceByMaterial(Material* material, int group,
FP_PRECISION source) {

Material* fsr_material;

/* Add the source to all FSRs for this Material */
for (int r=0; r < _num_FSRs; r++) {
fsr_material = _geometry->findFSRMaterial(r);
if (material->getId() == fsr_material->getId())
setFixedSourceByFSR(r, group, source);
}
_fix_src_material_map[std::pair<Material*, int>(material, group)] = source;
}


Expand Down Expand Up @@ -656,6 +632,55 @@ void Solver::countFissionableFSRs() {
}


/**
* @brief Assigns fixed sources assigned by Cell, Material to FSRs.
*/
void Solver::initializeFixedSources() {

Cell* fsr_cell;
Material* fsr_material;
int group;
FP_PRECISION source;
std::pair<Cell*, int> cell_group_key;
std::pair<Material*, int> mat_group_key;
std::map< std::pair<Cell*, int>, FP_PRECISION >::iterator cell_iter;
std::map< std::pair<Material*, int>, FP_PRECISION >::iterator mat_iter;

/** Fixed sources assigned by Cell */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for the double *?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, just a typo!

for (cell_iter = _fix_src_cell_map.begin();
cell_iter != _fix_src_cell_map.end(); ++cell_iter) {

/* Get the Cell with an assigned fixed source */
cell_group_key = cell_iter->first;
group = cell_group_key.second;
source = _fix_src_cell_map[cell_group_key];

/* Search for this Cell in all FSRs */
for (int r=0; r < _num_FSRs; r++) {
fsr_cell = _geometry->findCellContainingFSR(r);
if (cell_group_key.first->getId() == fsr_cell->getId())
setFixedSourceByFSR(r, group, source);
}
}

/** Fixed sources assigned by Material */
for (mat_iter = _fix_src_material_map.begin();
mat_iter != _fix_src_material_map.end(); ++mat_iter) {

/* Get the Material with an assigned fixed source */
mat_group_key = mat_iter->first;
group = mat_group_key.second;
source = _fix_src_material_map[mat_group_key];

for (int r=0; r < _num_FSRs; r++) {
fsr_material = _geometry->findFSRMaterial(r);
if (mat_group_key.first->getId() == fsr_material->getId())
setFixedSourceByFSR(r, group, source);
}
}
}


/**
* @brief Initializes a Cmfd object for acceleratiion prior to source iteration.
* @details Instantiates a dummy Cmfd object if one was not assigned to
Expand Down
9 changes: 8 additions & 1 deletion src/Solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,13 @@ class Solver {
FP_PRECISION* _fixed_sources;

/** A mapping of fixed sources keyed by the pair (FSR ID, energy group) */
std::map< std::pair<int, int>, FP_PRECISION > _fixed_sources_map;
std::map< std::pair<int, int>, FP_PRECISION > _fix_src_FSR_map;

/** A mapping of fixed sources keyed by the pair (Cell*, energy group) */
std::map< std::pair<Cell*, int>, FP_PRECISION > _fix_src_cell_map;

/** A mapping of fixed sources keyed by the pair (Material*, energy group) */
std::map< std::pair<Material*, int>, FP_PRECISION > _fix_src_material_map;

/** Ratios of source to total cross-section for each FSR and energy group */
FP_PRECISION* _reduced_sources;
Expand Down Expand Up @@ -231,6 +237,7 @@ class Solver {
virtual void initializeMaterials(solverMode mode=FORWARD);
virtual void initializeFSRs();
virtual void countFissionableFSRs();
virtual void initializeFixedSources();
virtual void initializeCmfd();

virtual void resetMaterials(solverMode mode=FORWARD);
Expand Down
Loading