5#ifndef _MOLECULARDYNAMICS_COUPLING_SERVICES_COUPLINGCELLSERVICE_H_
6#define _MOLECULARDYNAMICS_COUPLING_SERVICES_COUPLINGCELLSERVICE_H_
10#include "coupling/CouplingCellPlotter.h"
11#include "coupling/KineticEnergyController.h"
12#include "coupling/MomentumController.h"
13#include "coupling/cell-mappings/ComputeMeanPotentialEnergyMapping.h"
14#include "coupling/cell-mappings/ComputeMomentumMapping.h"
15#include "coupling/cell-mappings/PerturbateVelocityMapping.h"
16#include "coupling/configurations/BoundaryForceConfiguration.h"
17#include "coupling/configurations/CouplingCellConfiguration.h"
18#include "coupling/configurations/MaMiCoConfiguration.h"
19#include "coupling/configurations/MomentumInsertionConfiguration.h"
20#include "coupling/configurations/ParallelTopologyConfiguration.h"
21#include "coupling/configurations/ParticleInsertionConfiguration.h"
22#include "coupling/configurations/ThermostatConfiguration.h"
23#include "coupling/configurations/TransferStrategyConfiguration.h"
24#include "coupling/datastructures/CellContainer.h"
25#include "coupling/indexing/IndexingService.h"
26#include "coupling/interface/MDSolverInterface.h"
27#include "coupling/interface/MacroscopicSolverInterface.h"
28#include "coupling/sendrecv/DataExchangeFromMD2Macro.h"
29#include "coupling/sendrecv/DataExchangeFromMacro2MD.h"
30#include "coupling/sendrecv/FromMD2Macro.h"
31#include "coupling/sendrecv/FromMacro2MD.h"
32#include "tarch/utils/MultiMDService.h"
34#include "coupling/filtering/FilterPipeline.h"
39template <
unsigned int dim>
class CouplingCellService;
51 CouplingCellService(
unsigned int ID,
unsigned int topologyOffset) : _id(ID),
_topologyOffset(topologyOffset) {
52#if (COUPLING_MD_DEBUG == COUPLING_MD_YES)
53 std::cout <<
"CouplingCellService::CouplingCellService(): Set ID=" << _id << std::endl;
56 virtual ~CouplingCellService() {}
58 virtual double applyFilterPipeline() = 0;
59 virtual void sendFromMacro2MDPreProcess() = 0;
60 virtual void sendFromMacro2MDPostProcess() = 0;
62 virtual void sendFromMD2MacroPreProcess() = 0;
63 virtual void sendFromMD2MacroPostProcess() = 0;
65 virtual void processInnerCouplingCellAfterMDTimestep() = 0;
66 virtual void computeAndStoreTemperature(
double temperature) = 0;
67 virtual void applyTemperatureToMolecules(
unsigned int t) = 0;
73 virtual void plotEveryMacroscopicTimestep(
unsigned int t) = 0;
76 throw std::runtime_error(
"CouplingCellService: Error: Called "
77 "initFiltering for non-Impl object.");
81 throw std::runtime_error(
"CouplingCellService: Error: Called getFilterPipeline() in instance "
82 "without FilterPipeline.");
86 unsigned int getID()
const {
return _id; }
89 const unsigned int _id;
135 unsigned int numberMDTimestepsPerCouplingCycle,
155 unsigned int numberMDTimestepsPerCouplingCycle,
161 :
CouplingCellServiceImpl<LinkedCell, dim>(ID, mdSolverInterface, macroscopicSolverInterface, numberProcesses, rank, particleInsertionConfiguration,
162 momentumInsertionConfiguration, boundaryForceConfiguration, transferStrategyConfiguration,
163 parallelTopologyConfiguration, thermostatConfiguration, numberMDTimestepsPerCouplingCycle,
164 couplingCellConfiguration, filterPipelineConfiguration, multiMDService, 0) {}
193 void sendFromMacro2MDPreProcess()
override;
195 void sendFromMacro2MDPostProcess()
override;
197 void sendFromMD2MacroPreProcess()
override;
199 void sendFromMD2MacroPostProcess()
override {}
239 void plotEveryMacroscopicTimestep(
unsigned int t)
override;
280#include "CouplingCellTraversalWrappers.cpph"
288 if (thermostatConfiguration.getThermostatRegionType() == coupling::configurations::ThermostatConfiguration::ThermostatRegion::all)
289 return [
this](
Wrapper& wrapper) {
_couplingCells.applyToLocalNonGhostCouplingCellsWithLinkedCells(wrapper); };
290 else if (thermostatConfiguration.getThermostatRegionType() == coupling::configurations::ThermostatConfiguration::ThermostatRegion::outerLayers)
291 return [
this, &thermostatConfiguration](Wrapper& wrapper) {
292 _couplingCells.applyXLayersOfGlobalNonGhostCellsWithLinkedCells(wrapper, thermostatConfiguration.getCells2Use());
294 else if (thermostatConfiguration.getThermostatRegionType() == coupling::configurations::ThermostatConfiguration::ThermostatRegion::onlyOutestLayer)
295 return [
this](Wrapper& wrapper) {
_couplingCells.applyToFirstLayerOfGlobalNonGhostCellsWithLinkedCells(wrapper); };
297 return [](Wrapper& wrapper) {};
344 std::function<void(
Wrapper&)> _applyAccordingToConfiguration;
348 const unsigned int _writeEveryMicroscopicTimestep;
349 const std::string _macroscopicFilename;
350 const unsigned int _writeEveryMacroscopicTimestep;
363#include "CouplingCellService.cpph"
controller for forces acting at open MD boundaries
Definition BoundaryForceController.h:25
controles and regulates the kinetic energy of the MD system.
Definition KineticEnergyController.h:27
controls the momentum in a coupling cell.
Definition MomentumController.h:26
used to manipulate the momentum/ velocity of the molecules contained in a coupling cell.
Definition MomentumInsertion.h:23
interface for particle insertion/removal on coupling cell basis.
Definition ParticleInsertion.h:23
reads boundary force tag
Definition BoundaryForceConfiguration.h:27
configuration for output of coupling cell data to vtk files.
Definition CouplingCellConfiguration.h:24
momentum insertion configuration. friend class: NieTest
Definition MomentumInsertionConfiguration.h:31
MomentumInsertionType
Definition MomentumInsertionConfiguration.h:39
reads parallel topology configuration. XYZ and ZYX are supported.
Definition ParallelTopologyConfiguration.h:25
configuration for particle insertion algorithm (e.g.: USHER).
Definition ParticleInsertionConfiguration.h:28
ParticleInsertionType
Definition ParticleInsertionConfiguration.h:82
Definition ThermostatConfiguration.h:23
transfer strategy configuration, i.e. algorithm/combin. of quantity transfer steps and quantity inter...
Definition TransferStrategyConfiguration.h:34
provides access to coupling cells, which may belong to different indexing domains
Definition FlexibleCellContainer.h:30
provides access to the coupling cells with linked cells.
Definition LinkedCellContainer.h:21
Definition FilterPipeline.h:44
interface to the MD simulation
Definition MDSolverInterface.h:25
interface for the macroscopic, i.e. continuum solver
Definition MacroscopicSolverInterface.h:23
data exchange from the MD solver to the macroscopic solver. Derived from the class coupling::sendrecv...
Definition DataExchangeFromMD2Macro.h:36
data exchange from the macroscopic solver to the MD solver. Derived from the class coupling::sendrecv...
Definition DataExchangeFromMacro2MD.h:36
sends coupling cell information from MaMiCo to the macroscopic solver. Derived from the class couplin...
Definition FromMD2Macro.h:29
SendReceiveBuffer for transfer of quantities from a macroscopic solver to the coupling cells....
Definition FromMacro2MD.h:28
Definition CouplingCellService.h:22
Definition CouplingCellService.h:98
coupling::sendrecv::FromMacro2MD< coupling::datastructures::CouplingCell< dim >, dim > _fromMacro2MD
Definition CouplingCellService.h:310
void processInnerCouplingCellAfterMDTimestep() override
coupling::interface::MDSolverInterface< LinkedCell, dim > * _mdSolverInterface
Definition CouplingCellService.h:304
void plotEveryMicroscopicTimestep(unsigned int t) override
void initFiltering() override
Definition CouplingCellService.h:246
void applyTemperatureToMolecules(unsigned int t) override
CouplingCellServiceImpl(unsigned int ID, coupling::interface::MDSolverInterface< LinkedCell, dim > *mdSolverInterface, coupling::interface::MacroscopicSolverInterface< dim > *macroscopicSolverInterface, tarch::la::Vector< dim, unsigned int > numberProcesses, unsigned int rank, const coupling::configurations::ParticleInsertionConfiguration &particleInsertionConfiguration, const coupling::configurations::MomentumInsertionConfiguration &momentumInsertionConfiguration, const coupling::configurations::BoundaryForceConfiguration< dim > &boundaryForceConfiguration, const coupling::configurations::TransferStrategyConfiguration< dim > &transferStrategyConfiguration, const coupling::configurations::ParallelTopologyConfiguration ¶llelTopologyConfiguration, const coupling::configurations::ThermostatConfiguration &thermostatConfiguration, unsigned int numberMDTimestepsPerCouplingCycle, const coupling::configurations::CouplingCellConfiguration< dim > &couplingCellConfiguration, const char *filterPipelineConfiguration, const tarch::utils::MultiMDService< dim > &multiMDService, unsigned int topologyOffset, int tws=0)
void initIndexVectors4Usher()
double sendFromMD2Macro(const coupling::datastructures::FlexibleCellContainer< dim > ¯oscopicSolverCellContainer) override
void sendFromMacro2MD(const coupling::datastructures::FlexibleCellContainer< dim > ¯o2MDBuffer) override
void computeAndStoreTemperature(double temperature) override
void perturbateVelocity() override
tarch::la::Vector< 3, unsigned int > _usherCellStart[1<< dim]
Definition CouplingCellService.h:356
const std::string _microscopicFilename
Definition CouplingCellService.h:347
void distributeMass(unsigned int t) override
coupling::transferstrategies::TransferStrategy< LinkedCell, dim > * _transferStrategy
Definition CouplingCellService.h:333
double applyFilterPipeline() override
void distributeMomentum(unsigned int t) override
virtual ~CouplingCellServiceImpl()
coupling::ParticleInsertion< LinkedCell, dim > * _particleInsertion
Definition CouplingCellService.h:329
coupling::datastructures::LinkedCellContainer< LinkedCell, dim > & getCouplingCells()
Definition CouplingCellService.h:275
coupling::KineticEnergyController< LinkedCell, dim > _kineticEnergyController
Definition CouplingCellService.h:337
coupling::interface::MacroscopicSolverInterface< dim > * _macroscopicSolverInterface
Definition CouplingCellService.h:307
void applyBoundaryForce(unsigned int t) override
coupling::MomentumInsertion< LinkedCell, dim > * _momentumInsertion
Definition CouplingCellService.h:326
coupling::MomentumController< LinkedCell, dim > _momentumController
Definition CouplingCellService.h:342
coupling::filtering::FilterPipeline< I02, dim > * _filterPipeline
Definition CouplingCellService.h:319
coupling::datastructures::LinkedCellContainer< LinkedCell, dim > _couplingCells
Definition CouplingCellService.h:316
coupling::BoundaryForceController< LinkedCell, dim > * _boundaryForceController
Definition CouplingCellService.h:340
const unsigned int _numberMDTimestepsPerCouplingCycle
Definition CouplingCellService.h:301
const char * _filterPipelineConfiguration
Definition CouplingCellService.h:322
Definition CouplingCellService.h:49
unsigned int _topologyOffset
Definition CouplingCellService.h:90
Definition TransferStrategy.h:25
Definition MultiMDService.h:30
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15