ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-2.0/src/brains/SimCreator.cpp
Revision: 1713
Committed: Fri Nov 5 02:56:22 2004 UTC (19 years, 8 months ago) by tim
File size: 3286 byte(s)
Log Message:
Pain......

File Contents

# Content
1 /*
2 * Copyright (C) 2000-2004 Object Oriented Parallel Simulation Engine (OOPSE) project
3 *
4 * Contact: oopse@oopse.org
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1
9 * of the License, or (at your option) any later version.
10 * All we ask is that proper credit is given for our work, which includes
11 * - but is not limited to - adding the above copyright notice to the beginning
12 * of your source code files, and to any copyright notice that you may distribute
13 * with programs based on this work.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 *
24 */
25
26 /**
27 * @file SimCreator.cpp
28 * @author tlin
29 * @date 11/03/2004
30 * @time 13:51am
31 * @version 1.0
32 */
33
34 #include "brains/SimCreator.hpp"
35 namespace oopse {
36
37 void SimSetup::parseFile(char* mdfile, MakeStamps* stamps, Globals* globals){
38 #ifdef IS_MPI
39 if (worldRank == 0){
40 #endif // is_mpi
41
42
43 globals->initalize();
44 set_interface_stamps(stamps, globals);
45
46 #ifdef IS_MPI
47 mpiEventInit();
48 #endif
49
50 yacc_BASS(mdfile);
51
52 #ifdef IS_MPI
53 throwMPIEvent(NULL);
54 }
55 else{
56 set_interface_stamps(stamps, globals);
57 mpiEventInit();
58 MPIcheckPoint();
59 mpiEventLoop();
60 }
61 #endif
62
63 }
64
65
66 SimModel* SimCreator::createSim(const std::string& mdfile) {
67 MakeStamps* stamps;
68
69 Globals* globals = new Globals();
70
71 //parse meta-data file
72 parseFile(mdfile, stamps, globals);
73
74 //create the force field
75 ForceFiled* ff = ForceFieldFactory::getInstance()->createForceField(globals->getForceField());
76
77 //create SimModel
78 model = new SimInfo();
79
80 //gather parameters
81 gatherParameters(model);
82
83 //divide the molecules and determine the global index of molecules
84
85 //create the molecules
86
87 //create atoms, bonds, bend, torsions, rigidbodies
88
89 //allocate memory for DataStorage(circular reference, need to break it)
90 model->setSnapshotManager(new SimSnapshotManager(model);
91
92 //load initial coordinates
93 DumpReader reader();
94 reader.readFrame(model);
95
96 //initialize fortran
97 return model;
98 }
99
100 void SimCreator::gatherParameters(SimModel* model) {
101 model->addProperty(new StringGenericData("Ensemble", globals->getForceFiled()));
102 model->addProperty(new DoubleGenericData("dt"), globals->getDt());
103 }
104
105 #ifdef IS_MPI
106 void SimCreator::mpiMolDivide(){
107
108 mpiSim = new mpiSimulation(info);
109
110 mpiSim->divideLabor();
111
112 strcpy(checkPointMsg, "Passed nlocal consistency check.");
113 MPIcheckPoint();
114 }
115 #endif
116
117 Molecule* SimCreator::createMolecule() {
118 Molecule* mol = new Molecule();
119
120
121 //create atoms
122 mol->addAtom();
123
124 //create rigid bodies
125 createRigidBody(mol);
126
127 //create bonds
128
129
130
131 }
132
133 } //end namespace oopse