p4est 2.8.6
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_ghost.h>
29
30SC_EXTERN_C_BEGIN;
31
32typedef int16_t p8est_lnodes_code_t;
33
111typedef 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
139typedef 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@*/
202static inline int
203p8est_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
247p8est_lnodes_t *p8est_lnodes_new (p8est_t * p8est,
248 p8est_ghost_t * ghost_layer,
249 int degree);
250
251void p8est_lnodes_destroy (p8est_lnodes_t * lnodes);
252
263void p8est_partition_lnodes (p8est_t * p8est,
264 p8est_ghost_t * ghost, int degree,
265 int partition_for_coarsening);
266
270void p8est_partition_lnodes_detailed (p8est_t * p4est,
271 p8est_ghost_t * ghost,
272 int nodes_per_volume,
273 int nodes_per_face,
274 int nodes_per_edge,
275 int nodes_per_corner,
276 int
277 partition_for_coarsening);
278
287void p8est_ghost_support_lnodes (p8est_t * p8est,
288 p8est_lnodes_t * lnodes,
289 p8est_ghost_t * ghost);
290
299void p8est_ghost_expand_by_lnodes (p8est_t * p4est,
300 p8est_lnodes_t * lnodes,
301 p8est_ghost_t * ghost);
302
318{
319 sc_array_t *requests; /* sc_MPI_Request */
320 sc_array_t *send_buffers;
321 sc_array_t *recv_buffers;
322}
324
341p8est_lnodes_buffer_t *p8est_lnodes_share_owned_begin (sc_array_t * node_data,
343 lnodes);
344
345void p8est_lnodes_share_owned_end (p8est_lnodes_buffer_t *
346 buffer);
347
352void p8est_lnodes_share_owned (sc_array_t * node_data,
353 p8est_lnodes_t * lnodes);
354
371p8est_lnodes_buffer_t *p8est_lnodes_share_all_begin (sc_array_t * node_data,
372 p8est_lnodes_t * lnodes);
373
374void p8est_lnodes_share_all_end (p8est_lnodes_buffer_t *
375 buffer);
376
384p8est_lnodes_buffer_t *p8est_lnodes_share_all (sc_array_t * node_data,
385 p8est_lnodes_t * lnodes);
386
387void p8est_lnodes_buffer_destroy (p8est_lnodes_buffer_t *
388 buffer);
389
392/*@unused@*/
393static inline p8est_lnodes_rank_t *
394p8est_lnodes_rank_array_index_int (sc_array_t * array, int it)
395{
396 P4EST_ASSERT (array->elem_size == sizeof (p8est_lnodes_rank_t));
397 P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
398
399 return (p8est_lnodes_rank_t *)
400 (array->array + sizeof (p8est_lnodes_rank_t) * (size_t) it);
401}
402
405/*@unused@*/
406static inline p8est_lnodes_rank_t *
407p8est_lnodes_rank_array_index (sc_array_t * array, size_t it)
408{
409 P4EST_ASSERT (array->elem_size == sizeof (p8est_lnodes_rank_t));
410 P4EST_ASSERT (it < array->elem_count);
411
412 return (p8est_lnodes_rank_t *)
413 (array->array + sizeof (p8est_lnodes_rank_t) * it);
414}
415
417/*@unused@*/
418static inline p4est_gloidx_t
419p8est_lnodes_global_index (p8est_lnodes_t * lnodes, p4est_locidx_t lidx)
420{
421 p4est_locidx_t owned = lnodes->owned_count;
422 P4EST_ASSERT (lidx >= 0 && lidx < lnodes->num_local_nodes);
423
424 return (lidx < owned) ? lnodes->global_offset + lidx :
425 lnodes->nonlocal_nodes[lidx - owned];
426}
427
428SC_EXTERN_C_END;
429
430#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
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:318
The structure stored in the sharers array.
Definition: p8est_lnodes.h:140
Store a parallel numbering of Lobatto points of a given degree > 0.
Definition: p8est_lnodes.h:112
The p8est forest datatype.
Definition: p8est.h:132