CHROMA
fermact.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*! @file
4  * @brief Class structure for fermion actions
5  */
6 
7 #ifndef __fermact_h__
8 #define __fermact_h__
9 
10 #include "chromabase.h"
11 #include "fermbc.h"
12 #include "state.h"
13 #include "create_state.h"
14 #include "linearop.h"
15 #include "lmdagm.h"
16 #include "syssolver.h"
17 #include "io/xml_group_reader.h"
24 namespace Chroma
25 {
26  //! Base class for quadratic matter actions (e.g., fermions)
27  /*! @ingroup actions
28  *
29  * Supports creation and application for quadratic actions.
30  * This is basically a foundry class with additional operations.
31  *
32  * The class holds info on the particulars of a bi-local action,
33  * but it DOES NOT hold gauge fields. A specific dirac-operator
34  * is a functional of the gauge fields, hence when a dirac-operator
35  * is needed, it is created.
36  *
37  * The FermState holds gauge fields and whatever auxilliary info
38  * is needed to create a specific dirac operator (linear operator)
39  * on some background gauge field.
40  *
41  * The FermBC is the type of boundary conditions used for this action
42  *
43  * The linop and lmdagm functions create a linear operator on a
44  * fixed FermState
45  *
46  * The qprop solves for the full linear system undoing all preconditioning.
47  * No direct functions are provided (or needed) to call a linear system
48  * solver - that is a stand-alone function in the generic programming sense.
49  *
50  */
51  template<typename T, typename P, typename Q>
53  {
54  public:
55  //! Virtual destructor to help with cleanup;
56  virtual ~FermionAction() {}
57 
58  //! Given links (coordinates Q) create the state needed for the linear operators
59  virtual FermState<T,P,Q>* createState(const Q& q) const
60  {
61  return getCreateState()(q);
62  }
63 
64  //! Given links (coordinates Q) create a state with additional info held by the XMLReader
65  /*!
66  * THIS FUNCTION SHOULD DISAPPEAR.
67  * This function is only really used by the overlap operators to hand
68  * around the StateInfo stuff. We are moving to have this stuff live within
69  * the FermState
70  */
71  virtual FermState<T,P,Q>* createState(const Q& q,
72  XMLReader& reader,
73  const std::string& path) const
74  {
75  return createState(q);
76  }
77 
78  //! Return the fermion BC object for this action
79  virtual const FermBC<T,P,Q>& getFermBC() const
80  {
81  return getCreateState().getBC();
82  }
83 
84  //! Return the factory object that produces a state
85  /*!
86  * The user will supply the FermState in a derived class
87  *
88  * This method is public for the simple reason that
89  * a fermact might be nested, in which case the container would
90  * forward this function call to the children.
91  */
92  virtual const CreateFermState<T,P,Q>& getCreateState() const = 0;
93 
94  //! Return quark prop solver, solution of unpreconditioned system
96  const GroupXML_t& invParam) const = 0;
97 
98  //! Given a complete propagator as a source, this does all the inversions needed
99  /*!
100  * \param q_sol quark propagator ( Write )
101  * \param q_src source ( Read )
102  * \param xml_out diagnostic output ( Modify )
103  * \param state gauge connection state ( Read )
104  * \param invParam inverter parameters ( Read )
105  * \param quarkSpinType compute only a non-relativistic prop ( Read )
106  * \param ncg_had number of solver iterations ( Write )
107  */
108  virtual void quarkProp(typename PropTypeTraits<T>::Type_t& q_sol,
109  XMLWriter& xml_out,
110  const typename PropTypeTraits<T>::Type_t& q_src,
112  const GroupXML_t& invParam,
113  QuarkSpinType quarkSpinType,
114  int& ncg_had) const = 0;
115 
116  //! Given a complete propagator as a source, this does all the inversions needed
117  /*!
118  * Provides a default version
119  *
120  * \param q_sol quark propagator ( Write )
121  * \param q_src source ( Read )
122  * \param xml_out diagnostic output ( Modify )
123  * \param state gauge connection state ( Read )
124  * \param invParam inverter parameters ( Read )
125  * \param quarkSpinType compute only a non-relativistic prop ( Read )
126  * \param ncg_had number of solver iterations ( Write )
127  * \param t_src time slice of source ( Read )
128  * \param j_decay direction of decay ( Read )
129  * \param obsvP compute currents and residual mass ( Read )
130  * \param ncg_had number of solver iterations ( Write )
131  */
132  virtual void quarkProp(typename PropTypeTraits<T>::Type_t& q_sol,
133  XMLWriter& xml_out,
134  const typename PropTypeTraits<T>::Type_t& q_src,
135  int t_src, int j_decay,
137  const GroupXML_t& invParam,
138  QuarkSpinType quarkSpinType,
139  bool obsvP,
140  int& ncg_had) const
141  {
142  quarkProp(q_sol, xml_out, q_src, state, invParam, quarkSpinType, ncg_had);
143  }
144 
145  };
146 
147 
148  //-------------------------------------------------------------------------------------------
149  //! Base class for quadratic matter actions (e.g., fermions)
150  /*! @ingroup actions
151  *
152  * Supports creation and application for quadratic actions.
153  * This is basically a foundry class with additional operations.
154  *
155  * The class holds info on the particulars of a bi-local action,
156  * but it DOES NOT hold gauge fields. A specific dirac-operator
157  * is a functional of the gauge fields, hence when a dirac-operator
158  * is needed, it is created.
159  *
160  * The FermState<T,P,Q> holds gauge fields and whatever auxilliary info
161  * is needed to create a specific dirac operator (linear operator)
162  * on some background gauge field.
163  *
164  * The FermBC is the type of boundary conditions used for this action
165  *
166  * The linop and lmdagm functions create a linear operator on a
167  * fixed FermState
168  *
169  * The qprop solves for the full linear system undoing all preconditioning.
170  * No direct functions are provided (or needed) to call a linear system
171  * solver - that is a stand-alone function in the generic programming sense.
172  *
173  */
174  template<typename T, typename P, typename Q>
175  class FermAct4D : public FermionAction<T,P,Q>
176  {
177  public:
178  //! Virtual destructor to help with cleanup;
179  virtual ~FermAct4D() {}
180 
181  //! Produce a linear operator for this action
183 
184  //! Produce a linear operator M^dag.M for this action
186 
187  //! Return a linear operator solver for this action to solve M*psi=chi
189  const GroupXML_t& invParam) const = 0;
190 
191  //! Return a linear operator solver for this action to solve MdagM*psi=chi
193  const GroupXML_t& invParam) const = 0;
194 
195  //! Return a multi-shift linear operator solver for this action to solve (M+shift)*psi=chi
197  const GroupXML_t& invParam) const = 0;
198 
199  //! Return a multi-shift linear operator solver for this action to solve (MdagM+shift)*psi=chi
201  const GroupXML_t& invParam) const = 0;
202 
203  //! Return a multi-shift accumulate solver.
204  // for solving A \sum_j p_j (MdagM + shift_j)^{-1} psi_j
206  const GroupXML_t& invParam) const = 0;
207 
208  //! Return quark prop solver, solution of unpreconditioned system
209  /*! Default implementation provided */
211  const GroupXML_t& invParam) const;
212  };
213 
214 
215  //-------------------------------------------------------------------------------------------
216  //! Base class for quadratic matter actions (e.g., fermions)
217  /*! @ingroup actions
218  *
219  * Supports creation and application for quadratic actions with derivatives
220  * This is basically a foundry class with additional operations.
221  */
222  template<typename T, typename P, typename Q>
223  class DiffFermAct4D : public FermAct4D<T,P,Q>
224  {
225  public:
226  //! Virtual destructor to help with cleanup;
227  virtual ~DiffFermAct4D() {}
228 
229  //! Produce a linear operator for this action
231 
232  //! Produce a linear operator M^dag.M for this action
234  };
235 
236 
237  //-------------------------------------------------------------------------------------------
238  //! Base class of quadratic matter actions (e.g., fermions) living in an extra dimension
239  /*! @ingroup actions
240  *
241  * Supports creation and application for quadratic actions, specialized
242  * to support arrays of matter fields
243  *
244  * The class holds info on the particulars of a bi-local action,
245  * but it DOES NOT hold gauge fields. A specific dirac-operator
246  * is a functional of the gauge fields, hence when a dirac-operator
247  * is needed, it is created.
248  *
249  * The FermState holds gauge fields and whatever auxilliary info
250  * is needed to create a specific dirac operator (linear operator)
251  * on some background gauge field.
252  *
253  * The FermBC is the type of boundary conditions used for this action
254  *
255  * The linop and lmdagm functions create a linear operator on a
256  * fixed FermState
257  *
258  * The qprop solves for the full linear system undoing all preconditioning.
259  * No direct functions are provided (or needed) to call a linear system
260  * solver - that is a stand-alone function in the generic programming sense.
261  *
262  */
263  template<typename T, typename P, typename Q>
264  class FermAct5D : public FermionAction<T,P,Q>
265  {
266  public:
267  //! Virtual destructor to help with cleanup;
268  virtual ~FermAct5D() {}
269 
270  //! Return the quark mass
271  virtual Real getQuarkMass() const = 0;
272 
273  //! Expected length of array index
274  virtual int size() const = 0;
275 
276  //! Produce a linear operator for this action
278 
279  //! Produce a linear operator M^dag.M for this action
281 
282  //! Produce a Pauli-Villars linear operator for this action
284 
285  //! Return a linear operator solver for this action to solve M*psi=chi
287  const GroupXML_t& invParam) const = 0;
288 
289  //! Return a linear operator solver for this action to solve MdagM*psi=chi
291  const GroupXML_t& invParam) const = 0;
292 
293  //! Return a linear operator solver for this action to solve PV*psi=chi
294  /*! Do we need this critter? */
296  const GroupXML_t& invParam) const = 0;
297 
298  //! Return a linear operator solver for this action to solve PV^dag*PV*psi=chi
299  /*! This is used in two-flavor molecdyn monomials */
301  const GroupXML_t& invParam) const = 0;
302 
303  //! Return a multi-shift linear operator solver for this action to solve (MdagM+shift)*psi=chi
305  const GroupXML_t& invParam) const = 0;
306 
307 
308 
309 
310  //! Return a multi-shift accumulate solver.
311  // for solving A \sum_j p_j (MdagM + shift_j)^{-1} psi_j
313  const GroupXML_t& invParam) const = 0;
314 
315 
316  //! Return a multi-shift linear operator solver for this action to solve (PV^dag*PV+shift)*psi=chi
318  const GroupXML_t& invParam) const = 0;
319 
320 
321  //! Return a multi-shift accumulate solver.
322  // for solving A \sum_j p_j (MdagM + shift_j)^{-1} psi_j
323  // but for the PV.
325  const GroupXML_t& invParam) const = 0;
326 
327 
328  //! Return quark prop solver, solution of unpreconditioned system
329  /*! Default implementation provided */
331  const GroupXML_t& invParam) const;
332  };
333 
334 
335  //-------------------------------------------------------------------------------------------
336  //! Base class of quadratic matter actions (e.g., fermions) living in an extra dimension
337  /*! @ingroup actions
338  *
339  * Supports creation and application for quadratic actions, specialized
340  * to support arrays of matter fields including derivatives
341  */
342  template<typename T, typename P, typename Q>
343  class DiffFermAct5D : public FermAct5D<T,P,Q>
344  {
345  public:
346  //! Virtual destructor to help with cleanup;
347  virtual ~DiffFermAct5D() {}
348 
349  //! Produce a linear operator for this action
351 
352  //! Produce a linear operator M^dag.M for this action
354 
355  //! Produce a Pauli-Villars linear operator for this action
357  };
358 
359 }
360 
361 
362 #endif
Primary include file for CHROMA library code.
Create a fermion connection state.
Definition: create_state.h:69
Base class for quadratic matter actions (e.g., fermions)
Definition: fermact.h:224
virtual ~DiffFermAct4D()
Virtual destructor to help with cleanup;.
Definition: fermact.h:227
virtual DiffLinearOperator< T, Q, P > * lMdagM(Handle< FermState< T, P, Q > > state) const =0
Produce a linear operator M^dag.M for this action.
virtual DiffLinearOperator< T, Q, P > * linOp(Handle< FermState< T, P, Q > > state) const =0
Produce a linear operator for this action.
Base class of quadratic matter actions (e.g., fermions) living in an extra dimension.
Definition: fermact.h:344
virtual DiffLinearOperatorArray< T, P, Q > * linOp(Handle< FermState< T, P, Q > > state) const =0
Produce a linear operator for this action.
virtual ~DiffFermAct5D()
Virtual destructor to help with cleanup;.
Definition: fermact.h:347
virtual DiffLinearOperatorArray< T, P, Q > * lMdagM(Handle< FermState< T, P, Q > > state) const =0
Produce a linear operator M^dag.M for this action.
virtual DiffLinearOperatorArray< T, P, Q > * linOpPV(Handle< FermState< T, P, Q > > state) const =0
Produce a Pauli-Villars linear operator for this action.
Differentiable Linear Operator.
Definition: linearop.h:150
Differentiable Linear Operator.
Definition: linearop.h:98
Base class for quadratic matter actions (e.g., fermions)
Definition: fermact.h:176
virtual LinearOperator< T > * lMdagM(Handle< FermState< T, P, Q > > state) const =0
Produce a linear operator M^dag.M for this action.
virtual LinOpSystemSolver< T > * invLinOp(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const =0
Return a linear operator solver for this action to solve M*psi=chi.
virtual SystemSolver< T > * qprop(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return quark prop solver, solution of unpreconditioned system.
virtual LinOpMultiSystemSolver< T > * mInvLinOp(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const =0
Return a multi-shift linear operator solver for this action to solve (M+shift)*psi=chi.
virtual MdagMMultiSystemSolver< T > * mInvMdagM(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const =0
Return a multi-shift linear operator solver for this action to solve (MdagM+shift)*psi=chi.
virtual MdagMMultiSystemSolverAccumulate< T > * mInvMdagMAcc(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const =0
Return a multi-shift accumulate solver.
virtual MdagMSystemSolver< T > * invMdagM(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const =0
Return a linear operator solver for this action to solve MdagM*psi=chi.
virtual ~FermAct4D()
Virtual destructor to help with cleanup;.
Definition: fermact.h:179
virtual LinearOperator< T > * linOp(Handle< FermState< T, P, Q > > state) const =0
Produce a linear operator for this action.
Base class of quadratic matter actions (e.g., fermions) living in an extra dimension.
Definition: fermact.h:265
virtual MdagMSystemSolverArray< T > * invMdagM(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const =0
Return a linear operator solver for this action to solve MdagM*psi=chi.
virtual ~FermAct5D()
Virtual destructor to help with cleanup;.
Definition: fermact.h:268
virtual MdagMMultiSystemSolverAccumulateArray< T > * mInvMdagMPVAcc(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const =0
Return a multi-shift accumulate solver.
virtual LinOpSystemSolverArray< T > * invLinOp(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const =0
Return a linear operator solver for this action to solve M*psi=chi.
virtual LinearOperatorArray< T > * linOpPV(Handle< FermState< T, P, Q > > state) const =0
Produce a Pauli-Villars linear operator for this action.
virtual LinOpSystemSolverArray< T > * invLinOpPV(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const =0
Return a linear operator solver for this action to solve PV*psi=chi.
virtual MdagMMultiSystemSolverArray< T > * mInvMdagM(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const =0
Return a multi-shift linear operator solver for this action to solve (MdagM+shift)*psi=chi.
virtual MdagMMultiSystemSolverArray< T > * mInvMdagMPV(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const =0
Return a multi-shift linear operator solver for this action to solve (PV^dag*PV+shift)*psi=chi.
virtual Real getQuarkMass() const =0
Return the quark mass.
virtual int size() const =0
Expected length of array index.
virtual LinearOperatorArray< T > * linOp(Handle< FermState< T, P, Q > > state) const =0
Produce a linear operator for this action.
virtual MdagMMultiSystemSolverAccumulateArray< T > * mInvMdagMAcc(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const =0
Return a multi-shift accumulate solver.
virtual MdagMSystemSolverArray< T > * invMdagMPV(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const =0
Return a linear operator solver for this action to solve PV^dag*PV*psi=chi.
virtual LinearOperatorArray< T > * lMdagM(Handle< FermState< T, P, Q > > state) const =0
Produce a linear operator M^dag.M for this action.
virtual SystemSolverArray< T > * qpropT(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return quark prop solver, solution of unpreconditioned system.
Base class for all fermion action boundary conditions.
Definition: fermbc.h:20
Support class for fermion actions and linear operators.
Definition: state.h:94
Base class for quadratic matter actions (e.g., fermions)
Definition: fermact.h:53
virtual void quarkProp(typename PropTypeTraits< T >::Type_t &q_sol, XMLWriter &xml_out, const typename PropTypeTraits< T >::Type_t &q_src, Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam, QuarkSpinType quarkSpinType, int &ncg_had) const =0
Given a complete propagator as a source, this does all the inversions needed.
virtual void quarkProp(typename PropTypeTraits< T >::Type_t &q_sol, XMLWriter &xml_out, const typename PropTypeTraits< T >::Type_t &q_src, int t_src, int j_decay, Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam, QuarkSpinType quarkSpinType, bool obsvP, int &ncg_had) const
Given a complete propagator as a source, this does all the inversions needed.
Definition: fermact.h:132
virtual FermState< T, P, Q > * createState(const Q &q, XMLReader &reader, const std::string &path) const
Given links (coordinates Q) create a state with additional info held by the XMLReader.
Definition: fermact.h:71
virtual const FermBC< T, P, Q > & getFermBC() const
Return the fermion BC object for this action.
Definition: fermact.h:79
virtual const CreateFermState< T, P, Q > & getCreateState() const =0
Return the factory object that produces a state.
virtual SystemSolver< T > * qprop(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const =0
Return quark prop solver, solution of unpreconditioned system.
virtual ~FermionAction()
Virtual destructor to help with cleanup;.
Definition: fermact.h:56
virtual FermState< T, P, Q > * createState(const Q &q) const
Given links (coordinates Q) create the state needed for the linear operators.
Definition: fermact.h:59
Class for counted reference semantics.
Definition: handle.h:33
SystemSolver disambiguator.
SystemSolver disambiguator.
Linear Operator to arrays.
Definition: linearop.h:61
Linear Operator.
Definition: linearop.h:27
SystemSolver disambiguator.
SystemSolver disambiguator.
Linear system solvers of arrays.
Definition: syssolver.h:62
Linear system solvers.
Definition: syssolver.h:34
Create a connection state.
Enum for what spin components of a quark prop to compute.
Fermion action boundary conditions.
QuarkSpinType
Quark spin type.
Linear Operators.
M^dag*M composition of a linear operator.
int j_decay
Definition: meslate.cc:22
Double q
Definition: mesq.cc:17
Disambiguator for multi-shift linop system solvers.
Disambiguator for multi-shift MdagM system solvers.
Disambiguator for multi-shift MdagM system solvers.
Handle< FermBC< LatticeStaggeredFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > reader(XMLReader &xml_in, const std::string &path)
Helper function for the FermionAction readers.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
LinOpSysSolverMGProtoClover::Q Q
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
::std::string string
Definition: gtest.h:1979
Support class for fermion actions and linear operators.
Hold group xml and type id.
SystemSolver disambiguator.
SystemSolver disambiguator.
Linear system solvers.
Disambiguator for LinOp system solvers.
Disambiguator for MdagM system solvers.
Read an XML group as a std::string.