MaMiCo 1.2
Loading...
Searching...
No Matches
CouetteScenario.h
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, or at
3// www5.in.tum.de/mamico
4#ifndef _COUPLING_SCENARIO_COUETTESCENARIO_H_
5#define _COUPLING_SCENARIO_COUETTESCENARIO_H_
6
7#include "coupling/ErrorEstimation.h"
8#include "coupling/InstanceHandling.h"
9#include "coupling/MultiMDMediator.h"
10#include "coupling/services/ParallelTimeIntegrationService.h"
11#include "coupling/solvers/CouetteSolver.h"
12#include "coupling/solvers/LBCouetteSolver.h"
13#include "simplemd/configurations/MolecularDynamicsConfiguration.h"
14#include "tarch/configuration/ParseConfiguration.h"
15#include "tarch/utils/MultiMDService.h"
16#include "tarch/utils/RandomNumberService.h"
17#include "tarch/utils/Utils.h"
18#if (BUILD_WITH_OPENFOAM)
19#include "coupling/solvers/IcoFoamInterface.h"
20#endif
21#include "coupling/configurations/CouetteConfiguration.h"
22#include "coupling/configurations/MaMiCoConfiguration.h"
23#include "coupling/indexing/IndexingService.h"
24#include "coupling/interface/MDSimulationFactory.h"
25#include "coupling/interface/impl/SimpleMD/SimpleMDSolverInterface.h"
26#include "coupling/services/MultiMDCellService.h"
27#include "coupling/solvers/CouetteSolverInterface.h"
28#include "coupling/solvers/FDCouetteSolver.h"
29#include "coupling/solvers/LBCouetteSolverInterface.h"
30
31#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
32#include <mpi.h>
33#endif
34#include <chrono>
35#include <math.h>
36#include <random>
37#include <sys/time.h>
38
39#if defined(LS1_MARDYN)
40#include "coupling/interface/impl/ls1/LS1MDSolverInterface.h"
41#include "coupling/interface/impl/ls1/LS1StaticCommData.h"
42#include "utils/Logger.h"
43using Log::global_log;
44#endif
45
46// This is ignored if you dont use synthetic MD. For further instructions cf.
47// SYNTHETIC part of initSolvers().
48#define SYNTHETICMD_SEQUENCE "SYNTHETIC-MD"
49
69class CouetteScenario : public Scenario {
70public:
72 CouetteScenario() : Scenario("CouetteScenario"), _generator(std::chrono::system_clock::now().time_since_epoch().count()) {}
74 virtual ~CouetteScenario() {}
75
78 void run() override {
79 init();
80 if (_cfg.twsLoop) {
81 twsLoop();
82 return;
83 }
84 _timeIntegrationService->run(_cfg.couplingCycles);
85 shutdown();
86 }
87
90 void init() override {
91#if defined(LS1_MARDYN)
92 Log::global_log = std::make_unique<Log::Logger>(Log::Error); // Log::Info
93#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
94 global_log->set_mpi_output_root(0);
95#endif
96#endif
100 }
101
107 void runOneCouplingCycle(int cycle) override {
108 advanceMacro(cycle);
109 varyMD(cycle);
110 advanceMicro(cycle);
111 computeSNR(cycle);
112 twoWayCoupling(cycle);
113 if (_cfg.totalNumberMDSimulations < 0) // dynamic MD
114 _multiMDCellService->finishCycle(cycle, *_instanceHandling);
115 if (_isRootRank) {
116 // Output status info only every 10 seconds
117 gettimeofday(&_tv.end, NULL);
118 int runtime_ms = (int)(((_tv.end.tv_sec - _tv.output.tv_sec) * 1000000 + (_tv.end.tv_usec - _tv.output.tv_usec)) / 1000);
119 if (runtime_ms > 10000) {
120 std::cout << "Finish coupling cycle " << cycle << std::endl;
121 gettimeofday(&_tv.output, NULL);
122 }
123 }
124 }
125
126 coupling::solvers::AbstractCouetteSolver<3>* getSolver() override { return _couetteSolver; }
127
128protected:
130 void getRootRank() {
131 int rank = 0;
132#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
133 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
134#endif
135 _isRootRank = (rank == 0);
136 }
137
139 void twsLoop() {
140 for (_tws = _cfg.twsLoopMin; _tws <= _cfg.twsLoopMax; _tws += _cfg.twsLoopStep) {
141 init();
142 for (int cycle = 0; cycle < _cfg.couplingCycles; cycle++)
143 runOneCouplingCycle(cycle);
144 shutdown();
145 }
146 }
147
151 std::string filename("couette.xml");
152
155 if (!_simpleMDConfig.isValid()) {
156 std::cout << "ERROR CouetteScenario: Invalid SimpleMD config!" << std::endl;
157 exit(EXIT_FAILURE);
158 }
160 if (!_mamicoConfig.isValid()) {
161 std::cout << "ERROR CouetteScenario: Invalid MaMiCo config!" << std::endl;
162 exit(EXIT_FAILURE);
163 }
164
166
168 _simpleMDConfig.getDomainDecompConfiguration().getDecompType() ==
169 simplemd::configurations::DomainDecompConfiguration::DecompositionType::STATIC_IRREG_RECT_GRID) {
170 std::cout << "ERROR Currently, only LS1 supports irregular rectilinear domain decomposition! Please change md type to ls1, or decomposition to default!"
171 << std::endl;
172 exit(EXIT_FAILURE);
173 }
174
175#if defined(LS1_MARDYN)
176 auto offset = _simpleMDConfig.getDomainConfiguration().getGlobalDomainOffset();
177 coupling::interface::LS1StaticCommData::getInstance().setConfigFilename("ls1config.xml");
178 coupling::interface::LS1StaticCommData::getInstance().setBoxOffsetAtDim(0, offset[0]); // temporary till ls1 offset is natively supported
179 coupling::interface::LS1StaticCommData::getInstance().setBoxOffsetAtDim(1, offset[1]);
180 coupling::interface::LS1StaticCommData::getInstance().setBoxOffsetAtDim(2, offset[2]);
181#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
182 auto subdomainWeights = _simpleMDConfig.getDomainDecompConfiguration().getSubdomainWeights();
183 coupling::interface::LS1StaticCommData::getInstance().setSubdomainWeights(subdomainWeights);
184#endif
185#endif
186 }
187
190 void initSolvers() {
191 _timeIntegrationService = std::make_unique<coupling::services::ParallelTimeIntegrationService<3>>(_mamicoConfig, this);
192 _rank = _timeIntegrationService->getRank(); // returns the rank inside local time domain
193
195 _mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize()[0], _simpleMDConfig.getDomainConfiguration().getGlobalDomainOffset(),
196 _mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize(), getGlobalNumberCouplingCells(_simpleMDConfig, _mamicoConfig),
197 _mamicoConfig.getMomentumInsertionConfiguration().getInnerOverlap());
198
199 // init indexing
200 if (_simpleMDConfig.getDomainDecompConfiguration().getDecompType() ==
201 simplemd::configurations::DomainDecompConfiguration::DecompositionType::STATIC_IRREG_RECT_GRID) {
202 coupling::indexing::IndexingService<3>::getInstance().initWithMDSize(
203 _simpleMDConfig.getDomainDecompConfiguration().getSubdomainWeights(), _simpleMDConfig.getDomainConfiguration().getGlobalDomainSize(),
204 _simpleMDConfig.getDomainConfiguration().getGlobalDomainOffset(), _simpleMDConfig.getMPIConfiguration().getNumberOfProcesses(),
205 _mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize(), _mamicoConfig.getParallelTopologyConfiguration().getParallelTopologyType(),
206 _mamicoConfig.getMomentumInsertionConfiguration().getInnerOverlap(), (unsigned int)_rank
207#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
208 ,
209 _timeIntegrationService->getPintComm()
210#endif
211 );
212 } else {
213 coupling::indexing::IndexingService<3>::getInstance().initWithMDSize(
214 _simpleMDConfig.getDomainConfiguration().getGlobalDomainSize(), _simpleMDConfig.getDomainConfiguration().getGlobalDomainOffset(),
215 _simpleMDConfig.getMPIConfiguration().getNumberOfProcesses(), _mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize(),
216 _mamicoConfig.getParallelTopologyConfiguration().getParallelTopologyType(), _mamicoConfig.getMomentumInsertionConfiguration().getInnerOverlap(),
217 (unsigned int)_rank
218#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
219 ,
220 _timeIntegrationService->getPintComm()
221#endif
222 );
223 }
224
225 // for timing measurements
226 _tv.micro = 0;
227 _tv.macro = 0;
228 _tv.filter = 0;
229
230 // even if _cfg.miSolverType == SYNTHETIC then
231 // multiMDService, _mdSimulations, _mdSolverInterface etc need to be initialized
232
233 unsigned int totNumMD;
234 if (_cfg.totalNumberMDSimulations > 0)
235 totNumMD = _cfg.totalNumberMDSimulations;
236 else // dynamic case, start with _cfg.lowerBoundNumberMDSimulations MD
237 totNumMD = _cfg.lowerBoundNumberMDSimulations;
238
239 _multiMDService = new tarch::utils::MultiMDService<3>(_simpleMDConfig.getMPIConfiguration().getNumberOfProcesses(), totNumMD
240#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
241 ,
242 _timeIntegrationService->getPintComm()
243#endif
244 );
245
247 if (_instanceHandling == nullptr) {
248 std::cout << "ERROR CouetteScenario::initSolvers() : _instanceHandling == NULL!" << std::endl;
249 std::exit(EXIT_FAILURE);
250 }
251
252 _mdStepCounter = 0;
253 if (_isRootRank) {
254 gettimeofday(&_tv.start, NULL);
255 gettimeofday(&_tv.output, NULL);
256 }
257
259 // equilibrate MD
260 _instanceHandling->switchOffCoupling();
261 _instanceHandling->equilibrate(_cfg.equSteps, _mdStepCounter);
262 _instanceHandling->switchOnCoupling();
263 _mdStepCounter += _cfg.equSteps;
264 }
265
266 // allocate coupling interfaces
267 _instanceHandling->setMDSolverInterface();
268 _mdSolverInterface = _instanceHandling->getMDSolverInterface();
269
270 if (_cfg.twsLoop) {
271 // initialise coupling cell service for multi-MD case and set single
272 // cell services in each MD simulation
274 _mamicoConfig, "couette.xml", *_multiMDService, _tws);
275 } else {
276 // initialise coupling cell service for multi-MD case and set single
277 // cell services in each MD simulation
279 _mamicoConfig, "couette.xml", *_multiMDService);
280 }
281
282 // init filtering for all md instances
283 _multiMDCellService->constructFilterPipelines();
284
285 _multiMDMediator = new coupling::MultiMDMediator<MY_LINKEDCELL, 3>(*_multiMDCellService, *_instanceHandling, *_multiMDService, couetteSolverInterface);
286
287 // allocate solvers
288 _couetteSolver = NULL;
290 getCouetteSolver(_mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize()[0],
291 _simpleMDConfig.getSimulationConfiguration().getDt() * _simpleMDConfig.getSimulationConfiguration().getNumberOfTimesteps());
292
294 // set couette solver interface in MamicoInterfaceProvider
296
297 _instanceHandling->setCouplingCellServices(*_multiMDCellService);
298 // compute and store temperature in coupling cells (temp=1.1
299 // everywhere)
300 _multiMDCellService->computeAndStoreTemperature(_cfg.temp);
301 }
302
303 /*
304 * A synthethic solver is modeled using a dynamically linked filter,
305 * i.e. a lambda function producing artifical data in every filter step.
306 *
307 * This is how to properly instanciate and use a synthethic solver:
308 * - Create a sequence named like the macro SYNTHETICMD_SEQUENCE in xml. Use
309 * whatever input, but make sure the filter system's output is set to this
310 * sequence.
311 * - Set filtered-values = "macro-mass macro-momentum" for that sequence.
312 * - Use that sequence as input for all sequences that want (unfiltered) MD
313 * input.
314 *
315 * Note that this synthethic solver is designed to be used on sequential
316 * mode only and with only one MD instance.
317 *
318 * TODO
319 * - major bug when there is ONLY a FFF in a sequence
320 * - reduce capture: most variables in lambda can be defined beforehand as
321 * they are const (e.g. everything coming from cfg)
322 * - totalNumberMDSimulations > 1 is theoretically possible with this
323 * redesign. test it and remove the restriction for it to be 1
324 */
325
327 // Synthetic MD runs sequentially only, as described above.
328 if (_cfg.macro2Md || _cfg.totalNumberMDSimulations != 1 || _cfg.lbNumberProcesses[0] != 1 || _cfg.lbNumberProcesses[1] != 1 ||
329 _cfg.lbNumberProcesses[2] != 1) {
330 throw std::runtime_error("ERROR: Syntethic MD is only available in sequential mode!");
331 }
332
333 // set couette solver interface in MamicoInterfaceProvider
335
338
339 // Create new FilterFromFunction instance and insert it into Filtering
340 // System.
341 try {
342 _multiMDCellService->getCouplingCellService(0)
343 .getFilterPipeline()
344 ->getSequence(SYNTHETICMD_SEQUENCE)
345 ->addFilter(
346 new std::function<std::vector<double>(std::vector<double>, std::vector<std::array<unsigned int, 3>>)>{
347 // applyScalar
348 [this](std::vector<double> inputScalars, // not actually used as input:
349 // matching MCS's
350 // addFilterToSequence(...)
351 // signature
352 std::vector<std::array<unsigned int, 3>> cellIndices // not used either
353 ) {
354 if (_isRootRank) {
355 gettimeofday(&_tv.start, NULL);
356 }
357
358 // std::cout << "Entering synthetic MD scalar..." << std::endl;
359
360 const unsigned int size = inputScalars.size();
361 auto dx = coupling::indexing::IndexingService<3>::getInstance().getCouplingCellSize();
362 const tarch::la::Vector<3, double> couplingCellSize(dx);
363 const double mass = (_cfg.density) * couplingCellSize[0] * couplingCellSize[1] * couplingCellSize[2];
364
365 std::vector<double> syntheticMasses;
366 for (unsigned int i = 0; i < size; i++) {
367 syntheticMasses.push_back(mass);
368 }
369 // std::cout << "Generated masses!" << std::endl;
370
371 if (_isRootRank) {
372 gettimeofday(&_tv.end, NULL);
373 _tv.micro += (_tv.end.tv_sec - _tv.start.tv_sec) * 1000000 + (_tv.end.tv_usec - _tv.start.tv_usec);
374 }
375
376 return syntheticMasses;
377 }},
378 new std::function<std::vector<std::array<double, 3>>(std::vector<std::array<double, 3>>, std::vector<std::array<unsigned int, 3>>)>{
379 // applyVector
380 [this](std::vector<std::array<double, 3>> inputVectors, // same as above
381 std::vector<std::array<unsigned int, 3>> cellIndices // same as above
382 ) {
383 if (_isRootRank) {
384 gettimeofday(&_tv.start, NULL);
385 }
386
387 // std::cout << "Entering synthetic MD vector." << std::endl;
388
389 const unsigned int size = inputVectors.size();
390 auto dx = coupling::indexing::IndexingService<3>::getInstance().getCouplingCellSize();
391 const tarch::la::Vector<3, double> couplingCellSize(dx);
392 const double mass = (_cfg.density) * couplingCellSize[0] * couplingCellSize[1] * couplingCellSize[2];
393
394 using coupling::indexing::IndexTrait;
396
397 const tarch::la::Vector<3, double> md2MacroDomainOffset = {
398 CellIndex<3, IndexTrait::local, IndexTrait::md2macro, IndexTrait::noGhost>::lowerBoundary.get()[0] * couplingCellSize[0],
399 CellIndex<3, IndexTrait::local, IndexTrait::md2macro, IndexTrait::noGhost>::lowerBoundary.get()[1] * couplingCellSize[1],
400 CellIndex<3, IndexTrait::local, IndexTrait::md2macro, IndexTrait::noGhost>::lowerBoundary.get()[2] * couplingCellSize[2],
401 };
402
403 std::normal_distribution<double> distribution(0.0, _cfg.noiseSigma);
404 std::vector<std::array<double, 3>> syntheticMomenta;
405 for (unsigned int i = 0; i < size; i++) {
406 // determine cell midpoint
407 CellIndex<3, IndexTrait::vector> globalIndex(
408 CellIndex<3, IndexTrait::local, IndexTrait::md2macro, IndexTrait::noGhost>{i}); // construct global CellIndex from buffer
409 // and convert it to vector
410 tarch::la::Vector<3, double> cellMidPoint(md2MacroDomainOffset - 0.5 * couplingCellSize);
411 for (unsigned int d = 0; d < 3; d++) {
412 cellMidPoint[d] = cellMidPoint[d] + ((double)globalIndex.get()[d]) * couplingCellSize[d];
413 }
414
415 // compute momentum
416 const tarch::la::Vector<3, double> noise(distribution(_generator), distribution(_generator), distribution(_generator));
417 const tarch::la::Vector<3, double> momentum(mass * ((*_couetteSolver).getVelocity(cellMidPoint) + noise));
418
419 // conversion from tarch::la::Vector to std::array
420 syntheticMomenta.push_back({momentum[0], momentum[1], momentum[2]});
421 }
422 // std::cout << "Generated momenta!" << std::endl;
423
424 if (_isRootRank) {
425 gettimeofday(&_tv.end, NULL);
426 _tv.micro += (_tv.end.tv_sec - _tv.start.tv_sec) * 1000000 + (_tv.end.tv_usec - _tv.start.tv_usec);
427 }
428
429 return syntheticMomenta;
430 }},
431 0 // filterIndex
432 );
433 } catch (std::runtime_error& e) {
434 auto expectedError = std::string("ERROR: Could not find Filter Sequence named ").append(SYNTHETICMD_SEQUENCE);
435 if (expectedError.compare(e.what()) == 0) {
436 std::cout << "ERROR: Synthetic MD solver selected without providing "
437 "filter sequence '"
438 << SYNTHETICMD_SEQUENCE << "' in config." << std::endl;
439 exit(EXIT_FAILURE);
440 } else
441 throw e;
442 }
443 }
444
445 // allocate buffers for send/recv operations
446 allocateMacro2mdBuffer(*couetteSolverInterface);
447 allocateMd2macroBuffer(*couetteSolverInterface);
448
449 if (_cfg.initAdvanceCycles > 0 && _couetteSolver != NULL)
450 _couetteSolver->advance(_cfg.initAdvanceCycles * _simpleMDConfig.getSimulationConfiguration().getDt() *
451 _simpleMDConfig.getSimulationConfiguration().getNumberOfTimesteps());
452
453 // finish time measurement for initialisation
454 if (_isRootRank) {
455 gettimeofday(&_tv.end, NULL);
456 double runtime = (_tv.end.tv_sec - _tv.start.tv_sec) * 1000000 + (_tv.end.tv_usec - _tv.start.tv_usec);
457 std::cout << "Initialization: " << (int)(runtime / 1000) << "ms" << std::endl;
458 }
459
460 if (_cfg.computeSNR) {
461 std::cout << "Output for every coupling cycle, for the cell 87 in recvBuffer:" << std::endl;
462 std::cout << "cycle number (after filter-init-cycles), vel_x macroscopic "
463 "solver, vel_x filter output"
464 << std::endl;
465 _sum_signal = 0;
466 _sum_noise = 0;
467 }
468
469 if (_isRootRank) {
470 gettimeofday(&_tv.start_total, NULL);
471 }
472 std::cout << "Finish CouetteScenario::initSolvers() " << std::endl;
473 }
474
478 void advanceMacro(int cycle) {
479 if (_couetteSolver != NULL) {
480 if (_isRootRank) {
481 gettimeofday(&_tv.start, NULL);
482 }
483
484 // run one time step for macroscopic couette solver
485 if (_cfg.wallInitCycles > 0 && cycle == _cfg.wallInitCycles) {
486 _couetteSolver->setWallVelocity(_cfg.wallVelocity);
487 // When using Synthetic MD,
488 }
489 if (_cfg.wallOscillations != 0) {
490 tarch::la::Vector<3, double> vel = cycle < _cfg.wallInitCycles ? _cfg.wallInitVelocity : _cfg.wallVelocity;
491 vel = vel * cos(2 * M_PI * _cfg.wallOscillations * cycle / _cfg.couplingCycles);
492 _couetteSolver->setWallVelocity(vel);
493 }
494 _couetteSolver->advance(_simpleMDConfig.getSimulationConfiguration().getDt() * _simpleMDConfig.getSimulationConfiguration().getNumberOfTimesteps());
495 if (_isRootRank) {
496 gettimeofday(&_tv.end, NULL);
497 _tv.macro += (_tv.end.tv_sec - _tv.start.tv_sec) * 1000000 + (_tv.end.tv_usec - _tv.start.tv_usec);
498 // std::cout << "Finish _couetteSolver->advance " << std::endl;
499 }
500
501 // extract data from couette solver and send them to MD (can take any
502 // index-conversion object)
503 fillSendBuffer(_cfg.density, *_couetteSolver, _couplingBuffer.macro2MDBuffer);
504 }
505 if (_cfg.macro2Md) {
506#ifdef USE_COLLECTIVE_MPI
507 _multiMDCellService->bcastFromMacro2MD(_couplingBuffer.macro2MDBuffer);
508#else
509 _multiMDCellService->sendFromMacro2MD(_couplingBuffer.macro2MDBuffer);
510#endif
511 // std::cout << "Finish _multiMDCellService->sendFromMacro2MD " <<
512 // std::endl;
513 }
514 }
515
516 void varyMD(int cycle) {
517 // Non-dynamic case: Nothing to do.
519 return;
520
521 // modify number of instances only once every 10 cycles
522 if (cycle % 10 != 0)
523 return;
524
525 int addMDInstances = 0;
526
527 if (_rank == 0) {
528 tarch::la::Vector<3, double> vel(0, 0, 0);
529 double mass = 0;
530 for (auto pair : _couplingBuffer.md2macroBuffer) {
531 I01 idx;
533 std::tie(couplingCell, idx) = pair;
534 vel += couplingCell->getMacroscopicMomentum();
535 mass += couplingCell->getMacroscopicMass();
536 }
537 vel = vel / (double)_couplingBuffer.md2macroBuffer.size();
538 mass /= _couplingBuffer.md2macroBuffer.size();
539
540 double soundSpeed =
541 (1 / std::sqrt(3)) * (_mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize()[0] /
542 (_simpleMDConfig.getSimulationConfiguration().getDt() * _simpleMDConfig.getSimulationConfiguration().getNumberOfTimesteps()));
543 double cellVolume = _mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize()[0] *
544 _mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize()[1] *
545 _mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize()[2];
546
547 coupling::error::ErrorEstimation errorControl(vel[0], _cfg.temp, mass, _simpleMDConfig.getMoleculeConfiguration().getMass(), soundSpeed,
548 _multiMDService->getTotalNumberOfMDSimulations(), cellVolume);
549
550 double simtime = (double)cycle / _cfg.couplingCycles;
551 double targetError = _cfg.absVelErrEnd * simtime + _cfg.absVelErrStart * (1 - simtime);
552 errorControl.setAbsVelocityError(targetError);
553 double NoMD = errorControl.getCorrectorNumberOfSamples(coupling::error::ErrorEstimation::Velocity, coupling::error::ErrorEstimation::Absolute);
554
555 addMDInstances = NoMD - _multiMDService->getTotalNumberOfMDSimulations();
556 }
557
558#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
559 MPI_Bcast(&addMDInstances, 1, MPI_INT, 0, _timeIntegrationService->getPintComm());
560#endif
561 if (addMDInstances < 0) {
562 if ((int)_multiMDMediator->getNumberOfActiveMDSimulations() + addMDInstances < _cfg.lowerBoundNumberMDSimulations) {
563 addMDInstances = (_cfg.lowerBoundNumberMDSimulations - (int)_multiMDMediator->getNumberOfActiveMDSimulations());
564 }
565 }
566 if (addMDInstances < 0) {
567 if (_rank == 0)
568 std::cout << "Removing " << -addMDInstances << " of " << _multiMDService->getTotalNumberOfMDSimulations() << " MD simulations" << std::endl;
569 _multiMDMediator->rmNMDSimulations(-addMDInstances);
570 } else if (addMDInstances > 0) {
571 if (_rank == 0)
572 std::cout << "Adding " << addMDInstances << " to " << _multiMDService->getTotalNumberOfMDSimulations() << " MD simulations" << std::endl;
573 _multiMDMediator->addNMDSimulations(addMDInstances);
574 }
575 }
576
580 void advanceMicro(int cycle) {
581 if (_isRootRank) {
582 gettimeofday(&_tv.start, NULL);
583 }
585 // run MD instances
586 _instanceHandling->simulateTimesteps(_simpleMDConfig.getSimulationConfiguration().getNumberOfTimesteps(), _mdStepCounter, *_multiMDCellService);
587 // plot macroscopic time step info in multi md service
588 _multiMDCellService->plotEveryMacroscopicTimestep(cycle);
589
590 _mdStepCounter += _simpleMDConfig.getSimulationConfiguration().getNumberOfTimesteps();
591
592 if (_isRootRank) {
593 gettimeofday(&_tv.end, NULL);
594 _tv.micro += (_tv.end.tv_sec - _tv.start.tv_sec) * 1000000 + (_tv.end.tv_usec - _tv.start.tv_usec);
595 }
596
597 // send back data from MD instances and merge it
598 if (_cfg.md2Macro) {
599#ifdef USE_COLLECTIVE_MPI
600 _tv.filter += _multiMDCellService->reduceFromMD2Macro(_couplingBuffer.md2macroBuffer);
601#else
602 _tv.filter += _multiMDCellService->sendFromMD2Macro(_couplingBuffer.md2macroBuffer);
603#endif
604 // std::cout << "Finish _multiMDCellService->sendFromMD2Macro " <<
605 // std::endl;
606 }
607 }
608
610 if (_cfg.md2Macro) {
611 //_couplingBuffer does not get used here: Instead, the synthetic MD in the
612 // SYNTHETICMD_SEQUENCE generates values. To prevent segfaults, it has
613 // to be nonempty, though.
614#ifdef USE_COLLECTIVE_MPI
615 _tv.filter += _multiMDCellService->reduceFromMD2Macro(_couplingBuffer.md2macroBuffer);
616#else
617 _tv.filter += _multiMDCellService->sendFromMD2Macro(_couplingBuffer.md2macroBuffer);
618#endif
619 }
620 }
621 }
622
624 void computeSNR(int cycle) {
625 if (_cfg.computeSNR && cycle >= _cfg.filterInitCycles) {
626 std::cout << cycle - _cfg.filterInitCycles << ", ";
627 using namespace coupling::indexing;
628 const tarch::la::Vector<3, double> dx(IndexingService<3>::getInstance().getCouplingCellSize());
629 const double mass = _cfg.density * dx[0] * dx[1] * dx[2];
630 unsigned int i = 0;
631 for (auto pair : _couplingBuffer.md2macroBuffer) {
633 if (i == 87) {
634 I01 idx;
636 std::tie(couplingCell, idx) = pair;
637 auto midPoint = idx.getCellMidPoint();
638 double vx_macro = _couetteSolver->getVelocity(midPoint)[0];
639 double vx_filter = (1 / mass * couplingCell->getMacroscopicMomentum())[0];
640 _sum_noise += (vx_macro - vx_filter) * (vx_macro - vx_filter);
641 _sum_signal += vx_macro * vx_macro;
642 std::cout << vx_macro << ", " << vx_filter << std::endl;
643 }
644 i++;
645 }
646 }
647 }
648
652 void twoWayCoupling(int cycle) {
654 if (_cfg.twoWayCoupling) {
655 if ((_cfg.maSolverType == CouetteConfig::COUETTE_LB || _cfg.maSolverType == CouetteConfig::COUETTE_FD) && cycle == _cfg.filterInitCycles) {
657 ->setMDBoundary(_simpleMDConfig.getDomainConfiguration().getGlobalDomainOffset(), _simpleMDConfig.getDomainConfiguration().getGlobalDomainSize(),
658 _mamicoConfig.getMomentumInsertionConfiguration().getInnerOverlap());
659 }
660#if (BUILD_WITH_OPENFOAM)
661 else if ((_cfg.maSolverType == CouetteConfig::COUETTE_FOAM) && cycle == _cfg.filterInitCycles && _couetteSolver != NULL) {
662 static_cast<coupling::solvers::IcoFoamInterface*>(_couetteSolver)->setupMDBoundary();
663 }
664#endif
665 if ((_cfg.maSolverType == CouetteConfig::COUETTE_LB || _cfg.maSolverType == CouetteConfig::COUETTE_FD) && cycle >= _cfg.filterInitCycles) {
666 static_cast<coupling::solvers::LBCouetteSolver*>(_couetteSolver)->setMDBoundaryValues(_couplingBuffer.md2macroBuffer);
667 }
668#if (BUILD_WITH_OPENFOAM)
669 else if (_cfg.maSolverType == CouetteConfig::COUETTE_FOAM && cycle >= _cfg.filterInitCycles && _couetteSolver != NULL) {
670 static_cast<coupling::solvers::IcoFoamInterface*>(_couetteSolver)->setMDBoundaryValues(_couplingBuffer.md2macroBuffer);
671 }
672#endif
673 }
674 // write data to csv-compatible file for evaluation
675 write2CSV(_couplingBuffer.md2macroBuffer, cycle + 1);
676 }
677
680 void shutdown() {
681 if (_cfg.computeSNR) {
682 std::cout << "SNR = " << 10 * log10(_sum_signal / _sum_noise) << std::endl;
683 }
684
685 // finish time measurement for coupled simulation
686 if (_isRootRank) {
687 gettimeofday(&_tv.end, NULL);
688 double time_total = (_tv.end.tv_sec - _tv.start_total.tv_sec) * 1000000 + (_tv.end.tv_usec - _tv.start_total.tv_usec);
689 std::cout << "Finished all coupling cycles after " << time_total / 1000000 << " s" << std::endl;
690 if (_cfg.twsLoop)
691 std::cout << "TWS = " << _tws << std::endl;
692 std::cout << "Time percentages Micro, Macro, Filter, Other: " << std::endl;
693 std::cout << _tv.micro / time_total * 100 << ", " << _tv.macro / time_total * 100 << ", " << _tv.filter / time_total * 100 << ", "
694 << (1 - (_tv.micro + _tv.macro + _tv.filter) / time_total) * 100 << std::endl;
695 }
696
697 if (_instanceHandling != nullptr) {
698 delete _instanceHandling;
699 }
700
703
704 if (_multiMDService != NULL) {
705 delete _multiMDService;
706 _multiMDService = NULL;
707 }
708 if (couetteSolverInterface != NULL) {
709 delete couetteSolverInterface;
710 couetteSolverInterface = NULL;
711 }
712 if (_couetteSolver != NULL) {
713 delete _couetteSolver;
714 _couetteSolver = NULL;
715 }
716 if (_multiMDCellService != NULL) {
717 delete _multiMDCellService;
718 _multiMDCellService = NULL;
719 }
720 if (_multiMDMediator != nullptr) {
721 delete _multiMDMediator;
722 _multiMDMediator = nullptr;
723 }
724
725 std::cout << "Finish CouetteScenario::shutdown() " << std::endl;
726 }
727
729 tarch::la::Vector<3, unsigned int> getGlobalNumberCouplingCells(const simplemd::configurations::MolecularDynamicsConfiguration& simpleMDConfig,
730 const coupling::configurations::MaMiCoConfiguration<3>& mamicoConfig) const {
731 tarch::la::Vector<3, double> domainSize(simpleMDConfig.getDomainConfiguration().getGlobalDomainSize());
732 tarch::la::Vector<3, double> dx(mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize());
733 tarch::la::Vector<3, unsigned int> globalNumberCouplingCells(0);
734 for (unsigned int d = 0; d < 3; d++) {
735 int buf = floor(domainSize[d] / dx[d] + 0.5);
736 globalNumberCouplingCells[d] = (unsigned int)buf;
737 }
738 return globalNumberCouplingCells;
739 }
740
745 for (auto idx : I08()) {
746 if (!I12::contains(idx)) {
747 if (tarch::utils::contains(msi.getSourceRanks(idx), (unsigned int)_rank)) {
749 _couplingBuffer.macro2MDBuffer << std::make_pair(couplingCell, idx);
750 if (couplingCell == nullptr)
751 throw std::runtime_error(std::string("ERROR CouetteScenario::allocateMacro2mdBuffer: couplingCell==NULL!"));
752 }
753 }
754 }
755 }
756
760 for (auto idx : I12()) {
761 if (tarch::utils::contains(msi.getTargetRanks(idx), (unsigned int)_rank)) {
763 _couplingBuffer.md2macroBuffer << std::make_pair(couplingCell, idx);
764 if (couplingCell == nullptr)
765 throw std::runtime_error(std::string("ERROR CouetteScenario::allocateMacro2mdBuffer: couplingCell==NULL!"));
766 }
767 }
768 }
769
774 template <class Container_T> void write2CSV(Container_T& md2macroBuffer, int couplingCycle) const {
775 if (md2macroBuffer.size() == 0)
776 return;
777 if (_cfg.csvEveryTimestep < 1 || couplingCycle % _cfg.csvEveryTimestep > 0)
778 return;
779 // form file name and open file
780 std::stringstream ss;
781 ss << "CouetteAvgMultiMDCells_" << _timeIntegrationService->getPintDomain() << "_" << _rank << "_" << couplingCycle << ".csv";
782 std::ofstream file(ss.str().c_str());
783 if (!file.is_open()) {
784 std::cout << "ERROR CouetteScenario::write2CSV(): Could not open file " << ss.str() << "!" << std::endl;
785 exit(EXIT_FAILURE);
786 }
787
788 // loop over md2macro cells; read macroscopic mass+momentum buffers and
789 // write cell index, mass and velocity to one line in the csv-file
790 file << "I01_x,I01_y,I01_z,vel_x,vel_y,vel_z,mass" << std::endl;
791 for (auto pair : md2macroBuffer) {
792 I01 idx;
794 std::tie(couplingCell, idx) = pair;
796 if (couplingCell->getMacroscopicMass() != 0.0) {
797 vel = (1.0 / couplingCell->getMacroscopicMass()) * vel;
798 }
799 file << idx << "," << vel[0] << "," << vel[1] << "," << vel[2] << "," << couplingCell->getMacroscopicMass() << std::endl;
800 }
801
802 // close file
803 file.close();
804 }
805
812 void fillSendBuffer(const double density, const coupling::solvers::AbstractCouetteSolver<3>& couetteSolver,
815 using namespace coupling::indexing;
816 const tarch::la::Vector<3, double> dx(IndexingService<3>::getInstance().getCouplingCellSize());
817 double mass = density * dx[0] * dx[1] * dx[2];
818 for (auto pair : macro2MDBuffer) {
819 I01 idx;
821 std::tie(couplingCell, idx) = pair;
822 auto midPoint = idx.getCellMidPoint();
823 if (_cfg.maSolverType == CouetteConfig::COUETTE_LB || _cfg.maSolverType == CouetteConfig::COUETTE_FD)
824 mass *= static_cast<const coupling::solvers::LBCouetteSolver*>(&couetteSolver)->getDensity(midPoint);
825 // compute momentum
826 tarch::la::Vector<3, double> momentum(mass * couetteSolver.getVelocity(midPoint));
827 couplingCell->setMicroscopicMass(mass);
828 couplingCell->setMicroscopicMomentum(momentum);
829 }
830 }
831
838 tarch::la::Vector<3, double> vel = _cfg.wallInitCycles > 0 ? _cfg.wallInitVelocity : _cfg.wallVelocity;
839 // analytical solver: is only active on rank 0
840 if (_cfg.maSolverType == CouetteConfig::COUETTE_ANALYTICAL) {
841 if (_rank == 0 || _cfg.miSolverType == CouetteConfig::SYNTHETIC) {
842 solver = new coupling::solvers::CouetteSolver<3>(_cfg.channelheight, vel[0], _cfg.kinVisc);
843 if (solver == NULL) {
844 std::cout << "ERROR CouetteScenario::getCouetteSolver(): Analytic solver==NULL!" << std::endl;
845 exit(EXIT_FAILURE);
846 }
847 }
848 }
849#if (BUILD_WITH_OPENFOAM)
850 else if (_cfg.maSolverType == CouetteConfig::COUETTE_FOAM) {
851 solver = new coupling::solvers::IcoFoamInterface(_rank, _cfg.plotEveryTimestep, _cfg.channelheight, _cfg.foam.directory, _cfg.foam.folder,
852 _cfg.foam.boundariesWithMD, _cfg.wallVelocity);
853 if (solver == NULL) {
854 std::cout << "ERROR CouetteScenario::getCouetteSolver(): IcoFoamInterface solver==NULL!" << std::endl;
855 exit(EXIT_FAILURE);
856 }
857 }
858#endif
859 // LB solver: active on lbNumberProcesses
860 else if (_cfg.maSolverType == CouetteConfig::COUETTE_LB) {
861 solver = new coupling::solvers::LBCouetteSolver(_cfg.channelheight, vel, _cfg.kinVisc, dx, dt, _cfg.plotEveryTimestep, "LBCouette",
862 _cfg.lbNumberProcesses, 1, this);
863 if (solver == NULL) {
864 std::cout << "ERROR CouetteScenario::getCouetteSolver(): LB solver==NULL!" << std::endl;
865 exit(EXIT_FAILURE);
866 }
867 } else if (_cfg.maSolverType == CouetteConfig::COUETTE_FD) {
868 solver = new coupling::solvers::FiniteDifferenceSolver(_cfg.channelheight, vel, _cfg.kinVisc, dx, dt, _cfg.plotEveryTimestep, "FDCouette",
869 _cfg.lbNumberProcesses, 1);
870 if (solver == NULL) {
871 std::cout << "ERROR CouetteScenario::getCouetteSolver(): FD solver==NULL!" << std::endl;
872 exit(EXIT_FAILURE);
873 }
874 } else {
875 std::cout << "ERROR CouetteScenario::getCouetteSolver(): Unknown solver type!" << std::endl;
876 exit(EXIT_FAILURE);
877 }
878 return solver;
879 }
880
890 tarch::la::Vector<3, double> mamicoMeshsize,
891 tarch::la::Vector<3, unsigned int> globalNumberCouplingCells,
892 unsigned int outerRegion) {
895 if (_cfg.maSolverType == CouetteConfig::COUETTE_ANALYTICAL) {
896 interface = new coupling::solvers::CouetteSolverInterface<3>(globalNumberCouplingCells, outerRegion);
897 } else if (_cfg.maSolverType == CouetteConfig::COUETTE_LB) {
898 // compute number of cells of MD offset; detect any mismatches!
899 tarch::la::Vector<3, unsigned int> offsetMDDomain(0);
900 for (unsigned int d = 0; d < 3; d++) {
901 if (mdOffset[d] < 0.0) {
902 std::cout << "ERROR CouetteScenario::getCouetteSolverInterface(...): mdOffset[" << d << "]<0.0!" << std::endl;
903 exit(EXIT_FAILURE);
904 }
905 offsetMDDomain[d] = floor(mdOffset[d] / mamicoMeshsize[d] + 0.5);
906 if (fabs((offsetMDDomain[d] * mamicoMeshsize[d] - mdOffset[d]) / mamicoMeshsize[d]) > 1.0e-8) {
907 std::cout << "ERROR CouetteScenario::getCouetteSolverInterface: MD offset and mesh size mismatch!" << std::endl;
908 exit(EXIT_FAILURE);
909 }
910 }
911 tarch::la::Vector<3, unsigned int> cells_per_process{
913 coupling::solvers::NumericalSolver::getAvgDomainSize(_cfg.channelheight, dx, _cfg.lbNumberProcesses, 1),
914 coupling::solvers::NumericalSolver::getAvgDomainSize(_cfg.channelheight, dx, _cfg.lbNumberProcesses, 2)}};
915 interface =
916 new coupling::solvers::LBCouetteSolverInterface(cells_per_process, _cfg.lbNumberProcesses, offsetMDDomain, globalNumberCouplingCells, outerRegion);
917 }
918#if (BUILD_WITH_OPENFOAM)
919 else if (_cfg.maSolverType == CouetteConfig::COUETTE_FOAM) {
920 interface = new coupling::solvers::CouetteSolverInterface<3>(globalNumberCouplingCells, outerRegion);
921 }
922#endif
923 else if (_cfg.maSolverType == CouetteConfig::COUETTE_FD) {
924 // compute number of cells of MD offset; detect any mismatches!
925 tarch::la::Vector<3, unsigned int> offsetMDDomain(0);
926 for (unsigned int d = 0; d < 3; d++) {
927 if (mdOffset[d] < 0.0) {
928 std::cout << "ERROR CouetteScenario::getCouetteSolverInterface(...): mdOffset[" << d << "]<0.0!" << std::endl;
929 exit(EXIT_FAILURE);
930 }
931 offsetMDDomain[d] = floor(mdOffset[d] / mamicoMeshsize[d] + 0.5);
932 if (fabs((offsetMDDomain[d] * mamicoMeshsize[d] - mdOffset[d]) / mamicoMeshsize[d]) > 1.0e-8) {
933 std::cout << "ERROR CouetteScenario::getCouetteSolverInterface: MD offset and mesh size mismatch!" << std::endl;
934 exit(EXIT_FAILURE);
935 }
936 }
937 tarch::la::Vector<3, unsigned int> cells_per_process{
939 coupling::solvers::NumericalSolver::getAvgDomainSize(_cfg.channelheight, dx, _cfg.lbNumberProcesses, 1),
940 coupling::solvers::NumericalSolver::getAvgDomainSize(_cfg.channelheight, dx, _cfg.lbNumberProcesses, 2)}};
941 interface =
942 new coupling::solvers::LBCouetteSolverInterface(cells_per_process, _cfg.lbNumberProcesses, offsetMDDomain, globalNumberCouplingCells, outerRegion);
943 }
944
945 if (interface == NULL) {
946 std::cout << "ERROR CouetteScenario::getCouetteSolverInterface(...), rank=" << _rank << ": interface==NULL!" << std::endl;
947 exit(EXIT_FAILURE);
948 }
949 return interface;
950 }
951
961
966 timeval start_total;
968 timeval start;
970 timeval end;
971 timeval output;
973 double micro;
975 double macro;
977 double filter;
978 };
979
981 int _rank;
985 int _tws;
987 simplemd::configurations::MolecularDynamicsConfiguration _simpleMDConfig;
993 unsigned int _mdStepCounter;
1003 std::vector<coupling::interface::MDSolverInterface<MY_LINKEDCELL, 3>*> _mdSolverInterface;
1006 std::default_random_engine _generator;
1014};
1015
1016#endif // _COUPLING_SCENARIO_COUETTESCENARIO_H_
coupling::solvers::AbstractCouetteSolver< 3 > * getCouetteSolver(const double dx, const double dt)
Definition CouetteScenario.h:835
CouetteScenario()
simple constructor
Definition CouetteScenario.h:72
void allocateMd2macroBuffer(coupling::interface::MacroscopicSolverInterface< 3 > &msi)
Definition CouetteScenario.h:759
void computeSNR(int cycle)
used to compute signal-to-noise ratio, stores values in _sum_noise and _sum_signal
Definition CouetteScenario.h:624
void parseConfigurations()
reads the configuration from the xml file and calls parseCouetteScenarioConfiguration()
Definition CouetteScenario.h:150
TimingValues _tv
a instance of the timingValues
Definition CouetteScenario.h:1012
coupling::configurations::MaMiCoConfiguration< 3 > _mamicoConfig
the config data and information for MaMiCo
Definition CouetteScenario.h:989
void fillSendBuffer(const double density, const coupling::solvers::AbstractCouetteSolver< 3 > &couetteSolver, coupling::datastructures::FlexibleCellContainer< 3 > &macro2MDBuffer) const
fills send buffer with data from macro/continuum solver
Definition CouetteScenario.h:812
void advanceMacro(int cycle)
advances the continuum solver and collects data to send to md (fillSendBuffer())
Definition CouetteScenario.h:478
void twsLoop()
Executes the entire test several times for a range of time-window-size parameters.
Definition CouetteScenario.h:139
void initSolvers()
initialises the macro and micro solver according to the setup from the xml file and pre-proccses them
Definition CouetteScenario.h:190
void allocateMacro2mdBuffer(coupling::interface::MacroscopicSolverInterface< 3 > &msi)
allocates the send buffer (with values for all coupling cells).
Definition CouetteScenario.h:744
CouplingBuffer _couplingBuffer
the current buffer for the coupling
Definition CouetteScenario.h:1001
int _tws
Definition CouetteScenario.h:985
void advanceMicro(int cycle)
advances the md solver for one coupling time step and collect the data for the coupling
Definition CouetteScenario.h:580
double _sum_signal
Definition CouetteScenario.h:1008
void init() override
initialises everthing necessary for the test
Definition CouetteScenario.h:90
unsigned int _mdStepCounter
the counter for the time steps, which are done within the md
Definition CouetteScenario.h:993
double _sum_noise
Definition CouetteScenario.h:1010
tarch::utils::MultiMDService< 3 > * _multiMDService
Definition CouetteScenario.h:997
void shutdown()
finalize the time measurement, and cleans up at the end of the simulation
Definition CouetteScenario.h:680
simplemd::configurations::MolecularDynamicsConfiguration _simpleMDConfig
the config data and information for SimpleMD
Definition CouetteScenario.h:987
coupling::interface::MacroscopicSolverInterface< 3 > * getCouetteSolverInterface(const double dx, tarch::la::Vector< 3, double > mdOffset, tarch::la::Vector< 3, double > mamicoMeshsize, tarch::la::Vector< 3, unsigned int > globalNumberCouplingCells, unsigned int outerRegion)
Definition CouetteScenario.h:889
bool _isRootRank
if this is the world global root process
Definition CouetteScenario.h:983
virtual ~CouetteScenario()
a dummy destructor
Definition CouetteScenario.h:74
void twoWayCoupling(int cycle)
sets up the boundaries in the macro solver for the coupling and applies the values from the md in the...
Definition CouetteScenario.h:652
void getRootRank()
initialises all MPI variables
Definition CouetteScenario.h:130
void run() override
runs the simulation
Definition CouetteScenario.h:78
void runOneCouplingCycle(int cycle) override
combines the functioniality necessary for a cycle of the coupled simulation
Definition CouetteScenario.h:107
int _rank
the rank of the current MPI process in the local time domain
Definition CouetteScenario.h:981
std::default_random_engine _generator
Definition CouetteScenario.h:1006
coupling::configurations::CouetteConfig _cfg
the CouetteConfig for the current setup
Definition CouetteScenario.h:991
tarch::la::Vector< 3, unsigned int > getGlobalNumberCouplingCells(const simplemd::configurations::MolecularDynamicsConfiguration &simpleMDConfig, const coupling::configurations::MaMiCoConfiguration< 3 > &mamicoConfig) const
Definition CouetteScenario.h:729
coupling::services::MultiMDCellService< MY_LINKEDCELL, 3 > * _multiMDCellService
Definition CouetteScenario.h:999
std::vector< coupling::interface::MDSolverInterface< MY_LINKEDCELL, 3 > * > _mdSolverInterface
the interface to the md solver
Definition CouetteScenario.h:1003
coupling::solvers::AbstractCouetteSolver< 3 > * _couetteSolver
the current macro/continuum solver
Definition CouetteScenario.h:995
void write2CSV(Container_T &md2macroBuffer, int couplingCycle) const
write coupling cells that have been received from MD to csv file
Definition CouetteScenario.h:774
Simulation slots are managed (i.e., added/removed) via this class. Works and interacts with the class...
Definition InstanceHandling.h:35
Class to handle interaction between MultiMDCellService and InstanceHandling This is currently mainly ...
Definition MultiMDMediator.h:25
parses all sub-tags for MaMiCo configuration.
Definition MaMiCoConfiguration.h:31
const coupling::configurations::CouplingCellConfiguration< dim > & getCouplingCellConfiguration() const
Definition MaMiCoConfiguration.h:68
defines the cell type with cell-averaged quantities only (no linked cells).
Definition CouplingCell.h:29
const tarch::la::Vector< dim, double > & getMacroscopicMomentum() const
Definition CouplingCell.h:64
void setMicroscopicMass(const double &mass)
Definition CouplingCell.h:42
const double & getMacroscopicMass() const
Definition CouplingCell.h:58
void setMicroscopicMomentum(const tarch::la::Vector< dim, double > &momentum)
Definition CouplingCell.h:48
provides access to coupling cells, which may belong to different indexing domains
Definition FlexibleCellContainer.h:30
@ Velocity
Definition ErrorEstimation.h:51
@ Absolute
Definition ErrorEstimation.h:61
Definition CellIndex.h:85
static bool contains(const coupling::indexing::BaseIndex< dim > &index)
Definition CellIndex.h:227
interface for the macroscopic, i.e. continuum solver
Definition MacroscopicSolverInterface.h:23
virtual std::vector< unsigned int > getSourceRanks(I01 idx)
Definition MacroscopicSolverInterface.h:67
virtual std::vector< unsigned int > getTargetRanks(I01 idx)
Definition MacroscopicSolverInterface.h:78
void setMDSolverInterface(coupling::interface::MDSolverInterface< LinkedCell, dim > *mdSolverInterface)
Definition MamicoInterfaceProvider.h:48
void setMacroscopicSolverInterface(coupling::interface::MacroscopicSolverInterface< dim > *macroscopicSolverInterface)
Definition MamicoInterfaceProvider.h:36
static MamicoInterfaceProvider & getInstance()
Definition MamicoInterfaceProvider.h:28
coupling::interface::MacroscopicSolverInterface< dim > * getMacroscopicSolverInterface()
Definition MamicoInterfaceProvider.h:43
void setCouplingCellService(coupling::services::CouplingCellService< dim > *couplingCellService)
Definition MamicoInterfaceProvider.h:58
Definition MultiMDCellService.h:29
interface for continuum/macro fluid solvers for the Couette scenario
Definition CouetteSolver.h:19
virtual tarch::la::Vector< dim, double > getVelocity(tarch::la::Vector< dim, double > pos) const =0
returns the current velocity at the given position
interface to couette solver
Definition CouetteSolverInterface.h:28
implements an analytic Couette flow solver.
Definition CouetteSolver.h:46
implements a simple one-dimensional finite-diffference solver for the Couette flow.
Definition FDCouetteSolver.h:20
Definition IcoFoamInterface.h:34
interface for the LBCouetteSolver
Definition LBCouetteSolverInterface.h:26
implements a three-dimensional Lattice-Boltzmann Couette flow solver.
Definition LBCouetteSolver.h:56
static int getAvgDomainSize(double channelheight, double dx, tarch::la::Vector< 3, unsigned int > processes, int d)
Definition NumericalSolver.h:225
static void parseConfiguration(const std::string filename, const std::string topleveltag, Configuration &config)
Definition ParseConfiguration.h:63
Definition Vector.h:24
Definition MultiMDService.h:30
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15
holds the buffers for the data transfer
Definition CouetteScenario.h:955
coupling::datastructures::FlexibleCellContainer< 3 > macro2MDBuffer
the buffer for data transfer from macro to md
Definition CouetteScenario.h:957
coupling::datastructures::FlexibleCellContainer< 3 > md2macroBuffer
the buffer for data transfer from md to macro
Definition CouetteScenario.h:959
holds all the variables for the time measurement of a simulation
Definition CouetteScenario.h:964
Configuration parameters for Couette flow scenario.
Definition CouetteConfiguration.h:25
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
@ 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