1#ifndef PSPG_K_FIELD_COMPARISON_TPP
2#define PSPG_K_FIELD_COMPARISON_TPP
11#include "KFieldComparison.h"
33 cudaComplex* temp_a =
new cudaComplex[nPoints];
34 cudaComplex* temp_b =
new cudaComplex[nPoints];
35 cudaMemcpy(temp_a, a.
cDField(), nPoints*
sizeof(cudaComplex), cudaMemcpyDeviceToHost);
36 cudaMemcpy(temp_b, b.
cDField(), nPoints*
sizeof(cudaComplex), cudaMemcpyDeviceToHost);
38 double diffSq, diff, d0, d1;
41 for (
int i = 0; i < nPoints; ++i) {
42 d0 = temp_a[i].x - temp_b[i].x;
43 d1 = temp_a[i].y - temp_b[i].y;
44 diffSq = d0*d0 + d1*d1;
46 if (diff > maxDiff_) {
51 rmsDiff_ = rmsDiff_/double(nPoints);
52 rmsDiff_ = sqrt(rmsDiff_);
70 int nPoints = a[0].capacity();
73 for (
int i = 0; i < nFields; i++) {
74 temp_a[i] =
new cudaComplex[nPoints];
75 temp_b[i] =
new cudaComplex[nPoints];
76 cudaMemcpy(temp_a[i], a[i].cDField(), nPoints*
sizeof(cudaComplex), cudaMemcpyDeviceToHost);
77 cudaMemcpy(temp_b[i], b[i].cDField(), nPoints*
sizeof(cudaComplex), cudaMemcpyDeviceToHost);
80 double diffSq, diff, d0, d1;
84 for (i = 0; i < nFields; ++i) {
85 for (j = 0; j < nPoints; ++j) {
86 d0 = temp_a[i][j].x - temp_b[i][j].x;
87 d1 = temp_a[i][j].y - temp_b[i][j].y;
88 diffSq = d0*d0 + d1*d1;
90 if (diff > maxDiff_) {
96 rmsDiff_ = rmsDiff_/double(nFields*nPoints);
97 rmsDiff_ = sqrt(rmsDiff_);
Data * cDField()
Return pointer to underlying C array.
int capacity() const
Return allocated size.
KFieldComparison()
Default constructor.
double compare(RDFieldDft< D > const &a, RDFieldDft< D > const &b)
Compare individual fields.
Discrete Fourier Transform (DFT) of a real field on an FFT mesh.
int capacity() const
Return allocated size.
Dynamically allocatable contiguous array template.
void allocate(int capacity)
Allocate the underlying C array.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
C++ namespace for polymer self-consistent field theory (PSCF).