p4est  1.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
p8est_lnodes.h
1 /*
2  This file is part of p4est.
3  p4est is a C library to manage a collection (a forest) of multiple
4  connected adaptive quadtrees or octrees in parallel.
5 
6  Copyright (C) 2010 The University of Texas System
7  Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac
8 
9  p4est is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13 
14  p4est is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with p4est; if not, write to the Free Software Foundation, Inc.,
21  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 */
23 
24 #ifndef P8EST_LNODES_H
25 #define P8EST_LNODES_H
26 
27 #include <p8est.h>
28 #include <p8est_ghost.h>
29 
30 SC_EXTERN_C_BEGIN;
31 
32 typedef int16_t p8est_lnodes_code_t;
33 
111 typedef struct p8est_lnodes
112 {
113  sc_MPI_Comm mpicomm;
114  p4est_locidx_t num_local_nodes;
115  p4est_locidx_t owned_count;
116  p4est_gloidx_t global_offset;
117  p4est_gloidx_t *nonlocal_nodes;
118  sc_array_t *sharers;
119  p4est_locidx_t *global_owned_count;
120 
121  int degree, vnodes;
122  p4est_locidx_t num_local_elements;
123  p8est_lnodes_code_t *face_code;
124  p4est_locidx_t *element_nodes;
125 }
127 
139 typedef struct p8est_lnodes_rank
140 {
141  int rank;
142  sc_array_t shared_nodes;
143  p4est_locidx_t shared_mine_offset, shared_mine_count;
144  p4est_locidx_t owned_offset, owned_count;
145 }
147 
201 /*@unused@*/
202 static inline int
203 p8est_lnodes_decode (p8est_lnodes_code_t face_code, int hanging_face[6],
204  int hanging_edge[12])
205 {
206  P4EST_ASSERT (face_code >= 0);
207 
208  if (face_code) {
209  int i, j;
210  int16_t c = face_code & 0x0007;
211  int16_t cwork;
212  int f;
213  int e;
214  int16_t work = face_code >> 3;
215 
216  memset (hanging_face, -1, 6 * sizeof (int));
217  memset (hanging_edge, -1, 12 * sizeof (int));
218 
219  cwork = c;
220  for (i = 0; i < 3; ++i) {
221  if (work & 0x0001) {
222  f = p8est_corner_faces[c][i];
223  hanging_face[f] = p8est_corner_face_corners[c][f];
224  for (j = 0; j < 4; j++) {
225  e = p8est_face_edges[f][j];
226  hanging_edge[e] = 4;
227  }
228  }
229  work >>= 1;
230  }
231  for (i = 0; i < 3; ++i) {
232  if (work & 0x0001) {
233  e = p8est_corner_edges[c][i];
234  hanging_edge[e] = (hanging_edge[e] == -1) ? 0 : 2;
235  hanging_edge[e] += (int) (cwork & 0x0001);
236  }
237  cwork >>= 1;
238  work >>= 1;
239  }
240  return 1;
241  }
242  else {
243  return 0;
244  }
245 }
246 
247 p8est_lnodes_t *p8est_lnodes_new (p8est_t * p8est,
248  p8est_ghost_t * ghost_layer,
249  int degree);
250 
251 void p8est_lnodes_destroy (p8est_lnodes_t *);
252 
261 void p8est_ghost_support_lnodes (p8est_t * p8est,
262  p8est_lnodes_t * lnodes,
263  p8est_ghost_t * ghost);
264 
273 void p8est_ghost_expand_by_lnodes (p8est_t * p4est,
274  p8est_lnodes_t * lnodes,
275  p8est_ghost_t * ghost);
276 
291 typedef struct p8est_lnodes_buffer
292 {
293  sc_array_t *requests; /* sc_MPI_Request */
294  sc_array_t *send_buffers;
295  sc_array_t *recv_buffers;
296 }
298 
315 p8est_lnodes_buffer_t *p8est_lnodes_share_owned_begin (sc_array_t * node_data,
317  lnodes);
318 
319 void p8est_lnodes_share_owned_end (p8est_lnodes_buffer_t *
320  buffer);
321 
326 void p8est_lnodes_share_owned (sc_array_t * node_data,
327  p8est_lnodes_t * lnodes);
328 
345 p8est_lnodes_buffer_t *p8est_lnodes_share_all_begin (sc_array_t * node_data,
346  p8est_lnodes_t * lnodes);
347 
348 void p8est_lnodes_share_all_end (p8est_lnodes_buffer_t *
349  buffer);
350 
358 p8est_lnodes_buffer_t *p8est_lnodes_share_all (sc_array_t * node_data,
359  p8est_lnodes_t * lnodes);
360 
361 void p8est_lnodes_buffer_destroy (p8est_lnodes_buffer_t *
362  buffer);
363 
366 /*@unused@*/
367 static inline p8est_lnodes_rank_t *
368 p8est_lnodes_rank_array_index_int (sc_array_t * array, int it)
369 {
370  P4EST_ASSERT (array->elem_size == sizeof (p8est_lnodes_rank_t));
371  P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
372 
373  return (p8est_lnodes_rank_t *)
374  (array->array + sizeof (p8est_lnodes_rank_t) * it);
375 }
376 
379 /*@unused@*/
380 static inline p8est_lnodes_rank_t *
381 p8est_lnodes_rank_array_index (sc_array_t * array, size_t it)
382 {
383  P4EST_ASSERT (array->elem_size == sizeof (p8est_lnodes_rank_t));
384  P4EST_ASSERT (it < array->elem_count);
385 
386  return (p8est_lnodes_rank_t *)
387  (array->array + sizeof (p8est_lnodes_rank_t) * it);
388 }
389 
391 /*@unused@*/
392 static inline p4est_gloidx_t
393 p8est_lnodes_global_index (p8est_lnodes_t * lnodes, p4est_locidx_t lidx)
394 {
395  p4est_locidx_t owned = lnodes->owned_count;
396  P4EST_ASSERT (lidx >= 0 && lidx < lnodes->num_local_nodes);
397 
398  return (lidx < owned) ? lnodes->global_offset + lidx :
399  lnodes->nonlocal_nodes[lidx - owned];
400 }
401 
402 SC_EXTERN_C_END;
403 
404 #endif /* !P8EST_LNODES */
passing quadrants and data to neighboring processes
const int p8est_face_edges[6][4]
Store the face numbers 0..12 for each tree face.
Definition: p8est_connectivity.c:36
char * array
linear array to store elements
Definition: sc_containers.h:104
size_t elem_size
size of a single element
Definition: sc_containers.h:95
quadrants that neighbor the local domain
Definition: p8est_ghost.h:39
The top-level 3D p8est interface.
const int p8est_corner_edges[8][3]
Store the edge numbers 0..11 for each tree corner.
Definition: p8est_connectivity.c:114
int64_t p4est_gloidx_t
Typedef for globally unique indexing of quadrants.
Definition: p4est_base.h:84
const int p8est_corner_faces[8][3]
Store the face numbers 0..5 for each tree corner.
Definition: p8est_connectivity.c:105
The p8est forest datatype.
Definition: p8est.h:125
const int p8est_corner_face_corners[8][6]
Store the face corner numbers for the faces touching a tree corner.
Definition: p8est_connectivity.c:123
The sc_array object provides a large array of equal-size elements.
Definition: sc_containers.h:92
Store a parallel numbering of Lobatto points of a given degree > 0.
Definition: p8est_lnodes.h:111
p8est_lnodes_buffer_t handles the communication of data associated with nodes.
Definition: p8est_lnodes.h:291
The structure stored in the sharers array.
Definition: p8est_lnodes.h:139
int32_t p4est_locidx_t
Typedef for processor-local indexing of quadrants and nodes.
Definition: p4est_base.h:74