p4est  2.8.643-dbc7-dirty
p4est is a software library for parallel adaptive mesh refinement.
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  Additional copyright (C) 2011 individual authors
8  Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac
9 
10  p4est is free software; you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation; either version 2 of the License, or
13  (at your option) any later version.
14 
15  p4est is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with p4est; if not, write to the Free Software Foundation, Inc.,
22  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 */
24 
25 #ifndef P8EST_LNODES_H
26 #define P8EST_LNODES_H
27 
28 #include <p8est.h>
29 #include <p8est_ghost.h>
30 
31 SC_EXTERN_C_BEGIN;
32 
33 typedef int16_t p8est_lnodes_code_t;
34 
112 typedef struct p8est_lnodes
113 {
114  sc_MPI_Comm mpicomm;
115  p4est_locidx_t num_local_nodes;
116  p4est_locidx_t owned_count;
117  p4est_gloidx_t global_offset;
118  p4est_gloidx_t *nonlocal_nodes;
119  sc_array_t *sharers;
120  p4est_locidx_t *global_owned_count;
121 
122  int degree, vnodes;
123  p4est_locidx_t num_local_elements;
124  p8est_lnodes_code_t *face_code;
125  p4est_locidx_t *element_nodes;
126 }
128 
140 typedef struct p8est_lnodes_rank
141 {
142  int rank;
143  sc_array_t shared_nodes;
144  p4est_locidx_t shared_mine_offset, shared_mine_count;
145  p4est_locidx_t owned_offset, owned_count;
146 }
148 
202 /*@unused@*/
203 static inline int
204 p8est_lnodes_decode (p8est_lnodes_code_t face_code, int hanging_face[6],
205  int hanging_edge[12])
206 {
207  P4EST_ASSERT (face_code >= 0);
208 
209  if (face_code) {
210  int i, j;
211  int16_t c = face_code & 0x0007;
212  int16_t cwork;
213  int f;
214  int e;
215  int16_t work = face_code >> 3;
216 
217  memset (hanging_face, -1, 6 * sizeof (int));
218  memset (hanging_edge, -1, 12 * sizeof (int));
219 
220  cwork = c;
221  for (i = 0; i < 3; ++i) {
222  if (work & 0x0001) {
223  f = p8est_corner_faces[c][i];
224  hanging_face[f] = p8est_corner_face_corners[c][f];
225  for (j = 0; j < 4; j++) {
226  e = p8est_face_edges[f][j];
227  hanging_edge[e] = 4;
228  }
229  }
230  work >>= 1;
231  }
232  for (i = 0; i < 3; ++i) {
233  if (work & 0x0001) {
234  e = p8est_corner_edges[c][i];
235  hanging_edge[e] = (hanging_edge[e] == -1) ? 0 : 2;
236  hanging_edge[e] += (int) (cwork & 0x0001);
237  }
238  cwork >>= 1;
239  work >>= 1;
240  }
241  return 1;
242  }
243  else {
244  return 0;
245  }
246 }
247 
248 p8est_lnodes_t *p8est_lnodes_new (p8est_t * p8est,
249  p8est_ghost_t * ghost_layer,
250  int degree);
251 
252 void p8est_lnodes_destroy (p8est_lnodes_t * lnodes);
253 
264 void p8est_partition_lnodes (p8est_t * p8est,
265  p8est_ghost_t * ghost, int degree,
266  int partition_for_coarsening);
267 
271 void p8est_partition_lnodes_detailed (p8est_t * p4est,
272  p8est_ghost_t * ghost,
273  int nodes_per_volume,
274  int nodes_per_face,
275  int nodes_per_edge,
276  int nodes_per_corner,
277  int
278  partition_for_coarsening);
279 
288 void p8est_ghost_support_lnodes (p8est_t * p8est,
289  p8est_lnodes_t * lnodes,
290  p8est_ghost_t * ghost);
291 
300 void p8est_ghost_expand_by_lnodes (p8est_t * p4est,
301  p8est_lnodes_t * lnodes,
302  p8est_ghost_t * ghost);
303 
318 typedef struct p8est_lnodes_buffer
319 {
320  sc_array_t *requests; /* sc_MPI_Request */
321  sc_array_t *send_buffers;
322  sc_array_t *recv_buffers;
323 }
325 
342 p8est_lnodes_buffer_t *p8est_lnodes_share_owned_begin (sc_array_t * node_data,
344  lnodes);
345 
346 void p8est_lnodes_share_owned_end (p8est_lnodes_buffer_t *
347  buffer);
348 
353 void p8est_lnodes_share_owned (sc_array_t * node_data,
354  p8est_lnodes_t * lnodes);
355 
372 p8est_lnodes_buffer_t *p8est_lnodes_share_all_begin (sc_array_t * node_data,
373  p8est_lnodes_t * lnodes);
374 
375 void p8est_lnodes_share_all_end (p8est_lnodes_buffer_t *
376  buffer);
377 
385 p8est_lnodes_buffer_t *p8est_lnodes_share_all (sc_array_t * node_data,
386  p8est_lnodes_t * lnodes);
387 
388 void p8est_lnodes_buffer_destroy (p8est_lnodes_buffer_t *
389  buffer);
390 
393 /*@unused@*/
394 static inline p8est_lnodes_rank_t *
395 p8est_lnodes_rank_array_index_int (sc_array_t * array, int it)
396 {
397  P4EST_ASSERT (array->elem_size == sizeof (p8est_lnodes_rank_t));
398  P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
399 
400  return (p8est_lnodes_rank_t *)
401  (array->array + sizeof (p8est_lnodes_rank_t) * (size_t) it);
402 }
403 
406 /*@unused@*/
407 static inline p8est_lnodes_rank_t *
408 p8est_lnodes_rank_array_index (sc_array_t * array, size_t it)
409 {
410  P4EST_ASSERT (array->elem_size == sizeof (p8est_lnodes_rank_t));
411  P4EST_ASSERT (it < array->elem_count);
412 
413  return (p8est_lnodes_rank_t *)
414  (array->array + sizeof (p8est_lnodes_rank_t) * it);
415 }
416 
418 /*@unused@*/
419 static inline p4est_gloidx_t
420 p8est_lnodes_global_index (p8est_lnodes_t * lnodes, p4est_locidx_t lidx)
421 {
422  p4est_locidx_t owned = lnodes->owned_count;
423  P4EST_ASSERT (lidx >= 0 && lidx < lnodes->num_local_nodes);
424 
425  return (lidx < owned) ? lnodes->global_offset + lidx :
426  lnodes->nonlocal_nodes[lidx - owned];
427 }
428 
429 SC_EXTERN_C_END;
430 
431 #endif /* !P8EST_LNODES */
int32_t p4est_locidx_t
Typedef for processor-local indexing of quadrants and nodes.
Definition: p4est_base.h:106
int64_t p4est_gloidx_t
Typedef for globally unique indexing of quadrants.
Definition: p4est_base.h:118
The top-level 3D p8est interface.
const int p8est_corner_faces[8][3]
Store the face numbers 0..5 for each tree corner.
const int p8est_face_edges[6][4]
Store the edge numbers 0..12 for each tree face.
const int p8est_corner_face_corners[8][6]
Store the face corner numbers for the faces touching a tree corner.
const int p8est_corner_edges[8][3]
Store the edge numbers 0..11 for each tree corner.
passing quadrants and data to neighboring processes
sc3_MPI_Comm_t sc_MPI_Comm
The p4est forest datatype.
Definition: p4est.h:136
quadrants that neighbor the local domain
Definition: p8est_ghost.h:41
p8est_lnodes_buffer_t handles the communication of data associated with nodes.
Definition: p8est_lnodes.h:319
The structure stored in the sharers array.
Definition: p8est_lnodes.h:141
Store a parallel numbering of Lobatto points of a given degree > 0.
Definition: p8est_lnodes.h:113
The p8est forest datatype.
Definition: p8est.h:132
size_t elem_size
char * array