12 #include "primitive_utilities.H"
14 class T3DGeomEnt :
public std::pair<unsigned int,unsigned int>
21 this->first = ing.first;
22 this->second = ing.second;
26 this->first = ing.first;
27 this->second = ing.second;
31 first > ge.first ?
false : second < ge.second); };
37 main(
int argc,
char *argv[])
40 std::istringstream Istr;
41 unsigned int mesh_type = 0;
42 unsigned int elem_order = 0;
43 unsigned int nnodes = 0;
44 unsigned int nedges = 0;
45 unsigned int ntris = 0;
46 unsigned int nquads = 0;
47 unsigned int ntets = 0;
48 unsigned int nhexs = 0;
49 unsigned int npyrs = 0;
50 unsigned int npriss = 0;
54 std::getline(std::cin,line);
56 Istr >> mesh_type >> elem_order;
57 std::getline(std::cin,line);
59 Istr >> nnodes >> nedges;
62 Istr >> ntris >> ntets;
65 Istr >> nquads >> nhexs;
68 Istr >> ntris >> nquads >> ntets >> npyrs >> npriss >> nhexs;
71 std::cerr <<
"Fatal Error: Unsupported mesh type, "
72 << mesh_type <<
"." << std::endl;
77 std::getline(std::cin,line);
81 unsigned int n_2d_elem = ntris + nquads;
82 unsigned int n_3d_elem = ntets + npyrs + npriss + nhexs;
83 if(n_2d_elem > 0 && n_3d_elem > 0){
84 std::cerr <<
"Fatal Error: Mixing 2d and 3d elements not supported at this time."
88 nelems = n_2d_elem > 0 ? n_2d_elem : n_3d_elem;
90 std::cout << nnodes << std::endl;
93 std::ofstream PropOut;
94 std::list<T3DGeomEnt> geomlist;
95 std::list<int> nodal_properties;
96 std::list<int> elemental_properties;
97 std::vector<T3DGeomEnt> nodal_geoms(nnodes);
98 std::vector<T3DGeomEnt> elem_geoms(nelems);
99 for(
unsigned int i = 0;
i < nnodes;
i++){
101 std::getline(std::cin,line);
105 Istr >> superfluous_id;
108 std::cout << x <<
"\t" << y <<
"\t" << z << std::endl;
110 Istr >> nodal_geoms[
i].first >> nodal_geoms[
i].second >> property;
115 nodal_properties.push_back(property);
119 std::getline(std::cin,line);
120 std::cout << nelems << std::endl;
124 std::cerr <<
"Warning: skipping edges." << std::endl;
125 for(
unsigned int i = 0;
i < nedges;
i++)
126 std::getline(std::cin,line);
127 std::getline(std::cin,line);
131 if(mesh_type != 4 && ntris > 0){
132 for(
unsigned int i = 0;
i < ntris;
i++){
133 std::getline(std::cin,line);
134 std::string::size_type xpos = line.find_first_not_of(
" ");
135 line = line.substr(xpos);
138 unsigned int superfluous_id;
139 Istr >> superfluous_id;
140 unsigned int node_id;
141 for(
unsigned int j = 0;
j < elem_order*3;
j++){
143 std::cout << node_id;
144 if(
j != (elem_order*3 - 1)) std::cout <<
"\t";
146 std::cout << std::endl;
148 Istr >> elem_geoms[
i].first >> elem_geoms[
i].second >> property;
149 elemental_properties.push_back(property);
155 std::getline(std::cin,line);
160 if(mesh_type != 3 && nquads > 0){
161 for(
unsigned int i = 0;
i < nquads;
i++){
162 std::getline(std::cin,line);
163 std::string::size_type xpos = line.find_first_not_of(
" ");
164 line = line.substr(xpos);
167 unsigned int superfluous_id;
168 Istr >> superfluous_id;
169 unsigned int node_id;
170 for(
unsigned int j = 0;
j < elem_order*4;
j++){
172 std::cout << node_id;
173 if(
j != (elem_order*4 - 1)) std::cout <<
"\t";
175 std::cout << std::endl;
177 Istr >> elem_geoms[
i+egoffset].first >> elem_geoms[
i+egoffset].second >> property;
178 elemental_properties.push_back(property);
180 std::getline(std::cin,line);
184 if(mesh_type != 4 && ntets > 0){
185 unsigned int elem_size = elem_order==1 ? 4 : 10;
186 for(
unsigned int i = 0;
i < ntets;
i++){
187 std::getline(std::cin,line);
188 std::string::size_type xpos = line.find_first_not_of(
" ");
189 line = line.substr(xpos);
192 unsigned int superfluous_id;
193 Istr >> superfluous_id;
194 unsigned int node_id;
195 for(
unsigned int j = 0;
j < elem_size;
j++){
197 std::cout << node_id;
198 if(
j != (elem_size - 1)) std::cout <<
"\t";
200 std::cout << std::endl;
202 Istr >> elem_geoms[
i+egoffset].first >> elem_geoms[
i+egoffset].second >> property;
203 elemental_properties.push_back(property);
205 std::getline(std::cin,line);
209 if(mesh_type == 7 && npyrs > 0){
210 unsigned int elem_size = elem_order==1 ? 5 : 8;
211 for(
unsigned int i = 0;
i < npyrs;
i++){
212 std::getline(std::cin,line);
213 std::string::size_type xpos = line.find_first_not_of(
" ");
214 line = line.substr(xpos);
217 unsigned int superfluous_id;
218 Istr >> superfluous_id;
219 unsigned int node_id;
220 for(
unsigned int j = 0;
j < elem_size;
j++){
222 std::cout << node_id;
223 if(
j != (elem_size - 1)) std::cout <<
"\t";
225 std::cout << std::endl;
227 Istr >> elem_geoms[
i+egoffset].first >> elem_geoms[
i+egoffset].second >> property;
228 elemental_properties.push_back(property);
230 std::getline(std::cin,line);
236 if(mesh_type == 7 && npriss > 0){
237 unsigned int elem_size = elem_order==1 ? 6 : 15;
238 for(
unsigned int i = 0;
i < npriss;
i++){
239 std::getline(std::cin,line);
240 std::string::size_type xpos = line.find_first_not_of(
" ");
241 line = line.substr(xpos);
244 unsigned int superfluous_id;
245 Istr >> superfluous_id;
246 unsigned int node_id;
247 for(
unsigned int j = 0;
j < elem_size;
j++){
249 std::cout << node_id;
250 if(
j != (elem_size - 1)) std::cout <<
"\t";
252 std::cout << std::endl;
254 Istr >> elem_geoms[
i+egoffset].first >> elem_geoms[
i+egoffset].second >> property;
255 elemental_properties.push_back(property);
257 std::getline(std::cin,line);
261 if(mesh_type != 3 && nhexs > 0){
262 unsigned int elem_size = elem_order==1 ? 8 : 20;
263 for(
unsigned int i = 0;
i < nhexs;
i++){
264 std::getline(std::cin,line);
265 std::string::size_type xpos = line.find_first_not_of(
" ");
266 line = line.substr(xpos);
269 unsigned int superfluous_id;
270 Istr >> superfluous_id;
271 unsigned int node_id;
272 for(
unsigned int j = 0;
j < elem_size;
j++){
274 std::cout << node_id;
275 if(
j != (elem_size - 1)) std::cout <<
"\t";
277 std::cout << std::endl;
279 Istr >> elem_geoms[
i+egoffset].first >> elem_geoms[
i+egoffset].second >> property;
280 elemental_properties.push_back(property);
282 std::getline(std::cin,line);
287 std::vector<T3DGeomEnt>::iterator gi = nodal_geoms.begin();
288 while(gi != nodal_geoms.end()){
289 std::list<T3DGeomEnt>::iterator gli = std::find(geomlist.begin(),geomlist.end(),*gi);
290 if(gli == geomlist.end()){
291 geomlist.push_back(*gi);
295 gi = elem_geoms.begin();
296 while(gi != elem_geoms.end())
298 std::list<T3DGeomEnt>::iterator gli = std::find(geomlist.begin(),geomlist.end(),*gi);
299 if(gli == geomlist.end())
300 geomlist.push_back(*gi);
304 std::list<T3DGeomEnt>::iterator gli = geomlist.begin();
305 std::cerr <<
"GEOMETRIES:" << std::endl;
306 while(gli != geomlist.end())
308 std::cerr <<
"Dimension: " << gli->first <<
", Id = " << gli->second << std::endl;
319 std::vector<Mesh::GeometricEntity> geometries(ngeoms);
320 std::vector<T3DGeomEnt> t3d_geovec(ngeoms);
321 gli = geomlist.begin();
322 while(gli != geomlist.end()){
323 ubyte dim = (gli->first == 1 ? 0 :
324 gli->first == 2 ? 1 :
325 gli->first == 3 ? 2 :
326 gli->first == 4 ? 3 :
327 gli->first == 5 ? 2 :
328 gli->first == 6 ? 2 :
331 std::cerr <<
"Error: Cannot deal with interface mesh type"
335 std::ostringstream Ostr;
337 Ostr <<
"Vertex-" << ++nvertex;
339 Ostr <<
"Curve-" << ++ncurve;
341 Ostr <<
"Surface-" << ++nsurf;
343 Ostr <<
"Region-" << ++nregion;
345 t3d_geovec[index] = *gli;
346 geometries[index].first = Ostr.str();
347 geometries[index].second = dim;
348 geometries[index]._collections.resize((
unsigned int)dim+1);
352 std::cerr <<
"Geometries created, populating..." << std::endl;
353 gi = nodal_geoms.begin();
355 std::cerr <<
" populating nodal geoms..." << std::endl;
356 PropOut.open(
"t3d_properties");
357 std::list<int>::iterator
pi = nodal_properties.begin();
358 while(gi != nodal_geoms.end()){
359 Mesh::IndexType gindex = std::find(t3d_geovec.begin(),t3d_geovec.end(),*gi++) -
361 geometries[gindex]._collections[0].push_back(nid++);
362 PropOut << gindex+1 <<
"\t" << *pi++ << std::endl;
365 PropOut << std::endl;
366 gi = elem_geoms.begin();
367 pi = elemental_properties.begin();
368 std::cerr <<
" populating elemental geoms..." << std::endl;
370 while(gi != elem_geoms.end()){
371 Mesh::IndexType gindex = std::find(t3d_geovec.begin(),t3d_geovec.end(),*gi++) -
373 geometries[gindex]._collections[geometries[gindex].second].push_back(eid++);
374 PropOut << gindex+1 <<
"\t" << *pi++ << std::endl;
377 std::ofstream GeomOut;
378 GeomOut.open(
"t3d_geometries");
379 GeomOut << geometries.size() << std::endl;
381 GeomOut << geometries[gindex].first <<
"\t"
382 << (uint)geometries[gindex].second << std::endl;
384 GeomOut << geometries[gindex] << std::endl;
bool operator<(const T3DGeomEnt &ge) const
void int int REAL REAL * y
void int int int REAL REAL REAL * z
const T3DGeomEnt & operator=(const T3DGeomEnt &ing)
int main(int argc, char *argv[])
bool operator==(const T3DGeomEnt &ge) const
IRAD::Primitive::IndexType IndexType
T3DGeomEnt(const T3DGeomEnt &ing)