MaMiCo 1.2
Loading...
Searching...
No Matches
MomentumInsertionConfiguration.h
1// Copyright (C) 2015 Technische Universitaet Muenchen
2// This file is part of the Mamico project. For conditions of distribution
3// and use, please see the copyright notice in Mamico's main folder, or at
4// www5.in.tum.de/mamico
5#ifndef _MOLECULARDYNAMICS_COUPLING_CONFIGURATIONS_MOMENTUMINSERTIONCONFIGURATION_H_
6#define _MOLECULARDYNAMICS_COUPLING_CONFIGURATIONS_MOMENTUMINSERTIONCONFIGURATION_H_
7
8#include "coupling/AdditiveMomentumInsertion.h"
9#include "coupling/NieVelocityImposition.h"
10#include "coupling/NoMomentumInsertion.h"
11#include "coupling/SetGivenVelocity4MomentumInsertion.h"
12#include "coupling/VelocityGradientRelaxation.h"
13#include "tarch/configuration/Configuration.h"
14#include "tarch/configuration/ParseConfiguration.h"
15#include "tarch/la/Vector.h"
16#include <iostream>
17
18namespace coupling {
19namespace configurations {
21}
22} // namespace coupling
23
25class NieTest;
26
32public:
33 // for testing: give access to variables; will only be used in the read-sense
34 friend class ::NieTest;
35
47
49 MomentumInsertionConfiguration() : _insertionType(ADDITIVE_MOMENTUM_INSERTION), _isValid(true) {}
50
53
58 std::string value;
60 if (value == "additive-momentum-insertion") {
61 _insertionType = ADDITIVE_MOMENTUM_INSERTION;
62 } else if (value == "direct-velocity-insertion") {
63 _insertionType = DIRECT_VELOCITY_INSERTION;
64 } else if (value == "velocity-gradient-relaxation") {
65 _insertionType = VELOCITY_GRADIENT_RELAXATION;
66 } else if (value == "none") {
67 _insertionType = NO_INSERTION;
68 } else if (value == "velocity-gradient-relaxation-top-only") {
70 } else if (value == "nie-velocity-imposition") {
71 _insertionType = NIE_VELOCITY_IMPOSITION;
72 } else {
73 std::cout << "ERROR coupling::MomentumInsertionConfiguration: Wrong "
74 "insertion type!"
75 << std::endl;
76 _isValid = false;
77 exit(EXIT_FAILURE);
78 }
79
80 if (_insertionType == VELOCITY_GRADIENT_RELAXATION) {
81 tarch::configuration::ParseConfiguration::readDoubleMandatory(_velocityRelaxationFactor, node, "velocity-relaxation-factor");
82 if ((_velocityRelaxationFactor <= 0.0) || (_velocityRelaxationFactor > 1.0)) {
83 std::cout << "ERROR coupling::MomentumInsertionConfiguration: "
84 "velocity-relaxation-factor="
85 << _velocityRelaxationFactor << "!";
86 std::cout << " It must be in the range (0.0,1.0]!" << std::endl;
87 _isValid = false;
88 exit(EXIT_FAILURE);
89 }
90 } else if (_insertionType == VELOCITY_GRADIENT_RELAXATION_TOPONLY) {
91 tarch::configuration::ParseConfiguration::readDoubleMandatory(_velocityRelaxationFactor, node, "velocity-relaxation-factor");
92 if ((_velocityRelaxationFactor <= 0.0) || (_velocityRelaxationFactor > 1.0)) {
93 std::cout << "ERROR coupling::MomentumInsertionConfiguration: "
94 "velocity-relaxation-factor="
95 << _velocityRelaxationFactor << "!";
96 std::cout << " It must be in the range (0.0,1.0]!" << std::endl;
97 _isValid = false;
98 exit(EXIT_FAILURE);
99 }
100 } else if (_insertionType == NIE_VELOCITY_IMPOSITION) {
101 int buf;
102 tarch::configuration::ParseConfiguration::readIntMandatory(buf, node, "innermost-overlap-layer");
103 if (buf <= 0) {
104 std::cout << "ERROR coupling::MomentumInsertionConfiguration: "
105 "innermost-overlap-layer="
106 << buf << "!" << std::endl;
107 _isValid = false;
108 exit(EXIT_FAILURE);
109 }
110 _innerOverlap = (unsigned int)buf;
111 tarch::configuration::ParseConfiguration::readIntMandatory(buf, node, "outermost-overlap-layer");
112 if (((unsigned int)buf > _innerOverlap) || (buf <= 0)) {
113 std::cout << "ERROR coupling::MomentumInsertionConfiguration: "
114 "outermost-overlap-layer="
115 << buf << "!" << std::endl;
116 _isValid = false;
117 exit(EXIT_FAILURE);
118 }
119 _outerOverlap = (unsigned int)buf;
120 }
121 }
122
126 std::string getTag() const { return "momentum-insertion"; }
127
136 bool isValid() const { return _isValid; }
137
141 const MomentumInsertionType& getMomentumInsertionType() const { return _insertionType; }
142
146 unsigned int getInnerOverlap() const { return _innerOverlap; }
147
156 template <class LinkedCell, unsigned int dim>
159 unsigned int numberMDTimestepsPerCouplingCycle) const {
160 if (_insertionType == ADDITIVE_MOMENTUM_INSERTION) {
161 return new coupling::AdditiveMomentumInsertion<LinkedCell, dim>(mdSolverInterface, numberMDTimestepsPerCouplingCycle);
162 } else if (_insertionType == DIRECT_VELOCITY_INSERTION) {
164 } else if (_insertionType == VELOCITY_GRADIENT_RELAXATION) {
165 return new coupling::VelocityGradientRelaxation<LinkedCell, dim>(_velocityRelaxationFactor, mdSolverInterface, couplingCells);
166 } else if (_insertionType == NO_INSERTION) {
167 return new coupling::NoMomentumInsertion<LinkedCell, dim>(mdSolverInterface);
168 } else if (_insertionType == VELOCITY_GRADIENT_RELAXATION_TOPONLY) {
169 return new coupling::VelocityGradientRelaxationTopOnly<LinkedCell, dim>(_velocityRelaxationFactor, mdSolverInterface, couplingCells);
170 } else if (_insertionType == NIE_VELOCITY_IMPOSITION) {
171 return new coupling::NieVelocityImposition<LinkedCell, dim>(mdSolverInterface, _outerOverlap, _innerOverlap);
172 }
173 return NULL;
174 }
175
176protected:
177 MomentumInsertionConfiguration(MomentumInsertionType insertionType) : _insertionType(insertionType), _isValid(true) {}
178
179private:
180 MomentumInsertionType _insertionType;
181 double _velocityRelaxationFactor; // required by velocity relaxation schemes
182 unsigned int _innerOverlap; // innermost layer of overlap cells (required by
183 // nie velocity imposition)
184 unsigned int _outerOverlap; // outermost layer of overlap cells (required by
185 // nie velocity imposition)
186 bool _isValid;
187};
188
189#endif // _MOLECULARDYNAMICS_COUPLING_CONFIGURATIONS_MOMENTUMINSERTIONCONFIGURATION_H_
used to manipulate the momentum/velocity of the molecules contained in a coupling cell.
Definition AdditiveMomentumInsertion.h:30
used to manipulate the momentum/ velocity of the molecules contained in a coupling cell.
Definition MomentumInsertion.h:23
Velocity imposition scheme following the respective paper by Nie et al., J. Fluid....
Definition NieVelocityImposition.h:25
dummy class. Empty momentum insertion mechanism. Doesn't change anything.
Definition NoMomentumInsertion.h:21
Definition SetGivenVelocity4MomentumInsertion.h:25
carries out velocity relaxation (similar to the SetMomentumMapping procedure).
Definition VelocityGradientRelaxation.h:106
carries out velocity relaxation (similar to the SetMomentumMapping procedure).
Definition VelocityGradientRelaxation.h:37
momentum insertion configuration. friend class: NieTest
Definition MomentumInsertionConfiguration.h:31
bool isValid() const
Definition MomentumInsertionConfiguration.h:136
unsigned int getInnerOverlap() const
Definition MomentumInsertionConfiguration.h:146
void parseSubtag(tinyxml2::XMLElement *node)
Definition MomentumInsertionConfiguration.h:57
std::string getTag() const
Definition MomentumInsertionConfiguration.h:126
virtual ~MomentumInsertionConfiguration()
Definition MomentumInsertionConfiguration.h:52
MomentumInsertionType
Definition MomentumInsertionConfiguration.h:39
@ DIRECT_VELOCITY_INSERTION
Definition MomentumInsertionConfiguration.h:41
@ VELOCITY_GRADIENT_RELAXATION_TOPONLY
Definition MomentumInsertionConfiguration.h:44
@ VELOCITY_GRADIENT_RELAXATION
Definition MomentumInsertionConfiguration.h:42
@ ADDITIVE_MOMENTUM_INSERTION
Definition MomentumInsertionConfiguration.h:40
@ NIE_VELOCITY_IMPOSITION
Definition MomentumInsertionConfiguration.h:45
@ NO_INSERTION
Definition MomentumInsertionConfiguration.h:43
const MomentumInsertionType & getMomentumInsertionType() const
Definition MomentumInsertionConfiguration.h:141
MomentumInsertionConfiguration()
Definition MomentumInsertionConfiguration.h:49
MomentumInsertion< LinkedCell, dim > * interpreteConfiguration(coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface, const coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > *const couplingCells, unsigned int numberMDTimestepsPerCouplingCycle) const
Definition MomentumInsertionConfiguration.h:157
defines the cell type with cell-averaged quantities. Derived from the class coupling::datastructures:...
Definition CouplingCellWithLinkedCells.h:26
interface to the MD simulation
Definition MDSolverInterface.h:25
Definition Configuration.h:22
static void readStringMandatory(std::string &storage, tinyxml2::XMLElement *node, std::string tag)
Definition ParseConfiguration.h:201
static void readIntMandatory(int &storage, tinyxml2::XMLElement *node, std::string tag)
Definition ParseConfiguration.h:115
static void readDoubleMandatory(double &storage, tinyxml2::XMLElement *node, std::string tag)
Definition ParseConfiguration.h:79
Definition tinyxml2.h:1268
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15