PSCF v1.4.0
cpc/solvers/Block.h
1#ifndef CPC_BLOCK_H
2#define CPC_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 <prdc/cpu/CField.h> // members
14#include <prdc/cpu/RField.h> // member
15
16namespace Pscf {
17
18 // Forward declarations
19 template <int D> class Mesh;
20 namespace Prdc{
21 template <int D> class UnitCell;
22 namespace Cpu {
23 template <int D> class FFT;
24 template <int D> class WaveList;
25 }
26 }
27 namespace Cpc{
28 template <int D> class Propagator;
29 }
30
31 // Explicit instantiation declarations for base class
32 extern template
34 extern template
36 extern template
38
39}
40
41namespace Pscf {
42namespace Cpc {
43
44 using namespace Util;
45 using namespace Pscf::Prdc;
46 using namespace Pscf::Prdc::Cpu;
47
57 template <int D>
58 class Block : public BlockTmpl< Propagator<D>, CField<D> >
59 {
60
61 public:
62
63 // Public type name aliases
64
67
69 using typename Base::PropagatorT;
70
72 using typename Base::FieldT;
73
74 // Public member functions
75
79 Block();
80
84 ~Block();
85
98 void associate(Mesh<D> const& mesh,
99 FFT<D> const& fft,
100 UnitCell<D> const& cell,
101 WaveList<D>& wavelist);
102
128 void allocate(double ds);
129
138 void clearUnitCellData();
139
148 void setLength(double newLength);
149
155 void setKuhn(double kuhn);
156
166 void setupSolver(CField<D> const & w);
167
179 void stepThread(CField<D> const & qin, CField<D>& qout) const;
180
190 void stepBead(CField<D> const & qin, CField<D>& qout) const;
191
200 void stepFieldBead(CField<D> & q) const;
201
212 void stepBondBead(CField<D> const & qin, CField<D>& qout) const;
213
225 void stepHalfBondBead(CField<D> const & qin, CField<D>& qout) const;
226
251 void computeConcentrationThread(fftw_complex const & prefactor);
252
276 void computeConcentrationBead(fftw_complex const & prefactor);
277
281 double ds() const;
282
296 int ns() const;
297
298 // Inherited public member functions with non-dependent names
299
300 using Base::setKuhn;
301 using Base::propagator;
302 using Base::cField;
303 using Base::kuhn;
304
305 using Edge::setId;
306 using Edge::setVertexIds;
307 using Edge::setMonomerId;
308 using Edge::setLength;
309 using Edge::id;
310 using Edge::monomerId;
311 using Edge::vertexIds;
312 using Edge::vertexId;
313 using Edge::length;
314 using Edge::nBead;
315
316 private:
317
318 // Private member data
319
320 // In bead model, ds=1 by definition.
321
323 RField<D> expKsq_;
324
326 RField<D> expKsq2_;
327
329 CField<D> expW_;
330
332 CField<D> expW2_;
333
335 CField<D> expWInv_;
336
338 mutable CField<D> qr_;
339
341 mutable CField<D> qr2_;
342
344 mutable CField<D> qk_;
345
347 mutable CField<D> qk2_;
348
350 Mesh<D> const * meshPtr_;
351
353 FFT<D> const * fftPtr_;
354
356 UnitCell<D> const * unitCellPtr_;
357
359 WaveList<D> * waveListPtr_;
360
362 double ds_;
363
365 double dsTarget_;
366
368 int ns_;
369
371 bool isAllocated_;
372
374 bool hasExpKsq_;
375
377 int nParams_;
378
379 // Private member functions
380
384 Mesh<D> const & mesh() const;
385
389 UnitCell<D> const & unitCell() const;
390
394 FFT<D> const & fft() const;
395
399 WaveList<D> const & wavelist() const;
400
404 void computeExpKsq();
405
406 };
407
408 // Public inline member functions
409
410 // Get number of contour grid points, including end points.
411 template <int D>
412 inline int Block<D>::ns() const
413 { return ns_; }
414
415 // Get contour step size.
416 template <int D>
417 inline double Block<D>::ds() const
418 { return ds_; }
419
420 // Private inline member functions
421
422 // Get associated Mesh<D> by const reference.
423 template <int D> inline
424 Mesh<D> const & Block<D>::mesh() const
425 {
426 UTIL_CHECK(meshPtr_);
427 return *meshPtr_;
428 }
429
430 // Get associated UnitCell<D> as const reference.
431 template <int D> inline
432 UnitCell<D> const & Block<D>::unitCell() const
433 { return *unitCellPtr_; }
434
435 // Get associated FFT<D> by const reference.
436 template <int D> inline
437 FFT<D> const & Block<D>::fft() const
438 {
439 UTIL_CHECK(fftPtr_);
440 return * fftPtr_;
441 }
442
443 // Get associated WaveList<D> by const reference.
444 template <int D> inline
445 WaveList<D> const & Block<D>::wavelist() const
446 { return *waveListPtr_; }
447
448 // Explicit instantiation declarations
449 extern template class Block<1>;
450 extern template class Block<2>;
451 extern template class Block<3>;
452
453} // Cpc
454} // Pscf
455#endif
Class template for a block solver in a block copolymer.
Definition BlockTmpl.h:107
Propagator< D > & propagator(int directionId)
Block within a linear or branched block polymer.
BlockTmpl< Propagator< D >, CField< D > > Base
Base class.
void clearUnitCellData()
Clear all internal data that depends on the unit cell parameters.
void stepFieldBead(CField< D > &q) const
Apply the exponential field operator for the bead model.
void computeConcentrationThread(fftw_complex const &prefactor)
Compute the concentration for this block, for the thread model.
int ns() const
Get the number of contour grid points, including end points.
void computeConcentrationBead(fftw_complex const &prefactor)
Compute the concentration for this block, using the bead model.
void allocate(double ds)
Allocate memory and set number of counter steps.
void stepBead(CField< D > const &qin, CField< D > &qout) const
Compute one step of solution of MDE for the bead model.
void stepHalfBondBead(CField< D > const &qin, CField< D > &qout) const
Apply a half-bond operator for the bead model.
void setLength(double newLength)
Set or reset block length (only used in thread model).
double ds() const
Get contour length step size.
void stepBondBead(CField< D > const &qin, CField< D > &qout) const
Apply a bond operator for the bead model.
void setKuhn(double kuhn)
Set or reset monomer statistical segment length.
void stepThread(CField< D > const &qin, CField< D > &qout) const
Compute one step of solution of MDE for the thread model.
double kuhn() const
Get monomer statistical segment length.
void associate(Mesh< D > const &mesh, FFT< D > const &fft, UnitCell< D > const &cell, WaveList< D > &wavelist)
Create permanent associations with related objects.
void setupSolver(CField< D > const &w)
Set up the MDE solver for this block.
MDE solver for one direction of one block.
int id() const
Get the id of this block (unique within the polymer).
Definition Edge.h:278
void setVertexIds(int vertexId0, int vertexId1)
Set indices of associated vertices.
Definition Edge.cpp:44
const Pair< int > & vertexIds() const
Get the pair of associated vertex ids.
Definition Edge.h:290
int nBead() const
Get the number of beads in this block, in the bead model.
Definition Edge.h:302
virtual void setLength(double length)
Set the length of this block (only valid for thread model).
Definition Edge.cpp:62
int monomerId() const
Get the monomer type id for this block.
Definition Edge.h:284
int vertexId(int i) const
Get the id of one associated vertex.
Definition Edge.h:296
void setMonomerId(int monomerId)
Set the monomer type id.
Definition Edge.cpp:38
void setId(int id)
Set the id for this block.
Definition Edge.cpp:32
double length() const
Get the length of this block, in the thread model.
Definition Edge.h:311
Description of a regular grid of points in a periodic domain.
Definition Mesh.h:61
Field of complex double precision values on an FFT mesh.
Definition cpu/CField.h:29
Fourier transform wrapper.
Definition cpu/FFT.h:39
Field of real double precision values on an FFT mesh.
Definition cpu/RField.h:27
Class to compute and store properties associated with wavevectors.
Base template for UnitCell<D> classes, D=1, 2 or 3.
Definition UnitCell.h:56
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
Complex periodic fields, CL-FTS (CPU).
Definition cpc.mod:6
Fields and FFTs for periodic boundary conditions (CPU)
Definition complex.cpp:12
Periodic fields and crystallography.
Definition complex.cpp:11
PSCF package top-level namespace.