Loading...
Searching...
No Matches
POD_example_00003.cpp
1/*---------------------------------------------------------------------------*\
2 *
3 * bitpit
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of bitpit.
10 *
11 * bitpit is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * bitpit is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with bitpit. If not, see <http://www.gnu.org/licenses/>.
22 *
23\*---------------------------------------------------------------------------*/
24
36#include <array>
37#if BITPIT_ENABLE_MPI
38#include <mpi.h>
39#endif
40
41#include "pod.hpp"
42
43using namespace bitpit;
44
48void run()
49{
51 POD pod;
52
54 for (int i=0; i<10; i++)
55 pod.addSnapshot("./data", "test."+std::to_string(i));
56
58 pod.setMeshType(POD::MeshType::VOLOCTREE);
59 pod.setStaticMesh(true);
60 pod.setUseMean(false);
61 pod.setWriteMode(POD::WriteMode::DEBUG);
62 pod.setMemoryMode(POD::MemoryMode::MEMORY_NORMAL);
63 pod.setEnergyLevel(99);
64
65 pod.setDirectory("pod");
66 pod.setName("pod.test.solver");
67
71 for (int i=0; i<5; i++)
72 pod.removeLeave1outSnapshot("./data", "test."+std::to_string(2*i));
73
75 pod.leave1out();
76
78 std::vector<std::string> namesf {"rho","rho_e"};
79 std::vector<std::array<std::string,3>> namevf {}; //{{"u_x", "u_y","u_z"}};
80 pod.setTargetErrorFields(namesf,namevf);
81
83 pod.setErrorThreshold(0.001);
84
87}
88
93int main(int argc, char *argv[])
94{
95#if BITPIT_ENABLE_MPI
96 MPI_Init(&argc,&argv);
97#endif
98
100 try {
101 run();
102 } catch (const std::exception &exception) {
103 log::cout() << exception.what();
104 exit(1);
105 }
106
107#if BITPIT_ENABLE_MPI
108 MPI_Finalize();
109#endif
110
111}
The POD (Proper Orthogonal Decomposition) class provides an interface for defining POD object.
Definition pod.hpp:41
void setErrorThreshold(double threshold)
Definition pod.cpp:346
void setTargetErrorFields(std::vector< std::string > &namesf, std::vector< std::array< std::string, 3 > > &namevf)
Definition pod.cpp:367
void setMeshType(MeshType type)
Definition pod.cpp:390
void setStaticMesh(bool flag)
Definition pod.cpp:483
void setMemoryMode(MemoryMode mode)
Definition pod.cpp:505
void setDirectory(const std::string &directory)
Definition pod.cpp:180
void leave1out()
Definition pod.cpp:1121
void evalErrorBoundingBox()
Definition pod.cpp:1503
void setUseMean(bool flag)
Definition pod.cpp:493
void removeLeave1outSnapshot(const std::string &directory, const std::string &name)
Definition pod.cpp:243
void setWriteMode(WriteMode mode)
Definition pod.cpp:576
void setEnergyLevel(double energy)
Definition pod.cpp:326
void setName(const std::string &name)
Definition pod.cpp:160
void addSnapshot(const std::string &directory, const std::string &name)
Definition pod.cpp:208
Logger & cout(log::Level defaultSeverity, log::Visibility defaultVisibility)
Definition logger.cpp:1705
--- layout: doxygen_footer ---