@@ -52,6 +52,7 @@ namespace matset
5252// ---------------------------------------------------------------------------//
5353MatsetAccessor::MatsetAccessor ()
5454 : m_get_mat_id(&MatsetAccessor::get_error_mat_id),
55+ m_get_mat_order_id (&MatsetAccessor::get_error_mat_order_id),
5556 m_get_elem_id(&MatsetAccessor::get_error_elem_id),
5657 m_get_vol_frac(&MatsetAccessor::get_error_vol_frac),
5758 m_get_mset_val(&MatsetAccessor::get_error_mset_val),
@@ -66,6 +67,7 @@ MatsetAccessor::MatsetAccessor()
6667// ---------------------------------------------------------------------------//
6768MatsetAccessor::MatsetAccessor (const Node &matset)
6869 : m_get_mat_id(&MatsetAccessor::get_error_mat_id),
70+ m_get_mat_order_id(&MatsetAccessor::get_error_mat_order_id),
6971 m_get_elem_id(&MatsetAccessor::get_error_elem_id),
7072 m_get_vol_frac(&MatsetAccessor::get_error_vol_frac),
7173 m_get_mset_val(&MatsetAccessor::get_error_mset_val),
@@ -81,6 +83,7 @@ MatsetAccessor::MatsetAccessor(const Node &matset)
8183MatsetAccessor::MatsetAccessor (const Node &matset,
8284 const Node &specset_or_field)
8385 : m_get_mat_id(&MatsetAccessor::get_error_mat_id),
86+ m_get_mat_order_id(&MatsetAccessor::get_error_mat_order_id),
8487 m_get_elem_id(&MatsetAccessor::get_error_elem_id),
8588 m_get_vol_frac(&MatsetAccessor::get_error_vol_frac),
8689 m_get_mset_val(&MatsetAccessor::get_error_mset_val),
@@ -108,6 +111,7 @@ MatsetAccessor::MatsetAccessor(const Node &matset,
108111 const Node &field,
109112 const Node &specset)
110113 : m_get_mat_id(&MatsetAccessor::get_error_mat_id),
114+ m_get_mat_order_id(&MatsetAccessor::get_error_mat_order_id),
111115 m_get_elem_id(&MatsetAccessor::get_error_elem_id),
112116 m_get_vol_frac(&MatsetAccessor::get_error_vol_frac),
113117 m_get_mset_val(&MatsetAccessor::get_error_mset_val),
@@ -122,6 +126,7 @@ MatsetAccessor::MatsetAccessor(const Node &matset,
122126// ---------------------------------------------------------------------------//
123127MatsetAccessor::MatsetAccessor (const MatsetAccessor &m_acc)
124128: m_get_mat_id(m_acc.m_get_mat_id),
129+ m_get_mat_order_id(m_acc.m_get_mat_order_id),
125130 m_get_elem_id(m_acc.m_get_elem_id),
126131 m_get_vol_frac(m_acc.m_get_vol_frac),
127132 m_get_mset_val(m_acc.m_get_mset_val),
@@ -145,6 +150,8 @@ MatsetAccessor::MatsetAccessor(const MatsetAccessor &m_acc)
145150 m_multi_mass_fracs(m_acc.m_multi_mass_fracs),
146151 m_sbm_elem_ids(m_acc.m_sbm_elem_ids),
147152 m_sbe_material_ids(m_acc.m_sbe_material_ids),
153+ m_sbe_mat_order_ids(m_acc.m_sbe_mat_order_ids),
154+ m_sbe_mat_order_ids_acc(m_acc.m_sbe_mat_order_ids_acc),
148155 m_sbe_vol_fracs(m_acc.m_sbe_vol_fracs),
149156 m_sbe_mset_vals(m_acc.m_sbe_mset_vals),
150157 m_sbe_o2m_idx(m_acc.m_sbe_o2m_idx),
@@ -159,6 +166,7 @@ MatsetAccessor::operator=(const MatsetAccessor &m_acc)
159166 if (this != &m_acc)
160167 {
161168 m_get_mat_id = m_acc.m_get_mat_id ;
169+ m_get_mat_order_id = m_acc.m_get_mat_order_id ;
162170 m_get_elem_id = m_acc.m_get_elem_id ;
163171 m_get_vol_frac = m_acc.m_get_vol_frac ;
164172 m_get_mset_val = m_acc.m_get_mset_val ;
@@ -182,6 +190,8 @@ MatsetAccessor::operator=(const MatsetAccessor &m_acc)
182190 m_multi_mass_fracs = m_acc.m_multi_mass_fracs ;
183191 m_sbm_elem_ids = m_acc.m_sbm_elem_ids ;
184192 m_sbe_material_ids = m_acc.m_sbe_material_ids ;
193+ m_sbe_mat_order_ids = m_acc.m_sbe_mat_order_ids ;
194+ m_sbe_mat_order_ids_acc = m_acc.m_sbe_mat_order_ids_acc ;
185195 m_sbe_vol_fracs = m_acc.m_sbe_vol_fracs ;
186196 m_sbe_mset_vals = m_acc.m_sbe_mset_vals ;
187197 m_sbe_o2m_idx = m_acc.m_sbe_o2m_idx ;
@@ -227,8 +237,8 @@ MatsetAccessor::init(const Node &matset,
227237 m_has_specset = true ;
228238 }
229239
230- m_is_uni_buffer = blueprint::mesh:: matset::is_uni_buffer (matset);
231- m_is_element_dominant = blueprint::mesh:: matset::is_element_dominant (matset);
240+ m_is_uni_buffer = matset::is_uni_buffer (matset);
241+ m_is_element_dominant = matset::is_element_dominant (matset);
232242
233243 m_num_elems = count_zones_from_matset (matset);
234244 m_num_mats = count_materials_from_matset (matset);
@@ -245,6 +255,28 @@ MatsetAccessor::init(const Node &matset,
245255 m_sbe_material_ids = matset[" material_ids" ].value ();
246256 m_sbe_vol_fracs = matset[" volume_fractions" ].value ();
247257 m_sbe_o2m_idx = o2mrelation::O2MIndex (matset);
258+
259+ //
260+ // save material order ids
261+ //
262+ const index_t num_vol_fracs = matset[" volume_fractions" ].dtype ().number_of_elements ();
263+ m_sbe_mat_order_ids.set (DataType::index_t (num_vol_fracs));
264+ m_sbe_mat_order_ids_acc = m_sbe_mat_order_ids.value ();
265+ // create a map from material id to material order id
266+ std::map<index_t , index_t > mat_id_to_order_id;
267+ for (index_t mat_idx = 0 ; mat_idx < m_num_mats; mat_idx ++)
268+ {
269+ const index_t mat_id = material_map.child (mat_idx).to_index_t ();
270+ mat_id_to_order_id[mat_id] = mat_idx;
271+ }
272+ // now we can fill the mat order id array using the information we've collected
273+ for (index_t vf_elem = 0 ; vf_elem < num_vol_fracs; vf_elem ++)
274+ {
275+ const index_t mat_id = m_sbe_material_ids[vf_elem];
276+ const index_t mat_order_id = mat_id_to_order_id.at (mat_id);
277+ m_sbe_mat_order_ids_acc.set (vf_elem, mat_order_id);
278+ }
279+
248280 if (nullptr != field)
249281 {
250282 m_sbe_mset_vals = (*field)[" matset_values" ].value ();
@@ -423,7 +455,6 @@ MatsetAccessor::init(const Node &matset,
423455 // We pay a price at the start when creating these arrays, but we enable quick
424456 // access of species mass fraction data.
425457
426- const index_t num_vol_fracs = matset[" volume_fractions" ].dtype ().number_of_elements ();
427458 m_nmatspec[" nmatspec" ].set (DataType::index_t (num_vol_fracs));
428459 m_nmatspec_acc = m_nmatspec[" nmatspec" ].value ();
429460 m_nmatspec[" nmatspec_offsets" ].set (DataType::index_t (num_vol_fracs));
@@ -465,9 +496,10 @@ MatsetAccessor::init(const Node &matset,
465496 }
466497
467498 // set our fetch methods
468- m_get_mat_id = &MatsetAccessor::get_sbe_mat_id;
469- m_get_elem_id = &MatsetAccessor::get_sbe_elem_id;
470- m_get_vol_frac = &MatsetAccessor::get_sbe_vol_frac;
499+ m_get_mat_id = &MatsetAccessor::get_sbe_mat_id;
500+ m_get_mat_order_id = &MatsetAccessor::get_sbe_mat_order_id;
501+ m_get_elem_id = &MatsetAccessor::get_sbe_elem_id;
502+ m_get_vol_frac = &MatsetAccessor::get_sbe_vol_frac;
471503 if (nullptr != field)
472504 {
473505 m_get_mset_val = &MatsetAccessor::get_sbe_mset_val;
@@ -571,9 +603,10 @@ MatsetAccessor::init(const Node &matset,
571603 // multi-buffer by element (full)
572604 if (m_is_element_dominant)
573605 {
574- m_get_mat_id = &MatsetAccessor::get_full_mat_id;
575- m_get_elem_id = &MatsetAccessor::get_full_elem_id;
576- m_get_vol_frac = &MatsetAccessor::get_full_vol_frac;
606+ m_get_mat_id = &MatsetAccessor::get_full_mat_id;
607+ m_get_mat_order_id = &MatsetAccessor::get_full_mat_order_id;
608+ m_get_elem_id = &MatsetAccessor::get_full_elem_id;
609+ m_get_vol_frac = &MatsetAccessor::get_full_vol_frac;
577610 if (nullptr != field)
578611 {
579612 m_get_mset_val = &MatsetAccessor::get_full_mset_val;
@@ -593,9 +626,10 @@ MatsetAccessor::init(const Node &matset,
593626 m_sbm_elem_ids.push_back (matset[" element_ids" ][matname].value ());
594627 }
595628
596- m_get_mat_id = &MatsetAccessor::get_sbm_mat_id;
597- m_get_elem_id = &MatsetAccessor::get_sbm_elem_id;
598- m_get_vol_frac = &MatsetAccessor::get_sbm_vol_frac;
629+ m_get_mat_id = &MatsetAccessor::get_sbm_mat_id;
630+ m_get_mat_order_id = &MatsetAccessor::get_sbm_mat_order_id;
631+ m_get_elem_id = &MatsetAccessor::get_sbm_elem_id;
632+ m_get_vol_frac = &MatsetAccessor::get_sbm_vol_frac;
599633 if (nullptr != field)
600634 {
601635 m_get_mset_val = &MatsetAccessor::get_sbm_mset_val;
@@ -623,6 +657,14 @@ MatsetAccessor::get_full_mat_id(const index_t elem_idx, const index_t mat_idx) c
623657 return m_multi_mat_idx_map_acc[mat_idx];
624658}
625659
660+ // -----------------------------------------------------------------------------
661+ index_t
662+ MatsetAccessor::get_full_mat_order_id (const index_t elem_idx, const index_t mat_idx) const
663+ {
664+ (void ) elem_idx;
665+ return mat_idx;
666+ }
667+
626668// -----------------------------------------------------------------------------
627669index_t
628670MatsetAccessor::get_full_elem_id (const index_t elem_idx, const index_t mat_idx) const
@@ -676,6 +718,14 @@ MatsetAccessor::get_sbm_mat_id(const index_t elem_idx, const index_t mat_idx) co
676718 return m_multi_mat_idx_map_acc[mat_idx];
677719}
678720
721+ // -----------------------------------------------------------------------------
722+ index_t
723+ MatsetAccessor::get_sbm_mat_order_id (const index_t elem_idx, const index_t mat_idx) const
724+ {
725+ (void ) elem_idx;
726+ return mat_idx;
727+ }
728+
679729// -----------------------------------------------------------------------------
680730index_t
681731MatsetAccessor::get_sbm_elem_id (const index_t elem_idx, const index_t mat_idx) const
@@ -735,6 +785,14 @@ MatsetAccessor::get_sbe_mat_id(const index_t elem_idx, const index_t mat_idx) co
735785 return m_sbe_material_ids[data_index];
736786}
737787
788+ // -----------------------------------------------------------------------------
789+ index_t
790+ MatsetAccessor::get_sbe_mat_order_id (const index_t elem_idx, const index_t mat_idx) const
791+ {
792+ const index_t data_index = m_sbe_o2m_idx.index (elem_idx, mat_idx);
793+ return m_sbe_mat_order_ids_acc[data_index];
794+ }
795+
738796// -----------------------------------------------------------------------------
739797index_t
740798MatsetAccessor::get_sbe_elem_id (const index_t elem_idx, const index_t mat_idx) const
@@ -814,6 +872,16 @@ MatsetAccessor::get_error_mat_id(const index_t elem_idx, const index_t mat_idx)
814872 return 0 ;
815873}
816874
875+ // -----------------------------------------------------------------------------
876+ index_t
877+ MatsetAccessor::get_error_mat_order_id (const index_t elem_idx, const index_t mat_idx) const
878+ {
879+ (void ) elem_idx;
880+ (void ) mat_idx;
881+ CONDUIT_ERROR (" Impossible to fetch mat_order_id from material set." );
882+ return 0 ;
883+ }
884+
817885// -----------------------------------------------------------------------------
818886index_t
819887MatsetAccessor::get_error_elem_id (const index_t elem_idx, const index_t mat_idx) const
@@ -921,4 +989,3 @@ MatsetAccessor::get_error_nspec_for_mat(const index_t elem_idx, const index_t ma
921989// -- end conduit:: --
922990// -----------------------------------------------------------------------------
923991
924-
0 commit comments