Merge branch 'maint'
[hoomd-blue.git] / libhoomd / computes / ConstraintSphere.h
blob0c829466b86c77771f9d6b6365597abf82976dc8
1 /*
2 Highly Optimized Object-oriented Many-particle Dynamics -- Blue Edition
3 (HOOMD-blue) Open Source Software License Copyright 2009-2014 The Regents of
4 the University of Michigan All rights reserved.
6 HOOMD-blue may contain modifications ("Contributions") provided, and to which
7 copyright is held, by various Contributors who have granted The Regents of the
8 University of Michigan the right to modify and/or distribute such Contributions.
10 You may redistribute, use, and create derivate works of HOOMD-blue, in source
11 and binary forms, provided you abide by the following conditions:
13 * Redistributions of source code must retain the above copyright notice, this
14 list of conditions, and the following disclaimer both in the code and
15 prominently in any materials provided with the distribution.
17 * Redistributions in binary form must reproduce the above copyright notice, this
18 list of conditions, and the following disclaimer in the documentation and/or
19 other materials provided with the distribution.
21 * All publications and presentations based on HOOMD-blue, including any reports
22 or published results obtained, in whole or in part, with HOOMD-blue, will
23 acknowledge its use according to the terms posted at the time of submission on:
24 http://codeblue.umich.edu/hoomd-blue/citations.html
26 * Any electronic documents citing HOOMD-Blue will link to the HOOMD-Blue website:
27 http://codeblue.umich.edu/hoomd-blue/
29 * Apart from the above required attributions, neither the name of the copyright
30 holder nor the names of HOOMD-blue's contributors may be used to endorse or
31 promote products derived from this software without specific prior written
32 permission.
34 Disclaimer
36 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' AND
37 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
38 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND/OR ANY
39 WARRANTIES THAT THIS SOFTWARE IS FREE OF INFRINGEMENT ARE DISCLAIMED.
41 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
42 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
43 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
44 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
45 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
46 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
47 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50 // Maintainer: joaander
52 #include <boost/shared_ptr.hpp>
54 #include "ForceConstraint.h"
55 #include "ParticleGroup.h"
57 /*! \file ConstraintSphere.h
58 \brief Declares a class for computing sphere constraint forces
61 #ifdef NVCC
62 #error This header cannot be compiled by nvcc
63 #endif
65 #ifndef __CONSTRAINT_SPHERE_H__
66 #define __CONSTRAINT_SPHERE_H__
68 //! Applys a constraint force to keep a group of particles on a sphere
69 /*! \ingroup computes
71 class ConstraintSphere : public ForceConstraint
73 public:
74 //! Constructs the compute
75 ConstraintSphere(boost::shared_ptr<SystemDefinition> sysdef,
76 boost::shared_ptr<ParticleGroup> group,
77 Scalar3 P,
78 Scalar r);
80 //! Destructor
81 virtual ~ConstraintSphere();
83 //! Set the force to a new value
84 void setSphere(Scalar3 P, Scalar r);
86 //! Return the number of DOF removed by this constraint
87 virtual unsigned int getNDOFRemoved();
89 protected:
90 boost::shared_ptr<ParticleGroup> m_group; //!< Group of particles on which this constraint is applied
91 Scalar3 m_P; //!< Position of the sphere
92 Scalar m_r; //!< Radius of the sphere
94 //! Actually compute the forces
95 virtual void computeForces(unsigned int timestep);
97 private:
98 //! Validate that the sphere is in the box and all particles are very near the constraint
99 void validate();
102 //! Exports the ConstraintSphere class to python
103 void export_ConstraintSphere();
105 #endif