PSCF v1.4.0
WFields.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 "WFields.h" // class header
9#include <rpg/field/FieldIo.h>
10#include <pscf/cuda/VecOp.h>
11#include <pscf/cuda/DeviceArray.h>
12#include <rp/field/WFields.tpp> // base class implementation
13
14namespace Pscf {
15namespace Rpg {
16
17 using namespace Util;
18 using namespace Pscf::Prdc;
19 using namespace Pscf::Prdc::Cuda;
20
21 // Public member function
22
23 /*
24 * Set new w-field values, using unfolded array of r-grid fields.
25 */
26 template <int D>
28 {
29 // Create DArray tmp with RField<D> elements
31 const int nMonomer = RpWFields::nMonomer();
32 tmp.allocate(nMonomer);
33
34 // Associate each RField<D> with a slice of the unfolded array
36 const int meshSize = RpWFields::meshSize();
37 for (int i = 0; i < nMonomer; i++) {
38 tmp[i].associate(fields, i*meshSize, meshDimensions);
39 }
40
41 // Use tmp array to set w-fields for all monomer types
42 bool isSymmetric = false;
44 }
45
46}
47}
48
49// Explicit instantiation definitions
50namespace Pscf {
51 namespace Rp {
52 using namespace Prdc;
53 template class WFields<1, Cuda::RField<1>, Rpg::FieldIo<1> >;
54 template class WFields<2, Cuda::RField<2>, Rpg::FieldIo<2> >;
55 template class WFields<3, Cuda::RField<3>, Rpg::FieldIo<3> >;
56 }
57 namespace Rpg {
58 template class WFields<1>;
59 template class WFields<2>;
60 template class WFields<3>;
61 }
62}
Dynamic array on the GPU device with aligned data.
Definition DeviceArray.h:96
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
void setRGrid(DArray< RField< D > > const &fields, bool isSymmetric=false)
File input/output operations and format conversions for fields.
A container of fields stored in both basis and r-grid format.
void setRGrid(DeviceArray< cudaReal > &fields)
Set new w fields, in unfolded real-space (r-grid) format.
Definition WFields.cu:27
Dynamically allocatable contiguous array template.
Definition DArray.h:32
void allocate(int capacity)
Allocate the underlying C array.
Definition DArray.h:269
Fields, FFTs, and utilities for periodic boundary conditions (CUDA).
Definition CField.cu:12
Periodic fields and crystallography.
Definition complex.cpp:11
Class templates for real-valued periodic fields.
SCFT and PS-FTS with real periodic fields (GPU)
PSCF package top-level namespace.