Line data Source code
1 : // This file is part of the Mamico project. For conditions of distribution
2 : // and use, please see the copyright notice in Mamico's main folder
3 :
4 : #ifndef _MOLECULARDYNAMICS_CONFIGURATIONS_DOMAINDECOMPCONFIGURATION_H_
5 : #define _MOLECULARDYNAMICS_CONFIGURATIONS_DOMAINDECOMPCONFIGURATION_H_
6 :
7 : #include "simplemd/MolecularDynamicsDefinitions.h"
8 : #include "tarch/configuration/Configuration.h"
9 : #include "tarch/la/Vector.h"
10 : #include <array>
11 : #include <iostream>
12 : #include <vector>
13 :
14 : namespace simplemd {
15 : namespace configurations {
16 : class DomainDecompConfiguration;
17 : }
18 : } // namespace simplemd
19 :
20 : /** input configuration for specifying domain decomposition type
21 : * @author Amartya Das Sharma
22 : */
23 :
24 : class simplemd::configurations::DomainDecompConfiguration : public tarch::configuration::Configuration {
25 : public:
26 : DomainDecompConfiguration();
27 408 : virtual ~DomainDecompConfiguration() {}
28 :
29 : /** enum containing the type of domain decompositions currently supported
30 : * DEFAULT : default behaviour, regularly spaced grid
31 : * STATIC_IRREG_RECT_GRID : rectilinear grid with weights given to specify subdomain sizes
32 : * E.g. x values 1,2,1 define an x axis with subdomain lengths in the 1:2:1 ratio
33 : */
34 : enum class DecompositionType { DEFAULT, STATIC_IRREG_RECT_GRID };
35 :
36 : void parseSubtag(tinyxml2::XMLElement* node);
37 :
38 : /**
39 : * Return name of xml tag that is associated to the configuration.
40 : */
41 : std::string getTag() const;
42 :
43 : /**
44 : * Is config valid?
45 : *
46 : * This operation usually fails, if
47 : *
48 : * - parseSubtag() hasn't been called, i.e. configuration has not been
49 : * used, or
50 : * - parseSubtag() failed due to a wrong file.
51 : *
52 : * If a tag isn't optional and parseSubtag() was not called (first case)
53 : */
54 : bool isValid() const;
55 :
56 : /** getters for all parsed and computed quantities */
57 : const tarch::la::Vector<MD_DIM, std::vector<unsigned int>>& getSubdomainWeights() const { return _subdomainWeights; }
58 : DecompositionType getDecompType() const { return _decompType; }
59 :
60 : private:
61 : static const std::string DECOMP_TYPE;
62 : static const std::string DEFAULT_DECOMP;
63 : static const std::string STATIC_IRREG_RECT_GRID;
64 : static const std::string AXES[MD_DIM];
65 :
66 : /** helper method to parse input string */
67 : std::vector<unsigned int> getWeightsFromString(std::string weights);
68 :
69 : /** type of decomposition */
70 : DecompositionType _decompType;
71 :
72 : /** weights parsed from the XML */
73 : tarch::la::Vector<MD_DIM, std::vector<unsigned int>> _subdomainWeights;
74 :
75 : /** whether the decomposition-type tag was present or not (since the tag is optional) */
76 : bool _isDefined;
77 :
78 : /** validity of the config */
79 : bool _isValid;
80 : };
81 :
82 : #endif // _MOLECULARDYNAMICS_CONFIGURATIONS_DOMAINDECOMPCONFIGURATION_H_
|