LatticeYangMills
jsonobservable.cpp
1 #include "InputOutput/JsonInput/json.hpp"
2 #include "InputOutput/JsonInput/jsoninput.h"
3 #include "InputOutput/JsonInput/JsonObservable/jsonobservable.h"
4 //#include "Observables/JsonInput/jsonuserobservables.h"
5 #include "Apps/app.h"
7 #include <iostream>
8 
9 namespace LatticeIO {
10  namespace JsonInput {
11  void validateObservables(){
12  // check observables
13  if(jsonFile["App"]["type"] == "GFR" || jsonFile["App"]["type"] == "FLOW"){
14  if(jsonFile.count("Observables") == 0){
15  std::cerr << "LatticeQCD Error: no Observables specified\n";
16  exit(1);
17  }
18  if(jsonFile.count("Observables") != 1){
19  std::cerr << "LatticeQCD Error: too many Observables tag specified\n";
20  exit(1);
21  }
22  }
23  if(jsonFile["Observables"].size() == 0){
24  std::cerr << "LatticeQCD Error: no Observables specified\n";
25  exit(1);
26  }
27 
28  // check observables
29  for(auto& obs : jsonFile["Observables"]){
30  if( !validateCoreObservables(obs)
31  //&& !validateUserObservables(obs)
32  ) {
33  std::cerr << "LatticeQCD Error: unknown Observable "
34  << obs << "\n";
35  exit(1);
36  }
37 
38  }
39  }
40 
41  bool validateCoreObservables(std::string obs){
42  if(obs == "plaquette"){
43  return true;
44  }
45  else if(obs == "energydensity"){
46  return true;
47  }
48  else if(obs == "topologicalcharge"){
49  return true;
50  }
51  else if(obs == "superobs"){
52  return true;
53  }
54  return false;
55  }
56 
57  void registerObservables(App*& app){
58  for(auto& obs : jsonFile["Observables"]){
59  registerCoreObservables(app, obs);
60  //registerUserObservables(app, obs);
61  }
62  }
63 
64  void registerCoreObservables(App*& app, std::string obs){
65  /*if(obs == "plaquette"){
66  app->addObservable(new Plaquette());
67  }
68  else if(obs == "energydensity"){
69  app->addObservable(new EnergyDensity());
70  }
71  else if(obs == "topologicalcharge"){
72  app->addObservable(new TopologicalCharge());
73  }
74  else
75  */if(obs == "superobs"){
76  app->addObservable(new SuperObs());
77  }
78  }
79 
80  } // end JsonInput
81 } // end LatticeIO
Main include file for Observable derived classes.
Class to compute the plaquette, the energy density and the topological charge.
Definition: superobs.h:52
Contains the definition of the App prototype.
void addObservable(Observable *observable)
Adds a Observable class pointer to the vector of observables of the App.
Definition: app.cpp:58
Prototype for the App class group.
Definition: app.h:59