ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/hydrodynamics/ShapeBuilder.cpp
Revision: 2732
Committed: Tue Apr 25 02:06:12 2006 UTC (18 years, 4 months ago) by gezelter
File size: 7223 byte(s)
Log Message:
Added EAM atom types to Hydro models

File Contents

# User Rev Content
1 tim 2634 /*
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     #include "applications/hydrodynamics/ShapeBuilder.hpp"
42     #include "applications/hydrodynamics/Spheric.hpp"
43     #include "applications/hydrodynamics/Ellipsoid.hpp"
44     #include "applications/hydrodynamics/CompositeShape.hpp"
45     namespace oopse {
46 gezelter 2732
47     Shape* ShapeBuilder::createShape(StuntDouble* sd) {
48 tim 2634 Shape* currShape = NULL;
49 gezelter 2732 if (sd->isDirectionalAtom()) {
50     currShape = internalCreateShape(static_cast<DirectionalAtom*>(sd));
51     } else if (sd->isAtom()) {
52     currShape = internalCreateShape(static_cast<Atom*>(sd));
53     } else if (sd->isRigidBody()) {
54     currShape = internalCreateShape(static_cast<RigidBody*>(sd));
55     }
56     return currShape;
57     }
58    
59     Shape* ShapeBuilder::internalCreateShape(Atom* atom) {
60 tim 2634 AtomType* atomType = atom->getAtomType();
61     Shape* currShape = NULL;
62     if (atomType->isLennardJones()){
63 gezelter 2732 GenericData* data = atomType->getPropertyByName("LennardJones");
64     if (data != NULL) {
65     LJParamGenericData* ljData = dynamic_cast<LJParamGenericData*>(data);
66    
67     if (ljData != NULL) {
68     LJParam ljParam = ljData->getData();
69     currShape = new Spheric(atom->getPos(), ljParam.sigma/2.0);
70 tim 2634 } else {
71 gezelter 2732 sprintf( painCave.errMsg,
72     "Can not cast GenericData to LJParam\n");
73     painCave.severity = OOPSE_ERROR;
74     painCave.isFatal = 1;
75     simError();
76     }
77     }
78     } else if (atomType->isEAM()) {
79     GenericData* data = atomType->getPropertyByName("EAM");
80     if (data != NULL) {
81     EAMParamGenericData* eamData = dynamic_cast<EAMParamGenericData*>(data);
82    
83     if (eamData != NULL) {
84     EAMParam eamParam = eamData->getData();
85     currShape = new Spheric(atom->getPos(), eamParam.rcut);
86     } else {
87     sprintf( painCave.errMsg,
88     "Can not cast GenericData to EAMParam\n");
89     painCave.severity = OOPSE_ERROR;
90     painCave.isFatal = 1;
91     simError();
92     }
93     }
94     }
95 tim 2634 return currShape;
96 gezelter 2732 }
97    
98     Shape* ShapeBuilder::internalCreateShape(DirectionalAtom* datom) {
99 tim 2634 AtomType* atomType = datom->getAtomType();
100     Shape* currShape = NULL;
101     if (atomType->isGayBerne()) {
102 gezelter 2732 DirectionalAtomType* dAtomType = dynamic_cast<DirectionalAtomType*>(atomType);
103    
104     GenericData* data = dAtomType->getPropertyByName("GayBerne");
105     if (data != NULL) {
106     GayBerneParamGenericData* gayBerneData = dynamic_cast<GayBerneParamGenericData*>(data);
107    
108     if (gayBerneData != NULL) {
109     GayBerneParam gayBerneParam = gayBerneData->getData();
110     currShape = new Ellipsoid(datom->getPos(), gayBerneParam.GB_sigma/2.0, gayBerneParam.GB_l2b_ratio*gayBerneParam.GB_sigma/2.0, datom->getA());
111 tim 2634 } else {
112 gezelter 2732 sprintf( painCave.errMsg,
113     "Can not cast GenericData to GayBerneParam\n");
114     painCave.severity = OOPSE_ERROR;
115     painCave.isFatal = 1;
116     simError();
117     }
118     } else {
119     sprintf( painCave.errMsg, "Can not find Parameters for GayBerne\n");
120     painCave.severity = OOPSE_ERROR;
121     painCave.isFatal = 1;
122     simError();
123     }
124     } else if (atomType->isLennardJones()) {
125     GenericData* data = atomType->getPropertyByName("LennardJones");
126     if (data != NULL) {
127     LJParamGenericData* ljData = dynamic_cast<LJParamGenericData*>(data);
128    
129     if (ljData != NULL) {
130     LJParam ljParam = ljData->getData();
131     currShape = new Spheric(datom->getPos(), ljParam.sigma/2.0);
132     } else {
133     sprintf( painCave.errMsg,
134     "Can not cast GenericData to LJParam\n");
135     painCave.severity = OOPSE_ERROR;
136     painCave.isFatal = 1;
137     simError();
138     }
139     } else if (atomType->isEAM()) {
140     GenericData* data = atomType->getPropertyByName("EAM");
141 tim 2646 if (data != NULL) {
142 gezelter 2732 EAMParamGenericData* eamData = dynamic_cast<EAMParamGenericData*>(data);
143     if (eamData != NULL) {
144     EAMParam eamParam = eamData->getData();
145     currShape = new Spheric(datom->getPos(), eamParam.rcut);
146     } else {
147 tim 2646 sprintf( painCave.errMsg,
148 gezelter 2732 "Can not cast GenericData to EAMParam\n");
149 tim 2646 painCave.severity = OOPSE_ERROR;
150     painCave.isFatal = 1;
151     simError();
152 gezelter 2732 }
153 tim 2646 }
154 gezelter 2732 }
155 tim 2634 }
156     return currShape;
157 gezelter 2732 }
158 tim 2634
159 gezelter 2732 Shape* ShapeBuilder::internalCreateShape(RigidBody* rb) {
160    
161     std::vector<Atom*>::iterator ai;
162     CompositeShape* compositeShape = new CompositeShape;
163     Atom* atom;
164     for (atom = rb->beginAtom(ai); atom != NULL; atom = rb->nextAtom(ai)) {
165     Shape* currShape = NULL;
166     if (atom->isDirectionalAtom()){
167     currShape = internalCreateShape(static_cast<DirectionalAtom*>(atom));
168     }else if (atom->isAtom()){
169     currShape = internalCreateShape(static_cast<Atom*>(atom));
170     }
171     if (currShape != NULL)
172     compositeShape->addShape(currShape);
173     }
174    
175     return compositeShape;
176     }
177 tim 2634 }