PSCF v1.3
rpg/field/WFieldContainer.tpp
1#ifndef RPG_W_FIELD_CONTAINER_TPP
2#define RPG_W_FIELD_CONTAINER_TPP
3
4/*
5* PSCF - Polymer Self-Consistent Field
6*
7* Copyright 2015 - 2025, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include "WFieldContainer.h"
12#include <prdc/field/WFieldsReal.tpp>
13#include <prdc/cuda/VecOp.h>
14#include <pscf/cuda/DeviceArray.h>
15
16namespace Pscf {
17namespace Rpg {
18
19 using namespace Util;
20 using namespace Pscf::Prdc;
21 using namespace Pscf::Prdc::Cuda;
22
23 // Public member function
24
25 /*
26 * Set new w-field values, using unfolded array of r-grid fields.
27 */
28 template <int D>
30 {
32 tmp.allocate(nMonomer());
33 for (int i = 0; i < nMonomer(); i++) {
34 tmp[i].associate(fields, i * meshSize(), meshDimensions());
35 }
36 bool isSymmetric = false;
38 }
39
40 // Private virtual function
41
42 template <int D>
43 void
44 WFieldContainer<D>::assignRField(RField<D>& lhs, RField<D> const & rhs)
45 const
46 {
47 int n = rhs.capacity();
48 UTIL_CHECK(lhs.capacity() == n);
49 UTIL_CHECK(meshSize() == n);
50 VecOp::eqV(lhs, rhs);
51 }
52
53} // namespace Rpg
54} // namespace Pscf
55#endif
Dynamic array on the GPU device with aligned data.
Definition DeviceArray.h:43
Field of real double precision values on an FFT mesh.
Definition cpu/RField.h:29
void setRGrid(DArray< RField< D > > const &fields, bool isSymmetric=false)
bool isSymmetric() const
Are fields symmetric under all elements of the space group?
int meshSize() const
Get mesh size (number of grid points), set on r-grid allocation.
IntVec< D > const & meshDimensions() const
Get mesh dimensions in each direction, set on r-grid allocation.
int nMonomer() const
Get number of monomer types.
void setRGrid(DeviceArray< cudaReal > &fields)
Set new w fields, in unfolded real-space (r-grid) format.
int capacity() const
Return allocated size.
Definition Array.h:159
Dynamically allocatable contiguous array template.
Definition DArray.h:32
void allocate(int capacity)
Allocate the underlying C array.
Definition DArray.h:199
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
void eqV(DeviceArray< cudaReal > &a, DeviceArray< cudaReal > const &b, const int beginIdA, const int beginIdB, const int n)
Vector assignment, a[i] = b[i], kernel wrapper (cudaReal).
Definition VecOp.cu:1039
Fields, FFTs, and utilities for periodic boundary conditions (CUDA)
Definition Reduce.cpp:14
Periodic fields and crystallography.
Definition CField.cpp:11
SCFT and PS-FTS with real periodic fields (GPU)
PSCF package top-level namespace.
Definition param_pc.dox:1