Rheolef  7.1
an efficient C++ finite element environment
msg_local_context.h
Go to the documentation of this file.
1 #ifndef RHEO_MSG_LOCAL_CONTEXT_H
2 #define RHEO_MSG_LOCAL_CONTEXT_H
23 
24 # include "rheolef/msg_util.h"
25 namespace rheolef {
26 
27 /*F:
28 NAME: msg_local_context -- receive pattern (@PACKAGE@ @VERSION@)
29 DESCRIPTION:
30  Computes the receive compresed message local pattern,
31  i.e. the only part that does not requires communication.
32  (see "msg_to_context"(5)).
33 ALGORITHM:
34  msg_local_context
35 
36  "input": the index sets and the local processor index range
37  | idx(0:nidx-1), idy(0:nidx-1), istart, ilast
38  "output": the send and receive local contexts (to, from)
39  | to_loc_idx(0:n_local-1), from_loc_idy(0:n_local-1)
40  begin
41  | if n_local <> 0 then
42  | iloc := 0
43  | for k := 0 to nidx-1 do
44  | if idy(k) in (istart, ilast( then
45  | to_loc_idx(iloc) := idy(k) - istart
46  | from_loc_idy(iloc) := idy(k)
47  | iloc := iloc + 1
48  | endif
49  | endfor
50  | endif
51  end
52 
53 COMPLEXITY:
54  Memory and time complexity is O(receive_total_size).
55 SEE ALSO: "msg_to_context"(5)
56 
57 METHODS: @msg_local_context
58 AUTHORS:
59  LMC-IMAG, 38041 Grenoble cedex 9, France
60  | Pierre.Saramito@imag.fr
61 DATE: 23 march 1999
62 END:
63 */
64 
65 //<msg_local_context:
66 template <
67  class InputIterator1,
68  class InputIterator2,
69  class Size,
70  class OutputIterator1,
71  class OutputIterator2>
72 void
74  InputIterator1 idx, // nidx
75  InputIterator1 last_idx,
76  InputIterator2 idy, // nidx
77  Size idy_maxval,
78  Size istart,
79  Size ilast,
80  OutputIterator1 to_loc_idx, // n_local
81  OutputIterator1 last_to_loc_idx,
82  OutputIterator2 from_loc_idy) // n_local
83 {
84  if (to_loc_idx == last_to_loc_idx) {
85  return;
86  }
87  while (idx != last_idx) {
88  Size idx_i = *idx;
89  if (idx_i >= istart && idx_i < ilast) {
90  Size idy_i = *idy;
91  assert_macro (idy_i < idy_maxval, "Scattering past end of TO vector");
92  (*to_loc_idx++) = idx_i - istart;
93  (*from_loc_idy++) = idy_i;
94  }
95  ++idx;
96  ++idy;
97  }
98 }
99 //>msg_local_context:
100 } // namespace rheolef
101 #endif // RHEO_MSG_LOCAL_CONTEXT_H
This file is part of Rheolef.
void msg_local_context(InputIterator1 idx, InputIterator1 last_idx, InputIterator2 idy, Size idy_maxval, Size istart, Size ilast, OutputIterator1 to_loc_idx, OutputIterator1 last_to_loc_idx, OutputIterator2 from_loc_idy)