STORMM Source Documentation
Loading...
Searching...
No Matches
local_exclusionmask.h
1// -*-c++-*-
2#ifndef STORMM_LOCAL_EXCLUSIONMASK_H
3#define STORMM_LOCAL_EXCLUSIONMASK_H
4
5#include "copyright.h"
6#include "Accelerator/hybrid.h"
7#include "DataTypes/common_types.h"
8#include "DataTypes/stormm_vector_types.h"
9#include "Math/formulas.h"
10#include "Synthesis/atomgraph_synthesis.h"
11#include "Topology/atomgraph.h"
12#include "Topology/atomgraph_abstracts.h"
13#include "energy_enumerators.h"
14
15namespace stormm {
16namespace energy {
17
18using card::Hybrid;
19using card::HybridTargetLevel;
20using stmath::ipow;
21using synthesis::AtomGraphSynthesis;
22using topology::AtomGraph;
23using topology::ChemicalDetailsKit;
24using topology::NonbondedKit;
25
29static const ullint lmask_mode_a = 0x0LLU;
30static const ullint lmask_mode_b = 0x2000000000000000LLU;
31static const ullint lmask_mode_c = 0x4000000000000000LLU;
32static const ullint lmask_mode_d = 0x6000000000000000LLU;
33static const ullint lmask_mode_e = 0x8000000000000000LLU;
34static const ullint lmask_mode_f = 0xa000000000000000LLU;
36
39static const ullint lmask_mode_bitmask = 0xe000000000000000LLU;
40static const ullint lmask_a_excl = 0x1fffffffffffffffLLU;
41static const ullint lmask_b_excl = 0x000000007fffffffLLU;
42static const ullint lmask_b_lower_mask = 0x000001ff80000000LLU;
43static const ullint lmask_b_upper_mask = 0x0007fe0000000000LLU;
44static const ullint lmask_b_lower_shft = 0x00f8000000000000LLU;
45static const ullint lmask_b_upper_shft = 0x1f00000000000000LLU;
46static const ullint lmask_c_excl = 0x000000007fffffffLLU;
47static const ullint lmask_c_alt_mask = 0x00001fff80000000LLU;
48static const ullint lmask_c_shft = 0x1fffe00000000000LLU;
49static const ullint lmask_d_excl = 0x000000007fffffffLLU;
50static const ullint lmask_d_array_idx = 0x003fffff80000000LLU;
51static const ullint lmask_d_array_cnt = 0x1fc0000000000000LLU;
52static const ullint lmask_e_array_idx = 0x000000ffffffffffLLU;
53static const ullint lmask_e_array_cnt = 0x1fffff0000000000LLU;
54static const ullint lmask_f_idx = 0x000000000000001fLLU;
56
59static const int lmask_long_local_span = 30;
60static const int lmask_short_local_span = 15;
61static const int lmask_long_pivot_point = lmask_long_local_span + 1;
62static const int lmask_short_pivot_point = lmask_short_local_span + 1;
63static const int lmask_long_extra_span = 14;
64static const int lmask_short_extra_span = 10;
66
70static const int lmask_mode_bits = 3;
71static const int lmask_b_lower_mask_bits = lmask_short_extra_span;
72static const int lmask_b_upper_mask_bits = lmask_short_extra_span;
73static const int lmask_b_shft_bits = 5;
74static const int lmask_b_max_reach = lmask_short_local_span + 32 +
75 lmask_short_extra_span - 1;
76static const int lmask_c_alt_mask_bits = lmask_long_extra_span;
77static const int lmask_c_shft_bits = 16;
78static const int lmask_d_array_idx_bits = 23;
79static const int lmask_d_array_cnt_bits = 7;
80static const int lmask_e_array_idx_bits = 40;
81static const int lmask_e_array_cnt_bits = 21;
83
87static const int lmask_mode_pos = (2 * lmask_long_local_span) + 1;
88static const int lmask_b_lower_mask_pos = (2 * lmask_short_local_span) + 1;
89static const int lmask_b_upper_mask_pos = lmask_b_lower_mask_pos + lmask_short_extra_span;
90static const int lmask_b_lower_shft_pos = lmask_b_upper_mask_pos + lmask_short_extra_span;
91static const int lmask_b_upper_shft_pos = lmask_b_lower_shft_pos + lmask_b_shft_bits;
92static const int lmask_c_alt_mask_pos = (2 * lmask_short_local_span) + 1;
93static const int lmask_c_shft_pos = lmask_c_alt_mask_pos + lmask_c_alt_mask_bits;
94static const int lmask_d_array_idx_pos = (2 * lmask_short_local_span) + 1;
95static const int lmask_d_array_cnt_pos = lmask_d_array_idx_pos + lmask_d_array_idx_bits;
96static const int lmask_e_array_cnt_pos = 40;
98
101
105 LocalExclusionMaskReader(const int* prof_idx_in, const ullint* profiles_in,
106 const uint2* aux_masks_in);
107
117
118 const int* prof_idx;
119 const ullint* profiles;
123};
124
209public:
210
213 LocalExclusionMask(const AtomGraph *ag_in = nullptr,
214 NonbondedTheme theme_in = NonbondedTheme::ALL);
215
216 LocalExclusionMask(const AtomGraph &ag_in, NonbondedTheme theme_in = NonbondedTheme::ALL);
217
218 LocalExclusionMask(const AtomGraphSynthesis *poly_ag_in,
219 NonbondedTheme theme_in = NonbondedTheme::ALL);
220
221 LocalExclusionMask(const AtomGraphSynthesis &poly_ag_in,
222 NonbondedTheme theme_in = NonbondedTheme::ALL);
224
229 LocalExclusionMask(const LocalExclusionMask &original) = default;
230 LocalExclusionMask(LocalExclusionMask &&original) = default;
231 LocalExclusionMask& operator=(const LocalExclusionMask &other) = default;
232 LocalExclusionMask& operator=(LocalExclusionMask &&other) = default;
234
236 int getAtomCount() const;
237
246 int getProfileCount() const;
247 int getProfileCount(int mode_index) const;
249
254 int getMode(int atom_index, int system_index = 0) const;
255
257 size_t getSecondaryMaskCount() const;
258
263 ullint getProfile(int atom_index, int system_index = 0) const;
264
268 const Hybrid<uint2> getSecondaryMaskView(int atom_index, int system_index = 0);
269
273 std::vector<uint2> getSecondaryMasks(int atom_index, int system_index = 0) const;
275
278
281
295 bool testExclusion(int atom_i, int atom_j) const;
296 bool testExclusion(int atom_i, int atom_j, int system_index) const;
298
302 LocalExclusionMaskReader data(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
303
304#ifdef STORMM_USE_HPC
306 void upload();
307
309 void download();
310#endif
311
321 void setTopology(const AtomGraph *ag_in);
322 void setTopology(const AtomGraph &ag_in);
323 void setTopology(const AtomGraphSynthesis *poly_ag_in);
324 void setTopology(const AtomGraphSynthesis &poly_ag_in);
326
327private:
328
332 int total_atom_count;
333
336 NonbondedTheme theme;
337
340 int mode_a_profile_count;
341 int mode_b_profile_count;
342 int mode_c_profile_count;
343 int mode_d_profile_count;
344 int mode_e_profile_count;
345 int mode_f_profile_count;
347
349 Hybrid<int> atom_profile_codes;
350
354 Hybrid<ullint> atom_profiles;
355
359 Hybrid<uint2> secondary_masks;
360
362 AtomGraph *ag_pointer;
363
366 AtomGraphSynthesis *poly_ag_pointer;
367
371 void nullify();
372
384 void validateAtomIndex(int atom_index, int system_index = 0, const char* caller = nullptr) const;
385 void validateAtomIndex(int atom_index, const char* caller) const;
387
390 void countProfileKinds();
391
408 std::vector<int> extendMasks(const NonbondedKit<double> &nbk, const ChemicalDetailsKit &cdk);
409 std::vector<int> extendMasks(const AtomGraph *ag);
411};
412
424std::vector<int> compileLocalExclusionList(const NonbondedKit<double> &nbk, int atom_index,
425 NonbondedTheme theme, VdwCombiningRule lj_rule);
426
431std::string lMaskModeToString(ullint mode);
432
440void appendLMaskPrintout(std::string *result, const std::vector<int> &limits, ullint mask);
441
446std::string lMaskToString(ullint mask);
447
453bool lMaskFitsModeA(int atom_index, const std::vector<int> &excluded_atoms);
454
458bool lMaskFitsModeB(int atom_index, const std::vector<int> &excluded_atoms);
459
464bool lMaskFitsModeC(int atom_index, const std::vector<int> &excluded_atoms);
465
474bool lMaskFitsModeD(int atom_index, const std::vector<int> &excluded_atoms,
475 const std::vector<uint2> &tmp_secondary_masks);
476
493ullint lMaskCreateProfile(int atom_index, ullint mode, const std::vector<int> &excluded_atoms);
494
495std::vector<uint2> lMaskCreateProfile(int atom_index, ullint mode,
496 const std::vector<int> &excluded_atoms, ullint *t_profile);
498
517void setProfile(int pos, ullint tprof, std::vector<int> *profile_indices,
518 std::vector<ullint> *tmp_profiles);
519
520void setProfile(int pos, ullint tprof, ullint mode,
521 const std::vector<uint2> &tprof_secondary_masks, std::vector<int> *profile_indices,
522 std::vector<ullint> *tmp_profiles, std::vector<uint2> *tmp_secondary_masks);
524
535bool evaluateLocalMask(int atom_i, int atom_j, ullint prof, const uint2* secondary_ptr);
536
544bool testExclusion(const LocalExclusionMaskReader &lemr, int atom_i, int atom_j);
545
546} // namespace energy
547} // namespace stormm
548
549#endif
An evolution of GpuBuffer in pmemd.cuda, the Composite array has elements that are accessible from ei...
Definition hybrid.h:202
LocalExclusionMask(const LocalExclusionMask &original)=default
The default copy and move constructors as well as the copy and move assignment operator will suffice ...
LocalExclusionMaskReader data(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the abstract for the object.
Definition local_exclusionmask.cpp:198
int getAtomCount() const
Get the number of atoms in the system.
Definition local_exclusionmask.cpp:75
size_t getSecondaryMaskCount() const
Get the number of secondary masks.
Definition local_exclusionmask.cpp:117
int getProfileCount() const
Get the number of unique profiles.
Definition local_exclusionmask.cpp:80
const AtomGraph * getTopologyPointer() const
Get a pointer to the topology associated with this object.
const AtomGraphSynthesis * getTopologySynthesisPointer() const
Get a pointer to the topology synthesis associated with this object.
const Hybrid< uint2 > getSecondaryMaskView(int atom_index, int system_index=0)
Get a POINTER-kind Hybrid object for viewing all secondary masks associated with an atom....
Definition local_exclusionmask.cpp:129
ullint getProfile(int atom_index, int system_index=0) const
Get the exclusion profile for an atom.
Definition local_exclusionmask.cpp:122
bool testExclusion(int atom_i, int atom_j) const
Return TRUE if two atoms in the same molecular system share an excluded interaction and FALSE if they...
Definition local_exclusionmask.cpp:172
void setTopology(const AtomGraph *ag_in)
Set (or reset) the topology for the object. All exclusion masks and profiles will be rebuilt if the t...
Definition local_exclusionmask.cpp:220
LocalExclusionMask(const AtomGraph *ag_in=nullptr, NonbondedTheme theme_in=NonbondedTheme::ALL)
Constructor requires a topology, and creates a blank object if nullptr is supplied.
Definition local_exclusionmask.cpp:31
int getMode(int atom_index, int system_index=0) const
Get the profile mode used by a particular atom as a positive integer.
Definition local_exclusionmask.cpp:107
std::vector< uint2 > getSecondaryMasks(int atom_index, int system_index=0) const
Get a copy of all secondary masks associated with an atom. Descriptions of parameters follow from get...
A collection of one or more AtomGraph objects, with similar components arranged in contiguous arrays ...
Definition atomgraph_synthesis.h:55
A struct to hold information relating to an Amber topology. This struct's member functions are limite...
Definition atomgraph.h:50
Definition stormm_vector_types.h:40
A lean, read-only abstract for the LocalExclusionMask class.
Definition local_exclusionmask.h:100
const uint2 * aux_masks
Definition local_exclusionmask.h:121
const int * prof_idx
Profile indices of each atom.
Definition local_exclusionmask.h:118
const ullint * profiles
Definition local_exclusionmask.h:119
LocalExclusionMaskReader(const int *prof_idx_in, const ullint *profiles_in, const uint2 *aux_masks_in)
The constructor for this and other abstracts takes input arguments for each member variable....
Definition local_exclusionmask.cpp:24
LocalExclusionMaskReader(const LocalExclusionMaskReader &original)=default
As with other abstracts, the copy and move constructors are valid and can be taken in their default f...
Information on atoms and residues which may be useful for applying atom masks or identifying specific...
Definition atomgraph_abstracts.h:382
Information needed for non-bonded real-space calculations. Templating is used as above,...
Definition atomgraph_abstracts.h:287