Skip to content

feat: Introduce DoubleKeyedMap for more generalised storage of pair-related data - #2214

Merged
trisyoungs merged 18 commits into
dissolve2/no-atomtype-pointersfrom
dissolve2/double-keyed-map
Aug 15, 2025
Merged

feat: Introduce DoubleKeyedMap for more generalised storage of pair-related data#2214
trisyoungs merged 18 commits into
dissolve2/no-atomtype-pointersfrom
dissolve2/double-keyed-map

Conversation

@trisyoungs

@trisyoungs trisyoungs commented Jul 28, 2025

Copy link
Copy Markdown
Member

Follows #2209

This PR replaces the Array2D storage of RDFs and histograms, used extensively by PartialSet, with one based on std::map. The principal reason for doing so is detailed in #2207 and removes any dependence of calculated partials on the order of the underlying AtomTypes. A new class DoubleKeyedMap is introduced to implement this, and allows e.g. entries to be retrieved based on a key generated from two atom type names, also taking into account whether the terms i-j and j-i should be treated as equivalent (Array2D::half_ == true).

@trisyoungs
trisyoungs changed the base branch from develop2 to dissolve2/no-atomtype-pointers July 28, 2025 14:10
@trisyoungs
trisyoungs force-pushed the dissolve2/no-atomtype-pointers branch from ee8e1f4 to b61bdcf Compare July 31, 2025 12:38
@trisyoungs
trisyoungs force-pushed the dissolve2/double-keyed-map branch from 4ee479b to ff94f7a Compare August 4, 2025 14:34
@trisyoungs
trisyoungs force-pushed the dissolve2/double-keyed-map branch from ec3eb2b to 08ac2ea Compare August 13, 2025 11:41
@trisyoungs
trisyoungs marked this pull request as ready for review August 13, 2025 11:47
std::map<std::string, ValueClass> &map() { return data_; }
const std::map<std::string, ValueClass> &map() const { return data_; }
// Return number of data in map
int size() const { return data_.size(); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have the possibility that A//B == B//A, do we need something like a countUnique() method to give the effective size of the data in terms of keys that have this mirror form (thus exluding the equivalent keys)? Would that be useful information to access from the point of view of the simulation?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. You might expect this to be quite a useful number ( the total number of unique pairs is (N * (N+1)) / 2)) but if you're not storing it in a 2D matrix and are just looking up numbers then you don't need to know, which is kinda nice.

Co-authored-by: Tristan Youngs <trisyoungs@googlemail.com>
@trisyoungs
trisyoungs merged commit 0468e2f into dissolve2/no-atomtype-pointers Aug 15, 2025
@trisyoungs
trisyoungs deleted the dissolve2/double-keyed-map branch August 15, 2025 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants