OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
AmrYtWriter.h
Go to the documentation of this file.
1 //
2 // Class AmrYtWriter
3 // This concrete class writes output files that are readable by yt
4 // (cf. http://yt-project.org/). We have a fork of yt in
5 // the repository at https://gitlab.psi.ch/frey_m/yt.
6 // The functions of this class are copied from AMReX and modified to fit
7 // our needs.
8 //
9 // Copyright (c) 2016 - 2020, Matthias Frey, Paul Scherrer Institut, Villigen PSI, Switzerland
10 // All rights reserved
11 //
12 // Implemented as part of the PhD thesis
13 // "Precise Simulations of Multibunches in High Intensity Cyclotrons"
14 //
15 // This file is part of OPAL.
16 //
17 // OPAL is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
24 //
25 #ifndef AMR_YT_WRITER_H
26 #define AMR_YT_WRITER_H
27 
28 #include "Amr/AbstractAmrWriter.h"
29 
30 #include <boost/filesystem.hpp>
31 
32 #include <vector>
33 
35 
36 public:
37 
42  explicit AmrYtWriter(int step, int bin = 0);
43 
53  const amr::AmrVectorFieldContainer_t& efield,
54  const amr::AmrIntArray_t& refRatio,
55  const amr::AmrGeomContainer_t& geom,
56  const int& nLevel,
57  const double& time,
58  const double& scale);
59 
60 
61  void writeBunch(const AmrPartBunch* bunch_p,
62  const double& time,
63  const double& gamma);
64 
65 private:
66  /* Copied and slightely modified version of
67  * AMReX_ParticleContainerI.H
68  *
69  * @param level to write
70  * @param ofs out stream
71  * @param fnum file number
72  * @param which file
73  * @param count how many particles on this grid
74  * @param where file offset
75  * @param bunch_p to get data from
76  * @param gamma is the Lorentz factor
77  */
78  void writeParticles_m(int level,
79  std::ofstream& ofs,
80  int fnum,
81  amrex::Vector<int>& which,
82  amrex::Vector<int>& count,
83  amrex::Vector<long>& where,
84  const AmrPartBunch* bunch_p,
85  const double gamma) const;
86 
87 private:
88  std::string dir_m;
89 
90  std::vector<std::string> intData_m;
91  std::vector<std::string> realData_m;
92 };
93 
94 #endif
PETE_TTTree< OpWhere, typename Cond_t::PETE_Expr_t, typename True_t::PETE_Expr_t, PETE_Scalar< Vektor< T, Dim > > > where(const PETE_Expr< Cond_t > &c, const PETE_Expr< True_t > &t, const Vektor< T, Dim > &f)
amrex::Vector< AmrVectorField_t > AmrVectorFieldContainer_t
Definition: AmrDefs.h:42
amrex::Vector< AmrGeometry_t > AmrGeomContainer_t
Definition: AmrDefs.h:43
amrex::Vector< std::unique_ptr< AmrField_t > > AmrScalarFieldContainer_t
Definition: AmrDefs.h:41
amrex::Vector< int > AmrIntArray_t
Definition: AmrDefs.h:47
std::vector< std::string > intData_m
integer bunch data
Definition: AmrYtWriter.h:90
std::vector< std::string > realData_m
real bunch data
Definition: AmrYtWriter.h:91
AmrYtWriter(int step, int bin=0)
Definition: AmrYtWriter.cpp:39
void writeFields(const amr::AmrScalarFieldContainer_t &rho, const amr::AmrScalarFieldContainer_t &phi, const amr::AmrVectorFieldContainer_t &efield, const amr::AmrIntArray_t &refRatio, const amr::AmrGeomContainer_t &geom, const int &nLevel, const double &time, const double &scale)
Definition: AmrYtWriter.cpp:93
std::string dir_m
directory where to write files
Definition: AmrYtWriter.h:88
void writeParticles_m(int level, std::ofstream &ofs, int fnum, amrex::Vector< int > &which, amrex::Vector< int > &count, amrex::Vector< long > &where, const AmrPartBunch *bunch_p, const double gamma) const
void writeBunch(const AmrPartBunch *bunch_p, const double &time, const double &gamma)