p4est 2.8.7.456-de8c6
p4est is a software library for parallel adaptive mesh refinement.
Loading...
Searching...
No Matches
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
35SC_EXTERN_C_BEGIN;
36
43extern const int p8est_lnodes_corner_hanging[8];
44
46typedef int16_t p8est_lnodes_code_t;
47
148
160typedef 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
226inline int
227p8est_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
277void
279 p8est_lnodes_code_t fcs[8]);
280
293 p8est_ghost_t * ghost_layer,
294 int degree);
295
301
307
319 p8est_ghost_t * ghost, int degree,
320 int partition_for_coarsening);
321
326 p8est_ghost_t * ghost,
327 int nodes_per_volume,
328 int nodes_per_face,
329 int nodes_per_edge,
330 int nodes_per_corner,
331 int
332 partition_for_coarsening);
333
343 p8est_lnodes_t * lnodes,
344 p8est_ghost_t * ghost);
345
355 p8est_lnodes_t * lnodes,
356 p8est_ghost_t * ghost);
357
373{
374 sc_array_t *requests; /* sc_MPI_Request */
375 sc_array_t *send_buffers;
376 sc_array_t *recv_buffers;
377}
379
398 lnodes);
399
405 buffer);
406
411void p8est_lnodes_share_owned (sc_array_t * node_data,
412 p8est_lnodes_t * lnodes);
413
431 p8est_lnodes_t * lnodes);
437 buffer);
438
447 p8est_lnodes_t * lnodes);
448
452 buffer);
453
456inline p8est_lnodes_rank_t *
457p8est_lnodes_rank_array_index_int (sc_array_t * array, int it)
458{
459 P4EST_ASSERT (array->elem_size == sizeof (p8est_lnodes_rank_t));
460 P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
461
462 return (p8est_lnodes_rank_t *)
463 (array->array + sizeof (p8est_lnodes_rank_t) * (size_t) it);
464}
465
468inline p8est_lnodes_rank_t *
469p8est_lnodes_rank_array_index (sc_array_t * array, size_t it)
470{
471 P4EST_ASSERT (array->elem_size == sizeof (p8est_lnodes_rank_t));
472 P4EST_ASSERT (it < array->elem_count);
473
474 return (p8est_lnodes_rank_t *)
475 (array->array + sizeof (p8est_lnodes_rank_t) * it);
476}
477
479inline p4est_gloidx_t
481{
482 p4est_locidx_t owned = lnodes->owned_count;
483 P4EST_ASSERT (lidx >= 0 && lidx < lnodes->num_local_nodes);
484
485 return (lidx < owned) ? lnodes->global_offset + lidx :
486 lnodes->nonlocal_nodes[lidx - owned];
487}
488
489SC_EXTERN_C_END;
490
491#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.
void p8est_lnodes_derive_child_codes(int pc, p8est_lnodes_code_t pfc, p8est_lnodes_code_t fcs[8])
Given a quadrant and its face code, derive children's face codes.
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_lnodes_share_all_end(p8est_lnodes_buffer_t *buffer)
p8est_lnodes_shared_all_end
p8est_lnodes_rank_t * p8est_lnodes_rank_array_index_int(sc_array_t *array, int it)
Return a pointer to a lnodes_rank array element indexed by a int.
Definition p8est_lnodes.h:457
p8est_lnodes_buffer_t * p8est_lnodes_share_owned_begin(sc_array_t *node_data, p8est_lnodes_t *lnodes)
p8est_lnodes_share_owned_begin
int p8est_lnodes_decode(p8est_lnodes_code_t face_code, int hanging_face[6], int hanging_edge[12])
Decode the face_code into hanging face information.
Definition p8est_lnodes.h:227
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.
size_t p8est_lnodes_memory_used(p8est_lnodes_t *lnodes)
Calculate the memory allocated in a p8est_lnodes structure.
struct p8est_lnodes_rank p8est_lnodes_rank_t
The structure stored in the sharers array.
void p8est_lnodes_buffer_destroy(p8est_lnodes_buffer_t *buffer)
Destroy the buffer filled with node data during a call to p8est_lnodes_share_all_end or p8est_lnodes_...
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.
void p8est_lnodes_share_owned_end(p8est_lnodes_buffer_t *buffer)
p8est_lnodes_shared_owned_end
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_all_begin(sc_array_t *node_data, p8est_lnodes_t *lnodes)
p8est_lnodes_share_all_begin
p4est_gloidx_t p8est_lnodes_global_index(p8est_lnodes_t *lnodes, p4est_locidx_t lidx)
Compute the global number of a local node number.
Definition p8est_lnodes.h:480
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...
p8est_lnodes_buffer_t * p8est_lnodes_share_all(sc_array_t *node_data, p8est_lnodes_t *lnodes)
Equivalent to calling p8est_lnodes_share_all_end directly after p8est_lnodes_share_all_begin.
p8est_lnodes_rank_t * p8est_lnodes_rank_array_index(sc_array_t *array, size_t it)
Return a pointer to a lnodes_rank array element indexed by a size_t.
Definition p8est_lnodes.h:469
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.
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:373
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