ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/applications/oopse/oopse.cpp
(Generate patch)

Comparing trunk/OOPSE-2.0/src/applications/oopse/oopse.cpp (file contents):
Revision 1501 by tim, Tue Sep 28 23:24:25 2004 UTC vs.
Revision 1930 by gezelter, Wed Jan 12 22:41:40 2005 UTC

# Line 1 | Line 1
1 < #include <iostream>
2 < #include <fstream>
3 < #include <cstdlib>
4 < #include <cmath>
5 < #include <cstring>
6 <
1 > /*
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   #ifdef IS_MPI
43   #include <mpi.h>
44   #endif
45  
11 #ifdef PROFILE
12 #include "profiling/mdProfile.hpp"
13 #endif // PROFILE
14
46   #include "utils/simError.h"
47 < #include "brains/SimSetup.hpp"
47 > #include "brains/Register.hpp"
48 > #include "brains/SimCreator.hpp"
49   #include "brains/SimInfo.hpp"
50 < #include "primitives/Atom.hpp"
50 > #include "constraints/ZconstraintForceManager.hpp"
51 > #include "integrators/IntegratorFactory.hpp"
52   #include "integrators/Integrator.hpp"
53 < #include "brains/Thermo.hpp"
54 < #include "io/ReadWrite.hpp"
55 < #include "minimizers/OOPSEMinimizer.hpp"
53 > #include "minimizers/MinimizerFactory.hpp"
54 > #include "minimizers/Minimizer.hpp"
55 > using namespace oopse;
56  
24 char* program_name;
25 using namespace std;
26
57   int main(int argc,char* argv[]){
28  
29  char* in_name;
30  SimSetup* startMe;
31  SimInfo* entry_plug;
58    
59    // first things first, all of the initializations
60  
# Line 38 | Line 64 | int main(int argc,char* argv[]){
64    
65    initSimError();           // the error handler
66    srand48( 1337 );          // the random number generator.
41
42 #ifdef PROFILE
43  initProfile();
44 #endif //profile
67    
46  // check command line arguments, and set the input file
47  
48  program_name = argv[0]; // save the program name in case we need it
49  
68   #ifdef IS_MPI
69    if( worldRank == 0 ){
70   #endif
# Line 78 | Line 96 | int main(int argc,char* argv[]){
96    }
97   #endif
98    
81  in_name = argv[1];
82
99   #ifdef IS_MPI
100    strcpy( checkPointMsg, "Successful number of arguments" );
101    MPIcheckPoint();
102   #endif
103 +
104 +
105 +
106 +    //register forcefields, integrators and minimizers
107 +    registerAll();
108 +
109 +    //create simulation model
110 +    SimCreator creator;
111 +    SimInfo* info = creator.createSim(argv[1]);
112 +    Globals* simParams = info->getSimParams();
113 +
114 +    if (simParams->haveMinimizer() && simParams->haveEnsemble()) {
115 +        sprintf(painCave.errMsg, "Minimizer keyword and Ensemble keyword can not exist together\n");
116 +        painCave.isFatal = 1;
117 +        simError();        
118 +    }
119      
120 <  // create the simulation objects, and get the show on the road
120 >    if (simParams->haveMinimizer()) {
121 >        //create minimizer
122 >        Minimizer* myMinimizer = MinimizerFactory::getInstance()->createMinimizer(simParams->getMinimizer(), info);
123  
124 <  entry_plug = new SimInfo();
125 <  startMe = new SimSetup();
124 >        if (myMinimizer == NULL) {
125 >            sprintf(painCave.errMsg, "Minimizer Factory can not create %s Minimizer\n",
126 >                    simParams->getMinimizer());
127 >            painCave.isFatal = 1;
128 >            simError();
129 >        }
130  
131 <  startMe->setSimInfo( entry_plug );
131 >        myMinimizer->minimize();
132 >        delete myMinimizer;
133 >    } else if (simParams->haveEnsemble()) {
134 >        //create Integrator
135  
136 < #ifdef PROFILE
96 <  startProfile( pro1 );
97 < #endif //profile
136 >        Integrator* myIntegrator = IntegratorFactory::getInstance()->createIntegrator(simParams->getEnsemble(), info);
137  
138 <  startMe->parseFile( in_name );
138 >        if (myIntegrator == NULL) {
139 >            sprintf(painCave.errMsg, "Integrator Factory can not create %s Integrator\n",
140 >                    simParams->getEnsemble());
141 >            painCave.isFatal = 1;
142 >            simError();
143 >        }
144 >                
145 >        //Thermodynamic Integration Method
146 >        //ForceManager* fman = new ThermodynamicForceManager(info);
147 >       //myIntegrator->setForceManager(fman);
148  
101 #ifdef PROFILE
102  endProfile( pro1 );
103  
104  startProfile( pro2 );
105 #endif //profile
149  
150 <  startMe->createSim();
151 <  delete startMe;
150 >        //Zconstraint-Method
151 >        if (simParams->haveZconstraints()) {
152 >            info->setNZconstraint(simParams->getNzConstraints());
153 >            ForceManager* fman = new ZconstraintForceManager(info);
154 >            myIntegrator->setForceManager(fman);
155 >        }
156 >        
157 >        myIntegrator->integrate();
158 >        delete myIntegrator;
159 >    }else {
160 >            sprintf(painCave.errMsg, "Integrator Factory can not create %s Integrator\n",
161 >            simParams->getEnsemble());
162 >            painCave.isFatal = 1;
163 >            simError();
164 >    }
165  
110 #ifdef PROFILE
111  endProfile( pro2 );
112  
113  startProfile( pro3 );
114 #endif //profile
166  
167 <  if (!entry_plug->has_minimizer)
168 <    entry_plug->the_integrator->integrate();
118 <  else
119 <    entry_plug->the_minimizer->minimize();
120 < #ifdef PROFILE
121 <  endProfile( pro3 );
122 <
123 <  writeProfiles();
124 < #endif //profile
167 >    
168 >    delete info;
169  
170   #ifdef IS_MPI
171    strcpy( checkPointMsg, "Oh what a lovely Tea Party!" );
172    MPIcheckPoint();
173    
174 <  MPI_Finalize();        
174 >  MPI_Finalize();
175   #endif
176  
177    return 0 ;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines