PSCF v1.1
fd1d/misc/FieldIo.h
1#ifndef FD1D_FIELD_IO_H
2#define FD1D_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 Fd1d {
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);
112
124 void writeFields(DArray<Field> const& fields,
125 std::string const& filename, bool writeHeader= true);
126
135 void writeBlockCFields(Mixture const& mixture, std::ostream& out);
136
148 void writeBlockCFields(Mixture const& mixture,
149 std::string const& filename);
150
161 void writeVertexQ(Mixture const& mixture,
162 int polymerId, int vertexId, std::ostream& out);
163
172 void writeVertexQ(Mixture const& mixture,
173 int polymerId, int vertexId,
174 std::string const& filename);
175
183 void remesh(DArray<Field> const& fields, int nx, std::ostream& out);
184
192 void remesh(DArray<Field> const& fields, int nx,
193 std::string const& filename);
194
205 void extend(DArray<Field> const& fields, int m, std::ostream& out);
206
217 void extend(DArray<Field> const& fields, int m,
218 std::string const& filename);
219
220 private:
221
223 mutable DArray<double> w_;
224
225 // Pointers to associated objects.
226
228 Domain const * domainPtr_;
229
231 FileMaster const * fileMasterPtr_;
232
233 // Private accessor functions:
234
236 Domain const& domain() const
237 {
238 UTIL_ASSERT(domainPtr_);
239 return *domainPtr_;
240 }
241
243 FileMaster const & fileMaster() const
244 {
245 UTIL_ASSERT(fileMasterPtr_);
246 return *fileMasterPtr_;
247 }
248
249 };
250
251
252} // namespace Fd1d
253} // namespace Pscf
254#endif
One-dimensional spatial domain and discretization grid.
Read and write fields to file.
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)
Write product of incoming q fields for one vertex to stream.
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 associate(Domain const &domain, FileMaster const &fileMaster)
Get and store addresses of associated objects.
void writeFields(DArray< Field > const &fields, std::ostream &out, bool writeHeader=true)
Write a set of fields, one per monomer type, to an output stream.
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 writeBlockCFields(Mixture const &mixture, std::ostream &out)
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.
Definition: DArray.h:32
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
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.
Definition: accumulators.mod:1