14#include "arcane/utils/ScopedPtr.h"
15#include "arcane/utils/StringBuilder.h"
16#include "arcane/utils/ITraceMng.h"
17#include "arcane/utils/HashTableMap.h"
18#include "arcane/utils/PlatformUtils.h"
19#include "arcane/utils/NotSupportedException.h"
21#include "arcane/core/AbstractService.h"
22#include "arcane/core/IVariableReader.h"
23#include "arcane/core/BasicTimeLoopService.h"
24#include "arcane/core/IXmlDocumentHolder.h"
25#include "arcane/core/IIOMng.h"
26#include "arcane/core/IMesh.h"
27#include "arcane/core/IItemFamily.h"
28#include "arcane/core/IParallelMng.h"
29#include "arcane/core/ISubDomain.h"
30#include "arcane/core/CommonVariables.h"
31#include "arcane/core/IVariableAccessor.h"
32#include "arcane/core/Directory.h"
33#include "arcane/core/VariableCollection.h"
34#include "arcane/core/IMeshMng.h"
36#include "arcane/hdf5/Hdf5VariableReader_axl.h"
37#include "arcane/hdf5/Hdf5Utils.h"
38#include "arcane/hdf5/Hdf5VariableInfoBase.h"
56class Hdf5VariableReaderHelperBase
75 Real timeValue()
const {
return m_time; }
76 const String& path()
const {
return m_path; }
86 Hdf5VariableReaderHelperBase(
IMesh* mesh)
106 void _checkValidVariable(
IVariable* var);
112void Hdf5VariableReaderHelperBase::
113_readStandardArray(IVariable* var,
RealArray& buffer, hid_t file_id,
const String& path)
115 Hdf5Utils::StandardArrayT<Real> values(file_id, path);
120 fatal() <<
"Only one-dimension array are allowed "
121 <<
" dim=" << nb_dim <<
" var_name=" << var->fullName() <<
" path=" << path;
123 info(4) <<
"NB_ITEM: nb_item=" << nb_item;
125 if (nb_item!=family->nbItem())
126 fatal() <<
"Bad number of items in file n=" << nb_item
127 <<
" expected=" << family->nbItem()
128 <<
" var_name=" << var_name <<
" path=" << var_path
129 <<
" family=" << var_family;
131 buffer.resize(nb_item);
132 values.read(m_types, buffer);
136 for(
Integer i=0; i<nb_item; ++i ){
139 info() <<
" VAR_VAL i=" << i <<
" value=" << buffer[i];
151void Hdf5VariableReaderHelperBase::
154 IParallelMng* pm = m_mesh->parallelMng();
155 bool is_master = pm->isMasterIO();
157 Integer master_rank = pm->masterIORank();
161 if (hfile.id() < 0) {
162 info() <<
"Hdf5VariableReaderHelper::OPEN FILE " << m_hdf5_file_name;
163 hfile.openRead(m_hdf5_file_name);
165 _readStandardArray(var, buffer, hfile.id(), path);
166 buf_size = buffer.size();
168 pm->broadcast(iav, master_rank);
169 pm->broadcast(buffer, master_rank);
173 pm->broadcast(iav, master_rank);
174 buffer.resize(buf_size);
175 pm->broadcast(buffer, master_rank);
180 IData* var_data = var->data();
181 auto* var_true_data =
dynamic_cast<IArrayDataT<Real>*
>(var_data);
183 throw FatalErrorException(A_FUNCINFO,
"Variable is not an array of Real");
185 Integer nb_var_value = var_value.size();
186 for (
Integer z = 0; z < buf_size; ++z)
188 var->itemFamily()->itemsUniqueIdToLocalId(local_ids, unique_ids,
false);
189 for (
Integer z = 0; z < buf_size; ++z) {
191 if (lid == NULL_ITEM_LOCAL_ID)
193 if (lid > nb_var_value)
194 throw FatalErrorException(A_FUNCINFO,
"Bad variable");
195 var_value[lid] = buffer[z];
197 info(4) <<
"End of read for variable '" << var->fullName()
198 <<
"' path=" << path;
204void Hdf5VariableReaderHelperBase::
207 if (var->dataType() ==
DT_Real && (var->dimension() == 1) && var->itemFamily())
209 throw FatalErrorException(A_FUNCINFO,
210 String::format(
"Bad variable '{0}'. Variable must be an item variable,"
211 " have datatype 'Real' and dimension '1'",
223class Hdf5VariableReaderHelper
224:
public Hdf5VariableReaderHelperBase
231 class TimeVariableInfoBase
274 Hdf5VariableReaderHelper(
IMesh* mesh,
const String& xml_file_name);
275 ~Hdf5VariableReaderHelper();
285 void open(
bool is_start);
316Hdf5VariableReaderHelper::
317Hdf5VariableReaderHelper(
IMesh* mesh,
const String& xml_file_name)
319, m_xml_file_name(xml_file_name)
326Hdf5VariableReaderHelper::
327~Hdf5VariableReaderHelper()
329 for (
Integer i = 0, n = m_init_variables.size(); i < n; ++i)
330 delete m_init_variables[i];
331 m_init_variables.clear();
332 for (
Integer i = 0, n = m_time_variables.size(); i < n; ++i)
333 delete m_time_variables[i];
334 m_time_variables.clear();
343 if (m_xml_file_name.null())
345 IIOMng* io_mng = m_mesh->parallelMng()->ioMng();
346 m_xml_document_holder = io_mng->
parseXmlFile(m_xml_file_name);
347 if (!m_xml_document_holder.get())
348 ARCANE_FATAL(
"Can not read file '{0}'", m_xml_file_name);
351 m_hdf5_file_name = root_element.
attrValue(
"file-name",
true);
356 for (
XmlNode elem : variables_elem) {
357 String var_name = elem.attrValue(
"name",
true);
358 String var_family = elem.attrValue(
"family",
true);
359 String var_path = elem.attrValue(
"path",
true);
360 info() <<
"INIT_VARIABLE: name=" << var_name <<
" path=" << var_path
361 <<
" family=" << var_family;
364 m_init_variables.add(var_info);
369 for (
XmlNode elem : variables_elem) {
370 String var_name = elem.attrValue(
"name",
true);
371 String var_family = elem.attrValue(
"family",
true);
372 info() <<
"TIME_VARIABLE: name=" << var_name <<
" family=" << var_family;
373 IItemFamily* family = m_mesh->findItemFamily(var_family,
true);
376 warning() <<
"TEMPORARY: Create variable from hdf5 file";
380 _checkValidVariable(var);
384 XmlNodeList times_elem = elem.children(
"time-value");
385 Real last_var_time = -1.0;
386 for (
XmlNode time_elem : times_elem) {
387 String var_path = time_elem.attrValue(
"path",
true);
388 XmlNode var_time_node = time_elem.
attr(
"global-time",
true);
390 if (var_time <= last_var_time) {
392 <<
" current=" << var_time <<
" previous=" << last_var_time
393 <<
". current value should be greater than previous time.";
395 last_var_time = var_time;
399 m_time_variables.add(var_info);
412 for (
Integer iz = 0, izs = m_init_variables.size(); iz < izs; ++iz) {
415 info() <<
"Hdf5VariableReader: init for variable name=" << var->
fullName();
416 vi->readVariable(hfile, m_hdf5_file_name, m_types,
String(), var->
data());
423void Hdf5VariableReaderHelper::
424_readAndUpdateVariable(TimeVariableInfoBase* vi,
Real wanted_time,
HFile& hfile)
430 Real begin_time = 0.0;
432 Integer nb_value = time_path_values.size();
433 for (
Integer i = 0; i < nb_value; ++i) {
434 begin_time = time_path_values[i].timeValue();
435 if (wanted_time < begin_time) {
439 if ((i + 1) == nb_value) {
445 end_time = time_path_values[i + 1].timeValue();
446 if (wanted_time > begin_time && wanted_time < end_time) {
451 if (current_index < 0)
454 <<
" begin=" << begin_time <<
" end=" << end_time
455 <<
" index=" << current_index;
457 bool need_read = current_index != vi->m_current_index || vi->m_mesh_timestamp != mesh_timestamp;
458 if (nb_value == 1 || (current_index + 1) == nb_value) {
464 String begin_path = vi->m_time_path_values[current_index].path();
465 info() <<
"Hdf5VariableReaderHelper:: PATH=" << begin_path;
466 _readVariable(vi->m_begin_variable.variable(), buffer, hfile, begin_path);
467 vi->m_current_index = current_index;
468 vi->m_mesh_timestamp = mesh_timestamp;
471 begin_time = vi->m_time_path_values[current_index].timeValue();
475 Real begin_value = begin_variable[iitem];
476 var[iitem] = begin_value;
478 info() <<
"Value for cell=" << (*iitem).uniqueId() <<
" var_value=" << var[iitem];
484 String begin_path = vi->m_time_path_values[current_index].path();
485 String end_path = vi->m_time_path_values[current_index + 1].path();
486 info(4) <<
"Hdf5VariableReaderHelper:: BEGIN_PATH=" << begin_path <<
" END_PATH=" << end_path;
487 _readVariable(vi->m_begin_variable.variable(), buffer, hfile, begin_path);
488 _readVariable(vi->m_end_variable.variable(), buffer, hfile, end_path);
489 vi->m_current_index = current_index;
490 vi->m_mesh_timestamp = mesh_timestamp;
493 begin_time = vi->m_time_path_values[current_index].timeValue();
494 end_time = vi->m_time_path_values[current_index + 1].timeValue();
496 fatal() <<
"Hdf5VariableReaderHelper::_readAndUpdateVariable() "
497 <<
" same value for begin and end time (value=" << begin_time <<
")";
498 Real ratio = (wanted_time - begin_time) / (end_time - begin_time);
499 info(4) <<
" RATIO = " << ratio;
504 Real begin_value = begin_variable[iitem];
505 Real end_value = end_variable[iitem];
506 var[iitem] = (end_value - begin_value) * ratio + begin_value;
508 info() <<
"Value for cell=" << (*iitem).uniqueId()
509 <<
" begin=" << begin_value <<
" end_value=" << end_value
510 <<
" var_value=" << var[iitem];
524 for (
Integer iz = 0, izs = m_time_variables.size(); iz < izs; ++iz) {
526 _readAndUpdateVariable(vi, wanted_time, hfile);
538 for (
Integer iz = 0, izs = m_time_variables.size(); iz < izs; ++iz) {
552class Hdf5VariableReaderHelper2
553:
public Hdf5VariableReaderHelperBase
562 class TimeVariableInfoBase
567 : m_hdf5_var_info(var)
572 ~TimeVariableInfoBase()
578 IVariable* variable() {
return m_hdf5_var_info->variable(); }
580 Real2 timeInterval()
const
582 Integer n = m_time_path_values.size();
584 return Real2(0.0, 0.0);
585 Real x = m_time_path_values[0].timeValue();
586 Real y = m_time_path_values[n - 1].timeValue();
624 CorrespondanceInfo(
const ItemGroup& group)
627 , m_corresponding_hash(512,
true)
635 ARCANE_UNUSED(index);
639 String::format(
"Can not find corresponding uid item='{0}' group={1}",
640 uid, m_group.fullName()));
641 Int64 old_uid = uid_data->value();
649 m_corresponding_hash.clear();
650 Integer nb_pair = m_corresponding_uids.size() / 2;
651 for (
Integer z = 0; z < nb_pair; ++z)
652 m_corresponding_hash.add(m_corresponding_uids[z * 2], m_corresponding_uids[(z * 2) + 1]);
664 Hdf5VariableReaderHelper2(
IMesh* mesh,
const String& hdf5_file_name);
665 ~Hdf5VariableReaderHelper2();
677 m_wanted_vars = vars;
686 void open(
bool is_start);
689 void readAndUpdateTimeVariables(
Real wanted_time);
692 void notifyRestore();
696 for (
Integer i = 0, n = m_time_variables.size(); i < n; ++i) {
697 TimeVariableInfoBase* vinfo = m_time_variables[i];
698 if (vinfo->variable() == var)
699 return vinfo->timeInterval();
701 return Real2(0.0, 0.0);
707 UniqueArray<IVariable*> m_wanted_vars;
708 ScopedPtrT<IXmlDocumentHolder> m_xml_document_holder;
709 UniqueArray<TimeVariableInfoBase*> m_time_variables;
710 std::map<String, CorrespondanceInfo*> m_correspondance_map;
714 template <
typename DataType>
715 void _readAndUpdateVariable(TimeVariableInfoBase* vi, Real wanted_time, HFile& hfile);
716 bool _isWanted(
const String& var_name,
const String& var_family);
717 void _checkCreateCorrespondance(Hdf5VariableInfoBase* var, HFile& file_id,
const String& group_path,
bool is_start);
718 void _createCorrespondance(IVariable* var, CorrespondanceInfo* ci, Int64ConstArrayView saved_uids, Real3ConstArrayView saved_centers);
726Hdf5VariableReaderHelper2::
727Hdf5VariableReaderHelper2(IMesh* mesh,
const String& hdf5_file_name)
728: Hdf5VariableReaderHelperBase(mesh)
730 m_hdf5_file_name = hdf5_file_name;
736Hdf5VariableReaderHelper2::
737~Hdf5VariableReaderHelper2()
739 for (
Integer i = 0, n = m_time_variables.size(); i < n; ++i)
740 delete m_time_variables[i];
741 m_time_variables.clear();
750 if (m_hdf5_file_name.null())
758 file_id.openRead(m_hdf5_file_name);
762 info(5) <<
"XML_DATA len=" << xml_bytes.
size() <<
" data=" << xml_bytes <<
"__EOF";
765 IIOMng* io_mng = m_mesh->parallelMng()->ioMng();
766 m_xml_document_holder = io_mng->
parseXmlBuffer(xml_bytes, m_hdf5_file_name);
767 if (!m_xml_document_holder.get())
768 ARCANE_FATAL(
"Can not XML data from file '{0}'", m_hdf5_file_name);
774 for (
const auto& elem : variables_elem) {
775 String var_name = elem.attrValue(
"name",
true);
776 String var_family = elem.attrValue(
"family",
true);
777 info(4) <<
"TIME_VARIABLE: name=" << var_name <<
" family=" << var_family;
778 if (!_isWanted(var_name, var_family))
785 String group_path = index_path +
"/Groups/" + group_name;
786 _checkCreateCorrespondance(var_info, file_id, group_path, is_start);
790 XmlNodeList times_elem = elem.children(
"time-value");
791 Real last_var_time = -1.0;
792 for (
const auto& time_elem : times_elem) {
793 String var_path = time_elem.attrValue(
"path",
true);
794 XmlNode var_time_node = time_elem.
attr(
"global-time",
true);
796 if (var_time <= last_var_time) {
798 <<
" current=" << var_time <<
" previous=" << last_var_time
799 <<
". current value should be greater than previous time.";
801 last_var_time = var_time;
802 time_var_info->m_time_path_values.
add(
TimePathPair(var_time, var_path));
805 m_time_variables.add(time_var_info);
812void Hdf5VariableReaderHelper2::
818 CorrespondanceInfo* ci = 0;
819 std::map<String, CorrespondanceInfo*>::const_iterator iter = m_correspondance_map.find(group.
fullName());
820 if (iter == m_correspondance_map.end()) {
821 ci =
new CorrespondanceInfo(group);
825 var_info->readGroupInfo(file_id, m_types, group_path, saved_uids, saved_centers);
826 _createCorrespondance(var, ci, saved_uids, saved_centers);
829 m_correspondance_map.insert(std::make_pair(group.
fullName(), ci));
833 var_info->setCorrespondanceFunctor(ci);
851void Hdf5VariableReaderHelper2::
855 IMesh* mesh = var->meshHandle().mesh();
856 ItemGroup group = var->itemGroup();
857 IParallelMng* pm = mesh->parallelMng();
864 ItemUniqueId item_uid = (*iitem).uniqueId();
865 if ((*iitem).isItemWithNodes()) {
866 ItemWithNodes item = (*iitem).toItemWithNodes();
869 Integer nb_node = item.nbNode();
870 for (NodeLocalId inode : item.nodeIds()) {
871 item_center += nodes_coords[inode];
873 item_center /= nb_node;
876 Node node = (*iitem).toNode();
877 item_center = nodes_coords[node];
881 Real min_dist = FloatInfo<Real>::maxValue();
883 for (
Integer z = 0; z < nb_orig_item; ++z) {
890 if (min_index == (-1))
891 throw FatalErrorException(A_FUNCINFO,
"Can not find old unique id");
892 info() <<
"FIND NEAREST my_uid=" << item_uid <<
" orig_uid=" << saved_uids[min_index]
893 <<
" d^2=" << min_dist;
894 corresponding_uids.add(item_uid);
895 corresponding_uids.add(saved_uids[min_index]);
905 pm->allGatherVariable(corresponding_uids, global_uids);
906 ci->m_corresponding_uids.
resize(global_uids.size());
907 ci->m_corresponding_uids.copy(global_uids);
913bool Hdf5VariableReaderHelper2::
914_isWanted(
const String& var_name,
const String& var_family)
916 Integer nb_var = m_wanted_vars.size();
919 for (
Integer i = 0, n = m_wanted_vars.size(); i < n; ++i) {
920 IVariable* v = m_wanted_vars[i];
921 if (v->name() == var_name && v->itemFamilyName() == var_family)
930template <
typename DataType>
931void Hdf5VariableReaderHelper2::
932_readAndUpdateVariable(TimeVariableInfoBase* vi,
Real wanted_time,
HFile& hfile)
936 ConstArrayView<TimePathPair> time_path_values(vi->m_time_path_values.view());
938 Real begin_time = 0.0;
940 Integer nb_value = time_path_values.size();
941 for (
Integer i = 0; i < nb_value; ++i) {
942 begin_time = time_path_values[i].timeValue();
943 if (wanted_time < begin_time) {
947 if ((i + 1) == nb_value) {
955 end_time = time_path_values[i + 1].timeValue();
956 if (wanted_time > begin_time && wanted_time < end_time) {
961 if (current_index < 0)
965 IVariable* variable = vi->variable();
966 Int64 mesh_timestamp = variable->meshHandle().mesh()->timestamp();
970 bool need_read = current_index != vi->m_current_index || vi->m_mesh_timestamp != mesh_timestamp;
974 String ids_hpath = String(
"Index1/Groups/") + variable->itemGroupName() +
"_Ids";
975 info(4) <<
" FIND TIME: current=" << wanted_time <<
" begin=" << begin_time <<
" end=" << end_time
976 <<
" index=" << current_index <<
"ids_path=" << ids_hpath <<
" var=" << variable->fullName();
977 Hdf5VariableInfoBase* var_info = vi->hdf5Info();
978 IArrayDataT<DataType>* true_begin_data =
dynamic_cast<IArrayDataT<DataType>*
>(vi->m_begin_data.get());
979 IArrayDataT<DataType>* true_end_data =
dynamic_cast<IArrayDataT<DataType>*
>(vi->m_end_data.get());
980 IArrayDataT<DataType>* true_data =
dynamic_cast<IArrayDataT<DataType>*
>(variable->data());
981 info(4) <<
"DATA: begin=" << vi->m_begin_data.get() <<
" end=" << vi->m_end_data.get() <<
" current=" << variable->data();
982 info(4) <<
"TRUEDATA: begin=" << true_begin_data <<
" end=" << true_end_data <<
" current=" << true_data;
983 if (!true_data || !true_end_data || !true_begin_data) {
984 throw FatalErrorException(A_FUNCINFO,
"variable data can not be cast to type IArrayDataT");
986 bool is_partial = variable->isPartial();
989 String begin_path = vi->m_time_path_values[current_index].path();
990 String end_path = vi->m_time_path_values[current_index + 1].path();
991 info(4) <<
"Hdf5VariableReaderHelper2:: Reading new index BEGIN_PATH=" << begin_path <<
" END_PATH=" << end_path;
992 var_info->setPath(begin_path);
993 var_info->readVariable(hfile, m_hdf5_file_name, m_types, ids_hpath, vi->m_begin_data.get());
994 var_info->setPath(end_path);
995 var_info->readVariable(hfile, m_hdf5_file_name, m_types, ids_hpath, vi->m_end_data.get());
998 vi->m_current_index = current_index;
999 vi->m_mesh_timestamp = mesh_timestamp;
1001 begin_time = vi->m_time_path_values[current_index].timeValue();
1002 end_time = vi->m_time_path_values[current_index + 1].timeValue();
1004 throw FatalErrorException(A_FUNCINFO,
1005 String::format(
"same value for begin and end time (value={0})",
1007 Real ratio = (wanted_time - begin_time) / (end_time - begin_time);
1008 info(4) <<
" BeginTime=" << begin_time <<
" wanted=" << wanted_time <<
" end_time=" << end_time
1009 <<
" ratio = " << ratio;
1011 ConstArrayView<DataType> begin_values_view = true_begin_data->view();
1012 ConstArrayView<DataType> end_values_view = true_end_data->view();
1013 ArrayView<DataType> values_view = true_data->view();
1015 Int32 lid = (is_partial) ? iitem.index() : iitem.itemLocalId();
1016 DataType begin_value = begin_values_view[lid];
1017 DataType end_value = end_values_view[lid];
1018 values_view[lid] = (end_value - begin_value) * ratio + begin_value;
1020 info() <<
"Value for cell=" << (*iitem).uniqueId()
1021 <<
" begin=" << begin_value <<
" end_value=" << end_value
1022 <<
" var_value=" << values_view[lid];
1036 for (
Integer iz = 0, izs = m_time_variables.size(); iz < izs; ++iz) {
1041 _readAndUpdateVariable<Real>(vi, wanted_time, hfile);
1044 _readAndUpdateVariable<Real3>(vi, wanted_time, hfile);
1047 throw NotSupportedException(A_FUNCINFO,
"Bad variable datatype (only Real and Real3 are supported)");
1060 for (
Integer iz = 0, izs = m_time_variables.size(); iz < izs; ++iz) {
1074class Hdf5VariableReader
1075:
public ArcaneHdf5VariableReaderObject
1080 ~Hdf5VariableReader()
override;
1084 void build()
override
1088 void onTimeLoopStartInit()
override
1091 for (
Integer i = 0, is = m_readers.size(); i < is; ++i) {
1092 m_readers[i]->readInit();
1095 void onTimeLoopContinueInit()
override
1100 void onTimeLoopEndLoop()
override {}
1101 void onTimeLoopRestore()
override
1103 for (
Integer i = 0, is = m_readers.size(); i < is; ++i) {
1104 m_readers[i]->notifyRestore();
1107 void onTimeLoopBeginLoop()
override
1109 Real current_time = subDomain()->commonVariables().globalTime();
1110 for (
Integer i = 0, is = m_readers.size(); i < is; ++i) {
1111 m_readers[i]->readAndUpdateTimeVariables(current_time);
1117 void _load(
bool is_start)
1119 IMeshMng* mm = subDomain()->meshMng();
1120 for (
Integer i = 0, is = options()->read.size(); i < is; ++i) {
1121 String file_name = options()->read[i]->fileName();
1122 String mesh_name = options()->read[i]->meshName();
1123 info() <<
"Hdf5VariableReader: FILE_INFO: mesh=" << mesh_name <<
" file_name=" << file_name;
1130 info() <<
"Hdf5VariableReader: Nb reader =" << m_readers.size();
1131 for (
Integer i = 0, is = m_readers.size(); i < is; ++i) {
1132 m_readers[i]->open(is_start);
1146: ArcaneHdf5VariableReaderObject(sbi)
1154~Hdf5VariableReader()
1156 for (
Integer i = 0, is = m_readers.size(); i < is; ++i)
1157 delete m_readers[i];
1169class ManualHdf5VariableReader
1170:
public BasicService
1176 ~ManualHdf5VariableReader();
1191 pwarning() <<
"Reading variable from HDF5 file does not work with mesh load balancing";
1192 if (m_base_file_name.null())
1193 m_base_file_name =
"data";
1194 String file_name = m_base_file_name +
".h5";
1198 m_helper->setVariables(m_variables);
1199 m_helper->open(is_start);
1204 m_helper->readAndUpdateTimeVariables(wanted_time);
1209 m_directory_name = path;
1214 m_base_file_name = path;
1219 for (VariableCollection::Enumerator ivar(vars); ++ivar;)
1220 m_variables.add(*ivar);
1224 arcaneCheckNull(m_helper);
1225 arcaneCheckNull(var);
1226 return m_helper->timeInterval(var);
1240ManualHdf5VariableReader::
1241ManualHdf5VariableReader(
const ServiceBuildInfo& sbi)
1244, m_directory_name(
".")
1245, m_base_file_name(
"data")
1252ManualHdf5VariableReader::
1253~ManualHdf5VariableReader()
1263class OldManualHdf5VariableReader
1264:
public BasicService
1273 ~OldManualHdf5VariableReader()
1299 m_reader->readAndUpdateTimeVariables(wanted_time);
1304 m_directory_name = path;
1309 m_base_file_name = path;
1314 ARCANE_UNUSED(vars);
1326 void _load(
bool is_start)
1328 ARCANE_UNUSED(is_start);
1331 String file_name = dir.file(m_base_file_name);
1333 info() <<
"OldManualHdf5VariableReader: FILE_INFO: file_name=" << file_name;
1341 Hdf5VariableReaderHelper* m_reader;
1342 String m_directory_name;
1343 String m_base_file_name;
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
#define ARCANE_SERVICE_INTERFACE(ainterface)
Macro to declare an interface when registering a service.
Integer size() const
Number of elements in the vector.
void resize(Int64 s)
Changes the number of elements in the array to s.
Constant view of an array of type T.
Class managing a directory.
String file(const String &file_name) const override
Returns the full path of the file file_name in the directory.
Exception when a fatal error has occurred.
Encapsulates a hid_t for a file.
Encapsulates a simple dataset from an HDF5 file that represents an array.
void directRead(StandardTypes &st, Array< DataType > &buffer)
Reads the dataset of a 1D array.
Definition of standard Arcane types for hdf5.
Functor to establish the correspondence between a entity of the current mesh and that of the saved me...
void setPath(const String &path)
Sets the path in the Hdf5 file containing the variable value.
Int64 m_mesh_timestamp
Mesh timestamp when this index was read.
Integer m_current_index
Contains the index in the time array of the currently read time.
Reading variables in HDF5 format.
void readAndUpdateTimeVariables(Real wanted_time)
Reading and updating variables.
void setVariables(ConstArrayView< IVariable * > vars)
Specifies the variables that we want to reread.
void notifyRestore()
Notification of a rollback.
void open(bool is_start)
Opens the file containing the reading information.
Integer m_current_index
Contains the index in the time array of the currently read time.
Int64 m_mesh_timestamp
Mesh timestamp at which this index was read.
Reading variables in HDF5 format.
void notifyRestore()
Notification of a rollback.
void readInit()
Reads the information.
void open(bool is_start)
Opens the file containing the reading information.
void readAndUpdateTimeVariables(Real wanted_time)
Reads and updates time variables.
Reading variables in HDF5 format.
virtual Ref< IData > cloneRef()=0
Clone the data.
Interface of the input/output manager.
virtual IXmlDocumentHolder * parseXmlFile(const String &filename, const String &schemaname=String{})=0
Reads and parses the XML file filename.
virtual IXmlDocumentHolder * parseXmlBuffer(Span< const Byte > buffer, const String &name)=0
Reads and parses the XML file contained in the buffer buffer.
Interface of an entity family.
virtual String name() const =0
Family name.
virtual IVariable * findVariable(const String &name, bool throw_exception=false)=0
Searches for the variable name name associated with this family.
virtual MeshHandle * findMeshHandle(const String &name, bool throw_exception)=0
Searches for the mesh with name name.
virtual Int64 timestamp()=0
Counter indicating the time of the last mesh modification.
Interface of the parallelism manager for a subdomain.
virtual void broadcastMemoryBuffer(ByteArray &bytes, Int32 rank)=0
Performs a broadcast of a memory region.
virtual bool isMasterIO() const =0
true if the instance is a master I/O manager.
virtual Integer masterIORank() const =0
Rank of the instance managing I/O (for which isMasterIO() is true).
virtual IMesh * defaultMesh()=0
Default mesh.
virtual eDataType dataType() const =0
Data type managed by the variable (Real, Integer, ...).
virtual String fullName() const =0
Full variable name (with family prefix).
@ PNoRestore
Indicates that the variable should not be restored.
@ PNoDump
Indicates that the variable should not be saved.
virtual eItemKind itemKind() const =0
Kind of mesh entities on which the variable is based.
virtual IData * data()=0
Data associated with the variable.
virtual ItemGroup itemGroup() const =0
Associated mesh group.
virtual IItemFamily * itemFamily() const =0
Associated entity family.
virtual String itemGroupName() const =0
Name of the associated entity group.
virtual MeshHandle meshHandle() const =0
Mesh associated with the variable.
virtual String name() const =0
Variable name.
const String & fullName() const
Group name.
eItemKind itemKind() const
Group kind. This is the kind of its elements.
IMesh * mesh() const
Mesh to which this group belongs (0 for the null group).
Reading variables in HDF5 format.
virtual void updateVariables(Real wanted_time)
Updates the variables for the time wanted_time.
virtual void setBaseFileName(const String &path)
Sets the name of the file containing the data.
virtual void setBaseDirectoryName(const String &path)
Sets the path of the directory containing the data.
virtual void setVariables(VariableCollection vars)
Sets the list of variables that we wish to reread. This call must happen before initialize().
virtual void initialize(bool is_start)
Initializes the reader.
virtual Real2 timeInterval(IVariable *var)
Time interval of values for the variable var. The data for the variable var exists for the times incl...
virtual void build()
Build-level construction of the service.
IMesh * mesh() const
Associated mesh.
Reading variables in HDF5 format via an XML descriptor.
virtual void build()
Build-level construction of the service.
virtual void setBaseDirectoryName(const String &path)
Sets the path of the directory containing the data.
virtual void setVariables(VariableCollection vars)
Sets the list of variables that we wish to reread. This call must happen before initialize().
virtual void updateVariables(Real wanted_time)
Updates the variables for the time wanted_time.
virtual void setBaseFileName(const String &path)
Sets the name of the file containing the data.
virtual void initialize(bool is_start)
Initializes the reader.
virtual Real2 timeInterval(IVariable *var)
Time interval of values for the variable var. The data for the variable var exists for the times incl...
Class managing a 2-dimensional real vector.
Reference to an instance.
Encapsulation of an automatically destructing pointer.
Structure containing the information to create a service.
Service creation properties.
Unicode character string.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
TraceMessage fatal() const
Flow for a fatal error message.
TraceMessage info() const
Flow for an information message.
TraceMessage warning() const
Flow for a warning message.
ITraceMng * traceMng() const
Trace manager.
TraceMessage pwarning() const
1D data vector with value semantics (STL style).
Parameters necessary for building a variable.
IVariable * variable() const
Associated variable.
String name() const
Variable name.
List of nodes of a DOM tree.
XmlNode attr(const String &name, bool throw_exception=false) const
Returns the attribute of name name.
String xpathFullName() const
XPath name of the node with its ancestors.
XmlNode documentElement() const
Returns the document element.
String attrValue(const String &name, bool throw_exception=false) const
Value of attribute name.
Real valueAsReal(bool throw_exception=false) const
Node value converted to real number. If conversion fails, if throw_exception is false returns 0....
XmlNodeList children(const String &name) const
Set of child nodes of this node having the name name.
void add(ConstReferenceType val)
Adds element val to the end of the array.
#define ARCANE_REGISTER_SERVICE(aclass, a_service_property,...)
Macro for registering a service.
MeshVariableScalarRefT< Cell, Real > VariableCellReal
Real type quantity at cell center.
VariableRefArrayT< Int64 > VariableArrayInt64
Array variable of 64-bit integer type.
ItemVariableScalarRefT< Real > VariableItemReal
Real type quantity.
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Coordinate type quantity at node.
Utility functions for Hdf5.
constexpr __host__ __device__ Real squareNormL2(const Real2 &v)
Returns the squared norm of the pair $ .
constexpr __host__ __device__ bool isEqual(const _Type &a, const _Type &b)
Tests the bit-by-bit equality between two values.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Integer arcaneCheckArraySize(unsigned long long size)
Checks that size can be converted into an 'Integer' to serve as the size of an array....
ConstArrayView< Real3 > Real3ConstArrayView
C equivalent of a 1D array of Real3.
UniqueArray< Int64 > Int64UniqueArray
Dynamic 1D array of 64-bit integers.
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
UniqueArray< Real3 > Real3UniqueArray
Dynamic 1D array of rank 3 vectors.
ArrayView< Integer > IntegerArrayView
C equivalent of a 1D array of integers.
@ ST_SubDomain
The service is used at the subdomain level.
ConstArrayView< Int64 > Int64ConstArrayView
C equivalent of a 1D array of 64-bit integers.
UniqueArray< Byte > ByteUniqueArray
Dynamic 1D array of characters.
UniqueArray< Int32 > Int32UniqueArray
Dynamic 1D array of 32-bit integers.
UniqueArray< Real > RealUniqueArray
Dynamic 1D array of reals.
double Real
Type representing a real number.
Array< Real > RealArray
Dynamic one-dimensional array of reals.
@ DT_Real3
Vector 3 data type.
ArrayView< Real > RealArrayView
C equivalent of a 1D array of reals.
std::int32_t Int32
Signed integer type of 32 bits.