p4est  1.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
p4est_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 P4EST_LNODES_H
25 #define P4EST_LNODES_H
26 
27 #include <p4est.h>
28 #include <p4est_ghost.h>
29 
30 SC_EXTERN_C_BEGIN;
31 
32 typedef int8_t p4est_lnodes_code_t;
33 
131 typedef struct p4est_lnodes
132 {
133  sc_MPI_Comm mpicomm;
134  p4est_locidx_t num_local_nodes;
135  p4est_locidx_t owned_count;
136  p4est_gloidx_t global_offset;
137  p4est_gloidx_t *nonlocal_nodes;
138  sc_array_t *sharers;
139  p4est_locidx_t *global_owned_count;
140 
141  int degree, vnodes;
142  p4est_locidx_t num_local_elements;
143  p4est_lnodes_code_t *face_code;
144  p4est_locidx_t *element_nodes;
145 }
147 
159 typedef struct p4est_lnodes_rank
160 {
161  int rank;
162  sc_array_t shared_nodes;
163  p4est_locidx_t shared_mine_offset, shared_mine_count;
164  p4est_locidx_t owned_offset, owned_count;
165 }
167 
181 /*@unused@*/
182 static inline int
183 p4est_lnodes_decode (p4est_lnodes_code_t face_code, int hanging_face[4])
184 {
185  P4EST_ASSERT (face_code >= 0);
186 
187  if (face_code) {
188  int i;
189  int8_t c = face_code & 0x03;
190  int f;
191  int8_t work = face_code >> 2;
192 
193  memset (hanging_face, -1, 4 * sizeof (int));
194 
195  for (i = 0; i < 2; ++i) {
196  f = p4est_corner_faces[c][i];
197  hanging_face[f] = (work & 0x01) ? p4est_corner_face_corners[c][f] : -1;
198  work >>= 1;
199  }
200 
201  return 1;
202  }
203  else {
204  return 0;
205  }
206 }
207 
208 p4est_lnodes_t *p4est_lnodes_new (p4est_t * p4est,
209  p4est_ghost_t * ghost_layer,
210  int degree);
211 
212 void p4est_lnodes_destroy (p4est_lnodes_t * lnodes);
213 
222 void p4est_ghost_support_lnodes (p4est_t * p4est,
223  p4est_lnodes_t * lnodes,
224  p4est_ghost_t * ghost);
225 
234 void p4est_ghost_expand_by_lnodes (p4est_t * p4est,
235  p4est_lnodes_t * lnodes,
236  p4est_ghost_t * ghost);
237 
252 typedef struct p4est_lnodes_buffer
253 {
254  sc_array_t *requests; /* sc_MPI_Request */
255  sc_array_t *send_buffers;
256  sc_array_t *recv_buffers;
257 }
259 
276 p4est_lnodes_buffer_t *p4est_lnodes_share_owned_begin (sc_array_t * node_data,
278  lnodes);
279 
280 void p4est_lnodes_share_owned_end (p4est_lnodes_buffer_t *
281  buffer);
282 
287 void p4est_lnodes_share_owned (sc_array_t * node_data,
288  p4est_lnodes_t * lnodes);
289 
306 p4est_lnodes_buffer_t *p4est_lnodes_share_all_begin (sc_array_t * node_data,
307  p4est_lnodes_t * lnodes);
308 
309 void p4est_lnodes_share_all_end (p4est_lnodes_buffer_t *
310  buffer);
311 
319 p4est_lnodes_buffer_t *p4est_lnodes_share_all (sc_array_t * node_data,
320  p4est_lnodes_t * lnodes);
321 
322 void p4est_lnodes_buffer_destroy (p4est_lnodes_buffer_t *
323  buffer);
324 
327 /*@unused@*/
328 static inline p4est_lnodes_rank_t *
329 p4est_lnodes_rank_array_index_int (sc_array_t * array, int it)
330 {
331  P4EST_ASSERT (array->elem_size == sizeof (p4est_lnodes_rank_t));
332  P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
333 
334  return (p4est_lnodes_rank_t *)
335  (array->array + sizeof (p4est_lnodes_rank_t) * it);
336 }
337 
340 /*@unused@*/
341 static inline p4est_lnodes_rank_t *
342 p4est_lnodes_rank_array_index (sc_array_t * array, size_t it)
343 {
344  P4EST_ASSERT (array->elem_size == sizeof (p4est_lnodes_rank_t));
345  P4EST_ASSERT (it < array->elem_count);
346 
347  return (p4est_lnodes_rank_t *)
348  (array->array + sizeof (p4est_lnodes_rank_t) * it);
349 }
350 
352 /*@unused@*/
353 static inline p4est_gloidx_t
354 p4est_lnodes_global_index (p4est_lnodes_t * lnodes, p4est_locidx_t lidx)
355 {
356  p4est_locidx_t owned = lnodes->owned_count;
357  P4EST_ASSERT (lidx >= 0 && lidx < lnodes->num_local_nodes);
358 
359  return (lidx < owned) ? lnodes->global_offset + lidx :
360  lnodes->nonlocal_nodes[lidx - owned];
361 }
362 
363 SC_EXTERN_C_END;
364 
365 #endif /* !P4EST_LNODES */
quadrants that neighbor the local domain
Definition: p4est_ghost.h:39
char * array
linear array to store elements
Definition: sc_containers.h:104
const int p4est_corner_faces[4][2]
Store the face numbers 0..3 for each tree corner.
Definition: p4est_connectivity.c:44
size_t elem_size
size of a single element
Definition: sc_containers.h:95
int64_t p4est_gloidx_t
Typedef for globally unique indexing of quadrants.
Definition: p4est_base.h:84
The p4est forest datatype.
Definition: p4est.h:129
The top-level 2D p4est interface.
const int p4est_corner_face_corners[4][4]
Store the face corner numbers for the faces touching a tree corner.
Definition: p4est_connectivity.c:49
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: p4est_lnodes.h:131
The structure stored in the sharers array.
Definition: p4est_lnodes.h:159
int32_t p4est_locidx_t
Typedef for processor-local indexing of quadrants and nodes.
Definition: p4est_base.h:74
p4est_lnodes_buffer_t handles the communication of data associated with nodes.
Definition: p4est_lnodes.h:252
passing quadrants and data to neighboring processes