PSCF v1.2
r1d/misc/FieldIo.h
1#ifndef R1D_FIELD_IO_H
2#define R1D_FIELD_IO_H
3
4/*
5* PSCF - Polymer Self-Consistent Field Theory
6*
7* Copyright 2016 - 2022, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <util/containers/DArray.h> // member
12
13namespace Util { class FileMaster; }
14
15namespace Pscf {
16namespace R1d {
17
18 class Domain;
19 class Mixture;
20 using namespace Util;
21
27 class FieldIo
28 {
29
30 public:
31
32 typedef DArray<double> Field;
33
37 FieldIo();
38
42 ~FieldIo();
43
50 void associate(Domain const & domain,
51 FileMaster const & fileMaster);
52
61 void readFields(DArray<Field>& fields, std::istream &in);
62
73 void readFields(DArray<Field>& fields, std::string const& filename);
74
84 void writeField(Field const& field, std::ostream& out,
85 bool writeHeader = true) const;
86
98 void writeField(Field const& field, std::string const& filename,
99 bool writeHeader= true) const;
100
110 void writeFields(DArray<Field> const& fields, std::ostream& out,
111 bool writeHeader= true) const;
112
124 void writeFields(DArray<Field> const& fields,
125 std::string const& filename,
126 bool writeHeader= true) const;
127
136 void writeBlockCFields(Mixture const& mixture, std::ostream& out) const;
137
149 void writeBlockCFields(Mixture const& mixture,
150 std::string const& filename) const;
151
162 void writeVertexQ(Mixture const& mixture,
163 int polymerId, int vertexId,
164 std::ostream& out) const;
165
174 void writeVertexQ(Mixture const& mixture,
175 int polymerId, int vertexId,
176 std::string const& filename) const;
177
185 void remesh(DArray<Field> const& fields, int nx, std::ostream& out);
186
194 void remesh(DArray<Field> const& fields, int nx,
195 std::string const& filename);
196
207 void extend(DArray<Field> const& fields, int m, std::ostream& out);
208
219 void extend(DArray<Field> const& fields, int m,
220 std::string const& filename);
221
222 private:
223
225 mutable DArray<double> w_;
226
227 // Pointers to associated objects.
228
230 Domain const * domainPtr_;
231
233 FileMaster const * fileMasterPtr_;
234
235 // Private accessor functions:
236
238 Domain const& domain() const
239 {
240 UTIL_ASSERT(domainPtr_);
241 return *domainPtr_;
242 }
243
245 FileMaster const & fileMaster() const
246 {
247 UTIL_ASSERT(fileMasterPtr_);
248 return *fileMasterPtr_;
249 }
250
251 };
252
253
254} // namespace R1d
255} // namespace Pscf
256#endif
One-dimensional spatial domain and discretization grid.
Read and write fields to file.
void extend(DArray< Field > const &fields, int m, std::ostream &out)
Add points to the end of a field mesh and write to stream.
void writeField(Field const &field, std::ostream &out, bool writeHeader=true) const
Write a single field to an output stream.
void writeVertexQ(Mixture const &mixture, int polymerId, int vertexId, std::ostream &out) const
Write product of incoming q fields for one vertex to stream.
void associate(Domain const &domain, FileMaster const &fileMaster)
Get and store addresses of associated objects.
void remesh(DArray< Field > const &fields, int nx, std::ostream &out)
Interpolate an array of fields onto a new mesh and write to stream.
void writeFields(DArray< Field > const &fields, std::ostream &out, bool writeHeader=true) const
Write a set of fields, one per monomer type, to an output stream.
void writeBlockCFields(Mixture const &mixture, std::ostream &out) const
Write block concentration fields for all blocks to an output stream.
void readFields(DArray< Field > &fields, std::istream &in)
Read a set of fields, one per monomer type.
Mixture of polymers and solvents.
Dynamically allocatable contiguous array template.
A FileMaster manages input and output files for a simulation.
Definition FileMaster.h:143
#define UTIL_ASSERT(condition)
Assertion macro suitable for debugging serial or parallel code.
Definition global.h:75
PSCF package top-level namespace.
Definition param_pc.dox:1
Utility classes for scientific computation.