Changeset 3284
- Timestamp:
- 11/05/09 14:23:10 (3 weeks ago)
- Files:
-
- 1 modified
-
MeshKit/trunk/sixth.cpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
MeshKit/trunk/sixth.cpp
r3239 r3284 96 96 std::vector<std::string> &files, 97 97 std::vector<int> &assy_types, 98 std::string &outfile); 98 std::string &outfile, bool &global_ids); 99 100 int read_input_defaults(int &nrings, int &pack_type, double &pitch, int &symm, 101 bool &back_mesh, 102 std::vector<std::string> &files, 103 std::vector<int> &assy_types, 104 std::string &outfile, bool &global_ids); 99 105 100 106 int del_orig_mesh(std::vector<iBase_EntitySetHandle> &assys, … … 103 109 int main(int argc, char **argv) 104 110 { 111 int test_flag; 112 if (1 == argc) { 113 test_flag = 1; 114 } 105 115 // make a mesh instance 106 116 int err; … … 119 129 bool back_mesh; 120 130 std::string outfile; 121 err = read_input(nrings, pack_type, pitch, symm, back_mesh, 122 files, assy_types, outfile); 131 bool global_ids; 132 if (test_flag == 1){ 133 err = read_input_defaults(nrings, pack_type, pitch, symm, back_mesh, 134 files, assy_types, outfile, global_ids); 123 135 ERRORR("Couldn't parse input.", err); 124 136 } 137 else{ 138 err = read_input(nrings, pack_type, pitch, symm, back_mesh, 139 files, assy_types, outfile, global_ids); 140 ERRORR("Couldn't parse input.", err); 141 } 125 142 std::vector<iBase_EntitySetHandle> assys; 126 143 iBase_EntitySetHandle orig_set; … … 152 169 &ents, &ents_alloc, &ents_size, &err); 153 170 ERRORR("Trouble getting entities for merge.", err); 154 171 172 const double merge_tol = 1.0e-8; 173 const int do_merge = 1; 174 const int update_sets= 0; 175 iBase_TagHandle merge_tag = NULL; 155 176 int num1, num2; 156 177 iMesh_getNumOfType(impl, root_set, iBase_VERTEX, &num1, &err); 157 178 ERRORR("Trouble getting number of entities before merge.", err); 158 179 159 err = mm->merge_entities(ents, ents_size, 1.0e-7); 180 err = mm->merge_entities(ents, ents_size, merge_tol, 181 do_merge, update_sets,merge_tag); 160 182 ERRORR("Trouble merging entities.", err); 161 183 … … 165 187 std::cout << "Merged " << num1 - num2 << " vertices." << std::endl; 166 188 189 // assign new global ids 190 if (global_ids == true){ 191 std::cout << "Assigning global ids." << std::endl; 192 MKUtils mu(impl); 193 err = mu.assign_global_ids(root_set, 3, 1, true, false, 194 "GLOBAL_ID"); 195 ERRORR("Error assigning global ids.", err); 196 } 197 198 // export 167 199 iMesh_save(impl, root_set, outfile.c_str(), NULL, &err, 168 200 strlen(outfile.c_str()), 0); 169 201 ERRORR("Trouble writing output mesh.", err); 170 202 std::cout << "Saved: "<< outfile.c_str() <<std::endl; 171 203 return iBase_SUCCESS; 172 204 } … … 209 241 iBase_EntityHandle *new_ents; 210 242 int new_ents_alloc, new_ents_size; 211 int err; 212 243 int err; 213 244 int i = 0; 214 245 for (int n1 = 0; n1 < nrings; n1++) { … … 222 253 new_ents = NULL; 223 254 new_ents_alloc = 0; 224 225 255 err = cm->copy_move_entities(assys[assy_types[i]], dx, 226 256 &new_ents, &new_ents_alloc, &new_ents_size, … … 239 269 std::vector<std::string> &files, 240 270 std::vector<int> &assy_types, 241 std::string &outfile )271 std::string &outfile, bool &global_ids) 242 272 { 243 273 std::cout << "Nrings: "; … … 285 315 else 286 316 back_mesh = false; 317 318 std::cout << "New global ids (y/n)?" << std::endl; 319 scanf("%s", filename); 320 if (filename[0] == 'y' || filename[0] == 'Y') { 321 scanf("%s", filename); 322 global_ids = true; 323 } 324 else 325 global_ids = false; 287 326 } 288 327 … … 294 333 return iBase_SUCCESS; 295 334 } 335 336 337 int read_input_defaults(int &nrings, int &pack_type, double &pitch, int &symm, 338 bool &back_mesh, 339 std::vector<std::string> &files, 340 std::vector<int> &assy_types, 341 std::string &outfile, bool &global_ids) 342 { 343 std::cout << "Using defaults for running sixth program \n Usage: sixth <any_character> for user defined inputs"; 344 nrings = 3; 345 std::cout << "\n\n----Inputs to Sixth Program----\n\nNrings: " << nrings; 346 pack_type = 1; 347 std::cout << "\nPacking type: 1 (for Assembly) 0 (for Unit Cell Duct)"; 348 std::cout << "\nUsing packing type: " << pack_type; 349 pitch = 14.685; 350 std::cout << "\nPitch: "<< pitch; 351 symm = 6; 352 std::cout << "\n1/Symmetry: " << symm; 353 354 355 // ASSY_TYPES is setup as default case 356 if (UNITCELL_DUCT == pack_type) { 357 std::string filename; 358 std::cout << "\nUnit cell file: "; std::cin >> filename; files.push_back(filename); 359 std::cout << "\nDuct file: "; std::cin >> filename; files.push_back(filename); 360 back_mesh = true; 361 } 362 else if (ASSY_TYPES == pack_type) { 363 std::cout << "\nNo. of assembly types = 2"; //both types are pin1.cub 364 //manually enter nrings(nrings+1)/2 assy types 365 assy_types.push_back(0); 366 assy_types.push_back(1); 367 assy_types.push_back(0); 368 369 // get the number of assy types then read that many filenames 370 std::set<int> all_assys; 371 for (std::vector<int>::iterator vit = assy_types.begin(); 372 vit != assy_types.end(); vit++) all_assys.insert(*vit); 373 all_assys.erase(-1); 374 375 //char filename[] = "fuel_assy.cub"; 376 char filename[] = "pin1.cub"; 377 for (unsigned int i = 0; i < all_assys.size(); i++) { 378 std::cout << "\nAssy " << i << ": "<< filename; 379 files.push_back(std::string(filename)); 380 } 381 char bfilename[] = "y"; 382 std::cout << "\nBackground assembly (y/n)?: " << bfilename << std::endl; 383 384 if (bfilename[0] == 'y' || bfilename[0] == 'Y') { 385 char bfile[] = "test_sodium_all.cub"; 386 //char bfile[] = "sodium_all.cub"; 387 std::cout << "Defaulting to file: " << bfile; 388 389 files.push_back(std::string(bfile)); 390 back_mesh = true; 391 } 392 else 393 back_mesh = false; 394 } 395 char g_id[]= "n"; 396 std::cout << "\nNew global ids (y/n)? " << g_id; 397 global_ids = false; 398 char filename[] = "sixth_test.h5m"; 399 std::cout << "\nOutput file: "<< filename << std::endl; 400 outfile = filename; 401 402 std::cout << "\n------------------------------\n\n"; 403 404 return iBase_SUCCESS; 405 } 406 407
![(please configure the [header_logo] section in trac.ini)](/projects/ITAPS/chrome/common/trac_banner.png)