10 #ifndef SFCSORTBENCH_CHECKPOINT_H 11 #define SFCSORTBENCH_CHECKPOINT_H 35 int writeOctToFile(
const char * fName,
const ot::TreeNode* pNodes,
const unsigned int num);
43 int readOctFromFile(
const char * fName,std::vector<ot::TreeNode> & pNodes);
56 int writeVecToFile(
const char * fName,
const ot::Mesh* pMesh,
const T* vec);
69 int writeVecToFile(
const char * fName,
const ot::Mesh* pMesh,
const T** vec,
const unsigned int numVars);
78 int readVecFromFile(
const char * fName,
const ot::Mesh* pMesh, T* vec);
89 int readVecFromFile(
const char * fName,
const ot::Mesh* pMesh, T** vec,
const unsigned int numVars);
107 template <
typename T>
108 int writeVecToFile(
const char * fName,
const ot::Mesh* pMesh,
const T* vec)
114 FILE * outfile=fopen(fName,
"w");
115 if(outfile==NULL){std::cout<<fName<<
" file open failed "<<std::endl;
return 1;}
117 fwrite(&numNodes,
sizeof(
unsigned int ),1,outfile);
118 fwrite(&nLocalBegin,
sizeof(
unsigned int ),1,outfile);
119 fwrite(&nLocalEnd,
sizeof(
unsigned int ),1,outfile);
129 template <
typename T>
130 int writeVecToFile(
const char * fName,
const ot::Mesh* pMesh,
const T** vec,
const unsigned int numVars)
136 FILE * outfile=fopen(fName,
"w");
137 if(outfile==NULL){std::cout<<fName<<
" file open failed "<<std::endl;
return 1;}
139 fwrite(&numNodes,
sizeof(
unsigned int ),1,outfile);
140 fwrite(&nLocalBegin,
sizeof(
unsigned int ),1,outfile);
141 fwrite(&nLocalEnd,
sizeof(
unsigned int ),1,outfile);
143 for(
unsigned int i=0;i<numVars;i++)
152 template <
typename T>
153 int readVecFromFile(
const char * fName,
const ot::Mesh* pMesh,T* vec)
156 unsigned int numNodes,nLocalBegin,nLocalEnd;
158 FILE * infile = fopen(fName,
"r");
159 if(infile==NULL){std::cout<<fName<<
" file open failed "<<std::endl;
return 1;}
160 fread(&numNodes,
sizeof(
unsigned int ),1,infile);
161 fread(&nLocalBegin,
sizeof(
unsigned int ),1,infile);
162 fread(&nLocalEnd,
sizeof(
unsigned int ),1,infile);
165 if(nLocalBegin!=pMesh->
getNodeLocalBegin()) {std::cout<<fName<<
" file local node begin location mismatched with the mesh. "<<std::endl;
return 1;}
166 if(nLocalEnd!=pMesh->
getNodeLocalEnd()) {std::cout<<fName<<
" file local node end location mismatched with the mesh. "<<std::endl;
return 1;}
175 template <
typename T>
176 int readVecFromFile(
const char * fName,
const ot::Mesh* pMesh, T** vec,
const unsigned int numVars)
178 unsigned int numNodes,nLocalBegin,nLocalEnd;
180 FILE * infile = fopen(fName,
"r");
181 if(infile==NULL){std::cout<<fName<<
" file open failed "<<std::endl;
return 1;}
182 fread(&numNodes,
sizeof(
unsigned int ),1,infile);
183 fread(&nLocalBegin,
sizeof(
unsigned int ),1,infile);
184 fread(&nLocalEnd,
sizeof(
unsigned int ),1,infile);
187 if(nLocalBegin!=pMesh->
getNodeLocalBegin()) {std::cout<<fName<<
" file local node begin location mismatched with the mesh. "<<std::endl;
return 1;}
188 if(nLocalEnd!=pMesh->
getNodeLocalEnd()) {std::cout<<fName<<
" file local node end location mismatched with the mesh. "<<std::endl;
return 1;}
191 for(
unsigned int i=0;i<numVars;i++)
206 #endif //SFCSORTBENCH_CHECKPOINT_H unsigned int getNumPostMeshNodes() const
return the number of post ghost mesh nodes
Definition: mesh.h:1024
a class to store JSON values
Definition: json.hpp:85
A class to manage octants.
Definition: TreeNode.h:35
basic_json<> json
default JSON class
Definition: json.hpp:109
unsigned int getNodeLocalBegin() const
return the location of local node begin
Definition: mesh.h:1043
contains functions to dump out raw data asci/binary. Can be useful for debugging purposes.
Definition: rawIO.h:19
unsigned int getNumPreMeshNodes() const
return the number of pre ghost mesh nodes
Definition: mesh.h:1022
unsigned int getNumLocalMeshNodes() const
return the number of nodes local to the mesh
Definition: mesh.h:1020
unsigned int getNodeLocalEnd() const
return the location of local node end
Definition: mesh.h:1045