PSCF v1.3.3
rpc/scft/iterator/Iterator.tpp
1#ifndef RPC_ITERATOR_TPP
2#define RPC_ITERATOR_TPP
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 "Iterator.h"
12
13#include <rpc/system/System.h>
14#include <rpc/solvers/Mixture.h>
15#include <rpc/field/Domain.h>
16#include <prdc/environment/Environment.h>
17
18namespace Pscf {
19namespace Rpc {
20
21 using namespace Util;
22
23 /*
24 * Default constructor.
25 */
26 template <int D>
28 : isSymmetric_(false),
29 isFlexible_(false),
30 sysPtr_(nullptr)
31 { setClassName("Iterator"); }
32
33 /*
34 * Constructor.
35 */
36 template <int D>
38 : isSymmetric_(false),
39 isFlexible_(false),
40 sysPtr_(&system)
41 { setClassName("Iterator"); }
42
43 /*
44 * Destructor.
45 */
46 template <int D>
49
50 /*
51 * Get the number of flexible lattice parameters.
52 */
53 template <int D>
55 {
57 system().domain().unitCell().nParameter());
58 int nFlexParams = 0;
59 for (int i = 0; i < flexibleParams_.size(); i++) {
60 if (flexibleParams_[i]) nFlexParams++;
61 }
62 return nFlexParams;
63 }
64
65 /*
66 * Set the array indicating which lattice parameters are flexible.
67 */
68 template <int D>
70 {
71 flexibleParams_ = flexParams;
72 if (nFlexibleParams() == 0) {
73 isFlexible_ = false;
74 } else {
75 isFlexible_ = true;
76 }
77 }
78
79 /*
80 * Return the stress used by this Iterator, for one lattice parameter.
81 */
82 template <int D>
83 double Iterator<D>::stress(int paramId) const
84 {
85 // Parameter must be flexible to access the stress
87
88 if (system().hasEnvironment()) {
89 return system().environment().stress(paramId);
90 } else {
91 return system().mixture().stress(paramId);
92 }
93 }
94
95} // namespace Rpc
96} // namespace Pscf
97#endif
bool isSymmetric_
Does this iterator use a symmetry-adapted basis?
void setFlexibleParams(FSArray< bool, 6 > const &flexParams)
Set the array indicating which lattice parameters are flexible.
int nFlexibleParams() const
Get the number of flexible lattice parameters.
System< D > const & system() const
Get parent system by const reference.
bool isFlexible_
Are any lattice parameters flexible during iteration?
virtual double stress(int paramId) const
Return the stress used by this Iterator, for one lattice parameter.
FSArray< bool, 6 > flexibleParams_
Array of indices of the lattice parameters that are flexible.
Main class, representing a complete physical system.
A fixed capacity (static) contiguous array with a variable logical size.
Definition FSArray.h:38
void setClassName(const char *className)
Set class name string.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
Real periodic fields, SCFT and PS-FTS (CPU).
Definition param_pc.dox:2
PSCF package top-level namespace.