GlobalMaster.C

Go to the documentation of this file.
00001 
00007 #include "Node.h"
00008 #include "Molecule.h"
00009 #include "NamdTypes.h"
00010 #include "GlobalMaster.h"
00011 
00012 //#define DEBUGM
00013 #define MIN_DEBUG_LEVEL 1
00014 #include "Debug.h"
00015 
00016 void GlobalMaster::processData(AtomIDList::iterator a_i,
00017                                AtomIDList::iterator a_e,
00018                                PositionList::iterator p_i,
00019                                PositionList::iterator g_i,
00020                                PositionList::iterator g_e,
00021                                BigRealList::iterator gm_i,
00022                                BigRealList::iterator gm_e,
00023                                ForceList::iterator gtf_i,
00024                                ForceList::iterator gtf_e,
00025                                AtomIDList::iterator last_atoms_forced_i,
00026                                AtomIDList::iterator last_atoms_forced_e,
00027                                ForceList::iterator last_forces_i,
00028                                AtomIDList::iterator forceid_i,
00029                                AtomIDList::iterator forceid_e,
00030                                ForceList::iterator totalforce_i) {
00031   atomIdBegin = a_i;
00032   atomIdEnd = a_e;
00033   atomPositionBegin = p_i;
00034   groupPositionBegin = g_i;
00035   groupPositionEnd = g_e;
00036   groupMassBegin = gm_i;
00037   groupMassEnd = gm_e;
00038   groupTotalForceBegin = gtf_i;
00039   groupTotalForceEnd = gtf_e;
00040   lastAtomsForcedBegin = last_atoms_forced_i;
00041   lastAtomsForcedEnd = last_atoms_forced_e;
00042   lastForcesBegin = last_forces_i;
00043   forceIdBegin = forceid_i;
00044   forceIdEnd = forceid_e;
00045   totalForceBegin = totalforce_i;
00046 
00047   calculate();
00048 
00049   /* check to make sure the force arrays still match */
00050   if(appForcesChanged) {
00051     if(fAtoms.size() != appForces.size())
00052       NAMD_die("# of atoms forced != # of forces given");
00053   }
00054   if(appForcesChanged) {
00055     if(grpForces.size() != gm_e - gm_i)
00056       NAMD_die("# of groups forced != # of groups requested");
00057   }
00058 }
00059 
00060 void GlobalMaster::check() const {
00061   /* check to make sure the force arrays still match */
00062   if(fAtoms.size() != appForces.size())
00063     NAMD_die("# of atoms forced != # of forces given");
00064   if(grpForces.size() != groupMassEnd - groupMassBegin)
00065     NAMD_die("# of groups forced != # of groups requested");
00066 }
00067 
00068 void GlobalMaster::clearChanged() {
00069   reqAtomsChanged = false;
00070   appForcesChanged = false;
00071   reqGroupsChanged = false;
00072 }
00073 
00074 void GlobalMaster::calculate() {
00075   NAMD_die("Internal error: pure virtual function called");
00076 }
00077 
00078 GlobalMaster::GlobalMaster() {
00079   step = -1;
00080   old_num_groups_requested = 0;
00081   clearChanged();
00082   atomIdBegin = 0;
00083   atomIdEnd = 0;
00084   atomPositionBegin = 0;
00085   groupPositionBegin = 0;
00086   groupPositionEnd = 0;
00087   groupMassBegin = 0;
00088   groupMassEnd = 0;
00089   lastAtomsForcedBegin = 0;
00090   lastAtomsForcedEnd = 0;
00091   lastForcesBegin = 0;
00092   forceIdBegin = 0;
00093   forceIdEnd = 0;
00094   totalForceBegin = 0;
00095   lattice = 0;
00096   totalForceRequested = false;
00097 }
00098 
00099 bool GlobalMaster::changedAtoms() {
00100   return reqAtomsChanged;
00101 }
00102 
00103 bool GlobalMaster::changedForces() {
00104   return appForcesChanged;
00105 }
00106 
00107 bool GlobalMaster::changedGroups() {
00108   return reqGroupsChanged;
00109 }
00110 
00111 const AtomIDList &GlobalMaster::requestedAtoms() {
00112   return reqAtoms;
00113 }
00114 
00115 AtomIDList &GlobalMaster::modifyRequestedAtoms() {
00116   reqAtomsChanged = true;
00117   return reqAtoms;
00118 }
00119 
00120 const AtomIDList &GlobalMaster::forcedAtoms() {
00121   return fAtoms;
00122 }
00123 
00124 const ForceList &GlobalMaster::appliedForces() {
00125   return appForces;
00126 }
00127 
00128 const ForceList &GlobalMaster::groupForces() {
00129   return grpForces;
00130 }
00131 
00132 const ResizeArray<AtomIDList> &GlobalMaster::requestedGroups() {
00133   return reqGroups;
00134 }
00135 
00136 AtomIDList &GlobalMaster::modifyForcedAtoms() {
00137   appForcesChanged = true;
00138   return fAtoms;
00139 }
00140 
00141 ForceList &GlobalMaster::modifyAppliedForces() {
00142   appForcesChanged = true;
00143   return appForces;
00144 }
00145 
00146 ForceList &GlobalMaster::modifyGroupForces() {
00147   // XXX should we mark something else here?
00148   appForcesChanged = true;
00149   return grpForces;
00150 }
00151 
00152 ResizeArray<AtomIDList> &GlobalMaster::modifyRequestedGroups() {
00153   reqGroupsChanged = true;
00154   DebugM(1,"Groups have changed.\n");
00155   return reqGroups;
00156 }
00157 
00158 AtomIDList::const_iterator GlobalMaster::getAtomIdBegin() {
00159   return atomIdBegin;
00160 }
00161 
00162 AtomIDList::const_iterator GlobalMaster::getAtomIdEnd() {
00163   return atomIdEnd;
00164 }
00165 
00166 PositionList::const_iterator GlobalMaster::getAtomPositionBegin() {
00167   return atomPositionBegin;
00168 }
00169 
00170 PositionList::const_iterator GlobalMaster::getGroupPositionBegin() {
00171   return groupPositionBegin;
00172 }
00173 
00174 PositionList::const_iterator GlobalMaster::getGroupPositionEnd() {
00175   return groupPositionEnd;
00176 }
00177 
00178 ForceList::const_iterator GlobalMaster::getGroupTotalForceBegin() {
00179   return groupTotalForceBegin;
00180 }
00181 
00182 ForceList::const_iterator GlobalMaster::getGroupTotalForceEnd() {
00183   return groupTotalForceEnd;
00184 }
00185 
00186 BigRealList::const_iterator GlobalMaster::getGroupMassBegin()
00187 {
00188   return groupMassBegin;
00189 }
00190 
00191 BigRealList::const_iterator GlobalMaster::getGroupMassEnd() {
00192   return groupMassEnd;
00193 }
00194 
00195 AtomIDList::const_iterator GlobalMaster::getLastAtomsForcedBegin() {
00196   return lastAtomsForcedBegin;
00197 }
00198 
00199 AtomIDList::const_iterator GlobalMaster::getLastAtomsForcedEnd() {
00200   return lastAtomsForcedEnd;
00201 }
00202 
00203 ForceList::const_iterator GlobalMaster::getLastForcesBegin() {
00204   return lastForcesBegin;
00205 }
00206 
00207 AtomIDList::const_iterator GlobalMaster::getForceIdBegin()
00208 {
00209   return forceIdBegin;
00210 }
00211 
00212 AtomIDList::const_iterator GlobalMaster::getForceIdEnd()
00213 {
00214   return forceIdEnd;
00215 }
00216 
00217 ForceList::const_iterator GlobalMaster::getTotalForce()
00218 {
00219   return totalForceBegin;
00220 }

Generated on Sat Sep 23 01:17:13 2017 for NAMD by  doxygen 1.4.7