-
Notifications
You must be signed in to change notification settings - Fork 0
/
gid_marker.hpp
executable file
·148 lines (140 loc) · 4.88 KB
/
gid_marker.hpp
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
139
140
141
142
143
144
145
146
147
148
/*
ver.03.03
file gid_marker.hpp
*/
#include "gid.h"
#include "marker.h"
class Gid_marker:public Gid{
public:
template<class Elem_type,class Material_type>
Gid_marker(
std::vector<Dof*>& vdof,
unsigned& num_dof_dirichlet,
unsigned& num_dof_nond,
MATRIX& T,
string projectname,
std::vector<Elem_type*>& elem_buffer,
Material_type* front_material,
const unsigned DIM,
const unsigned NODE_IN_ELEM,
const unsigned NUM_GP,
Markers_handler*& markers_handler,
Material_type* back_material
):
PrePostProcessor(vdof,num_dof_dirichlet,num_dof_nond,T,projectname,DIM,NODE_IN_ELEM,NUM_GP),
Gid(vdof,num_dof_dirichlet,num_dof_nond,T,projectname,elem_buffer,back_material,DIM,NODE_IN_ELEM,NUM_GP),
markers_handler(markers_handler)
{
ostringstream marker_file;
marker_file <<
PATH <<
projectname << "-marker.gid/" <<
projectname << "-marker.dat";
marker_file_out <<
PATH <<
projectname << "-marker.gid/" <<
projectname << "-marker.post.res";
Element::Up_cast(velements,elem_buffer);
markers_handler=new Markers_handler(
marker_file,
elem_buffer,
front_material
);
};
virtual ~Gid_marker(){
if(markers_handler)
delete markers_handler;
};
void save_result(unsigned loadstep){
m_result.str("");
//parent
Gid::save_result(loadstep);
Gid::gid_result<Element_marker>(Gid::m_result,loadstep,"marker weight",&Element_marker::get_weight,velements);
Gid::gid_result<Element_marker>(Gid::m_result,loadstep,"num marker",&Element_marker::get_num_marker,velements);
gid_result(m_result,loadstep,"displacement",&Marker::getDisplacement);
gid_result(m_result,loadstep,"stress_xx",&Marker::getStress,0,0);
gid_result(m_result,loadstep,"stress_xy",&Marker::getStress,0,1);
gid_result(m_result,loadstep,"stress_xz",&Marker::getStress,0,2);
gid_result(m_result,loadstep,"stress_yy",&Marker::getStress,1,1);
gid_result(m_result,loadstep,"stress_yz",&Marker::getStress,1,2);
gid_result(m_result,loadstep,"stress_zz",&Marker::getStress,2,2);
gid_result(m_result,loadstep,"deform_xx",&Marker::getStrain,0,0);
gid_result(m_result,loadstep,"deform_xy",&Marker::getStrain,0,1);
gid_result(m_result,loadstep,"deform_xz",&Marker::getStrain,0,2);
gid_result(m_result,loadstep,"deform_yx",&Marker::getStrain,1,0);
gid_result(m_result,loadstep,"deform_yy",&Marker::getStrain,1,1);
gid_result(m_result,loadstep,"deform_yz",&Marker::getStrain,1,2);
gid_result(m_result,loadstep,"deform_zx",&Marker::getStrain,2,0);
gid_result(m_result,loadstep,"deform_zy",&Marker::getStrain,2,1);
gid_result(m_result,loadstep,"deform_zz",&Marker::getStrain,2,2);
gid_result<int>(m_result,loadstep,"parent_elem",&Marker::get_parent);
gid_result<double>(m_result,loadstep,"potential",&Marker::getPotential);
};
void post_process(unsigned loadstep){
using std::endl;
Gid::post_process(loadstep);
ofstream fout;
static bool isfirst=true;
if(isfirst){
isfirst=false;
fout.open(marker_file_out.str().c_str());
fout << "GiD Post Results File 1.0" <<endl<<endl;
fout << "GaussPoints \"gauss_points\" ElemType " << gid_elemtype << endl;
fout << "Number of Gauss Points: 1" << endl;
fout << "Nodes not included" << endl;
fout << "Natural Coordinates: Internal" << endl;
fout << "End Gausspoints" << endl;
}else{
fout.open(marker_file_out.str().c_str(),std::ios::app);
}
fout << m_result.str();
};
private:
void gid_result(ostream& fout,unsigned loadstep,string name,double (Marker::*func)(unsigned)const){
using std::endl;
fout << "Result \"" << name << "\" \"FEM\" ";
fout << loadstep << " ";
fout << "Vector OnNodes" << endl;
fout << "Values" <<endl;
for(unsigned i=0;i<markers_handler->num_markers;i++){
fout << (i+1) << "\t";
for(unsigned j=0;j<DIM;j++){
fout << ((*markers_handler)(i)->*func)(j) << " ";
}
fout<<endl;
}
fout << "End Values" <<endl;
};
void gid_result(ostream& fout,unsigned loadstep,string name,double (Marker::*func)(unsigned,unsigned)const,unsigned i_,unsigned j_){
using std::endl;
fout << "Result \"" << name << "\" \"FEM\" ";
fout << loadstep << " ";
fout << "Scalar OnNodes" << endl;
fout << "Values" <<endl;
for(unsigned i=0;i<markers_handler->num_markers;i++){
fout << (i+1) << "\t";
fout << ((*markers_handler)(i)->*func)(i_,j_) << " ";
fout << endl;
}
fout << "End Values" <<endl;
};
template<class Type>
void gid_result(ostream& fout,unsigned loadstep,string name,Type (Marker::*func)(void)const){
using std::endl;
fout << "Result \"" << name << "\" \"FEM\" ";
fout << loadstep << " ";
fout << "Scalar OnNodes" << endl;
fout << "Values" <<endl;
for(unsigned i=0;i<markers_handler->num_markers;i++){
fout << (i+1) << "\t";
fout << ((*markers_handler)(i)->*func)() << " ";
fout<<endl;
}
fout << "End Values" <<endl;
};
private:
std::vector<Element_marker*> velements;
ostringstream marker_file_out;
Markers_handler*& markers_handler;
ostringstream m_result;
};