PSCF v1.1
Public Member Functions | List of all members
Pscf::Fd1d::FieldIo Class Reference

Read and write fields to file. More...

#include <FieldIo.h>

Public Member Functions

 FieldIo ()
 Constructor. More...
 
 ~FieldIo ()
 Destructor. More...
 
void associate (Domain const &domain, FileMaster const &fileMaster)
 Get and store addresses of associated objects. More...
 
void readFields (DArray< Field > &fields, std::istream &in)
 Read a set of fields, one per monomer type. More...
 
void readFields (DArray< Field > &fields, std::string const &filename)
 Read a set of fields, one per monomer type. More...
 
void writeField (Field const &field, std::ostream &out, bool writeHeader=true) const
 Write a single field to an output stream. More...
 
void writeField (Field const &field, std::string const &filename, bool writeHeader=true) const
 Write a single field to a file. More...
 
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. More...
 
void writeFields (DArray< Field > const &fields, std::string const &filename, bool writeHeader=true)
 Write a set of fields, one per monomer type, to a named file. More...
 
void writeBlockCFields (Mixture const &mixture, std::ostream &out)
 Write block concentration fields for all blocks to an output stream. More...
 
void writeBlockCFields (Mixture const &mixture, std::string const &filename)
 Write block concentration fields for all blocks to a named file. More...
 
void writeVertexQ (Mixture const &mixture, int polymerId, int vertexId, std::ostream &out)
 Write product of incoming q fields for one vertex to stream. More...
 
void writeVertexQ (Mixture const &mixture, int polymerId, int vertexId, std::string const &filename)
 Write incoming q fields for a specified vertex. More...
 
void remesh (DArray< Field > const &fields, int nx, std::ostream &out)
 Interpolate an array of fields onto a new mesh and write to stream. More...
 
void remesh (DArray< Field > const &fields, int nx, std::string const &filename)
 Interpolate an array of fields onto a new mesh and write to file. More...
 
void extend (DArray< Field > const &fields, int m, std::ostream &out)
 Add points to the end of a field mesh and write to stream. More...
 
void extend (DArray< Field > const &fields, int m, std::string const &filename)
 Add points to the end of a field mesh and write to a file. More...
 

Detailed Description

Read and write fields to file.

Definition at line 27 of file fd1d/misc/FieldIo.h.

Constructor & Destructor Documentation

◆ FieldIo()

Pscf::Fd1d::FieldIo::FieldIo ( )

Constructor.

Definition at line 34 of file fd1d/misc/FieldIo.cpp.

◆ ~FieldIo()

Pscf::Fd1d::FieldIo::~FieldIo ( )

Destructor.

Definition at line 40 of file fd1d/misc/FieldIo.cpp.

Member Function Documentation

◆ associate()

void Pscf::Fd1d::FieldIo::associate ( Domain const &  domain,
FileMaster const &  fileMaster 
)

Get and store addresses of associated objects.

Parameters
domainassociated spatial domain
fileMasterassociated FileMaster (for file paths)

Definition at line 44 of file fd1d/misc/FieldIo.cpp.

Referenced by Pscf::Fd1d::Sweep::Sweep(), and Pscf::Fd1d::System::System().

◆ readFields() [1/2]

void Pscf::Fd1d::FieldIo::readFields ( DArray< Field > &  fields,
std::istream &  in 
)

Read a set of fields, one per monomer type.

Precondition
File in must be open for reading.
Parameters
fieldsarray of fields to read, indexed by monomer id
ininput stream, open for reading.

Definition at line 60 of file fd1d/misc/FieldIo.cpp.

References Util::Array< Data >::capacity(), and UTIL_CHECK.

Referenced by Pscf::Fd1d::System::readCommands(), and readFields().

◆ readFields() [2/2]

void Pscf::Fd1d::FieldIo::readFields ( DArray< Field > &  fields,
std::string const &  filename 
)

Read a set of fields, one per monomer type.

This function uses the associated FileMaster to open an input file named filename before reading, and closes the file after reading.

Parameters
fieldsarray of fields to read, indexed by monomer id.
filenamename of input file

Definition at line 51 of file fd1d/misc/FieldIo.cpp.

References Util::FileMaster::openInputFile(), and readFields().

◆ writeField() [1/2]

void Pscf::Fd1d::FieldIo::writeField ( Field const &  field,
std::ostream &  out,
bool  writeHeader = true 
) const

Write a single field to an output stream.

Precondition
Stream out must be open for writing.
Parameters
fieldfield defined on r-space grid (input)
outoutput stream
writeHeaderwrite file header iff this bool is true

Definition at line 102 of file fd1d/misc/FieldIo.cpp.

References Util::Array< Data >::capacity(), and UTIL_CHECK.

Referenced by Pscf::Fd1d::System::writeQ(), Pscf::Fd1d::System::writeQSlice(), and Pscf::Fd1d::System::writeQTail().

◆ writeField() [2/2]

void Pscf::Fd1d::FieldIo::writeField ( Field const &  field,
std::string const &  filename,
bool  writeHeader = true 
) const

Write a single field to a file.

This function uses the associated FileMaster to open an output file named filename before writing, and closes the file after writing.

Parameters
fieldfield defined on r-space grid (input)
filenameoutput filename
writeHeaderwrite file header iff this bool is true

Definition at line 93 of file fd1d/misc/FieldIo.cpp.

References Util::FileMaster::openOutputFile(), and writeField().

Referenced by writeField().

◆ writeFields() [1/2]

void Pscf::Fd1d::FieldIo::writeFields ( DArray< Field > const &  fields,
std::ostream &  out,
bool  writeHeader = true 
)

Write a set of fields, one per monomer type, to an output stream.

Precondition
Stream out must be open for writing.
Parameters
fieldsset of fields to written.
outoutput stream
writeHeaderwrite file header iff this bool is true

Definition at line 127 of file fd1d/misc/FieldIo.cpp.

References Util::Array< Data >::capacity(), and UTIL_CHECK.

Referenced by Pscf::Fd1d::Sweep::outputSolution(), Pscf::Fd1d::System::readCommands(), Pscf::Fd1d::System::writeC(), writeFields(), and Pscf::Fd1d::System::writeW().

◆ writeFields() [2/2]

void Pscf::Fd1d::FieldIo::writeFields ( DArray< Field > const &  fields,
std::string const &  filename,
bool  writeHeader = true 
)

Write a set of fields, one per monomer type, to a named file.

This function uses the associated FileMaster to open an output file named filename before writing, and closes the file after writing.

Parameters
fieldsarray of fields to read, indexed by monomer id
filenameoutput filename
writeHeaderwrite header iff this bool is true

Definition at line 118 of file fd1d/misc/FieldIo.cpp.

References Util::FileMaster::openOutputFile(), and writeFields().

◆ writeBlockCFields() [1/2]

void Pscf::Fd1d::FieldIo::writeBlockCFields ( Mixture const &  mixture,
std::ostream &  out 
)

Write block concentration fields for all blocks to an output stream.

Precondition
Stream out must be open for writing.
Parameters
mixtureassociated Mixture MDE solver object
outoutput stream

Definition at line 165 of file fd1d/misc/FieldIo.cpp.

References Pscf::MixtureTmpl< TP, TS >::nBlock(), Pscf::MixtureTmpl< TP, TS >::nPolymer(), Pscf::MixtureTmpl< TP, TS >::nSolvent(), Pscf::Fd1d::Domain::nx(), Pscf::MixtureTmpl< TP, TS >::polymer(), and Pscf::MixtureTmpl< TP, TS >::solvent().

Referenced by Pscf::Fd1d::System::readCommands(), Pscf::Fd1d::System::writeBlockC(), and writeBlockCFields().

◆ writeBlockCFields() [2/2]

void Pscf::Fd1d::FieldIo::writeBlockCFields ( Mixture const &  mixture,
std::string const &  filename 
)

Write block concentration fields for all blocks to a named file.

This function uses the associated FileMaster to open an output file named filename before writing, and closes the file after writing.

Parameters
mixtureassociated Mixture MDE solver object
filenamename of output file

Definition at line 153 of file fd1d/misc/FieldIo.cpp.

References Util::FileMaster::openOutputFile(), and writeBlockCFields().

◆ writeVertexQ() [1/2]

void Pscf::Fd1d::FieldIo::writeVertexQ ( Mixture const &  mixture,
int  polymerId,
int  vertexId,
std::ostream &  out 
)

Write product of incoming q fields for one vertex to stream.

Precondition
Stream out must be open for writing.
Parameters
mixtureassociated Mixture MDE solver object
polymerIdinteger id of polymer species
vertexIdinteger id of vertex (end or junction)
outoutput stream

Definition at line 212 of file fd1d/misc/FieldIo.cpp.

References Pscf::Vertex::inPropagatorId(), Pscf::PolymerTmpl< Block >::nBlock(), Pscf::MixtureTmpl< TP, TS >::nPolymer(), Pscf::Fd1d::Domain::nx(), Pscf::MixtureTmpl< TP, TS >::polymer(), Util::product(), Pscf::PolymerTmpl< Block >::propagator(), Pscf::Vertex::size(), UTIL_CHECK, and Pscf::PolymerTmpl< Block >::vertex().

Referenced by Pscf::Fd1d::System::readCommands(), and writeVertexQ().

◆ writeVertexQ() [2/2]

void Pscf::Fd1d::FieldIo::writeVertexQ ( Mixture const &  mixture,
int  polymerId,
int  vertexId,
std::string const &  filename 
)

Write incoming q fields for a specified vertex.

Parameters
mixtureassociated Mixture MDE solver object
polymerIdinteger id of polymer species
vertexIdinteger id of vertex (end or junction)
filenamename of output file

Definition at line 199 of file fd1d/misc/FieldIo.cpp.

References Util::FileMaster::openOutputFile(), and writeVertexQ().

◆ remesh() [1/2]

void Pscf::Fd1d::FieldIo::remesh ( DArray< Field > const &  fields,
int  nx,
std::ostream &  out 
)

Interpolate an array of fields onto a new mesh and write to stream.

Parameters
fieldsfield to be remeshed
nxnumber of grid points in new mesh
outoutput stream for remeshed field

Definition at line 265 of file fd1d/misc/FieldIo.cpp.

References Util::Array< Data >::capacity(), Pscf::Fd1d::Domain::dx(), Pscf::Fd1d::Domain::nx(), UTIL_CHECK, Pscf::Fd1d::Domain::xMax(), and Pscf::Fd1d::Domain::xMin().

Referenced by Pscf::Fd1d::System::readCommands(), and remesh().

◆ remesh() [2/2]

void Pscf::Fd1d::FieldIo::remesh ( DArray< Field > const &  fields,
int  nx,
std::string const &  filename 
)

Interpolate an array of fields onto a new mesh and write to file.

Parameters
fieldsfield to be remeshed
nxnumber of grid points in new mesh
filenamename of output file for remeshed field

Definition at line 252 of file fd1d/misc/FieldIo.cpp.

References Util::FileMaster::openOutputFile(), and remesh().

◆ extend() [1/2]

void Pscf::Fd1d::FieldIo::extend ( DArray< Field > const &  fields,
int  m,
std::ostream &  out 
)

Add points to the end of a field mesh and write to stream.

Values at the added mesh points are taken to be the same as those at the last mesh point of the original mesh.

Parameters
fieldsarray of fields to be extended
mnumber of added grid points
outoutput stream for extended field

Definition at line 338 of file fd1d/misc/FieldIo.cpp.

References Util::Array< Data >::capacity(), and UTIL_CHECK.

Referenced by extend(), and Pscf::Fd1d::System::readCommands().

◆ extend() [2/2]

void Pscf::Fd1d::FieldIo::extend ( DArray< Field > const &  fields,
int  m,
std::string const &  filename 
)

Add points to the end of a field mesh and write to a file.

Values at the added mesh points are taken to be the same as those at the last mesh point of the original mesh.

Parameters
fieldsfield to be remeshed
mnumber of added grid points
filenamename of output file for remeshed field

Definition at line 325 of file fd1d/misc/FieldIo.cpp.

References extend(), and Util::FileMaster::openOutputFile().


The documentation for this class was generated from the following files: