Loading...
Searching...
No Matches
ITHACAstream.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ██╗████████╗██╗ ██╗ █████╗ ██████╗ █████╗ ███████╗██╗ ██╗
3 ██║╚══██╔══╝██║ ██║██╔══██╗██╔════╝██╔══██╗ ██╔════╝██║ ██║
4 ██║ ██║ ███████║███████║██║ ███████║█████╗█████╗ ██║ ██║
5 ██║ ██║ ██╔══██║██╔══██║██║ ██╔══██║╚════╝██╔══╝ ╚██╗ ██╔╝
6 ██║ ██║ ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ╚████╔╝
7 ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═══╝
8
9 * In real Time Highly Advanced Computational Applications for Finite Volumes
10 * Copyright (C) 2017 by the ITHACA-FV authors
11-------------------------------------------------------------------------------
12License
13 This file is part of ITHACA-FV
14 ITHACA-FV is free software: you can redistribute it and/or modify
15 it under the terms of the GNU Lesser General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18 ITHACA-FV is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU Lesser General Public License for more details.
22 You should have received a copy of the GNU Lesser General Public License
23 along with ITHACA-FV. If not, see <http://www.gnu.org/licenses/>.
24Class
25 ITHACAstream
26Description
27 Methods for input and outputs from and to files
28SourceFiles
29 ITHACAstream.C
30 ITHACAstreamTemplates.C
31\*---------------------------------------------------------------------------*/
32
38
39#ifndef ITHACAstream_H
40#define ITHACAstream_H
41
42#include "fvCFD.H"
43#include "IOmanip.H"
44#include <stdio.h>
45#include <sys/types.h>
46#include <dirent.h>
47#include <algorithm>
48#include <fstream>
49#include <string>
50#include <stdexcept>
51#include <sstream>
52#include <vector>
53#include <cstdio>
54#include <typeinfo>
55#include <iostream>
56#include <cassert>
57#include <zlib.h>
58#include <map>
59#include "ITHACAassert.H"
60#include "ITHACAparameters.H"
61#include "ITHACAutilities.H"
62#pragma GCC diagnostic push
63#pragma GCC diagnostic ignored "-Wold-style-cast"
64#pragma GCC diagnostic ignored "-Wignored-attributes"
65#include <Eigen/Eigen>
66#include "EigenFunctions.H"
67
68#include <unsupported/Eigen/CXX11/Tensor>
69#pragma GCC diagnostic pop
70
71#define MAXBUFSIZE (static_cast<int> (1e6))
72#define PBSTR "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
73#define PBWIDTH 60
74
75// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
76
77
78/*---------------------------------------------------------------------------*\
79 Namespace ITHACAstream Declaration
80\*---------------------------------------------------------------------------*/
81
82#pragma GCC diagnostic push
83#pragma GCC diagnostic ignored "-Wold-style-cast"
84#include "cnpy.H"
85#pragma GCC diagnostic pop
86
88namespace ITHACAstream
89{
90
91//--------------------------------------------------------------------------
100template<typename Type>
101void exportFvMatrix(fvMatrix<Type>& Matrix, word folder,
102 word MatrixName);
103
104//--------------------------------------------------------------------------
115template<typename T, int dim>
116void exportMatrix(Eigen::Matrix < T, -1, dim > & matrix, word Name,
117 word type = "python", word folder = "./Matrices");
118
119//--------------------------------------------------------------------------
130void exportMatrix(List <Eigen::MatrixXd>& matrix, word Name,
131 word type = "python", word folder = "./Matrices");
132
133//--------------------------------------------------------------------------
144template<typename T>
145void exportTensor(Eigen::Tensor<T, 3 > tensor, word Name,
146 word type = "python", word folder = "./Matrices");
147
148
149//----------------------------------------------------------------------
165template<class Type, template<class> class PatchField, class GeoMesh>
166void read_fields(PtrList<GeometricField<Type, PatchField, GeoMesh >> &
167 Lfield, word Name,
168 fileName casename, int first_snap = 0, int n_snap = 0);
169
170
171
172//----------------------------------------------------------------------
188template<class Type, template<class> class PatchField, class GeoMesh >
189void read_fields(PtrList<GeometricField<Type, PatchField, GeoMesh >> &
190 Lfield,
191 GeometricField<Type, PatchField, GeoMesh>& field,
192 fileName casename, int first_snap = 0, int n_snap = 0);
193
194//----------------------------------------------------------------------
207template<class Type, template<class> class PatchField, class GeoMesh>
208void readMiddleFields(PtrList<GeometricField<Type, PatchField, GeoMesh >> &
209 Lfield,
210 GeometricField<Type, PatchField, GeoMesh>& field,
211 fileName casename);
212
213//----------------------------------------------------------------------
226template<class Type, template<class> class PatchField, class GeoMesh>
228 PtrList<GeometricField<Type, PatchField, GeoMesh >> & Lfield,
229 GeometricField<Type, PatchField, GeoMesh>& field,
230 fileName casename);
231
232//----------------------------------------------------------------------
240
245template<class Type, template<class> class PatchField, class GeoMesh>
246void read_last_fields(PtrList<GeometricField<Type, PatchField, GeoMesh >> &
247 Lfield,
248 const GeometricField<Type, PatchField, GeoMesh>& field,
249 const fileName casename);
250
251//----------------------------------------------------------------------
264template<class Type, template<class> class PatchField, class GeoMesh>
265void readLastFields(PtrList<GeometricField<Type, PatchField, GeoMesh >> &
266 Lfield,
267 const GeometricField<Type, PatchField, GeoMesh>& field,
268 const fileName casename);
269
270//--------------------------------------------------------------------------
281template<class Type, template<class> class PatchField, class GeoMesh>
282void exportFields(PtrList<GeometricField<Type, PatchField, GeoMesh >> &
283 field,
284 word folder, word fieldname);
285
286//--------------------------------------------------------------------------
288/* One has to provide the complete filename with the absolute or relative path */
294Eigen::MatrixXd readMatrix(word filename);
295
296//--------------------------------------------------------------------------
298/* One has to provide the folder containing the matrix files and the filename of the
299 the matrix. Since it is stored as a List of matrices each matrix must be stored in a
300 different file with the following format:
301 matFileName(i)_mat.txt */
308List <Eigen::MatrixXd> readMatrix(word folder, word mat_name);
309
310//--------------------------------------------------------------------------
322template<class Type, template<class> class PatchField, class GeoMesh>
323void exportSolution(GeometricField<Type, PatchField, GeoMesh>& s,
324 fileName subfolder, fileName folder,
325 word fieldName);
326
327//--------------------------------------------------------------------------
338template<class Type, template<class> class PatchField, class GeoMesh>
339void exportSolution(GeometricField<Type, PatchField, GeoMesh>& s,
340 fileName subfolder, fileName folder);
341
342//--------------------------------------------------------------------------
351template<typename T>
352void exportList(T& list, word folder, word filename);
353
354
355//--------------------------------------------------------------------------
366template <typename T, int Nrows, typename IND>
367void SaveSparseMatrix(Eigen::SparseMatrix<T, Nrows, IND>& m,
368 word folder, word MatrixName);
369
370//--------------------------------------------------------------------------
381template <typename T, int Nrows, typename IND>
382void ReadSparseMatrix(Eigen::SparseMatrix<T, Nrows, IND>& m,
383 word folder, word MatrixName);
384
385//--------------------------------------------------------------------------
394template <typename MatrixType>
395void SaveDenseMatrix(MatrixType& Matrix, word folder, word MatrixName);
396
397//--------------------------------------------------------------------------
406template <typename MatrixType>
407void ReadDenseMatrix(MatrixType& Matrix, word folder, word MatrixName);
408
409
410//----------------------------------------------------------------------
419template <typename TensorType>
420void SaveDenseTensor(TensorType& Tensor, word folder, word MatrixName);
421
422
423//----------------------------------------------------------------------
432template <typename TensorType>
433void ReadDenseTensor(TensorType& Tensor, word folder, word MatrixName);
434
435//--------------------------------------------------------------------------
444template <typename MatrixType>
445void SaveSparseMatrixList(List<MatrixType>& MatrixList, word folder,
446 word MatrixName);
447
448//--------------------------------------------------------------------------
459template <typename T, int Nrows, typename IND>
460void ReadSparseMatrixList(List<Eigen::SparseMatrix<T, Nrows, IND >> & m,
461 word folder, word MatrixName);
462
463//--------------------------------------------------------------------------
472template <typename MatrixType>
473void SaveDenseMatrixList(List<MatrixType>& MatrixList, word folder,
474 word MatrixName);
475
476
477//--------------------------------------------------------------------------
486template <typename MatrixType>
487void ReadDenseMatrixList(List<MatrixType>& m, word folder,
488 word MatrixName);
489
490//--------------------------------------------------------------------------
498int numberOfFiles(word folder, word MatrixName, word ext = "");
499
500//--------------------------------------------------------------------------
507void writePoints(pointField points, fileName folder, fileName subfolder);
508
509//--------------------------------------------------------------------------
514void printProgress(double percentage);
515
516template<typename T>
517void save(const List<Eigen::SparseMatrix<T >> & MatrixList, word folder,
518 word MatrixName);
519
520template<typename T>
521void load(List<Eigen::SparseMatrix<T >> & MatrixList, word folder,
522 word MatrixName);
523
524//--------------------------------------------------------------------------
537template<class Type, template<class> class PatchField, class GeoMesh >
538GeometricField<Type, PatchField, GeoMesh> readFieldByIndex(
539 const GeometricField<Type, PatchField, GeoMesh>& field,
540 fileName casename,
541 label index
542);
543
544};
545
546namespace Foam
547{
548template<typename T>
549Ostream& operator<< (Ostream& os, const Eigen::Matrix < T, -1, -1 > & mat)
550{
551 os << mat.rows() << mat.cols() << UList<T>(const_cast<Eigen::MatrixXd&>
552 (mat).data(), mat.size());
553 return os;
554}
555
556template<typename T>
557Istream& operator>> (Istream& is, Eigen::Matrix < T, -1, -1 > & mat)
558{
559 int nrow, ncol;
560 is >> nrow >> ncol;
561 mat.resize(nrow, ncol);
562 UList<T> list(mat.data(), nrow * ncol);
563 is >> list;
564 return is;
565}
566
567template<typename T>
568Ostream& operator<< (Ostream& os, const Eigen::Matrix < T, -1, 1 > & mat)
569{
570 os << mat.rows() << mat.cols() << UList<T>(const_cast<Eigen::VectorXd&>
571 (mat).data(), mat.size());
572 return os;
573}
574
575template<typename T>
576Istream& operator>> (Istream& is, Eigen::Matrix < T, -1, 1 > & mat)
577{
578 int nrow, ncol;
579 is >> nrow >> ncol;
580 mat.resize(nrow, ncol);
581 UList<T> list(mat.data(), nrow * ncol);
582 is >> list;
583 return is;
584}
585
586template<typename T>
587Ostream& operator<< (Ostream& os, const Eigen::Tensor<T, 3>& tens)
588{
589 os << tens.dimension(0) << tens.dimension(1) << tens.dimension(
590 2) << UList<T>(const_cast<Eigen::Tensor<T, 3>&>(tens).data(),
591 tens.size());
592 return os;
593}
594
595template<typename T>
596Istream& operator>> (Istream& is, Eigen::Tensor<T, 3>& tens)
597{
598 int d1, d2, d3;
599 is >> d1 >> d2 >> d3;
600 tens.resize(d1, d2, d3);
601 UList<T> list(tens.data(), d1 * d2 * d3);
602 is >> list;
603 return is;
604}
605
606}
607
608template <typename T, int whatever, typename IND>
609void ITHACAstream::SaveSparseMatrix(Eigen::SparseMatrix<T, whatever, IND>& m,
610 word folder, word MatrixName)
611{
612 typedef Eigen::Triplet<int> Trip;
613 std::vector<Trip> res;
614 m.makeCompressed();
615 mkDir(folder);
616 std::fstream writeFile;
617 writeFile.open(folder + MatrixName, std::ios::binary | std::ios::out);
618
619 if (writeFile.is_open())
620 {
621 IND rows, cols, nnzs, outS, innS;
622 rows = m.rows() ;
623 cols = m.cols() ;
624 nnzs = m.nonZeros() ;
625 outS = m.outerSize();
626 innS = m.innerSize();
627 writeFile.write(reinterpret_cast<const char*> (& rows), sizeof(IND));
628 writeFile.write(reinterpret_cast<const char*> (& cols), sizeof(IND));
629 writeFile.write(reinterpret_cast<const char*> (& nnzs), sizeof(IND));
630 writeFile.write(reinterpret_cast<const char*> (& outS), sizeof(IND));
631 writeFile.write(reinterpret_cast<const char*> (& innS), sizeof(IND));
632 writeFile.write(reinterpret_cast<const char*>(m.valuePtr()),
633 sizeof(T ) * m.nonZeros());
634 writeFile.write(reinterpret_cast<const char*>(m.outerIndexPtr()),
635 sizeof(IND) * m.outerSize());
636 writeFile.write(reinterpret_cast<const char*>(m.innerIndexPtr()),
637 sizeof(IND) * m.nonZeros());
638 writeFile.close();
639 }
640}
641
642template <typename T, int whatever, typename IND>
643void ITHACAstream::ReadSparseMatrix(Eigen::SparseMatrix<T, whatever, IND>& m,
644 word folder, word MatrixName)
645{
646 std::fstream readFile;
647 readFile.open(folder + MatrixName, std::ios::binary | std::ios::in);
648
649 if (!readFile.good())
650 {
651 std::cout << folder + MatrixName <<
652 " file does not exist, try to rerun the Offline Stage!" << std::endl;
653 exit(EXIT_FAILURE);
654 }
655 else if (readFile.is_open())
656 {
657 IND rows, cols, nnz, inSz, outSz;
658 readFile.read(reinterpret_cast<char*>(& rows ), sizeof(IND));
659 readFile.read(reinterpret_cast<char*>(& cols ), sizeof(IND));
660 readFile.read(reinterpret_cast<char*>(& nnz ), sizeof(IND));
661 readFile.read(reinterpret_cast<char*>(& inSz ), sizeof(IND));
662 readFile.read(reinterpret_cast<char*>(& outSz), sizeof(IND));
663 m.resize(rows, cols);
664 m.makeCompressed();
665 m.resizeNonZeros(nnz);
666 readFile.read(reinterpret_cast<char*>(m.valuePtr()), sizeof(T ) * nnz );
667 readFile.read(reinterpret_cast<char*>(m.outerIndexPtr()), sizeof(IND) * outSz);
668 readFile.read(reinterpret_cast<char*>(m.innerIndexPtr()), sizeof(IND) * nnz );
669 m.finalize();
670 readFile.close();
671 }
672}
673
674template <typename MatrixType>
675void ITHACAstream::SaveDenseMatrix(MatrixType& Matrix, word folder,
676 word MatrixName)
677{
678 mkDir(folder);
679 std::ofstream out(folder + MatrixName,
680 std::ios::out | std::ios::binary | std::ios::trunc);
681 typename MatrixType::Index rows = Matrix.rows(), cols = Matrix.cols();
682 out.write(reinterpret_cast<char*> (& rows),
683 sizeof(typename MatrixType::Index));
684 out.write(reinterpret_cast<char*> (& cols),
685 sizeof(typename MatrixType::Index));
686 out.write(reinterpret_cast<char*> (Matrix.data()),
687 rows * cols * sizeof(typename MatrixType::Scalar) );
688 out.close();
689}
690
691template <typename MatrixType>
692void ITHACAstream::ReadDenseMatrix(MatrixType& Matrix, word folder,
693 word MatrixName)
694{
695 std::ifstream in;
696 in.open(folder + MatrixName, std::ios::in | std::ios::binary);
697
698 if (!in.good())
699 {
700 std::cout << folder + MatrixName <<
701 " file does not exist, try to rerun the Offline Stage!" << std::endl;
702 exit(EXIT_FAILURE);
703 }
704 else if (in.is_open())
705 {
706 typename MatrixType::Index rows = 0, cols = 0;
707 in.read(reinterpret_cast<char*> (& rows), sizeof(typename MatrixType::Index));
708 in.read(reinterpret_cast<char*> (& cols), sizeof(typename MatrixType::Index));
709 Matrix.resize(rows, cols);
710 in.read( reinterpret_cast<char*>(Matrix.data()),
711 rows * cols * sizeof(typename MatrixType::Scalar) );
712 in.close();
713 }
714}
715
716
717template <typename TensorType>
718void ITHACAstream::SaveDenseTensor(TensorType& Tensor, word folder,
719 word MatrixName)
720{
721 std::ofstream out(folder + MatrixName,
722 std::ios::out | std::ios::binary | std::ios::trunc);
723 typename TensorType::Dimensions dim = Tensor.dimensions();
724 int tot = 1;
725
726 for (int k = 0; k < dim.size(); k++)
727 {
728 tot *= dim[k];
729 }
730
731 out.write(reinterpret_cast<char*> (& dim),
732 sizeof(typename TensorType::Dimensions));
733 out.write(reinterpret_cast<char*> (Tensor.data()),
734 tot * sizeof(typename TensorType::Scalar) );
735 out.close();
736}
737
738template <typename TensorType>
739void ITHACAstream::ReadDenseTensor(TensorType& Tensor, word folder,
740 word MatrixName)
741{
742 std::ifstream in;
743 in.open(folder + MatrixName, std::ios::in | std::ios::binary);
744 typename TensorType::Dimensions dim;
745 in.read(reinterpret_cast<char*> (& dim),
746 sizeof(typename TensorType::Dimensions));
747 auto dims = Tensor.dimensions();
748 M_Assert(dims.size() == dim.size(),
749 "The rank of the tensor you want to fill does not coincide with the rank of the tensor you are reading");
750 int tot = 1;
751
752 for (int k = 0; k < dim.size(); k++)
753 {
754 tot *= dim[k];
755 }
756
757 Tensor.resize(dim);
758 in.read( reinterpret_cast<char*>(Tensor.data()),
759 tot * sizeof(typename TensorType::Scalar) );
760 in.close();
761}
762
763template <typename MatrixType>
764void ITHACAstream::SaveSparseMatrixList(List<MatrixType>& MatrixList,
765 word folder, word MatrixName)
766{
767 for (int i = 0; i < MatrixList.size(); i++)
768 {
769 SaveSparseMatrix(MatrixList[i], folder, MatrixName + name(i));
770 }
771}
772
773template <typename MatrixType>
774void ITHACAstream::SaveDenseMatrixList(List<MatrixType>& MatrixList,
775 word folder, word MatrixName)
776{
777 for (int i = 0; i < MatrixList.size(); i++)
778 {
779 SaveDenseMatrix(MatrixList[i], folder, MatrixName + name(i));
780 }
781}
782
783template <typename T, int whatever, typename IND>
785 List<Eigen::SparseMatrix<T, whatever, IND >> & m, word folder, word MatrixName)
786{
787 int number_of_files = numberOfFiles(folder, MatrixName);
788 std::cout << "Reading the Matrix " + folder + MatrixName << std::endl;
789 M_Assert(number_of_files != 0,
790 "Check if the file you are trying to read exists" );
791 Eigen::SparseMatrix<T, whatever, IND> A;
792
793 for (int i = 0; i < number_of_files; i++)
794 {
795 ReadSparseMatrix(A, folder, MatrixName + name(i));
796 m.append(A);
797 }
798}
799
800
801template <typename MatrixType>
802void ITHACAstream::ReadDenseMatrixList(List<MatrixType>& m, word folder,
803 word MatrixName)
804{
805 int number_of_files = numberOfFiles(folder, MatrixName);
806 std::cout << "Reading the Matrix " + folder + MatrixName << std::endl;
807 M_Assert(number_of_files != 0,
808 "Check if the file you are trying to read exists" );
809 MatrixType A;
810
811 for (int i = 0; i < number_of_files; i++)
812 {
813 ReadDenseMatrix(A, folder, MatrixName + name(i));
814 m.append(A);
815 }
816}
817
818
819
820
821
822// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
823
824
825
826#endif
827
828
829
830
831
832
Header file of the EigenFunctions class.
Implementation of the assert function for ITHACA-FV.
#define M_Assert(Expr, Msg)
Header file of the ITHACAutilities namespace.
volScalarField & T
Definition createT.H:46
volScalarField & A
Ostream & operator<<(Ostream &os, const Eigen::Matrix< T, -1, -1 > &mat)
Istream & operator>>(Istream &is, Eigen::Matrix< T, -1, -1 > &mat)
Namespace for input-output manipulation.
void writePoints(pointField points, fileName folder, fileName subfolder)
Write points of a mesh to a file.
void ReadDenseMatrixList(List< MatrixType > &m, word folder, word MatrixName)
Read a sparse matrix list to bynary files.
void SaveSparseMatrix(Eigen::SparseMatrix< T, Nrows, IND > &m, word folder, word MatrixName)
Export an Eigen sparse matrix into bynary format file.
GeometricField< Type, PatchField, GeoMesh > readFieldByIndex(const GeometricField< Type, PatchField, GeoMesh > &field, fileName casename, label index)
Function to read a single field by index from a folder.
void ReadDenseMatrix(MatrixType &Matrix, word folder, word MatrixName)
Read a dense matrix from a binary format file.
int numberOfFiles(word folder, word MatrixName, word ext)
Count the number of files with a certain name prefix, used by reading functions of list of matrices.
void readConvergedFields(PtrList< GeometricField< Type, PatchField, GeoMesh > > &Lfield, GeometricField< Type, PatchField, GeoMesh > &field, fileName casename)
Function to read a list of volVectorField from name of the field including only converged snapshots.
void save(const List< Eigen::SparseMatrix< T > > &MatrixList, word folder, word MatrixName)
void exportFields(PtrList< GeometricField< Type, PatchField, GeoMesh > > &field, word folder, word fieldname)
Function to export a scalar of vector field.
void load(List< Eigen::SparseMatrix< T > > &MatrixList, word folder, word MatrixName)
void exportSolution(GeometricField< Type, PatchField, GeoMesh > &s, fileName subfolder, fileName folder, word fieldName)
Export a field to file in a certain folder and subfolder.
void read_last_fields(PtrList< GeometricField< Type, PatchField, GeoMesh > > &Lfield, const GeometricField< Type, PatchField, GeoMesh > &field, const fileName casename)
Function to read a list of fields from the name of the field including only the last snapshot.
void readMiddleFields(PtrList< GeometricField< Type, PatchField, GeoMesh > > &Lfield, GeometricField< Type, PatchField, GeoMesh > &field, fileName casename)
Funtion to read a list of volVectorField from name of the field including all the intermediate snapsh...
void exportMatrix(Eigen::Matrix< T, -1, dim > &matrix, word Name, word type, word folder)
Export the reduced matrices in numpy (type=python), matlab (type=matlab) and txt (type=eigen) format ...
void exportList(T &list, word folder, word filename)
Export a list to file.
void ReadSparseMatrixList(List< Eigen::SparseMatrix< T, Nrows, IND > > &m, word folder, word MatrixName)
Read a sparse matrix list to bynary files.
void SaveDenseMatrix(MatrixType &Matrix, word folder, word MatrixName)
Save a dense matrix to a binary format file.
void ReadDenseTensor(TensorType &Tensor, word folder, word MatrixName)
Read a dense tensor from file.
void exportFvMatrix(fvMatrix< Type > &Matrix, word folder, word MatrixName)
Export an Fv Matrix to folder together with its source term.
void SaveDenseMatrixList(List< MatrixType > &MatrixList, word folder, word MatrixName)
Save a dense matrix list to bynary files.
List< Eigen::MatrixXd > readMatrix(word folder, word mat_name)
Read a three dimensional matrix from a txt file in Eigen format.
void SaveSparseMatrixList(List< MatrixType > &MatrixList, word folder, word MatrixName)
Save a sparse matrix list to bynary files.
void read_fields(PtrList< GeometricField< Type, PatchField, GeoMesh > > &Lfield, word Name, fileName casename, int first_snap, int n_snap)
Function to read a list of fields from the name of the field and casename.
void readLastFields(PtrList< GeometricField< Type, PatchField, GeoMesh > > &Lfield, const GeometricField< Type, PatchField, GeoMesh > &field, const fileName casename)
Funtion to read a list of volVectorField from name of the field including only the last snapshots.
void exportTensor(Eigen::Tensor< T, 3 > tensor, word Name, word type, word folder)
Export the reduced tensor in numpy (tipo=python), matlab (tipo=matlab) and txt (tipo=eigen) format.
void ReadSparseMatrix(Eigen::SparseMatrix< T, Nrows, IND > &m, word folder, word MatrixName)
Read an Eigen sparse matrix from a bynary format file.
void SaveDenseTensor(TensorType &Tensor, word folder, word MatrixName)
Save a dense tensor to file.
void printProgress(double percentage)
Print progress bar given the percentage.
label i
Definition pEqn.H:46