Debian Codegraph @

dune/uggrid/parallel/ddd/if/ifcheck.cc

raw
1 // SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LGPL-2.1-or-later
3 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 // vi: set et ts=4 sw=2 sts=2:
5 /****************************************************************************/
6 /* */
7 /* File: ifcheck.c */
8 /* */
9 /* Purpose: routines concerning interfaces between processors */
10 /* checking routines */
11 /* */
12 /* Author: Klaus Birken */
13 /* Institut fuer Computeranwendungen III */
14 /* Universitaet Stuttgart */
15 /* Pfaffenwaldring 27 */
16 /* 70550 Stuttgart */
17 /* email: [email protected] */
18 /* */
19 /* History: 960926 kb begin */
20 /* */
21 /* Remarks: */
22 /* */
23 /****************************************************************************/
24
25 /****************************************************************************/
26 /* */
27 /* include files */
28 /* system include files */
29 /* application include files */
30 /* */
31 /****************************************************************************/
32
33 /* standard C library */
34 #include <config.h>
35 #include <cstdlib>
36 #include <cstdio>
37
38 #include <iomanip>
39
40 #include <dune/common/stdstreams.hh>
41
42 #include <dune/uggrid/parallel/ddd/dddi.h>
43 #include <dune/uggrid/parallel/ddd/basic/notify.h>
44 #include "if.h"
45
46 using namespace PPIF;
47
48 /* general error string */
49 #define ERRSTR " DDD-IFC Warning: "
50
51 START_UGDIM_NAMESPACE
52
53 /****************************************************************************/
54 /* */
55 /* definition of static variables */
56 /* */
57 /****************************************************************************/
58
59
60
61
62 /****************************************************************************/
63 /* */
64 /* routines */
65 /* */
66 /****************************************************************************/
67
68
69
70 static int DDD_CheckInterface(DDD::DDDContext& context, DDD_IF ifId)
71 {
72 using std::setw;
73
74 auto& theIF = context.ifCreateContext().theIf;
75 const auto& me = context.me();
76
77 int errors=0;
78 IF_PROC *h;
79 NOTIFY_DESC *msgs = DDD_NotifyBegin(context, theIF[ifId].nIfHeads);
80 int nRecvs, k;
81
82 /* fill NOTIFY_DESCS */
83 k=0;
84 ForIF(context, ifId, h)
85 {
86 msgs[k].proc = h->proc;
87 msgs[k].size = h->nItems;
88 k++;
89 }
90
91 nRecvs = DDD_Notify(context);
92 if (nRecvs==ERROR)
93 {
94 Dune::dwarn << "Notify failed on proc " << me << "\n";
95 errors++;
96 }
97 else
98 {
99 if (nRecvs!=theIF[ifId].nIfHeads)
100 {
101 Dune::dwarn
102 << ERRSTR "IF " << setw(2) << ifId << "not symmetric on proc "
103 << me << " (" << nRecvs << " != " << theIF[ifId].nIfHeads << ")\n";
104 errors++;
105 }
106
107 ForIF(context, ifId, h)
108 {
109 for(k=0; k<nRecvs; k++)
110 {
111 if (msgs[k].proc==h->proc)
112 {
113 if (msgs[k].size!=h->nItems)
114 {
115 Dune::dwarn
116 << ERRSTR "IF " << setw(2) << ifId << " proc " << me << "->"
117 << msgs[k].proc << " has non-symmetric items (" << h->nItems
118 << " != " << msgs[k].size << ")\n";
119 errors++;
120 }
121 }
122 }
123 }
124 }
125
126 DDD_NotifyEnd(context);
127 return(errors);
128 }
129
130
131 /****************************************************************************/
132
133
134 int DDD_CheckInterfaces(DDD::DDDContext& context)
135 {
136 const auto& nIFs = context.ifCreateContext().nIfs;
137
138 int errors = 0;
139 for(int i = 0; i < nIFs; ++i)
140 {
141 errors += DDD_CheckInterface(context, i);
142 }
143
144 return(errors);
145 }
146
147 /****************************************************************************/
148
149 END_UGDIM_NAMESPACE