ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-3.0/src/brains/SimCreator.cpp
(Generate patch)

Comparing branches/new_design/OOPSE-3.0/src/brains/SimCreator.cpp (file contents):
Revision 1713 by tim, Fri Nov 5 02:56:22 2004 UTC vs.
Revision 1719 by tim, Fri Nov 5 23:38:27 2004 UTC

# Line 63 | Line 63 | SimModel* SimCreator::createSim(const std::string& mdf
63   }
64  
65  
66 < SimModel* SimCreator::createSim(const std::string& mdfile) {
67 <    MakeStamps* stamps;
66 > SimInfo* SimCreator::createSim(const std::string& mdfile) {
67 >    MakeStamps* stamps = new MakeStamps();
68      
69      Globals* globals = new Globals();
70  
# Line 74 | Line 74 | SimModel* SimCreator::createSim(const std::string& mdf
74      //create the force field
75      ForceFiled* ff = ForceFieldFactory::getInstance()->createForceField(globals->getForceField());
76      
77 <    //create SimModel
78 <    model = new SimInfo();
77 >    //create SimInfo
78 >    SimInfo* info = new SimInfo();
79 >    info->setGlobals(globals);
80 >    info->setForceField(ff);
81 >
82 >    //extract the molecule stamps and add them into SimInfo
83 >    compList(stamps, info);
84      
85 <    //gather parameters
86 <    gatherParameters(model);
85 >    //gather parameters (SimCreator only retrieves the parameters which will be used to create
86 >    // the simulation)
87 >    gatherParameters(info);
88      
89      //divide the molecules and determine the global index of molecules
90 <
90 >    
91      //create the molecules
92 +    createMolecules(info);
93  
87    //create atoms, bonds, bend, torsions, rigidbodies
88
94      //allocate memory for DataStorage(circular reference, need to break it)
95 <    model->setSnapshotManager(new SimSnapshotManager(model);
95 >    info->setSnapshotManager(new SimSnapshotManager(info);
96      
97      //load initial coordinates
98 <    DumpReader reader();
99 <    reader.readFrame(model);
98 >    DumpReader reader(info->getInitFilename());
99 >    int nframes = reader->getNframes();
100 >
101 >    if (nframes > 0) {
102 >        reader.readFrame(info, nframes - 1);
103 >    } else {
104 >        //invalid initial coordinate file
105 >        
106 >    }
107 >
108      
109      //initialize fortran    
110 <    return model;
110 >    
111 >    return info;
112   }    
113  
114   void SimCreator::gatherParameters(SimModel* model) {
# Line 114 | Line 128 | Molecule* SimCreator::createMolecule() {
128   }
129   #endif
130  
131 < Molecule* SimCreator::createMolecule() {
118 <    Molecule* mol = new Molecule();
131 > Molecule* SimCreator::createMolecules(SimInfo* info) {
132  
133  
121    //create atoms
122    mol->addAtom();
123
124    //create rigid bodies
125    createRigidBody(mol);
134      
135 <    //create bonds
135 >    for (i = 0; i < mpiSim->getNMolGlobal(); i++){
136 >        if (mol2proc[i] == worldRank){
137  
138 <    
139 <    
138 >            Molecule* mol = MoleculeCreator.createMolecule(molStamp, stampID, globalIndex);
139 >                        
140 >            info->addMolecule(mol);
141 >        }
142 >    }        
143 >      
144   }
145  
146 +
147 + void SimSetup::compList(MakeStamps* stamps,SimInfo* info) {
148 +    int i;
149 +    char* id;
150 +    MoleculeStamp* currentStamp;
151 +    Component* the_components = info->getGlobals()->getComponents();
152 +    int n_components = info->getGlobals()->getNComponents();
153 +
154 +    if (!globals->haveNMol()){
155 +        // we don't have the total number of molecules, so we assume it is
156 +        // given in each component
157 +
158 +        for (i = 0; i < n_components; i++){
159 +            if (!the_components[i]->haveNMol()){
160 +                // we have a problem
161 +                sprintf(painCave.errMsg,
162 +                    "SimSetup Error. No global NMol or component NMol given.\n"
163 +                    "\tCannot calculate the number of atoms.\n");
164 +                painCave.isFatal = 1;
165 +                simError();
166 +            }
167 +
168 +            id = the_components[i]->getType();
169 +            currentStamp = stamps->extractMolStamp(id);
170 +            if (currentStamp == NULL){
171 +                sprintf(painCave.errMsg,
172 +                    "SimSetup error: Component \"%s\" was not found in the "
173 +                    "list of declared molecules\n",
174 +                    id);
175 +                painCave.isFatal = 1;
176 +                simError();
177 +            }      
178 +
179 +            info.moleculeStamps.push_back(make_pair(currentStamp, the_components[i]->getNMol()));
180 +          
181 +        } //end for (i = 0; i < n_components; i++)
182 +        
183 +    } else{
184 +        sprintf(painCave.errMsg,
185 +                "SimSetup error.\n"
186 +                "\tSorry, the ability to specify total"
187 +                " nMols and then give molfractions in the components\n"
188 +                "\tis not currently supported."
189 +                " Please give nMol in the components.\n");
190 +        painCave.isFatal = 1;
191 +        simError();
192 +    }
193 +  
194 + #ifdef IS_MPI
195 +  strcpy(checkPointMsg, "Component stamps successfully extracted\n");
196 +  MPIcheckPoint();
197 + #endif // is_mpi
198 + }
199 +
200 +
201   } //end namespace oopse

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines