PSCF v1.4.0
StepLogger.tpp
1#ifndef RP_STEP_LOGGER_TPP
2#define RP_STEP_LOGGER_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 <util/format/Int.h>
12#include <util/misc/Log.h>
13
14namespace Pscf {
15namespace Rp {
16
17 using namespace Util;
18
19 /*
20 * Constructor.
21 */
22 template <int D, class T>
23 StepLogger<D,T>::StepLogger(typename T::Simulator& simulator,
24 typename T::System& system)
25 : AnalyzerT(simulator, system)
26 { ParamComposite::setClassName("StepLogger"); }
27
28 /*
29 * Read interval.
30 */
31 template <int D, class T>
32 void StepLogger<D,T>::readParameters(std::istream& in)
33 { AnalyzerT::readInterval(in); }
34
35 /*
36 * Periodically write the step index to a log file.
37 */
38 template <int D, class T>
39 void StepLogger<D,T>::sample(long iStep)
40 {
41 if (AnalyzerT::isAtInterval(iStep)) {
42 Log::file() << "iStep " << Int(iStep,10) << std::endl;
43 }
44 }
46}
47}
48#endif
void readParameters(std::istream &in) override
Read interval.
void sample(long iStep) override
Write the step index to a log file.
StepLogger(typename T::Simulator &simulator, typename T::System &system)
Constructor.
Wrapper for an int, for formatted ostream output.
Definition Int.h:37
static std::ostream & file()
Get log ostream by reference.
Definition Log.cpp:59
void setClassName(const char *className)
Set class name string.
Class templates for real-valued periodic fields.
PSCF package top-level namespace.