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/DataExchangeFromAllMacro2MD.h"
31#include "coupling/sendrecv/FromMD2Macro.h"
32#include "coupling/sendrecv/FromMacro2MD.h"
33#include "tarch/utils/MultiMDService.h"
35#include "coupling/filtering/FilterPipeline.h"
40template <
unsigned int dim>
class CouplingCellService;
52 CouplingCellService(
unsigned int ID,
unsigned int topologyOffset) : _id(ID),
_topologyOffset(topologyOffset) {
53#if (COUPLING_MD_DEBUG == COUPLING_MD_YES)
54 std::cout <<
"CouplingCellService::CouplingCellService(): Set ID=" << _id << std::endl;
57 virtual ~CouplingCellService() {}
59 virtual double applyFilterPipeline() = 0;
60 virtual void sendFromMacro2MDPreProcess() = 0;
61 virtual void sendFromMacro2MDPostProcess() = 0;
63 virtual void sendFromMD2MacroPreProcess() = 0;
64 virtual void sendFromMD2MacroPostProcess() = 0;
66 virtual void processInnerCouplingCellAfterMDTimestep() = 0;
67 virtual void computeAndStoreTemperature(
double temperature) = 0;
74 virtual void plotEveryMacroscopicTimestep(
unsigned int t) = 0;
75 virtual void setInnerMomentumImposition(
bool enable) = 0;
78 throw std::runtime_error(
"CouplingCellService: Error: Called "
79 "initFiltering for non-Impl object.");
83 throw std::runtime_error(
"CouplingCellService: Error: Called getFilterPipeline() in instance "
84 "without FilterPipeline.");
88 unsigned int getID()
const {
return _id; }
91 const unsigned int _id;
137 unsigned int numberMDTimestepsPerCouplingCycle,
157 unsigned int numberMDTimestepsPerCouplingCycle,
163 :
CouplingCellServiceImpl<LinkedCell, dim>(ID, mdSolverInterface, macroscopicSolverInterface, numberProcesses, rank, particleInsertionConfiguration,
164 momentumInsertionConfiguration, boundaryForceConfiguration, transferStrategyConfiguration,
165 parallelTopologyConfiguration, thermostatConfiguration, numberMDTimestepsPerCouplingCycle,
166 couplingCellConfiguration, filterPipelineConfiguration, multiMDService, 0) {}
195 void sendFromMacro2MDPreProcess()
override;
197 void sendFromMacro2MDPostProcess()
override;
199 void sendFromMD2MacroPreProcess()
override;
201 void sendFromMD2MacroPostProcess()
override {}
241 void plotEveryMacroscopicTimestep(
unsigned int t)
override;
242 void setInnerMomentumImposition(
bool enable)
override;
283#include "CouplingCellTraversalWrappers.cpph"
291 if (thermostatConfiguration.getThermostatRegionType() == coupling::configurations::ThermostatConfiguration::ThermostatRegion::all)
292 return [
this](
Wrapper& wrapper) {
_couplingCells.applyToLocalNonGhostCouplingCellsWithLinkedCells(wrapper); };
293 else if (thermostatConfiguration.getThermostatRegionType() == coupling::configurations::ThermostatConfiguration::ThermostatRegion::outerLayers)
294 return [
this, &thermostatConfiguration](Wrapper& wrapper) {
295 _couplingCells.applyXLayersOfGlobalNonGhostCellsWithLinkedCells(wrapper, thermostatConfiguration.getCells2Use());
297 else if (thermostatConfiguration.getThermostatRegionType() == coupling::configurations::ThermostatConfiguration::ThermostatRegion::onlyOutestLayer)
298 return [
this](Wrapper& wrapper) {
_couplingCells.applyToFirstLayerOfGlobalNonGhostCellsWithLinkedCells(wrapper); };
300 return [](Wrapper& wrapper) {};
316 bool _enableInnerImposition;
349 std::function<void(
Wrapper&)> _applyAccordingToConfiguration;
353 const unsigned int _writeEveryMicroscopicTimestep;
354 const std::string _macroscopicFilename;
355 const unsigned int _writeEveryMacroscopicTimestep;
368#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
Definition DataExchangeFromAllMacro2MD.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:100
coupling::sendrecv::FromMacro2MD< coupling::datastructures::CouplingCell< dim >, dim > _fromMacro2MD
Definition CouplingCellService.h:313
void processInnerCouplingCellAfterMDTimestep() override
coupling::interface::MDSolverInterface< LinkedCell, dim > * _mdSolverInterface
Definition CouplingCellService.h:307
void plotEveryMicroscopicTimestep(unsigned int t) override
void initFiltering() override
Definition CouplingCellService.h:249
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:361
const std::string _microscopicFilename
Definition CouplingCellService.h:352
void distributeMass(unsigned int t) override
coupling::transferstrategies::TransferStrategy< LinkedCell, dim > * _transferStrategy
Definition CouplingCellService.h:338
double applyFilterPipeline() override
void distributeMomentum(unsigned int t) override
virtual ~CouplingCellServiceImpl()
coupling::ParticleInsertion< LinkedCell, dim > * _particleInsertion
Definition CouplingCellService.h:334
coupling::datastructures::LinkedCellContainer< LinkedCell, dim > & getCouplingCells()
Definition CouplingCellService.h:278
coupling::KineticEnergyController< LinkedCell, dim > _kineticEnergyController
Definition CouplingCellService.h:342
coupling::interface::MacroscopicSolverInterface< dim > * _macroscopicSolverInterface
Definition CouplingCellService.h:310
void applyBoundaryForce(unsigned int t) override
coupling::MomentumInsertion< LinkedCell, dim > * _momentumInsertion
Definition CouplingCellService.h:331
coupling::MomentumController< LinkedCell, dim > _momentumController
Definition CouplingCellService.h:347
coupling::filtering::FilterPipeline< I02, dim > * _filterPipeline
Definition CouplingCellService.h:324
coupling::datastructures::LinkedCellContainer< LinkedCell, dim > _couplingCells
Definition CouplingCellService.h:321
coupling::BoundaryForceController< LinkedCell, dim > * _boundaryForceController
Definition CouplingCellService.h:345
const unsigned int _numberMDTimestepsPerCouplingCycle
Definition CouplingCellService.h:304
const char * _filterPipelineConfiguration
Definition CouplingCellService.h:327
Definition CouplingCellService.h:50
unsigned int _topologyOffset
Definition CouplingCellService.h:92
Definition TransferStrategy.h:25
Definition MultiMDService.h:30
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15