10#include <r1d/domain/Domain.h>
11#include <r1d/solvers/Mixture.h>
12#include <r1d/solvers/Polymer.h>
14#include <pscf/chem/Vertex.h>
15#include <pscf/floryHuggins/Clump.h>
18#include <util/misc/FileMaster.h>
19#include <util/format/Str.h>
20#include <util/format/Int.h>
21#include <util/format/Dbl.h>
48 fileMasterPtr_ = &fileMaster;
52 std::string
const & filename)
55 fileMaster().openInputFile(filename, in);
78 for (
int i = 0; i < nm; ++i) {
84 for (i = 0; i < nx; ++i) {
87 for (j = 0; j < nm; ++j) {
94 std::string
const & filename,
bool writeHeader)
const
97 fileMaster().openOutputFile(filename, out);
108 out <<
"nx " << nx << std::endl;
112 for (i = 0; i < nx; ++i) {
113 out <<
" " <<
Dbl(field[i], 18, 11);
119 std::string
const & filename,
bool writeHeader)
123 fileMaster().openOutputFile(filename, out);
129 std::ostream& out,
bool writeHeader)
137 for (
int i = 0; i < nm; ++i) {
142 out <<
"nx " << nx << std::endl;
143 out <<
"nm " << nm << std::endl;
147 for (i = 0; i < nx; ++i) {
149 for (j = 0; j < nm; ++j) {
150 out <<
" " <<
Dbl(fields[j][i], 18, 11);
157 std::string
const & filename)
const
160 fileMaster().openOutputFile(filename, out);
171 int nx = domain().nx();
173 int nb_tot = mixture.
nBlock();
176 out <<
"nx " << nx << std::endl;
177 out <<
"n_block " << nb_tot << std::endl;
178 out <<
"n_solvent " << ns << std::endl;
183 for (i = 0; i < nx; ++i) {
185 for (j = 0; j < np; ++j) {
186 nb = mixture.
polymer(j).nBlock();
187 for (k = 0; k < nb; ++k) {
188 c = mixture.
polymer(j).block(k).cField()[i];
189 out <<
" " <<
Dbl(c, 15, 8);
192 for (l = 0; l < ns; ++l) {
193 c = mixture.
solvent(l).cField()[i];
194 out <<
" " <<
Dbl(c, 15, 8);
204 int polymerId,
int vertexId,
205 std::string
const & filename)
const
208 fileMaster().openOutputFile(filename, out);
217 int polymerId,
int vertexId,
218 std::ostream& out)
const
226 int nb = vertex.
size();
227 int nx = domain().nx();
234 for (i = 0; i < nx; ++i) {
237 for (j = 0; j < nb; ++j) {
245 out <<
" " <<
Dbl(c, 15, 8);
248 out <<
" " <<
Dbl(
product, 15, 8) << std::endl;
257 std::string
const & filename)
260 fileMaster().openOutputFile(filename, out);
274 for (
int i = 0; i < nm; ++i) {
275 UTIL_CHECK(fields[i].capacity() == domain().nx());
279 out <<
"nx " << nx << std::endl;
280 out <<
"nm " << nm << std::endl;
286 for (j = 0; j < nm; ++j) {
287 out <<
" " <<
Dbl(fields[j][i]);
292 double dx = (domain().xMax() - domain().xMin())/
double(nx-1);
302 for (i = 1; i < nx -1; ++i) {
303 y = dx*double(i)/domain().dx();
311 for (j = 0; j < nm; ++j) {
312 w = fl*fields[j][yi] + fu*fields[j][yi+1];
313 out <<
" " <<
Dbl(w);
319 out <<
Int(nx - 1, 5);
320 i = domain().nx() - 1;
321 for (j = 0; j < nm; ++j) {
322 out <<
" " <<
Dbl(fields[j][i]);
330 std::string
const & filename)
333 fileMaster().openOutputFile(filename, out);
350 for (
int i = 0; i < nm; ++i) {
356 out <<
"nx " << nx + m << std::endl;
357 out <<
"nm " << nm << std::endl;
361 for (i = 0; i < nx; ++i) {
363 for (j = 0; j < nm; ++j) {
364 out <<
" " <<
Dbl(fields[j][i]);
370 for (i = nx; i < nx + m; ++i) {
372 for (j = 0; j < nm; ++j) {
373 out <<
" " <<
Dbl(fields[j][nx-1]);
int nPolymer() const
Get number of polymer species.
int nBlock() const
Get total number blocks among all polymer species.
int nSolvent() const
Get number of solvent (point particle) species.
SolventT & solvent(int id)
Get a solvent solver object.
PolymerT & polymer(int id)
Get a polymer solver object by non-const reference.
const Vertex & vertex(int id) const
Get a specified Vertex by const reference.
int nBlock() const
Number of blocks.
PropagatorT & propagator(int blockId, int directionId)
Get the propagator for a specific block and direction (non-const).
One-dimensional spatial domain and discretization grid.
void writeFields(DArray< Field > const &fields, std::string const &filename, bool writeHeader=true) const
Write a set of fields, one per monomer type, to a named 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 writeField(Field const &field, std::string const &filename, bool writeHeader=true) const
Write a single field to a file.
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.
Descriptor and solver for a block polymer species.
A junction or chain end in a block polymer.
int size() const
Get the number of attached blocks.
Pair< int > const & inPropagatorId(int i) const
Get the block and direction of an incoming propagator.
int capacity() const
Return allocated size.
Dynamically allocatable contiguous array template.
Wrapper for a double precision number, for formatted ostream output.
A FileMaster manages input and output files for a simulation.
Wrapper for an int, for formatted ostream output.
An array of exactly 2 objects.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
SCFT with real 1D fields.
PSCF package top-level namespace.
float product(float a, float b)
Product for float Data.