From 81bb361299b08bc21f6920ac42a853276c2ab5fe Mon Sep 17 00:00:00 2001 From: Michael Marshall Date: Tue, 22 Jan 2019 13:19:39 +0000 Subject: [PATCH] Test program ready --- Hadrons/Modules/MDistil/LapEvec.hpp | 23 ++++- tests/hadrons/Test_hadrons_distil.cc | 123 ++++++++++++++++++++++++--- 2 files changed, 133 insertions(+), 13 deletions(-) diff --git a/Hadrons/Modules/MDistil/LapEvec.hpp b/Hadrons/Modules/MDistil/LapEvec.hpp index f52f76f9..fc1fae61 100644 --- a/Hadrons/Modules/MDistil/LapEvec.hpp +++ b/Hadrons/Modules/MDistil/LapEvec.hpp @@ -36,17 +36,34 @@ BEGIN_HADRONS_NAMESPACE +BEGIN_MODULE_NAMESPACE(MDistil) + /****************************************************************************** * LapEvec * ***** TEST ***** ******************************************************************************/ -BEGIN_MODULE_NAMESPACE(MDistil) + class LapEvecPar: Serializable { public: - GRID_SERIALIZABLE_CLASS_MEMBERS(LapEvecPar, - unsigned int, i); + GRID_SERIALIZABLE_CLASS_MEMBERS(LapEvecPar, + // StoutParameters, + int, steps, + double, parm, + // ChebyshevParameters, + int, PolyOrder, + double, alpha, + double, beta, + // LanczosParameters, + int, Nstart, + int, Nvec, + int, Nk, + int, Nm, // Not currently used + int, Np, + int, MaxIt, + int, MinRes, + double, resid); }; template diff --git a/tests/hadrons/Test_hadrons_distil.cc b/tests/hadrons/Test_hadrons_distil.cc index cb20b03e..1d16b086 100644 --- a/tests/hadrons/Test_hadrons_distil.cc +++ b/tests/hadrons/Test_hadrons_distil.cc @@ -33,8 +33,10 @@ using namespace Grid; using namespace Hadrons; +///////////////////////////////////////////////////////////// // This is copied from the free propagator test // Just used as an example - will be deleted +///////////////////////////////////////////////////////////// void free_prop(Application &application) { @@ -105,12 +107,8 @@ void free_prop(Application &application) freePar_W.mass = lepton_mass[i]; application.createModule("W_Lpt_" + lepton_flavour[i], freePar_W); - - } - - - + //Propagators from inversion for (unsigned int i = 0; i < flavour.size(); ++i) { @@ -138,8 +136,6 @@ void free_prop(Application &application) application.createModule("Qpt_" + flavour[i], quarkPar); - - //Wilson actions MAction::Wilson::Par actionPar_W; actionPar_W.gauge = "gauge"; @@ -147,7 +143,6 @@ void free_prop(Application &application) actionPar_W.boundary = boundary; application.createModule("W_" + flavour[i], actionPar_W); - // solvers MSolver::RBPrecCG::Par solverPar_W; solverPar_W.action = "W_" + flavour[i]; @@ -220,12 +215,108 @@ void free_prop(Application &application) application.createModule("W_meson_pt_" + flavour[i] + flavour[j], mesPar_W); - } } +///////////////////////////////////////////////////////////// +// Test creation of laplacian eigenvectors +///////////////////////////////////////////////////////////// + +void test_LapEvec(Application &application) +{ + const unsigned int nt = GridDefaultLatt()[Tp]; + + // global parameters + Application::GlobalPar globalPar; + globalPar.trajCounter.start = 1500; + globalPar.trajCounter.end = 1520; + globalPar.trajCounter.step = 20; + globalPar.runId = "test"; + application.setPar(globalPar); + // gauge field + application.createModule("gauge"); + // Now make an instance of the LapEvec object + application.createModule("LapEvecInstance"); +} + +///////////////////////////////////////////////////////////// +// Felix, this is your test here +///////////////////////////////////////////////////////////// + +void test_FelixRenameMe(Application &application) +{ + const unsigned int nt = GridDefaultLatt()[Tp]; + + // global parameters + Application::GlobalPar globalPar; + globalPar.trajCounter.start = 1500; + globalPar.trajCounter.end = 1520; + globalPar.trajCounter.step = 20; + globalPar.runId = "test"; + application.setPar(globalPar); + // gauge field + application.createModule("gauge"); + // Now make an instance of the LapEvec object + application.createModule("DistilVectorsInstance"); +} + +bool bNumber( int &ri, const char * & pstr, bool bGobbleWhiteSpace = true ) +{ + if( bGobbleWhiteSpace ) + while( std::isspace(static_cast(*pstr)) ) + pstr++; + const char * p = pstr; + bool bMinus = false; + char c = * p++; + if( c == '+' ) + c = * p++; + else if( c == '-' ) { + bMinus = true; + c = * p++; + } + int n = c - '0'; + if( n < 0 || n > 9 ) + return false; + while( * p >= '0' && * p <= '9' ) { + n = n * 10 + ( * p ) - '0'; + p++; + } + if( bMinus ) + n *= -1; + ri = n; + pstr = p; + return true; +} + int main(int argc, char *argv[]) { + // Decode command-line parameters. 1st one is which test to run + int iTestNum = 2; + + for(int i = 1 ; i < argc ; i++ ) { + std::cout << "argv[" << i << "]=\"" << argv[i] << "\"" << std::endl; + const char * p = argv[i]; + if( * p == '/' || * p == '-' ) { + p++; + char c = * p++; + switch(toupper(c)) { + case 'T': + if( bNumber( iTestNum, p ) ) { + std::cout << "Test " << iTestNum << " requested"; + if( * p ) + std::cout << " (ignoring trailer \"" << p << "\")"; + std::cout << std::endl; + } + else + std::cout << "Invalid test \"" << &argv[i][2] << "\"" << std::endl; + break; + default: + std::cout << "Ignoring switch \"" << &argv[i][1] << "\"" << std::endl; + break; + } + } + } + // initialization ////////////////////////////////////////////////////////// Grid_init(&argc, &argv); HadronsLogError.Active(GridLogError.isActive()); @@ -239,7 +330,19 @@ int main(int argc, char *argv[]) Application application; // For now perform free propagator test - replace this with distillation test(s) - free_prop( application ); + LOG(Message) << "====== Creating xml for test " << iTestNum << " ======" << std::endl; + switch(iTestNum) { + case 0: + free_prop( application ); + break; + case 1: + test_LapEvec( application ); + break; + default: // 2 + test_FelixRenameMe( application ); + break; + } + LOG(Message) << "====== XML creation for test " << iTestNum << " complete ======" << std::endl; // execution application.saveParameterFile("test_hadrons_distil.xml");