46using namespace bitpit;
59 std::vector<std::array<std::string,3>> vectorNames= pod.
getVectorNames();
60 int N = scalarNames.size();
61 for (
int i=0; i<N; i++) {
62 std::cout <<
"L2 norm of " << field_name <<
" " << scalarNames[i] <<
" is "<< vecL2[i] << std::endl;
64 int M = vectorNames.size();
65 for (
int i=N; i<N+M; i++) {
66 std::cout <<
"L2 norm of " << field_name <<
" " << vectorNames[i-N][0].substr(0,vectorNames[i-N][0].size()-2) <<
" is "<< vecL2[i] << std::endl;
75void printMat (std::vector < std::vector<double>> mat)
77 std::cout <<
"mat = " << std::endl;
78 size_t M = mat.size();
79 size_t N = mat[0].size();
80 for (
size_t i=0; i<M; i++) {
81 for (
size_t j=0; j<N; j++) {
83 std::cout <<
"[ "<< mat[i][j] ;
86 std::cout <<
" , " << mat[i][j] <<
" ]" << std::endl;
89 std::cout <<
" , " << mat[i][j] ;
92 std::cout <<
" ]" << std::endl;
107 for (
int i=0; i<6; i++) {
108 pod.
addSnapshot(
"./data",
"test_set2."+std::to_string(i));
120 pod.
setName(
"pod.test.solver");
131 std::cout <<
"the number of modes is = " << pod.
getModeCount() << std::endl;
134 std::vector<std::array<std::string,3>> namev = pod.
getVectorNames();
135 std::size_t N_sfields = names.size();
136 std::size_t N_vfiedls = namev.size();
137 std::size_t N_fields = N_sfields+N_vfiedls;
141 std::vector < std::vector<double>> recostructionCoeffs;
142 recostructionCoeffs.clear();
143 recostructionCoeffs.resize(N_fields, std::vector<double>(N_modes, 0.0));
144 for (std::size_t i = 0; i < N_fields; i++) {
145 recostructionCoeffs[i][0] = 1;
149 printL2norm(mode1_recon, pod,
"mode 1");
150 std::vector < std::vector<double>> test_mat = pod.
projectField(mode1_recon);
151 std::cout <<
"the coefficient matrix of the projection on the first mode is " << std::endl;
155 pod.
write(mode1_recon,
"mode1_recon");
156 pod.
write(0,
"mode1");
163int main(
int argc,
char *argv[])
166 MPI_Init(&argc,&argv);
172 }
catch (
const std::exception &exception) {
The POD (Proper Orthogonal Decomposition) class provides an interface for defining POD object.
std::size_t getModeCount()
std::vector< std::array< std::string, 3 > > getVectorNames()
std::vector< std::string > getScalarNames()
void setMeshType(MeshType type)
void setStaticMesh(bool flag)
std::vector< double > fieldsl2norm(pod::PODField &snap)
void setMemoryMode(MemoryMode mode)
void write(const pod::PODField &snap, std::string file_name) const
void setDirectory(const std::string &directory)
void reconstructFields(pod::PODField &field, pod::PODField &recon)
void setUseMean(bool flag)
std::vector< std::vector< double > > projectField(pod::PODField &field)
void setWriteMode(WriteMode mode)
void setEnergyLevel(double energy)
void setName(const std::string &name)
void setErrorMode(ErrorMode mode)
void addSnapshot(const std::string &directory, const std::string &name)
Logger & cout(log::Level defaultSeverity, log::Visibility defaultVisibility)
The PODfield structure is used to store the fields inside POD classes.