40using namespace bitpit;
102 std::cout<<
"Error. Not enough arguments found launching the application"<<std::endl;
103 std::cout<<
"Please run application_example_00001 --help for a brief guide on how to use it"<<std::endl;
107 std::unordered_set<std::string> input;
108 for(
int i=1; i<argc; ++i){
109 std::string temp = argv[i];
113 if(input.count(
"--help")>0){
114 std::cout<<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<std::endl;
115 std::cout<<
""<<std::endl;
116 std::cout<<
" Brief application_example_00001 helper, version 1.0"<<std::endl;
117 std::cout<<
""<<std::endl;
118 std::cout<<
""<<std::endl;
119 std::cout<<
" This is the executable command for running POD instructions from XML Control Dictionaries"<<std::endl;
120 std::cout<<
" The command needs mandatorily a XML dictionary to run. It can return execution info on "<<std::endl;
121 std::cout<<
" both console(screen) and external log file. As further debug info, it can plot optional "<<std::endl;
122 std::cout<<
" results of its execution. "<<std::endl;
123 std::cout<<
" "<<std::endl;
124 std::cout<<
" The full list of options for running the application are: "<<std::endl;
125 std::cout<<
" "<<std::endl;
126 std::cout<<
" "<<std::endl;
127 std::cout<<
" "<<std::endl;
128 std::cout<<
" --help : print this helper "<<std::endl;
129 std::cout<<
" "<<std::endl;
130 std::cout<<
" --dict=<dictionary name> : full path to the target xml dictionary. Mandatory. "<<std::endl;
131 std::cout<<
" "<<std::endl;
132 std::cout<<
" --vconsole=<quiet/normal/full> : print info on the execution on console(screen). "<<std::endl;
133 std::cout<<
" full is meant for full debug message verbosity, normal for "<<std::endl;
134 std::cout<<
" a medium verbosity, quiet shut off messaging on console. "<<std::endl;
135 std::cout<<
" Default verbosity is medium. "<<std::endl;
136 std::cout<<
" "<<std::endl;
137 std::cout<<
" --vlog=<quiet/normal/full> : print info on the execution external file bitpit.log. "<<std::endl;
138 std::cout<<
" full is meant for full debug message verbosity, normal for "<<std::endl;
139 std::cout<<
" a medium verbosity, quiet shut off messaging on file. "<<std::endl;
140 std::cout<<
" Default verbosity is full. "<<std::endl;
141 std::cout<<
" "<<std::endl;
142 std::cout<<
" "<<std::endl;
143 std::cout<<
" "<<std::endl;
144 std::cout<<
" For any problem, bug and malfunction please contact bitpit developers. "<<std::endl;
145 std::cout<<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<std::endl;
149 std::unordered_map<int, std::string> keymap;
152 keymap[2] =
"vconsole=";
154 std::map<int, std::string> final_map;
159 for(
const auto &val: input){
160 std::size_t pos = std::string::npos;
162 while (pos == std::string::npos && counter <3){
163 pos = val.find(keymap[counter]);
167 if(pos != std::string::npos) final_map[counter-1] =val.substr(pos+keymap[counter-1].size());
170 if(final_map.count(0) < 1) {
171 std::cout<<
"Error. Not valid xml dictionary found launching the application"<<std::endl;
172 std::cout<<
"Please run application_example_00001 --help for a brief guide on how to use it"<<std::endl;
181 if(final_map.count(1)){
182 int check = -1 + int(final_map[1]==
"quiet") + 2*int(final_map[1]==
"normal") + 3*int(final_map[1]==
"full");
183 if(check == -1)
check = 2;
184 result.
vlog =
static_cast<Verbose
>(
check);
187 if(final_map.count(2)){
188 int check = -1 + int(final_map[2]==
"quiet") + 2*int(final_map[2]==
"normal") + 3*int(final_map[2]==
"full");
189 if(check == -1)
check = 1;
227 std::string input = slotXML.
get(
"Directory");
229 std::string temp =
".";
237 std::string input = slotXML.
get(
"Name");
239 std::string temp =
"pod";
247 std::string input = slotXML.
get(
"MemoryMode");
249 if(input ==
"MEMORY_LIGHT")
256 std::string input = slotXML.
get(
"RunMode");
258 if(input ==
"RESTORE")
265 std::string input = slotXML.
get(
"WriteMode");
269 else if(input ==
"DEBUG")
275 if(slotXML.
hasOption(
"ReconstructionMode")){
276 std::string input = slotXML.
get(
"ReconstructionMode");
278 if(input ==
"MINIMIZATION")
285 std::string input = slotXML.
get(
"ErrorMode");
289 else if(input ==
"COMBINED")
296 std::string input = slotXML.
get(
"StaticMesh");
300 std::stringstream ss(input);
307 std::string input = slotXML.
get(
"MeshType");
309 if(input ==
"VOLOCTREE")
320 std::string meshDir = slotXML.
get(
"MeshDirectory");
322 if(!meshDir.empty()){
324 std::string meshName = slotXML.
get(
"MeshName");
326 if(!meshName.empty()){
327 podInst.
setMesh(meshDir, meshName);
334 std::string input = slotXML.
get(
"Mean");
338 std::stringstream ss(input);
345 std::string input = slotXML.
get(
"Modes");
347 std::size_t temp = std::numeric_limits<std::size_t>::max();
349 std::stringstream ss(input);
356 std::string input = slotXML.
get(
"Energy");
360 std::stringstream ss(input);
368 std::string input = slotXML.
get(
"ErrorThreshold");
372 std::stringstream ss(input);
378 std::vector<std::string> tempsf;
379 std::vector<std::array<std::string,3>> tempvf;
381 if(slotXML.
hasOption(
"targetErrorScalarFields")){
382 std::string input = slotXML.
get(
"targetErrorScalarFields");
386 std::stringstream ss(input);
391 if(slotXML.
hasOption(
"targetErrorVectorFields")){
392 std::string input = slotXML.
get(
"targetErrorVectorFields");
396 std::stringstream ss(input);
404 log::cout()<<
"Finished reading XML dictionary"<<std::endl;
409 std::vector<std::string> emode(2,
"restore");
410 emode[1] =
"compute";
412 std::vector<std::string> mmode(2,
"normal");
415 std::vector<std::string> wmode(3,
"dump");
419 std::vector<std::string> rmode(2,
"projection");
420 wmode[1] =
"minimization";
422 std::vector<std::string> errmode(3,
"combined");
426 log::cout()<<
"Resume of arguments in "<< podInst.
getName() <<
" : " << std::endl;
427 log::cout()<<
"execution mode: "<<emode[
static_cast<int>(podInst.
getRunMode())]<<std::endl;
458 std::vector<bool> controls;
459 controls.resize(3,
false);
462 std::string input = slotXML.
get(
"doPODbasis");
466 std::stringstream ss(input);
475 std::string input = slotXML.
get(
"doLeave1out");
479 std::stringstream ss(input);
486 std::string input = slotXML.
get(
"doBoundingBox");
490 std::stringstream ss(input);
562std::vector<bool> read_Dictionary(
POD & podInst) {
564 std::vector<bool> exeFlags;
565 exeFlags.resize(3,
false);
568 log::cout()<<
"Currently reading XML dictionary"<<std::endl;
575 read_podXML(podXML, podInst);
581 log::cout()<<
"No POD section available in the XML dictionary"<<std::endl;
590 for(
auto & sect : blockXML.getSections()){
592 std::string name =
".";
593 std::string path =
".";
594 std::size_t ns, first = 0;
595 std::size_t stride = 1;
597 name = sect.second->
get(
"Case");
598 path = sect.second->get(
"Directory");
599 std::string nss = sect.second->get(
"NSnapshots");
600 std::stringstream ss(nss);
602 if(sect.second->hasOption(
"Stride")){
603 std::string sstride = sect.second->get(
"Stride");
604 std::stringstream ssstride(sstride);
607 if(sect.second->hasOption(
"FirstSnapshot")){
608 std::string sfirst = sect.second->get(
"FirstSnapshot");
609 std::stringstream ssfirst(sfirst);
612 for (std::size_t i = first; i < ns; i+=stride){
615 snap.
name = name +
"." + std::to_string(i);
623 log::cout()<<
"No Database section available in the XML dictionary"<<std::endl;
632 for(
auto & sect : blockXML.getSections()){
634 std::string name =
".";
635 std::string path =
".";
636 std::size_t ns, first = 0;
637 std::size_t stride = 1;
639 name = sect.second->
get(
"Case");
640 path = sect.second->get(
"Directory");
641 std::string nss = sect.second->get(
"NSnapshots");
642 std::stringstream ss(nss);
644 if(sect.second->hasOption(
"Stride")){
645 std::string sstride = sect.second->get(
"Stride");
646 std::stringstream ssstride(sstride);
649 if(sect.second->hasOption(
"FirstSnapshot")){
650 std::string sfirst = sect.second->get(
"FirstSnapshot");
651 std::stringstream ssfirst(sfirst);
655 for (std::size_t i = first; i < ns; i+=stride){
658 snap.
name = name +
"." + std::to_string(i);
667 for(
auto & sect : blockXML.getSections()){
669 std::string name =
".";
670 std::string path =
".";
671 std::size_t ns, first = 0;
672 std::size_t stride = 1;
674 name = sect.second->
get(
"Case");
675 path = sect.second->get(
"Directory");
676 std::string nss = sect.second->get(
"NSnapshots");
677 std::stringstream ss(nss);
680 if(sect.second->hasOption(
"Stride")){
681 std::string sstride = sect.second->get(
"Stride");
682 std::stringstream ssstride(sstride);
685 if(sect.second->hasOption(
"FirstSnapshot")){
686 std::string sfirst = sect.second->get(
"FirstSnapshot");
687 std::stringstream ssfirst(sfirst);
691 for (std::size_t i = first; i < ns; i+=stride){
694 snap.
name = name +
"." + std::to_string(i);
702 exeFlags=read_jobControlsXML(jobXML, podInst);
707 log::cout()<<
"Finished reading XML dictionary"<<std::endl;
720 std::string log =
"bitpit";
722 switch(
int(
info.vconsole)){
736 switch(
int(
info.vlog)){
754 std::vector<std::string> verb(3,
"quiet");
758 log::cout()<<
"Resume of arguments:"<<std::endl;
760 log::cout()<<
"console verbosity: "<<verb[
static_cast<int>(
info.vconsole)]<<std::endl;
761 log::cout()<<
"log file verbosity: "<<verb[
static_cast<int>(
info.vlog)]<<std::endl;
773 std::vector<bool> exes;
774 exes=read_Dictionary(podInst);
792 log::cout()<<
"...execution of pod done"<<std::endl;
799int main(
int argc,
char *argv[] ) {
802 MPI_Init(&argc, &argv);
811 catch(std::exception & e){
812 std::cout<<
"application_example_00001 exited with an error of type : "<<e.what()<<std::endl;
const std::string & get(const std::string &key) const
Section & getSection(const std::string &key)
bool hasOption(const std::string &key) const
void setDefaultSeverity(log::Level severity)
The POD (Proper Orthogonal Decomposition) class provides an interface for defining POD object.
void setErrorThreshold(double threshold)
std::size_t getModeCount()
void setRunMode(RunMode mode)
void setTargetErrorFields(std::vector< std::string > &namesf, std::vector< std::array< std::string, 3 > > &namevf)
void setMeshType(MeshType type)
void setStaticMesh(bool flag)
void setMemoryMode(MemoryMode mode)
double getErrorThreshold()
void setDirectory(const std::string &directory)
const std::string & getName()
ReconstructionMode getReconstructionMode()
void evalErrorBoundingBox()
MemoryMode getMemoryMode()
void setUseMean(bool flag)
void addReconstructionSnapshot(const std::string &directory, const std::string &name)
void removeLeave1outSnapshot(const std::string &directory, const std::string &name)
void setWriteMode(WriteMode mode)
void setReconstructionMode(ReconstructionMode mode)
void setEnergyLevel(double energy)
void setModeCount(std::size_t nmodes)
void setName(const std::string &name)
void setErrorMode(ErrorMode mode)
void setMesh(const std::string &directory, const std::string &name)
void addSnapshot(const std::string &directory, const std::string &name)
#define BITPIT_UNUSED(variable)
std::string & trim(std::string &s)
GlobalConfigParser & root
void reset(const std::string &rootName)
void read(const std::string &filename, bool append)
unsigned int check(std::ifstream &, std::vector< std::vector< int > > &)
Logger & cout(log::Level defaultSeverity, log::Visibility defaultVisibility)
Logger & setFileVerbosity(Logger &logger, const log::Level &threshold)
Logger & info(log::Visibility defaultVisibility)
Logger & setConsoleVerbosity(Logger &logger, const log::Level &threshold)
database of essential information absorbed from the custom arguments
InfoBitpodPP(const InfoBitpodPP &other)
InfoBitpodPP & operator=(const InfoBitpodPP &other)
The SnapFile structure is used to store the file names inside POD classes.