ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/src/applications/staticProps/RadialDistrFunc.cpp
Revision: 2204
Committed: Fri Apr 15 22:04:00 2005 UTC (19 years, 3 months ago) by gezelter
File size: 6900 byte(s)
Log Message:
xemacs has been drafted to perform our indentation services

File Contents

# User Rev Content
1 tim 1990 /*
2     * 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     * A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14     * J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15     * Parallel Simulation Engine for Molecular Dynamics,"
16     * J. Comput. Chem. 26, pp. 252-271 (2005))
17     *
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    
42     #include <algorithm>
43    
44     #include "RadialDistrFunc.hpp"
45 tim 1995 #include "io/DumpReader.hpp"
46     #include "primitives/Molecule.hpp"
47 tim 1990 namespace oopse {
48    
49 gezelter 2204 RadialDistrFunc:: RadialDistrFunc(SimInfo* info, const std::string& filename, const std::string& sele1, const std::string& sele2)
50     : info_(info), currentSnapshot_(NULL), dumpFilename_(filename), step_(1),
51     selectionScript1_(sele1), selectionScript2_(sele2), evaluator1_(info), evaluator2_(info),
52     seleMan1_(info), seleMan2_(info), common_(info), sele1_minus_common_(info), sele2_minus_common_(info){
53 tim 1990
54 gezelter 2204 evaluator1_.loadScriptString(sele1);
55     evaluator2_.loadScriptString(sele2);
56 tim 1990
57 gezelter 2204 if (!evaluator1_.isDynamic()) {
58 tim 2045 seleMan1_.setSelectionSet(evaluator1_.evaluate());
59     validateSelection1(seleMan1_);
60 gezelter 2204 }
61     if (!evaluator2_.isDynamic()) {
62 tim 2045 seleMan2_.setSelectionSet(evaluator2_.evaluate());
63     validateSelection2(seleMan2_);
64 gezelter 2204 }
65 tim 1990
66 gezelter 2204 if (!evaluator1_.isDynamic() && !evaluator2_.isDynamic()) {
67 tim 2031 //if all selections are static, we can precompute the number of real pairs
68 tim 2037 common_ = seleMan1_ & seleMan2_;
69     sele1_minus_common_ = seleMan1_ - common_;
70     sele2_minus_common_ = seleMan2_ - common_;
71 tim 2031
72 tim 2032 int nSelected1 = seleMan1_.getSelectionCount();
73     int nSelected2 = seleMan2_.getSelectionCount();
74 tim 2037 int nIntersect = common_.getSelectionCount();
75    
76     nPairs_ = nSelected1 * nSelected2 - (nIntersect +1) * nIntersect/2;
77 gezelter 2204 }
78    
79 tim 2031 }
80 tim 1990
81 gezelter 2204 void RadialDistrFunc::process() {
82 tim 1995 Molecule* mol;
83     RigidBody* rb;
84     SimInfo::MoleculeIterator mi;
85     Molecule::RigidBodyIterator rbIter;
86 tim 2002
87 tim 1990 preProcess();
88    
89     DumpReader reader(info_, dumpFilename_);
90 tim 1995 int nFrames = reader.getNFrames();
91 tim 2035 nProcessed_ = nFrames / step_;
92    
93 tim 1990 for (int i = 0; i < nFrames; i += step_) {
94 gezelter 2204 reader.readFrame(i);
95     currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot();
96 tim 1990
97 gezelter 2204 if (evaluator1_.isDynamic()) {
98     seleMan1_.setSelectionSet(evaluator1_.evaluate());
99     validateSelection1(seleMan1_);
100     }
101     if (evaluator2_.isDynamic()) {
102     seleMan2_.setSelectionSet(evaluator2_.evaluate());
103     validateSelection2(seleMan2_);
104     }
105 tim 1990
106 gezelter 2204 for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) {
107 tim 1995
108 gezelter 2204 //change the positions of atoms which belong to the rigidbodies
109     for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) {
110     rb->updateAtoms();
111     }
112     }
113 tim 1995
114 gezelter 2204 initalizeHistogram();
115 tim 1990
116    
117 tim 2037
118 gezelter 2204 //selections may overlap.
119     //
120     // |s1 -c | c |
121     // | c |s2 - c|
122     //
123     // s1 : number of selected stuntdoubles in selection1
124     // s2 : number of selected stuntdoubles in selection2
125     // c : number of intersect stuntdouble between selection1 and selection2
126     //when loop over the pairs, we can divide the looping into 3 stages
127     //stage 1 : [s1-c] [s2]
128     //stage 2 : [c] [s2 - c]
129     //stage 3 : [c] [c]
130     //stage 1 and stage 2 are completly non-overlapping
131     //stage 3 are completely overlapping
132 tim 2037
133 gezelter 2204 if (evaluator1_.isDynamic() || evaluator2_.isDynamic()) {
134 tim 2037
135 gezelter 2204 common_ = seleMan1_ & seleMan2_;
136     sele1_minus_common_ = seleMan1_ - common_;
137     sele2_minus_common_ = seleMan2_ - common_;
138     int nSelected1 = seleMan1_.getSelectionCount();
139     int nSelected2 = seleMan2_.getSelectionCount();
140     int nIntersect = common_.getSelectionCount();
141 tim 2037
142 gezelter 2204 nPairs_ = nSelected1 * nSelected2 - (nIntersect +1) * nIntersect/2;
143     }
144 tim 1990
145 gezelter 2204 processNonOverlapping(sele1_minus_common_, seleMan2_);
146     processNonOverlapping(common_, sele2_minus_common_);
147     processOverlapping(common_);
148 tim 2037
149    
150 gezelter 2204 processHistogram();
151 tim 1990
152     }
153    
154     postProcess();
155    
156 tim 1991 writeRdf();
157 gezelter 2204 }
158 tim 1990
159 gezelter 2204 void RadialDistrFunc::processNonOverlapping( SelectionManager& sman1, SelectionManager& sman2) {
160 tim 2037 StuntDouble* sd1;
161     StuntDouble* sd2;
162     int i;
163     int j;
164    
165     for (sd1 = sman1.beginSelected(i); sd1 != NULL; sd1 = sman1.nextSelected(i)) {
166 tim 2031
167 gezelter 2204 for (sd2 = sman2.beginSelected(j); sd2 != NULL; sd2 = sman2.nextSelected(j)) {
168     collectHistogram(sd1, sd2);
169     }
170 tim 2037 }
171 tim 2031
172 gezelter 2204 }
173 tim 2031
174 gezelter 2204 void RadialDistrFunc::processOverlapping( SelectionManager& sman) {
175 tim 2037 StuntDouble* sd1;
176     StuntDouble* sd2;
177     int i;
178     int j;
179    
180     //basically, it is the same as below loop
181     //for (int i = 0; i < n; ++i )
182     // for (int j = i + 1; j < n; ++j) {}
183    
184     for (sd1 = sman.beginSelected(i); sd1 != NULL; sd1 = sman.nextSelected(i)) {
185 gezelter 2204 for (j = i, sd2 = sman.nextSelected(j); sd2 != NULL; sd2 = sman.nextSelected(j)) {
186     collectHistogram(sd1, sd2);
187     }
188 tim 2031 }
189    
190 gezelter 2204 }
191 tim 2031
192     }