Skip to content
Snippets Groups Projects
Commit e621f42c authored by cmaffeo2's avatar cmaffeo2
Browse files

chatgpt docs --- unsettlingly good

parent 19a7f749
No related branches found
No related tags found
No related merge requests found
/**
* @file LocalInteraction.h
* @brief Defines the LocalInteraction class and its related structures
*/
#pragma once
#include <cassert>
......@@ -5,32 +10,61 @@
#include <map>
#include "PatchOp.h"
/**
* @class LocalInteraction
* @brief Base class for local interaction
*/
class LocalInteraction : public BasePatchOp {
public:
/**
* @brief Computes interaction for a given patch
* @param patch Pointer to the patch for which interaction is to be computed
*/
virtual void compute(Patch* patch) = 0;
/**
* @brief Returns the number of patches
* @return The number of patches
*/
int num_patches() const { return 1; };
// Following relates to lazy initialized factory method
/**
* @brief Struct for defining interaction configuration
*/
struct Conf {
enum Object {Particle, RigidBody };
enum DoF {Bond, Angle, Dihedral, Bonded, NeighborhoodPair};
enum Form {Harmonic, Tabulated, LennardJones, Coulomb, LJ};
enum Backend { Default, CUDA, CPU };
enum Object {Particle, RigidBody };
enum DoF {Bond, Angle, Dihedral, Bonded, NeighborhoodPair};
enum Form {Harmonic, Tabulated, LennardJones, Coulomb, LJ};
enum Backend { Default, CUDA, CPU };
Object object_type;
DoF dof;
Form form;
Backend backend;
explicit operator int() const {return object_type*64 + dof*16 + form*4 + backend;};
Object object_type; ///< The object type
DoF dof; ///< The degree of freedom
Form form; ///< The form
Backend backend; ///< The backend for computing the interaction
/**
* @brief int Conversion operator for Conf for easy comparison
* @return The integer representation of Conf
*/
explicit operator int() const {return object_type*64 + dof*16 + form*4 + backend;};
};
/**
* @brief Factory method for obtaining a LocalInteraction object
* @param conf The configuration for the LocalInteraction object to be obtained
* @return A pointer to the LocalInteraction object
*/
static LocalInteraction* GetInteraction(Conf& conf);
private:
size_t num_interactions;
size_t num_interactions; /**< Stores the number of interactions of this type in the system. */
protected:
/**
* A map that maps interaction configurations to interaction objects.
* This map is shared across all instances of LocalInteraction and is used to
* lazily initialize and retrieve interaction objects based on their configuration.
*/
static std::map<Conf, LocalInteraction*> _interactions;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment