ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-4/src/UseTheForce/DUFF.cpp
Revision: 1837
Committed: Thu Dec 2 22:15:31 2004 UTC (19 years, 7 months ago) by tim
File size: 4004 byte(s)
Log Message:
refine factory pattern to make it initialized correctly

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 #include "UseTheForce/DUFF.hpp"
27 #include "UseTheForce/DarkSide/lj_interface.h"
28 #include "UseTheForce/DarkSide/charge_interface.h"
29 #include "UseTheForce/DarkSide/dipole_interface.h"
30 #include "UseTheForce/DarkSide/sticky_interface.h"
31 #include "UseTheForce/ForceFieldFactory.hpp"
32 #include "io/DirectionalAtomTypesSectionParser.hpp"
33 #include "io/AtomTypesSectionParser.hpp"
34 #include "io/LennardJonesAtomTypesSectionParser.hpp"
35 #include "io/ElectrostaticAtomTypesSectionParser.hpp"
36 #include "io/EAMAtomTypesSectionParser.hpp"
37 #include "io/StickyAtomTypesSectionParser.hpp"
38 #include "io/BondTypesSectionParser.hpp"
39 #include "io/BendTypesSectionParser.hpp"
40 #include "io/TorsionTypesSectionParser.hpp"
41 #include "UseTheForce/ForceFieldCreator.hpp"
42
43 namespace oopse {
44
45 static ForceFieldBuilder<DUFF>* DUFFCreator = new ForceFieldBuilder<DUFF>("DUFF");
46
47 DUFF::DUFF(){
48
49 //set default force field filename
50 setForceFieldFileName("DUFF.frc");
51
52 //the order of adding section parsers are important
53 //DirectionalAtomTypesSectionParser should be added before AtomTypesSectionParser Since
54 //These two section parsers will actually create "real" AtomTypes (AtomTypesSectionParser will create
55 //AtomType and DirectionalAtomTypesSectionParser will creat DirectionalAtomType which is a subclass
56 //of AtomType, therefore it should come first). Other AtomTypes Section Parser will not create the
57 //"real" AtomType, they only add and set some attribute of the AtomType. Thus their order are not
58 //important. AtomTypesSectionParser should be added before other atom type section parsers.
59 //Make sure they are added after DirectionalAtomTypesSectionParser and AtomTypesSectionParser.
60 //The order of BondTypesSectionParser, BendTypesSectionParser and TorsionTypesSectionParser are
61 //not important.
62 spMan_.push_back(new DirectionalAtomTypesSectionParser());
63 spMan_.push_back(new AtomTypesSectionParser());
64 spMan_.push_back(new LennardJonesAtomTypesSectionParser());
65 spMan_.push_back(new ElectrostaticAtomTypesSectionParser());
66 spMan_.push_back(new EAMAtomTypesSectionParser());
67 spMan_.push_back(new StickyAtomTypesSectionParser());
68 spMan_.push_back(new BondTypesSectionParser());
69 spMan_.push_back(new BendTypesSectionParser());
70 spMan_.push_back(new TorsionTypesSectionParser());
71
72 }
73
74 void DUFF::parse(const std::string& filename) {
75 ifstrstream* ffStream;
76 ffStream = openForceFieldFile(filename);
77
78 spMan_.parse(*ffStream, *this);
79
80 ForceField::AtomTypeContainer::MapTypeIterator i;
81 AtomType* at;
82
83 for (at = atomTypeCont_.beginType(i); at != NULL; at = atomTypeCont_.nextType(i)) {
84 at->makeFortranAtomType();
85 }
86
87 for (at = atomTypeCont_.beginType(i); at != NULL; at = atomTypeCont_.nextType(i)) {
88 at->complete();
89 }
90
91 }
92
93 } //end namespace oopse