5#ifndef _MOLECULARDYNAMICS_COUPLING_COUPLINGCELLPLOTTER_H_
6#define _MOLECULARDYNAMICS_COUPLING_COUPLINGCELLPLOTTER_H_
8#include "coupling/KineticEnergyController.h"
9#include "coupling/cell-mappings/ComputeMassMapping.h"
10#include "coupling/cell-mappings/ComputeMomentumMapping.h"
11#include "coupling/cell-mappings/VTKMoleculePlotter.h"
12#include "coupling/datastructures/LinkedCellContainer.h"
13#include "coupling/interface/MDSolverInterface.h"
14#include "tarch/la/Vector.h"
56 void plotMoleculeFile(
unsigned int ID, std::string filename,
unsigned int rank,
unsigned int t,
60 std::ofstream moleculeFile;
62 std::stringstream moleculeVelocities;
63 std::stringstream moleculePositions;
64 std::stringstream moleculePotentials;
66 std::string appendFloatZeros(
"");
69 appendFloatZeros =
" 0.0 0.0";
72 appendFloatZeros =
" 0.0";
75 appendFloatZeros =
"";
80 Writer4Molecules writer(moleculeVelocities, moleculePositions, moleculePotentials, appendFloatZeros, mdSolverInterface);
83 open(ID, filename,
"Molecules", rank, t, moleculeFile);
84 moleculeFile <<
"# vtk DataFile Version 2.0" << std::endl;
85 moleculeFile <<
"Generated by MaMiCo (Philipp Neumann)" << std::endl;
86 moleculeFile <<
"ASCII" << std::endl;
87 moleculeFile <<
"DATASET UNSTRUCTURED_GRID" << std::endl;
89 moleculeFile << moleculePositions.str() << std::endl << std::endl;
91 moleculeFile <<
"VECTORS velocity float" << std::endl;
92 moleculeFile << moleculeVelocities.str() << std::endl;
93 moleculeFile <<
"SCALARS potentialEnergy float 1" << std::endl;
94 moleculeFile <<
"LOOKUP_TABLE DEFAULT" << std::endl;
95 moleculeFile << moleculePotentials.str() << std::endl;
96 moleculePositions.clear();
97 moleculePositions.str(
"");
98 moleculeVelocities.clear();
99 moleculeVelocities.str(
"");
100 moleculePotentials.clear();
101 moleculePotentials.str(
"");
102 moleculeFile.close();
117 std::stringstream microscopicMasses;
118 microscopicMasses <<
"SCALARS microscopicMassBuffer float 1" << std::endl;
119 microscopicMasses <<
"LOOKUP_TABLE DEFAULT" << std::endl;
120 std::stringstream macroscopicMasses;
121 macroscopicMasses <<
"SCALARS macroscopicMassBuffer float 1" << std::endl;
122 macroscopicMasses <<
"LOOKUP_TABLE DEFAULT" << std::endl;
123 std::stringstream microscopicMomenta;
124 microscopicMomenta <<
"VECTORS microscopicMomentumBuffer float" << std::endl;
125 std::stringstream macroscopicMomenta;
126 macroscopicMomenta <<
"VECTORS macroscopicMomentumBuffer float" << std::endl;
127 std::stringstream meanVelocities;
128 meanVelocities <<
"VECTORS meanVelocity float" << std::endl;
129 std::stringstream masses;
130 masses <<
"SCALARS mass float 1" << std::endl;
131 masses <<
"LOOKUP_TABLE DEFAULT" << std::endl;
132 std::stringstream energies;
133 energies <<
"SCALARS meanPotentialEnergyBuffer float 1" << std::endl;
134 energies <<
"LOOKUP_TABLE DEFAULT" << std::endl;
135 std::stringstream temperatures;
136 temperatures <<
"SCALARS temperature float 1" << std::endl;
137 temperatures <<
"LOOKUP_TABLE DEFAULT" << std::endl;
139 std::ofstream ofCell;
141 std::string appendFloatZeros(
"");
144 appendFloatZeros =
" 0.0 0.0";
147 appendFloatZeros =
" 0.0";
150 appendFloatZeros =
"";
159 open(ID, filename,
"CouplingCells", rank, t, ofCell);
160 Writer4Cells writer(microscopicMasses, macroscopicMasses, microscopicMomenta, macroscopicMomenta, meanVelocities, masses, energies, temperatures,
161 appendFloatZeros, mdSolverInterface);
163 ofCell <<
"# vtk DataFile Version 2.0" << std::endl;
164 ofCell <<
"generated by MaMiCo (Philipp Neumann)" << std::endl;
165 ofCell <<
"ASCII" << std::endl << std::endl;
166 ofCell <<
"DATASET STRUCTURED_POINTS" << std::endl;
169 for (
unsigned int d = 0; d < 3; d++) {
170 ofCell << original[d] <<
" ";
173 ofCell <<
"SPACING ";
174 for (
unsigned int d = 0; d < dim; d++) {
175 ofCell << IDXS.getCouplingCellSize()[d] <<
" ";
177 for (
unsigned int d = dim; d < 3; d++) {
182 ofCell << microscopicMasses.str() << std::endl << std::endl;
183 microscopicMasses.clear();
184 microscopicMasses.str(
"");
185 ofCell << macroscopicMasses.str() << std::endl << std::endl;
186 macroscopicMasses.clear();
187 macroscopicMasses.str(
"");
188 ofCell << masses.str() << std::endl << std::endl;
191 ofCell << energies.str() << std::endl << std::endl;
194 ofCell << temperatures.str() << std::endl << std::endl;
195 temperatures.clear();
196 temperatures.str(
"");
197 ofCell << microscopicMomenta.str() << std::endl << std::endl;
198 microscopicMomenta.clear();
199 microscopicMomenta.str(
"");
200 ofCell << macroscopicMomenta.str() << std::endl << std::endl;
201 macroscopicMomenta.clear();
202 macroscopicMomenta.str(
"");
203 ofCell << meanVelocities.str() << std::endl << std::endl;
204 meanVelocities.clear();
205 meanVelocities.str(
"");
217 void open(
unsigned int ID, std::string filename, std::string fileType,
unsigned int rank,
unsigned int t, std::ofstream& of) {
218 std::stringstream ss;
219 ss << filename <<
"_" << fileType <<
"_" << ID <<
"_" << rank <<
"_" << t <<
".vtk";
220 of.open(ss.str().c_str());
222 std::cout <<
"ERROR coupling::CouplingCellPlotter: Could not open file " << ss.str() <<
"!" << std::endl;
243 Writer4Cells(std::stringstream& microscopicMasses, std::stringstream& macroscopicMasses, std::stringstream& microscopicMomenta,
244 std::stringstream& macroscopicMomenta, std::stringstream& meanVelocities, std::stringstream& masses, std::stringstream& energies,
245 std::stringstream& temperatures,
const std::string& appendFloatZeros,
270 double temperature = 0.0;
286 for (
unsigned int d = 0; d < dim; d++) {
339 Writer4Molecules(std::stringstream& moleculeVelocities, std::stringstream& moleculePositions, std::stringstream& moleculePotentials,
class for writing coupling cell data to stringstreams.
Definition CouplingCellPlotter.h:229
coupling::cellmappings::ComputeMomentumMapping< LinkedCell, dim > _computeMomentumMapping
Definition CouplingCellPlotter.h:322
std::stringstream & _microscopicMasses
Definition CouplingCellPlotter.h:299
std::stringstream & _macroscopicMasses
Definition CouplingCellPlotter.h:302
std::stringstream & _microscopicMomenta
Definition CouplingCellPlotter.h:305
std::stringstream & _energies
Definition CouplingCellPlotter.h:314
coupling::cellmappings::ComputeMassMapping< LinkedCell, dim > _computeMassMapping
Definition CouplingCellPlotter.h:320
void endCellIteration()
does everything which is neccessary after the application of the writer to the cells
Definition CouplingCellPlotter.h:261
~Writer4Cells()
a simple destructor
Definition CouplingCellPlotter.h:253
std::stringstream & _macroscopicMomenta
Definition CouplingCellPlotter.h:308
Writer4Cells(std::stringstream µscopicMasses, std::stringstream ¯oscopicMasses, std::stringstream µscopicMomenta, std::stringstream ¯oscopicMomenta, std::stringstream &meanVelocities, std::stringstream &masses, std::stringstream &energies, std::stringstream &temperatures, const std::string &appendFloatZeros, coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface)
a simple constructor
Definition CouplingCellPlotter.h:243
const std::string _appendFloatZeros
Definition CouplingCellPlotter.h:318
std::stringstream & _masses
Definition CouplingCellPlotter.h:312
void apply(coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > &cell, const I02 &index)
writes the data from the cell to the stringstreams
Definition CouplingCellPlotter.h:266
void beginCellIteration()
does everything which is neccessary before the application of the writer to the cells
Definition CouplingCellPlotter.h:257
coupling::KineticEnergyController< LinkedCell, dim > _kineticEnergyController
Definition CouplingCellPlotter.h:324
std::stringstream & _temperatures
Definition CouplingCellPlotter.h:316
std::stringstream & _meanVelocities
Definition CouplingCellPlotter.h:310
class for writing molecule data to stringstreams.
Definition CouplingCellPlotter.h:330
const std::string _appendFloatZeros
Definition CouplingCellPlotter.h:372
std::stringstream & _moleculePotentials
Definition CouplingCellPlotter.h:370
Writer4Molecules(std::stringstream &moleculeVelocities, std::stringstream &moleculePositions, std::stringstream &moleculePotentials, const std::string &appendFloatZeros, coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface)
a simple constructor
Definition CouplingCellPlotter.h:339
coupling::interface::MDSolverInterface< LinkedCell, dim > *const _mdSolverInterface
Definition CouplingCellPlotter.h:374
unsigned int _moleculeCounter
Definition CouplingCellPlotter.h:376
unsigned int getMoleculeCounter() const
returns the number of molecules
Definition CouplingCellPlotter.h:362
void endCellIteration()
does everything which is neccessary after the application of the writer to the cells
Definition CouplingCellPlotter.h:350
void apply(coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > &cell, const I02 &index)
aplication of the vtkMoleculePlotter to the coupling cells
Definition CouplingCellPlotter.h:353
void beginCellIteration()
does everything which is neccessary before the application of the writer to the cells
Definition CouplingCellPlotter.h:346
std::stringstream & _moleculePositions
Definition CouplingCellPlotter.h:368
std::stringstream & _moleculeVelocities
Definition CouplingCellPlotter.h:366
plots the coupling cell data.
Definition CouplingCellPlotter.h:28
~CouplingCellPlotter()
a simple destructor
Definition CouplingCellPlotter.h:44
void plotCouplingCellFile(unsigned int ID, std::string filename, unsigned int rank, unsigned int t, coupling::datastructures::LinkedCellContainer< LinkedCell, dim > &cells, coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface)
writes molecule information + coupling cell information to VTK file.
Definition CouplingCellPlotter.h:113
void open(unsigned int ID, std::string filename, std::string fileType, unsigned int rank, unsigned int t, std::ofstream &of)
opens a file
Definition CouplingCellPlotter.h:217
void plotMoleculeFile(unsigned int ID, std::string filename, unsigned int rank, unsigned int t, coupling::datastructures::LinkedCellContainer< LinkedCell, dim > &cells, coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface)
writes molecule information to VTK file.
Definition CouplingCellPlotter.h:56
CouplingCellPlotter(unsigned int ID, std::string filename, unsigned int rank, unsigned int t, datastructures::LinkedCellContainer< LinkedCell, dim > &cells, coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface)
a simple constructor
Definition CouplingCellPlotter.h:37
controles and regulates the kinetic energy of the MD system.
Definition KineticEnergyController.h:27
This class computes the mass over certain linked cells.
Definition ComputeMassMapping.h:23
This class computes the momentum over certain linked cells.
Definition ComputeMomentumMapping.h:24
This class writes molecule data to streams for .vtk file.
Definition VTKMoleculePlotter.h:25
const unsigned int & getParticleCounter() const
Definition VTKMoleculePlotter.h:78
defines the cell type with cell-averaged quantities. Derived from the class coupling::datastructures:...
Definition CouplingCellWithLinkedCells.h:26
void iterateConstCells(A &a) const
Definition CouplingCellWithLinkedCells.h:90
const tarch::la::Vector< dim, double > & getMicroscopicMomentum() const
Definition CouplingCell.h:51
const tarch::la::Vector< dim, double > & getMacroscopicMomentum() const
Definition CouplingCell.h:64
const double & getPotentialEnergy() const
Definition CouplingCell.h:68
const double & getMicroscopicMass() const
Definition CouplingCell.h:45
const double & getMacroscopicMass() const
Definition CouplingCell.h:58
provides access to the coupling cells with linked cells.
Definition LinkedCellContainer.h:21
void applyToLocalNonGhostCouplingCellsWithLinkedCells(A &a)
void applyToAllLocalCouplingCellsWithLinkedCells(A &a)
static unsigned int linearNumberCellsInDomain
Definition CellIndex.h:270
static tarch::la::Vector< dim, unsigned int > numberCellsInDomain
Definition CellIndex.h:264
static bool contains(const coupling::indexing::BaseIndex< dim > &index)
Definition CellIndex.h:227
interface to the MD simulation
Definition MDSolverInterface.h:25
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15