PeriDyno 1.0.0
Loading...
Searching...
No Matches
EigenValueWriter.cpp
Go to the documentation of this file.
1#include "EigenValueWriter.h"
2
3#include <sstream>
4#include <iostream>
5#include <fstream>
6#include <stdlib.h>
7
8namespace dyno
9{
11
12 template<typename TDataType>
17
18 template<typename TDataType>
22
23
24 template<typename TDataType>
26 {
27 auto path = this->varOutputPath()->getValue();
28
29 std::string filename = this->constructFileName() + std::string(".txt");
30 std::fstream output(filename.c_str(), std::ios::out);
31
32
33 int pNum = this->inTransform()->size();
34 output << pNum << ' ';
35
36 /*CArray<Coord> hPosition;
37 hPosition.resize(pNum);
38 hPosition.assign(this->inPosition()->getData());*/
39
41 tm.resize(pNum);
42 tm.assign(this->inTransform()->getData());
43
44 for (int i = 0; i < pNum; i++)
45 {
46 Vec3f dM = tm[i].scale();
47 Mat3f rM = tm[i].rotation();
48 Coord pos = tm[i].translation();
49 pos[1] += 21.37;
50
51 //Particle Position
52 char buf1[50], buf2[50], buf3[50];
53 sprintf(buf1, "%f", (double)pos[0]);
54 sprintf(buf2, "%f", (double)pos[1]);
55 sprintf(buf3, "%f", (double)pos[2]);
56 output << buf1 << ' ' << buf2 << ' ' << buf3 << ' ';
57
58 //Eigen Values
59 char d1[50], d2[50], d3[50];
60 sprintf(d1, "%f", (double)dM[0]);
61 sprintf(d2, "%f", (double)dM[1]);
62 sprintf(d3, "%f", (double)dM[2]);
63 output << d1 << ' ' << d2 << ' ' << d3 << ' ';
64
65 //Rotation Matrix
66 //v1
67 char v11[50], v12[50], v13[50];
68 sprintf(v11, "%f", (double)rM(0, 0));
69 sprintf(v12, "%f", (double)rM(1, 0));
70 sprintf(v13, "%f", (double)rM(2, 0));
71 output << v11 << ' ' << v12 << ' ' << v13 << ' ';
72
73 //v2
74 char v21[50], v22[50], v23[50];
75 sprintf(v21, "%f", (double)rM(0, 1));
76 sprintf(v22, "%f", (double)rM(1, 1));
77 sprintf(v23, "%f", (double)rM(2, 1));
78 output << v21 << ' ' << v22 << ' ' << v23 << ' ';
79
80 //v3
81 char v31[50], v32[50], v33[50];
82 sprintf(v31, "%f", (double)rM(0, 2));
83 sprintf(v32, "%f", (double)rM(1, 2));
84 sprintf(v33, "%f", (double)rM(2, 2));
85 output << v31 << ' ' << v32 << ' ' << v33 << ' ';
86 }
87
88 output.close();
89
90 }
91
93}
#define DEFINE_CLASS(name)
Definition Object.h:140
#define IMPLEMENT_TCLASS(name, T1)
Definition Object.h:103
std::string constructFileName()
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
SquareMatrix< float, 3 > Mat3f
Definition Matrix3x3.h:92
Vector< float, 3 > Vec3f
Definition Vector3D.h:93
Array< T, DeviceType::CPU > CArray
Definition Array.h:151