p4est 2.8.6
p4est is a software library for parallel adaptive mesh refinement.
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 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 P4EST_LNODES_H
26#define P4EST_LNODES_H
27
28#include <p4est_ghost.h>
29
30SC_EXTERN_C_BEGIN;
31
32typedef int8_t p4est_lnodes_code_t;
33
131typedef 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
159typedef 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@*/
182static inline int
183p4est_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
208p4est_lnodes_t *p4est_lnodes_new (p4est_t * p4est,
209 p4est_ghost_t * ghost_layer,
210 int degree);
211
212void p4est_lnodes_destroy (p4est_lnodes_t * lnodes);
213
222void p4est_ghost_support_lnodes (p4est_t * p4est,
223 p4est_lnodes_t * lnodes,
224 p4est_ghost_t * ghost);
225
234void p4est_ghost_expand_by_lnodes (p4est_t * p4est,
235 p4est_lnodes_t * lnodes,
236 p4est_ghost_t * ghost);
237
248void p4est_partition_lnodes (p4est_t * p4est,
249 p4est_ghost_t * ghost, int degree,
250 int partition_for_coarsening);
251
255void p4est_partition_lnodes_detailed (p4est_t * p4est,
256 p4est_ghost_t * ghost,
257 int nodes_per_volume,
258 int nodes_per_face,
259 int nodes_per_corner,
260 int
261 partition_for_coarsening);
262
278{
279 sc_array_t *requests; /* sc_MPI_Request */
280 sc_array_t *send_buffers;
281 sc_array_t *recv_buffers;
282}
284
301p4est_lnodes_buffer_t *p4est_lnodes_share_owned_begin (sc_array_t * node_data,
303 lnodes);
304
305void p4est_lnodes_share_owned_end (p4est_lnodes_buffer_t *
306 buffer);
307
312void p4est_lnodes_share_owned (sc_array_t * node_data,
313 p4est_lnodes_t * lnodes);
314
331p4est_lnodes_buffer_t *p4est_lnodes_share_all_begin (sc_array_t * node_data,
332 p4est_lnodes_t * lnodes);
333
334void p4est_lnodes_share_all_end (p4est_lnodes_buffer_t *
335 buffer);
336
344p4est_lnodes_buffer_t *p4est_lnodes_share_all (sc_array_t * node_data,
345 p4est_lnodes_t * lnodes);
346
347void p4est_lnodes_buffer_destroy (p4est_lnodes_buffer_t *
348 buffer);
349
352/*@unused@*/
353static inline p4est_lnodes_rank_t *
354p4est_lnodes_rank_array_index_int (sc_array_t * array, int it)
355{
356 P4EST_ASSERT (array->elem_size == sizeof (p4est_lnodes_rank_t));
357 P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
358
359 return (p4est_lnodes_rank_t *)
360 (array->array + sizeof (p4est_lnodes_rank_t) * (size_t) it);
361}
362
365/*@unused@*/
366static inline p4est_lnodes_rank_t *
367p4est_lnodes_rank_array_index (sc_array_t * array, size_t it)
368{
369 P4EST_ASSERT (array->elem_size == sizeof (p4est_lnodes_rank_t));
370 P4EST_ASSERT (it < array->elem_count);
371
372 return (p4est_lnodes_rank_t *)
373 (array->array + sizeof (p4est_lnodes_rank_t) * it);
374}
375
377/*@unused@*/
378static inline p4est_gloidx_t
379p4est_lnodes_global_index (p4est_lnodes_t * lnodes, p4est_locidx_t lidx)
380{
381 p4est_locidx_t owned = lnodes->owned_count;
382 P4EST_ASSERT (lidx >= 0 && lidx < lnodes->num_local_nodes);
383
384 return (lidx < owned) ? lnodes->global_offset + lidx :
385 lnodes->nonlocal_nodes[lidx - owned];
386}
387
388SC_EXTERN_C_END;
389
390#endif /* !P4EST_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 p4est_corner_faces[4][2]
Store the face numbers 0..3 for each tree corner.
const int p4est_corner_face_corners[4][4]
Store the face corner numbers for the faces touching a tree corner.
passing quadrants and data to neighboring processes
quadrants that neighbor the local domain
Definition: p4est_ghost.h:41
p4est_lnodes_buffer_t handles the communication of data associated with nodes.
Definition: p4est_lnodes.h:278
The structure stored in the sharers array.
Definition: p4est_lnodes.h:160
Store a parallel numbering of Lobatto points of a given degree > 0.
Definition: p4est_lnodes.h:132
The p4est forest datatype.
Definition: p4est.h:136