2016-12-15 18:26:39 +00:00
|
|
|
/*************************************************************************************
|
|
|
|
|
2016-02-25 12:07:21 +00:00
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
2016-12-15 18:26:39 +00:00
|
|
|
Source file: extras/Hadrons/Global.hpp
|
2016-02-25 12:07:21 +00:00
|
|
|
|
|
|
|
Copyright (C) 2015
|
2016-12-15 18:26:39 +00:00
|
|
|
Copyright (C) 2016
|
2016-02-25 12:07:21 +00:00
|
|
|
|
|
|
|
Author: Antonin Portelli <antonin.portelli@me.com>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program 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 General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
2016-12-15 18:26:39 +00:00
|
|
|
See the full license in the file "LICENSE" in the top level distribution directory
|
|
|
|
*************************************************************************************/
|
2016-12-15 18:21:52 +00:00
|
|
|
/* END LEGAL */
|
2015-10-27 17:33:18 +00:00
|
|
|
|
|
|
|
#ifndef Hadrons_Global_hpp_
|
|
|
|
#define Hadrons_Global_hpp_
|
|
|
|
|
2015-11-05 14:28:14 +00:00
|
|
|
#include <set>
|
2015-12-02 19:33:34 +00:00
|
|
|
#include <stack>
|
2016-08-03 17:14:32 +01:00
|
|
|
#include <Grid/Grid.h>
|
2016-12-14 18:02:18 +00:00
|
|
|
#include <cxxabi.h>
|
2015-10-27 17:33:18 +00:00
|
|
|
|
|
|
|
#define BEGIN_HADRONS_NAMESPACE \
|
2016-05-03 03:31:21 +01:00
|
|
|
namespace Grid {\
|
|
|
|
using namespace QCD;\
|
2015-10-27 17:33:18 +00:00
|
|
|
namespace Hadrons {\
|
2016-05-03 03:31:21 +01:00
|
|
|
using Grid::operator<<;
|
|
|
|
#define END_HADRONS_NAMESPACE }}
|
|
|
|
|
2016-12-05 05:29:32 +00:00
|
|
|
#define BEGIN_MODULE_NAMESPACE(name)\
|
|
|
|
namespace name {\
|
|
|
|
using Grid::operator<<;
|
|
|
|
#define END_MODULE_NAMESPACE }
|
|
|
|
|
2016-05-03 03:31:21 +01:00
|
|
|
/* the 'using Grid::operator<<;' statement prevents a very nasty compilation
|
2016-12-05 05:29:32 +00:00
|
|
|
* error with GCC 5 (clang & GCC 6 compile fine without it).
|
2016-05-03 03:31:21 +01:00
|
|
|
*/
|
2015-10-27 17:33:18 +00:00
|
|
|
|
2016-11-27 07:47:22 +00:00
|
|
|
#ifndef FIMPL
|
|
|
|
#define FIMPL WilsonImplR
|
|
|
|
#endif
|
2016-12-29 21:44:58 +00:00
|
|
|
#ifndef SIMPL
|
2017-06-05 22:37:47 +01:00
|
|
|
#define SIMPL ScalarImplCR
|
2016-12-29 21:44:58 +00:00
|
|
|
#endif
|
2016-11-27 07:47:22 +00:00
|
|
|
|
2015-10-27 17:33:18 +00:00
|
|
|
BEGIN_HADRONS_NAMESPACE
|
|
|
|
|
2016-11-28 05:02:10 +00:00
|
|
|
// type aliases
|
2016-12-29 21:44:58 +00:00
|
|
|
#define FERM_TYPE_ALIASES(FImpl, suffix)\
|
2017-06-07 14:38:51 +01:00
|
|
|
typedef FermionOperator<FImpl> FMat##suffix; \
|
|
|
|
typedef typename FImpl::FermionField FermionField##suffix; \
|
|
|
|
typedef typename FImpl::PropagatorField PropagatorField##suffix; \
|
|
|
|
typedef typename FImpl::SitePropagator::scalar_object SitePropagator##suffix; \
|
|
|
|
typedef std::vector<SitePropagator##suffix> SlicedPropagator##suffix;
|
2016-12-29 21:44:58 +00:00
|
|
|
|
|
|
|
#define GAUGE_TYPE_ALIASES(FImpl, suffix)\
|
|
|
|
typedef typename FImpl::DoubledGaugeField DoubledGaugeField##suffix;
|
|
|
|
|
|
|
|
#define SCALAR_TYPE_ALIASES(SImpl, suffix)\
|
2017-06-05 22:37:47 +01:00
|
|
|
typedef typename SImpl::Field ScalarField##suffix;\
|
|
|
|
typedef typename SImpl::Field PropagatorField##suffix;
|
2016-12-29 21:44:58 +00:00
|
|
|
|
|
|
|
#define SOLVER_TYPE_ALIASES(FImpl, suffix)\
|
|
|
|
typedef std::function<void(FermionField##suffix &,\
|
2016-12-05 07:47:29 +00:00
|
|
|
const FermionField##suffix &)> SolverFn##suffix;
|
2016-11-28 05:02:10 +00:00
|
|
|
|
2017-06-06 17:45:30 +01:00
|
|
|
#define SINK_TYPE_ALIASES(suffix)\
|
|
|
|
typedef std::function<SlicedPropagator##suffix(const PropagatorField##suffix &)> SinkFn##suffix;
|
|
|
|
|
|
|
|
#define FGS_TYPE_ALIASES(FImpl, suffix)\
|
2016-12-29 21:44:58 +00:00
|
|
|
FERM_TYPE_ALIASES(FImpl, suffix)\
|
|
|
|
GAUGE_TYPE_ALIASES(FImpl, suffix)\
|
|
|
|
SOLVER_TYPE_ALIASES(FImpl, suffix)
|
2016-11-28 05:02:10 +00:00
|
|
|
|
|
|
|
// logger
|
2015-10-27 17:33:18 +00:00
|
|
|
class HadronsLogger: public Logger
|
|
|
|
{
|
|
|
|
public:
|
2016-02-23 16:21:45 +00:00
|
|
|
HadronsLogger(int on, std::string nm): Logger("Hadrons", on, nm,
|
2016-08-03 17:14:32 +01:00
|
|
|
GridLogColours, "BLACK"){};
|
2015-10-27 17:33:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define LOG(channel) std::cout << HadronsLog##channel
|
2015-11-05 14:28:14 +00:00
|
|
|
#define HADRON_ERROR(msg)\
|
2016-04-30 08:17:04 +01:00
|
|
|
LOG(Error) << msg << " (" << __FUNCTION__ << " at " << __FILE__ << ":"\
|
|
|
|
<< __LINE__ << ")" << std::endl;\
|
2015-11-05 14:28:14 +00:00
|
|
|
abort();
|
|
|
|
|
|
|
|
#define DEBUG_VAR(var) LOG(Debug) << #var << "= " << (var) << std::endl;
|
2015-10-27 17:33:18 +00:00
|
|
|
|
|
|
|
extern HadronsLogger HadronsLogError;
|
|
|
|
extern HadronsLogger HadronsLogWarning;
|
|
|
|
extern HadronsLogger HadronsLogMessage;
|
2016-05-09 14:49:06 +01:00
|
|
|
extern HadronsLogger HadronsLogIterative;
|
2015-10-27 17:33:18 +00:00
|
|
|
extern HadronsLogger HadronsLogDebug;
|
|
|
|
|
2015-12-23 14:21:35 +00:00
|
|
|
// singleton pattern
|
|
|
|
#define SINGLETON(name)\
|
|
|
|
public:\
|
|
|
|
name(const name &e) = delete;\
|
|
|
|
void operator=(const name &e) = delete;\
|
|
|
|
static name & getInstance(void)\
|
|
|
|
{\
|
|
|
|
static name e;\
|
|
|
|
return e;\
|
|
|
|
}\
|
|
|
|
private:\
|
|
|
|
name(void);
|
|
|
|
|
2016-04-30 08:17:04 +01:00
|
|
|
#define SINGLETON_DEFCTOR(name)\
|
|
|
|
public:\
|
|
|
|
name(const name &e) = delete;\
|
|
|
|
void operator=(const name &e) = delete;\
|
|
|
|
static name & getInstance(void)\
|
|
|
|
{\
|
|
|
|
static name e;\
|
|
|
|
return e;\
|
|
|
|
}\
|
|
|
|
private:\
|
|
|
|
name(void) = default;
|
|
|
|
|
2016-05-10 19:07:41 +01:00
|
|
|
// pretty size formating
|
|
|
|
std::string sizeString(long unsigned int bytes);
|
|
|
|
|
2016-12-14 18:02:18 +00:00
|
|
|
// type utilities
|
2016-05-10 19:07:41 +01:00
|
|
|
template <typename T>
|
2016-12-14 18:02:18 +00:00
|
|
|
const std::type_info * typeIdPt(const T &x)
|
2016-05-10 19:07:41 +01:00
|
|
|
{
|
2016-12-14 18:02:18 +00:00
|
|
|
return &typeid(x);
|
2016-05-10 19:07:41 +01:00
|
|
|
}
|
|
|
|
|
2016-12-14 18:02:18 +00:00
|
|
|
std::string typeName(const std::type_info *info);
|
|
|
|
|
2016-05-10 19:07:41 +01:00
|
|
|
template <typename T>
|
2016-12-14 18:02:18 +00:00
|
|
|
const std::type_info * typeIdPt(void)
|
2016-05-10 19:07:41 +01:00
|
|
|
{
|
2016-12-14 18:02:18 +00:00
|
|
|
return &typeid(T);
|
2016-05-10 19:07:41 +01:00
|
|
|
}
|
|
|
|
|
2016-06-06 17:45:37 +01:00
|
|
|
template <typename T>
|
2016-12-14 18:02:18 +00:00
|
|
|
std::string typeName(const T &x)
|
2016-06-06 17:45:37 +01:00
|
|
|
{
|
2016-12-14 18:02:18 +00:00
|
|
|
return typeName(typeIdPt(x));
|
2016-06-06 17:45:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
2016-12-14 18:02:18 +00:00
|
|
|
std::string typeName(void)
|
2016-06-06 17:45:37 +01:00
|
|
|
{
|
2016-12-14 18:02:18 +00:00
|
|
|
return typeName(typeIdPt<T>());
|
2016-06-06 17:45:37 +01:00
|
|
|
}
|
|
|
|
|
2017-02-08 15:50:05 +00:00
|
|
|
// default writers/readers
|
|
|
|
#ifdef HAVE_HDF5
|
|
|
|
typedef Hdf5Reader CorrReader;
|
|
|
|
typedef Hdf5Writer CorrWriter;
|
|
|
|
#else
|
|
|
|
typedef XmlReader CorrReader;
|
|
|
|
typedef XmlWriter CorrWriter;
|
|
|
|
#endif
|
|
|
|
|
2015-10-27 17:33:18 +00:00
|
|
|
END_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
#endif // Hadrons_Global_hpp_
|