PSCF v1.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 "Propagator.h" // base class argument
12#include <pscf/solvers/BlockTmpl.h> // base class template
13#include <pscf/math/TridiagonalSolver.h> // member
14
15namespace Pscf {
16namespace R1d
17{
18
19 class Domain;
20 using namespace Util;
21
30 class Block : public BlockTmpl<Propagator>
31 {
32
33 public:
34
38 Block();
39
43 ~Block();
44
51 void setDiscretization(Domain const & domain, double ds);
52
58 virtual void setLength(double newLength);
59
65 void setupSolver(DArray<double> const & w);
66
79 void computeConcentration(double prefactor);
80
87 void step(DArray<double> const & q, DArray<double>& qNew);
88
92 Domain const & domain() const;
93
97 int ns() const;
98
99 private:
100
102 TridiagonalSolver solver_;
103
104 // Arrays dA_, uA_, lB_ dB_, uB_, luB_ contain elements of the
105 // the tridiagonal matrices A and B used in propagation from
106 // step i to i + 1, which requires solution of a linear system
107 // of the form: A q(i+1) = B q(i).
108
110 DArray<double> dA_;
111
113 DArray<double> uA_;
114
116 DArray<double> lA_;
117
119 DArray<double> dB_;
120
122 DArray<double> uB_;
123
125 DArray<double> lB_;
126
129
131 Domain const * domainPtr_;
132
134 double ds_;
135
136 // Contour length step size (value input in param file).
137 double dsTarget_;
138
140 int ns_;
141
142 };
143
144 // Inline member functions
145
147 inline Domain const & Block::domain() const
148 {
149 UTIL_ASSERT(domainPtr_);
150 return *domainPtr_;
151 }
152
154 inline int Block::ns() const
155 { return ns_; }
156
157}
158}
159#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.
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.
Definition param_pc.dox:1