MaMiCo 1.2
Loading...
Searching...
No Matches
BoundaryForceConfiguration.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_BOUNDARYFORCECONFIGURATION_H_
6#define _MOLECULARDYNAMICS_COUPLING_CONFIGURATIONS_BOUNDARYFORCECONFIGURATION_H_
7
8#include "coupling/NoBoundaryForce.h"
9#include "coupling/ZhouBoundaryForceController.h"
10#include "coupling/interface/MDSolverInterface.h"
11#include "tarch/configuration/Configuration.h"
12#include "tarch/configuration/ParseConfiguration.h"
13#include "tarch/la/Vector.h"
14#include <iostream>
15
16namespace coupling {
17namespace configurations {
18template <unsigned int dim> class BoundaryForceConfiguration;
19}
20} // namespace coupling
21
28public:
36
38 BoundaryForceConfiguration() : _insertionType(NO_BOUNDARYFORCE), _density(0.0), _temperature(0.0), _isValid(true) {}
39
42
47 std::string value;
49 const std::string boundaries[6] = {"west", "east", "south", "north", "bottom", "top"};
50
51 if (value == "zhou-boundary-force") {
52 _insertionType = ZHOU;
53 } else if (value == "none") {
54 _insertionType = NO_BOUNDARYFORCE;
55 } else {
56 std::cout << "ERROR coupling::BoundaryForceConfiguration: Wrong insertion type!" << std::endl;
57 _isValid = false;
58 exit(EXIT_FAILURE);
59 }
60
61 // for all boundary force types: read the sides at which boundary force
62 // shall be applied this may not be useful for NO_BOUNDARYFORCE; however,
63 // once read, the user can still use the flags, even in the NO_BOUNDARYFORCE
64 // case, to e.g. determine a setup with boundary forcing using external
65 // implementations
66 for (unsigned int d = 0; d < 2 * dim; d++) {
67 tarch::configuration::ParseConfiguration::readBoolMandatory(_boundary[d], node, boundaries[d]);
68 }
69
70 if (_insertionType == ZHOU) {
72 if (_density <= 0.0) {
73 std::cout << "ERROR coupling::BoundaryForceConfiguration: density is "
74 "smaller than zero! Density="
75 << _density;
76 _isValid = false;
77 exit(EXIT_FAILURE);
78 }
79
81 if (_temperature <= 0.0) {
82 std::cout << "ERROR coupling::BoundaryForceConfiguration: temperature "
83 "is smaller than zero! Temperature="
84 << _temperature;
85 _isValid = false;
86 exit(EXIT_FAILURE);
87 }
88 }
89 }
90
94 std::string getTag() const { return "boundary-force"; }
95
104 bool isValid() const { return _isValid; }
105
109 const BoundaryForceType& getBoundaryForceType() const { return _insertionType; }
110
114 const tarch::la::Vector<2 * dim, bool>& getBoundary() const { return _boundary; }
115
121 template <class LinkedCell>
124 if (_insertionType == ZHOU) {
125 if (dim != 3) {
126 std::cout << "ERROR "
127 "coupling::configurations::BoundaryForceConfiguration::"
128 "interpreteConfiguration(): Zhou boundary force only "
129 "valid in 3D!"
130 << std::endl;
131 exit(EXIT_FAILURE);
132 }
133 return new coupling::ZhouBoundaryForceController<LinkedCell, dim>(_density, _temperature, _boundary, mdSolverInterface);
134 } else if (_insertionType == NO_BOUNDARYFORCE) {
135 return new coupling::NoBoundaryForce<LinkedCell, dim>(mdSolverInterface);
136 }
137 return NULL;
138 }
139
140protected:
141 BoundaryForceConfiguration(BoundaryForceType insertionType, double density, double temperature, tarch::la::Vector<2 * dim, bool> boundary)
142 : _insertionType(insertionType), _density(density), _temperature(temperature), _isValid(true) {}
143
144private:
145 BoundaryForceType _insertionType;
146 double _density;
147 double _temperature;
149 bool _isValid;
150};
151
152#endif // _MOLECULARDYNAMICS_COUPLING_CONFIGURATIONS_BOUNDARYFORCECONFIGURATION_H_
controller for forces acting at open MD boundaries
Definition BoundaryForceController.h:25
dummy implementation, applying no boundary force.
Definition NoBoundaryForce.h:21
applies the boundary force from Zhou et al. in boundary cell.
Definition ZhouBoundaryForceController.h:24
reads boundary force tag
Definition BoundaryForceConfiguration.h:27
const tarch::la::Vector< 2 *dim, bool > & getBoundary() const
Definition BoundaryForceConfiguration.h:114
virtual ~BoundaryForceConfiguration()
Definition BoundaryForceConfiguration.h:41
BoundaryForceType
Definition BoundaryForceConfiguration.h:32
@ NO_BOUNDARYFORCE
Definition BoundaryForceConfiguration.h:34
@ ZHOU
Definition BoundaryForceConfiguration.h:33
void parseSubtag(tinyxml2::XMLElement *node)
Definition BoundaryForceConfiguration.h:46
bool isValid() const
Definition BoundaryForceConfiguration.h:104
std::string getTag() const
Definition BoundaryForceConfiguration.h:94
const BoundaryForceType & getBoundaryForceType() const
Definition BoundaryForceConfiguration.h:109
BoundaryForceConfiguration()
Definition BoundaryForceConfiguration.h:38
coupling::BoundaryForceController< LinkedCell, dim > * interpreteConfiguration(coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface) const
Definition BoundaryForceConfiguration.h:123
interface to the MD simulation
Definition MDSolverInterface.h:25
Definition Configuration.h:22
static void readBoolMandatory(bool &storage, tinyxml2::XMLElement *node, std::string tag)
Definition ParseConfiguration.h:151
static void readStringMandatory(std::string &storage, tinyxml2::XMLElement *node, std::string tag)
Definition ParseConfiguration.h:201
static void readDoubleMandatory(double &storage, tinyxml2::XMLElement *node, std::string tag)
Definition ParseConfiguration.h:79
Definition Vector.h:24
Definition tinyxml2.h:1268
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15