PSCF v1.4.0
rpg/fts/compressor/Compressor.h
1#ifndef RPG_COMPRESSOR_H
2#define RPG_COMPRESSOR_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 <util/param/ParamComposite.h> // base class
12#include <util/global.h>
13
14namespace Pscf {
15namespace Rpg {
16
17 template <int D> class System;
18
19 using namespace Util;
20
26 template <int D>
28 {
29
30 public:
31
35 Compressor();
36
43
47 virtual ~Compressor() = default;
48
54 virtual int compress() = 0;
55
59 int mdeCounter() const;
60
66 virtual void outputTimers(std::ostream& out) const = 0;
67
71 virtual void clearTimers() = 0;
72
73 protected:
74
79
86
90 System<D> const & system() const;
91
96
97 private:
98
100 System<D>* sysPtr_;
101
102 };
103
104 // Inline member functions
105
106 /*
107 * Return parent system by const reference.
108 */
109 template <int D> inline
111 {
112 UTIL_ASSERT(sysPtr_);
113 return *sysPtr_;
114 }
115
116 /*
117 * Return parent system by non-const reference.
118 */
119 template <int D> inline
121 {
122 UTIL_ASSERT(sysPtr_);
123 return *sysPtr_;
124 }
125
126 // Non-inline member functions
127
128 /*
129 * Default constructor.
130 */
131 template <int D>
133 : mdeCounter_(0),
134 sysPtr_(nullptr)
135 { setClassName("Compressor"); }
136
137 /*
138 * Constructor.
139 */
140 template <int D>
142 : mdeCounter_(0),
143 sysPtr_(&system)
144 { setClassName("Compressor"); }
145
146 /*
147 * Get number of times MDE has been solved.
148 */
149 template <int D>
151 { return mdeCounter_; }
152
153 // Protected function
154
155 /*
156 * Create association with the parent system.
157 */
158 template <int D>
160 {
161 UTIL_CHECK(!sysPtr_);
162 sysPtr_ = &system;
163 }
164
165} // namespace Rpg
166} // namespace Pscf
167#endif
int mdeCounter_
Count how many times MDE has been solved.
void setSystem(System< D > &system)
Create association with the parent System.
virtual ~Compressor()=default
Destructor.
int mdeCounter() const
Get the number of times the MDE has been solved.
virtual int compress()=0
Iterate Langrange multiplier field.
System< D > const & system() const
Return parent system by const reference.
virtual void outputTimers(std::ostream &out) const =0
Log output timing results.
virtual void clearTimers()=0
Clear timers.
Main class, representing a complete physical system.
void setClassName(const char *className)
Set class name string.
ParamComposite()
Constructor.
File containing preprocessor macros for error handling.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
#define UTIL_ASSERT(condition)
Assertion macro suitable for debugging serial or parallel code.
Definition global.h:75
SCFT and PS-FTS with real periodic fields (GPU)
PSCF package top-level namespace.