43template<
typename Type>
47 Eigen::SparseMatrix<double> A;
54template <
typename T,
int dim>
59 std::string message =
"The extension \"" + type +
60 "\" was not implemented. Check the list of possible extensions.";
61 M_Assert(type ==
"python" || type ==
"matlab"
62 || type ==
"eigen", message.c_str()
70 OFstream str(folder +
"/" + Name +
"_mat" + est);
71 str << Name <<
"=np.array([";
73 for (
int i = 0; i < matrix.rows(); i++)
75 for (
int j = 0; j < matrix.cols(); j++)
79 str <<
"[" << setprecision(10) << matrix(i, j);
83 str <<
"," << setprecision(10) << matrix(i, j);
87 if (i != (matrix.rows() - 1))
99 OFstream str(folder +
"/" + Name +
"_mat" + est);
102 for (
int i = 0; i < matrix.rows(); i++)
104 for (
int j = 0; j < matrix.cols(); j++)
106 str <<
" " << setprecision(10) << matrix(i, j);
109 if (i != (matrix.rows() - 1))
120 const static Eigen::IOFormat CSVFormat(6,
false,
", ",
"\n");
123 ofs.open (folder +
"/" + Name +
"_mat.txt");
125 for (
int i = 0; i < matrix.rows(); i++)
127 for (
int j = 0; j < matrix.cols(); j++)
135 ofs <<
" " << matrix(i, j);
139 if (i != (matrix.rows() - 1))
150 -1 > & matrix, word Name, word type,
154 -1 > & matrix, word Name, word type,
158 -1 > & matrix, word Name, word type,
162 1 > & matrix, word Name, word type,
166 1 > & matrix, word Name, word type,
170 1 > & matrix, word Name, word type,
174 word type, word folder)
176 std::string message =
"The extension \"" + type +
177 "\" was not implemented. Check the list of possible extensions.";
178 M_Assert(type ==
"python" || type ==
"matlab"
179 || type ==
"eigen", message.c_str()
185 if (type ==
"python")
188 OFstream str(folder +
"/" + Name +
"_mat" + est);
189 str << Name <<
"=np.zeros([" << matrix.size() <<
"," << matrix[0].rows() <<
190 "," << matrix[0].cols() <<
"])\n";
192 for (
int i = 0; i < matrix.size(); i++)
194 str << Name <<
"[" << i <<
",:,:]=np.array([";
196 for (
int j = 0; j < matrix[0].rows(); j++)
198 for (
int k = 0; k < matrix[0].cols(); k++)
202 str <<
"[" << setprecision(10) << matrix[i](j, k);
206 str <<
"," << setprecision(10) << matrix[i](j, k);
210 if (j != (matrix[0].rows() - 1))
216 str <<
"]])\n" << endl;
220 else if (type ==
"matlab")
223 OFstream str(folder +
"/" + Name +
"_mat" + est);
225 for (
int i = 0; i < matrix.size(); i++)
227 str << Name <<
"(" << i + 1 <<
",:,:)=[";
229 for (
int j = 0; j < matrix[0].rows(); j++)
231 for (
int k = 0; k < matrix[0].cols(); k++)
233 str <<
" " << setprecision(10) << matrix[i](j, k);
236 if (j != (matrix[0].rows() - 1))
245 else if (type ==
"eigen")
247 for (
int i = 0; i < matrix.size(); i++)
249 word Namei = Name + name(i);
255void exportVector(Eigen::VectorXd& vector,
256 word Name, word type,
259 Eigen::MatrixXd matrix = vector;
265 word type, word folder)
267 std::string message =
"The extension \"" + type +
268 "\" was not implemented. Check the list of possible extensions.";
269 M_Assert(type ==
"python" || type ==
"matlab"
270 || type ==
"eigen", message.c_str()
276 if (type ==
"python")
279 OFstream str(folder +
"/" + Name +
"_mat" + est);
280 str << Name <<
"=np.zeros([" << tensor.dimension(0) <<
"," <<
281 Eigen::SliceFromTensor(
284 "," << Eigen::SliceFromTensor(tensor, 0,
287 for (
int i = 0; i < tensor.dimension(0); i++)
289 str << Name <<
"[" << i <<
",:,:]=np.array([";
291 for (
int j = 0; j < Eigen::SliceFromTensor(tensor, 0, 0).rows(); j++)
293 for (
int k = 0; k < Eigen::SliceFromTensor(tensor, 0, 0).cols(); k++)
297 str <<
"[" << setprecision(10) << Eigen::SliceFromTensor(tensor, 0,
302 str <<
"," << setprecision(10) << Eigen::SliceFromTensor(tensor, 0,
307 if (j != (Eigen::SliceFromTensor(tensor, 0,
314 str <<
"]])\n" << endl;
318 else if (type ==
"matlab")
321 OFstream str(folder +
"/" + Name +
"_mat" + est);
323 for (
int i = 0; i < tensor.dimension(0); i++)
325 str << Name <<
"(" << i + 1 <<
",:,:)=[";
327 for (
int j = 0; j < Eigen::SliceFromTensor(tensor, 0,
330 for (
int k = 0; k < Eigen::SliceFromTensor(tensor, 0,
333 str <<
" " << setprecision(10) << Eigen::SliceFromTensor(tensor, 0,
337 if (j != (Eigen::SliceFromTensor(tensor, 0,
347 else if (type ==
"eigen")
349 for (
int i = 0; i < tensor.dimension(0); i++)
351 Eigen::Matrix < T, -1, -1 > matrixAux = Eigen::SliceFromTensor(tensor, 0, i);
352 word Namei = Name + name(i);
360template void exportTensor(Eigen::Tensor<double, 3> tensor,
362 word type, word folder);
366 word type, word folder);
368template void exportTensor(Eigen::Tensor<float, 3> tensor,
370 word type, word folder);
376 struct dirent* entry;
377 dirp = opendir(folder.c_str());
378 List <Eigen::MatrixXd> result;
380 while ((entry = readdir(dirp)) != NULL)
382 if (entry->d_type == DT_REG)
390 for (
int j = 0; j < file_count ; j++)
392 word matname = folder +
"/" + mat_name + name(j) +
"_mat.txt";
402 int cols = 0, rows = 0;
403 double buff[MAXBUFSIZE];
405 std::ifstream infile;
406 infile.open(filename.c_str());
407 std::string message =
"The matrix file \"" + filename +
408 "\" does not exist. Check the existence of the file or the way it is named.";
409 M_Assert(infile.good() != 0, message.c_str()
412 while (! infile.eof())
415 getline(infile, line);
417 std::stringstream stream(line);
419 while (! stream.eof())
421 stream >> buff[cols * rows + temp_cols++];
440 Eigen::MatrixXd result(rows, cols);
442 for (
int i = 0; i < rows; i++)
444 for (
int j = 0; j < cols; j++)
446 result(i, j) = buff[ cols * i + j ];
453template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
455 const GeometricField<Type, PatchField, GeoMesh>& field,
459 if (!Pstream::parRun())
461 fileName rootpath(
".");
462 Foam::Time runTime2(Foam::Time::controlDictName, rootpath, casename);
464 if (index >= runTime2.times().size() - 2)
467 <<
"Error: Index " << index <<
" is out of range. "
468 <<
"Maximum available index is " << runTime2.times().size() - 3
472 return GeometricField<Type, PatchField, GeoMesh>
477 casename +
"/" + runTime2.times()[index + 2].name(),
486 word timename(field.mesh().time().rootPath() +
"/" +
487 field.mesh().time().caseName());
488 timename = timename.substr(0, timename.find_last_of(
"\\/"));
489 timename = timename +
"/" + casename +
"/" +
"processor" + name(
490 Pstream::myProcNo());
492 "processor" + name(Pstream::myProcNo()));
494 if (index >= last_s - 1)
497 <<
"Error: Index " << index <<
" is out of range. "
498 <<
"Maximum available index is " << last_s - 2
502 return GeometricField<Type, PatchField, GeoMesh>
507 timename +
"/" + name(index + 1),
516template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
518 PtrList<GeometricField<Type, PatchField, GeoMesh >>& Lfield, word Name,
519 fileName casename,
int first_snap,
int n_snap)
522 const fvMesh& mesh = para->mesh;
523 const pointMesh& pMesh = pointMesh::New(mesh);
524 constexpr bool check_vol = std::is_same<volMesh, GeoMesh>::value
525 || std::is_same<surfaceMesh, GeoMesh>::value;
527 if (!Pstream::parRun())
529 Info <<
"######### Reading the Data for " << Name <<
" #########" << endl;
530 fileName rootpath(
".");
532 Foam::Time runTime2(Foam::Time::controlDictName, rootpath, casename);
534 if (first_snap >= runTime2.times().size())
536 Info <<
"Error the index of the first snapshot must be smaller than the number of snapshots"
543 last_s = runTime2.times().size();
547 last_s = min(runTime2.times().size(), n_snap + 2);
550 if constexpr(check_vol)
552 for (
int i = 2 + first_snap; i < last_s + first_snap; i++)
554 GeometricField<Type, PatchField, GeoMesh> tmp_field(
558 casename + runTime2.times()[i].name(),
564 Lfield.append(tmp_field.clone());
568 else if constexpr(std::is_same<pointMesh, GeoMesh>::value)
570 for (
int i = 2 + first_snap; i < last_s + first_snap; i++)
572 GeometricField<Type, PatchField, GeoMesh> tmp_field(
576 casename + runTime2.times()[i].name(),
582 Lfield.append(tmp_field.clone());
591 Info <<
"######### Reading the Data for " << Name <<
" #########" <<
593 word timename(mesh.time().rootPath() +
"/" +
594 mesh.time().caseName() );
595 timename = timename.substr(0, timename.find_last_of(
"\\/"));
596 timename = timename +
"/" + casename +
"/" +
"processor" + name(
597 Pstream::myProcNo());
599 "processor" + name(Pstream::myProcNo()) +
"/");
601 if (first_snap > last_s)
603 Info <<
"Error the index of the first snapshot must be smaller than the number of snapshots"
613 last_s = min(last_s, n_snap + 2);
616 if constexpr(check_vol)
618 for (
int i = 1 + first_snap; i < last_s + first_snap; i++)
620 GeometricField<Type, PatchField, GeoMesh> tmp_field(
624 timename +
"/" + name(i),
630 Lfield.append(tmp_field.clone());
634 else if constexpr(std::is_same<pointMesh, GeoMesh>::value)
636 for (
int i = 1 + first_snap; i < last_s + first_snap; i++)
638 GeometricField<Type, PatchField, GeoMesh> tmp_field(
642 timename +
"/" + name(i),
648 Lfield.append(tmp_field.clone());
657template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
659 PtrList<GeometricField<Type, PatchField, GeoMesh >>& Lfield,
660 GeometricField<Type, PatchField, GeoMesh>& field,
661 fileName casename,
int first_snap,
int n_snap)
664 const fvMesh& mesh = para->mesh;
665 const pointMesh& pMesh = pointMesh::New(mesh );
666 constexpr bool check_vol = std::is_same<volMesh, GeoMesh>::value
667 || std::is_same<surfaceMesh, GeoMesh>::value;
669 if (!Pstream::parRun())
671 Info <<
"######### Reading the Data for " << field.name() <<
" #########" <<
673 fileName rootpath(
".");
674 Foam::Time runTime2(Foam::Time::controlDictName, rootpath, casename);
677 if (first_snap >= runTime2.times().size())
679 Info <<
"Error the index of the first snapshot must be smaller than the number of snapshots"
686 last_s = runTime2.times().size();
690 last_s = min(runTime2.times().size(), n_snap + 2);
693 if constexpr(check_vol)
695 for (
int i = 2 + first_snap; i < last_s + first_snap; i++)
697 GeometricField<Type, PatchField, GeoMesh> tmp_field(
701 casename + runTime2.times()[i].name(),
707 Lfield.append(tmp_field.clone());
711 else if constexpr(std::is_same<pointMesh, GeoMesh>::value)
713 for (
int i = 2 + first_snap; i < last_s + first_snap; i++)
715 GeometricField<Type, PatchField, GeoMesh> tmp_field(
719 casename + runTime2.times()[i].name(),
720 field.mesh().thisDb(),
725 Lfield.append(tmp_field.clone());
734 Info <<
"################ Parallel Reading the Data for " << field.name() <<
" #########" <<
737 word timename = casename +
"processor" + name(Pstream::myProcNo());
738 Foam::Time runTime2(Foam::Time::controlDictName,
".", timename);
739 int last_s = runTime2.times().size();
741 timename = field.mesh().time().rootPath() +
"/" + field.mesh().time().caseName();
742 timename = timename.substr(0, timename.find_last_of(
"\\/"));
743 timename = timename +
"/" + casename +
"/" +
"processor" + name(
744 Pstream::myProcNo());
746 if (first_snap > last_s)
748 Info <<
"Error the index of the first snapshot must be smaller than the number of snapshots"
758 last_s = min(last_s, n_snap + 2);
761 if constexpr(check_vol)
763 for (
int i = 2 + first_snap; i < last_s + first_snap; i++)
765 GeometricField<Type, PatchField, GeoMesh> tmp_field(
769 timename +
"/" + runTime2.times()[i].name(),
775 Lfield.append(tmp_field.clone());
784template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
786 PtrList<GeometricField<Type, PatchField, GeoMesh >>& Lfield,
787 GeometricField<Type, PatchField, GeoMesh>& field, fileName casename)
791 "No parameter dependent solutions stored into Offline folder");
795 read_fields(Lfield, field, casename +
"/" + name(par));
800template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
802 PtrList<GeometricField<Type, PatchField, GeoMesh >>& Lfield,
803 GeometricField<Type, PatchField, GeoMesh>& field,
808 "No parameter dependent solutions stored into Offline folder");
809 Info <<
"######### Reading the Data for " << field.name() <<
" #########" << endl;
821 GeometricField<Type, PatchField, GeoMesh> tmpField(
825 casename +
"/" + name(par) +
"/" + name(last - 1),
831 Lfield.append(tmpField.clone());
836template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
838 PtrList<GeometricField<Type, PatchField, GeoMesh >>& Lfield,
839 const GeometricField<Type, PatchField, GeoMesh>& field,
840 const fileName casename)
842 if (!Pstream::parRun())
844 Info <<
"######### Reading the Data for " << field.name() <<
" #########" <<
846 fileName rootpath(
".");
847 Foam::Time runTime2(Foam::Time::controlDictName, rootpath, casename);
848 int last_s (runTime2.times().size());
849#if defined(OFVER) && (OFVER >= 2212)
855 casename +
"/" + runTime2.times()[last_s - 1].name(),
863 autoPtr<GeometricField<Type, PatchField, GeoMesh >>::New
868 casename +
"/" + runTime2.times()[last_s - 1].name(),
874 Lfield.append(std::move(tfld));
880 Info <<
"######### Reading the Data for " << field.name() <<
" #########" <<
882 word timename(field.mesh().time().rootPath() +
"/" +
883 field.mesh().time().caseName() );
884 timename = timename.substr(0, timename.find_last_of(
"\\/"));
885 timename = timename +
"/" + casename +
"/" +
"processor" + name(
886 Pstream::myProcNo());
888 "processor" + name(Pstream::myProcNo()));
889#if defined(OFVER) && (OFVER >= 2212)
895 timename +
"/" + name(last_s - 1),
903 autoPtr<GeometricField<Type, PatchField, GeoMesh >>::New
908 timename +
"/" + name(last_s - 1),
914 Lfield.append(std::move(tfld));
920template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
922 PtrList<GeometricField<Type, PatchField, GeoMesh >>& Lfield,
923 const GeometricField<Type, PatchField, GeoMesh>& field,
924 const fileName casename)
928 "No parameter dependent solutions stored into Offline folder");
939 int number_of_files = 0;
941 in.open(folder +
"/" + MatrixName + name(0) + ext,
942 std::ios::in | std::ios::binary);
943 Info << folder +
"/" + MatrixName + name(0) + ext << endl;
949 in.open(folder +
"/" + MatrixName + name(number_of_files) + ext,
950 std::ios::in | std::ios::binary);
954 return number_of_files;
957template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
959 PtrList<GeometricField<Type, PatchField, GeoMesh >>& field,
960 word folder, word fieldname)
963 Info <<
"######### Exporting the Data for " << fieldname <<
" #########" <<
966 for (
int j = 0; j < field.size() ; j++)
976 PtrList<GeometricField<scalar, fvPatchField, volMesh >>& field,
977 word folder, word fieldname);
979 PtrList<GeometricField<scalar, fvsPatchField, surfaceMesh >>& field,
980 word folder, word fieldname);
982 PtrList<GeometricField<vector, fvPatchField, volMesh >>& field,
983 word folder, word fieldname);
985 PtrList<GeometricField<tensor, fvPatchField, volMesh >>& field,
986 word folder, word fieldname);
988 PtrList<GeometricField<vector, pointPatchField, pointMesh>>& field,
989 word folder, word fieldname);
991template<
class Type,
template<
class>
class PatchField,
class GeoMesh >
993 fileName subfolder, fileName folder,
996 if (!Pstream::parRun())
998 mkDir(folder +
"/" + subfolder);
1000 GeometricField<Type, PatchField, GeoMesh> act(fieldName, s);
1001 fileName fieldname = folder +
"/" + subfolder +
"/" + fieldName;
1002 OFstream os(fieldname);
1003 act.writeHeader(os);
1008 mkDir(folder +
"/processor" + name(Pstream::myProcNo()) +
"/" + subfolder);
1010 GeometricField<Type, PatchField, GeoMesh> act(fieldName, s);
1011 fileName fieldname = folder +
"/processor" + name(Pstream::myProcNo()) +
"/" +
1012 subfolder +
"/" + fieldName;
1013 OFstream os(fieldname);
1014 act.writeHeader(os);
1020 GeometricField<scalar, fvPatchField, volMesh>& s,
1021 fileName subfolder, fileName folder,
1024 GeometricField<vector, fvPatchField, volMesh>& s,
1025 fileName subfolder, fileName folder,
1028 GeometricField<tensor, fvPatchField, volMesh>& s,
1029 fileName subfolder, fileName folder,
1032 GeometricField<scalar, fvsPatchField, surfaceMesh>& s,
1033 fileName subfolder, fileName folder,
1036 GeometricField<vector, fvsPatchField, surfaceMesh>& s,
1037 fileName subfolder, fileName folder,
1040template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1042 fileName subfolder, fileName folder)
1044 if (!Pstream::parRun())
1046 mkDir(folder +
"/" + subfolder);
1048 fileName fieldname = folder +
"/" + subfolder +
"/" + s.name();
1049 OFstream os(fieldname);
1055 mkDir(folder +
"/processor" + name(Pstream::myProcNo()) +
"/" + subfolder);
1057 fileName fieldname = folder +
"/processor" + name(Pstream::myProcNo()) +
"/" +
1058 subfolder +
"/" + s.name();
1059 OFstream os(fieldname);
1066 GeometricField<scalar, fvPatchField, volMesh>& s,
1067 fileName subfolder, fileName folder);
1069 GeometricField<vector, fvPatchField, volMesh>& s,
1070 fileName subfolder, fileName folder);
1072 GeometricField<tensor, fvPatchField, volMesh>& s,
1073 fileName subfolder, fileName folder);
1075 GeometricField<scalar, fvsPatchField, surfaceMesh>& s,
1076 fileName subfolder, fileName folder);
1079 GeometricField<vector, fvsPatchField, surfaceMesh>& s,
1080 fileName subfolder, fileName folder);
1083 GeometricField<scalar, pointPatchField, pointMesh>& s,
1084 fileName subfolder, fileName folder);
1086 GeometricField<vector, pointPatchField, pointMesh>& s,
1087 fileName subfolder, fileName folder);
1089 GeometricField<tensor, pointPatchField, pointMesh>& s,
1090 fileName subfolder, fileName folder);
1095 if (!Pstream::parRun())
1097 mkDir(folder +
"/" + subfolder);
1099 fileName fieldname = folder +
"/" + subfolder +
"/" +
"points";
1100 OFstream os(fieldname);
1101 os <<
"FoamFile \n { \n version 2.0; \n format ascii; \n class vectorField; \n location ""1 / polyMesh""; \n object points; \n }"
1103 os << points << endl;
1107 mkDir(folder +
"/processor" + name(Pstream::myProcNo()) +
"/" + subfolder);
1109 fileName fieldname = folder +
"/processor" + name(Pstream::myProcNo()) +
"/" +
1110 subfolder +
"/" +
"points";
1111 OFstream os(fieldname);
1112 os <<
"FoamFile \n { \n version 2.0; \n format ascii; \n class vectorField; \n location ""1 / polyMesh""; \n object points; \n }"
1114 os << points << endl;
1120 int val =
static_cast<int>(percentage * 100);
1121 int lpad =
static_cast<int> (percentage * PBWIDTH);
1122 int rpad = PBWIDTH - lpad;
1124 if (Pstream::master())
1126 printf (
"\r%3d%% [%.*s%*s]", val, lpad, PBSTR, rpad,
"");
1132void save(
const List<Eigen::SparseMatrix<T >>& MatrixList, word folder,
1137 for (
int i = 0; i < MatrixList.size(); i++)
1139 word fileName = folder +
"/" + MatrixName + name(i) +
".npz";
1140 cnpy::save(MatrixList[i], fileName);
1145void load(List<Eigen::SparseMatrix<T >>& MatrixList, word folder,
1148 int number_of_files =
numberOfFiles(folder, MatrixName,
".npz");
1149 Info <<
"Reading the Matrix " + folder +
"/" + MatrixName << endl;
1150 M_Assert(number_of_files != 0,
1151 "Check if the file you are trying to read exists" );
1152 MatrixList.resize(0);
1153 Eigen::SparseMatrix<T> A;
1155 for (
int i = 0; i < number_of_files; i++)
1157 cnpy::load(A, folder +
"/" + MatrixName + name(i) +
".npz");
1158 MatrixList.append(A);
1161template void read_fields(PtrList<pointVectorField>& Lfield, word Name,
1162 fileName casename,
int first_snap,
int n_snap);
1163template void read_fields(PtrList<pointVectorField>& Lfield,
1164 pointVectorField& field,
1165 fileName casename,
int first_snap,
int n_snap);
1167template void read_fields(PtrList<volScalarField>& Lfield,
1169 fileName casename,
int first_snap,
int n_snap);
1170template void read_fields(PtrList<volVectorField>& Lfield,
1172 fileName casename,
int first_snap,
int n_snap);
1173template void read_fields(PtrList<volTensorField>& Lfield,
1175 fileName casename,
int first_snap,
int n_snap);
1176template void read_fields(PtrList<surfaceScalarField>& Lfield,
1178 fileName casename,
int first_snap,
int n_snap);
1179template void read_fields(PtrList<surfaceVectorField>& Lfield,
1181 fileName casename,
int first_snap,
int n_snap);
1182template void read_fields(PtrList<volScalarField>& Lfield,
1183 volScalarField& field, fileName casename,
int first_snap,
int n_snap);
1184template void read_fields(PtrList<volVectorField>& Lfield,
1185 volVectorField& field, fileName casename,
int first_snap,
int n_snap);
1186template void read_fields(PtrList<volTensorField>& Lfield,
1187 volTensorField& field, fileName casename,
int first_snap,
int n_snap);
1188template void read_fields(PtrList<surfaceScalarField>& Lfield,
1189 surfaceScalarField& field, fileName casename,
int first_snap,
int n_snap);
1190template void read_fields(PtrList<surfaceVectorField>& Lfield,
1191 surfaceVectorField& field, fileName casename,
int first_snap,
int n_snap);
1193 volScalarField& field, fileName casename);
1196 pointVectorField& field, fileName casename);
1198 volVectorField& field, fileName casename);
1200 volTensorField& field, fileName casename);
1202 Lfield, surfaceScalarField& field, fileName casename);
1204 Lfield, surfaceVectorField& field, fileName casename);
1206 volScalarField& field, fileName casename);
1208 volVectorField& field, fileName casename);
1210 volTensorField& field, fileName casename);
1212 Lfield, surfaceScalarField& field, fileName casename);
1214 Lfield, surfaceVectorField& field, fileName casename);
1217 const volScalarField& field,
const fileName casename);
1219 const volVectorField& field,
const fileName casename);
1221 const volTensorField& field,
const fileName casename);
1223 const surfaceScalarField& field,
const fileName casename);
1225 const surfaceVectorField& field,
const fileName casename);
1227 const volScalarField& field,
const fileName casename);
1229 const volVectorField& field,
const fileName casename);
1231 const volTensorField& field,
const fileName casename);
1233 Lfield,
const surfaceScalarField& field,
const fileName casename);
1235 Lfield,
const surfaceVectorField& field,
const fileName casename);
1243 word fieldname = folder +
"/" + filename;
1244 OFstream os(fieldname);
1246 for (
int i = 0; i < list.size(); i++)
1248 os << list[i] << endl;
1252template void exportList(Field<scalar>& list, word folder,
1254template void exportList(Field<vector>& list, word folder,
1256template void exportList(Field<tensor>& list, word folder,
1259template void save(
const List<Eigen::SparseMatrix<double >>& MatrixList,
1260 word folder, word MatrixName);
1262template void load(List<Eigen::SparseMatrix<double >>& MatrixList, word folder,
1266template GeometricField<scalar, fvPatchField, volMesh>
1268 const GeometricField<scalar, fvPatchField, volMesh>&,
1272template GeometricField<vector, fvPatchField, volMesh>
1274 const GeometricField<vector, fvPatchField, volMesh>&,
1278template GeometricField<tensor, fvPatchField, volMesh>
1280 const GeometricField<tensor, fvPatchField, volMesh>&,
1284template GeometricField<scalar, fvsPatchField, surfaceMesh>
1286 const GeometricField<scalar, fvsPatchField, surfaceMesh>&,
1290template GeometricField<vector, fvsPatchField, surfaceMesh>
1292 const GeometricField<vector, fvsPatchField, surfaceMesh>&,
1298void read_snapshot(T& snapshot,
const Foam::word snap_time,
1299 Foam::word path, Foam::word name)
1302 const fvMesh& mesh = snapshot.mesh();
1303 word arg_path = path;
1304 word pathProcessor =
"";
1306 if (name ==
"default_name")
1308 name = snapshot.name();
1311 if (Pstream::parRun())
1314 word path_start = mesh.time().rootPath() +
"/" + mesh.time().caseName();
1315 path_start = path_start.substr(0, path_start.find_last_of(
"\\/")) +
"/";
1316 pathProcessor =
"/processor" + std::to_string(Pstream::myProcNo());
1320 path = path_start + arg_path.substr(0, arg_path.find_last_of(
"\\/")) + pathProcessor
1321 +
"/" + arg_path.substr(arg_path.find_last_of(
"\\/"), arg_path.size());
1325 path = path_start + arg_path;
1333 path = path +
"/" + snap_time;
1337 Info <<
"Error: data not found at :" << endl;
1338 Info << path << endl;
1339 Info << name << endl;
1355 snapshot = snapshot_dummy;
1359template void read_snapshot(Foam::volScalarField& snapshot,
1360 const Foam::word snap_time, Foam::word path, Foam::word name);
1361template void read_snapshot(Foam::volVectorField& snapshot,
1362 const Foam::word snap_time, Foam::word path, Foam::word name);
1363template void read_snapshot(Foam::volTensorField& snapshot,
1364 const Foam::word snap_time, Foam::word path, Foam::word name);