p4est  2.8.643-dbc7-dirty
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.h>
29 #include <p4est_ghost.h>
30 
31 SC_EXTERN_C_BEGIN;
32 
33 typedef int8_t p4est_lnodes_code_t;
34 
132 typedef struct p4est_lnodes
133 {
134  sc_MPI_Comm mpicomm;
135  p4est_locidx_t num_local_nodes;
136  p4est_locidx_t owned_count;
137  p4est_gloidx_t global_offset;
138  p4est_gloidx_t *nonlocal_nodes;
139  sc_array_t *sharers;
140  p4est_locidx_t *global_owned_count;
141 
142  int degree, vnodes;
143  p4est_locidx_t num_local_elements;
144  p4est_lnodes_code_t *face_code;
145  p4est_locidx_t *element_nodes;
146 }
148 
160 typedef struct p4est_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 
182 /*@unused@*/
183 static inline int
184 p4est_lnodes_decode (p4est_lnodes_code_t face_code, int hanging_face[4])
185 {
186  P4EST_ASSERT (face_code >= 0);
187 
188  if (face_code) {
189  int i;
190  int8_t c = face_code & 0x03;
191  int f;
192  int8_t work = face_code >> 2;
193 
194  memset (hanging_face, -1, 4 * sizeof (int));
195 
196  for (i = 0; i < 2; ++i) {
197  f = p4est_corner_faces[c][i];
198  hanging_face[f] = (work & 0x01) ? p4est_corner_face_corners[c][f] : -1;
199  work >>= 1;
200  }
201 
202  return 1;
203  }
204  else {
205  return 0;
206  }
207 }
208 
209 p4est_lnodes_t *p4est_lnodes_new (p4est_t * p4est,
210  p4est_ghost_t * ghost_layer,
211  int degree);
212 
213 void p4est_lnodes_destroy (p4est_lnodes_t * lnodes);
214 
223 void p4est_ghost_support_lnodes (p4est_t * p4est,
224  p4est_lnodes_t * lnodes,
225  p4est_ghost_t * ghost);
226 
235 void p4est_ghost_expand_by_lnodes (p4est_t * p4est,
236  p4est_lnodes_t * lnodes,
237  p4est_ghost_t * ghost);
238 
249 void p4est_partition_lnodes (p4est_t * p4est,
250  p4est_ghost_t * ghost, int degree,
251  int partition_for_coarsening);
252 
256 void p4est_partition_lnodes_detailed (p4est_t * p4est,
257  p4est_ghost_t * ghost,
258  int nodes_per_volume,
259  int nodes_per_face,
260  int nodes_per_corner,
261  int
262  partition_for_coarsening);
263 
278 typedef struct p4est_lnodes_buffer
279 {
280  sc_array_t *requests; /* sc_MPI_Request */
281  sc_array_t *send_buffers;
282  sc_array_t *recv_buffers;
283 }
285 
302 p4est_lnodes_buffer_t *p4est_lnodes_share_owned_begin (sc_array_t * node_data,
304  lnodes);
305 
306 void p4est_lnodes_share_owned_end (p4est_lnodes_buffer_t *
307  buffer);
308 
313 void p4est_lnodes_share_owned (sc_array_t * node_data,
314  p4est_lnodes_t * lnodes);
315 
332 p4est_lnodes_buffer_t *p4est_lnodes_share_all_begin (sc_array_t * node_data,
333  p4est_lnodes_t * lnodes);
334 
335 void p4est_lnodes_share_all_end (p4est_lnodes_buffer_t *
336  buffer);
337 
345 p4est_lnodes_buffer_t *p4est_lnodes_share_all (sc_array_t * node_data,
346  p4est_lnodes_t * lnodes);
347 
348 void p4est_lnodes_buffer_destroy (p4est_lnodes_buffer_t *
349  buffer);
350 
353 /*@unused@*/
354 static inline p4est_lnodes_rank_t *
355 p4est_lnodes_rank_array_index_int (sc_array_t * array, int it)
356 {
357  P4EST_ASSERT (array->elem_size == sizeof (p4est_lnodes_rank_t));
358  P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
359 
360  return (p4est_lnodes_rank_t *)
361  (array->array + sizeof (p4est_lnodes_rank_t) * (size_t) it);
362 }
363 
366 /*@unused@*/
367 static inline p4est_lnodes_rank_t *
368 p4est_lnodes_rank_array_index (sc_array_t * array, size_t it)
369 {
370  P4EST_ASSERT (array->elem_size == sizeof (p4est_lnodes_rank_t));
371  P4EST_ASSERT (it < array->elem_count);
372 
373  return (p4est_lnodes_rank_t *)
374  (array->array + sizeof (p4est_lnodes_rank_t) * it);
375 }
376 
378 /*@unused@*/
379 static inline p4est_gloidx_t
380 p4est_lnodes_global_index (p4est_lnodes_t * lnodes, p4est_locidx_t lidx)
381 {
382  p4est_locidx_t owned = lnodes->owned_count;
383  P4EST_ASSERT (lidx >= 0 && lidx < lnodes->num_local_nodes);
384 
385  return (lidx < owned) ? lnodes->global_offset + lidx :
386  lnodes->nonlocal_nodes[lidx - owned];
387 }
388 
389 SC_EXTERN_C_END;
390 
391 #endif /* !P4EST_LNODES */
The top-level 2D p4est interface.
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
sc3_MPI_Comm_t sc_MPI_Comm
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:279
The structure stored in the sharers array.
Definition: p4est_lnodes.h:161
Store a parallel numbering of Lobatto points of a given degree > 0.
Definition: p4est_lnodes.h:133
The p4est forest datatype.
Definition: p4est.h:136
size_t elem_size
char * array