MaMiCo 1.2
Loading...
Searching...
No Matches
CouetteConfiguration.h
1// Copyright (C) 2016 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 _COUETTECONFIG_H_
6#define _COUETTECONFIG_H_
7
8#include "tarch/configuration/ParseConfiguration.h"
9#include "tarch/la/Vector.h"
10
12
13namespace coupling {
14namespace configurations {
15
16struct CouetteConfig;
17}
18} // namespace coupling
26
27private:
28 // CouetteConfig(){}
29
30public:
41
45 LS1 = 2
46 };
47
51 static CouetteConfig parseCouetteConfiguration(const std::string& filename) {
52 CouetteConfig cfg;
53
55 tinyxml2::XMLElement* node = xmlConfig.root->FirstChildElement("couette-test");
56
57 if (node == NULL) {
58 std::cout << "Could not read input file " << filename
59 << ": missing element "
60 "<couette-test>"
61 << std::endl;
62 exit(EXIT_FAILURE);
63 }
64
65 tinyxml2::XMLElement* n_mamico = node->NextSiblingElement();
66 if (n_mamico == NULL) {
67 std::cout << "Could not read input file " << filename << ": missing element <mamico>" << std::endl;
68 exit(EXIT_FAILURE);
69 }
70 tinyxml2::XMLElement* n_md = n_mamico->NextSiblingElement();
71 if (n_md == NULL) {
72 std::cout << "Could not read input file " << filename
73 << ": missing element "
74 "<molecular-dynamics>"
75 << std::endl;
76 exit(EXIT_FAILURE);
77 }
79 if (n_fp == NULL) {
80 std::cout << "Could not read input file " << filename
81 << ": missing element "
82 "<filter-pipeline>"
83 << std::endl;
84 exit(EXIT_FAILURE);
85 }
86 tinyxml2::XMLElement* n_unexpected = n_fp->NextSiblingElement();
87 if (n_unexpected != NULL) {
88 std::cout << "Could not read input file " << filename << ": unknown element " << n_unexpected->Name() << std::endl;
89 exit(EXIT_FAILURE);
90 }
91
92 tinyxml2::XMLElement* subtag = node->FirstChildElement("domain");
93 if (subtag == NULL) {
94 std::cout << "Could not read input file " << filename << ": Missing subtag: domain" << std::endl;
95 exit(EXIT_FAILURE);
96 }
99 cfg.wallInitCycles = 0;
101 if (cfg.wallInitCycles > 0)
103 cfg.wallOscillations = 0;
105
106 subtag = node->FirstChildElement("coupling");
107 if (subtag == NULL) {
108 std::cout << "Could not read input file couette.xml: Missing subtag: coupling" << std::endl;
109 exit(EXIT_FAILURE);
110 }
113 tarch::configuration::ParseConfiguration::readBoolMandatory(cfg.md2Macro, subtag, "send-from-md-to-macro");
114 tarch::configuration::ParseConfiguration::readBoolMandatory(cfg.macro2Md, subtag, "send-from-macro-to-md");
118
119 subtag = node->FirstChildElement("microscopic-solver");
120 if (subtag == NULL) {
121 std::cout << "Could not read input file " << filename
122 << ": Missing subtag: "
123 "microscopic-solver"
124 << std::endl;
125 exit(EXIT_FAILURE);
126 }
127 std::string type;
129 if (type == "md") {
133
134 std::string num_MD;
135 tarch::configuration::ParseConfiguration::readStringMandatory(num_MD, subtag, "number-md-simulations");
136 if (num_MD == "dynamic") {
142 } else {
144 if (cfg.totalNumberMDSimulations < 1) {
145 std::cout << "Could not read input file " << filename
146 << ": "
147 "number-md-simulations < 1"
148 << std::endl;
149 exit(EXIT_FAILURE);
150 }
151 }
152 } else if (type == "synthetic") {
157 } else if (type == "ls1") {
158 cfg.miSolverType = LS1;
159
164 } else {
165 std::cout << "Could not read input file " << filename
166 << ": Unknown microscopic "
167 "solver type!"
168 << std::endl;
169 exit(EXIT_FAILURE);
170 }
172
173 subtag = node->FirstChildElement("macroscopic-solver");
174 if (subtag == NULL) {
175 std::cout << "Could not read input file " << filename
176 << ": Missing subtag: "
177 "macroscopic-solver"
178 << std::endl;
179 exit(EXIT_FAILURE);
180 }
183 if (type == "lb") {
187 } else if (type == "fd") {
191 }
192#if (BUILD_WITH_OPENFOAM)
193 else if (type == "foam") {
196 tarch::configuration::ParseConfiguration::readStringMandatory(cfg.foam.directory, subtag, "foam-setup-directory");
197 tarch::configuration::ParseConfiguration::readStringMandatory(cfg.foam.folder, subtag, "foam-setup-folder");
198 tarch::configuration::ParseConfiguration::readVectorMandatory<12, unsigned int>(cfg.foam.boundariesWithMD, subtag, "boundaries-with-MD");
199 }
200#endif
201 else if (type == "analytical") {
203 if (!(cfg.wallVelocity[1] == 0.0 && cfg.wallVelocity[2] == 0.0)) {
204 std::cout << "analytic solver only supports flow in x-direction" << std::endl;
205 exit(EXIT_FAILURE);
206 }
207 } else {
208 std::cout << "Could not read input file " << filename
209 << ": Unknown macroscopic "
210 "solver type!"
211 << std::endl;
212 exit(EXIT_FAILURE);
213 }
214 double vis;
216 cfg.kinVisc = vis / cfg.density;
218
219 subtag = node->FirstChildElement("tws-loop");
220 if (subtag == NULL)
221 cfg.twsLoop = false;
222 else {
223 cfg.twsLoop = true;
226 cfg.twsLoopStep = 1;
228 }
229
230 if (cfg.miSolverType == SYNTHETIC) {
231 if (cfg.macro2Md || cfg.totalNumberMDSimulations > 1 || cfg.lbNumberProcesses[0] != 1 || cfg.lbNumberProcesses[1] != 1 || cfg.lbNumberProcesses[2] != 1) {
232 std::cout << "Invalid configuration: Synthetic MD runs sequentially on "
233 "rank 0 only. "
234 << "It does neither support parallel communication nor "
235 "multi-instance sampling"
236 << std::endl;
237 exit(EXIT_FAILURE);
238 }
239 }
240 if (cfg.maSolverType == COUETTE_ANALYTICAL) {
241 if (cfg.twoWayCoupling) {
242 std::cout << "Invalid configuration: COUETTE_ANALYTICAL does not "
243 "support twoWayCoupling"
244 << std::endl;
245 exit(EXIT_FAILURE);
246 }
247 }
248
249 return cfg;
250 }
251
252#if (BUILD_WITH_OPENFOAM)
255 struct FoamConfig {
258 std::string directory;
260 std::string folder;
266 };
267#endif
268
305 double density;
307 double kinVisc;
316 double temp;
340
341#if (BUILD_WITH_OPENFOAM)
343 FoamConfig foam;
344#endif
345};
346
347#endif
Definition ParseConfiguration.h:26
static XMLConfiguration load(const std::string filename)
Definition ParseConfiguration.h:45
tinyxml2::XMLNode *const root
Definition ParseConfiguration.h:34
Definition ParseConfiguration.h:20
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 readVectorMandatory(tarch::la::Vector< size, T > &result, tinyxml2::XMLElement *node, std::string tag)
Definition ParseConfiguration.h:264
static void readIntOptional(int &storage, tinyxml2::XMLElement *node, std::string tag)
Definition ParseConfiguration.h:132
static void readIntMandatory(int &storage, tinyxml2::XMLElement *node, std::string tag)
Definition ParseConfiguration.h:115
static void readDoubleOptional(double &storage, tinyxml2::XMLElement *node, std::string tag)
Definition ParseConfiguration.h:96
static void readDoubleMandatory(double &storage, tinyxml2::XMLElement *node, std::string tag)
Definition ParseConfiguration.h:79
Definition Vector.h:24
Definition tinyxml2.h:1268
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition tinyxml2.h:1272
const XMLElement * NextSiblingElement(const char *name=0) const
Get the next (right) sibling element of this node, with an optionally supplied name.
const XMLElement * FirstChildElement(const char *name=0) const
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15
Configuration parameters for Couette flow scenario.
Definition CouetteConfiguration.h:25
double absVelErrEnd
only for dynamic MD: target absolute velocity error at end of all coupling cycles
Definition CouetteConfiguration.h:328
double density
the general density of the fluid under consideration
Definition CouetteConfiguration.h:305
bool twoWayCoupling
true if from the md solver will be applied as boundary condition for the continuum solver
Definition CouetteConfiguration.h:295
double channelheight
channel is always expected to have origin at (0.0,0.0,0.0) and to be cubic (MD 30: 50....
Definition CouetteConfiguration.h:271
double absVelErrStart
only for dynamic MD: target absolute velocity error at start of all coupling cycles
Definition CouetteConfiguration.h:326
int twsLoopMin
Definition CouetteConfiguration.h:335
int equSteps
number of equilibartion time steps = number of time steps that the md will run before the coupling is...
Definition CouetteConfiguration.h:319
int initAdvanceCycles
number of cycles the continuum solver is advanced before the coupling is enabled
Definition CouetteConfiguration.h:314
double temp
the start temperature for the fluid under consideration
Definition CouetteConfiguration.h:316
bool md2Macro
true if data will be send & received from the md to the continuum solver
Definition CouetteConfiguration.h:287
tarch::la::Vector< 3, double > wallInitVelocity
the velocity at the moving wall (z=0) while the wallInitCycles
Definition CouetteConfiguration.h:278
int lowerBoundNumberMDSimulations
the minimum number of md simulation instances in dynamic MD coupling
Definition CouetteConfiguration.h:324
bool computeSNR
true if the signal to noise ratio shall be evaluated
Definition CouetteConfiguration.h:292
tarch::la::Vector< 3, double > wallVelocity
velocity of moving wall (lower boundary moves)
Definition CouetteConfiguration.h:273
bool twsLoop
Definition CouetteConfiguration.h:333
double kinVisc
the kinematic viscosity of the fluid under consideration
Definition CouetteConfiguration.h:307
MacroSolverType
Definition CouetteConfiguration.h:32
@ COUETTE_ANALYTICAL
Definition CouetteConfiguration.h:33
@ COUETTE_LB
Definition CouetteConfiguration.h:35
@ COUETTE_FD
Definition CouetteConfiguration.h:37
@ COUETTE_FOAM
the IcoFoam solver is used (coupling::solvers::IcoFoam)
Definition CouetteConfiguration.h:39
int twsLoopMax
Definition CouetteConfiguration.h:337
double wallOscillations
total number of oscillation periods of the oscillating wall velocity
Definition CouetteConfiguration.h:281
MacroSolverType maSolverType
the type of continuum solver
Definition CouetteConfiguration.h:301
tarch::la::Vector< 3, unsigned int > lbNumberProcesses
only for LB couette solver: number of processes
Definition CouetteConfiguration.h:309
bool macro2Md
true if data will be send & received from the continuum to the md solver
Definition CouetteConfiguration.h:290
int csvEveryTimestep
the time step interval for writing the md data to csv files
Definition CouetteConfiguration.h:299
double noiseSigma
the sigma for the random noise in the case of synthetic md solver
Definition CouetteConfiguration.h:331
int totalNumberMDSimulations
the number of md simulation instances in a multi-instance coupling, -1 = dynamic
Definition CouetteConfiguration.h:322
static CouetteConfig parseCouetteConfiguration(const std::string &filename)
creates CouetteConfig if all elements exist and can be read
Definition CouetteConfiguration.h:51
int twsLoopStep
Definition CouetteConfiguration.h:339
int filterInitCycles
number of coupling cycles before a filter is applied
Definition CouetteConfiguration.h:297
MicroSolverType
Definition CouetteConfiguration.h:42
@ SIMPLEMD
the SimpleMD solver is used
Definition CouetteConfiguration.h:43
@ SYNTHETIC
the synthetic solver is used
Definition CouetteConfiguration.h:44
@ LS1
the LS1 solver is used
Definition CouetteConfiguration.h:45
int plotEveryTimestep
only for LB couette solver: VTK plotting per time step
Definition CouetteConfiguration.h:311
int couplingCycles
number of coupling cycles, that is continuum time steps; MD/DPD: 1000
Definition CouetteConfiguration.h:284
int wallInitCycles
number of coupling cycles that will be done, while the wall velocity is the wallInitVelocity
Definition CouetteConfiguration.h:276
MicroSolverType miSolverType
the type of md solver
Definition CouetteConfiguration.h:303