10#include <r1d/domain/Domain.h>
11#include <r1d/solvers/Mixture.h>
12#include <r1d/solvers/Polymer.h>
13#include <r1d/solvers/Solvent.h>
14#include <r1d/solvers/Block.h>
16#include <pscf/chem/Vertex.h>
17#include <pscf/floryHuggins/Clump.h>
19#include <util/misc/FileMaster.h>
20#include <util/format/Str.h>
21#include <util/format/Int.h>
22#include <util/format/Dbl.h>
49 fileMasterPtr_ = &fileMaster;
53 std::string
const & filename)
56 fileMaster().openInputFile(filename, in);
79 for (
int i = 0; i < nm; ++i) {
85 for (i = 0; i < nx; ++i) {
88 for (j = 0; j < nm; ++j) {
95 std::string
const & filename,
bool writeHeader)
const
98 fileMaster().openOutputFile(filename, out);
109 out <<
"nx " << nx << std::endl;
113 for (i = 0; i < nx; ++i) {
114 out <<
" " <<
Dbl(field[i], 18, 11);
120 std::string
const & filename,
bool writeHeader)
124 fileMaster().openOutputFile(filename, out);
130 std::ostream& out,
bool writeHeader)
138 for (
int i = 0; i < nm; ++i) {
143 out <<
"nx " << nx << std::endl;
144 out <<
"nm " << nm << std::endl;
148 for (i = 0; i < nx; ++i) {
150 for (j = 0; j < nm; ++j) {
151 out <<
" " <<
Dbl(fields[j][i], 18, 11);
158 std::string
const & filename)
const
161 fileMaster().openOutputFile(filename, out);
172 int nx = domain().nx();
174 int nb_tot = mixture.
nBlock();
177 out <<
"nx " << nx << std::endl;
178 out <<
"n_block " << nb_tot << std::endl;
179 out <<
"n_solvent " << ns << std::endl;
184 for (i = 0; i < nx; ++i) {
186 for (j = 0; j < np; ++j) {
187 nb = mixture.
polymer(j).nBlock();
188 for (k = 0; k < nb; ++k) {
189 c = mixture.
polymer(j).block(k).cField()[i];
190 out <<
" " <<
Dbl(c, 15, 8);
193 for (l = 0; l < ns; ++l) {
194 c = mixture.
solvent(l).cField()[i];
195 out <<
" " <<
Dbl(c, 15, 8);
205 int polymerId,
int vertexId,
206 std::string
const & filename)
const
209 fileMaster().openOutputFile(filename, out);
218 int polymerId,
int vertexId,
219 std::ostream& out)
const
227 int nb = vertex.
size();
228 int nx = domain().nx();
235 for (i = 0; i < nx; ++i) {
238 for (j = 0; j < nb; ++j) {
246 out <<
" " <<
Dbl(c, 15, 8);
249 out <<
" " <<
Dbl(
product, 15, 8) << std::endl;
258 std::string
const & filename)
261 fileMaster().openOutputFile(filename, out);
275 for (
int i = 0; i < nm; ++i) {
276 UTIL_CHECK(fields[i].capacity() == domain().nx());
280 out <<
"nx " << nx << std::endl;
281 out <<
"nm " << nm << std::endl;
287 for (j = 0; j < nm; ++j) {
288 out <<
" " <<
Dbl(fields[j][i]);
293 double dx = (domain().xMax() - domain().xMin())/
double(nx-1);
303 for (i = 1; i < nx -1; ++i) {
304 y = dx*double(i)/domain().dx();
312 for (j = 0; j < nm; ++j) {
313 w = fl*fields[j][yi] + fu*fields[j][yi+1];
314 out <<
" " <<
Dbl(w);
320 out <<
Int(nx - 1, 5);
321 i = domain().nx() - 1;
322 for (j = 0; j < nm; ++j) {
323 out <<
" " <<
Dbl(fields[j][i]);
331 std::string
const & filename)
334 fileMaster().openOutputFile(filename, out);
351 for (
int i = 0; i < nm; ++i) {
357 out <<
"nx " << nx + m << std::endl;
358 out <<
"nm " << nm << std::endl;
362 for (i = 0; i < nx; ++i) {
364 for (j = 0; j < nm; ++j) {
365 out <<
" " <<
Dbl(fields[j][i]);
371 for (i = nx; i < nx + m; ++i) {
373 for (j = 0; j < nm; ++j) {
374 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.
PT & propagator(int blockId, int directionId)
Get the propagator for a specific block and direction (non-const).
int nBlock() const
Number of blocks.
One-dimensional spatial domain and discretization grid.
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.
Solver and descriptor for a 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.