📄 communicator2d.hh
字号:
/* This file is part of the OpenLB library * * Copyright (C) 2007 Mathias J. Krause * Address: Wilhelm-Maybach-Str. 24, 68766 Hockenheim, Germany * E-mail: mathias.j.krause@gmx.de * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA.*//** \file * A communincator provides a cuboids with cells of other * cuboids -- generic implementation. */#ifndef COMMUNICATOR_2D_HH#define COMMUNICATOR_2D_HH#include "complexGrids/mpiManager/mpiManager.h"#include <vector>#include "communicator2D.h"#include "cuboidNeighbourhood2D.h"#include "cuboidGeometry2D.h"#include "superLattice2D.h"namespace olb {/////////////////// Class Communicator2D //////////////////////template<typename T, template<typename U> class Lattice>Communicator2D<T,Lattice>::Communicator2D(SuperLattice2D<T,Lattice>& sLattice):_sLattice(sLattice) { _initDone = false;}template<typename T, template<typename U> class Lattice>void Communicator2D<T,Lattice>::init_nh() { _nC = _sLattice.get_cGeometry().get_nC(); for (int iC=0; iC<_sLattice.get_load().size(); iC++) { CuboidNeighbourhood2D<T,Lattice> nh(_sLattice,_sLattice.get_load().glob(iC)); _nh.push_back(nh); }}template<typename T, template<typename U> class Lattice>void Communicator2D<T,Lattice>::add_cell(int iC, T globX, T globY) { if( iC >= _sLattice.get_load().get_firstGlobNum() && iC <= _sLattice.get_load().get_lastGlobNum() ) { _nh[_sLattice.get_load().loc(iC)].add_inCell(globX, globY); }}template<typename T, template<typename U> class Lattice>void Communicator2D<T,Lattice>::add_cells(int overlap) { for (int iC=0; iC<_sLattice.get_load().size(); iC++) { for (int i=0; i<=overlap; i++) { _nh[iC].add_inCells(overlap); } }}template<typename T, template<typename U> class Lattice>void Communicator2D<T,Lattice>::init() { reset(); for (int iC=0; iC<_sLattice.get_load().size(); iC++) { _nh[iC].init_inCN(); #ifndef PARALLEL_MODE_MPI for (int i=0; i<_nh[iC].get_inCellsSize(); i++) { Cell2D<T> temp; temp.globX = _nh[iC].get_inCell(i).globX; temp.globY = _nh[iC].get_inCell(i).globY; temp.iC = iC; int ID = _nh[iC].get_inCell(i).iC; _nh[ID].add_outCell(temp); } #endif } for (int iC=0; iC<_sLattice.get_load().size(); iC++) { _nh[iC].init_outCN(); } #ifdef PARALLEL_MODE_MPI for (int iC=0; iC<_sLattice.get_load().size(); iC++) { _nh[iC].finish_comm(); } for (int iC=0; iC<_sLattice.get_load().size(); iC++) { _nh[iC].bufSend_inCells(); } for (int iC=0; iC<_sLattice.get_load().size(); iC++) { _nh[iC].recWrite_outCells(); } for (int iC=0; iC<_sLattice.get_load().size(); iC++) { _nh[iC].finish_comm(); } #endif}template<typename T, template<typename U> class Lattice>void Communicator2D<T,Lattice>::reset() { if (_initDone) { for (int iC=0; iC<_sLattice.get_load().size(); iC++) { _nh[iC].reset(); } _initDone = false; }}template<typename T, template<typename U> class Lattice>void Communicator2D<T,Lattice>::send() { for (int iC=0; iC<_sLattice.get_load().size(); iC++) { _nh[iC].buffer_outData(); #ifdef PARALLEL_MODE_MPI _nh[iC].send_outData(); #endif }}template<typename T, template<typename U> class Lattice>void Communicator2D<T,Lattice>::receive() { for (int iC=0; iC<_sLattice.get_load().size(); iC++) { #ifdef PARALLEL_MODE_MPI _nh[iC].receive_inData(); #else for (int i=0; i<_nh[iC].get_inCsize();i++) { _nh[iC].get_inData()[_nh[iC].get_inC(i)] = _nh[_nh[iC].get_inC(i)].get_outData()[iC]; } #endif } #ifdef PARALLEL_MODE_MPI for (int iC=0; iC<_sLattice.get_load().size(); iC++) { _nh[iC].finish_comm(); } #endif}template<typename T, template<typename U> class Lattice>void Communicator2D<T,Lattice>::write() { for (int iC=0; iC<_sLattice.get_load().size(); iC++) { _nh[iC].write_inData(); }}}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -