PSCF v1.3
rpg/solvers/Mixture.tpp
1#ifndef RPG_MIXTURE_TPP
2#define RPG_MIXTURE_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 "Mixture.h"
12#include <rpg/field/FieldIo.h>
13#include <prdc/solvers/MixtureReal.tpp>
14#include <prdc/cuda/FFT.h>
15#include <prdc/cuda/RField.h>
16
17namespace Pscf {
18namespace Rpg {
19
20 using namespace Prdc;
21 using namespace Prdc::Cuda;
22
23 /*
24 * Constructor
25 */
26 template <int D>
28 : MixtureRealT(),
29 useBatchedFFT_(true)
30 {}
31
32 /*
33 * Read all parameters and initialize.
34 */
35 template <int D>
36 void Mixture<D>::readParameters(std::istream& in)
37 {
38 MixtureRealT::readParameters(in);
39
40 // Optionally read useBatchedFFT boolean
41 useBatchedFFT_ = true;
42 ParamComposite::readOptional(in, "useBatchedFFT", useBatchedFFT_);
43 }
44
45 /*
46 * Set all elements of a field to a single scalar: A[i] = c.
47 */
48 template <int D>
49 void Mixture<D>::eqS(FieldT& A, double c) const
50 {
51 const int nx = mesh().size();
52 UTIL_CHECK(nx == A.capacity());
53 VecOp::eqS(A,c);
54 }
55
56 /*
57 * Compound addition-assignment of two fields: A[i] += B[i]
58 */
59 template <int D>
60 void Mixture<D>::addEqV(FieldT& A, FieldT const & B) const
61 {
62 const int nx = mesh().size();
63 UTIL_CHECK(nx == A.capacity());
64 UTIL_CHECK(nx == B.capacity());
65 VecOp::addEqV(A, B);
66 }
67
68 /*
69 * Allocate memory for all blocks.
70 */
71 template <int D>
72 void Mixture<D>::allocateBlocks()
73 {
74 int i, j;
75 for (i = 0; i < nPolymer(); ++i) {
76 for (j = 0; j < polymer(i).nBlock(); ++j) {
77 polymer(i).block(j).allocate(ds(), useBatchedFFT_);
78 }
79 }
80 }
81
82} // namespace Rpg
83} // namespace Pscf
84#endif
void readParameters(std::istream &in) override
Read all parameters and initialize.
typename Prdc::MixtureReal< D, Polymer< D >, Solvent< D > > MixtureRealT
Direct (parent) base class.
ScalarParam< Type > & readOptional(std::istream &in, const char *label, Type &value)
Add and read a new optional ScalarParam < Type > object.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
void addEqV(DeviceArray< cudaReal > &a, DeviceArray< cudaReal > const &b, const int beginIdA, const int beginIdB, const int n)
Vector addition in-place, a[i] += b[i], kernel wrapper (cudaReal).
Definition VecOp.cu:1672
void eqS(DeviceArray< cudaReal > &a, const cudaReal b, const int beginIdA, const int n)
Vector assignment, a[i] = b, kernel wrapper (cudaReal).
Definition VecOp.cu:1073
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