p4est  2.8.7
p4est is a software library for parallel adaptive mesh refinement.
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
p8est_lnodes.h
Go to the documentation of this file.
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 
30 #ifndef P8EST_LNODES_H
31 #define P8EST_LNODES_H
32 
33 #include <p8est_ghost.h>
34 
35 SC_EXTERN_C_BEGIN;
36 
43 extern const int p8est_lnodes_corner_hanging[8];
44 
46 typedef int16_t p8est_lnodes_code_t;
47 
126 typedef struct p8est_lnodes
127 {
128  sc_MPI_Comm mpicomm;
133  sc_array_t *sharers;
138  int degree;
141  int vnodes;
146 }
148 
160 typedef struct p8est_lnodes_rank
161 {
162  int rank;
163  sc_array_t shared_nodes;
164  p4est_locidx_t shared_mine_offset, shared_mine_count;
165  p4est_locidx_t owned_offset, owned_count;
166 }
168 
226 static inline int
227 p8est_lnodes_decode (p8est_lnodes_code_t face_code, int hanging_face[6],
228  int hanging_edge[12])
229 {
230  P4EST_ASSERT (face_code >= 0);
231 
232  if (face_code) {
233  int i, j;
234  int16_t c = face_code & 0x0007;
235  int16_t cwork;
236  int f;
237  int e;
238  int16_t work = face_code >> 3;
239 
240  memset (hanging_face, -1, 6 * sizeof (int));
241  memset (hanging_edge, -1, 12 * sizeof (int));
242 
243  cwork = c;
244  for (i = 0; i < 3; ++i) {
245  if (work & 0x0001) {
246  f = p8est_corner_faces[c][i];
247  hanging_face[f] = p8est_corner_face_corners[c][f];
248  for (j = 0; j < 4; j++) {
249  e = p8est_face_edges[f][j];
250  hanging_edge[e] = 4;
251  }
252  }
253  work >>= 1;
254  }
255  for (i = 0; i < 3; ++i) {
256  if (work & 0x0001) {
257  e = p8est_corner_edges[c][i];
258  hanging_edge[e] = (hanging_edge[e] == -1) ? 0 : 2;
259  hanging_edge[e] += (int) (cwork & 0x0001);
260  }
261  cwork >>= 1;
262  work >>= 1;
263  }
264  return 1;
265  }
266  else {
267  return 0;
268  }
269 }
270 
283  p8est_ghost_t * ghost_layer,
284  int degree);
285 
291 
303  p8est_ghost_t * ghost, int degree,
304  int partition_for_coarsening);
305 
310  p8est_ghost_t * ghost,
311  int nodes_per_volume,
312  int nodes_per_face,
313  int nodes_per_edge,
314  int nodes_per_corner,
315  int
316  partition_for_coarsening);
317 
327  p8est_lnodes_t * lnodes,
328  p8est_ghost_t * ghost);
329 
339  p8est_lnodes_t * lnodes,
340  p8est_ghost_t * ghost);
341 
356 typedef struct p8est_lnodes_buffer
357 {
358  sc_array_t *requests; /* sc_MPI_Request */
359  sc_array_t *send_buffers;
360  sc_array_t *recv_buffers;
361 }
363 
382  lnodes);
383 
384 void p8est_lnodes_share_owned_end (p8est_lnodes_buffer_t *
385  buffer);
386 
391 void p8est_lnodes_share_owned (sc_array_t * node_data,
392  p8est_lnodes_t * lnodes);
393 
411  p8est_lnodes_t * lnodes);
412 
413 void p8est_lnodes_share_all_end (p8est_lnodes_buffer_t *
414  buffer);
415 
424  p8est_lnodes_t * lnodes);
425 
426 void p8est_lnodes_buffer_destroy (p8est_lnodes_buffer_t *
427  buffer);
428 
431 /*@unused@*/
432 static inline p8est_lnodes_rank_t *
433 p8est_lnodes_rank_array_index_int (sc_array_t * array, int it)
434 {
435  P4EST_ASSERT (array->elem_size == sizeof (p8est_lnodes_rank_t));
436  P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
437 
438  return (p8est_lnodes_rank_t *)
439  (array->array + sizeof (p8est_lnodes_rank_t) * (size_t) it);
440 }
441 
444 /*@unused@*/
445 static inline p8est_lnodes_rank_t *
446 p8est_lnodes_rank_array_index (sc_array_t * array, size_t it)
447 {
448  P4EST_ASSERT (array->elem_size == sizeof (p8est_lnodes_rank_t));
449  P4EST_ASSERT (it < array->elem_count);
450 
451  return (p8est_lnodes_rank_t *)
452  (array->array + sizeof (p8est_lnodes_rank_t) * it);
453 }
454 
456 /*@unused@*/
457 static inline p4est_gloidx_t
458 p8est_lnodes_global_index (p8est_lnodes_t * lnodes, p4est_locidx_t lidx)
459 {
460  p4est_locidx_t owned = lnodes->owned_count;
461  P4EST_ASSERT (lidx >= 0 && lidx < lnodes->num_local_nodes);
462 
463  return (lidx < owned) ? lnodes->global_offset + lidx :
464  lnodes->nonlocal_nodes[lidx - owned];
465 }
466 
467 SC_EXTERN_C_END;
468 
469 #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
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.
int16_t p8est_lnodes_code_t
The face code encodes the configuration of a hanging quadrant.
Definition: p8est_lnodes.h:46
void p8est_lnodes_share_owned(sc_array_t *node_data, p8est_lnodes_t *lnodes)
Equivalent to calling p8est_lnodes_share_owned_end directly after p8est_lnodes_share_owned_begin.
void p8est_lnodes_destroy(p8est_lnodes_t *lnodes)
Free all memory in a previously constructed lnodes structure.
void p8est_ghost_support_lnodes(p8est_t *p8est, p8est_lnodes_t *lnodes, p8est_ghost_t *ghost)
Expand the ghost layer to include the support of all nodes supported on the local partition.
struct p8est_lnodes_rank p8est_lnodes_rank_t
The structure stored in the sharers array.
void p8est_partition_lnodes_detailed(p8est_t *p4est, p8est_ghost_t *ghost, int nodes_per_volume, int nodes_per_face, int nodes_per_edge, int nodes_per_corner, int partition_for_coarsening)
Partition using weights that are broken down by where they reside: in volumes, on faces,...
struct p8est_lnodes_buffer p8est_lnodes_buffer_t
p8est_lnodes_buffer_t handles the communication of data associated with nodes.
p8est_lnodes_buffer_t * p8est_lnodes_share_all_begin(sc_array_t *node_data, p8est_lnodes_t *lnodes)
p8est_lnodes_share_all_begin
p8est_lnodes_buffer_t * p8est_lnodes_share_all(sc_array_t *node_data, p8est_lnodes_t *lnodes)
Equivalend to calling p8est_lnodes_share_all_end directly after p8est_lnodes_share_all_begin.
void p8est_ghost_expand_by_lnodes(p8est_t *p8est, p8est_lnodes_t *lnodes, p8est_ghost_t *ghost)
Expand the ghost layer as in p8est_ghost_expand(), but use node support to define adjacency instead o...
struct p8est_lnodes p8est_lnodes_t
Store a parallel numbering of Lobatto points of a given degree > 0.
const int p8est_lnodes_corner_hanging[8]
For each corner, the direction of the hanging face/edge.
void p8est_partition_lnodes(p8est_t *p8est, p8est_ghost_t *ghost, int degree, int partition_for_coarsening)
Partition using weights based on the number of nodes assigned to each element in lnodes.
p8est_lnodes_t * p8est_lnodes_new(p8est_t *p8est, p8est_ghost_t *ghost_layer, int degree)
Create a tensor-product Lobatto node structure for a given degree.
p8est_lnodes_buffer_t * p8est_lnodes_share_owned_begin(sc_array_t *node_data, p8est_lnodes_t *lnodes)
p8est_lnodes_share_owned_begin
The p4est forest datatype.
Definition: p4est.h:150
Quadrants that neighbor the local domain.
Definition: p8est_ghost.h:46
p8est_lnodes_buffer_t handles the communication of data associated with nodes.
Definition: p8est_lnodes.h:357
The structure stored in the sharers array.
Definition: p8est_lnodes.h:161
Store a parallel numbering of Lobatto points of a given degree > 0.
Definition: p8est_lnodes.h:127
p4est_locidx_t * element_nodes
Flat list: element_nodes * vnodes.
Definition: p8est_lnodes.h:145
p4est_gloidx_t global_offset
Global number of first local node.
Definition: p8est_lnodes.h:131
p4est_locidx_t owned_count
Number of owned nodes of process.
Definition: p8est_lnodes.h:130
int vnodes
Number of nodes of each element.
Definition: p8est_lnodes.h:141
sc_array_t * sharers
Encoding of sharer processes' nodes.
Definition: p8est_lnodes.h:133
p4est_locidx_t num_local_nodes
Number of nodes known to process.
Definition: p8est_lnodes.h:129
int degree
Degree used in construction.
Definition: p8est_lnodes.h:138
sc_MPI_Comm mpicomm
Valid MPI communicator.
Definition: p8est_lnodes.h:128
p4est_locidx_t * global_owned_count
For each rank: owned count.
Definition: p8est_lnodes.h:136
p4est_locidx_t num_local_elements
Elements local to process.
Definition: p8est_lnodes.h:142
p4est_gloidx_t * nonlocal_nodes
For nonlocal nodes: global number.
Definition: p8est_lnodes.h:132
p8est_lnodes_code_t * face_code
One entry per local element encoding its hanging situation.
Definition: p8est_lnodes.h:143
The p8est forest datatype.
Definition: p8est.h:146