46using namespace bitpit;
57 std::vector<double> vecL2 =
pod.fieldsl2norm(field);
58 std::vector<std::string> scalarNames =
pod.getScalarNames();
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));
113 pod.setStaticMesh(
true);
117 pod.setEnergyLevel(99.00);
118 pod.setUseMean(
false);
119 pod.setDirectory(
"pod");
120 pod.setName(
"pod.test.solver");
123 pod.evalDecomposition();
131 std::cout <<
"the number of modes is = " <<
pod.getModeCount() << std::endl;
132 std::size_t N_modes =
pod.getModeCount();
133 std::vector<std::string> names =
pod.getScalarNames();
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;
148 pod.reconstructFields(recostructionCoeffs, mode1_recon);
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.
Logger & cout(log::Level defaultSeverity, log::Visibility defaultVisibility)
The namespace 'pod' contains structures for working with the POD class.
The PODfield structure is used to store the fields inside POD classes.