source: src/comm/comm.hpp@ 2a5451

Last change on this file since 2a5451 was 2a5451, checked in by Julian Iseringhausen <isering@…>, 14 years ago

vmg now succeeds on test_comm.

git-svn-id: https://svn.version.fz-juelich.de/scafacos/trunk@1816 5161e1c8-67bf-11de-9fd5-51895aff932f

  • Property mode set to 100644
File size: 5.4 KB
RevLine 
[fcf7f6]1/*
2 * vmg - a versatile multigrid solver
3 * Copyright (C) 2012 Institute for Numerical Simulation, University of Bonn
4 *
5 * vmg is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * vmg is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
[48b662]19/**
20 * @file comm.hpp
21 * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
22 * @date Wed Jun 16 13:21:06 2010
23 *
24 * @brief Base class for communication.
25 *
26 */
27
28#ifndef COMM_HPP_
29#define COMM_HPP_
30
[dfed1c]31#include <list>
32
[48b662]33#include "base/defs.hpp"
34#include "base/index.hpp"
35#include "base/object.hpp"
[dfed1c]36#include "thirdparty/pugixml/pugixml.hpp"
[48b662]37
38namespace VMG
39{
40
[dfed1c]41class DomainDecomposition;
[48b662]42class Grid;
43class Multigrid;
44class Stencil;
45
46class Comm : public Object
47{
48public:
[dfed1c]49 Comm(const Boundary& boundary, DomainDecomposition* domain_dec) :
50 bound(boundary),
51 dd(domain_dec),
[894a5f]52 particle_grid(NULL),
[dfed1c]53 output_directory_is_created(false),
54 output_count(0)
[894a5f]55 {}
[48b662]56
[dfed1c]57 virtual ~Comm();
58
[48b662]59 virtual Grid& GetCoarserGrid(Multigrid& multigrid) = 0;
60 virtual Grid& GetFinerGrid(Multigrid& multigrid) = 0;
[894a5f]61 Grid& GetParticleGrid();
[48b662]62
63 virtual void CommFromGhosts(Grid& grid) = 0;
64 virtual void CommToGhosts(Grid& grid) = 0;
[ac6d04]65 virtual void CommSubgrid(Grid& grid_old, Grid& grid_new, const int& direction) = 0;
66 virtual void CommAddSubgrid(Grid& grid_old, Grid& grid_new, const int& direction) = 0;
[dfed1c]67
[894a5f]68 virtual void CommToGhostsAsyncStart(Grid& grid) = 0;
[ac6d04]69 virtual void CommToGhostsAsyncFinish(Grid& grid) = 0;
[894a5f]70 virtual void CommFromGhostsAsyncStart(Grid& grid) = 0;
71 virtual void CommFromGhostsAsyncFinish(Grid& grid) = 0;
72
[2a5451]73 virtual void Barrier() {}
74
[ac6d04]75 virtual vmg_float GlobalSum(const vmg_float& value) {return value;}
76 virtual vmg_float GlobalSumRoot(const vmg_float& value) {return value;}
77 virtual void GlobalSumArray(vmg_float* array, const vmg_int& size) {}
[b51c3b]78 virtual vmg_float GlobalMax(const vmg_float& value) {return value;}
79 virtual vmg_float GlobalMaxRoot(const vmg_float& value) {return value;}
80 virtual void GlobalMaxArray(vmg_float* array, const vmg_int& size) {}
[2a5451]81 virtual void GlobalBroadcast(vmg_float& value) {}
82 virtual void GlobalGather(vmg_float& value, vmg_float* array) {array[0] = value;}
[b51c3b]83
[2a5451]84 virtual vmg_int GlobalSum(const vmg_int& value) {return value;}
85 virtual vmg_int GlobalSumRoot(const vmg_int& value) {return value;}
86 virtual void GlobalSumArray(vmg_int* array, const vmg_int& size) {}
[b51c3b]87 virtual vmg_int GlobalMax(const vmg_int& value) {return value;}
88 virtual vmg_int GlobalMaxRoot(const vmg_int& value) {return value;}
89 virtual void GlobalMaxArray(vmg_int* array, const vmg_int& size) {}
[2a5451]90 virtual void GlobalBroadcast(vmg_int& value) {}
91 virtual void GlobalGather(vmg_int& value, vmg_int* array) {array[0] = value;}
92
93 virtual void GlobalBroadcast(char* str) {}
[b51c3b]94
[ac6d04]95 virtual vmg_float LevelSum(const Grid& grid, const vmg_float& value) {return value;}
96 virtual vmg_float LevelSumRoot(const Grid& grid, const vmg_float& value) {return value;}
97 virtual void LevelSumArray(const Grid& grid, vmg_float* array, const vmg_int& size) {}
98
99 virtual vmg_int LevelSum(const Grid& grid, const vmg_int& value) {return value;}
100 virtual vmg_int LevelSumRoot(const Grid& grid, const vmg_int& value) {return value;}
101 virtual void LevelSumArray(const Grid& grid, vmg_int* array, const vmg_int& size) {}
[dfed1c]102
103 virtual void PrintString(const char* format, ...) = 0;
104 virtual void PrintStringOnce(const char* format, ...) = 0;
105 virtual void PrintXML(const std::string& filename, const std::string& xml_data) = 0;
106 virtual void PrintXMLAll(const std::string& filename, const std::string& xml_data) = 0;
107 virtual void PrintAllSettings() = 0;
108 virtual void PrintGrid(Grid& grid, const char* information) = 0;
[ac6d04]109 virtual void PrintDefect(Grid& sol, Grid& rhs, const char* information) = 0;
[48b662]110
111 virtual void DebugPrintError(const Grid& sol, const char* information) {}
112 virtual void DebugPrintErrorNorm(Grid& sol) {}
113 virtual void DebugPrintGridStructure(Multigrid& multigrid) {}
114
[dfed1c]115 virtual int GlobalRank() const {return 0;}
[ac6d04]116 virtual int GlobalSize() const {return 1;}
117 virtual Index GlobalPos() const {return Index(0);}
118 virtual Index GlobalProcs() const {return Index(1);}
119
120 virtual int Rank(const Grid& grid) const {return 0;}
121 virtual int Size(const Grid& grid) const {return 1;}
122 virtual Index Pos(const Grid& grid) const {return Index(0);}
123 virtual Index Procs(const Grid& grid) const {return Index(1);}
[dfed1c]124
[894a5f]125 virtual void PostInit(Multigrid& sol, Multigrid& rhs) = 0;
126
[dfed1c]127 const Boundary& BoundaryConditions() const {return bound;}
[48b662]128
[dfed1c]129 DomainDecomposition& GetDomainDecomposition() {return *dd;}
[48b662]130
[dfed1c]131 vmg_float ComputeResidualNorm(Multigrid& sol, Multigrid& rhs);
[48b662]132
133protected:
[dfed1c]134 const std::string& OutputPath();
135 int OutputCount() {return ++output_count;}
136
137 Boundary bound;
138 DomainDecomposition* dd;
139
140private:
141 virtual std::string CreateOutputDirectory() = 0;
[894a5f]142
143 Grid* particle_grid;
[dfed1c]144 std::string output_path_str;
145 bool output_directory_is_created;
146 int output_count;
[48b662]147};
148
149}
150
151#endif /* COMM_HPP_ */
Note: See TracBrowser for help on using the repository browser.