39 #include "../MeshElements.h"
49 "Reads Swansea plt format for third-order tetrahedra.");
66 vector<vector<NodeSharedPtr> > elementList;
67 vector<int> tmp, tets;
72 cout <<
"InputSwan: Start reading file..." << endl;
82 m_mshFile.read(reinterpret_cast<char*>(&tmp[0]),
83 static_cast<int> (6*
sizeof(
int)));
85 if (tmp[0] != tmp[5] || tmp[0] != 4*
sizeof(
int))
87 cout <<
"Header data broken" << endl;
93 int NB_Points = tmp[2];
94 int GridOrder = tmp[4];
95 int ND = (GridOrder+1)*(GridOrder+2)*(GridOrder+3)/6;
97 cout <<
"NB_Tet = " << NB_Tet << endl;
98 cout <<
"NB_Points = " << NB_Points << endl;
99 cout <<
"GridOrder = " << GridOrder << endl;
100 cout <<
"ND = " << ND << endl;
105 tets.resize(ND*NB_Tet+2);
106 m_mshFile.read(reinterpret_cast<char*>(&tets[0]),
107 static_cast<int> ((ND*NB_Tet+2)*
sizeof(
int)));
109 if (tets[0] != tets[ND*NB_Tet+1] || tets[0] != ND*NB_Tet*
sizeof(
int))
111 cout <<
"ERROR [InputSwan]: Tetrahedron data broken." << endl;
118 pts.resize(3*NB_Points);
119 m_mshFile.read(reinterpret_cast<char*>(&tmp[0]),
120 static_cast<int> (
sizeof(
int)));
121 m_mshFile.read(reinterpret_cast<char*>(&pts[0]),
122 static_cast<int> (3*NB_Points*
sizeof(
double)));
123 m_mshFile.read(reinterpret_cast<char*>(&tmp[1]),
124 static_cast<int> (
sizeof(
int)));
126 if (tmp[0] != tmp[1] || tmp[0] != 3*NB_Points*
sizeof(
double))
128 cout <<
"ERROR [InputSwan]: Point data broken." << endl;
137 for (i = 0; i < NB_Points; ++i)
140 double y = pts [1*NB_Points+i];
141 double z = pts [2*NB_Points+i];
142 m_mesh->m_node.push_back(boost::shared_ptr<Node>(
new Node(vid, x, y, z)));
148 for (i = 0; i < NB_Tet; ++i)
150 vector<NodeSharedPtr> nodeList;
151 for (j = 0; j < 20; ++j)
153 int vid = tets[j*NB_Tet+i+1];
154 nodeList.push_back(
m_mesh->m_node[vid-1]);
159 tags.push_back(elType);
163 CreateInstance(elType,conf,nodeList,tags);
164 m_mesh->m_element[3].push_back(E);
170 m_mshFile.read(reinterpret_cast<char*>(&tmp[0]),
171 static_cast<int> (
sizeof(
int)));
172 int n_tri = tmp[0]/
sizeof(int)/5;
173 tets.resize(n_tri*5);
174 m_mshFile.read(reinterpret_cast<char*>(&tets[0]),
175 static_cast<int> (tmp[0]));
176 m_mshFile.read(reinterpret_cast<char*>(&tmp[1]),
177 static_cast<int> (
sizeof(
int)));
179 if (tmp[0] != tmp[1])
181 cout <<
"ERROR [InputSwan]: Surface data broken." << endl;
189 for (i = 0; i < n_tri; ++i)
191 vector<NodeSharedPtr> nodeList;
193 for (j = 0; j < 3; ++j)
195 nodeList.push_back(
m_mesh->m_node[tets[i+j*n_tri]-1]);
200 tags.push_back(elType);
204 CreateInstance(elType,conf,nodeList,tags);
205 m_mesh->m_element[2].push_back(E);
pair< ModuleType, string > ModuleKey
MeshSharedPtr m_mesh
Mesh object.
virtual void ProcessEdges(bool ReprocessEdges=true)
Extract element edges.
boost::shared_ptr< Element > ElementSharedPtr
Shared pointer to an element.
virtual void ProcessVertices()
Extract element vertices.
virtual void ProcessElements()
Generate element IDs.
boost::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
Basic information about an element.
virtual void ProcessComposites()
Generate composites.
Represents a point in the domain.
virtual void ProcessFaces(bool ReprocessFaces=true)
Extract element faces.
ElementFactory & GetElementFactory()
ModuleFactory & GetModuleFactory()
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.