Go to the documentation of this file.
82 int writeCheckpoint(
const std::string &dataFilePath,
const bool append =
false)
const override
84 H5Eset_auto(H5E_DEFAULT, NULL, NULL);
88 if (append && H5Fis_hdf5(dataFilePath.c_str()) > 0) file = H5Fopen(dataFilePath.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
89 else file = H5Fcreate(dataFilePath.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
94 H5Gget_num_objs(file, &numObjects);
96 for (
int i = 0; i < int(numObjects); ++i)
98 if (H5Gget_objtype_by_idx(file, i) == H5G_GROUP)
102 const int groupNameMaxLength = 32;
103 char groupName[groupNameMaxLength];
104 H5Gget_objname_by_idx(file, i, groupName, groupNameMaxLength);
106 hid_t group = H5Gopen(file, groupName, H5P_DEFAULT);
107 hid_t attr = H5Aopen(group,
"cutoff", H5P_DEFAULT);
109 H5Aread(attr, H5T_NATIVE_FLOAT, &c);
115 Log::log << Log::LogLevel::Warning <<
"Found existing checkpoint at cutoff " + std::to_string(
cutoff) +
". Skipping checkpoint." << Log::endl;
121 std::string checkpointName =
"checkpoint_" + std::to_string(checkpointId);
124 hid_t group = H5Gcreate(file, checkpointName.c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
125 hsize_t attrSpaceSize[1] = { 1 };
126 const int attrSpaceDim = 1;
127 hid_t attrSpace = H5Screate_simple(attrSpaceDim, attrSpaceSize, NULL);
128 hid_t attr = H5Acreate(group,
"cutoff", H5T_NATIVE_FLOAT, attrSpace, H5P_DEFAULT, H5P_DEFAULT);
129 H5Awrite(attr, H5T_NATIVE_FLOAT, &
cutoff);
134 auto writeCheckpointDataset = [&group](
const std::string &identifier,
const int size,
const float *data)
136 const int dataSpaceDim = 1;
137 const hsize_t dataSpaceSize[1] = { (hsize_t)size };
138 hid_t dataSpace = H5Screate_simple(dataSpaceDim, dataSpaceSize, NULL);
139 hid_t dataset = H5Dcreate(group, identifier.c_str(), H5T_NATIVE_FLOAT, dataSpace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
140 H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
144 writeCheckpointDataset(
"cutoff", 1, &
cutoff);
164 bool readCheckpoint(
const std::string &dataFilePath,
const int checkpointId)
override
166 H5Eset_auto(H5E_DEFAULT, NULL, NULL);
169 hid_t file = H5Fopen(dataFilePath.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
173 std::string checkpointName;
174 if (checkpointId >= 0) checkpointName =
"checkpoint_" + std::to_string(checkpointId);
178 H5Gget_num_objs(file, &numObjects);
179 for (
int i =
int(numObjects) - 1; i >= 0; --i)
181 if (H5Gget_objtype_by_idx(file, i) == H5G_GROUP)
183 checkpointName =
"checkpoint_" + std::to_string(i);
189 hid_t group = H5Gopen(file, checkpointName.c_str(), H5P_DEFAULT);
190 if (group < 0)
return false;
193 auto readDataset = [&group](
const std::string &name,
float *data)->
bool
195 hid_t dataset = H5Dopen(group, name.c_str(), H5P_DEFAULT);
196 if (dataset < 0)
return false;
197 H5Dread(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
201 if (!readDataset(
"cutoff", &
cutoff))
return false;
FrgCore implementation for models with diagonal interactions.
Definition: XYZFrgCore.hpp:15
float * _data
Vertex data.
Definition: XYZVertexSingleParticle.hpp:103
@ None
No spin component specified.
XYZEffectiveAction()
Construct a new XYZEffectiveAction object.
Definition: XYZEffectiveAction.hpp:25
@ Z
z-component of a spin.
Two-particle vertex implementation for models with diagonal interactions.
Definition: XYZVertexTwoParticle.hpp:41
float * _dataZZ
Spin-Z channel of the vertex.
Definition: XYZVertexTwoParticle.hpp:660
float normalization
Energy normalization factor.
Definition: XYZFrgCore.hpp:44
void expandIterator(int iterator, LatticeIterator &i1, float &s, float &t, float &u) const
Expand a linear iterator in the range [0,size) that iterates over all vertex entries.
Definition: XYZVertexTwoParticle.hpp:100
~XYZEffectiveAction()
Destroy the XYZEffectiveAction object.
Definition: XYZEffectiveAction.hpp:68
Single-particle vertex implementation for models with diagonal interactions.
Definition: XYZVertexSingleParticle.hpp:17
@ IOError
In/out error, raised when input or output routines fail.
XYZVertexTwoParticle * vertexTwoParticle
Two-particle vertex data.
Definition: XYZEffectiveAction.hpp:238
Descriptor object for exceptions.
Definition: Exception.hpp:17
int size
Size of the vertex per vertex channel (number of elements).
Definition: XYZVertexTwoParticle.hpp:655
Spin model representation.
Definition: SpinModel.hpp:19
Virtual implementation of a flowing effective action.
Definition: EffectiveAction.hpp:19
float * _dataDD
Density channel of the vertex.
Definition: XYZVertexTwoParticle.hpp:661
Two-particle vertex implementation for models with diagonal interactions.
@ Y
y-component of a spin.
Lattice iterator object.
Definition: Lattice.hpp:166
float * _dataYY
Spin-Y channel of the vertex.
Definition: XYZVertexTwoParticle.hpp:659
float * _dataXX
Spin-X channel of the vertex.
Definition: XYZVertexTwoParticle.hpp:658
std::vector< std::pair< LatticeIterator, SpinInteraction > > interactions
List of two-spin interactions in the model. All interactions are between the lattice site pair (s1,...
Definition: SpinModel.hpp:38
float & getValueRef(const int iterator) const
Directly access a vertex value by reference via a linear iterator in the range [0,...
Definition: XYZVertexSingleParticle.hpp:60
float cutoff
Value of the RG cutoff.
Definition: EffectiveAction.hpp:59
Descriptor object for exceptions.
XYZEffectiveAction(const float cutoff, const SpinModel &spinModel, const XYZFrgCore *core)
Construct a new effective action and initialize values at given cutoff for a given spin model.
Definition: XYZEffectiveAction.hpp:38
int size
Total number of vertex elements.
Definition: XYZVertexSingleParticle.hpp:102
bool isDiverged() const override
Indicate whether the vertex has diverged to NaN.
Definition: XYZEffectiveAction.hpp:219
XYZVertexSingleParticle * vertexSingleParticle
Single-particle vertex data.
Definition: XYZEffectiveAction.hpp:237
Virtual implementation of a flowing effective action.
bool readCheckpoint(const std::string &dataFilePath, const int checkpointId) override
Read checkpoint from file.
Definition: XYZEffectiveAction.hpp:164
int writeCheckpoint(const std::string &dataFilePath, const bool append=false) const override
Write checkpoint file.
Definition: XYZEffectiveAction.hpp:82
Implementation of a flowing effective action for models with diagonal interactions.
Definition: XYZEffectiveAction.hpp:19
float & getValueRef(const int iterator, const SpinComponent symmetry) const
Directly access a vertex value via a linear iterator in the range [0,size).
Definition: XYZVertexTwoParticle.hpp:168
@ X
x-component of a spin.
Single-particle vertex implementation for models with diagonal interactions.
FrgCore implementation for models with diagonal interactions.