PSCF v1.4.0
rpc/fts/compressor/Compressor.h
1#ifndef RPC_COMPRESSOR_H
2#define RPC_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 Rpc
16{
17
18 template <int D> class System;
19
20 using namespace Util;
21
27 template <int D>
29 {
30
31 public:
32
36 Compressor();
37
44
48 virtual ~Compressor() = default;
49
55 virtual int compress() = 0;
56
62 virtual void outputTimers(std::ostream& out) const = 0;
63
67 virtual void clearTimers() = 0;
68
72 int mdeCounter() const;
73
74 protected:
75
82
86 System<D> const & system() const;
87
92
97
98 private:
99
101 System<D>* sysPtr_;
102
103 };
104
105 // Inline member functions
106
107 /*
108 * Return parent system by const reference.
109 */
110 template <int D> inline
112 {
113 UTIL_ASSERT(sysPtr_);
114 return *sysPtr_;
115 }
116
117 /*
118 * Return parent system by non-const reference.
119 */
120 template <int D> inline
122 {
123 UTIL_ASSERT(sysPtr_);
124 return *sysPtr_;
125 }
126
127 // Non-inline Member functions
128
129 /*
130 * Default constructor.
131 */
132 template <int D>
134 : mdeCounter_(0),
135 sysPtr_(nullptr)
136 { setClassName("Compressor"); }
137
138 /*
139 * Constructor (creates association with parent system)
140 */
141 template <int D>
143 : mdeCounter_(0),
144 sysPtr_(&system)
145 { setClassName("Compressor"); }
146
147 /*
148 * Create association with the parent system.
149 */
150 template <int D>
153
154 /*
155 * Get number of times MDE has been solved.
156 */
157 template <int D>
158 inline int Compressor<D>::mdeCounter() const
159 { return mdeCounter_; }
160
161} // namespace Rpc
162} // namespace Pscf
163#endif
System< D > const & system() const
Return parent system by const reference.
virtual ~Compressor()=default
Destructor.
virtual void clearTimers()=0
Clear timers.
void setSystem(System< D > &system)
Create association with the parent System.
virtual void outputTimers(std::ostream &out) const =0
Output report of timing results to stream.
int mdeCounter_
Count how many times MDE has been solved.
virtual int compress()=0
Iterate Langrange multiplier field.
int mdeCounter() const
Get the number of times the MDE has been solved.
A complete physical system.
void setClassName(const char *className)
Set class name string.
ParamComposite()
Constructor.
File containing preprocessor macros for error handling.
#define UTIL_ASSERT(condition)
Assertion macro suitable for debugging serial or parallel code.
Definition global.h:75
Real periodic fields, SCFT and PS-FTS (CPU).
Definition param_pc.dox:2
PSCF package top-level namespace.