PSCF v1.3.3
r1d/solvers/Block.h
1#ifndef R1D_BLOCK_H
2#define R1D_BLOCK_H
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 <pscf/solvers/BlockTmpl.h> // base class template
12
13#include <pscf/math/TridiagonalSolver.h> // member
14#include <util/containers/DArray.h> // member
15
16namespace Pscf {
17namespace R1d {
18
19 // Forward declarations
20 class Domain;
21 class Propagator;
22
23 using namespace Util;
24
34 class Block : public BlockTmpl<Propagator, DArray<double> >
35 {
36
37 public:
38
42 Block();
43
47 ~Block();
48
55 void setDiscretization(Domain const & domain, double ds);
56
62 virtual void setLength(double newLength);
63
69 void setupSolver(DArray<double> const & w);
70
83 void computeConcentration(double prefactor);
84
91 void step(DArray<double> const & q, DArray<double>& qNew);
92
96 Domain const & domain() const;
97
101 int ns() const;
102
103 private:
104
106 TridiagonalSolver solver_;
107
108 // Arrays dA_, uA_, lB_ dB_, uB_, luB_ contain elements of the
109 // the tridiagonal matrices A and B used in propagation from
110 // step i to i + 1, which requires solution of a linear system
111 // of the form: A q(i+1) = B q(i).
112
114 DArray<double> dA_;
115
117 DArray<double> uA_;
118
120 DArray<double> lA_;
121
123 DArray<double> dB_;
124
126 DArray<double> uB_;
127
129 DArray<double> lB_;
130
133
135 Domain const * domainPtr_;
136
138 double ds_;
139
140 // Contour length step size (value input in param file).
141 double dsTarget_;
142
144 int ns_;
145
146 };
147
148 // Inline member functions
149
151 inline Domain const & Block::domain() const
152 {
153 UTIL_ASSERT(domainPtr_);
154 return *domainPtr_;
155 }
156
158 inline int Block::ns() const
159 { return ns_; }
160
161} // namespace R1d
162} // namespace Pscf
163
164// Explicit instantiation declaration for base class
165namespace Pscf {
166 extern template
167 class BlockTmpl<R1d::Propagator, Util::DArray<double> >;
168}
169#endif
virtual void setLength(double newLength)
Set length and readjust ds_ accordingly.
Domain const & domain() const
Return associated domain by reference.
void setupSolver(DArray< double > const &w)
Set Crank-Nicholson solver for this block.
void step(DArray< double > const &q, DArray< double > &qNew)
Compute one step of integration loop, from i to i+1.
int ns() const
Number of contour length steps.
void computeConcentration(double prefactor)
Compute concentration for block by integration.
void setDiscretization(Domain const &domain, double ds)
Initialize discretization and allocate required memory.
One-dimensional spatial domain and discretization grid.
MDE solver for one-direction of one block.
Solver for Ax=b with tridiagonal matrix A.
Dynamically allocatable contiguous array template.
Definition DArray.h:32
#define UTIL_ASSERT(condition)
Assertion macro suitable for debugging serial or parallel code.
Definition global.h:75
SCFT with real 1D fields.
PSCF package top-level namespace.