Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2025 The plumed team 3 : (see the PEOPLE file at the root of the distribution for a list of names) 4 : 5 : See http://www.plumed.org for more information. 6 : 7 : This file is part of plumed, version 2. 8 : 9 : plumed is free software: you can redistribute it and/or modify 10 : it under the terms of the GNU Lesser General Public License as published by 11 : the Free Software Foundation, either version 3 of the License, or 12 : (at your option) any later version. 13 : 14 : plumed is distributed in the hope that it will be useful, 15 : but WITHOUT ANY WARRANTY; without even the implied warranty of 16 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 : GNU Lesser General Public License for more details. 18 : 19 : You should have received a copy of the GNU Lesser General Public License 20 : along with plumed. If not, see <http://www.gnu.org/licenses/>. 21 : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ 22 : #ifndef __PLUMED_tools_AtomDistribution_h 23 : #define __PLUMED_tools_AtomDistribution_h 24 : 25 : #include "Vector.h" 26 : #include "View.h" 27 : #include "Random.h" 28 : 29 : #include <string_view> 30 : #include <memory> 31 : #include <vector> 32 : #include <tuple> 33 : 34 : namespace PLMD { 35 : ///tested in regtest/tools/rt-make-AtomicDistribution 36 : ///Acts as a template for any distribution 37 : struct AtomDistribution { 38 : ///Update the input vectors with the position and the box of the frame 39 : void frame(std::vector<Vector>& posToUpdate, 40 : std::vector<double>& box, 41 : unsigned step, 42 : Random& rng); 43 : ///Update the input vectors with the position and the box of the frame 44 : virtual void frame(View<Vector> posToUpdate, 45 : View<double,9> box, 46 : unsigned step, 47 : Random& rng)=0; 48 : virtual ~AtomDistribution() noexcept {} 49 : ///If necessary changes the number of atoms, returns true if that number has been changed 50 : /// 51 : ///This is used principally in the benchmark. 52 : ///All the atoms distributions usually acts all the atoms passed by the vector of positions, so this does not change the input 53 : /// 54 : ///But the "reading file" ones will only work if the number of atoms is the same of the one in the file, so this set the input to that number 55 : /// 56 : ///And in case of the ones that replicate the trajectory this multiplies the input by the number of replicated "systems" this 57 : ///this is needed to inform benchmark that if you asked for replicating `N` atoms `X*Y*Z` times it will need an array of `N*X*Y*Z` atoms 58 : ///Outside of the specific usecase of the benchmark this is less important, because replicate will generate the inner trjectory on a limited 59 : ///number of atoms and the it will replicate it 60 14 : virtual bool overrideNat(unsigned& ) { 61 14 : return false; 62 : } 63 : 64 50 : struct documentation { 65 : std::string id; 66 : std::string doc; 67 : }; 68 : static std::unique_ptr<AtomDistribution> getAtomDistribution(std::string_view atomicDistr); 69 : static std::unique_ptr<AtomDistribution> decorateAtomDistribution( 70 : std::unique_ptr<AtomDistribution> && ad, 71 : std::string_view decoratorsDistr); 72 : static std::vector<std::string> getDistributionList(); 73 : static std::vector<documentation> getDistributionDocumentation(); 74 : static std::vector<std::string> getDecoratorsList(); 75 : static std::vector<documentation> getDecoratorsDocumentation(); 76 : }; 77 : 78 : } //namespace PLMD 79 : #endif // __PLUMED_tools_AtomDistribution_h