PSCF v1.5.0
rp/solvers/Propagator.cpp
1/*
2* PSCF - Polymer Self-Consistent Field
3*
4* Copyright 2015 - 2026, David Morse (morse012@um.edu) and co-authors
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include <rp/solvers/PropagatorBase.tpp>
9#include "Propagator_c.h"
10#include <pscf/backend/cpp/CPT.h>
11
12namespace Pscf {
13namespace Rp {
14
15 using namespace Util;
16
17 /*
18 * Constructor.
19 */
20 template <int D>
24
25 /*
26 * Destructor.
27 */
28 template <int D>
31
32 /*
33 * Allocate memory used by this propagator.
34 */
35 template <int D>
37 {
40
41 qFields_.allocate(ns);
42 for (int i = 0; i < ns; ++i) {
43 qFields_[i].allocate(mesh.dimensions());
44 }
45 isAllocated_ = true;
46
48 }
49
50 /*
51 * Reallocate memory used by this propagator using new ns value.
52 */
53 template <int D>
55 {
58
59 // Deallocate all memory previously used by this propagator.
60 qFields_.deallocate();
61
62 // NOTE: Variable qFields_ is a DArray< RField<D,CPT> > container.
63 // The DArray::deallocate() function calls "delete [] ptr", where
64 // ptr is a pointer to the underlying C array. The C++ delete []
65 // command calls the destructor for each RField<D,CPT> array element
66 // before deleting the parent array. The RField<D,CPT> destructor
67 // deletes the double* array that stores the field associated with
68 // each slice of the propagator. All memory is thereby properly
69 // released.
70
71 // Allocate new memory for qFields_ using the new value of ns
72 qFields_.allocate(ns);
73 for (int i = 0; i < ns; ++i) {
74 qFields_[i].allocate(PropagatorBaseT::mesh().dimensions());
75 }
76
78 }
79
80} // namespace Rp
81} // namespace Pscf
82
83// Explicit instantiation definitions
84namespace Pscf {
85 namespace Rp {
86 template class PropagatorBase<1,CPT>;
87 template class PropagatorBase<2,CPT>;
88 template class PropagatorBase<3,CPT>;
89 template class Propagator<1,CPT>;
90 template class Propagator<2,CPT>;
91 template class Propagator<3,CPT>;
92 }
93}
Description of a regular grid of points in a periodic domain.
Definition Mesh.h:61
IntVec< D > dimensions() const
Get an IntVec<D> of the grid dimensions.
Definition Mesh.h:217
void setIsSolved(bool isSolved)
Set the isSolved flag to true or false.
virtual void reallocate(int ns)
Mesh< D > const & mesh() const
virtual void allocate(int ns, const Mesh< D > &mesh)
DArray< RField< D, CPT > > qFields_
Inherited non-dependent class members.
PropagatorBase< D, CPT > PropagatorBaseT
Direct (parent) base class.
bool isAllocated_
Is this propagator allocated?
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
Code for programs that simulate real-valued periodic fields.
Definition param_pc.dox:2
PSCF package top-level namespace.