ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/src/types/ShapeAtomType.cpp
Revision: 2214
Committed: Wed Apr 27 20:14:03 2005 UTC (19 years, 2 months ago) by chrisfen
File size: 7001 byte(s)
Log Message:
Got rid of write statements and am closer to a working shapes

File Contents

# User Rev Content
1 gezelter 2204 /*
2 gezelter 1930 * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3     *
4     * The University of Notre Dame grants you ("Licensee") a
5     * non-exclusive, royalty free, license to use, modify and
6     * redistribute this software in source and binary code form, provided
7     * that the following conditions are met:
8     *
9     * 1. Acknowledgement of the program authors must be made in any
10     * publication of scientific results based in part on use of the
11     * program. An acceptable form of acknowledgement is citation of
12     * the article in which the program was described (Matthew
13 chrisfen 2211 * A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14     * J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 gezelter 1930 * Parallel Simulation Engine for Molecular Dynamics,"
16 chrisfen 2211 * J. Comput. Chem. 26, pp. 252-271 (2005))
17 gezelter 1930 *
18     * 2. Redistributions of source code must retain the above copyright
19     * notice, this list of conditions and the following disclaimer.
20     *
21     * 3. Redistributions in binary form must reproduce the above copyright
22     * notice, this list of conditions and the following disclaimer in the
23     * documentation and/or other materials provided with the
24     * distribution.
25     *
26     * This software is provided "AS IS," without a warranty of any
27     * kind. All express or implied conditions, representations and
28     * warranties, including any implied warranty of merchantability,
29     * fitness for a particular purpose or non-infringement, are hereby
30     * excluded. The University of Notre Dame and its licensors shall not
31     * be liable for any damages suffered by licensee as a result of
32     * using, modifying or distributing the software or its
33     * derivatives. In no event will the University of Notre Dame or its
34     * licensors be liable for any lost revenue, profit or data, or for
35     * direct, indirect, special, consequential, incidental or punitive
36     * damages, however caused and regardless of the theory of liability,
37     * arising out of the use of or inability to use software, even if the
38     * University of Notre Dame has been advised of the possibility of
39     * such damages.
40     */
41 chrisfen 2211
42 gezelter 1652 #include "types/ShapeAtomType.hpp"
43 chrisfen 2211 #include "UseTheForce/DarkSide/shapes_interface.h"
44 gezelter 1652
45 chrisfen 2211 namespace oopse {
46 gezelter 1652
47 chrisfen 2211 ShapeAtomType::~ShapeAtomType() {
48     std::vector<RealSphericalHarmonic*>::iterator iter;
49     for (iter = contactFuncs.begin(); iter != contactFuncs.end(); ++iter)
50     delete (*iter);
51     for (iter = rangeFuncs.begin(); iter != rangeFuncs.end(); ++iter)
52     delete (*iter);
53     for (iter = strengthFuncs.begin(); iter != strengthFuncs.end(); ++iter)
54     delete (*iter);
55     contactFuncs.clear();
56     rangeFuncs.clear();
57     strengthFuncs.clear();
58     }
59 gezelter 1652
60 chrisfen 2211 double ShapeAtomType::getContactValueAt(double costheta, double phi) {
61    
62     std::vector<RealSphericalHarmonic*>::iterator contactIter;
63     double contactVal;
64    
65     contactVal = 0.0;
66    
67     for(contactIter = contactFuncs.begin(); contactIter != contactFuncs.end();
68     ++contactIter)
69     contactVal += (*contactIter)->getValueAt(costheta, phi);
70    
71     return contactVal;
72     }
73 gezelter 1652
74 chrisfen 2211 double ShapeAtomType::getRangeValueAt(double costheta, double phi) {
75    
76     std::vector<RealSphericalHarmonic*>::iterator rangeIter;
77     double rangeVal;
78    
79     rangeVal = 0.0;
80    
81     for(rangeIter = rangeFuncs.begin(); rangeIter != rangeFuncs.end();
82     ++rangeIter)
83     rangeVal += (*rangeIter)->getValueAt(costheta, phi);
84    
85     return rangeVal;
86     }
87 gezelter 1652
88 chrisfen 2211 double ShapeAtomType::getStrengthValueAt(double costheta, double phi) {
89    
90     std::vector<RealSphericalHarmonic*>::iterator strengthIter;
91     double strengthVal;
92    
93     strengthVal = 0.0;
94    
95     for(strengthIter = strengthFuncs.begin();
96     strengthIter != strengthFuncs.end();
97     ++strengthIter)
98     strengthVal += (*strengthIter)->getValueAt(costheta, phi);
99    
100     return strengthVal;
101     }
102 gezelter 1652
103 chrisfen 2211 void ShapeAtomType::complete() {
104    
105     // first complete all the non-shape atomTypes
106     DirectionalAtomType::complete();
107    
108     int isError = 0;
109    
110     //setup dipole atom type in fortran side
111     if (isShape()) {
112     // vectors for shape transfer to fortran
113     std::vector<RealSphericalHarmonic*> tempSHVector;
114     std::vector<int> contactL;
115     std::vector<int> contactM;
116     std::vector<int> contactFunc;
117     std::vector<double> contactCoeff;
118     std::vector<int> rangeL;
119     std::vector<int> rangeM;
120     std::vector<int> rangeFunc;
121     std::vector<double> rangeCoeff;
122     std::vector<int> strengthL;
123     std::vector<int> strengthM;
124     std::vector<int> strengthFunc;
125     std::vector<double> strengthCoeff;
126    
127     tempSHVector.clear();
128     contactL.clear();
129     contactM.clear();
130     contactFunc.clear();
131     contactCoeff.clear();
132    
133     tempSHVector = getContactFuncs();
134    
135     int nContact = tempSHVector.size();
136     for (int i=0; i<nContact; i++){
137     contactL.push_back(tempSHVector[i]->getL());
138     contactM.push_back(tempSHVector[i]->getM());
139     contactFunc.push_back(tempSHVector[i]->getFunctionType());
140     contactCoeff.push_back(tempSHVector[i]->getCoefficient());
141     }
142    
143     tempSHVector.clear();
144     rangeL.clear();
145     rangeM.clear();
146     rangeFunc.clear();
147     rangeCoeff.clear();
148    
149     tempSHVector = getRangeFuncs();
150    
151     int nRange = tempSHVector.size();
152     for (int i=0; i<nRange; i++){
153     rangeL.push_back(tempSHVector[i]->getL());
154     rangeM.push_back(tempSHVector[i]->getM());
155     rangeFunc.push_back(tempSHVector[i]->getFunctionType());
156     rangeCoeff.push_back(tempSHVector[i]->getCoefficient());
157     }
158    
159     tempSHVector.clear();
160     strengthL.clear();
161     strengthM.clear();
162     strengthFunc.clear();
163     strengthCoeff.clear();
164    
165     tempSHVector = getStrengthFuncs();
166    
167     int nStrength = tempSHVector.size();
168     for (int i=0; i<nStrength; i++){
169     strengthL.push_back(tempSHVector[i]->getL());
170     strengthM.push_back(tempSHVector[i]->getM());
171     strengthFunc.push_back(tempSHVector[i]->getFunctionType());
172     strengthCoeff.push_back(tempSHVector[i]->getCoefficient());
173     }
174    
175     int myATID = getIdent();
176    
177     makeShape( &nContact, &contactL[0], &contactM[0], &contactFunc[0],
178     &contactCoeff[0],
179 chrisfen 2214 &nRange, &rangeL[0], &rangeM[0], &rangeFunc[0],
180     &rangeCoeff[0],
181 chrisfen 2211 &nStrength, &strengthL[0], &strengthM[0], &strengthFunc[0],
182     &strengthCoeff[0],
183     &myATID,
184     &isError);
185    
186     if( isError ){
187     sprintf( painCave.errMsg,
188     "Error initializing the \"%s\" shape in fortran\n",
189     (getName()).c_str() );
190     painCave.severity = OOPSE_ERROR;
191     painCave.isFatal = 1;
192     simError();
193     }
194     }
195     }
196 gezelter 1652 }