PAPRECA hybrid off-lattice kMC/MD simulator  2.0.0 (17 September 2024)
bond.h
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------------------
2 PAPRECA hybrid off-lattice kinetic Monte Carlo/Molecular dynamics simulator.
3 Copyright (C) 2024 Stavros Ntioudis, James P. Ewen, Daniele Dini, and C. Heath Turner
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 ----------------------------------------------------------------------------------------*/
19 
22 
23 #ifndef BOND_H
24 #define BOND_H
25 
26 //System Headers
27 #include <vector>
28 #include <unordered_map>
29 #include <cstdlib>
30 #include <cstdio>
31 
32 
33 //LAMMPS headers
35 #include "pointers.h"
37 
38 //PAPRECA headers
39 #include "lammps_wrappers.h"
40 
41 
42 namespace PAPRECA{
43 
44  class Bond; //Forward definition of bond class
45  typedef std::vector< Bond > BOND_VECTOR;
46  typedef std::unordered_map< LAMMPS_NS::tagint , BOND_VECTOR > ATOM2BONDS_MAP;
47 
48  class Bond{
49 
56 
57 
58  private:
59  LAMMPS_NS::tagint bond_atom = -1;
60  int bond_type = -1;
61  bool head_parent_atom = false;
62 
63  public:
64  //Constructors/Destructors
65  Bond( ); //Default
66  Bond( const LAMMPS_NS::tagint &bond_atom_in , const int &bond_type_in , const bool &head_parent_atom_in );
67  ~Bond( );
68 
69  //Member functions
70  const LAMMPS_NS::tagint &getBondAtom( ) const;
71  const int &getBondType( ) const;
72  bool parentAtomIsHead( ) const;
73  void assignBondAtom( const LAMMPS_NS::tagint &bond_atom_in );
74  void assignBondType( const int &bond_type_in );
75 
76  //Static functions
77  static const bool atomIDIsMapped( LAMMPS_NS::tagint &parent_atomID , ATOM2BONDS_MAP &atomID2bonds );
78  static void addBond2BondVector( int &bond_type , LAMMPS_NS::tagint &parent_atomID , LAMMPS_NS::tagint &bond_atomID , const bool &head_atom_parent , ATOM2BONDS_MAP &atomID2bonds );
79  static void fillAtomID2BondsContainer( ATOM2BONDS_MAP &atomID2bonds , LAMMPS_NS::tagint *bonds_list , const LAMMPS_NS::bigint &bonds_num );
80  static void initAtomID2BondsMap( LAMMPS_NS::LAMMPS *lmp , const int &proc_id , ATOM2BONDS_MAP &atomID2bonds );
81  static bool atomHasBonds( const LAMMPS_NS::tagint &iatom_id , ATOM2BONDS_MAP &atomID2bonds );
82  static void recursiveCollectBondedAtoms( LAMMPS_NS::tagint &atom_id , std::vector< LAMMPS_NS::tagint > &delids_local , TAGINT_SET &delids_set , ATOM2BONDS_MAP &atomID2bonds );
83  };
84 
85 } //End of PAPRECA namespace
86 
87 #endif
Custom bond class (not to be confused with a LAMMPS bond).
Definition: bond.h:48
bool head_parent_atom
Definition: bond.h:61
void assignBondAtom(const LAMMPS_NS::tagint &bond_atom_in)
Definition: bond.cpp:37
void assignBondType(const int &bond_type_in)
Definition: bond.cpp:38
static void addBond2BondVector(int &bond_type, LAMMPS_NS::tagint &parent_atomID, LAMMPS_NS::tagint &bond_atomID, const bool &head_atom_parent, ATOM2BONDS_MAP &atomID2bonds)
Definition: bond.cpp:52
static void fillAtomID2BondsContainer(ATOM2BONDS_MAP &atomID2bonds, LAMMPS_NS::tagint *bonds_list, const LAMMPS_NS::bigint &bonds_num)
Definition: bond.cpp:75
const int & getBondType() const
Definition: bond.cpp:35
static void initAtomID2BondsMap(LAMMPS_NS::LAMMPS *lmp, const int &proc_id, ATOM2BONDS_MAP &atomID2bonds)
Definition: bond.cpp:94
LAMMPS_NS::tagint bond_atom
Definition: bond.h:59
const LAMMPS_NS::tagint & getBondAtom() const
Definition: bond.cpp:34
Bond()
Definition: bond.cpp:29
static const bool atomIDIsMapped(LAMMPS_NS::tagint &parent_atomID, ATOM2BONDS_MAP &atomID2bonds)
Definition: bond.cpp:41
bool parentAtomIsHead() const
For each bond in the system a tail and a head atom are (randomly) defined. This prevents the discover...
Definition: bond.cpp:36
static void recursiveCollectBondedAtoms(LAMMPS_NS::tagint &atom_id, std::vector< LAMMPS_NS::tagint > &delids_local, TAGINT_SET &delids_set, ATOM2BONDS_MAP &atomID2bonds)
Definition: bond.cpp:121
static bool atomHasBonds(const LAMMPS_NS::tagint &iatom_id, ATOM2BONDS_MAP &atomID2bonds)
Definition: bond.cpp:115
~Bond()
Definition: bond.cpp:31
int bond_type
Definition: bond.h:60
Declarations for LAMMPS wrapper functions.
Definition: bond.cpp:26
std::unordered_map< LAMMPS_NS::tagint, BOND_VECTOR > ATOM2BONDS_MAP
maps atom IDs to their associated PAPRECA::BOND_VECTOR to allow easy access of bonds and bond types.
Definition: bond.h:46
std::vector< Bond > BOND_VECTOR
Definition: bond.h:44
std::unordered_set< LAMMPS_NS::tagint > TAGINT_SET
Definition: utilities.h:185