Loading...
Searching...
No Matches
POD_example_00003.cpp

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. To run: ./POD_example_00003
.

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. To run: ./POD_example_00003

/*---------------------------------------------------------------------------*\
*
* 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/>.
*
\*---------------------------------------------------------------------------*/
#include <array>
#if BITPIT_ENABLE_MPI
#include <mpi.h>
#endif
#include "pod.hpp"
using namespace bitpit;
void run()
{
POD pod;
for (int i=0; i<10; i++)
pod.addSnapshot("./data", "test."+std::to_string(i));
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");
for (int i=0; i<5; i++)
pod.removeLeave1outSnapshot("./data", "test."+std::to_string(2*i));
pod.leave1out();
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);
pod.setErrorThreshold(0.001);
}
int main(int argc, char *argv[])
{
#if BITPIT_ENABLE_MPI
MPI_Init(&argc,&argv);
#endif
try {
run();
} catch (const std::exception &exception) {
log::cout() << exception.what();
exit(1);
}
#if BITPIT_ENABLE_MPI
MPI_Finalize();
#endif
}
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
--- layout: doxygen_footer ---