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);
137 const int EQUI_CYCLES = 3;
138 for(
int i = 0; i < EQUI_CYCLES; i++){
140 _instanceHandling->simulateTimesteps(
_simpleMDConfig.getSimulationConfiguration().getNumberOfTimesteps(),
154#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
155 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
164 for (
int cycle = 0; cycle <
_cfg.couplingCycles; cycle++)
173 std::string filename(
"couette.xml");
178 std::cout <<
"ERROR CouetteScenario: Invalid SimpleMD config!" << std::endl;
183 std::cout <<
"ERROR CouetteScenario: Invalid MaMiCo config!" << std::endl;
191 simplemd::configurations::DomainDecompConfiguration::DecompositionType::STATIC_IRREG_RECT_GRID) {
192 std::cout <<
"ERROR Currently, only LS1 supports irregular rectilinear domain decomposition! Please change md type to ls1, or decomposition to default!"
197#if defined(LS1_MARDYN)
198 auto offset =
_simpleMDConfig.getDomainConfiguration().getGlobalDomainOffset();
199 coupling::interface::LS1StaticCommData::getInstance().setConfigFilename(
"ls1config.xml");
200 coupling::interface::LS1StaticCommData::getInstance().setBoxOffsetAtDim(0, offset[0]);
201 coupling::interface::LS1StaticCommData::getInstance().setBoxOffsetAtDim(1, offset[1]);
202 coupling::interface::LS1StaticCommData::getInstance().setBoxOffsetAtDim(2, offset[2]);
203#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
204 auto subdomainWeights =
_simpleMDConfig.getDomainDecompConfiguration().getSubdomainWeights();
205 coupling::interface::LS1StaticCommData::getInstance().setSubdomainWeights(subdomainWeights);
213 _timeIntegrationService = std::make_unique<coupling::services::ParallelTimeIntegrationService<3>>(
_mamicoConfig,
this);
214 _rank = _timeIntegrationService->getRank();
217 _mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize()[0],
_simpleMDConfig.getDomainConfiguration().getGlobalDomainOffset(),
219 _mamicoConfig.getMomentumInsertionConfiguration().getInnerOverlap());
223 simplemd::configurations::DomainDecompConfiguration::DecompositionType::STATIC_IRREG_RECT_GRID) {
224 coupling::indexing::IndexingService<3>::getInstance().initWithMDSize(
227 _mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize(),
_mamicoConfig.getParallelTopologyConfiguration().getParallelTopologyType(),
228 _mamicoConfig.getMomentumInsertionConfiguration().getInnerOverlap(), (
unsigned int)
_rank
229#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
231 _timeIntegrationService->getPintComm()
235 coupling::indexing::IndexingService<3>::getInstance().initWithMDSize(
238 _mamicoConfig.getParallelTopologyConfiguration().getParallelTopologyType(),
_mamicoConfig.getMomentumInsertionConfiguration().getInnerOverlap(),
240#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
242 _timeIntegrationService->getPintComm()
255 unsigned int totNumMD;
256 if (
_cfg.totalNumberMDSimulations > 0)
257 totNumMD =
_cfg.totalNumberMDSimulations;
259 totNumMD =
_cfg.lowerBoundNumberMDSimulations;
262#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
264 _timeIntegrationService->getPintComm()
269 if (_instanceHandling ==
nullptr) {
270 std::cout <<
"ERROR CouetteScenario::initSolvers() : _instanceHandling == NULL!" << std::endl;
271 std::exit(EXIT_FAILURE);
276 gettimeofday(&
_tv.start, NULL);
277 gettimeofday(&
_tv.output, NULL);
282 _instanceHandling->switchOffCoupling();
284 _instanceHandling->switchOnCoupling();
289 _instanceHandling->setMDSolverInterface();
314 _MDBoundarySetupDone =
false;
351 if (
_cfg.macro2Md ||
_cfg.totalNumberMDSimulations != 1 ||
_cfg.lbNumberProcesses[0] != 1 ||
_cfg.lbNumberProcesses[1] != 1 ||
352 _cfg.lbNumberProcesses[2] != 1) {
353 throw std::runtime_error(
"ERROR: Syntethic MD is only available in sequential mode!");
367 ->getSequence(SYNTHETICMD_SEQUENCE)
369 new std::function<std::vector<double>(std::vector<double>, std::vector<std::array<unsigned int, 3>>)>{
371 [
this](std::vector<double> inputScalars,
375 std::vector<std::array<unsigned int, 3>> cellIndices
378 gettimeofday(&
_tv.start, NULL);
383 const unsigned int size = inputScalars.size();
384 auto dx = coupling::indexing::IndexingService<3>::getInstance().getCouplingCellSize();
386 const double mass = (
_cfg.density) * couplingCellSize[0] * couplingCellSize[1] * couplingCellSize[2];
388 std::vector<double> syntheticMasses;
389 for (
unsigned int i = 0; i < size; i++) {
390 syntheticMasses.push_back(mass);
395 gettimeofday(&
_tv.end, NULL);
396 _tv.micro += (
_tv.end.tv_sec -
_tv.start.tv_sec) * 1000000 + (
_tv.end.tv_usec -
_tv.start.tv_usec);
399 return syntheticMasses;
401 new std::function<std::vector<std::array<double, 3>>(std::vector<std::array<double, 3>>, std::vector<std::array<unsigned int, 3>>)>{
403 [
this](std::vector<std::array<double, 3>> inputVectors,
404 std::vector<std::array<unsigned int, 3>> cellIndices
407 gettimeofday(&
_tv.start, NULL);
412 const unsigned int size = inputVectors.size();
413 auto dx = coupling::indexing::IndexingService<3>::getInstance().getCouplingCellSize();
415 const double mass = (
_cfg.density) * couplingCellSize[0] * couplingCellSize[1] * couplingCellSize[2];
417 using coupling::indexing::IndexTrait;
421 CellIndex<3, IndexTrait::local, IndexTrait::md2macro, IndexTrait::noGhost>::lowerBoundary.get()[0] * couplingCellSize[0],
422 CellIndex<3, IndexTrait::local, IndexTrait::md2macro, IndexTrait::noGhost>::lowerBoundary.get()[1] * couplingCellSize[1],
423 CellIndex<3, IndexTrait::local, IndexTrait::md2macro, IndexTrait::noGhost>::lowerBoundary.get()[2] * couplingCellSize[2],
426 std::normal_distribution<double> distribution(0.0,
_cfg.noiseSigma);
427 std::vector<std::array<double, 3>> syntheticMomenta;
428 for (
unsigned int i = 0; i < size; i++) {
430 CellIndex<3, IndexTrait::vector> globalIndex(
431 CellIndex<3, IndexTrait::local, IndexTrait::md2macro, IndexTrait::noGhost>{i});
434 for (
unsigned int d = 0; d < 3; d++) {
435 cellMidPoint[d] = cellMidPoint[d] + ((double)globalIndex.get()[d]) * couplingCellSize[d];
443 syntheticMomenta.push_back({momentum[0], momentum[1], momentum[2]});
448 gettimeofday(&
_tv.end, NULL);
449 _tv.micro += (
_tv.end.tv_sec -
_tv.start.tv_sec) * 1000000 + (
_tv.end.tv_usec -
_tv.start.tv_usec);
452 return syntheticMomenta;
456 }
catch (std::runtime_error& e) {
457 auto expectedError = std::string(
"ERROR: Could not find Filter Sequence named ").append(SYNTHETICMD_SEQUENCE);
458 if (expectedError.compare(e.what()) == 0) {
459 std::cout <<
"ERROR: Synthetic MD solver selected without providing "
461 << SYNTHETICMD_SEQUENCE <<
"' in config." << std::endl;
478 gettimeofday(&
_tv.end, NULL);
479 double runtime = (
_tv.end.tv_sec -
_tv.start.tv_sec) * 1000000 + (
_tv.end.tv_usec -
_tv.start.tv_usec);
480 std::cout <<
"Initialization: " << (int)(runtime / 1000) <<
"ms" << std::endl;
483 if (
_cfg.computeSNR) {
484 std::cout <<
"Output for every coupling cycle, for the cell 87 in recvBuffer:" << std::endl;
485 std::cout <<
"cycle number (after filter-init-cycles), vel_x macroscopic "
486 "solver, vel_x filter output"
493 gettimeofday(&
_tv.start_total, NULL);
495 std::cout <<
"Finish CouetteScenario::initSolvers() " << std::endl;
504 gettimeofday(&
_tv.start, NULL);
508 if (
_cfg.wallInitCycles > 0 && cycle ==
_cfg.wallInitCycles) {
512 if (
_cfg.wallOscillations != 0) {
514 vel = vel * cos(2 * M_PI *
_cfg.wallOscillations * cycle /
_cfg.couplingCycles);
519 gettimeofday(&
_tv.end, NULL);
520 _tv.macro += (
_tv.end.tv_sec -
_tv.start.tv_sec) * 1000000 + (
_tv.end.tv_usec -
_tv.start.tv_usec);
529#ifdef USE_COLLECTIVE_MPI
539 void varyMD(
int cycle) {
548 int addMDInstances = 0;
556 std::tie(couplingCell, idx) = pair;
564 (1 / std::sqrt(3)) * (
_mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize()[0] /
566 double cellVolume =
_mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize()[0] *
567 _mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize()[1] *
568 _mamicoConfig.getCouplingCellConfiguration().getCouplingCellSize()[2];
570 coupling::error::ErrorEstimation errorControl(vel[0],
_cfg.temp, mass,
_simpleMDConfig.getMoleculeConfiguration().getMass(), soundSpeed,
573 double simtime = (double)cycle /
_cfg.couplingCycles;
574 double targetError =
_cfg.absVelErrEnd * simtime +
_cfg.absVelErrStart * (1 - simtime);
575 errorControl.setAbsVelocityError(targetError);
578 addMDInstances = NoMD -
_multiMDService->getTotalNumberOfMDSimulations();
581#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
582 MPI_Bcast(&addMDInstances, 1, MPI_INT, 0, _timeIntegrationService->getPintComm());
584 if (addMDInstances < 0) {
585 if ((
int)_multiMDMediator->getNumberOfActiveMDSimulations() + addMDInstances <
_cfg.lowerBoundNumberMDSimulations) {
586 addMDInstances = (
_cfg.lowerBoundNumberMDSimulations - (int)_multiMDMediator->getNumberOfActiveMDSimulations());
589 if (addMDInstances < 0) {
591 std::cout <<
"Removing " << -addMDInstances <<
" of " <<
_multiMDService->getTotalNumberOfMDSimulations() <<
" MD simulations" << std::endl;
592 _multiMDMediator->rmNMDSimulations(-addMDInstances);
593 }
else if (addMDInstances > 0) {
595 std::cout <<
"Adding " << addMDInstances <<
" to " <<
_multiMDService->getTotalNumberOfMDSimulations() <<
" MD simulations" << std::endl;
596 _multiMDMediator->addNMDSimulations(addMDInstances);
605 gettimeofday(&
_tv.start, NULL);
616 gettimeofday(&
_tv.end, NULL);
617 _tv.micro += (
_tv.end.tv_sec -
_tv.start.tv_sec) * 1000000 + (
_tv.end.tv_usec -
_tv.start.tv_usec);
622#ifdef USE_COLLECTIVE_MPI
637#ifdef USE_COLLECTIVE_MPI
648 if (
_cfg.computeSNR && cycle >=
_cfg.filterInitCycles) {
649 std::cout << cycle -
_cfg.filterInitCycles <<
", ";
650 using namespace coupling::indexing;
652 const double mass =
_cfg.density * dx[0] * dx[1] * dx[2];
659 std::tie(couplingCell, idx) = pair;
660 auto midPoint = idx.getCellMidPoint();
663 _sum_noise += (vx_macro - vx_filter) * (vx_macro - vx_filter);
665 std::cout << vx_macro <<
", " << vx_filter << std::endl;
677 if (
_cfg.twoWayCoupling) {
678#if (BUILD_WITH_OPENFOAM)
679 if ((
_cfg.maSolverType == CouetteConfig::COUETTE_FOAM) && cycle ==
_cfg.filterInitCycles &&
_couetteSolver != NULL) {
683 if ((
_cfg.maSolverType == CouetteConfig::COUETTE_LB ||
_cfg.maSolverType == CouetteConfig::COUETTE_FD) && cycle >=
_cfg.filterInitCycles) {
684 if (!_MDBoundarySetupDone){
686 ->setMDBoundary(
_simpleMDConfig.getDomainConfiguration().getGlobalDomainOffset(),
_simpleMDConfig.getDomainConfiguration().getGlobalDomainSize(),
_mamicoConfig.getMomentumInsertionConfiguration().getInnerOverlap());
687 _MDBoundarySetupDone =
true;
691#if (BUILD_WITH_OPENFOAM)
692 else if (
_cfg.maSolverType == CouetteConfig::COUETTE_FOAM && cycle >=
_cfg.filterInitCycles &&
_couetteSolver != NULL) {
704 if (
_cfg.computeSNR) {
710 gettimeofday(&
_tv.end, NULL);
711 double time_total = (
_tv.end.tv_sec -
_tv.start_total.tv_sec) * 1000000 + (
_tv.end.tv_usec -
_tv.start_total.tv_usec);
712 std::cout <<
"Finished all coupling cycles after " << time_total / 1000000 <<
" s" << std::endl;
714 std::cout <<
"TWS = " <<
_tws << std::endl;
715 std::cout <<
"Time percentages Micro, Macro, Filter, Other: " << std::endl;
716 std::cout <<
_tv.micro / time_total * 100 <<
", " <<
_tv.macro / time_total * 100 <<
", " <<
_tv.filter / time_total * 100 <<
", "
717 << (1 - (
_tv.micro +
_tv.macro +
_tv.filter) / time_total) * 100 << std::endl;
720 if (_instanceHandling !=
nullptr) {
721 delete _instanceHandling;
731 if (couetteSolverInterface != NULL) {
732 delete couetteSolverInterface;
733 couetteSolverInterface = NULL;
743 if (_multiMDMediator !=
nullptr) {
744 delete _multiMDMediator;
745 _multiMDMediator =
nullptr;
748 std::cout <<
"Finish CouetteScenario::shutdown() " << std::endl;
757 for (
unsigned int d = 0; d < 3; d++) {
758 int buf = floor(domainSize[d] / dx[d] + 0.5);
759 globalNumberCouplingCells[d] = (
unsigned int)buf;
761 return globalNumberCouplingCells;
768 for (
auto idx : I08()) {
773 if (couplingCell ==
nullptr)
774 throw std::runtime_error(std::string(
"ERROR CouetteScenario::allocateMacro2mdBuffer: couplingCell==NULL!"));
783 for (
auto idx : I12()) {
787 if (couplingCell ==
nullptr)
788 throw std::runtime_error(std::string(
"ERROR CouetteScenario::allocateMacro2mdBuffer: couplingCell==NULL!"));
797 template <
class Container_T>
void write2CSV(Container_T& md2macroBuffer,
int couplingCycle)
const {
798 if (md2macroBuffer.size() == 0)
800 if (
_cfg.csvEveryTimestep < 1 || couplingCycle %
_cfg.csvEveryTimestep > 0)
803 std::stringstream ss;
804 ss <<
"CouetteAvgMultiMDCells_" << _timeIntegrationService->getPintDomain() <<
"_" <<
_rank <<
"_" << couplingCycle <<
".csv";
805 std::ofstream file(ss.str().c_str());
806 if (!file.is_open()) {
807 std::cout <<
"ERROR CouetteScenario::write2CSV(): Could not open file " << ss.str() <<
"!" << std::endl;
813 file <<
"I01_x,I01_y,I01_z,vel_x,vel_y,vel_z,mass" << std::endl;
814 for (
auto pair : md2macroBuffer) {
817 std::tie(couplingCell, idx) = pair;
822 file << idx <<
"," << vel[0] <<
"," << vel[1] <<
"," << vel[2] <<
"," << couplingCell->
getMacroscopicMass() << std::endl;
838 using namespace coupling::indexing;
840 double mass = density * dx[0] * dx[1] * dx[2];
841 for (
auto pair : macro2MDBuffer) {
844 std::tie(couplingCell, idx) = pair;
845 auto midPoint = idx.getCellMidPoint();
846 if (
_cfg.maSolverType == CouetteConfig::COUETTE_LB ||
_cfg.maSolverType == CouetteConfig::COUETTE_FD)
863 if (
_cfg.maSolverType == CouetteConfig::COUETTE_ANALYTICAL) {
864 if (
_rank == 0 ||
_cfg.miSolverType == CouetteConfig::SYNTHETIC) {
866 if (solver == NULL) {
867 std::cout <<
"ERROR CouetteScenario::getCouetteSolver(): Analytic solver==NULL!" << std::endl;
872#if (BUILD_WITH_OPENFOAM)
873 else if (
_cfg.maSolverType == CouetteConfig::COUETTE_FOAM) {
875 _cfg.foam.boundariesWithMD,
_cfg.wallVelocity);
876 if (solver == NULL) {
877 std::cout <<
"ERROR CouetteScenario::getCouetteSolver(): IcoFoamInterface solver==NULL!" << std::endl;
883 else if (
_cfg.maSolverType == CouetteConfig::COUETTE_LB) {
885 _cfg.lbNumberProcesses, 1,
this);
886 if (solver == NULL) {
887 std::cout <<
"ERROR CouetteScenario::getCouetteSolver(): LB solver==NULL!" << std::endl;
890 }
else if (
_cfg.maSolverType == CouetteConfig::COUETTE_FD) {
892 _cfg.lbNumberProcesses, 1);
893 if (solver == NULL) {
894 std::cout <<
"ERROR CouetteScenario::getCouetteSolver(): FD solver==NULL!" << std::endl;
898 std::cout <<
"ERROR CouetteScenario::getCouetteSolver(): Unknown solver type!" << std::endl;
915 unsigned int outerRegion) {
918 if (
_cfg.maSolverType == CouetteConfig::COUETTE_ANALYTICAL) {
920 } else if (_cfg.maSolverType == CouetteConfig::COUETTE_LB) {
923 for (
unsigned int d = 0; d < 3; d++) {
924 if (mdOffset[d] < 0.0) {
925 std::cout <<
"ERROR CouetteScenario::getCouetteSolverInterface(...): mdOffset[" << d <<
"]<0.0!" << std::endl;
928 offsetMDDomain[d] = floor(mdOffset[d] / mamicoMeshsize[d] + 0.5);
929 if (fabs((offsetMDDomain[d] * mamicoMeshsize[d] - mdOffset[d]) / mamicoMeshsize[d]) > 1.0e-8) {
930 std::cout <<
"ERROR CouetteScenario::getCouetteSolverInterface: MD offset and mesh size mismatch!" << std::endl;
941#if (BUILD_WITH_OPENFOAM)
942 else if (_cfg.maSolverType == CouetteConfig::COUETTE_FOAM) {
946 else if (_cfg.maSolverType == CouetteConfig::COUETTE_FD) {
949 for (
unsigned int d = 0; d < 3; d++) {
950 if (mdOffset[d] < 0.0) {
951 std::cout <<
"ERROR CouetteScenario::getCouetteSolverInterface(...): mdOffset[" << d <<
"]<0.0!" << std::endl;
954 offsetMDDomain[d] = floor(mdOffset[d] / mamicoMeshsize[d] + 0.5);
955 if (fabs((offsetMDDomain[d] * mamicoMeshsize[d] - mdOffset[d]) / mamicoMeshsize[d]) > 1.0e-8) {
956 std::cout <<
"ERROR CouetteScenario::getCouetteSolverInterface: MD offset and mesh size mismatch!" << std::endl;
968 if (interface == NULL) {
969 std::cout <<
"ERROR CouetteScenario::getCouetteSolverInterface(...), rank=" <<
_rank <<
": interface==NULL!" << std::endl;
1037 bool _MDBoundarySetupDone;
coupling::solvers::AbstractCouetteSolver< 3 > * getCouetteSolver(const double dx, const double dt)
Definition CouetteScenario.h:858
CouetteScenario()
simple constructor
Definition CouetteScenario.h:72
void allocateMd2macroBuffer(coupling::interface::MacroscopicSolverInterface< 3 > &msi)
Definition CouetteScenario.h:782
void computeSNR(int cycle)
used to compute signal-to-noise ratio, stores values in _sum_noise and _sum_signal
Definition CouetteScenario.h:647
void parseConfigurations()
reads the configuration from the xml file and calls parseCouetteScenarioConfiguration()
Definition CouetteScenario.h:172
TimingValues _tv
a instance of the timingValues
Definition CouetteScenario.h:1035
coupling::configurations::MaMiCoConfiguration< 3 > _mamicoConfig
the config data and information for MaMiCo
Definition CouetteScenario.h:1012
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:835
void advanceMacro(int cycle)
advances the continuum solver and collects data to send to md (fillSendBuffer())
Definition CouetteScenario.h:501
void twsLoop()
Executes the entire test several times for a range of time-window-size parameters.
Definition CouetteScenario.h:161
void initSolvers()
initialises the macro and micro solver according to the setup from the xml file and pre-proccses them
Definition CouetteScenario.h:212
void allocateMacro2mdBuffer(coupling::interface::MacroscopicSolverInterface< 3 > &msi)
allocates the send buffer (with values for all coupling cells).
Definition CouetteScenario.h:767
CouplingBuffer _couplingBuffer
the current buffer for the coupling
Definition CouetteScenario.h:1024
int _tws
Definition CouetteScenario.h:1008
void equilibrateMicro() override
Definition CouetteScenario.h:128
void advanceMicro(int cycle)
advances the md solver for one coupling time step and collect the data for the coupling
Definition CouetteScenario.h:603
double _sum_signal
Definition CouetteScenario.h:1031
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:1016
double _sum_noise
Definition CouetteScenario.h:1033
tarch::utils::MultiMDService< 3 > * _multiMDService
Definition CouetteScenario.h:1020
void shutdown()
finalize the time measurement, and cleans up at the end of the simulation
Definition CouetteScenario.h:703
simplemd::configurations::MolecularDynamicsConfiguration _simpleMDConfig
the config data and information for SimpleMD
Definition CouetteScenario.h:1010
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:912
bool _isRootRank
if this is the world global root process
Definition CouetteScenario.h:1006
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:675
void getRootRank()
initialises all MPI variables
Definition CouetteScenario.h:152
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:1004
std::default_random_engine _generator
Definition CouetteScenario.h:1029
coupling::configurations::CouetteConfig _cfg
the CouetteConfig for the current setup
Definition CouetteScenario.h:1014
tarch::la::Vector< 3, unsigned int > getGlobalNumberCouplingCells(const simplemd::configurations::MolecularDynamicsConfiguration &simpleMDConfig, const coupling::configurations::MaMiCoConfiguration< 3 > &mamicoConfig) const
Definition CouetteScenario.h:752
coupling::services::MultiMDCellService< MY_LINKEDCELL, 3 > * _multiMDCellService
Definition CouetteScenario.h:1022
std::vector< coupling::interface::MDSolverInterface< MY_LINKEDCELL, 3 > * > _mdSolverInterface
the interface to the md solver
Definition CouetteScenario.h:1026
coupling::solvers::AbstractCouetteSolver< 3 > * _couetteSolver
the current macro/continuum solver
Definition CouetteScenario.h:1018
void write2CSV(Container_T &md2macroBuffer, int couplingCycle) const
write coupling cells that have been received from MD to csv file
Definition CouetteScenario.h:797
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:978
coupling::datastructures::FlexibleCellContainer< 3 > macro2MDBuffer
the buffer for data transfer from macro to md
Definition CouetteScenario.h:980
coupling::datastructures::FlexibleCellContainer< 3 > md2macroBuffer
the buffer for data transfer from md to macro
Definition CouetteScenario.h:982
holds all the variables for the time measurement of a simulation
Definition CouetteScenario.h:987
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