seams-core v2.14.0
libyodaLib, the C++ engine of d-SEAMS
Loading...
Searching...
No Matches
franzblau.hpp
Go to the documentation of this file.
1//-----------------------------------------------------------------------------------
2// d-SEAMS - Deferred Structural Elucidation Analysis for Molecular Simulations
3//
4// Copyright (c) 2018--present d-SEAMS core team
5//
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the MIT License as published by
8// the Open Source Initiative.
9//
10// A copy of the MIT License is included in the LICENSE file of this repository.
11// You should have received a copy of the MIT License along with this program.
12// If not, see <https://opensource.org/licenses/MIT>.
13//-----------------------------------------------------------------------------------
14
15#ifndef SEAMS_FRANZBLAU_H_
16#define SEAMS_FRANZBLAU_H_
17
18#include <algorithm>
19#include <array>
20#include <fstream>
21#include <iostream>
22#include <iterator>
23#include <cmath>
24#include <memory>
25#include <sstream>
26#include <string>
27#include <vector>
28
29#include <cage.hpp>
30#include <mol_sys.hpp>
31#include <seams_input.hpp>
32#include <seams_output.hpp>
33
38
43
75
76namespace primitive {
77
89struct Vertex {
91 std::vector<int> neighListIndex;
93 bool inGraph =
94 true;
95};
96
107struct Graph {
108 std::vector<Vertex> pts;
110 std::vector<std::vector<int>>
112};
113
119std::vector<std::vector<int>> ringNetwork(const std::vector<std::vector<int>> &nList,
120 int maxDepth);
121
125std::vector<int> atomRingSizeCounts(const std::vector<std::vector<int>> &nList,
126 int maxDepth);
127
131std::vector<std::vector<int>> ringNetworkMinSize(const std::vector<std::vector<int>> &nList,
132 int maxDepth, int minDepth);
133
138enum class RingRows { Auto, Vectors, Packed };
139
140std::vector<std::vector<int>> ringNetwork(const std::vector<std::vector<int>> &nList,
141 int maxDepth, RingRows rows);
142
145std::vector<std::vector<int>> ringNetwork(const std::vector<std::vector<int>> &nList,
146 int maxDepth,
147 const std::vector<char> &sources);
148
153std::vector<std::vector<int>> ringNetwork(const std::vector<int> &offsets,
154 const std::vector<int> &cols, int maxDepth,
155 const std::vector<char> &sources = {});
156
160void ringSizeCounts(const std::vector<int> &offsets, const std::vector<int> &cols,
161 int maxDepth, int *counts, int countsLen);
162
167std::vector<std::vector<int>>
168ringNetworkBalls(const std::vector<std::vector<int>> &nList, int maxDepth);
169
176[[nodiscard]] int lastRingSearchUsedBalls();
177
183 const std::vector<std::vector<int>> &neighHbondList);
184
188Graph populateGraphFromIndices(const std::vector<std::vector<int>> &nList);
189
194 const std::vector<std::vector<int>> &nList);
195
197Graph countAllRingsFromIndex(const std::vector<std::vector<int>> &neighHbondList,
198 int maxDepth);
199
201void removeNonSPrings(Graph &fullGraph);
202
204[[nodiscard]] int findRings(Graph &fullGraph, int v, std::vector<int> &visited, int maxDepth,
205 int depth, int root = -1);
206
208[[nodiscard]] int shortestPath(Graph &fullGraph, int v, int goal, std::vector<int> &path,
209 std::vector<int> &visited, int maxDepth, int depth = 1);
210
212Graph clearGraph(Graph &currentGraph);
213
214
227public:
228 explicit RingUpdater(int maxDepth);
231 RingUpdater &operator=(RingUpdater &&) noexcept;
232 RingUpdater(const RingUpdater &) = delete;
233 RingUpdater &operator=(const RingUpdater &) = delete;
234
237 const std::vector<std::vector<int>> &
238 update(const std::vector<std::vector<int>> &nList);
239
242 [[nodiscard]] int lastRecomputedSources() const;
243
245 [[nodiscard]] int lastBallsRefreshed() const;
246
251 [[nodiscard]] int lastChangedBonds() const;
252
254 [[nodiscard]] double lastChangedBondFraction() const;
255
260 void setFullPassFraction(double fraction);
261
265 void setBondCrossover(double changedBondsPerMolecule);
266
267private:
268 struct Impl;
269 std::unique_ptr<Impl> impl_;
270};
271
273 double balls_ms = 0;
274 double enumerate_ms = 0;
275 double merge_ms = 0;
276 double adj_ms = 0;
277 double ball_count_ms = 0;
278 double ball_fill_ms = 0;
279};
280
283
285void setPhaseTiming(bool on);
286
289
293void setSourceWork(double *microseconds);
294
295} // namespace primitive
296
298#endif // SEAMS_FRANZBLAU_H_
File for cage types for topological network criteria.
int lastRecomputedSources() const
void setFullPassFraction(double fraction)
RingUpdater(RingUpdater &&) noexcept
RingUpdater(int maxDepth)
int lastChangedBonds() const
const std::vector< std::vector< int > > & update(const std::vector< std::vector< int > > &nList)
double lastChangedBondFraction() const
Changed bonds per molecule on the last update.
int lastBallsRefreshed() const
Vertices whose bounded balls were rebuilt on the last update.
void setBondCrossover(double changedBondsPerMolecule)
The main molecular system handler.
Functions for generating primitive rings.
Definition franzblau.hpp:76
double takePrimitiveMs()
Primitive-test milliseconds from the last timed ringNetwork, then zero.
Graph populateGraphFromNListID(molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< std::vector< int > > &neighHbondList)
int findRings(Graph &fullGraph, int v, std::vector< int > &visited, int maxDepth, int depth, int root=-1)
Main function that searches for all rings.
void restoreEdgesFromIndices(Graph &fullGraph, const std::vector< std::vector< int > > &nList)
Graph populateGraphFromIndices(const std::vector< std::vector< int > > &nList)
void removeNonSPrings(Graph &fullGraph)
Removes the non-SP rings, using the Franzblau shortest path criterion.
void ringSizeCounts(const std::vector< int > &offsets, const std::vector< int > &cols, int maxDepth, int *counts, int countsLen)
int shortestPath(Graph &fullGraph, int v, int goal, std::vector< int > &path, std::vector< int > &visited, int maxDepth, int depth=1)
Calculates the shortest path.
std::vector< std::vector< int > > ringNetwork(const std::vector< std::vector< int > > &nList, int maxDepth)
int lastRingSearchUsedBalls()
std::vector< std::vector< int > > ringNetworkBalls(const std::vector< std::vector< int > > &nList, int maxDepth)
RingSearchSplit lastRingSearchSplit()
Balls, source enumeration and the gather from the last ringNetwork call.
void setPhaseTiming(bool on)
When set, ringNetwork records the primitive-test time in the split.
std::vector< std::vector< int > > ringNetworkMinSize(const std::vector< std::vector< int > > &nList, int maxDepth, int minDepth)
Graph countAllRingsFromIndex(const std::vector< std::vector< int > > &neighHbondList, int maxDepth)
Creates a vector of vectors of all possible rings.
void setSourceWork(double *microseconds)
Graph clearGraph(Graph &currentGraph)
Function for clearing vectors in Graph after multiple usage.
std::vector< int > atomRingSizeCounts(const std::vector< std::vector< int > > &nList, int maxDepth)
File for functions that read in files).
This contains a collection of points; contains information for a particular frame.
Definition mol_sys.hpp:173
This contains per-particle information.
Definition mol_sys.hpp:152
This is a per-frame object, containing all the vertices for the particular frame, along with the vect...
std::vector< std::vector< int > > rings
std::vector< Vertex > pts
This is a collection of elements, for each point, required for graph traversal.
Definition franzblau.hpp:89
std::vector< int > neighListIndex
This is the index according to pointCloud.
Definition franzblau.hpp:91