--- trunk/src/applications/hydrodynamics/RoughShell.cpp 2006/03/15 15:51:44 898 +++ trunk/src/applications/hydrodynamics/RoughShell.cpp 2009/11/25 20:02:06 1390 @@ -6,19 +6,10 @@ * 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,84 +28,105 @@ * arising out of the use of or inability to use software, even if the * 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, 24107 (2008). + * [4] Vardeman & Gezelter, in progress (2009). */ #include "applications/hydrodynamics/RoughShell.hpp" - -namespace oopse { - -RoughShell::RoughShell(StuntDouble* sd, const DynamicProperty& extraParams) : HydrodynamicsModel(sd, extraParams), sdShape_(sd){ - DynamicProperty::const_iterator iter = extraParams.find("Sigma"); - if (iter != extraParams.end()) { - boost::any param = iter->second; - sigma_ = boost::any_cast(param); +#include "applications/hydrodynamics/ShapeBuilder.hpp" +#include "brains/SimInfo.hpp" +namespace OpenMD { + + RoughShell::RoughShell(StuntDouble* sd, SimInfo* info) : ApproximationModel(sd, info){ + shape_=ShapeBuilder::createShape(sd); + Globals* simParams = info->getSimParams(); + if (simParams->haveBeadSize()) { + sigma_ = simParams->getBeadSize(); }else { - std::cout << "RoughShell Model Error\n" ; + } -} - -struct BeadLattice { + } + + struct BeadLattice { Vector3d origin; - double radius; + RealType radius; bool interior; -}; - -struct ExteriorFunctor : public std::unary_function{ - + }; + + struct ExteriorFunctor : public std::unary_function{ + bool operator() (const BeadLattice& bead) { - return !bead.interior; + return !bead.interior; } - -}; - -struct InteriorFunctor : public std::unary_function{ - + + }; + + struct InteriorFunctor : public std::unary_function{ + bool operator() (const BeadLattice& bead) { - return bead.interior; + return bead.interior; } - -}; -bool RoughShell::createBeads(std::vector& beads) { - std::pair boxBoundary = sdShape_.getBox(); - double len = boxBoundary.second[0] - boxBoundary.first[0]; - int numLattices = static_cast(len/sigma_) + 1; + + }; + bool RoughShell::createBeads(std::vector& beads) { + std::pair boxBoundary = shape_->getBoundingBox(); + RealType firstMin = std::min(std::min(boxBoundary.first[0], boxBoundary.first[1]), boxBoundary.first[2]); + RealType secondMax = std::max(std::max(boxBoundary.second[0], boxBoundary.second[1]), boxBoundary.second[2]); + RealType len = secondMax - firstMin; + int numLattices = static_cast(len/sigma_) + 2; Grid3D grid(numLattices, numLattices, numLattices); - + //fill beads for (int i = 0; i < numLattices; ++i) { - for (int j = 0; j < numLattices; ++j) { - for (int k = 0; k < numLattices; ++k) { - BeadLattice& currentBead = grid(i, j, k); - currentBead.origin = Vector3d(i*sigma_ + boxBoundary.first[0], j *sigma_ + boxBoundary.first[1], k*sigma_+ boxBoundary.first[2]); - currentBead.radius = sigma_; - currentBead.interior = sdShape_.isInterior(grid(i, j, k).origin); - } + for (int j = 0; j < numLattices; ++j) { + for (int k = 0; k < numLattices; ++k) { + BeadLattice& currentBead = grid(i, j, k); + currentBead.origin = Vector3d((i-1)*sigma_ + boxBoundary.first[0], (j-1) *sigma_ + boxBoundary.first[1], (k-1)*sigma_+ boxBoundary.first[2]); + currentBead.radius = sigma_ / 2.0; + currentBead.interior = shape_->isInterior(grid(i, j, k).origin); } + } } - + //remove embedded beads for (int i = 0; i < numLattices; ++i) { - for (int j = 0; j < numLattices; ++j) { - for (int k = 0; k < numLattices; ++k) { - std::vector neighborCells = grid.getAllNeighbors(i, j, k); - //if one of its neighbor cells is exterior, current cell is on the surface - - std::vector::iterator ei = std::find_if(neighborCells.begin(), neighborCells.end(), ExteriorFunctor()); - std::vector::iterator ii = std::find_if(neighborCells.begin(), neighborCells.end(), InteriorFunctor()); - - if (ei != neighborCells.end() && ii != neighborCells.end()) { - BeadParam surfaceBead; - surfaceBead.atomName = "Bead"; - surfaceBead.pos = grid(i, j, k).origin; - surfaceBead.radius = grid(i, j, k).radius; - beads.push_back(surfaceBead); - } - + for (int j = 0; j < numLattices; ++j) { + for (int k = 0; k < numLattices; ++k) { + std::vector neighborCells = grid.getAllNeighbors(i, j, k); + //if one of its neighbor cells is exterior, current cell is on the surface + + if (grid(i, j, k).interior){ + + bool allNeighBorIsInterior = true; + for (std::vector::iterator l = neighborCells.begin(); l != neighborCells.end(); ++l) { + if (!l->interior) { + allNeighBorIsInterior = false; + break; + } } + + if (allNeighBorIsInterior) + continue; + + BeadParam surfaceBead; + surfaceBead.atomName = "H"; + surfaceBead.pos = grid(i, j, k).origin; + surfaceBead.radius = grid(i, j, k).radius; + beads.push_back(surfaceBead); + + } } + } } - + return true; + } + } - -}