PSCF v1.4.0
rpc/solvers/Block.h
1#ifndef RPC_BLOCK_H
2#define RPC_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/RField.h> // member
14#include <prdc/cpu/RFieldDft.h> // member
15#include <util/containers/FSArray.h> // member
16
17// Forward declarations
18namespace Pscf {
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 Rpc{
28 template <int D> class Propagator;
29 }
30}
31
32namespace Pscf {
33namespace Rpc {
34
35 using namespace Util;
36 using namespace Pscf::Prdc;
37 using namespace Pscf::Prdc::Cpu;
38
48 template <int D>
49 class Block : public BlockTmpl< Propagator<D>, RField<D> >
50 {
51
52 public:
53
54 // Public type name aliases
55
58
60 using typename BlockTmplT::PropagatorT;
61
63 using typename BlockTmplT::FieldT;
64
65 // Public member functions
66
70 Block();
71
75 ~Block();
76
79
92 void associate(Mesh<D> const& mesh,
93 FFT<D> const& fft,
94 UnitCell<D> const& cell,
95 WaveList<D>& waveList);
96
122 void allocate(double ds);
123
132 void clearUnitCellData();
133
142 void setLength(double newLength);
143
149 void setKuhn(double kuhn);
150
160 void setupSolver(RField<D> const & w);
161
165
177 void stepThread(RField<D> const & qin, RField<D>& qout) const;
178
190 void stepBead(RField<D> const & qin, RField<D>& qout) const;
191
200 void stepFieldBead(RField<D> & q) const;
201
212 void stepBondBead(RField<D> const & qin, RField<D>& qout) const;
213
225 void stepHalfBondBead(RField<D> const & qin, RField<D>& qout) const;
226
230
255 void computeConcentrationThread(double prefactor);
256
280 void computeConcentrationBead(double prefactor);
281
285
295 void computeStressThread(double prefactor);
296
306 void computeStressBead(double prefactor);
307
316 double stress(int n) const;
317
321
325 double ds() const;
326
340 int ns() const;
341
342 // Inherited inherited functions with non-dependent names (selected)
344 using BlockTmplT::cField;
345
346 private:
347
348 // Private member data
349
351 FSArray<double, 6> stress_;
352
354 RField<D> expKsq_;
355
357 RField<D> expW_;
358
360 RField<D> expKsq2_;
361
363 RField<D> expW2_;
364
366 RField<D> expWInv_;
367
369 mutable RField<D> qr_;
370
372 mutable RField<D> qr2_;
373
375 mutable RFieldDft<D> qk_;
376
378 mutable RFieldDft<D> qk2_;
379
381 Mesh<D> const * meshPtr_;
382
384 FFT<D> const * fftPtr_;
385
387 UnitCell<D> const * unitCellPtr_;
388
390 WaveList<D> * waveListPtr_;
391
393 IntVec<D> kMeshDimensions_;
394
396 int kSize_;
397
399 // In bead model, ds=1 by definition.
400 double ds_;
401
403 double dsTarget_;
404
406 int ns_;
407
409 int nParams_;
410
412 bool isAllocated_;
413
415 bool hasExpKsq_;
416
417 // Private member functions
418
420 Mesh<D> const & mesh() const;
421
423 FFT<D> const & fft() const;
424
426 UnitCell<D> const & unitCell() const;
427
429 WaveList<D> & waveList();
430
434 void computeExpKsq();
435
436 };
437
438 // Inline member functions
439
440 // Get number of contour grid points, including end points.
441 template <int D>
442 inline int Block<D>::ns() const
443 { return ns_; }
444
445 // Get contour step size.
446 template <int D>
447 inline double Block<D>::ds() const
448 { return ds_; }
449
450 // Stress with respect to unit cell parameter n.
451 template <int D>
452 inline double Block<D>::stress(int n) const
453 { return stress_[n]; }
454
455 // Private inline member function definitions
456
457 // Get associated Mesh<D> object by const reference (private).
458 template <int D>
459 inline Mesh<D> const & Block<D>::mesh() const
460 {
461 UTIL_CHECK(meshPtr_);
462 return *meshPtr_;
463 }
464
465 // Get associated FFT<D> object by const reference (private).
466 template <int D>
467 inline FFT<D> const & Block<D>::fft() const
468 {
469 UTIL_CHECK(fftPtr_);
470 return * fftPtr_;
471 }
472
473 // Get associated UnitCell<D> by const reference (private).
474 template <int D>
475 UnitCell<D> const & Block<D>::unitCell() const
476 {
477 UTIL_CHECK(unitCellPtr_);
478 return *unitCellPtr_;
479 }
480
481 // Get associated WaveList<D> by reference (private).
482 template <int D>
483 WaveList<D>& Block<D>::waveList()
484 {
485 UTIL_CHECK(waveListPtr_);
486 return *waveListPtr_;
487 }
488
489} // namespace R1d
490} // namespace Pscf
491
492// Explicit instantiation declarations
493namespace Pscf {
494
495 extern template
497 extern template
499 extern template
501
502 namespace Rpc {
503 extern template class Block<1>;
504 extern template class Block<2>;
505 extern template class Block<3>;
506 }
507
508}
509#endif
Class template for a block solver in a block copolymer.
Definition BlockTmpl.h:107
Propagator< D > & propagator(int directionId)
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
Description of a regular grid of points in a periodic domain.
Definition Mesh.h:61
Fourier transform wrapper.
Definition cpu/FFT.h:39
Fourier transform of a real field on an FFT mesh.
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
Block within a linear or branched block polymer.
void stepBondBead(RField< D > const &qin, RField< D > &qout) const
Apply a bond operator for the bead model.
void setLength(double newLength)
Set or reset block length (only used in thread model).
void computeConcentrationBead(double prefactor)
Compute the concentration for this block, using the bead model.
double stress(int n) const
Get derivative of free energy w/ respect to a unit cell parameter.
void setKuhn(double kuhn)
Set or reset monomer statistical segment length.
void clearUnitCellData()
Clear all internal data that depends on the unit cell parameters.
void setupSolver(RField< D > const &w)
Set up the MDE solver for this block.
void allocate(double ds)
Allocate memory and set contour step size.
void computeStressBead(double prefactor)
Compute stress contribution for this block, using bead model.
void associate(Mesh< D > const &mesh, FFT< D > const &fft, UnitCell< D > const &cell, WaveList< D > &waveList)
Create permanent associations with related objects.
void computeConcentrationThread(double prefactor)
Compute the concentration for this block, for the thread model.
void stepThread(RField< D > const &qin, RField< D > &qout) const
Compute one step of solution of MDE for the thread model.
void computeStressThread(double prefactor)
Compute stress contribution for this block, using thread model.
double ds() const
Get contour length step size.
int ns() const
Get the number of contour grid points, including end points.
void stepFieldBead(RField< D > &q) const
Apply the exponential field operator for the bead model.
void stepHalfBondBead(RField< D > const &qin, RField< D > &qout) const
Apply a half-bond operator for the bead model.
void stepBead(RField< D > const &qin, RField< D > &qout) const
Compute one step of solution of MDE for the bead model.
BlockTmpl< Propagator< D >, RField< D > > BlockTmplT
Direct (parent) base class.
MDE solver for one direction of one block.
A fixed capacity (static) contiguous array with a variable logical size.
Definition FSArray.h:38
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
Fields and FFTs for periodic boundary conditions (CPU)
Definition complex.cpp:12
Periodic fields and crystallography.
Definition complex.cpp:11
Real periodic fields, SCFT and PS-FTS (CPU).
Definition param_pc.dox:2
PSCF package top-level namespace.