MaMiCo 1.2
Loading...
Searching...
No Matches
LBCouetteSolverInterface.h
1// Copyright (C) 2016 Technische Universitaet Muenchen
2// This file is part of the Mamico project. For conditions of distribution
3// and use, please see the copyright notice in Mamico's main folder, or at
4// www5.in.tum.de/mamico
5
6#ifndef _MOLECULARDYNAMICS_COUPLING_SOLVERS_LBCOUETTESOLVERINTERFACE_H_
7#define _MOLECULARDYNAMICS_COUPLING_SOLVERS_LBCOUETTESOLVERINTERFACE_H_
8
9#include "coupling/interface/MacroscopicSolverInterface.h"
10
11namespace coupling {
12namespace solvers {
14}
15} // namespace coupling
16
27public:
39 tarch::la::Vector<3, unsigned int> offsetMDDomain, tarch::la::Vector<3, unsigned int> globalNumberCouplingCells,
40 unsigned int outerRegion = 1)
41 : _avgNumberLBCells(avgNumberLBCells), _numberProcesses(numberProcesses), _offsetMDDomain(offsetMDDomain), _outerRegion(outerRegion),
42 _globalNumberCouplingCells(globalNumberCouplingCells) {}
44
45 unsigned int getOuterRegion() override { return _outerRegion; }
46
51 std::vector<unsigned int> getRanks(I01 idx) override {
52 std::vector<unsigned int> ranks;
53 // determine global index of cell in LB simulation
55 // modify global LB cell index due to ghost layer
56 for (int d = 0; d < 3; d++) {
57#if (COUPLING_MD_DEBUG == COUPLING_MD_YES)
58 std::cout << "LB cell index for global cell index " << idx << ": " << globalLBCellIndex << std::endl;
59#endif
60 if (globalLBCellIndex[d] > 0) {
61 globalLBCellIndex[d]--;
62 }
63 }
64 // loop over all neighbouring cells within a one-cell surrounding and detect
65 // the respective ranks. IMPROVE: This currently only allows for simulations
66 // with MD located inside the domain (no simulation across boundary)
67 for (int z = -1; z < 2; z++) {
68 for (int y = -1; y < 2; y++) {
69 for (int x = -1; x < 2; x++) {
70 // neighbour cell index
71 const tarch::la::Vector<3, unsigned int> nbIndex(globalLBCellIndex[0] + x, globalLBCellIndex[1] + y, globalLBCellIndex[2] + z);
72 // coordinates of process of neighbour celll
73 const tarch::la::Vector<3, unsigned int> processCoordinates((nbIndex[0] / _avgNumberLBCells[0]), (nbIndex[1] / _avgNumberLBCells[1]),
74 (nbIndex[2] / _avgNumberLBCells[2]));
75 // corresponding rank
76 const unsigned int rank = processCoordinates[0] + _numberProcesses[0] * (processCoordinates[1] + processCoordinates[2] * _numberProcesses[1]);
77
78 // if this rank is not part of the vector, push it back
79 bool found = false;
80 for (unsigned int i = 0; i < ranks.size(); i++) {
81 found = found || (rank == ranks[i]);
82 }
83 if (!found) {
84 ranks.push_back(rank);
85 }
86 }
87 }
88 }
89#if (COUPLING_MD_DEBUG == COUPLING_MD_YES)
90 std::cout << "Ranks for cell " << idx << ":";
91 for (unsigned int i = 0; i < ranks.size(); i++) {
92 std::cout << " " << ranks[i];
93 }
94 std::cout << std::endl;
95#endif
96 return ranks;
97 }
98
109 std::vector<unsigned int> getSourceRanks(I01 idx) override {
110 // determine global index of cell in LB simulation
112 // modify global LB cell index due to ghost layer
113 for (int d = 0; d < 3; d++) {
114#if (COUPLING_MD_DEBUG == COUPLING_MD_YES)
115 std::cout << "LB cell index for global cell index " << idx << ": " << globalLBCellIndex << std::endl;
116#endif
117 if (globalLBCellIndex[d] > 0) {
118 globalLBCellIndex[d]--;
119 }
120 }
121 // determine process coordinates and respective rank
122 const tarch::la::Vector<3, unsigned int> processCoordinates(globalLBCellIndex[0] / _avgNumberLBCells[0], globalLBCellIndex[1] / _avgNumberLBCells[1],
123 globalLBCellIndex[2] / _avgNumberLBCells[2]);
124 const unsigned int rank = processCoordinates[0] + _numberProcesses[0] * (processCoordinates[1] + processCoordinates[2] * _numberProcesses[1]);
125 std::vector<unsigned int> ranks;
126 ranks.push_back(rank);
127#if (COUPLING_MD_DEBUG == COUPLING_MD_YES)
128 std::cout << "Source rank for cell " << idx << ": " << ranks[0] << std::endl;
129#endif
130 return ranks;
131 }
132
133private:
143 const unsigned int _outerRegion;
146};
147
148#endif // _MOLECULARDYNAMICS_COUPLING_SOLVERS_LBCOUETTESOLVERINTERFACE_H_
value_T get() const
Definition CellIndex.h:138
interface for the macroscopic, i.e. continuum solver
Definition MacroscopicSolverInterface.h:23
interface for the LBCouetteSolver
Definition LBCouetteSolverInterface.h:26
LBCouetteSolverInterface(tarch::la::Vector< 3, unsigned int > avgNumberLBCells, tarch::la::Vector< 3, unsigned int > numberProcesses, tarch::la::Vector< 3, unsigned int > offsetMDDomain, tarch::la::Vector< 3, unsigned int > globalNumberCouplingCells, unsigned int outerRegion=1)
a simple constructor
Definition LBCouetteSolverInterface.h:38
std::vector< unsigned int > getRanks(I01 idx) override
returns for a given coupling cell index, which rank holds the correct data @oaram idx global dimensio...
Definition LBCouetteSolverInterface.h:51
const tarch::la::Vector< 3, unsigned int > _globalNumberCouplingCells
global number of coupling cells
Definition LBCouetteSolverInterface.h:145
const tarch::la::Vector< 3, unsigned int > _offsetMDDomain
offset of MD domain (excl. any ghost layers on MD or LB side)
Definition LBCouetteSolverInterface.h:140
const tarch::la::Vector< 3, unsigned int > _avgNumberLBCells
avg. number of LB cells per LB process (must be same for Interface and LBCouetteSolver)
Definition LBCouetteSolverInterface.h:136
std::vector< unsigned int > getSourceRanks(I01 idx) override
returns for a given coupling cell index, which source rank holds the correct data
Definition LBCouetteSolverInterface.h:109
const tarch::la::Vector< 3, unsigned int > _numberProcesses
number of processes used by LB solver
Definition LBCouetteSolverInterface.h:138
const unsigned int _outerRegion
defines an offset of cells which is considered to be the outer region
Definition LBCouetteSolverInterface.h:143
Definition Vector.h:24
all numerical solvers are defined in the namespace, and their interfaces
Definition CouetteSolver.h:14
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15