PSCF v1.4.0
cpc/solvers/Mixture.tpp
1#ifndef CPC_MIXTURE_TPP
2#define CPC_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 "Polymer.h"
13#include "Solvent.h"
14#include "Block.h"
15#include "Propagator.h"
16#include <cpc/field/FieldIo.h>
17#include <prdc/cpu/FFT.h>
18#include <prdc/cpu/RField.h>
19#include <pscf/cpu/complex.h>
20
21#include <cp/solvers/Mixture.tpp>
22
23namespace Pscf {
24namespace Cpc {
25
26 using namespace Util;
27 using namespace Prdc;
28
29 template <int D>
30 void Mixture<D>::eqS(FieldT& A, double c) const
31 {
32 const int nx = mesh().size();
33 UTIL_CHECK(nx == A.capacity());
34 for (int i = 0; i < nx; ++i) {
35 assign(A[i], c);
36 }
37 }
38
39 template <int D>
40 void Mixture<D>::addEqV(FieldT& A, FieldT const & B) const
41 {
42 const int nx = mesh().size();
43 UTIL_CHECK(nx == A.capacity());
44 UTIL_CHECK(nx == B.capacity());
45 for (int i = 0; i < nx; ++i) {
46 assign(A[i], B[i]);
47 }
48 }
49
50 /*
51 * Allocate memory for all blocks.
52 */
53 template <int D>
54 void Mixture<D>::allocateBlocks()
55 {
56 int i, j;
57 for (i = 0; i < nPolymer(); ++i) {
58 for (j = 0; j < polymer(i).nBlock(); ++j) {
59 polymer(i).block(j).allocate(ds());
60 }
61 }
62 }
63
64} // namespace Cpc
65} // namespace Pscf
66#endif
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
void assign(fftw_complex &z, double const &a, double const &b)
Create an fftw_complex from real and imaginary parts, z = a + ib.
Complex periodic fields, CL-FTS (CPU).
Definition cpc.mod:6
Periodic fields and crystallography.
Definition complex.cpp:11
PSCF package top-level namespace.