Skip to content

Commit fcb8bd1

Browse files
clpetixmphoward
andauthored
Apply suggestions from code review
Co-authored-by: Michael Howard <[email protected]>
1 parent 26c3941 commit fcb8bd1

File tree

2 files changed

+12
-50
lines changed

2 files changed

+12
-50
lines changed

src/ImagePotentialBond.h

Lines changed: 10 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -34,43 +34,16 @@ namespace azplugins
3434
3535
\ingroup computes
3636
*/
37-
template<class evaluator, class Bonds> class ImagePotentialBond : public ForceCompute
37+
template<class evaluator, class Bonds> class ImagePotentialBond : public PotentialBond<evaluator, Bonds>
3838
{
39-
public:
40-
//! Param type from evaluator
41-
typedef typename evaluator::param_type param_type;
42-
43-
//! Constructs the compute
44-
ImagePotentialBond(std::shared_ptr<SystemDefinition> sysdef);
45-
46-
//! Constructs the compute with external Bond data
47-
ImagePotentialBond(std::shared_ptr<SystemDefinition> sysdef,
48-
std::shared_ptr<MeshDefinition> meshdef);
49-
50-
//! Destructor
51-
virtual ~ImagePotentialBond();
52-
53-
/// Set the parameters
54-
virtual void setParams(unsigned int type, const param_type& param);
55-
virtual void setParamsPython(std::string type, pybind11::dict param);
56-
57-
/// Get the parameters
58-
pybind11::dict getParams(std::string type);
59-
60-
/// Validate bond type
61-
virtual void validateType(unsigned int type, std::string action);
62-
6339
#ifdef ENABLE_MPI
40+
public:
6441
//! Get ghost particle fields requested by this pair potential
65-
virtual CommFlags getRequestedCommFlags(uint64_t timestep);
42+
CommFlags getRequestedCommFlags(uint64_t timestep) override;
6643
#endif
6744

6845
protected:
69-
GPUArray<param_type> m_params; //!< Bond parameters per type
70-
std::shared_ptr<Bonds> m_bond_data; //!< Bond data to use in computing bonds
71-
72-
//! Actually compute the forces
73-
virtual void computeForces(uint64_t timestep);
46+
void computeForces(uint64_t timestep) override;
7447
};
7548

7649
template<class evaluator, class Bonds>
@@ -174,7 +147,7 @@ void ImagePotentialBond<evaluator, Bonds>::computeForces(uint64_t timestep)
174147
assert(m_pdata);
175148

176149
// access the particle data arrays
177-
ArrayHandle<Scalar4> h_pos(m_pdata->getPositions(), access_location::host, access_mode::read);
150+
ArrayHandle<Scalar4> h_pos(this->m_pdata->getPositions(), access_location::host, access_mode::read);
178151
ArrayHandle<int3> h_image(m_pdata->getImages(), access_location::host, access_mode::read);
179152
ArrayHandle<unsigned int> h_rtag(m_pdata->getRTags(), access_location::host, access_mode::read);
180153
ArrayHandle<Scalar> h_charge(m_pdata->getCharges(), access_location::host, access_mode::read);
@@ -328,16 +301,9 @@ void ImagePotentialBond<evaluator, Bonds>::computeForces(uint64_t timestep)
328301
template<class evaluator, class Bonds>
329302
CommFlags ImagePotentialBond<evaluator, Bonds>::getRequestedCommFlags(uint64_t timestep)
330303
{
331-
CommFlags flags = CommFlags(0);
332-
333-
flags[comm_flag::tag] = 1;
304+
CommFlags flags = PotentialBond<evaluator, Bonds>::getRequestedCommFlags(timestep);
334305
flags[comm_flag::image] = 1;
335306

336-
if (evaluator::needsCharge())
337-
flags[comm_flag::charge] = 1;
338-
339-
flags |= ForceCompute::getRequestedCommFlags(timestep);
340-
341307
return flags;
342308
}
343309
#endif
@@ -351,11 +317,9 @@ namespace detail
351317
template<class T> void export_ImagePotentialBond(pybind11::module& m, const std::string& name)
352318
{
353319
pybind11::class_<ImagePotentialBond<T, BondData>,
354-
ForceCompute,
320+
PotentialBond<T, BondData>,
355321
std::shared_ptr<ImagePotentialBond<T, BondData>>>(m, name.c_str())
356-
.def(pybind11::init<std::shared_ptr<SystemDefinition>>())
357-
.def("setParams", &ImagePotentialBond<T, BondData>::setParamsPython)
358-
.def("getParams", &ImagePotentialBond<T, BondData>::getParams);
322+
.def(pybind11::init<std::shared_ptr<SystemDefinition>>());
359323
}
360324

361325
//! Exports the PotentialMeshBond class to python
@@ -365,11 +329,9 @@ template<class T> void export_ImagePotentialBond(pybind11::module& m, const std:
365329
template<class T> void export_PotentialMeshBond(pybind11::module& m, const std::string& name)
366330
{
367331
pybind11::class_<ImagePotentialBond<T, MeshBondData>,
368-
ForceCompute,
332+
PotentialBond<T, MeshBondData>,
369333
std::shared_ptr<ImagePotentialBond<T, MeshBondData>>>(m, name.c_str())
370-
.def(pybind11::init<std::shared_ptr<SystemDefinition>, std::shared_ptr<MeshDefinition>>())
371-
.def("setParams", &ImagePotentialBond<T, MeshBondData>::setParamsPython)
372-
.def("getParams", &ImagePotentialBond<T, MeshBondData>::getParams);
334+
.def(pybind11::init<std::shared_ptr<SystemDefinition>, std::shared_ptr<MeshDefinition>>());
373335
}
374336

375337
} // end namespace detail

src/export_ImageBondPotentialHarmonic.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ namespace azplugins
1212
{
1313
namespace detail
1414
{
15-
void export_ImageBondPotentialHarmonic(pybind11::module& m)
15+
void export_ImagePotentialBondHarmonic(pybind11::module& m)
1616
{
17-
export_ImagePotentialBond<hoomd::md::EvaluatorBondHarmonic>(m, "ImageBondPotentialHarmonic");
17+
export_ImagePotentialBond<hoomd::md::EvaluatorBondHarmonic>(m, "ImagePotentialBondHarmonic");
1818
}
1919
} // end namespace detail
2020
} // end namespace azplugins

0 commit comments

Comments
 (0)