source: ThirdParty/vmg/src/comm/comm.hpp@ 33a694

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes
Last change on this file since 33a694 was 7faa5c, checked in by Frederik Heber <heber@…>, 8 years ago

Merge commit 'de061d9d851257a04e924d4472df4523d33bb08b' as 'ThirdParty/vmg'

  • Property mode set to 100644
File size: 5.9 KB
Line 
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
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
31#include <map>
32#include <vector>
33
34#include "base/defs.hpp"
35#include "base/index.hpp"
36#include "base/object.hpp"
37#include "comm/domain_decomposition.hpp"
38#include "thirdparty/pugixml/pugixml.hpp"
39
40namespace VMG
41{
42
43class BoundaryValue;
44class DomainDecomposition;
45class GlobalIndices;
46class Grid;
47class Interface;
48class Multigrid;
49class Stencil;
50
51class Comm : public Object
52{
53public:
54 Comm(const Boundary& boundary, DomainDecomposition* domain_dec, bool register_ = true) :
55 Object("COMM", register_),
56 bound(boundary),
57 dd(domain_dec),
58 particle_grid(NULL),
59 output_directory_is_created(false),
60 output_count(0)
61 {}
62
63 virtual ~Comm();
64
65 virtual Grid& GetCoarserGrid(Multigrid& multigrid) = 0;
66 virtual Grid& GetFinerGrid(Multigrid& multigrid) = 0;
67 Grid& GetParticleGrid();
68
69 virtual void CommFromGhosts(Grid& grid) = 0;
70 virtual void CommToGhosts(Grid& grid) = 0;
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;
73 virtual std::vector<BoundaryValue> CommBoundaryValues() = 0;
74
75 virtual void CommToGhostsAsyncStart(Grid& grid) = 0;
76 virtual void CommToGhostsAsyncFinish(Grid& grid) = 0;
77 virtual void CommFromGhostsAsyncStart(Grid& grid) = 0;
78 virtual void CommFromGhostsAsyncFinish(Grid& grid) = 0;
79
80 virtual void Barrier() {}
81
82 virtual vmg_float GlobalSum(vmg_float value) {return value;}
83 virtual vmg_float GlobalSumRoot(vmg_float value) {return value;}
84 virtual void GlobalSumArray(vmg_float* array, const vmg_int& size) {}
85 virtual vmg_float GlobalMax(vmg_float value) {return value;}
86 virtual vmg_float GlobalMaxRoot(vmg_float value) {return value;}
87 virtual void GlobalMaxArray(vmg_float* array, const vmg_int& size) {}
88 virtual void GlobalBroadcast(vmg_float& value) {}
89 virtual void GlobalGather(vmg_float& value, vmg_float* array) {array[0] = value;}
90
91 virtual vmg_int GlobalSum(vmg_int value) {return value;}
92 virtual vmg_int GlobalSumRoot(vmg_int value) {return value;}
93 virtual void GlobalSumArray(vmg_int* array, const vmg_int& size) {}
94 virtual vmg_int GlobalMax(vmg_int value) {return value;}
95 virtual vmg_int GlobalMaxRoot(vmg_int value) {return value;}
96 virtual void GlobalMaxArray(vmg_int* array, const vmg_int& size) {}
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) {}
101
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;}
104 virtual void LevelSumArray(const Grid& grid, vmg_float* array, const vmg_int& size) {}
105
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;}
108 virtual void LevelSumArray(const Grid& grid, vmg_int* array, const vmg_int& size) {}
109
110 virtual void Print(const OutputLevel level, const char* format, ...) = 0;
111 virtual void PrintOnce(const OutputLevel level, const char* format, ...) = 0;
112
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;
117 virtual void PrintDefect(Grid& sol, Grid& rhs, const char* information) = 0;
118
119 virtual void DebugPrintError(const Grid& sol, const char* information) {}
120 virtual void DebugPrintErrorNorm(Grid& sol) {}
121 virtual void DebugPrintGridStructure(Multigrid& multigrid) {}
122
123 virtual int GlobalRank() const {return 0;}
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);}
132
133 virtual void PostInit(Multigrid& sol, Multigrid& rhs) = 0;
134
135 const Boundary& BoundaryConditions() const {return bound;}
136
137 vmg_float ComputeResidualNorm(Multigrid& sol, Multigrid& rhs);
138
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
143protected:
144 const std::string& OutputPath();
145 int OutputCount() {return ++output_count;}
146
147 std::map<Index, std::vector<GlobalIndices> > decomposed_global;
148
149 Boundary bound;
150 DomainDecomposition* dd;
151
152private:
153 virtual std::string CreateOutputDirectory() = 0;
154
155 Grid* particle_grid;
156 std::string output_path_str;
157 bool output_directory_is_created;
158 int output_count;
159};
160
161}
162
163#endif /* COMM_HPP_ */
Note: See TracBrowser for help on using the repository browser.