| 1 | /*BHEADER**********************************************************************
|
|---|
| 2 | * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
|
|---|
| 3 | * Produced at the Lawrence Livermore National Laboratory.
|
|---|
| 4 | * This file is part of HYPRE. See file COPYRIGHT for details.
|
|---|
| 5 | *
|
|---|
| 6 | * HYPRE is free software; you can redistribute it and/or modify it under the
|
|---|
| 7 | * terms of the GNU Lesser General Public License (as published by the Free
|
|---|
| 8 | * Software Foundation) version 2.1 dated February 1999.
|
|---|
| 9 | *
|
|---|
| 10 | * $Revision: 2.4 $
|
|---|
| 11 | ***********************************************************************EHEADER*/
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 | /******************************************************************************
|
|---|
| 16 | *
|
|---|
| 17 | *****************************************************************************/
|
|---|
| 18 |
|
|---|
| 19 | /* following should be in a header file */
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 | #include "headers.h"
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 | /*==========================================================================*/
|
|---|
| 27 | /*==========================================================================*/
|
|---|
| 28 | /**
|
|---|
| 29 | Generates global coarse_size and dof_func for next coarser level
|
|---|
| 30 |
|
|---|
| 31 | Notes:
|
|---|
| 32 | \begin{itemize}
|
|---|
| 33 | \item The routine returns the following:
|
|---|
| 34 | \begin{itemize}
|
|---|
| 35 | \item an integer array containing the
|
|---|
| 36 | function values for the local coarse points
|
|---|
| 37 | \item the global number of coarse points
|
|---|
| 38 | \end{itemize}
|
|---|
| 39 | \end{itemize}
|
|---|
| 40 |
|
|---|
| 41 | {\bf Input files:}
|
|---|
| 42 | headers.h
|
|---|
| 43 |
|
|---|
| 44 | @return Error code.
|
|---|
| 45 |
|
|---|
| 46 | @param comm [IN]
|
|---|
| 47 | MPI Communicator
|
|---|
| 48 | @param local_num_variables [IN]
|
|---|
| 49 | number of points on local processor
|
|---|
| 50 | @param dof_func [IN]
|
|---|
| 51 | array that contains the function numbers for all local points
|
|---|
| 52 | @param CF_marker [IN]
|
|---|
| 53 | marker array for coarse points
|
|---|
| 54 | @param coarse_dof_func_ptr [OUT]
|
|---|
| 55 | pointer to array which contains the function numbers for local coarse points
|
|---|
| 56 | @param coarse_pnts_global_ptr [OUT]
|
|---|
| 57 | pointer to array which contains the number of the first coarse point on each processor and the total number of coarse points in its last element
|
|---|
| 58 |
|
|---|
| 59 | @see */
|
|---|
| 60 | /*--------------------------------------------------------------------------*/
|
|---|
| 61 |
|
|---|
| 62 | int
|
|---|
| 63 | hypre_BoomerAMGCoarseParms(MPI_Comm comm,
|
|---|
| 64 | int local_num_variables,
|
|---|
| 65 | int num_functions,
|
|---|
| 66 | int *dof_func,
|
|---|
| 67 | int *CF_marker,
|
|---|
| 68 | int **coarse_dof_func_ptr,
|
|---|
| 69 | HYPRE_BigInt **coarse_pnts_global_ptr)
|
|---|
| 70 | {
|
|---|
| 71 | int i, lcs=0;
|
|---|
| 72 | int ierr = 0;
|
|---|
| 73 | int num_procs;
|
|---|
| 74 | HYPRE_BigInt local_coarse_size = 0;
|
|---|
| 75 |
|
|---|
| 76 | int *coarse_dof_func;
|
|---|
| 77 | HYPRE_BigInt *coarse_pnts_global;
|
|---|
| 78 |
|
|---|
| 79 | /*--------------------------------------------------------------
|
|---|
| 80 | *----------------------------------------------------------------*/
|
|---|
| 81 |
|
|---|
| 82 | MPI_Comm_size(comm,&num_procs);
|
|---|
| 83 |
|
|---|
| 84 | for (i=0; i < local_num_variables; i++)
|
|---|
| 85 | {
|
|---|
| 86 | if (CF_marker[i] == 1) lcs++;
|
|---|
| 87 | }
|
|---|
| 88 | if (num_functions > 1)
|
|---|
| 89 | {
|
|---|
| 90 | coarse_dof_func = hypre_CTAlloc(int,lcs);
|
|---|
| 91 |
|
|---|
| 92 | local_coarse_size = 0;
|
|---|
| 93 | for (i=0; i < local_num_variables; i++)
|
|---|
| 94 | {
|
|---|
| 95 | if (CF_marker[i] == 1)
|
|---|
| 96 | coarse_dof_func[lcs++] = dof_func[i];
|
|---|
| 97 | }
|
|---|
| 98 | *coarse_dof_func_ptr = coarse_dof_func;
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 | local_coarse_size = (HYPRE_BigInt) lcs;
|
|---|
| 102 | #ifdef HYPRE_NO_GLOBAL_PARTITION
|
|---|
| 103 | {
|
|---|
| 104 | HYPRE_BigInt scan_recv;
|
|---|
| 105 |
|
|---|
| 106 | coarse_pnts_global = hypre_CTAlloc(HYPRE_BigInt,2);
|
|---|
| 107 | MPI_Scan(&local_coarse_size, &scan_recv, 1, MPI_HYPRE_BIG_INT, MPI_SUM, comm);
|
|---|
| 108 | /* first point in my range */
|
|---|
| 109 | coarse_pnts_global[0] = scan_recv - local_coarse_size;
|
|---|
| 110 | /* first point in next proc's range */
|
|---|
| 111 | coarse_pnts_global[1] = scan_recv;
|
|---|
| 112 |
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 | #else
|
|---|
| 117 | coarse_pnts_global = hypre_CTAlloc(HYPRE_BigInt,num_procs+1);
|
|---|
| 118 |
|
|---|
| 119 | MPI_Allgather(&local_coarse_size,1,MPI_HYPRE_BIG_INT,&coarse_pnts_global[1],
|
|---|
| 120 | 1,MPI_HYPRE_BIG_INT,comm);
|
|---|
| 121 |
|
|---|
| 122 | for (i=2; i < num_procs+1; i++)
|
|---|
| 123 | coarse_pnts_global[i] += coarse_pnts_global[i-1];
|
|---|
| 124 | #endif
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 | *coarse_pnts_global_ptr = coarse_pnts_global;
|
|---|
| 130 |
|
|---|
| 131 | return (ierr);
|
|---|
| 132 | }
|
|---|