PSCF v1.5.0
ShiftMoveBase.h
1#ifndef RP_SHIFT_MOVE_BASE_H
2#define RP_SHIFT_MOVE_BASE_H
3
4/*
5* PSCF - Polymer Self-Consistent Field
6*
7* Copyright 2015 - 2026, David Morse (morse012@um.edu) and co-authors
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <rp/fts/montecarlo/McMove.h> // base class
12#include <pscf/field/RField.h> // member
13#include <pscf/math/IntVec.h> // template with defaults
14#include <util/containers/DArray.h> // member
15
16#include <pscf/backend/TmplDeclare.h>
17
18// Forward declaration
19namespace Util {
20 template <typename Data> class Array;
21}
22namespace Pscf {
23 namespace Rp {
24 template <int D, class T> class System;
25 }
26}
27
28
29namespace Pscf {
30namespace Rp {
31
32 using namespace Util;
33
49 template <int D, class T>
50 class ShiftMoveBase : public McMove<D,T>
51 {
52
53 public:
54
61
65 ~ShiftMoveBase() = default;
66
72 void readParameters(std::istream &in) override;
73
77 void setup() override;
78
79 protected:
80
84 void attemptMove() override;
85
94 virtual void shiftFields(IntVec<D> const & shift) = 0;
95
107 Array<double> const & in,
108 IntVec<D> shift,
109 IntVec<D> dimensions) const;
110
113
114 // Alias for McMove base class.
115 using McMoveT = McMove<D,T>;
116
117 // Inherited protected member functions (selected).
118 using McMove<D,T>::system;
119 using McMove<D,T>::simulator;
120
121 private:
122
124 int maxShift_;
125
127 bool isAllocated_;
128
129 };
130
131 // Explicit instantiation declarations
132 PSCF_TMPL_DECLARE(ShiftMoveBase)
133
134 // Declaration of primary ShiftMove template
135 template <int D, class T> class ShiftMove;
136
137}
138}
139#endif
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
McSimulator< D, CPT > & simulator()
Definition McMove.h:342
System< D, CPT > & system()
Definition McMove.h:328
McMove(McSimulator< D, T > &simulator)
Constructor.
Definition McMove.tpp:32
Monte-Carlo simulation coordinator.
Definition McSimulator.h:55
ShiftMove rigidly translates all w fields.
DArray< RField< D, CPT > > w_
void attemptMove() override
Attempt move that translates all w fields.
~ShiftMoveBase()=default
Destructor.
virtual void shiftFields(IntVec< D > const &shift)=0
Compute and store shifted w fields.
void setup() override
Setup before the beginning of each simulation run.
void readParameters(std::istream &in) override
Read body of parameter file block.
ShiftMoveBase(McSimulator< D, T > &simulator)
Constructor.
void shiftField(Array< double > &out, Array< double > const &in, IntVec< D > shift, IntVec< D > dimensions) const
Compute a shifted version of a field.
Base class template for classes that represent a complete system.
Array container class template.
Definition Array.h:41
Dynamically allocatable contiguous array template.
Definition DArray.h:32
Code for programs that simulate real-valued periodic fields.
Definition param_pc.dox:2
PSCF package top-level namespace.
Utility classes for scientific computation.