p4est 2.8.8
p4est is a software library for parallel adaptive mesh refinement.
Loading...
Searching...
No Matches
p4est_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 P4EST_LNODES_H
31#define P4EST_LNODES_H
32
33#include <p4est_ghost.h>
34
35SC_EXTERN_C_BEGIN;
36
41extern const int p4est_lnodes_corner_hanging[4];
42
44typedef int8_t p4est_lnodes_code_t;
45
166
178typedef struct p4est_lnodes_rank
179{
180 int rank;
181 sc_array_t shared_nodes;
182 p4est_locidx_t shared_mine_offset, shared_mine_count;
183 p4est_locidx_t owned_offset, owned_count;
184}
186
200inline int
201p4est_lnodes_decode (p4est_lnodes_code_t face_code, int hanging_face[4])
202{
203 P4EST_ASSERT (face_code >= 0);
204
205 if (face_code) {
206 int i;
207 int8_t c = face_code & 0x03;
208 int f;
209 int8_t work = face_code >> 2;
210
211 memset (hanging_face, -1, 4 * sizeof (int));
212
213 for (i = 0; i < 2; ++i) {
214 f = p4est_corner_faces[c][i];
215 hanging_face[f] = (work & 0x01) ? p4est_corner_face_corners[c][f] : -1;
216 work >>= 1;
217 }
218
219 return 1;
220 }
221 else {
222 return 0;
223 }
224}
225
232void
233p4est_lnodes_derive_child_codes (int pc, p4est_lnodes_code_t pfc,
234 p4est_lnodes_code_t fcs[4]);
235
247p4est_lnodes_t *p4est_lnodes_new (p4est_t * p4est,
248 p4est_ghost_t * ghost_layer,
249 int degree);
250
255size_t p4est_lnodes_memory_used (p4est_lnodes_t *lnodes);
256
261void p4est_lnodes_destroy (p4est_lnodes_t * lnodes);
262
271void p4est_ghost_support_lnodes (p4est_t * p4est,
272 p4est_lnodes_t * lnodes,
273 p4est_ghost_t * ghost);
274
283void p4est_ghost_expand_by_lnodes (p4est_t * p4est,
284 p4est_lnodes_t * lnodes,
285 p4est_ghost_t * ghost);
286
297void p4est_partition_lnodes (p4est_t * p4est,
298 p4est_ghost_t * ghost, int degree,
299 int partition_for_coarsening);
300
304void p4est_partition_lnodes_detailed (p4est_t * p4est,
305 p4est_ghost_t * ghost,
306 int nodes_per_volume,
307 int nodes_per_face,
308 int nodes_per_corner,
309 int
310 partition_for_coarsening);
311
327{
328 sc_array_t *requests; /* sc_MPI_Request */
329 sc_array_t *send_buffers;
330 sc_array_t *recv_buffers;
331}
333
350p4est_lnodes_buffer_t *p4est_lnodes_share_owned_begin (sc_array_t * node_data,
352 lnodes);
353
358void p4est_lnodes_share_owned_end (p4est_lnodes_buffer_t *
359 buffer);
360
365void p4est_lnodes_share_owned (sc_array_t * node_data,
366 p4est_lnodes_t * lnodes);
367
384p4est_lnodes_buffer_t *p4est_lnodes_share_all_begin (sc_array_t * node_data,
385 p4est_lnodes_t * lnodes);
386
391void p4est_lnodes_share_all_end (p4est_lnodes_buffer_t *
392 buffer);
393
401p4est_lnodes_buffer_t *p4est_lnodes_share_all (sc_array_t * node_data,
402 p4est_lnodes_t * lnodes);
403
406void p4est_lnodes_buffer_destroy (p4est_lnodes_buffer_t *
407 buffer);
408
411inline p4est_lnodes_rank_t *
412p4est_lnodes_rank_array_index_int (sc_array_t *array, int it)
413{
414 P4EST_ASSERT (array->elem_size == sizeof (p4est_lnodes_rank_t));
415 P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
416
417 return (p4est_lnodes_rank_t *)
418 (array->array + sizeof (p4est_lnodes_rank_t) * (size_t) it);
419}
420
423inline p4est_lnodes_rank_t *
424p4est_lnodes_rank_array_index (sc_array_t *array, size_t it)
425{
426 P4EST_ASSERT (array->elem_size == sizeof (p4est_lnodes_rank_t));
427 P4EST_ASSERT (it < array->elem_count);
428
429 return (p4est_lnodes_rank_t *)
430 (array->array + sizeof (p4est_lnodes_rank_t) * it);
431}
432
434inline p4est_gloidx_t
435p4est_lnodes_global_index (p4est_lnodes_t *lnodes, p4est_locidx_t lidx)
436{
437 p4est_locidx_t owned = lnodes->owned_count;
438 P4EST_ASSERT (lidx >= 0 && lidx < lnodes->num_local_nodes);
439
440 return (lidx < owned) ? lnodes->global_offset + lidx :
441 lnodes->nonlocal_nodes[lidx - owned];
442}
443
444SC_EXTERN_C_END;
445
446#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
Passing quadrants and data to neighboring processes.
struct p4est_lnodes_rank p4est_lnodes_rank_t
The structure stored in the sharers array.
struct p4est_lnodes p4est_lnodes_t
Store a parallel numbering of Lobatto points of a given degree > 0.
struct p4est_lnodes_buffer p4est_lnodes_buffer_t
p4est_lnodes_buffer_t handles the communication of data associated with nodes.
const int p4est_lnodes_corner_hanging[4]
For each corner, the normal direction of the hanging face.
int8_t p4est_lnodes_code_t
The face code encodes the configuration of a hanging quadrant.
Definition p4est_lnodes.h:44
Quadrants that neighbor the local domain.
Definition p4est_ghost.h:46
p4est_lnodes_buffer_t handles the communication of data associated with nodes.
Definition p4est_lnodes.h:327
The structure stored in the sharers array.
Definition p4est_lnodes.h:179
Store a parallel numbering of Lobatto points of a given degree > 0.
Definition p4est_lnodes.h:145
p4est_gloidx_t * nonlocal_nodes
For nonlocal nodes: global number.
Definition p4est_lnodes.h:150
p4est_lnodes_code_t * face_code
One entry per local element encoding its hanging situation.
Definition p4est_lnodes.h:161
p4est_locidx_t * global_owned_count
For each rank: owned count.
Definition p4est_lnodes.h:154
int degree
Degree used in construction.
Definition p4est_lnodes.h:156
p4est_gloidx_t global_offset
Global number of first local node.
Definition p4est_lnodes.h:149
p4est_locidx_t owned_count
Number of owned nodes of process.
Definition p4est_lnodes.h:148
sc_MPI_Comm mpicomm
Valid MPI communicator.
Definition p4est_lnodes.h:146
p4est_locidx_t num_local_nodes
Number of nodes known to process.
Definition p4est_lnodes.h:147
p4est_locidx_t * element_nodes
Flat list: element_nodes * vnodes.
Definition p4est_lnodes.h:163
sc_array_t * sharers
Encoding of sharer processes' nodes.
Definition p4est_lnodes.h:151
int vnodes
Number of nodes of each element.
Definition p4est_lnodes.h:159
p4est_locidx_t num_local_elements
Elements local to process.
Definition p4est_lnodes.h:160
The p4est forest datatype.
Definition p4est.h:150