Skip to content
Open
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
10 changes: 8 additions & 2 deletions include/openmc/capi.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ int openmc_get_material_index(int32_t id, int32_t* index);
int openmc_get_mesh_index(int32_t id, int32_t* index);
int openmc_get_n_batches(int* n_batches, bool get_max_batches);
int openmc_get_nuclide_index(const char name[], int* index);
int openmc_add_unstructured_mesh(
const char filename[], const char library[], int* id);
int openmc_add_unstructured_mesh(const char filename[], const char library[],
double length_multiplier, const char options[], int32_t id, int32_t* index);
int64_t openmc_get_seed();
uint64_t openmc_get_stride();
int openmc_get_tally_index(int32_t id, int32_t* index);
Expand Down Expand Up @@ -140,12 +140,18 @@ int openmc_mesh_filter_get_translation(int32_t index, double translation[3]);
int openmc_mesh_filter_set_translation(int32_t index, double translation[3]);
int openmc_mesh_get_id(int32_t index, int32_t* id);
int openmc_mesh_set_id(int32_t index, int32_t id);
int openmc_mesh_get_name(int32_t index, const char** name);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's add some tests for these new functions in test_lib.py

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Implemented new tests that cover these

int openmc_mesh_set_name(int32_t index, const char* name);
int openmc_mesh_get_n_elements(int32_t index, size_t* n);
int openmc_mesh_get_volumes(int32_t index, double* volumes);
int openmc_mesh_material_volumes(int32_t index, int nx, int ny, int nz,
int max_mats, int32_t* materials, double* volumes, double* bboxes);
int openmc_meshsurface_filter_get_mesh(int32_t index, int32_t* index_mesh);
int openmc_meshsurface_filter_set_mesh(int32_t index, int32_t index_mesh);
int openmc_cylindrical_mesh_get_origin(int32_t index, double origin[3]);
int openmc_cylindrical_mesh_set_origin(int32_t index, const double origin[3]);
int openmc_spherical_mesh_get_origin(int32_t index, double origin[3]);
int openmc_spherical_mesh_set_origin(int32_t index, const double origin[3]);
int openmc_new_filter(const char* type, int32_t* index);
int openmc_next_batch(int* status);
int openmc_nuclide_name(int index, const char** name);
Expand Down
18 changes: 16 additions & 2 deletions include/openmc/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ class Mesh {

const std::string& name() const { return name_; }

void set_name(const std::string& name) { name_ = name; }

//! Set the mesh ID
void set_id(int32_t id = -1);

Expand Down Expand Up @@ -475,6 +477,16 @@ class PeriodicStructuredMesh : public StructuredMesh {
return r - origin_;
};

const Position& origin() const { return origin_; }

virtual int set_grid() = 0;

int set_origin(Position origin)
{
origin_ = origin;
return set_grid();
}

// Data members
Position origin_ {0.0, 0.0, 0.0}; //!< Origin of the mesh
};
Expand Down Expand Up @@ -832,7 +844,8 @@ class MOABMesh : public UnstructuredMesh {
MOABMesh() = default;
MOABMesh(pugi::xml_node);
MOABMesh(hid_t group);
MOABMesh(const std::string& filename, double length_multiplier = 1.0);
MOABMesh(const std::string& filename, double length_multiplier = 1.0,
const std::string& options = {});
MOABMesh(std::shared_ptr<moab::Interface> external_mbi);

static const std::string mesh_lib_type;
Expand Down Expand Up @@ -1002,7 +1015,8 @@ class LibMesh : public UnstructuredMesh {
// Constructors
LibMesh(pugi::xml_node node);
LibMesh(hid_t group);
LibMesh(const std::string& filename, double length_multiplier = 1.0);
LibMesh(const std::string& filename, double length_multiplier = 1.0,
const std::string& options = {});
LibMesh(libMesh::MeshBase& input_mesh, double length_multiplier = 1.0);

static const std::string mesh_lib_type;
Expand Down
3 changes: 3 additions & 0 deletions include/openmc/weight_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ class WeightWindows {
//! Ready the weight window class for use
void set_defaults();

//! Replace the energy grid with defaults for the selected particle type
void reset_energy_bounds();

//! Ensure the weight window lower bounds are properly allocated
void allocate_ww_bounds();

Expand Down
12 changes: 12 additions & 0 deletions openmc/checkvalue.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import copy
import os
from collections.abc import Iterable
from numbers import Real

import numpy as np

Expand Down Expand Up @@ -80,7 +81,18 @@ def check_iterable_type(name, value, expected_type, min_depth=1, max_depth=1):
max_depth : int
The maximum number of layers of nested iterables there should be before
reaching the ultimately contained items

Notes
-----
For NumPy floating-point arrays with an allowed number of dimensions, the
dtype guarantees the element type and the per-element scan is skipped when
*expected_type* is :class:`numbers.Real` or :class:`float`.
"""
if (isinstance(value, np.ndarray) and value.dtype.kind == 'f'
and min_depth <= value.ndim <= max_depth
and expected_type in (Real, float)):
return

# Initialize the tree at the very first item.
tree = [value]
index = [0]
Expand Down
Loading
Loading