1 /* 2 *-------------------------------------------------------------------- 3 * This software is Copyright (c) 2012-2015 The Regents of the 4 * University of California. All Rights Reserved. 5 * 6 * Permission to copy and modify this software and its documentation 7 * for educational, research and non-profit purposes, without fee, 8 * and without a written agreement is hereby granted, provided that 9 * the above copyright notice, this paragraph and the following three 10 * paragraphs appear in all copies. 11 * 12 * Permission to make commercial use of this software may be obtained 13 * by contacting: 14 * 15 * Technology Transfer Office 16 * 9500 Gilman Drive, Mail Code 0910 17 * University of California 18 * La Jolla, CA 92093-0910 19 * (858) 534-5815 20 * invent@ucsd.edu 21 * 22 * This software program and documentation are copyrighted by The 23 * Regents of the University of California. The software program and 24 * documentation are supplied "as is", without any accompanying 25 * services from The Regents. The Regents does not warrant that the 26 * operation of the program will be uninterrupted or error-free. The 27 * end-user understands that the program was developed for research 28 * purposes and is advised not to rely exclusively on the program for 29 * any reason. 30 * 31 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY 32 * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL 33 * DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS 34 * SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF 35 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY 37 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 38 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE 39 * SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE 40 * UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE 41 * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 42 *-------------------------------------------------------------------- 43 */ 44 45 // Some defenitions 46 #define LS_TYPE_CG 1 47 #define LS_TYPE_GMRES 2 48 #define LS_TYPE_NS 3 49 #define BC_TYPE_Dir 0 50 #define BC_TYPE_Neu 1 51 #define BCOP_TYPE_ADD 0 52 #define BCOP_TYPE_PRE 1 53 54 // Communication structure 55 typedef struct { 56 int foC;// = false; // Free of created (USE) 57 int masF; // If this the master (USE) 58 int master; // Master ID (USE) 59 int task; // ID of this proc. (USE) 60 int tF; // Task in FORTRAN indexing (USE) 61 int nTasks; // Total number of tasks (USE) 62 MPI_Aint comm; // MPI communicator (IN) 63 } svLS_commuType; 64 /* 65 // LHS matrix related data 66 typedef struct { 67 int foC;// = false; // Free or created (USE) 68 int coupledFlag; // Neu: P/Q coupling (USE) 69 int sharedFlag;// = false; // Neu: shared between proces (USE) 70 int incFlag; // Included in the computations (IN) 71 int nNo;// = 0; // Number of nodes (IN) 72 int dof; // Degrees of freedom for val (IN) 73 int bGrp;// = BC_TYPE_Dir; // Dir/Neu (IN) 74 int reserved; // Only for data alignment 75 int *glob; // Global node number (IN) 76 double nS; // ||Sai||**2D0 (USE) 77 double res;// = 0D0; // Neu: P = res*Q (IN) 78 double **val; // nodal Sai for Neu (IN) 79 double **valM; // Neu W*Sai (TMP) 80 } svLS_faceType; 81 82 typedef struct { 83 int ptr; // Pointer to start of data for commu (only 2 proc shared points) 84 int n; // Number of data to be commu (only 2 proc shared points) 85 int tag; // Commu tag 86 int req; // Commu req 87 int nBl; // Number of blocks for commu (for 3 < proc shared points) 88 int reserved; // Only for data alignment 89 int *blPtr; // Pointer to beggining of each block (for 3 < proc shared points) 90 int *blN; // Length of each block (for 3 < proc shared points) 91 } svLS_cSType; 92 93 typedef struct { 94 int foC;// = false; // Free or created (USE) 95 int gnNo;// = 0; // Global number of nodes (IN) 96 int nNo;// = 0; // Number of nodes (IN) 97 int nnz;// = 0; // Number of non-zero in lhs (IN) 98 int nFaces;// = 0; // Number of faces (IN) 99 int mynNo; // nNo of this proc (USE) 100 int *colPtr; // Column pointer (USE) 101 int **rowPtr; // Row pointer (USE) 102 int *diagPt; // Diagonal pointer (USE) 103 int *map; // Mapping of nodes (USE) 104 svLS_commuType commu; 105 svLS_cSType *cS; 106 svLS_faceType *face; 107 } svLS_lhsType; 108 */ 109 // LS related structures 110 typedef struct { 111 int suc; // Successful solving (OUT) 112 int mItr; // Maximum iteration (IN) 113 int sD; // Space dimension (IN) 114 int itr; // Number of iteration (OUT) 115 int cM; // Number of Ax multiply (OUT) 116 int cN; // Number of |x| norms (OUT) 117 int cD; // Number of <x.y> dot products(OUT) 118 int reserve; // Only for data alignment (-) 119 double absTol; // Absolute tolerance (IN) 120 double relTol; // Relative tolerance (IN) 121 double iNorm; // Initial norm of residual (OUT) 122 double fNorm; // Final norm of residual (OUT) 123 double dB; // Res. rduction in last itr. (OUT) 124 double callD; // Calling duration (OUT) 125 } svLS_subLsType; 126 127 typedef struct { 128 int foC;// = false; // Free of created (USE) 129 int LS_type; // Which one of LS (IN) 130 int Resm; // Contribution of mom. res. (OUT) 131 int Resc; // Contribution of cont. res. (OUT) 132 svLS_subLsType GM; 133 svLS_subLsType CG; 134 svLS_subLsType RI; 135 } svLS_lsType; 136