--- trunk/src/math/Triangle.hpp 2008/10/20 19:36:32 1307 +++ trunk/src/math/Triangle.hpp 2013/06/16 15:15:42 1879 @@ -1,23 +1,14 @@ -/* Copyright (c) 2008 The University of Notre Dame. All Rights Reserved. +/* Copyright (c) 2008, 2010 The University of Notre Dame. All Rights Reserved. * * The University of Notre Dame grants you ("Licensee") a * non-exclusive, royalty free, license to use, modify and * redistribute this software in source and binary code form, provided * that the following conditions are met: * - * 1. Acknowledgement of the program authors must be made in any - * publication of scientific results based in part on use of the - * program. An acceptable form of acknowledgement is citation of - * the article in which the program was described (Matthew - * A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher - * J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented - * Parallel Simulation Engine for Molecular Dynamics," - * J. Comput. Chem. 26, pp. 252-271 (2005)) - * - * 2. Redistributions of source code must retain the above copyright + * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - * 3. Redistributions in binary form must reproduce the above copyright + * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. @@ -37,14 +28,23 @@ * University of Notre Dame has been advised of the possibility of * such damages. * + * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your + * research, please cite the appropriate papers when you publish your + * work. Good starting points are: + * + * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). + * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). + * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). + * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). + * [4] , Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). * * * Triangle.hpp * - * Purpose: Provide facets from hull to oopse + * Purpose: Provide basic triangle class for OpenMD. Hates Particle class. * * Created by Charles F. Vardeman II on 29 July 2008. * @author Charles F. Vardeman II - * @version $Id: Triangle.hpp,v 1.2 2008-10-20 19:36:32 chuckv Exp $ + * @version $Id$ * */ @@ -53,57 +53,91 @@ #define MATH_FACET_HPP #include "math/Vector3.hpp" +#include "math/SquareMatrix3.hpp" #include "config.h" #include "primitives/StuntDouble.hpp" #include -namespace oopse { +namespace OpenMD { /** * @class Triangle * - * Triangle provides geometric data to oopse. Triangle includes + * Triangle provides geometric data to OpenMD. Triangle includes * information about the normal, centroid and the atoms * that belong to this triangle. */ class Triangle { public: - Triangle(){}; + Triangle(); virtual ~Triangle() { }; void setNormal(Vector3d normal) { normal_ = normal; + HaveNormal_ = true; } + void setUnitNormal(Vector3d normal) { + unitnormal_ = normal; + HaveUnitNormal_ = true; + } - void addVertex(StuntDouble* thisSD){ + void addVertices(Vector3d P1, Vector3d P2, Vector3d P3); + + void addVertexSD(StuntDouble* thisSD){ vertexSD_.push_back(thisSD); } - + std::vector getVertices(){return vertexSD_;} void setArea(RealType area) { area_ = area; + HaveArea_ = true; } - Vector3d getNormal() { - return normal_; + Vector3d getNormal() { + if (HaveNormal_) { + return normal_; + } else { + return computeNormal(); + } } + Vector3d getUnitNormal() { + if (HaveUnitNormal_) { + return unitnormal_; + } else { + return computeUnitNormal(); + } + } RealType getArea() { - return area_; + if(HaveArea_){ + return area_; + }else{ + return computeArea(); + } } + RealType computeArea(); + Vector3d computeNormal(); + Vector3d computeCentroid(); + Vector3d computeUnitNormal(); + void setCentroid(Vector3d centroid) { centroid_ = centroid; + HaveCentroid_ = true; } - Vector3d getCentroid() { - return centroid_; + Vector3d getCentroid() { + if (HaveCentroid_) { + return centroid_; + } else { + return computeCentroid(); + } } - + Vector3d getFacetVelocity(){ return facetVelocity_; } @@ -112,20 +146,80 @@ namespace oopse { facetVelocity_ = facetVelocity; } + void setFacetMass(RealType mass){ + mass_ = mass; + } + RealType getFacetMass(){ + return mass_; + } + + RealType a(){ + return a_.length(); + } + + RealType b(){ + return b_.length(); + } + + RealType c(){ + return c_.length(); + } + + RealType getHydroLength() { + RealType a1 = a(); + RealType b1 = b(); + RealType c1 = c(); + RealType t1 = a1 + b1 + c1; + RealType t4 = a1 + b1 - c1; + + return 32.0 * c1 / log(t1*t1/t4/t4); + } + + + RealType getIncircleRadius() { + return 2.0 * getArea() / (a() + b() + c()); + } + + RealType getCircumcircleRadius() { + RealType a1 = a(); + RealType b1 = b(); + RealType c1 = c(); + RealType t1 = a1 + b1 + c1; + RealType t2 = -a1 + b1 + c1; + RealType t3 = a1 - b1 + c1; + RealType t4 = a1 + b1 - c1; + return a1 * b1 * c1 / sqrt(t1 * t2 * t3 * t4); + } + + Mat3x3d computeHydrodynamicTensor(RealType viscosity); + + private: + Mat3x3d hydro_tensor(const Vector3d& ri, const Vector3d& rj0, const Vector3d& rj1, const Vector3d& rj2,RealType s, RealType viscosity); + /* Local Indentity of vertex atoms in pos array*/ std::vector vertexSD_; Vector3d normal_; + Vector3d unitnormal_; Vector3d centroid_; - RealType area_; + Vector3d vertices_[3]; + RealType area_; + RealType mass_; Vector3d facetVelocity_; + //Length of triangle sides + Vector3d a_,b_,c_; + RealType alpha_,beta_,gamma_; + bool HaveArea_; + bool HaveNormal_; + bool HaveUnitNormal_; + bool HaveCentroid_; }; // End class Triangle -} //End Namespace oopse +} //end namespace OpenMD