MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SuperQuadricParticleVtkWriter.cc
Go to the documentation of this file.
1 //Copyright (c) 2013-2020, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 
28 #include "DPMBase.h"
29 
31 {
32  std::fstream file = makeVTKFileWithHeader();
33  file << "<Piece NumberOfPoints=\"" << handler_.getSize() << "\" NumberOfCells=\"" << 0 << "\">\n";
34  writeVTKPositions(file);
35  file << "<PointData Scalars=\"speciesType\" Vectors=\"axesScales\" Tensors=\"orientationTensor\">\n";
36  writeVTKIndSpecies(file);
38  writeVTKOrientation(file);
39  file << "</PointData>\n";
41 }
42 
44 {
45  file << " <DataArray type=\"Float32\" Name=\"orientationTensor\" NumberOfComponents=\"9\" format=\"ascii\">\n";
46  // Add orientationTensor
47  for (const auto& p: handler_)
48  {
50  p->getOrientation().getRotationMatrix(A);
51  file << '\t';
52  for (unsigned i = 0; i < 3; ++i)
53  {
54  for (unsigned j = 0; j < 3; ++j)
55  {
56  file << A(i, j) << " ";
57  }
58  }
59  file << '\n';
60  }
61  file << " </DataArray>\n";
62 }
63 
65 {
66  file << " <DataArray type=\"Float32\" Name=\"phiAndTheta\" NumberOfComponents=\"2\" format=\"ascii\">\n";
67  // Add exponents eps1 and eps2. Note, they are defined in reverse order in Paraview!
68  for (const auto& p: handler_)
69  {
70  file << '\t' << p->getExponentEps2() << " " << p->getExponentEps1() << '\n';
71  }
72  file << " </DataArray>\n";
73  file << " <DataArray type=\"Float32\" Name=\"axesScales\" NumberOfComponents=\"3\" format=\"ascii\">\n";
74  // Add axesScales
75  for (const auto& p: handler_)
76  {
77  file << '\t' << 2 * p->getAxes() << '\n';
78  }
79  file << " </DataArray>\n";
80 }
void writeVTKPositions(std::fstream &file) const
void writeVTKOrientation(std::fstream &file) const
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
void writeVTKIndSpecies(std::fstream &file) const
ParticleHandler & handler_
particle handler from which the particles should be written
Definition: BaseVTKWriter.h:72
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
std::fstream makeVTKFileWithHeader() const
void writeVTKFooterAndClose(std::fstream &file) const
void writeVTKSuperquadricGeometry(std::fstream &file) const
Data type for small dense matrix.
Definition: SmallMatrix.h:67