PSCF v1.4.0
ShiftMove.cu
1/*
2* PSCF - Polymer Self-Consistent Field
3*
4* Copyright 2015 - 2025, The Regents of the University of Minnesota
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "ShiftMove.h"
9#include <rpg/fts/montecarlo/McSimulator.h>
10#include <rpg/system/System.h>
11#include <rpg/solvers/Mixture.h>
12#include <rpg/field/Domain.h>
13#include <rpg/field/WFields.h>
14
15#include <rp/fts/montecarlo/ShiftMove.tpp>
16
17namespace Pscf {
18namespace Rpg {
19
20 using namespace Util;
21 using namespace Prdc;
22 using namespace Prdc::Cuda;
23
24 /*
25 * Constructor.
26 */
27 template <int D>
29 : RpShiftMove(simulator)
30 {}
31
32 /*
33 * Setup immediately before starting a simulation.
34 */
35 template <int D>
37 {
38 RpShiftMove::setup();
39
40 // Allocate CPU work space
41 if (!wOld_.isAllocated()) {
42 UTIL_CHECK(!wNew_.isAllocated());
43 const int meshSize = system().domain().mesh().size();
44 wOld_.allocate(meshSize);
45 wNew_.allocate(meshSize);
46 }
47 }
48 /*
49 * Compute and store array w_ of shifted fields.
50 */
51 template <int D>
53 {
54 IntVec<D> const& dimensions = system().domain().mesh().dimensions();
55 const int nMonomer = system().mixture().nMonomer();
56
57 for (int j = 0; j< nMonomer; ++j) {
58 wOld_ = system().w().rgrid(j);
59 RpShiftMove::shiftField(wNew_, wOld_, shift, dimensions);
60 RpShiftMove::w_[j] = wNew_;
61 }
62 }
63
64}
65}
66
67// Explicit instantiation declarations
68namespace Pscf {
69 namespace Rp {
70 template class Rp::ShiftMove<1, Rpg::Types<1> >;
71 template class Rp::ShiftMove<2, Rpg::Types<2> >;
72 template class Rp::ShiftMove<3, Rpg::Types<3> >;
73 }
74 namespace Rpg {
75 template class ShiftMove<1>;
76 template class ShiftMove<2>;
77 template class ShiftMove<3>;
78 }
79}
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
DArray< typename Types< D >::RField > w_
void shiftField(Array< double > &out, Array< double > const &in, IntVec< D > shift, IntVec< D > dimensions) const
Monte Carlo simulator for PS-FTS.
ShiftMove shifts field.
void shiftFields(IntVec< D > const &shift) override
Compute and store shifted w fields.
Definition ShiftMove.cu:52
ShiftMove(McSimulator< D > &simulator)
Constructor.
Definition ShiftMove.cu:28
void setup() override
Setup before simulation.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
Periodic fields and crystallography.
Definition complex.cpp:11
SCFT and PS-FTS with real periodic fields (GPU)
PSCF package top-level namespace.