Skip to content

Commit c31032c

Browse files
GuyStenpshriwise
andauthored
load mesh objects from weight_windows.h5 file (#3598)
Co-authored-by: Patrick Shriwise <pshriwise@gmail.com>
1 parent 3ac5d6f commit c31032c

5 files changed

Lines changed: 576 additions & 71 deletions

File tree

include/openmc/mesh.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,14 @@ class Mesh {
132132
// Constructors and destructor
133133
Mesh() = default;
134134
Mesh(pugi::xml_node node);
135+
Mesh(hid_t group);
135136
virtual ~Mesh() = default;
136137

138+
// Factory method for creating meshes from either an XML node or HDF5 group
139+
template<typename T>
140+
static const std::unique_ptr<Mesh>& create(
141+
T dataset, const std::string& mesh_type, const std::string& mesh_library);
142+
137143
// Methods
138144
//! Perform any preparation needed to support point location within the mesh
139145
virtual void prepare_for_point_location() {};
@@ -258,6 +264,7 @@ class StructuredMesh : public Mesh {
258264
public:
259265
StructuredMesh() = default;
260266
StructuredMesh(pugi::xml_node node) : Mesh {node} {};
267+
StructuredMesh(hid_t group) : Mesh {group} {};
261268
virtual ~StructuredMesh() = default;
262269

263270
using MeshIndex = std::array<int, 3>;
@@ -423,6 +430,7 @@ class PeriodicStructuredMesh : public StructuredMesh {
423430
public:
424431
PeriodicStructuredMesh() = default;
425432
PeriodicStructuredMesh(pugi::xml_node node) : StructuredMesh {node} {};
433+
PeriodicStructuredMesh(hid_t group) : StructuredMesh {group} {};
426434

427435
Position local_coords(const Position& r) const override
428436
{
@@ -442,6 +450,7 @@ class RegularMesh : public StructuredMesh {
442450
// Constructors
443451
RegularMesh() = default;
444452
RegularMesh(pugi::xml_node node);
453+
RegularMesh(hid_t group);
445454

446455
// Overridden methods
447456
int get_index_in_direction(double r, int i) const override;
@@ -481,6 +490,8 @@ class RegularMesh : public StructuredMesh {
481490
//! Return the volume for a given mesh index
482491
double volume(const MeshIndex& ijk) const override;
483492

493+
int set_grid();
494+
484495
// Data members
485496
double volume_frac_; //!< Volume fraction of each mesh element
486497
double element_volume_; //!< Volume of each mesh element
@@ -492,6 +503,7 @@ class RectilinearMesh : public StructuredMesh {
492503
// Constructors
493504
RectilinearMesh() = default;
494505
RectilinearMesh(pugi::xml_node node);
506+
RectilinearMesh(hid_t group);
495507

496508
// Overridden methods
497509
int get_index_in_direction(double r, int i) const override;
@@ -534,6 +546,7 @@ class CylindricalMesh : public PeriodicStructuredMesh {
534546
// Constructors
535547
CylindricalMesh() = default;
536548
CylindricalMesh(pugi::xml_node node);
549+
CylindricalMesh(hid_t group);
537550

538551
// Overridden methods
539552
virtual MeshIndex get_indices(Position r, bool& in_mesh) const override;
@@ -598,6 +611,7 @@ class SphericalMesh : public PeriodicStructuredMesh {
598611
// Constructors
599612
SphericalMesh() = default;
600613
SphericalMesh(pugi::xml_node node);
614+
SphericalMesh(hid_t group);
601615

602616
// Overridden methods
603617
virtual MeshIndex get_indices(Position r, bool& in_mesh) const override;
@@ -668,6 +682,7 @@ class UnstructuredMesh : public Mesh {
668682
// Constructors
669683
UnstructuredMesh() { n_dimension_ = 3; };
670684
UnstructuredMesh(pugi::xml_node node);
685+
UnstructuredMesh(hid_t group);
671686

672687
static const std::string mesh_type;
673688
virtual std::string get_mesh_type() const override;
@@ -774,6 +789,7 @@ class MOABMesh : public UnstructuredMesh {
774789
// Constructors
775790
MOABMesh() = default;
776791
MOABMesh(pugi::xml_node);
792+
MOABMesh(hid_t group);
777793
MOABMesh(const std::string& filename, double length_multiplier = 1.0);
778794
MOABMesh(std::shared_ptr<moab::Interface> external_mbi);
779795

@@ -943,6 +959,7 @@ class LibMesh : public UnstructuredMesh {
943959
public:
944960
// Constructors
945961
LibMesh(pugi::xml_node node);
962+
LibMesh(hid_t group);
946963
LibMesh(const std::string& filename, double length_multiplier = 1.0);
947964
LibMesh(libMesh::MeshBase& input_mesh, double length_multiplier = 1.0);
948965

@@ -1069,6 +1086,11 @@ class AdaptiveLibMesh : public LibMesh {
10691086
//! \param[in] root XML node
10701087
void read_meshes(pugi::xml_node root);
10711088

1089+
//! Read meshes from an HDF5 file
1090+
//
1091+
//! \param[in] group HDF5 group ("meshes" group)
1092+
void read_meshes(hid_t group);
1093+
10721094
//! Write mesh data to an HDF5 group
10731095
//
10741096
//! \param[in] group HDF5 group

0 commit comments

Comments
 (0)