-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathPOD_example_00003.cpp
More file actions
111 lines (93 loc) · 3.18 KB
/
Copy pathPOD_example_00003.cpp
File metadata and controls
111 lines (93 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*---------------------------------------------------------------------------*\
*
* bitpit
*
* Copyright (C) 2015-2021 OPTIMAD engineering Srl
*
* -------------------------------------------------------------------------
* License
* This file is part of bitpit.
*
* bitpit is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License v3 (LGPL)
* as published by the Free Software Foundation.
*
* bitpit is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with bitpit. If not, see <http://www.gnu.org/licenses/>.
*
\*---------------------------------------------------------------------------*/
/**
* \example POD_example_00003.cpp
*
* \brief POD leave-1-out error map computation using voloctree.
* This example uses the leave-1-out cross-validation method to compute the reconstruction
* error map starting from a database of simulations defined on the same mesh.
* It evaluates also the bounding box containing all those cells whose error is equal or greater
* than an assigned threshold.
* <b>To run</b>: ./POD_example_00003 \n
*/
#include <array>
#if BITPIT_ENABLE_MPI
#include <mpi.h>
#endif
#include "pod.hpp"
using namespace bitpit;
/**
* Run the example.
*/
void run()
{
/**<Create POD object.*/
POD pod;
/**<Add snapshots to database.*/
for (int i=0; i<10; i++)
pod.addSnapshot("./data", "test."+std::to_string(i));
/**<Set POD.*/
pod.setMeshType(POD::MeshType::VOLOCTREE);
pod.setStaticMesh(true);
pod.setUseMean(false);
pod.setWriteMode(POD::WriteMode::DEBUG);
pod.setMemoryMode(POD::MemoryMode::MEMORY_NORMAL);
pod.setEnergyLevel(99);
pod.setDirectory("pod");
pod.setName("pod.test.solver");
/**<Remove snapshots from the leave-1-out method.
* These snapshots are always used in the POD bases computation and
* the corresponding reconstruction error is never evaluated. */
for (int i=0; i<5; i++)
pod.removeLeave1outSnapshot("./data", "test."+std::to_string(2*i));
/**<Compute the error map through the leave-1-out method.*/
pod.leave1out();
/**<Set target error fields used in the bounding box evaluation.*/
std::vector<std::string> namesf {"rho","rho_e"};
std::vector<std::array<std::string,3>> namevf {}; //{{"u_x", "u_y","u_z"}};
pod.setTargetErrorFields(namesf,namevf);
/**<Set error threshold for the bounding box evaluation.*/
pod.setErrorThreshold(0.001);
/**<Evaluate the bounding box of the target error fields.*/
pod.evalErrorBoundingBox();
}
/**
* Main program.
*/
int main(int argc, char *argv[])
{
#if BITPIT_ENABLE_MPI
MPI_Init(&argc,&argv);
#endif
/** Run the example */
try {
run();
} catch (const std::exception &exception) {
log::cout() << exception.what();
exit(1);
}
#if BITPIT_ENABLE_MPI
MPI_Finalize();
#endif
}