mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-03 21:44:33 +00:00 
			
		
		
		
	👷 Added all pseudofermion actions to the serialiser
This commit is contained in:
		@@ -45,15 +45,20 @@ namespace QCD {
 | 
			
		||||
      WilsonImplParams() : overlapCommsCompute(false) {};
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    struct OneFlavourRationalParams { 
 | 
			
		||||
      RealD  lo;
 | 
			
		||||
      RealD  hi;
 | 
			
		||||
      int MaxIter;   // Vector?
 | 
			
		||||
      RealD tolerance; // Vector? 
 | 
			
		||||
      int    degree=10;
 | 
			
		||||
      int precision=64;
 | 
			
		||||
  struct OneFlavourRationalParams : Serializable {
 | 
			
		||||
      GRID_SERIALIZABLE_CLASS_MEMBERS(OneFlavourRationalParams,
 | 
			
		||||
				      RealD,  lo,
 | 
			
		||||
				      RealD,  hi,
 | 
			
		||||
				      int, MaxIter,   
 | 
			
		||||
				      RealD, tolerance, 
 | 
			
		||||
				      int,    degree,
 | 
			
		||||
				      int, precision);
 | 
			
		||||
 | 
			
		||||
      OneFlavourRationalParams (RealD _lo,RealD _hi,int _maxit,RealD tol=1.0e-8,int _degree = 10,int _precision=64) :
 | 
			
		||||
      // MaxIter and tolerance, vectors??
 | 
			
		||||
  public:
 | 
			
		||||
      OneFlavourRationalParams (RealD _lo   = 0.0,  RealD _hi      = 0.0 ,
 | 
			
		||||
				int _maxit  = 1000, RealD tol      = 1.0e-8,
 | 
			
		||||
				int _degree = 10,   int _precision = 64) :
 | 
			
		||||
        lo(_lo), hi(_hi), MaxIter(_maxit), tolerance(tol), degree(_degree), precision(_precision)
 | 
			
		||||
      {};
 | 
			
		||||
    };
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************
 | 
			
		||||
 | 
			
		||||
Grid physics library, www.github.com/paboyle/Grid
 | 
			
		||||
@@ -91,6 +92,17 @@ class OneFlavourEvenOddRationalPseudoFermionAction
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  virtual std::string action_name(){return "OneFlavourEvenOddRationalPseudoFermionAction";}
 | 
			
		||||
 | 
			
		||||
  virtual std::string LogParameters(){
 | 
			
		||||
    std::stringstream sstream;
 | 
			
		||||
    sstream << GridLogMessage << "["<<action_name()<<"] Low            :" << param.lo <<  std::endl;
 | 
			
		||||
    sstream << GridLogMessage << "["<<action_name()<<"] High           :" << param.hi <<  std::endl;
 | 
			
		||||
    sstream << GridLogMessage << "["<<action_name()<<"] Max iterations :" << param.MaxIter <<  std::endl;
 | 
			
		||||
    sstream << GridLogMessage << "["<<action_name()<<"] Tolerance      :" << param.tolerance <<  std::endl;
 | 
			
		||||
    sstream << GridLogMessage << "["<<action_name()<<"] Degree         :" << param.degree <<  std::endl;
 | 
			
		||||
    sstream << GridLogMessage << "["<<action_name()<<"] Precision      :" << param.precision <<  std::endl;
 | 
			
		||||
    return sstream.str();
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  virtual void refresh(const GaugeField &U, GridParallelRNG &pRNG) {
 | 
			
		||||
    // P(phi) = e^{- phi^dag (MpcdagMpc)^-1/2 phi}
 | 
			
		||||
 
 | 
			
		||||
@@ -89,6 +89,18 @@ namespace Grid{
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
      virtual std::string action_name(){return "OneFlavourEvenOddRatioRationalPseudoFermionAction";}
 | 
			
		||||
 | 
			
		||||
      virtual std::string LogParameters(){
 | 
			
		||||
	std::stringstream sstream;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] Low            :" << param.lo <<  std::endl;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] High           :" << param.hi <<  std::endl;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] Max iterations :" << param.MaxIter <<  std::endl;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] Tolerance      :" << param.tolerance <<  std::endl;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] Degree         :" << param.degree <<  std::endl;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] Precision      :" << param.precision <<  std::endl;
 | 
			
		||||
	return sstream.str();
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
      
 | 
			
		||||
      virtual void refresh(const GaugeField &U, GridParallelRNG& pRNG) {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -85,9 +85,23 @@ namespace Grid{
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
      virtual std::string action_name(){return "OneFlavourRationalPseudoFermionAction";}
 | 
			
		||||
 | 
			
		||||
      virtual std::string LogParameters(){
 | 
			
		||||
	std::stringstream sstream;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] Low            :" << param.lo <<  std::endl;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] High           :" << param.hi <<  std::endl;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] Max iterations :" << param.MaxIter <<  std::endl;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] Tolerance      :" << param.tolerance <<  std::endl;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] Degree         :" << param.degree <<  std::endl;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] Precision      :" << param.precision <<  std::endl;
 | 
			
		||||
	return sstream.str();
 | 
			
		||||
      }  
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      
 | 
			
		||||
      virtual void refresh(const GaugeField &U, GridParallelRNG& pRNG) {
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	// P(phi) = e^{- phi^dag (MdagM)^-1/2 phi}
 | 
			
		||||
	//        = e^{- phi^dag (MdagM)^-1/4 (MdagM)^-1/4 phi}
 | 
			
		||||
	// Phi = Mdag^{1/4} eta 
 | 
			
		||||
 
 | 
			
		||||
@@ -84,6 +84,18 @@ namespace Grid{
 | 
			
		||||
 | 
			
		||||
      virtual std::string action_name(){return "OneFlavourRatioRationalPseudoFermionAction";}
 | 
			
		||||
      
 | 
			
		||||
      virtual std::string LogParameters(){
 | 
			
		||||
	std::stringstream sstream;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] Low            :" << param.lo <<  std::endl;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] High           :" << param.hi <<  std::endl;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] Max iterations :" << param.MaxIter <<  std::endl;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] Tolerance      :" << param.tolerance <<  std::endl;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] Degree         :" << param.degree <<  std::endl;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] Precision      :" << param.precision <<  std::endl;
 | 
			
		||||
	return sstream.str();
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      virtual void refresh(const GaugeField &U, GridParallelRNG& pRNG) {
 | 
			
		||||
 | 
			
		||||
	// S_f = chi^dag* P(V^dag*V)/Q(V^dag*V)* N(M^dag*M)/D(M^dag*M)* P(V^dag*V)/Q(V^dag*V)* chi       
 | 
			
		||||
 
 | 
			
		||||
@@ -69,6 +69,13 @@ namespace Grid{
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
      virtual std::string action_name(){return "TwoFlavourEvenOddRatioPseudoFermionAction";}
 | 
			
		||||
 | 
			
		||||
      virtual std::string LogParameters(){
 | 
			
		||||
	std::stringstream sstream;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] has no parameters" << std::endl;
 | 
			
		||||
	return sstream.str();
 | 
			
		||||
      } 
 | 
			
		||||
 | 
			
		||||
      
 | 
			
		||||
      virtual void refresh(const GaugeField &U, GridParallelRNG& pRNG) {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -193,10 +193,10 @@ class DBW2GModule: public ActionModule<DBW2GaugeAction<Impl>, BetaGaugeActionPar
 | 
			
		||||
/////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
template <class Impl, template <typename> class FermionA >
 | 
			
		||||
class PseudoFermionModuleBase: public ActionModule<FermionA<Impl>, NoParameters> {
 | 
			
		||||
template <class Impl, template <typename> class FermionA, class Params = NoParameters >
 | 
			
		||||
class PseudoFermionModuleBase: public ActionModule<FermionA<Impl>, Params> {
 | 
			
		||||
protected:
 | 
			
		||||
  typedef ActionModule<FermionA<Impl>, NoParameters> ActionBase;
 | 
			
		||||
  typedef ActionModule<FermionA<Impl>, Params> ActionBase;
 | 
			
		||||
  using ActionBase::ActionBase; // for constructors
 | 
			
		||||
 | 
			
		||||
  typedef std::unique_ptr<FermionOperatorModuleBase<FermionOperator<Impl>> > operator_type;
 | 
			
		||||
@@ -314,6 +314,158 @@ class TwoFlavourRatioFModule: public PseudoFermionModuleBase<Impl, TwoFlavourRat
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template <class Impl >
 | 
			
		||||
class TwoFlavourRatioEOFModule: public PseudoFermionModuleBase<Impl, TwoFlavourEvenOddRatioPseudoFermionAction>{
 | 
			
		||||
  typedef PseudoFermionModuleBase<Impl, TwoFlavourEvenOddRatioPseudoFermionAction> Base;
 | 
			
		||||
  using Base::Base;
 | 
			
		||||
 | 
			
		||||
  typename Base::operator_type fop_numerator_mod;
 | 
			
		||||
  typename Base::operator_type fop_denominator_mod;
 | 
			
		||||
  typename Base::solver_type   solver_mod;
 | 
			
		||||
 | 
			
		||||
 public:
 | 
			
		||||
  virtual void acquireResource(typename Base::Resource& GridMod){
 | 
			
		||||
    fop_numerator_mod->AddGridPair(GridMod);
 | 
			
		||||
    fop_denominator_mod->AddGridPair(GridMod);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
   // constructor
 | 
			
		||||
   template <class ReaderClass>
 | 
			
		||||
   TwoFlavourRatioEOFModule(Reader<ReaderClass>& R): Base(R) {
 | 
			
		||||
    this->getSolverOperator(R, solver_mod, "Solver");
 | 
			
		||||
    this->getFermionOperator(R, fop_numerator_mod, "Numerator");
 | 
			
		||||
    this->getFermionOperator(R, fop_denominator_mod, "Denominator");
 | 
			
		||||
   } 
 | 
			
		||||
 | 
			
		||||
  // acquire resource
 | 
			
		||||
  virtual void initialize() {
 | 
			
		||||
    // here temporarily assuming that the force and action solver are the same
 | 
			
		||||
    this->ActionPtr.reset(new TwoFlavourEvenOddRatioPseudoFermionAction<Impl>(*(this->fop_numerator_mod->getPtr()), 
 | 
			
		||||
      *(this->fop_denominator_mod->getPtr()), *(this->solver_mod->getPtr()), *(this->solver_mod->getPtr())));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
template <class Impl >
 | 
			
		||||
class OneFlavourFModule: public PseudoFermionModuleBase<Impl, OneFlavourRationalPseudoFermionAction, OneFlavourRationalParams>{
 | 
			
		||||
  typedef PseudoFermionModuleBase<Impl, OneFlavourRationalPseudoFermionAction, OneFlavourRationalParams> Base;
 | 
			
		||||
  using Base::Base;
 | 
			
		||||
 | 
			
		||||
  typename Base::operator_type fop_mod;
 | 
			
		||||
 | 
			
		||||
 public:
 | 
			
		||||
  virtual void acquireResource(typename Base::Resource& GridMod){
 | 
			
		||||
    fop_mod->AddGridPair(GridMod);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
   // constructor
 | 
			
		||||
   template <class ReaderClass>
 | 
			
		||||
   OneFlavourFModule(Reader<ReaderClass>& R): Base(R) {
 | 
			
		||||
    this->getFermionOperator(R, fop_mod, "Operator");
 | 
			
		||||
   } 
 | 
			
		||||
 | 
			
		||||
  // acquire resource
 | 
			
		||||
  virtual void initialize() {
 | 
			
		||||
    this->ActionPtr.reset(new OneFlavourRationalPseudoFermionAction<Impl>(*(this->fop_mod->getPtr()), this->Par_ ));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template <class Impl >
 | 
			
		||||
class OneFlavourEOFModule: 
 | 
			
		||||
  public PseudoFermionModuleBase<Impl, OneFlavourEvenOddRationalPseudoFermionAction, OneFlavourRationalParams>
 | 
			
		||||
  {
 | 
			
		||||
  typedef PseudoFermionModuleBase<Impl, OneFlavourEvenOddRationalPseudoFermionAction, OneFlavourRationalParams> Base;
 | 
			
		||||
  using Base::Base;
 | 
			
		||||
 | 
			
		||||
  typename Base::operator_type fop_mod;
 | 
			
		||||
 | 
			
		||||
 public:
 | 
			
		||||
  virtual void acquireResource(typename Base::Resource& GridMod){
 | 
			
		||||
    fop_mod->AddGridPair(GridMod);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
   // constructor
 | 
			
		||||
   template <class ReaderClass>
 | 
			
		||||
   OneFlavourEOFModule(Reader<ReaderClass>& R): Base(R) {
 | 
			
		||||
    this->getFermionOperator(R, fop_mod, "Operator");
 | 
			
		||||
   } 
 | 
			
		||||
 | 
			
		||||
  // acquire resource
 | 
			
		||||
  virtual void initialize() {
 | 
			
		||||
    this->ActionPtr.reset(new OneFlavourEvenOddRationalPseudoFermionAction<Impl>(*(this->fop_mod->getPtr()), this->Par_ ));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
template <class Impl >
 | 
			
		||||
class OneFlavourRatioFModule: 
 | 
			
		||||
  public PseudoFermionModuleBase<Impl, OneFlavourRatioRationalPseudoFermionAction, OneFlavourRationalParams>
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
  typedef PseudoFermionModuleBase<Impl, OneFlavourRatioRationalPseudoFermionAction, OneFlavourRationalParams> Base;
 | 
			
		||||
  using Base::Base;
 | 
			
		||||
 | 
			
		||||
  typename Base::operator_type fop_numerator_mod;
 | 
			
		||||
  typename Base::operator_type fop_denominator_mod;
 | 
			
		||||
 | 
			
		||||
 public:
 | 
			
		||||
  virtual void acquireResource(typename Base::Resource& GridMod){
 | 
			
		||||
    fop_numerator_mod->AddGridPair(GridMod);
 | 
			
		||||
    fop_denominator_mod->AddGridPair(GridMod);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
   // constructor
 | 
			
		||||
   template <class ReaderClass>
 | 
			
		||||
   OneFlavourRatioFModule(Reader<ReaderClass>& R): Base(R) {
 | 
			
		||||
    this->getFermionOperator(R, fop_numerator_mod, "Numerator");
 | 
			
		||||
    this->getFermionOperator(R, fop_denominator_mod, "Denominator");
 | 
			
		||||
   } 
 | 
			
		||||
 | 
			
		||||
  // acquire resource
 | 
			
		||||
  virtual void initialize() {
 | 
			
		||||
    this->ActionPtr.reset(new OneFlavourRatioRationalPseudoFermionAction<Impl>( *(this->fop_numerator_mod->getPtr()), 
 | 
			
		||||
                                                                                *(this->fop_denominator_mod->getPtr()), 
 | 
			
		||||
                                                                                this->Par_ ));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
template <class Impl >
 | 
			
		||||
class OneFlavourRatioEOFModule: 
 | 
			
		||||
  public PseudoFermionModuleBase<Impl, OneFlavourEvenOddRatioRationalPseudoFermionAction, OneFlavourRationalParams>
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
  typedef PseudoFermionModuleBase<Impl, OneFlavourEvenOddRatioRationalPseudoFermionAction, OneFlavourRationalParams> Base;
 | 
			
		||||
  using Base::Base;
 | 
			
		||||
 | 
			
		||||
  typename Base::operator_type fop_numerator_mod;
 | 
			
		||||
  typename Base::operator_type fop_denominator_mod;
 | 
			
		||||
 | 
			
		||||
 public:
 | 
			
		||||
  virtual void acquireResource(typename Base::Resource& GridMod){
 | 
			
		||||
    fop_numerator_mod->AddGridPair(GridMod);
 | 
			
		||||
    fop_denominator_mod->AddGridPair(GridMod);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
   // constructor
 | 
			
		||||
   template <class ReaderClass>
 | 
			
		||||
   OneFlavourRatioEOFModule(Reader<ReaderClass>& R): Base(R) {
 | 
			
		||||
    this->getFermionOperator(R, fop_numerator_mod, "Numerator");
 | 
			
		||||
    this->getFermionOperator(R, fop_denominator_mod, "Denominator");
 | 
			
		||||
   } 
 | 
			
		||||
 | 
			
		||||
  // acquire resource
 | 
			
		||||
  virtual void initialize() {
 | 
			
		||||
    this->ActionPtr.reset(new OneFlavourEvenOddRatioRationalPseudoFermionAction<Impl>(*(this->fop_numerator_mod->getPtr()), 
 | 
			
		||||
                                                                                      *(this->fop_denominator_mod->getPtr()), 
 | 
			
		||||
                                                                                      this->Par_ ));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -379,6 +531,12 @@ static Registrar<QCD::PlaqPlusRectangleGMod, HMC_LGTActionModuleFactory<gauge_st
 | 
			
		||||
static Registrar<QCD::TwoFlavourFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __TwoFlavourFmodXMLInit("TwoFlavours"); 
 | 
			
		||||
static Registrar<QCD::TwoFlavourRatioFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __TwoFlavourRatioFmodXMLInit("TwoFlavoursRatio"); 
 | 
			
		||||
static Registrar<QCD::TwoFlavourEOFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __TwoFlavourEOFmodXMLInit("TwoFlavoursEvenOdd"); 
 | 
			
		||||
static Registrar<QCD::TwoFlavourRatioEOFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __TwoFlavourRatioEOFmodXMLInit("TwoFlavoursEvenOddRatio"); 
 | 
			
		||||
static Registrar<QCD::OneFlavourFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __OneFlavourFmodXMLInit("OneFlavour"); 
 | 
			
		||||
static Registrar<QCD::OneFlavourEOFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __OneFlavourEOFmodXMLInit("OneFlavourEvenOdd"); 
 | 
			
		||||
static Registrar<QCD::OneFlavourRatioFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __OneFlavourRatioFmodXMLInit("OneFlavourRatio"); 
 | 
			
		||||
static Registrar<QCD::OneFlavourRatioEOFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __OneFlavourRatioEOFmodXMLInit("OneFlavourEvenOddRatio"); 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -106,15 +106,15 @@ bool JSONReader::push(const string &s)
 | 
			
		||||
      std::cout << "out of range: " << e.what() << '\n';
 | 
			
		||||
      return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    cout << "JSONReader::push : " << s << " : "<< jcur_ << endl;
 | 
			
		||||
    return true;
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    do_pop.push_back(false);
 | 
			
		||||
    return true;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void JSONReader::pop(void)
 | 
			
		||||
@@ -134,19 +134,17 @@ bool JSONReader::nextElement(const std::string &s)
 | 
			
		||||
{
 | 
			
		||||
  // JSON dictionaries do not support multiple names 
 | 
			
		||||
  // Same name objects must be packed in vectors
 | 
			
		||||
  cout << "JSONReader::nextElement(string) : " << s << " : "<< jcur_ << endl;
 | 
			
		||||
  /*
 | 
			
		||||
  if (node_.next_sibling(s.c_str()))
 | 
			
		||||
    {
 | 
			
		||||
      node_ = node_.next_sibling(s.c_str());
 | 
			
		||||
      
 | 
			
		||||
      return true;
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    {
 | 
			
		||||
      return false;
 | 
			
		||||
    }
 | 
			
		||||
*/
 | 
			
		||||
  ++it_;
 | 
			
		||||
  
 | 
			
		||||
  //if (it_ == it_end_){
 | 
			
		||||
  //  return false;
 | 
			
		||||
  //}
 | 
			
		||||
 | 
			
		||||
  jcur_ = *it_; 
 | 
			
		||||
  //cout << "JSONReader::nextElement(string) : " << s << " : "<< jcur_ << endl;
 | 
			
		||||
  //return true;
 | 
			
		||||
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <>
 | 
			
		||||
 
 | 
			
		||||
@@ -84,6 +84,8 @@ namespace Grid
 | 
			
		||||
    std::vector<json>   jold_;  // previous json object
 | 
			
		||||
    std::string         fileName_;
 | 
			
		||||
    std::vector<bool>   do_pop;
 | 
			
		||||
    json::iterator      it_;
 | 
			
		||||
    json::iterator      it_end_;
 | 
			
		||||
  };
 | 
			
		||||
  
 | 
			
		||||
  // Writer template implementation ////////////////////////////////////////////
 | 
			
		||||
@@ -125,12 +127,7 @@ namespace Grid
 | 
			
		||||
  template <typename U>
 | 
			
		||||
  void JSONReader::readDefault(const std::string &s, U &output)
 | 
			
		||||
  {
 | 
			
		||||
    //std::string buf;
 | 
			
		||||
    std::cout << "JSONReader::readDefault(U) : " << s << "  :  "<< jcur_ << std::endl;
 | 
			
		||||
    //readDefault(s, output);
 | 
			
		||||
 | 
			
		||||
    //std::cout << s << "   " << buf << std::endl;
 | 
			
		||||
    //fromString(output, buf);
 | 
			
		||||
  
 | 
			
		||||
    if (s.size()){
 | 
			
		||||
      std::cout << "String: "<< jcur_[s] << std::endl;
 | 
			
		||||
@@ -164,6 +161,7 @@ namespace Grid
 | 
			
		||||
      output.resize(i + 1);
 | 
			
		||||
      read("", output[i++]);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    jcur_ = j;
 | 
			
		||||
    if (s.size())
 | 
			
		||||
 
 | 
			
		||||
@@ -49,7 +49,7 @@ namespace Grid {
 | 
			
		||||
    
 | 
			
		||||
    myclass() {}
 | 
			
		||||
    myclass(int i)
 | 
			
		||||
    : array(4,5.1), twodimarray(3,std::vector<double>(2,1.23456)), ve(2, myenum::blue)
 | 
			
		||||
      : array(4,5.1), twodimarray(3,std::vector<double>(2,1.23456)), ve({myenum::blue, myenum::red})
 | 
			
		||||
    {
 | 
			
		||||
      e=myenum::red;
 | 
			
		||||
      x=i;
 | 
			
		||||
@@ -202,5 +202,13 @@ int main(int argc,char **argv)
 | 
			
		||||
    std::cout << jcopy1 << std::endl << jveccopy1 << std::endl;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  {
 | 
			
		||||
    // Testing the next element function
 | 
			
		||||
    JSONReader RD("test.json");
 | 
			
		||||
    RD.push("grid");
 | 
			
		||||
    RD.push("Observable");
 | 
			
		||||
    std::string name;
 | 
			
		||||
    read(RD,"name", name);
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user