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
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 
35 SC_EXTERN_C_BEGIN;
36 
41 extern const int p4est_lnodes_corner_hanging[4];
42 
44 typedef int8_t p4est_lnodes_code_t;
45 
144 typedef struct p4est_lnodes
145 {
146  sc_MPI_Comm mpicomm;
151  sc_array_t *sharers;
156  int degree;
159  int vnodes;
164 }
166 
178 typedef 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 
200 static inline int
201 p4est_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 
238  p4est_ghost_t * ghost_layer,
239  int degree);
240 
246 
256  p4est_lnodes_t * lnodes,
257  p4est_ghost_t * ghost);
258 
268  p4est_lnodes_t * lnodes,
269  p4est_ghost_t * ghost);
270 
282  p4est_ghost_t * ghost, int degree,
283  int partition_for_coarsening);
284 
289  p4est_ghost_t * ghost,
290  int nodes_per_volume,
291  int nodes_per_face,
292  int nodes_per_corner,
293  int
294  partition_for_coarsening);
295 
310 typedef struct p4est_lnodes_buffer
311 {
312  sc_array_t *requests; /* sc_MPI_Request */
313  sc_array_t *send_buffers;
314  sc_array_t *recv_buffers;
315 }
317 
336  lnodes);
337 
338 void p4est_lnodes_share_owned_end (p4est_lnodes_buffer_t *
339  buffer);
340 
345 void p4est_lnodes_share_owned (sc_array_t * node_data,
346  p4est_lnodes_t * lnodes);
347 
365  p4est_lnodes_t * lnodes);
366 
367 void p4est_lnodes_share_all_end (p4est_lnodes_buffer_t *
368  buffer);
369 
378  p4est_lnodes_t * lnodes);
379 
380 void p4est_lnodes_buffer_destroy (p4est_lnodes_buffer_t *
381  buffer);
382 
385 /*@unused@*/
386 static inline p4est_lnodes_rank_t *
387 p4est_lnodes_rank_array_index_int (sc_array_t * array, int it)
388 {
389  P4EST_ASSERT (array->elem_size == sizeof (p4est_lnodes_rank_t));
390  P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
391 
392  return (p4est_lnodes_rank_t *)
393  (array->array + sizeof (p4est_lnodes_rank_t) * (size_t) it);
394 }
395 
398 /*@unused@*/
399 static inline p4est_lnodes_rank_t *
400 p4est_lnodes_rank_array_index (sc_array_t * array, size_t it)
401 {
402  P4EST_ASSERT (array->elem_size == sizeof (p4est_lnodes_rank_t));
403  P4EST_ASSERT (it < array->elem_count);
404 
405  return (p4est_lnodes_rank_t *)
406  (array->array + sizeof (p4est_lnodes_rank_t) * it);
407 }
408 
410 /*@unused@*/
411 static inline p4est_gloidx_t
412 p4est_lnodes_global_index (p4est_lnodes_t * lnodes, p4est_locidx_t lidx)
413 {
414  p4est_locidx_t owned = lnodes->owned_count;
415  P4EST_ASSERT (lidx >= 0 && lidx < lnodes->num_local_nodes);
416 
417  return (lidx < owned) ? lnodes->global_offset + lidx :
418  lnodes->nonlocal_nodes[lidx - owned];
419 }
420 
421 SC_EXTERN_C_END;
422 
423 #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.
p4est_lnodes_buffer_t * p4est_lnodes_share_all_begin(sc_array_t *node_data, p4est_lnodes_t *lnodes)
p4est_lnodes_share_all_begin
void p4est_partition_lnodes_detailed(p4est_t *p4est, p4est_ghost_t *ghost, int nodes_per_volume, int nodes_per_face, int nodes_per_corner, int partition_for_coarsening)
Partition using weights that are broken down by where they reside: in volumes, on faces,...
p4est_lnodes_buffer_t * p4est_lnodes_share_all(sc_array_t *node_data, p4est_lnodes_t *lnodes)
Equivalent to calling p4est_lnodes_share_all_end directly after p4est_lnodes_share_all_begin.
struct p4est_lnodes_rank p4est_lnodes_rank_t
The structure stored in the sharers array.
void p4est_ghost_expand_by_lnodes(p4est_t *p4est, p4est_lnodes_t *lnodes, p4est_ghost_t *ghost)
Expand the ghost layer as in p4est_ghost_expand(), but use node support to define adjacency instead o...
struct p4est_lnodes p4est_lnodes_t
Store a parallel numbering of Lobatto points of a given degree > 0.
p4est_lnodes_buffer_t * p4est_lnodes_share_owned_begin(sc_array_t *node_data, p4est_lnodes_t *lnodes)
p4est_lnodes_share_owned_begin
void p4est_lnodes_share_owned(sc_array_t *node_data, p4est_lnodes_t *lnodes)
Equivalent to calling p4est_lnodes_share_owned_end directly after p4est_lnodes_share_owned_begin.
void p4est_partition_lnodes(p4est_t *p4est, p4est_ghost_t *ghost, int degree, int partition_for_coarsening)
Partition using weights based on the number of nodes assigned to each element in lnodes.
void p4est_ghost_support_lnodes(p4est_t *p4est, p4est_lnodes_t *lnodes, p4est_ghost_t *ghost)
Expand the ghost layer to include the support of all nodes supported on the local partition.
struct p4est_lnodes_buffer p4est_lnodes_buffer_t
p4est_lnodes_buffer_t handles the communication of data associated with nodes.
void p4est_lnodes_destroy(p4est_lnodes_t *lnodes)
Free all memory in a previously constructed lnodes structure.
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
p4est_lnodes_t * p4est_lnodes_new(p4est_t *p4est, p4est_ghost_t *ghost_layer, int degree)
Create a tensor-product Lobatto node structure for a given degree.
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:311
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