Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
Hdf5VariableInfoBase.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* Hdf5VariableInfoBase.h (C) 2000-2023 */
9/* */
10/* Linking a variable with an HDF5 file. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_HDF5_HDF5VARIABLEINFOBASE_H
13#define ARCANE_HDF5_HDF5VARIABLEINFOBASE_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/hdf5/Hdf5Utils.h"
18#include "arcane/core/VariableTypes.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29class IMesh;
30class IVariable;
31
32/*---------------------------------------------------------------------------*/
33/*---------------------------------------------------------------------------*/
34/*!
35 * \internal
36 * \brief Base class for reading or writing a variable.
37 */
38class ARCANE_HDF5_EXPORT Hdf5VariableInfoBase
39{
40 public:
41
42 /*!
43 * \brief Functor to establish the correspondence between a
44 * entity of the current mesh and that of the saved mesh.
45 */
47 {
48 public:
49
50 virtual ~ICorrespondanceFunctor() {}
51
52 public:
53
54 virtual Int64 getOldUniqueId(Int64 uid, Integer index) = 0;
55 };
56
57 public:
58
59 static const Integer SAVE_IDS = 1;
60 static const Integer SAVE_COORDS = 2;
61
62 protected:
63
64 Hdf5VariableInfoBase()
65 : m_correspondance_functor(0)
66 {}
67
68 public:
69
70 virtual ~Hdf5VariableInfoBase() {}
71
72 public:
73
74 static Hdf5VariableInfoBase* create(IMesh* mesh, const String& name,
75 const String& family);
76 //! Creates an instance for the variable \a variable.
77 static Hdf5VariableInfoBase* create(IVariable* variable);
78
79 public:
80
81 //! Path in the Hdf5 file containing the variable value
82 const String& path() const { return m_path; }
83 //! Sets the path in the Hdf5 file containing the variable value
84 void setPath(const String& path) { m_path = path; }
85 virtual void readVariable(Hdf5Utils::HFile& hfile, const String& filename,
86 Hdf5Utils::StandardTypes& st, const String& ids_hpath, IData* data) = 0;
87 virtual void writeVariable(Hdf5Utils::HFile& hfile, Hdf5Utils::StandardTypes& st) = 0;
88 virtual IVariable* variable() const = 0;
89
90 public:
91
92 void writeGroup(Hdf5Utils::HFile& hfile, Hdf5Utils::StandardTypes& st,
93 const String& hdf_path, Integer save_type);
94 void readGroupInfo(Hdf5Utils::HFile& hfile, Hdf5Utils::StandardTypes& st,
95 const String& hdf_path, Int64Array& uids, Real3Array& centers);
96 void setCorrespondanceFunctor(ICorrespondanceFunctor* functor)
97 {
98 m_correspondance_functor = functor;
99 }
100
101 private:
102
103 String m_path;
104
105 protected:
106
107 ICorrespondanceFunctor* m_correspondance_functor;
108
109 private:
110
111 static void _checkValidVariable(IVariable* var);
112};
113
114/*---------------------------------------------------------------------------*/
115/*---------------------------------------------------------------------------*/
116
117} // namespace Arcane
118
119/*---------------------------------------------------------------------------*/
120/*---------------------------------------------------------------------------*/
121
122#endif
Encapsulates a hid_t for a file.
Definition Hdf5Utils.h:275
Definition of standard Arcane types for hdf5.
Definition Hdf5Utils.h:593
Functor to establish the correspondence between a entity of the current mesh and that of the saved me...
const String & path() const
Path in the Hdf5 file containing the variable value.
void setPath(const String &path)
Sets the path in the Hdf5 file containing the variable value.
Interface of a data item.
Definition IData.h:34
Interface of a variable.
Definition IVariable.h:40
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Array< Int64 > Int64Array
Dynamic one-dimensional array of 64-bit integers.
Definition UtilsTypes.h:125
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
Array< Real3 > Real3Array
Dynamic one-dimensional array of rank 3 vectors.
Definition UtilsTypes.h:149