PSCF v1.4.0
rpc/solvers/Propagator.cpp
1/*
2* PSCF - Polymer Self-Consistent Field
3*
4* Copyright 2015 - 2025, The Regents of the University of Minnesota
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "Propagator.h"
9#include "Block.h"
10#include <prdc/cpu/RField.h>
11#include <pscf/cpu/VecOp.h>
12#include <pscf/cpu/Reduce.h>
13#include <pscf/mesh/Mesh.h>
14
15#include <rp/solvers/Propagator.tpp>
16
17namespace Pscf {
18namespace Rpc {
19
20 using namespace Util;
21
22 /*
23 * Constructor.
24 */
25 template <int D>
29
30 /*
31 * Destructor.
32 */
33 template <int D>
36
37 /*
38 * Allocate memory used by this propagator.
39 */
40 template <int D>
42 {
45
46 qFields_.allocate(ns);
47 for (int i = 0; i < ns; ++i) {
48 qFields_[i].allocate(mesh.dimensions());
49 }
50 isAllocated_ = true;
51
53 }
54
55 /*
56 * Reallocate memory used by this propagator using new ns value.
57 */
58 template <int D>
60 {
63
64 // Deallocate all memory previously used by this propagator.
65 qFields_.deallocate();
66
67 // NOTE: Variable qFields_ is a DArray< RField<D> > container.
68 // The DArray::deallocate() function calls "delete [] ptr", where
69 // ptr is a pointer to the underlying C array. The C++ delete []
70 // command calls the destructor for each RField<D> array element
71 // before deleting the parent array. The RField<D> destructor
72 // deletes the double* array that stores the field associated
73 // with each slice of the propagator. All memory is thus released.
74
75 // Allocate new memory for qFields_ using the new value of ns
76 qFields_.allocate(ns);
77 for (int i = 0; i < ns; ++i) {
78 qFields_[i].allocate(RpPropagatorT::mesh().dimensions());
79 }
80
82 }
83
84} // namespace Rpc
85} // namespace Pscf
86
87// Explicit instantiation definitions
88namespace Pscf {
89 namespace Rp {
90 template class Propagator<1, Rpc::Types<1> >;
91 template class Propagator<2, Rpc::Types<2> >;
92 template class Propagator<3, Rpc::Types<3> >;
93 }
94 namespace Rpc {
95 template class Propagator<1>;
96 template class Propagator<2>;
97 template class Propagator<3>;
98 }
99}
Description of a regular grid of points in a periodic domain.
Definition Mesh.h:61
void setIsSolved(bool isSolved)
Set the isSolved flag to true or false.
Mesh< D > const & mesh() const
virtual void allocate(int ns, const Mesh< D > &mesh)
MDE solver for one direction of one block.
DArray< typename Types< D >::RField > qFields_
Inherited non-dependent class members.
Rp::Propagator< D, Types< D > > RpPropagatorT
Direct (parent) base class.
void allocate(int ns, const Mesh< D > &mesh) override
Allocate memory used by this propagator.
void reallocate(int ns) override
Reallocate memory used by this propagator.
bool isAllocated_
Is this propagator allocated?
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
Real periodic fields, SCFT and PS-FTS (CPU).
Definition param_pc.dox:2
PSCF package top-level namespace.