8#include "FilmFieldGenExt_u.h"
10#include <rp/system/System.h>
11#include <rp/scft/iterator/Iterator.h>
12#include <rp/solvers/Mixture.h>
13#include <rp/field/Domain.h>
14#include <rp/field/CFields.cu>
15#include <rp/field/WFields.cu>
16#include <rp/field/Mask.cu>
18#include <pscf/field/cpp/RField.h>
19#include <pscf/field/cuda/resources.h>
21#include <pscf/crystal/Basis.h>
22#include <pscf/crystal/UnitCell.h>
23#include <pscf/crystal/paramIdConversions.h>
56 __global__
void _hFieldDerivatives(
cudaReal ** hDerivs,
61 int const normalVecId,
66 int ix = blockIdx.x * blockDim.x + threadIdx.x;
67 int iy = blockIdx.y * blockDim.y + threadIdx.y;
68 int iz = blockIdx.z * blockDim.z + threadIdx.z;
93 dPhidL = dPhidL * (dPhidL - 1) * 8.0 * ( std::abs(d - 0.5) - 0.5 )
97 for (
int in = 0; in < nMonomer; in++) {
99 hDerivs[in][id] = -1.0 * dPhidL * chiBottom[in];
101 hDerivs[in][id] = -1.0 * dPhidL * chiTop[in];
119 __global__
void _generateHFields(
cudaReal ** hFields,
123 int const normalVecId,
128 int ix = blockIdx.x * blockDim.x + threadIdx.x;
129 int iy = blockIdx.y * blockDim.y + threadIdx.y;
130 int iz = blockIdx.z * blockDim.z + threadIdx.z;
141 if (normalVecId == 2) topHalf = (2*ix >=
meshDims.x);
142 if (normalVecId == 1) topHalf = (2*iy >=
meshDims.y);
143 if (normalVecId == 0) topHalf = (2*iz >=
meshDims.z);
145 if (normalVecId == 1) topHalf = (2*ix >=
meshDims.x);
146 if (normalVecId == 0) topHalf = (2*iy >=
meshDims.y);
156 for (
int in = 0; in < nMonomer; in++) {
158 hFields[in][id] = (1.0 - maskVal) * chiTop[in];
160 hFields[in][id] = (1.0 - maskVal) * chiBottom[in];
211 system().domain().lattice());
212 if (nvParamId != paramId)
return 0.0;
221 int nMonomer =
system().mixture().nMonomer();
228 for (
int i = 0; i < nMonomer; i++) {
230 hDerivPtrs_h[i] = hDerivatives[i].
cArray();
232 hDerivPtrs = hDerivPtrs_h;
236 for (
int i = 0; i < nMonomer; i++) {
240 chiBottom_d = chiBottom_h;
249 _hFieldDerivatives<D><<<gridDims, blockDims>>>
250 (hDerivPtrs.cArray(),
system().mask().rgrid().cArray(),
256 for (
int i = 0; i < nMonomer; i++) {
287 int nMonomer =
system().mixture().nMonomer();
294 for (
int i = 0; i < nMonomer; i++) {
296 hPtrs_h[i] = hFields[i].
cArray();
302 for (
int i = 0; i < nMonomer; i++) {
306 chiBottom_d = chiBottom_h;
315 _generateHFields<D><<<gridDims, blockDims>>>
316 (hPtrs.cArray(),
system().mask().rgrid().cArray(),
317 chiBottom_d.cArray(), chiTop_d.cArray(),
normalVecId(),
321 bool isSymmetric =
system().domain().hasGroup();
327 system().h().setRGrid(hFields, isSymmetric);
336 template class FilmFieldGenExt<1,CUT>;
337 template class FilmFieldGenExt<2,CUT>;
338 template class FilmFieldGenExt<3,CUT>;
int normalVecId() const
Get value of normalVecId.
bool isAthermal() const
Are the walls athermal?
RealVec< D > normalVecCurrent_
The lattice vector normal to the film used to generate these fields.
DArray< double > chiBottomCurrent_
The chiBottom array used to generate the current external fields.
double interfaceThickness() const
Get value of interfaceThickness.
DArray< double > const & chiBottom() const
Get const chiBottom matrix by reference.
FilmFieldGenExtBase()
Constructor.
DArray< double > chiTopCurrent_
The chiTop array used to generate the current external fields.
DArray< double > const & chiTop() const
Get const chiTop array by reference.
FilmFieldGenExt()
Default constructor.
double stress(int paramId) const
Get contribution to the stress from the external fields.
RealVec< D > systemLatticeVector(int id) const
Get one of the lattice vectors for this system.
System< D, CUT > & system()
Get the System associated with this object by reference.
Base class template for classes that represent a complete system.
Data * cArray()
Return a pointer to the underlying C array (non-const data).
int capacity() const
Return allocated size.
Dynamically allocatable contiguous array template.
void allocate(int capacity)
Allocate the underlying C array.
void setClassName(const char *className)
Set class name string.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
int convertFullParamIdToReduced(const int fullId, const typename UnitCell< D >::LatticeSystem lattice)
Convert full lattice parameter index to a reduced index.
void setConfig(IntVec< D > const &meshDims, bool invert, int blockSize)
Given a multidimensional grid of threads, set execution configuration.
dim3 gridDims()
Get the multidimensional grid of blocks determined by setConfig.
dim3 meshDims()
Return last requested multidimensional grid of threads.
dim3 blockDims()
Get the dimensions of a single block determined by setConfig.
double innerProduct(Array< double > const &a, Array< double > const &b)
Compute Euclidean inner product of two real arrays .
Code for programs that simulate real-valued periodic fields.
PSCF package top-level namespace.
cufftDoubleReal cudaReal
Real number type used in CPU code that uses FFTW.