Changeset 4795cd for src/Parser/TremoloParser.cpp
- Timestamp:
- May 18, 2016, 10:03:03 PM (9 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, 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_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, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, 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:
- 35d171
- Parents:
- 797a40
- git-author:
- Frederik Heber <heber@…> (03/08/16 20:08:29)
- git-committer:
- Frederik Heber <heber@…> (05/18/16 22:03:03)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/TremoloParser.cpp
r797a40 r4795cd 57 57 #include <algorithm> 58 58 #include <boost/bind.hpp> 59 #include <boost/function.hpp> 59 60 #include <boost/lambda/lambda.hpp> 60 61 #include <boost/lexical_cast.hpp> … … 362 363 } 363 364 365 template <class T> 366 T NoOp(const atom * const) 367 { 368 return T(); 369 } 370 371 template <class T> 372 void writeEntryFromAdditionalAtomData_ifpresent( 373 std::map<const atomId_t, TremoloAtomInfoContainer> &_additionalAtomData, 374 std::map<TremoloKey::atomDataKey, std::string> &_knownKeyNames, 375 std::ostream* _file, 376 const atom * const _currentAtom, 377 const TremoloKey::atomDataKey _currentField, 378 const typename boost::function<T (const atom * const)> _getter) 379 { 380 if (_additionalAtomData.count(_currentAtom->getId())) { 381 LOG(3, "Writing for type " << _knownKeyNames[_currentField] << ": " 382 << _additionalAtomData[_currentAtom->getId()].get(_currentField)); 383 *_file << _additionalAtomData[_currentAtom->getId()].get(_currentField); 384 } else if (_additionalAtomData.count(_currentAtom->GetTrueFather()->getId())) { 385 LOG(3, "Writing for type " << _knownKeyNames[_currentField] << " stuff from father: " 386 << _additionalAtomData[_currentAtom->GetTrueFather()->getId()].get(_currentField)); 387 *_file << _additionalAtomData[_currentAtom->GetTrueFather()->getId()].get(_currentField); 388 } else { 389 LOG(3, "Writing for type " << _knownKeyNames[_currentField] << " its default value: " 390 << _getter(_currentAtom)); 391 *_file << _getter(_currentAtom); 392 } 393 *_file << "\t"; 394 } 395 396 template <class T> 397 void writeAdditionalAtomDataEntry( 398 std::map<const atomId_t, TremoloAtomInfoContainer> &_additionalAtomData, 399 std::map<TremoloKey::atomDataKey, std::string> &_knownKeyNames, 400 TremoloAtomInfoContainer &_defaultAdditionalData, 401 std::ostream* _file, 402 const atom * const _currentAtom, 403 const TremoloKey::atomDataKey _currentField) 404 { 405 if (_additionalAtomData.count(_currentAtom->getId())) { 406 LOG(3, "Writing for type " << _knownKeyNames[_currentField] << ": " 407 << _additionalAtomData[_currentAtom->getId()].get(_currentField)); 408 *_file << _additionalAtomData[_currentAtom->getId()].get(_currentField); 409 } else if (_additionalAtomData.count(_currentAtom->GetTrueFather()->getId())) { 410 LOG(3, "Writing for type " << _knownKeyNames[_currentField] << " stuff from father: " 411 << _additionalAtomData[_currentAtom->GetTrueFather()->getId()].get(_currentField)); 412 *_file << _additionalAtomData[_currentAtom->GetTrueFather()->getId()].get(_currentField); 413 } else { 414 LOG(3, "Writing for type " << _knownKeyNames[_currentField] << " its default value: " 415 << _defaultAdditionalData.get(_currentField)); 416 *_file << _defaultAdditionalData.get(_currentField); 417 } 418 *_file << "\t"; 419 } 420 421 template <class T> 422 void writeEntryFromAdditionalAtomData_ifnotempty( 423 std::map<const atomId_t, TremoloAtomInfoContainer> &_additionalAtomData, 424 std::map<TremoloKey::atomDataKey, std::string> &_knownKeyNames, 425 TremoloAtomInfoContainer &_defaultAdditionalData, 426 std::ostream* _file, 427 const atom * const _currentAtom, 428 const TremoloKey::atomDataKey _currentField, 429 const typename boost::function<T (const atom * const)> _getter) 430 { 431 if (_additionalAtomData.count(_currentAtom->getId())) { 432 if (_additionalAtomData[_currentAtom->getId()].get(_currentField) != "-") { 433 LOG(3, "Writing for type " << _knownKeyNames[_currentField] << ": " 434 << _additionalAtomData[_currentAtom->getId()].get(_currentField)); 435 *_file << _additionalAtomData[_currentAtom->getId()].get(_currentField); 436 } else { 437 LOG(3, "Writing for type " << _knownKeyNames[_currentField] << " default value: " 438 << _getter(_currentAtom)); 439 *_file << _getter(_currentAtom); 440 } 441 } else if (_additionalAtomData.count(_currentAtom->GetTrueFather()->getId())) { 442 if (_additionalAtomData[_currentAtom->GetTrueFather()->getId()].get(_currentField) != "-") { 443 LOG(3, "Writing for type " << _knownKeyNames[_currentField] << " stuff from father: " 444 << _additionalAtomData[_currentAtom->GetTrueFather()->getId()].get(_currentField)); 445 *_file << _additionalAtomData[_currentAtom->GetTrueFather()->getId()].get(_currentField); 446 } else { 447 LOG(3, "Writing for type " << _knownKeyNames[_currentField] << " default value from father: " 448 << _getter(_currentAtom->GetTrueFather())); 449 *_file << _getter(_currentAtom->GetTrueFather()); 450 } 451 } else { 452 LOG(3, "Writing for type " << _knownKeyNames[_currentField] << " its default value: " 453 << _getter(_currentAtom)); 454 *_file << _getter(_currentAtom); 455 } 456 *_file << "\t"; 457 } 458 364 459 /** 365 460 * Writes one line of tremolo-formatted data to the provided stream. … … 401 496 break; 402 497 case TremoloKey::type : 403 if (additionalAtomData.count(currentAtom->getId())) { 404 if (additionalAtomData[currentAtom->getId()].get(currentField) != "-") { 405 LOG(3, "Writing for type " << knownKeyNames[currentField] << ": " << additionalAtomData[currentAtom->getId()].get(currentField)); 406 *file << additionalAtomData[currentAtom->getId()].get(currentField) << "\t"; 407 } else { 408 LOG(3, "Writing for type " << knownKeyNames[currentField] << " default value: " << currentAtom->getType()->getSymbol()); 409 *file << currentAtom->getType()->getSymbol() << "\t"; 410 } 411 } else if (additionalAtomData.count(currentAtom->GetTrueFather()->getId())) { 412 if (additionalAtomData[currentAtom->GetTrueFather()->getId()].get(currentField) != "-") { 413 LOG(3, "Writing for type " << knownKeyNames[currentField] << " stuff from father: " << additionalAtomData[currentAtom->GetTrueFather()->getId()].get(currentField)); 414 *file << additionalAtomData[currentAtom->GetTrueFather()->getId()].get(currentField) << "\t"; 415 } else { 416 LOG(3, "Writing for type " << knownKeyNames[currentField] << " default value from father: " << currentAtom->GetTrueFather()->getType()->getSymbol()); 417 *file << currentAtom->GetTrueFather()->getType()->getSymbol() << "\t"; 418 } 419 } else { 420 LOG(3, "Writing for type " << knownKeyNames[currentField] << " its default value: " << currentAtom->getType()->getSymbol()); 421 *file << currentAtom->getType()->getSymbol() << "\t"; 422 } 498 writeEntryFromAdditionalAtomData_ifnotempty<std::string>( 499 additionalAtomData, 500 knownKeyNames, 501 defaultAdditionalData, 502 file, 503 currentAtom, 504 currentField, 505 boost::bind(&element::getSymbol, boost::bind(&AtomInfo::getType, _1))); 423 506 break; 424 507 case TremoloKey::Id : … … 453 536 case TremoloKey::charge : 454 537 if (currentAtom->getCharge() == 0.) { 455 if (additionalAtomData.count(currentAtom->getId())) { 456 LOG(3, "Writing for type " << knownKeyNames[currentField] << ": " << additionalAtomData[currentAtom->getId()].get(currentField)); 457 *file << additionalAtomData[currentAtom->getId()].get(currentField); 458 } else if (additionalAtomData.count(currentAtom->GetTrueFather()->getId())) { 459 LOG(3, "Writing for type " << knownKeyNames[currentField] << " stuff from father: " << additionalAtomData[currentAtom->GetTrueFather()->getId()].get(currentField)); 460 *file << additionalAtomData[currentAtom->GetTrueFather()->getId()].get(currentField); 461 } else { 462 LOG(3, "Writing for type " << knownKeyNames[currentField] << " AtomInfo::charge : " << currentAtom->getCharge()); 463 *file << currentAtom->getCharge(); 464 } 538 writeEntryFromAdditionalAtomData_ifpresent<double>( 539 additionalAtomData, 540 knownKeyNames, 541 file, 542 currentAtom, 543 currentField, 544 boost::bind(&AtomInfo::getCharge, _1)); 465 545 } else { 466 546 LOG(3, "Writing for type " << knownKeyNames[currentField] << " AtomInfo::charge : " << currentAtom->getCharge()); 467 *file << currentAtom->getCharge() ;547 *file << currentAtom->getCharge() << "\t"; 468 548 } 469 *file << "\t";470 549 break; 471 550 default : 472 if (additionalAtomData.count(currentAtom->getId())) { 473 LOG(3, "Writing for type " << knownKeyNames[currentField] << ": " << additionalAtomData[currentAtom->getId()].get(currentField)); 474 *file << additionalAtomData[currentAtom->getId()].get(currentField); 475 } else if (additionalAtomData.count(currentAtom->GetTrueFather()->getId())) { 476 LOG(3, "Writing for type " << knownKeyNames[currentField] << " stuff from father: " << additionalAtomData[currentAtom->GetTrueFather()->getId()].get(currentField)); 477 *file << additionalAtomData[currentAtom->GetTrueFather()->getId()].get(currentField); 478 } else { 479 LOG(3, "Writing for type " << knownKeyNames[currentField] << " the default: " << defaultAdditionalData.get(currentField)); 480 *file << defaultAdditionalData.get(currentField); 481 } 482 *file << "\t"; 551 writeAdditionalAtomDataEntry<std::string>( 552 additionalAtomData, 553 knownKeyNames, 554 defaultAdditionalData, 555 file, 556 currentAtom, 557 currentField); 483 558 break; 484 559 }
Note:
See TracChangeset
for help on using the changeset viewer.