PSCF v1.3.1
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 <prdc/environment/Environment.h>
15
16namespace Pscf {
17namespace Rpc {
18
19 using namespace Util;
20
21 /*
22 * Default constructor.
23 */
24 template <int D>
26 : isSymmetric_(false),
27 isFlexible_(false),
28 sysPtr_(nullptr)
29 { setClassName("Iterator"); }
30
31 /*
32 * Constructor.
33 */
34 template <int D>
36 : isSymmetric_(false),
37 isFlexible_(false),
38 sysPtr_(&system)
39 { setClassName("Iterator"); }
40
41 /*
42 * Destructor.
43 */
44 template <int D>
47
48 /*
49 * Get the number of flexible lattice parameters.
50 */
51 template <int D>
53 {
55 system().domain().unitCell().nParameter());
56 int nFlexParams = 0;
57 for (int i = 0; i < flexibleParams_.size(); i++) {
58 if (flexibleParams_[i]) nFlexParams++;
59 }
60 return nFlexParams;
61 }
62
63 /*
64 * Set the array indicating which lattice parameters are flexible.
65 */
66 template <int D>
68 {
69 flexibleParams_ = flexParams;
70 if (nFlexibleParams() == 0) {
71 isFlexible_ = false;
72 } else {
73 isFlexible_ = true;
74 }
75 }
76
77 /*
78 * Return the stress used by this Iterator, for one lattice parameter.
79 */
80 template <int D>
81 double Iterator<D>::stress(int paramId) const
82 {
83 // Parameter must be flexible to access the stress
85
86 if (system().hasEnvironment()) {
87 return system().environment().stress(paramId);
88 } else {
89 return system().mixture().stress(paramId);
90 }
91 }
92
93} // namespace Rpc
94} // namespace Pscf
95#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.
Definition param_pc.dox:1