summaryrefslogtreecommitdiff
path: root/src/particles/superParticleSysVTUout.h
blob: a6c90b063a1f014310d4c79158266564422864e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*  This file is part of the OpenLB library
 *
 *  Copyright (C) 2013 Thomas Henn, Mathias J. Krause
 *  E-mail contact: info@openlb.net
 *  The most recent release of OpenLB can be downloaded at
 *  <http://www.openlb.net/>
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public
 *  License along with this program; if not, write to the Free
 *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *  Boston, MA  02110-1301, USA.
 */

#ifndef SUPERPARTICLESYSVTUOUT_H
#define SUPERPARTICLESYSVTUOUT_H

#include <stddef.h>
#include <sys/types.h>
#include <cstdint>
#include <fstream>
#include <iostream>
#include <string>
#include <bitset>

#include "core/singleton.h"
#include "io/base64.h"
#include "io/base64.hh"
#include "io/fileName.h"
#include "io/ostreamManager.h"
#include "superParticleSystem3D.h"

namespace olb {

template<typename T, template<typename U> class PARTICLETYPE>
class SuperParticleSystem3D;

template<typename T, template<typename U> class PARTICLETYPE>
class SuperParticleSysVtuWriter {
public:
  //  SuperParticleSysVtuWriter() = default;
  SuperParticleSysVtuWriter(SuperParticleSystem3D<T, PARTICLETYPE>&,
                            std::string const,
                            unsigned short properties,
                            bool binary = true);
  SuperParticleSysVtuWriter(const SuperParticleSysVtuWriter<T, PARTICLETYPE>& rhs);
  SuperParticleSysVtuWriter(const SuperParticleSysVtuWriter<T, PARTICLETYPE>&& rhs);

  void write(int iT = 0);

  int numofpsys();

  void set(unsigned short);

  enum particleProperties
    : unsigned short {velocity = 1, radius = 2, mass = 4, force = 8, cuboid = 16, active = 32};

//private:
protected:
  ///  performes <VTKFile ...>, <ImageData ...> and <PieceExtent ...>
  void preambleVTU(const std::string& fullName);
  ///  performes </ImageData> and </VTKFile>
  void closeVTU(const std::string& fullNamePiece);
  ///  performes <VTKFile ...> and <Collection>
  void preamblePVD(const std::string& fullNamePVD);
  ///  performes </Collection> and </VTKFile>
  void closePVD(const std::string& fullNamePVD);
  ///  performes <DataSet timestep= ... file=namePiece />
  void dataPVD(int iT, int iR, const std::string& fullNamePVD,
               const std::string& namePiece);
  ///  performes <DataSet timestep= ... file=namePiece />
  void dataPVDmaster(int iT, int iR, const std::string& fullNamePVDMaster,
                     const std::string& namePiece);
  ///  writes functors stored at pointerVec
  void dataArray(const std::string& fullName);
  ///  writes functors stored at pointerVec
  void dataArrayBinary(const std::string& fullName);
  ///  performes <VTKFile...> and <ImageData ...>
  void preambleOneFile(const std::string& fullName);
  ///  writes instantaniously given functor, without adding to _pointerVec
  void writePieceToOneFile(const std::string& fullName);

  void createMasterFile();

//private:
protected:
  SuperParticleSystem3D<T, PARTICLETYPE>& _psys;
  std::string _name;
  unsigned short _properties;
  bool _binary;
  bool _haveMaster;
  mutable OstreamManager clout;

};

template<typename T>
class SuperParticleSysVtuWriterMag : public SuperParticleSysVtuWriter<T, MagneticParticle3D> {
public:
  const int pPropActive = 0;
  const int pPropCuboid = 1;
  const int pPropMass = 2;
  const int pPropRadius = 3;
  const int pPropVelocity = 4;
  const int pPropForce = 5;
  const int pPropAVel = 6;
  const int pPropTorque = 7;
  const int pPropMoment = 8;

  SuperParticleSysVtuWriterMag(SuperParticleSystem3D<T, MagneticParticle3D>&,
                               std::string const,
                               const std::bitset<9>& properties,
                               bool binary = true);
  SuperParticleSysVtuWriterMag(const SuperParticleSysVtuWriterMag<T>& rhs);
  SuperParticleSysVtuWriterMag(const SuperParticleSysVtuWriterMag<T>&& rhs);

  void write(int iT = 0);
  void set(int);

private:
  void dataArray(const std::string& fullName);
  void dataArrayBinary(const std::string& fullName);

  std::bitset<9> _properties;

};

}  // namespace OLB

#endif /* SUPERPARTICLESYSVTUOUT_H */