source: src/comm/comm.hpp@ 177495

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

Implemented boundary values derived from continious problem.

  • Property mode set to 100644
File size: 5.9 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
[d6a338]31#include <map>
[177495]32#include <vector>
[dfed1c]33
[48b662]34#include "base/defs.hpp"
35#include "base/index.hpp"
36#include "base/object.hpp"
[d6a338]37#include "comm/domain_decomposition.hpp"
[dfed1c]38#include "thirdparty/pugixml/pugixml.hpp"
[48b662]39
40namespace VMG
41{
42
[177495]43class BoundaryValue;
[dfed1c]44class DomainDecomposition;
[d6a338]45class GlobalIndices;
[48b662]46class Grid;
[d6a338]47class Interface;
[48b662]48class Multigrid;
49class Stencil;
50
51class Comm : public Object
52{
53public:
[b57b9b]54 Comm(const Boundary& boundary, DomainDecomposition* domain_dec, bool register_ = true) :
55 Object("COMM", register_),
[dfed1c]56 bound(boundary),
57 dd(domain_dec),
[894a5f]58 particle_grid(NULL),
[dfed1c]59 output_directory_is_created(false),
60 output_count(0)
[894a5f]61 {}
[48b662]62
[dfed1c]63 virtual ~Comm();
64
[48b662]65 virtual Grid& GetCoarserGrid(Multigrid& multigrid) = 0;
66 virtual Grid& GetFinerGrid(Multigrid& multigrid) = 0;
[894a5f]67 Grid& GetParticleGrid();
[48b662]68
69 virtual void CommFromGhosts(Grid& grid) = 0;
70 virtual void CommToGhosts(Grid& grid) = 0;
[ac6d04]71 virtual void CommSubgrid(Grid& grid_old, Grid& grid_new, const int& direction) = 0;
72 virtual void CommAddSubgrid(Grid& grid_old, Grid& grid_new, const int& direction) = 0;
[177495]73 virtual std::vector<BoundaryValue> CommBoundaryValues() = 0;
[dfed1c]74
[894a5f]75 virtual void CommToGhostsAsyncStart(Grid& grid) = 0;
[ac6d04]76 virtual void CommToGhostsAsyncFinish(Grid& grid) = 0;
[894a5f]77 virtual void CommFromGhostsAsyncStart(Grid& grid) = 0;
78 virtual void CommFromGhostsAsyncFinish(Grid& grid) = 0;
79
[2a5451]80 virtual void Barrier() {}
81
[ef94e7]82 virtual vmg_float GlobalSum(vmg_float value) {return value;}
83 virtual vmg_float GlobalSumRoot(vmg_float value) {return value;}
[ac6d04]84 virtual void GlobalSumArray(vmg_float* array, const vmg_int& size) {}
[ef94e7]85 virtual vmg_float GlobalMax(vmg_float value) {return value;}
86 virtual vmg_float GlobalMaxRoot(vmg_float value) {return value;}
[b51c3b]87 virtual void GlobalMaxArray(vmg_float* array, const vmg_int& size) {}
[2a5451]88 virtual void GlobalBroadcast(vmg_float& value) {}
89 virtual void GlobalGather(vmg_float& value, vmg_float* array) {array[0] = value;}
[b51c3b]90
[ef94e7]91 virtual vmg_int GlobalSum(vmg_int value) {return value;}
92 virtual vmg_int GlobalSumRoot(vmg_int value) {return value;}
[2a5451]93 virtual void GlobalSumArray(vmg_int* array, const vmg_int& size) {}
[ef94e7]94 virtual vmg_int GlobalMax(vmg_int value) {return value;}
95 virtual vmg_int GlobalMaxRoot(vmg_int value) {return value;}
[b51c3b]96 virtual void GlobalMaxArray(vmg_int* array, const vmg_int& size) {}
[2a5451]97 virtual void GlobalBroadcast(vmg_int& value) {}
98 virtual void GlobalGather(vmg_int& value, vmg_int* array) {array[0] = value;}
99
100 virtual void GlobalBroadcast(char* str) {}
[b51c3b]101
[ef94e7]102 virtual vmg_float LevelSum(const Grid& grid, vmg_float value) {return value;}
103 virtual vmg_float LevelSumRoot(const Grid& grid, vmg_float value) {return value;}
[ac6d04]104 virtual void LevelSumArray(const Grid& grid, vmg_float* array, const vmg_int& size) {}
105
[ef94e7]106 virtual vmg_int LevelSum(const Grid& grid, vmg_int value) {return value;}
107 virtual vmg_int LevelSumRoot(const Grid& grid, vmg_int value) {return value;}
[ac6d04]108 virtual void LevelSumArray(const Grid& grid, vmg_int* array, const vmg_int& size) {}
[dfed1c]109
[d13e27]110 virtual void Print(const OutputLevel level, const char* format, ...) = 0;
111 virtual void PrintOnce(const OutputLevel level, const char* format, ...) = 0;
112
[dfed1c]113 virtual void PrintXML(const std::string& filename, const std::string& xml_data) = 0;
114 virtual void PrintXMLAll(const std::string& filename, const std::string& xml_data) = 0;
115 virtual void PrintAllSettings() = 0;
116 virtual void PrintGrid(Grid& grid, const char* information) = 0;
[ac6d04]117 virtual void PrintDefect(Grid& sol, Grid& rhs, const char* information) = 0;
[48b662]118
119 virtual void DebugPrintError(const Grid& sol, const char* information) {}
120 virtual void DebugPrintErrorNorm(Grid& sol) {}
121 virtual void DebugPrintGridStructure(Multigrid& multigrid) {}
122
[dfed1c]123 virtual int GlobalRank() const {return 0;}
[ac6d04]124 virtual int GlobalSize() const {return 1;}
125 virtual Index GlobalPos() const {return Index(0);}
126 virtual Index GlobalProcs() const {return Index(1);}
127
128 virtual int Rank(const Grid& grid) const {return 0;}
129 virtual int Size(const Grid& grid) const {return 1;}
130 virtual Index Pos(const Grid& grid) const {return Index(0);}
131 virtual Index Procs(const Grid& grid) const {return Index(1);}
[dfed1c]132
[894a5f]133 virtual void PostInit(Multigrid& sol, Multigrid& rhs) = 0;
134
[dfed1c]135 const Boundary& BoundaryConditions() const {return bound;}
[48b662]136
[dfed1c]137 vmg_float ComputeResidualNorm(Multigrid& sol, Multigrid& rhs);
[48b662]138
[d6a338]139 void ComputeDomainDecomposition(const Interface& interface) {dd->Compute(*this, interface, decomposed_global);}
140 const std::vector<GlobalIndices>& DecomposedGlobalMe() const {return decomposed_global.find(GlobalPos())->second;}
141 const std::map<Index, std::vector<GlobalIndices> >& DecomposedGlobal() const {return decomposed_global;}
142
[48b662]143protected:
[dfed1c]144 const std::string& OutputPath();
145 int OutputCount() {return ++output_count;}
146
[d6a338]147 std::map<Index, std::vector<GlobalIndices> > decomposed_global;
148
[dfed1c]149 Boundary bound;
150 DomainDecomposition* dd;
151
152private:
153 virtual std::string CreateOutputDirectory() = 0;
[894a5f]154
155 Grid* particle_grid;
[dfed1c]156 std::string output_path_str;
157 bool output_directory_is_created;
158 int output_count;
[48b662]159};
160
161}
162
163#endif /* COMM_HPP_ */
Note: See TracBrowser for help on using the repository browser.