90 const char* ETSolid45 =
"60045";
91 const char* ETSolid92 =
"60042";
92 const char* ETSolid95 =
"60095";
97 const char* MATDefault =
"1";
100 std::ofstream node_file;
101 std::ofstream elem_file;
102 std::ofstream ans_file;
105 std::string temp_string;
106 std::string base_string;
107 base_string.assign( file_name );
108 base_string.replace( base_string.find_last_of(
".ans" ) - 3, 4,
"" );
111 temp_string = base_string +
".node";
112 node_file.open( temp_string.c_str() );
113 node_file.setf( std::ios::scientific, std::ios::floatfield );
114 node_file.precision( 13 );
117 temp_string = base_string +
".elem";
118 elem_file.open( temp_string.c_str() );
121 ans_file.open( file_name );
122 ans_file <<
"/prep7" << std::endl;
126 if( ent_handles && num_sets > 0 )
128 for(
int i = 0; i < num_sets; i++ )
151 for(
Range::iterator it = node_range.begin(); it != node_range.end(); ++it )
158 node_file.width( 8 );
160 node_file.width( 20 );
161 node_file << coord[0];
162 node_file.width( 20 );
163 node_file << coord[1];
164 node_file.width( 20 );
165 node_file << coord[2] << std::endl;
169 ans_file <<
"nread," << base_string <<
",node" << std::endl;
172 Range node_mesh_sets;
177 for(
Range::iterator ns_it = node_mesh_sets.begin(); ns_it != node_mesh_sets.end(); ++ns_it )
181 std::vector< EntityHandle > node_vector;
185 for( std::vector< EntityHandle >::iterator node_it = node_vector.begin(); node_it != node_vector.end();
189 if( node_it == node_vector.begin() )
192 ans_file <<
"nsel,s,node,," << std::setw( 8 ) << ns_node_id << std::endl;
197 ans_file <<
"nsel,a,node,," << std::setw( 8 ) << ns_node_id << std::endl;
201 ans_file <<
"cm,NS" << ns_id <<
",node" << std::endl;
219 for(
Range::iterator elem_it = tet_range.begin(); elem_it != tet_range.end(); ++elem_it )
223 std::vector< EntityHandle > conn;
227 if( conn.size() != 4 && conn.size() != 10 )
229 std::cout <<
"Support not added for element type. \n";
233 if( conn.size() == 4 )
235 elem_file << std::setw( 8 ) << conn[0] << std::setw( 8 ) << conn[1];
236 elem_file << std::setw( 8 ) << conn[2] << std::setw( 8 ) << conn[2];
237 elem_file << std::setw( 8 ) << conn[3] << std::setw( 8 ) << conn[3];
238 elem_file << std::setw( 8 ) << conn[3] << std::setw( 8 ) << conn[3];
240 elem_file << std::setw( 8 ) << MATDefault << std::setw( 8 ) << ETSolid45;
241 elem_file << std::setw( 8 ) <<
"1" << std::setw( 8 ) <<
"1";
242 elem_file << std::setw( 8 ) <<
"0" << std::setw( 8 ) << elem_id;
243 elem_file << std::endl;
247 if( conn.size() == 10 )
249 elem_file << std::setw( 8 ) << conn[0] << std::setw( 8 ) << conn[1];
250 elem_file << std::setw( 8 ) << conn[2] << std::setw( 8 ) << conn[3];
251 elem_file << std::setw( 8 ) << conn[4] << std::setw( 8 ) << conn[5];
252 elem_file << std::setw( 8 ) << conn[6] << std::setw( 8 ) << conn[7];
254 elem_file << std::setw( 8 ) << MATDefault << std::setw( 8 ) << ETSolid92;
255 elem_file << std::setw( 8 ) <<
"1" << std::setw( 8 ) <<
"1";
256 elem_file << std::setw( 8 ) <<
"0" << std::setw( 8 ) << elem_id;
257 elem_file << std::endl;
259 elem_file << std::setw( 8 ) << conn[8] << std::setw( 8 ) << conn[9];
260 elem_file << std::endl;
268 for(
Range::iterator elem_it = hex_range.begin(); elem_it != hex_range.end(); ++elem_it )
272 std::vector< EntityHandle > conn;
276 if( conn.size() != 8 && conn.size() != 20 )
278 std::cout <<
"Support not added for element type. \n";
283 if( conn.size() == 8 )
285 elem_file << std::setw( 8 ) << conn[0] << std::setw( 8 ) << conn[1];
286 elem_file << std::setw( 8 ) << conn[2] << std::setw( 8 ) << conn[3];
287 elem_file << std::setw( 8 ) << conn[4] << std::setw( 8 ) << conn[5];
288 elem_file << std::setw( 8 ) << conn[6] << std::setw( 8 ) << conn[7];
290 elem_file << std::setw( 8 ) << MATDefault << std::setw( 8 ) << ETSolid45;
291 elem_file << std::setw( 8 ) <<
"1" << std::setw( 8 ) <<
"1";
292 elem_file << std::setw( 8 ) <<
"0" << std::setw( 8 ) << elem_id;
293 elem_file << std::endl;
297 if( conn.size() == 20 )
300 elem_file << std::setw( 8 ) << conn[4] << std::setw( 8 ) << conn[5];
301 elem_file << std::setw( 8 ) << conn[1] << std::setw( 8 ) << conn[0];
302 elem_file << std::setw( 8 ) << conn[7] << std::setw( 8 ) << conn[6];
303 elem_file << std::setw( 8 ) << conn[2] << std::setw( 8 ) << conn[3];
305 elem_file << std::setw( 8 ) << MATDefault << std::setw( 8 ) << ETSolid95;
306 elem_file << std::setw( 8 ) <<
"1" << std::setw( 8 ) <<
"1";
307 elem_file << std::setw( 8 ) <<
"0" << std::setw( 8 ) << elem_id;
308 elem_file << std::endl;
310 elem_file << std::setw( 8 ) << conn[16] << std::setw( 8 ) << conn[13];
311 elem_file << std::setw( 8 ) << conn[8] << std::setw( 8 ) << conn[12];
312 elem_file << std::setw( 8 ) << conn[18] << std::setw( 8 ) << conn[14];
313 elem_file << std::setw( 8 ) << conn[10] << std::setw( 8 ) << conn[15];
314 elem_file << std::setw( 8 ) << conn[19] << std::setw( 8 ) << conn[17];
315 elem_file << std::setw( 8 ) << conn[9] << std::setw( 8 ) << conn[11];
316 elem_file << std::endl;
323 for(
Range::iterator elem_it = prism_range.begin(); elem_it != prism_range.end(); ++elem_it )
327 std::vector< EntityHandle > conn;
331 if( conn.size() != 6 )
333 std::cout <<
"Support not added for element type. \n";
338 if( conn.size() == 6 )
340 elem_file << std::setw( 8 ) << conn[0] << std::setw( 8 ) << conn[3];
341 elem_file << std::setw( 8 ) << conn[4] << std::setw( 8 ) << conn[4];
342 elem_file << std::setw( 8 ) << conn[1] << std::setw( 8 ) << conn[2];
343 elem_file << std::setw( 8 ) << conn[5] << std::setw( 8 ) << conn[5];
345 elem_file << std::setw( 8 ) << MATDefault << std::setw( 8 ) << ETSolid45;
346 elem_file << std::setw( 8 ) <<
"1" << std::setw( 8 ) <<
"1";
347 elem_file << std::setw( 8 ) <<
"0" << std::setw( 8 ) << elem_id;
348 elem_file << std::endl;
353 ans_file <<
"et," << ETSolid45 <<
",SOLID45" << std::endl;
354 ans_file <<
"et," << ETSolid92 <<
",SOLID92" << std::endl;
355 ans_file <<
"et," << ETSolid95 <<
",SOLID95" << std::endl;
360 ans_file <<
"eread," << base_string <<
",elem" << std::endl;
363 Range side_mesh_sets;
368 for(
Range::iterator ss_it = side_mesh_sets.begin(); ss_it != side_mesh_sets.end(); ++ss_it )
372 std::vector< EntityHandle > elem_vector;
377 for( std::vector< EntityHandle >::iterator elem_it = elem_vector.begin(); elem_it != elem_vector.end();
383 std::vector< EntityHandle > conn;
386 if( elem_it == elem_vector.begin() )
388 ans_file <<
"nsel,s,node,," << std::setw( 8 ) << conn[0] << std::endl;
389 for(
unsigned int i = 1; i < conn.size(); i++ )
391 ans_file <<
"nsel,a,node,," << std::setw( 8 ) << conn[i] << std::endl;
396 for(
unsigned int i = 0; i < conn.size(); i++ )
398 ans_file <<
"nsel,a,node,," << std::setw( 8 ) << conn[i] << std::endl;
403 ans_file <<
"cm,SS" << ss_id <<
",node" << std::endl;
412 for(
Range::iterator mat_it = matset.begin(); mat_it != matset.end(); ++mat_it )
417 std::vector< EntityHandle > mat_vector;
421 for( std::vector< EntityHandle >::iterator elem_it = mat_vector.begin(); elem_it != mat_vector.end();
426 if( elem_it == mat_vector.begin() )
428 ans_file <<
"esel,s,elem,," << std::setw( 8 ) << elem_id << std::endl;
432 ans_file <<
"esel,a,elem,," << std::setw( 8 ) << elem_id << std::endl;
436 ans_file <<
"cm,EB" << mat_id <<
",elem" << std::endl;