10#include <fd1d/domain/Domain.h>
11#include <fd1d/solvers/Mixture.h>
12#include <fd1d/solvers/Polymer.h>
14#include <pscf/chem/Vertex.h>
15#include <pscf/homogeneous/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)
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
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)
134 for (
int i = 0; i < nm; ++i) {
139 out <<
"nx " << nx << std::endl;
140 out <<
"nm " << nm << std::endl;
144 for (i = 0; i < nx; ++i) {
146 for (j = 0; j < nm; ++j) {
147 out <<
" " <<
Dbl(fields[j][i], 18, 11);
154 std::string
const & filename)
167 int nx = domain().
nx();
169 int nb_tot = mixture.
nBlock();
172 out <<
"nx " << nx << std::endl;
173 out <<
"n_block " << nb_tot << std::endl;
174 out <<
"n_solvent " << ns << std::endl;
179 for (i = 0; i < nx; ++i) {
181 for (j = 0; j < np; ++j) {
182 nb = mixture.
polymer(j).nBlock();
183 for (k = 0; k < nb; ++k) {
184 c = mixture.
polymer(j).block(k).cField()[i];
185 out <<
" " <<
Dbl(c, 15, 8);
188 for (l = 0; l < ns; ++l) {
189 c = mixture.
solvent(l).cField()[i];
190 out <<
" " <<
Dbl(c, 15, 8);
200 int polymerId,
int vertexId,
201 std::string
const & filename)
213 int polymerId,
int vertexId,
222 int nb = vertex.
size();
223 int nx = domain().
nx();
230 for (i = 0; i < nx; ++i) {
233 for (j = 0; j < nb; ++j) {
241 out <<
" " <<
Dbl(c, 15, 8);
244 out <<
" " <<
Dbl(
product, 15, 8) << std::endl;
253 std::string
const & filename)
270 for (
int i = 0; i < nm; ++i) {
271 UTIL_CHECK(fields[i].capacity() == domain().nx());
275 out <<
"nx " << nx << std::endl;
276 out <<
"nm " << nm << std::endl;
282 for (j = 0; j < nm; ++j) {
283 out <<
" " <<
Dbl(fields[j][i]);
288 double dx = (domain().
xMax() - domain().
xMin())/
double(nx-1);
298 for (i = 1; i < nx -1; ++i) {
299 y = dx*double(i)/domain().
dx();
307 for (j = 0; j < nm; ++j) {
308 w = fl*fields[j][yi] + fu*fields[j][yi+1];
309 out <<
" " <<
Dbl(w);
315 out <<
Int(nx - 1, 5);
316 i = domain().
nx() - 1;
317 for (j = 0; j < nm; ++j) {
318 out <<
" " <<
Dbl(fields[j][i]);
326 std::string
const & filename)
346 for (
int i = 0; i < nm; ++i) {
352 out <<
"nx " << nx + m << std::endl;
353 out <<
"nm " << nm << std::endl;
357 for (i = 0; i < nx; ++i) {
359 for (j = 0; j < nm; ++j) {
360 out <<
" " <<
Dbl(fields[j][i]);
366 for (i = nx; i < nx + m; ++i) {
368 for (j = 0; j < nm; ++j) {
369 out <<
" " <<
Dbl(fields[j][nx-1]);
One-dimensional spatial domain and discretization grid.
double dx() const
Get spatial grid step size.
double xMin() const
Get minimum spatial coordinate.
double xMax() const
Get maximum spatial coordinate.
int nx() const
Get number of spatial grid points, including both endpoints.
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 writeField(Field const &field, std::string const &filename, bool writeHeader=true) const
Write a single field to a file.
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.
Descriptor and solver for a branched polymer species.
Polymer & polymer(int id)
Get a polymer object.
int nBlock() const
Get number of total blocks in the mixture across all polymers.
int nSolvent() const
Get number of solvent (point particle) species.
Solvent & solvent(int id)
Set a solvent solver object.
int nPolymer() const
Get number of polymer species.
int nBlock() const
Number of blocks.
Propagator & propagator(int blockId, int directionId)
Get propagator for a specific block and direction.
const Vertex & vertex(int id) const
Get a specified Vertex by const reference.
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.
void openOutputFile(const std::string &filename, std::ofstream &out, std::ios_base::openmode mode=std::ios_base::out) const
Open an output file.
void openInputFile(const std::string &filename, std::ifstream &in, std::ios_base::openmode mode=std::ios_base::in) const
Open an input file.
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.
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.
float product(float a, float b)
Product for float Data.