Changeset f714979 for src/boundary.cpp
- Timestamp:
- Dec 8, 2008, 2:16:34 PM (17 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, Candidate_v1.7.0, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- caf5d6
- Parents:
- a8bcea6
- File:
-
- 1 edited
-
src/boundary.cpp (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/boundary.cpp
ra8bcea6 rf714979 514 514 double a,b,c; 515 515 516 Find_non_convex_border(out, tecplot, *TesselStruct, mol);517 /* 516 //Find_non_convex_border(out, tecplot, *TesselStruct, mol); // Is now called from command line. 517 518 518 // 1. calculate center of gravity 519 519 *out << endl; … … 559 559 560 560 *out << Verbose(2) << "I created " << TesselStruct->TrianglesOnBoundaryCount << " triangles with " << TesselStruct->LinesOnBoundaryCount << " lines and " << TesselStruct->PointsOnBoundaryCount << " points." << endl; 561 */ 561 562 562 563 563 … … 582 582 *out << Verbose(0) << "RESULT: The summed volume is " << setprecision(10) << volume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl; 583 583 584 /* 584 585 585 // 7. translate all points back from CoG 586 586 *out << Verbose(1) << "Translating system back from Center of Gravity." << endl; … … 591 591 Walker->x.Translate(CenterOfGravity); 592 592 } 593 */ 593 594 594 595 595 … … 1039 1039 * with all neighbours of the candidate. 1040 1040 */ 1041 void Find_next_suitable_point(atom* a, atom* b, atom* Candidate, int n, Vector *Chord, Vector *d1, Vector * d2, atom*& Opt_Candidate, double *Storage, const double RADIUS, molecule* mol, bool problem)1042 { 1043 /* d2 is normal vector on thetriangle1044 * d1 is normal on the triangle line, from which we come, as well as on d2.1041 void Find_next_suitable_point(atom* a, atom* b, atom* Candidate, int n, Vector *Chord, Vector *d1, Vector *OldNormal, atom*& Opt_Candidate, double *Storage, const double RADIUS, molecule* mol, bool problem) 1042 { 1043 /* OldNormal is normal vector on the old triangle 1044 * d1 is normal on the triangle line, from which we come, as well as on OldNormal. 1045 1045 */ 1046 1046 Vector dif_a; //Vector from a to candidate … … 1066 1066 { 1067 1067 1068 if (Chord->Norm()/(2*sin( dif_a.Angle(&dif_b)))<RADIUS) //Using Formula for relation of chord length with inner angle to find of Ball will touch atom1068 if (Chord->Norm()/(2*sin(0.5*dif_a.Angle(&dif_b)))<RADIUS) //Using Formula for relation of chord length with inner angle to find if Ball will touch atom 1069 1069 { 1070 1070 if (dif_a.ScalarProduct(d1)/fabs(dif_a.ScalarProduct(d1))>Storage[0]) //This will give absolute preference to those in "right-hand" quadrants … … 1072 1072 Opt_Candidate = Candidate; 1073 1073 Storage[0]=dif_a.ScalarProduct(d1)/fabs(dif_a.ScalarProduct(d1)); 1074 Storage[1]=AngleCheck.Angle( d2);1074 Storage[1]=AngleCheck.Angle(OldNormal); 1075 1075 } 1076 1076 else 1077 1077 { 1078 if ((dif_a.ScalarProduct(d1)/fabs(dif_a.ScalarProduct(d1)) == Storage[0] && Storage[0]>0 && Storage[1] < AngleCheck.Angle(d2)) or \1079 (dif_a.ScalarProduct(d1)/fabs(dif_a.ScalarProduct(d1)) == Storage[0] && Storage[0]<0 && Storage[1] > AngleCheck.Angle(d2)))1078 if ((dif_a.ScalarProduct(d1)/fabs(dif_a.ScalarProduct(d1)) == Storage[0] && Storage[0]>0 && Storage[1]> AngleCheck.Angle(OldNormal)) or \ 1079 (dif_a.ScalarProduct(d1)/fabs(dif_a.ScalarProduct(d1)) == Storage[0] && Storage[0]<0 && Storage[1]< AngleCheck.Angle(OldNormal))) 1080 1080 //Depending on quadrant we prefer higher or lower atom with respect to Triangle normal first. 1081 1081 { 1082 1082 Opt_Candidate = Candidate; 1083 1083 Storage[0]=dif_a.ScalarProduct(d1)/fabs(dif_a.ScalarProduct(d1)); 1084 Storage[1]=AngleCheck.Angle( d2);1084 Storage[1]=AngleCheck.Angle(OldNormal); 1085 1085 } 1086 1086 else 1087 1087 { 1088 1088 if (problem) 1089 cout << "Lo ses to better candidate" << endl;1089 cout << "Looses to better candidate" << endl; 1090 1090 } 1091 1091 } … … 1109 1109 Walker = mol->ListOfBondsPerAtom[Candidate->nr][i]->GetOtherAtom(Candidate); 1110 1110 1111 Find_next_suitable_point(a, b, Walker, n+1, Chord, d1, d2, Opt_Candidate, Storage, RADIUS, mol, problem); //call function again1111 Find_next_suitable_point(a, b, Walker, n+1, Chord, d1, OldNormal, Opt_Candidate, Storage, RADIUS, mol, problem); //call function again 1112 1112 } 1113 1113 } … … 1117 1117 * this function fins a triangle to a line, adjacent to an existing one. 1118 1118 */ 1119 void Tesselation::Find_next_suitable_triangle(ofstream *out, ofstream *tecplot, molecule* mol, BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS )1119 void Tesselation::Find_next_suitable_triangle(ofstream *out, ofstream *tecplot, molecule* mol, BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, int N) 1120 1120 { 1121 1121 cout << Verbose(1) << "Looking for next suitable triangle \n"; … … 1147 1147 direction1.VectorProduct(&(T.NormalVector)); 1148 1148 1149 if (direction1.ScalarProduct(&helper) >0)1149 if (direction1.ScalarProduct(&helper)<0) 1150 1150 { 1151 1151 direction1.Scale(-1); … … 1158 1158 Find_next_suitable_point(Line.endpoints[0]->node, Line.endpoints[1]->node, Line.endpoints[0]->node, 0, &Chord, &direction1, &(T.NormalVector), Opt_Candidate, Storage, RADIUS, mol,0); 1159 1159 1160 if ( Opt_Candidate==NULL)1160 if (N>-1) 1161 1161 { 1162 1162 cout << Verbose(1) << "No new Atom found, triangle construction will crash" << endl; … … 1180 1180 cout << " Optimal candidate is " << *Opt_Candidate << endl; 1181 1181 BPS[0] = new class BoundaryPointSet(Opt_Candidate); 1182 cout << " Optimal candidate is " << *Opt_Candidate << endl; 1182 1183 1183 BPS[1] = new class BoundaryPointSet(Line.endpoints[1]->node); 1184 1184 BLS[1] = new class BoundaryLineSet(BPS , LinesOnBoundaryCount); … … 1190 1190 1191 1191 cout << Verbose(1) << "Checking for already present lines ... " << endl; 1192 for(int i=0;i<NDIM;i++) // sind Linien bereits vorhanden ??? 1193 { 1194 1195 1196 if ( (LinesOnBoundary.insert( LinePair(LinesOnBoundaryCount, BTS->lines[i]))).second); 1197 { 1198 LinesOnBoundaryCount++; 1199 } 1200 } 1192 for(int i=0; i<NDIM; i++) // sind Linien bereits vorhanden ??? 1193 { 1194 if ( (LinesOnBoundary.insert( LinePair(LinesOnBoundaryCount, BTS->lines[i]))).second); 1195 { 1196 LinesOnBoundaryCount++; 1197 } 1198 } 1201 1199 cout << Verbose(1) << "Constructing normal vector for this triangle ... " << endl; 1202 1200 … … 1219 1217 atom* Walker; 1220 1218 1221 AngleCheck.CopyVector(&(Candidate->x)); 1222 AngleCheck.SubtractVector(&(a->x)); 1223 if (AngleCheck.Norm() < RADIUS and AngleCheck.Angle(&Oben) < Storage[0]) 1224 { 1225 //cout << Verbose(1) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]); 1226 Opt_Candidate=Candidate; 1227 Storage[0]=AngleCheck.Angle(&Oben); 1228 //cout << Verbose(1) << "Changing something in Storage: %lf %lf. \n", Storage[0], Storage[1]); 1229 }; 1219 if (a->nr !=Candidate->nr) 1220 { 1221 AngleCheck.CopyVector(&(Candidate->x)); 1222 AngleCheck.SubtractVector(&(a->x)); 1223 if (AngleCheck.Norm() < RADIUS and AngleCheck.Angle(&Oben) < Storage[0]) 1224 { 1225 //cout << Verbose(1) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]); 1226 Opt_Candidate=Candidate; 1227 Storage[0]=AngleCheck.Angle(&Oben); 1228 //cout << Verbose(1) << "Changing something in Storage: %lf %lf. \n", Storage[0], Storage[1]); 1229 } 1230 else{ 1231 if (AngleCheck.Norm() > RADIUS) 1232 { 1233 cout << Verbose(1) << "refused due to Radius" << AngleCheck.Norm() << endl; 1234 } 1235 else{ 1236 cout << Verbose(1) << "Supposedly looses to better candidate" << Opt_Candidate->nr << endl; 1237 } 1238 } 1239 } 1240 1230 1241 if (n<5) 1231 1242 { … … 1246 1257 int i=0; 1247 1258 atom* Walker; 1248 atom* Walker2;1249 atom* Walker3;1259 atom* FirstPoint; 1260 atom* SecondPoint; 1250 1261 int max_index[3]; 1251 1262 double max_coordinate[3]; … … 1267 1278 { 1268 1279 Walker = Walker->next; 1269 for (i=0; i<3; i++)1270 {1271 if (Walker->x.x[i] > max_coordinate[i])1272 {1273 max_coordinate[i]=Walker->x.x[i];1274 max_index[i]=Walker->nr;1275 }1276 }1277 } 1278 1279 cout << Verbose(1) << "Found starting atom \n";1280 for (i=0; i<3; i++) 1281 { 1282 if (Walker->x.x[i] > max_coordinate[i]) 1283 { 1284 max_coordinate[i]=Walker->x.x[i]; 1285 max_index[i]=Walker->nr; 1286 } 1287 } 1288 } 1289 1290 cout << Verbose(1) << "Found maximum coordinates. "<< endl; 1280 1291 //Koennen dies fuer alle Richtungen, legen hier erstmal Richtung auf k=0 1281 const int k= 2;1292 const int k=0; 1282 1293 1283 1294 Oben.x[k]=1.; 1284 Walker= mol->start;1285 Walker = Walker->next;1286 while ( Walker->nr != max_index[k])1295 FirstPoint = mol->start; 1296 FirstPoint = FirstPoint->next; 1297 while (FirstPoint->nr != max_index[k]) 1287 1298 { 1288 Walker = Walker->next;1289 } 1290 cout << Verbose(1) << "Number of start atom: " << Walker->nr<< endl;1299 FirstPoint = FirstPoint->next; 1300 } 1301 cout << Verbose(1) << "Coordinates of start atom: " << FirstPoint->x.x[0] << endl; 1291 1302 double Storage[2]; 1292 1303 atom* Opt_Candidate = NULL; 1293 1304 Storage[0]=999999.; // This will contain the angle, which will be always positive (when looking for second point), when looking for third point this will be the quadrant. 1294 1305 Storage[1]=999999.; // This will be an angle looking for the third point. 1295 cout << Verbose(1) << "Number of Bonds: " << mol->NumberOfBondsPerAtom[Walker->nr] << endl; 1296 1297 for (i=1; i< (mol->NumberOfBondsPerAtom[Walker->nr]); i++) 1298 { 1299 Walker2 = mol->ListOfBondsPerAtom[Walker->nr][i]->GetOtherAtom(Walker); 1300 Find_second_point_for_Tesselation(Walker, Walker2, 0, Oben, Opt_Candidate, Storage, mol, RADIUS); 1301 } 1302 1303 Walker2 = Opt_Candidate; 1306 cout << Verbose(1) << "Number of Bonds: " << mol->NumberOfBondsPerAtom[FirstPoint->nr] << endl; 1307 1308 Find_second_point_for_Tesselation(FirstPoint, mol->ListOfBondsPerAtom[FirstPoint->nr][0]->GetOtherAtom(FirstPoint), 0, Oben, Opt_Candidate, Storage, mol, RADIUS); 1309 1310 1311 SecondPoint = Opt_Candidate; 1304 1312 Opt_Candidate=NULL; 1305 helper.CopyVector(&( Walker->x));1306 helper.SubtractVector(&( Walker2->x));1313 helper.CopyVector(&(FirstPoint->x)); 1314 helper.SubtractVector(&(SecondPoint->x)); 1307 1315 Oben.ProjectOntoPlane(&helper); 1308 1316 helper.VectorProduct(&Oben); … … 1310 1318 Storage[1]= 9999999.; // This will be an angle looking for the third point. 1311 1319 1312 Chord.CopyVector(&( Walker->x)); // bring into calling function1313 Chord.SubtractVector(&( Walker2->x));1320 Chord.CopyVector(&(FirstPoint->x)); // bring into calling function 1321 Chord.SubtractVector(&(SecondPoint->x)); 1314 1322 1315 1323 cout << Verbose(1) << "Looking for third point candidates \n"; 1316 Find_next_suitable_point( Walker, Walker2, mol->ListOfBondsPerAtom[Walker->nr][0]->GetOtherAtom(Walker), 0, &Chord, &helper, &Oben, Opt_Candidate, Storage, RADIUS, mol, 0);1317 1318 1319 //Starting Triangle is Walker, Walker2, Opt_Candidate1320 1321 AddPoint( Walker);1322 AddPoint( Walker2);1324 Find_next_suitable_point(FirstPoint, SecondPoint, mol->ListOfBondsPerAtom[FirstPoint->nr][0]->GetOtherAtom(FirstPoint), 0, &Chord, &helper, &Oben, Opt_Candidate, Storage, RADIUS, mol, 0); 1325 1326 1327 //Starting Triangle is Walker, SecondPoint, Opt_Candidate 1328 1329 AddPoint(FirstPoint); 1330 AddPoint(SecondPoint); 1323 1331 AddPoint(Opt_Candidate); 1324 1332 1325 cout << Verbose(1) << "The found starting triangle consists of " << * Walker << ", " << *Walker2<< " and " << *Opt_Candidate << "." << endl;1326 1327 BPS[0] = new class BoundaryPointSet( Walker);1328 BPS[1] = new class BoundaryPointSet( Walker2);1333 cout << Verbose(1) << "The found starting triangle consists of " << *FirstPoint << ", " << *SecondPoint << " and " << *Opt_Candidate << "." << endl; 1334 1335 BPS[0] = new class BoundaryPointSet(FirstPoint); 1336 BPS[1] = new class BoundaryPointSet(SecondPoint); 1329 1337 BLS[0] = new class BoundaryLineSet(BPS , LinesOnBoundaryCount); 1330 BPS[0] = new class BoundaryPointSet( Walker);1338 BPS[0] = new class BoundaryPointSet(FirstPoint); 1331 1339 BPS[1] = new class BoundaryPointSet(Opt_Candidate); 1332 1340 BLS[1] = new class BoundaryLineSet(BPS , LinesOnBoundaryCount); 1333 BPS[0] = new class BoundaryPointSet( Walker);1334 BPS[1] = new class BoundaryPointSet( Walker2);1341 BPS[0] = new class BoundaryPointSet(Opt_Candidate); 1342 BPS[1] = new class BoundaryPointSet(SecondPoint); 1335 1343 BLS[2] = new class BoundaryLineSet(BPS , LinesOnBoundaryCount); 1336 1344 … … 1354 1362 1355 1363 1356 void Find_non_convex_border(ofstream *out, ofstream *tecplot, Tesselation Tess, molecule* mol) 1357 { 1364 void Find_non_convex_border(ofstream *out, ofstream *tecplot, molecule* mol) 1365 { 1366 int N =0; 1367 struct Tesselation *Tess = new Tesselation; 1358 1368 cout << Verbose(1) << "Entering finding of non convex hull. " << endl; 1359 1369 cout << flush; 1360 const double RADIUS =6; 1361 LineMap::iterator baseline; 1362 Tess.Find_starting_triangle(mol, RADIUS); 1363 1364 baseline = Tess.LinesOnBoundary.begin(); 1365 while (baseline != Tess.LinesOnBoundary.end()) { 1366 if (baseline->second->TrianglesCount == 1) 1367 { 1368 cout << Verbose(1) << "Begin of Tesselation ... " << endl; 1369 Tess.Find_next_suitable_triangle(out, tecplot, mol, *(baseline->second), *(baseline->second->triangles.begin()->second), RADIUS); //the line is there, so there is a triangle, but only one. 1370 cout << Verbose(1) << "End of Tesselation ... " << endl; 1371 } 1372 else 1373 { 1374 cout << Verbose(1) << "There is a line with " << baseline->second->TrianglesCount << " triangles adjacent"; 1375 } 1376 baseline++; 1377 } 1378 1379 }; 1370 const double RADIUS =6.; 1371 LineMap::iterator baseline; 1372 Tess->Find_starting_triangle(mol, RADIUS); 1373 1374 baseline = Tess->LinesOnBoundary.begin(); 1375 while (baseline != Tess->LinesOnBoundary.end()) { 1376 if (baseline->second->TrianglesCount == 1) 1377 { 1378 cout << Verbose(1) << "Begin of Tesselation ... " << endl; 1379 Tess->Find_next_suitable_triangle(out, tecplot, mol, *(baseline->second), *(baseline->second->triangles.begin()->second), RADIUS, N); //the line is there, so there is a triangle, but only one. 1380 cout << Verbose(1) << "End of Tesselation ... " << endl; 1381 } 1382 else 1383 { 1384 cout << Verbose(1) << "There is a line with " << baseline->second->TrianglesCount << " triangles adjacent"; 1385 } 1386 N++; 1387 baseline++; 1388 } 1389 1390 };
Note:
See TracChangeset
for help on using the changeset viewer.
