4#ifndef _COUPLING_SCENARIO_COUETTESCENARIO_H_
5#define _COUPLING_SCENARIO_COUETTESCENARIO_H_
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"
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"
31#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
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"
48#define SYNTHETICMD_SEQUENCE "SYNTHETIC-MD"
84 _timeIntegrationService->run(
_cfg.couplingCycles);
91#if defined(LS1_MARDYN)
92 Log::global_log = std::make_unique<Log::Logger>(Log::Error);
93#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
94 global_log->set_mpi_output_root(0);
113 if (
_cfg.totalNumberMDSimulations < 0)
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);
132#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
133 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
142 for (
int cycle = 0; cycle <
_cfg.couplingCycles; cycle++)
151 std::string filename(
"couette.xml");
156 std::cout <<
"ERROR CouetteScenario: Invalid SimpleMD config!" << std::endl;
161 std::cout <<
"ERROR CouetteScenario: Invalid MaMiCo config!" << std::endl;
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!"
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]);
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);
191 _timeIntegrationService = std::make_unique<coupling::services::ParallelTimeIntegrationService<3>>(
_mamicoConfig,
this);
192 _rank = _timeIntegrationService->getRank();
195 _mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize()[0],
_simpleMDConfig.getDomainConfiguration().getGlobalDomainOffset(),
197 _mamicoConfig.getMomentumInsertionConfiguration().getInnerOverlap());
201 simplemd::configurations::DomainDecompConfiguration::DecompositionType::STATIC_IRREG_RECT_GRID) {
202 coupling::indexing::IndexingService<3>::getInstance().initWithMDSize(
205 _mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize(),
_mamicoConfig.getParallelTopologyConfiguration().getParallelTopologyType(),
206 _mamicoConfig.getMomentumInsertionConfiguration().getInnerOverlap(), (
unsigned int)
_rank
207#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
209 _timeIntegrationService->getPintComm()
213 coupling::indexing::IndexingService<3>::getInstance().initWithMDSize(
216 _mamicoConfig.getParallelTopologyConfiguration().getParallelTopologyType(),
_mamicoConfig.getMomentumInsertionConfiguration().getInnerOverlap(),
218#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
220 _timeIntegrationService->getPintComm()
233 unsigned int totNumMD;
234 if (
_cfg.totalNumberMDSimulations > 0)
235 totNumMD =
_cfg.totalNumberMDSimulations;
237 totNumMD =
_cfg.lowerBoundNumberMDSimulations;
240#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
242 _timeIntegrationService->getPintComm()
247 if (_instanceHandling ==
nullptr) {
248 std::cout <<
"ERROR CouetteScenario::initSolvers() : _instanceHandling == NULL!" << std::endl;
249 std::exit(EXIT_FAILURE);
254 gettimeofday(&
_tv.start, NULL);
255 gettimeofday(&
_tv.output, NULL);
260 _instanceHandling->switchOffCoupling();
262 _instanceHandling->switchOnCoupling();
267 _instanceHandling->setMDSolverInterface();
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!");
344 ->getSequence(SYNTHETICMD_SEQUENCE)
346 new std::function<std::vector<double>(std::vector<double>, std::vector<std::array<unsigned int, 3>>)>{
348 [
this](std::vector<double> inputScalars,
352 std::vector<std::array<unsigned int, 3>> cellIndices
355 gettimeofday(&
_tv.start, NULL);
360 const unsigned int size = inputScalars.size();
361 auto dx = coupling::indexing::IndexingService<3>::getInstance().getCouplingCellSize();
363 const double mass = (
_cfg.density) * couplingCellSize[0] * couplingCellSize[1] * couplingCellSize[2];
365 std::vector<double> syntheticMasses;
366 for (
unsigned int i = 0; i < size; i++) {
367 syntheticMasses.push_back(mass);
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);
376 return syntheticMasses;
378 new std::function<std::vector<std::array<double, 3>>(std::vector<std::array<double, 3>>, std::vector<std::array<unsigned int, 3>>)>{
380 [
this](std::vector<std::array<double, 3>> inputVectors,
381 std::vector<std::array<unsigned int, 3>> cellIndices
384 gettimeofday(&
_tv.start, NULL);
389 const unsigned int size = inputVectors.size();
390 auto dx = coupling::indexing::IndexingService<3>::getInstance().getCouplingCellSize();
392 const double mass = (
_cfg.density) * couplingCellSize[0] * couplingCellSize[1] * couplingCellSize[2];
394 using coupling::indexing::IndexTrait;
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],
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++) {
407 CellIndex<3, IndexTrait::vector> globalIndex(
408 CellIndex<3, IndexTrait::local, IndexTrait::md2macro, IndexTrait::noGhost>{i});
411 for (
unsigned int d = 0; d < 3; d++) {
412 cellMidPoint[d] = cellMidPoint[d] + ((double)globalIndex.get()[d]) * couplingCellSize[d];
420 syntheticMomenta.push_back({momentum[0], momentum[1], momentum[2]});
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);
429 return syntheticMomenta;
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 "
438 << SYNTHETICMD_SEQUENCE <<
"' in config." << std::endl;
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;
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"
470 gettimeofday(&
_tv.start_total, NULL);
472 std::cout <<
"Finish CouetteScenario::initSolvers() " << std::endl;
481 gettimeofday(&
_tv.start, NULL);
485 if (
_cfg.wallInitCycles > 0 && cycle ==
_cfg.wallInitCycles) {
489 if (
_cfg.wallOscillations != 0) {
491 vel = vel * cos(2 * M_PI *
_cfg.wallOscillations * cycle /
_cfg.couplingCycles);
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);
506#ifdef USE_COLLECTIVE_MPI
516 void varyMD(
int cycle) {
525 int addMDInstances = 0;
533 std::tie(couplingCell, idx) = pair;
541 (1 / std::sqrt(3)) * (
_mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize()[0] /
543 double cellVolume =
_mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize()[0] *
544 _mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize()[1] *
545 _mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize()[2];
547 coupling::error::ErrorEstimation errorControl(vel[0],
_cfg.temp, mass,
_simpleMDConfig.getMoleculeConfiguration().getMass(), soundSpeed,
550 double simtime = (double)cycle /
_cfg.couplingCycles;
551 double targetError =
_cfg.absVelErrEnd * simtime +
_cfg.absVelErrStart * (1 - simtime);
552 errorControl.setAbsVelocityError(targetError);
555 addMDInstances = NoMD -
_multiMDService->getTotalNumberOfMDSimulations();
558#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
559 MPI_Bcast(&addMDInstances, 1, MPI_INT, 0, _timeIntegrationService->getPintComm());
561 if (addMDInstances < 0) {
562 if ((
int)_multiMDMediator->getNumberOfActiveMDSimulations() + addMDInstances <
_cfg.lowerBoundNumberMDSimulations) {
563 addMDInstances = (
_cfg.lowerBoundNumberMDSimulations - (int)_multiMDMediator->getNumberOfActiveMDSimulations());
566 if (addMDInstances < 0) {
568 std::cout <<
"Removing " << -addMDInstances <<
" of " <<
_multiMDService->getTotalNumberOfMDSimulations() <<
" MD simulations" << std::endl;
569 _multiMDMediator->rmNMDSimulations(-addMDInstances);
570 }
else if (addMDInstances > 0) {
572 std::cout <<
"Adding " << addMDInstances <<
" to " <<
_multiMDService->getTotalNumberOfMDSimulations() <<
" MD simulations" << std::endl;
573 _multiMDMediator->addNMDSimulations(addMDInstances);
582 gettimeofday(&
_tv.start, NULL);
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);
599#ifdef USE_COLLECTIVE_MPI
614#ifdef USE_COLLECTIVE_MPI
625 if (
_cfg.computeSNR && cycle >=
_cfg.filterInitCycles) {
626 std::cout << cycle -
_cfg.filterInitCycles <<
", ";
627 using namespace coupling::indexing;
629 const double mass =
_cfg.density * dx[0] * dx[1] * dx[2];
636 std::tie(couplingCell, idx) = pair;
637 auto midPoint = idx.getCellMidPoint();
640 _sum_noise += (vx_macro - vx_filter) * (vx_macro - vx_filter);
642 std::cout << vx_macro <<
", " << vx_filter << std::endl;
654 if (
_cfg.twoWayCoupling) {
655 if ((
_cfg.maSolverType == CouetteConfig::COUETTE_LB ||
_cfg.maSolverType == CouetteConfig::COUETTE_FD) && cycle ==
_cfg.filterInitCycles) {
658 _mamicoConfig.getMomentumInsertionConfiguration().getInnerOverlap());
660#if (BUILD_WITH_OPENFOAM)
661 else if ((
_cfg.maSolverType == CouetteConfig::COUETTE_FOAM) && cycle ==
_cfg.filterInitCycles &&
_couetteSolver != NULL) {
665 if ((
_cfg.maSolverType == CouetteConfig::COUETTE_LB ||
_cfg.maSolverType == CouetteConfig::COUETTE_FD) && cycle >=
_cfg.filterInitCycles) {
668#if (BUILD_WITH_OPENFOAM)
669 else if (
_cfg.maSolverType == CouetteConfig::COUETTE_FOAM && cycle >=
_cfg.filterInitCycles &&
_couetteSolver != NULL) {
681 if (
_cfg.computeSNR) {
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;
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;
697 if (_instanceHandling !=
nullptr) {
698 delete _instanceHandling;
708 if (couetteSolverInterface != NULL) {
709 delete couetteSolverInterface;
710 couetteSolverInterface = NULL;
720 if (_multiMDMediator !=
nullptr) {
721 delete _multiMDMediator;
722 _multiMDMediator =
nullptr;
725 std::cout <<
"Finish CouetteScenario::shutdown() " << std::endl;
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;
738 return globalNumberCouplingCells;
745 for (
auto idx : I08()) {
750 if (couplingCell ==
nullptr)
751 throw std::runtime_error(std::string(
"ERROR CouetteScenario::allocateMacro2mdBuffer: couplingCell==NULL!"));
760 for (
auto idx : I12()) {
764 if (couplingCell ==
nullptr)
765 throw std::runtime_error(std::string(
"ERROR CouetteScenario::allocateMacro2mdBuffer: couplingCell==NULL!"));
774 template <
class Container_T>
void write2CSV(Container_T& md2macroBuffer,
int couplingCycle)
const {
775 if (md2macroBuffer.size() == 0)
777 if (
_cfg.csvEveryTimestep < 1 || couplingCycle %
_cfg.csvEveryTimestep > 0)
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;
790 file <<
"I01_x,I01_y,I01_z,vel_x,vel_y,vel_z,mass" << std::endl;
791 for (
auto pair : md2macroBuffer) {
794 std::tie(couplingCell, idx) = pair;
799 file << idx <<
"," << vel[0] <<
"," << vel[1] <<
"," << vel[2] <<
"," << couplingCell->
getMacroscopicMass() << std::endl;
815 using namespace coupling::indexing;
817 double mass = density * dx[0] * dx[1] * dx[2];
818 for (
auto pair : macro2MDBuffer) {
821 std::tie(couplingCell, idx) = pair;
822 auto midPoint = idx.getCellMidPoint();
823 if (
_cfg.maSolverType == CouetteConfig::COUETTE_LB ||
_cfg.maSolverType == CouetteConfig::COUETTE_FD)
840 if (
_cfg.maSolverType == CouetteConfig::COUETTE_ANALYTICAL) {
841 if (
_rank == 0 ||
_cfg.miSolverType == CouetteConfig::SYNTHETIC) {
843 if (solver == NULL) {
844 std::cout <<
"ERROR CouetteScenario::getCouetteSolver(): Analytic solver==NULL!" << std::endl;
849#if (BUILD_WITH_OPENFOAM)
850 else if (
_cfg.maSolverType == CouetteConfig::COUETTE_FOAM) {
852 _cfg.foam.boundariesWithMD,
_cfg.wallVelocity);
853 if (solver == NULL) {
854 std::cout <<
"ERROR CouetteScenario::getCouetteSolver(): IcoFoamInterface solver==NULL!" << std::endl;
860 else if (
_cfg.maSolverType == CouetteConfig::COUETTE_LB) {
862 _cfg.lbNumberProcesses, 1,
this);
863 if (solver == NULL) {
864 std::cout <<
"ERROR CouetteScenario::getCouetteSolver(): LB solver==NULL!" << std::endl;
867 }
else if (
_cfg.maSolverType == CouetteConfig::COUETTE_FD) {
869 _cfg.lbNumberProcesses, 1);
870 if (solver == NULL) {
871 std::cout <<
"ERROR CouetteScenario::getCouetteSolver(): FD solver==NULL!" << std::endl;
875 std::cout <<
"ERROR CouetteScenario::getCouetteSolver(): Unknown solver type!" << std::endl;
892 unsigned int outerRegion) {
895 if (
_cfg.maSolverType == CouetteConfig::COUETTE_ANALYTICAL) {
897 } else if (_cfg.maSolverType == CouetteConfig::COUETTE_LB) {
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;
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;
918#if (BUILD_WITH_OPENFOAM)
919 else if (_cfg.maSolverType == CouetteConfig::COUETTE_FOAM) {
923 else if (_cfg.maSolverType == CouetteConfig::COUETTE_FD) {
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;
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;
945 if (interface == NULL) {
946 std::cout <<
"ERROR CouetteScenario::getCouetteSolverInterface(...), rank=" <<
_rank <<
": interface==NULL!" << std::endl;
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 > ¯o2MDBuffer) 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
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 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