• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisión125beb363f517ce51b4f0204ff6c151ac86f963f (tree)
Tiempo2013-05-23 17:49:02
AutorMikiya Fujii <mikiya.fujii@gmai...>
CommiterMikiya Fujii

Log Message

Refactoring of Molecule class.

git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1352 1136aad2-a195-0410-b898-f5ea1d11b9d8

Cambiar Resumen

Diferencia incremental

--- a/src/base/Molecule.cpp
+++ b/src/base/Molecule.cpp
@@ -70,8 +70,6 @@ void Molecule::CopyInitialize(const Molecule& rhs){
7070 this->xyzCOM[i] = rhs.xyzCOM[i];
7171 this->xyzCOC[i] = rhs.xyzCOC[i];
7272 }
73- this->wasCalculatedXyzCOM = rhs.wasCalculatedXyzCOM;
74- this->wasCalculatedXyzCOC = rhs.wasCalculatedXyzCOC;
7573 this->totalNumberAOs = rhs.totalNumberAOs;
7674 this->totalNumberValenceElectrons = rhs.totalNumberValenceElectrons;
7775 this->totalCoreMass = rhs.totalCoreMass;
@@ -90,8 +88,6 @@ void Molecule::CopyInitialize(const Molecule& rhs){
9088
9189 void Molecule::Initialize(){
9290 this->SetMessages();
93- this->wasCalculatedXyzCOM = false;
94- this->wasCalculatedXyzCOC = false;
9591 this->xyzCOM = NULL;
9692 this->xyzCOC = NULL;
9793 this->atomVect = NULL;
@@ -170,39 +166,24 @@ void Molecule::AddAtom(Atom* atom){
170166
171167 }
172168
173-double* Molecule::GetXyzCOM() const{
169+double const* Molecule::GetXyzCOM() const{
174170 #ifdef MOLDS_DBG
175171 if(this->xyzCOM==NULL) throw MolDSException(this->errorMessageGetXyzCOMNull);
176172 #endif
177173 return this->xyzCOM;
178174 }
179175
180-double* Molecule::GetXyzCOM(){
181- if(!this->wasCalculatedXyzCOM){
182- this->CalcXyzCOM();
183- }
184- return this->xyzCOM;
185-}
186-
187-double* Molecule::GetXyzCOC() const{
176+double const* Molecule::GetXyzCOC() const{
188177 #ifdef MOLDS_DBG
189178 if(this->xyzCOC==NULL) throw MolDSException(this->errorMessageGetXyzCOCNull);
190179 #endif
191180 return this->xyzCOC;
192181 }
193182
194-double* Molecule::GetXyzCOC(){
195- if(!this->wasCalculatedXyzCOC){
196- this->CalcXyzCOC();
197- }
198- return this->xyzCOC;
199-}
200-
201183 void Molecule::CalcXyzCOM(){
202- MallocerFreer::GetInstance()->Malloc<double>(&this->xyzCOM, CartesianType_end);
203- double totalAtomicMass = 0.0;
184+ double totalAtomicMass = 0.0;
204185 double* atomicXyz;
205- double atomicMass = 0.0;
186+ double atomicMass = 0.0;
206187
207188 for(int j=0; j<3; j++){
208189 this->xyzCOM[j] = 0.0;
@@ -220,14 +201,12 @@ void Molecule::CalcXyzCOM(){
220201 for(int i=0; i<3; i++){
221202 this->xyzCOM[i]/=totalAtomicMass;
222203 }
223- this->wasCalculatedXyzCOM = true;
224204 }
225205
226206 void Molecule::CalcXyzCOC(){
227- MallocerFreer::GetInstance()->Malloc<double>(&this->xyzCOC, CartesianType_end);
228- double totalCoreMass = 0.0;
207+ double totalCoreMass = 0.0;
229208 double* atomicXyz;
230- double coreMass = 0.0;
209+ double coreMass = 0.0;
231210
232211 for(int j=0; j<3; j++){
233212 this->xyzCOC[j] = 0.0;
@@ -245,7 +224,6 @@ void Molecule::CalcXyzCOC(){
245224 for(int i=0; i<3; i++){
246225 this->xyzCOC[i]/=totalCoreMass;
247226 }
248- this->wasCalculatedXyzCOC = true;
249227 }
250228
251229 int Molecule::GetTotalNumberAOs() const{
@@ -408,9 +386,7 @@ void Molecule::OutputInertiaTensorOrigin(double* inertiaTensorOrigin) const{
408386
409387 void Molecule::CalcPrincipalAxes(){
410388 this->OutputLog(this->messageStartPrincipalAxes);
411- if(!this->wasCalculatedXyzCOM){
412- this->CalcXyzCOM();
413- }
389+ this->CalcXyzCOM();
414390 double inertiaTensorOrigin[3] = {this->xyzCOM[0], this->xyzCOM[1], this->xyzCOM[2]};
415391 if(Parameters::GetInstance()->GetInertiaTensorOrigin() != NULL){
416392 inertiaTensorOrigin[0] = Parameters::GetInstance()->GetInertiaTensorOrigin()[0];
@@ -479,9 +455,7 @@ void Molecule::Rotate(){
479455 this->OutputLog(this->messageStartRotate);
480456
481457 // Default values are set if some conditions are not specified.
482- if(!this->wasCalculatedXyzCOM){
483- this->CalcXyzCOM();
484- }
458+ this->CalcXyzCOM();
485459 double rotatingOrigin[3] = {this->xyzCOM[0], this->xyzCOM[1], this->xyzCOM[2]};
486460 if(Parameters::GetInstance()->GetRotatingOrigin() != NULL){
487461 rotatingOrigin[0] = Parameters::GetInstance()->GetRotatingOrigin()[0];
@@ -642,12 +616,8 @@ void Molecule::Translate(){
642616 atom.GetXyz()[1] += y;
643617 atom.GetXyz()[2] += z;
644618 }
645-
646- this->wasCalculatedXyzCOM = false;
647619 this->CalcXyzCOM();
648- this->wasCalculatedXyzCOC = false;
649620 this->CalcXyzCOC();
650-
651621 this->OutputConfiguration();
652622 this->OutputXyzCOM();
653623 this->OutputXyzCOC();
@@ -674,13 +644,11 @@ double Molecule::GetDistanceAtoms(int indexAtomA, int indexAtomB) const{
674644 }
675645
676646 double Molecule::GetDistanceAtoms(const Atom& atomA, const Atom& atomB) const{
677-
678647 double distance=0.0;
679648 distance = sqrt( pow(atomA.GetXyz()[0] - atomB.GetXyz()[0], 2.0)
680649 +pow(atomA.GetXyz()[1] - atomB.GetXyz()[1], 2.0)
681650 +pow(atomA.GetXyz()[2] - atomB.GetXyz()[2], 2.0) );
682651 return distance;
683-
684652 }
685653
686654 void Molecule::SynchronizeConfigurationTo(const Molecule& ref){
--- a/src/base/Molecule.h
+++ b/src/base/Molecule.h
@@ -39,10 +39,8 @@ public:
3939 return (*this->atomVect)[atomIndex];
4040 }
4141 void AddAtom(MolDS_base_atoms::Atom* atom);
42- double* GetXyzCOM() const;
43- double* GetXyzCOM();
44- double* GetXyzCOC() const;
45- double* GetXyzCOC();
42+ double const* GetXyzCOM() const;
43+ double const* GetXyzCOC() const;
4644 void CalcXyzCOM();
4745 void CalcXyzCOC();
4846 void CalcBasics();
@@ -67,8 +65,6 @@ private:
6765 std::vector<MolDS_base_atoms::Atom*>* atomVect;
6866 double* xyzCOM; // x, y, z coordinates of Center of Mass;
6967 double* xyzCOC; // x, y, z coordinates of Center of Core;
70- bool wasCalculatedXyzCOM;
71- bool wasCalculatedXyzCOC;
7268 int totalNumberAOs;
7369 int totalNumberValenceElectrons;
7470 double totalCoreMass;