#ifndef QCD_SCALAR_ACTION_H #define QCD_SCALAR_ACTION_H #define INHERIT_SIMPL_TYPES(Impl)\ typedef typename Impl::SiteScalar SiteScalar; \ typedef typename Impl::SiteSpinor SiteSpinor; \ typedef typename Impl::SitePropagator SitePropagator; \ typedef typename Impl::ScalarField ScalarField; \ typedef typename Impl::FermionField FermionField; \ typedef typename Impl::PropagatorField PropagatorField; \ typedef typename Impl::StencilImpl StencilImpl; namespace Grid{ namespace QCD{ // Scalar implementation class /////////////////////////////////////////////// // FIXME: it is not very nice to have the FImpl aliases template , class _Coeff_t = RealD> class ScalarImpl: public PeriodicGaugeImpl> { public: static constexpr unsigned int rDim = Representation::Dimension; public: // gauge types typedef PeriodicGaugeImpl> Gimpl; INHERIT_GIMPL_TYPES(Gimpl); // site types // (using classes instead of aliases to allow for partial specialisation) template class iImplScalar { public: typedef iScalar>> type; }; template class iImplScalar { public: typedef iScalar>> type; }; template class iImplPropagator { public: typedef iScalar>> type; }; template class iImplPropagator { public: typedef iScalar>> type; }; // type aliases typedef typename iImplScalar::type SiteScalar; typedef SiteScalar SiteSpinor; typedef typename iImplPropagator::type SitePropagator; typedef Lattice ScalarField; typedef ScalarField FermionField; typedef Lattice PropagatorField; typedef CartesianStencil StencilImpl; }; // single scalar implementation typedef ScalarImpl ScalarImplR; // Scalar action ///////////////////////////////////////////////////////////// template class Scalar: public CheckerBoardedSparseMatrixBase, public SImpl { public: INHERIT_GIMPL_TYPES(SImpl); INHERIT_SIMPL_TYPES(SImpl); public: // constructor Scalar(GaugeField &_Umu, GridCartesian &Sgrid, GridRedBlackCartesian &Hgrid, RealD _mass) : _grid(&Sgrid) , _cbgrid(&Hgrid) , mass(_mass) , Lebesgue(_grid) , LebesgueEvenOdd(_cbgrid) , Umu(&Sgrid) , UmuEven(&Hgrid) , UmuOdd(&Hgrid) { Umu = _Umu; pickCheckerboard(Even, UmuEven, Umu); pickCheckerboard(Odd, UmuOdd, Umu); } // grid access virtual GridBase *RedBlackGrid(void) {return _grid;} // half checkerboard operations // FIXME: do implementation virtual void Meooe(const ScalarField &in, ScalarField &out) { assert(0); } virtual void Mooee(const ScalarField &in, ScalarField &out) { assert(0); } virtual void MooeeInv(const ScalarField &in, ScalarField &out) { assert(0); } virtual void MeooeDag(const ScalarField &in, ScalarField &out) { assert(0); } virtual void MooeeDag(const ScalarField &in, ScalarField &out) { assert(0); } virtual void MooeeInvDag(const ScalarField &in, ScalarField &out) { assert(0); } // free propagators static void MomentumSpacePropagator(ScalarField &out, RealD m); static void FreePropagator(const ScalarField &in, ScalarField &out, const ScalarField &momKernel); static void FreePropagator(const ScalarField &in, ScalarField &out, RealD m); public: RealD mass; GridBase *_grid; GridBase *_cbgrid; // Defines the stencils for even and odd StencilImpl Stencil; StencilImpl StencilEven; StencilImpl StencilOdd; // Copy of the gauge field, with even and odd subsets GaugeField Umu; GaugeField UmuEven; GaugeField UmuOdd; LebesgueOrder Lebesgue; LebesgueOrder LebesgueEvenOdd; }; template void Scalar::MomentumSpacePropagator(ScalarField &out, RealD m) { GridBase *grid = out._grid; ScalarField kmu(grid); const unsigned int nd = grid->_ndimension; std::vector &l = grid->_fdimensions; out = m*m; for(int mu = 0; mu < nd; mu++) { Real twoPiL = M_PI*2./l[mu]; LatticeCoordinate(kmu,mu); kmu = 2.*sin(.5*twoPiL*kmu); out = out + kmu*kmu; } } template void Scalar::FreePropagator(const ScalarField &in, ScalarField &out, const ScalarField &FTKernel) { FFT fft((GridCartesian *)in._grid); ScalarField inFT(in._grid); fft.FFT_all_dim(inFT, in, FFT::forward); inFT = inFT*FTKernel; fft.FFT_all_dim(out, inFT, FFT::backward); } template void Scalar::FreePropagator(const ScalarField &in, ScalarField &out, RealD m) { ScalarField FTKernel(in._grid); MomentumSpacePropagator(FTKernel, m); FreePropagator(in, out, FTKernel); } template void ScalarToProp(typename SImpl::PropagatorField &p, const typename SImpl::ScalarField &s, const int c) { for(int i = 0; i < SImpl::rDim; ++i) { pokeColour(p, peekColour(s, i), i); } } template void PropToScalar(typename SImpl::ScalarField &s, const typename SImpl::PropagatorField &p, const int c) { for(int i = 0; i < SImpl::rDim; ++i) { pokeColour(s, peekColour(p, i), i); } } }} #endif