Alsvinn  0.5.3
The fast FVM simulator with UQ support
CudaCartesianCellExchanger.hpp
Go to the documentation of this file.
1 /* Copyright (c) 2018 ETH Zurich, Kjetil Olsen Lye
2  * This program is free software: you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation, either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program. If not, see <http://www.gnu.org/licenses/>.
14  */
15 
16 #pragma once
20 #include <thrust/host_vector.h>
21 
22 namespace alsfvm {
23 namespace mpi {
24 
28 public:
44  const ivec6& neighbours);
45 
47  const volume::Volume& inputVolume) override;
48 
49  real max(real number) override;
50 
51  bool hasSide(int side) const;
52 
53  int getNumberOfActiveSides() const;
54 
55  ivec6 getNeighbours() const override;
56 private:
57  ConfigurationPtr configuration;
58  ivec6 neighbours;
59 
60  // for each variable, for each side
61  std::vector<std::vector<alsfvm::shared_ptr<cuda::CudaMemory<real> > > > buffers;
62 
63  std::vector<std::vector<thrust::host_vector<real> > > cpuBuffersSend;
64  std::vector<std::vector<thrust::host_vector<real> > > cpuBuffersReceive;
65  void makeBuffers(const volume::Volume& inputVolume);
66  void makeStreams(const volume::Volume& inputVolume);
67 
68  void extractSides(const volume::Volume& inputVolume);
69  void extractSide(const ivec3& start, const ivec3& end,
70  int side,
71  const volume::Volume& inputvolume);
72 
73  void insertSides(volume::Volume& outputVolume);
74  void insertSide(const ivec3& start, const ivec3& end,
75  int side,
76  volume::Volume& outputVolume);
77 
78 
79  std::vector<std::vector<cudaStream_t> > memoryStreams;
80 
81  std::vector<std::vector<RequestPtr> > receiveRequests;
82  std::vector<std::vector<RequestPtr> > sendRequests;
83 
84 
85 };
86 } // namespace mpi
87 } // namespace alsfvm
real max(real number) override
Does the maximum over all processors.
CudaCartesianCellExchanger(ConfigurationPtr &configuration, const ivec6 &neighbours)
The Volume class represents a volume (a collection of cells with values for each cell (eg...
Definition: Volume.hpp:30
Abstract base class for exchanging cells.
Definition: CellExchanger.hpp:26
double real
Definition: types.hpp:65
ivec6 getNeighbours() const override
Definition: CudaCartesianCellExchanger.hpp:27
RequestContainer exchangeCells(volume::Volume &outputVolume, const volume::Volume &inputVolume) override
Does the exchange of cells between the processors.
Holds a collection of requests.
Definition: RequestContainer.hpp:23
alsfvm::shared_ptr< Configuration > ConfigurationPtr
Definition: Configuration.hpp:53
Various utility functions to implement the tecno flux.
Definition: types.hpp:30