/[escript]/trunk/finley/src/Mesh_getPattern.c
ViewVC logotype

Diff of /trunk/finley/src/Mesh_getPattern.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/finley/src/finleyC/Mesh_getPattern.c revision 155 by jgs, Wed Nov 9 02:02:19 2005 UTC temp_trunk_copy/finley/src/Mesh_getPattern.c revision 1384 by phornby, Fri Jan 11 02:29:38 2008 UTC
# Line 1  Line 1 
 /*  
  ******************************************************************************  
  *                                                                            *  
  *       COPYRIGHT  ACcESS 2003,2004,2005 -  All Rights Reserved              *  
  *                                                                            *  
  * This software is the property of ACcESS. No part of this code              *  
  * may be copied in any form or by any means without the expressed written    *  
  * consent of ACcESS.  Copying, use or modification of this software          *  
  * by any unauthorised person is illegal unless that person has a software    *  
  * license agreement with ACcESS.                                             *  
  *                                                                            *  
  ******************************************************************************  
 */  
1    
2  /**************************************************************/  /* $Id$ */
3    
4  /* Finley: Mesh */  /*******************************************************
5     *
6     *           Copyright 2003-2007 by ACceSS MNRF
7     *       Copyright 2007 by University of Queensland
8     *
9     *                http://esscc.uq.edu.au
10     *        Primary Business: Queensland, Australia
11     *  Licensed under the Open Software License version 3.0
12     *     http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16  /**************************************************************/  /**************************************************************/
17    
18  /*  Author: gross@access.edu.au */  /* Finley: Mesh */
 /*  Version: $Id$ */  
19    
20  /**************************************************************/  /**************************************************************/
21    
# Line 66  Paso_SystemMatrixPattern* Finley_getPatt Line 62  Paso_SystemMatrixPattern* Finley_getPatt
62  }  }
63  Paso_SystemMatrixPattern* Finley_makePattern(Finley_Mesh *mesh,bool_t reduce_row_order, bool_t reduce_col_order) {  Paso_SystemMatrixPattern* Finley_makePattern(Finley_Mesh *mesh,bool_t reduce_row_order, bool_t reduce_col_order) {
64    double time0;    double time0;
65    dim_t i,n;    Paso_SystemMatrixPattern* out=NULL;
66    index_t s,itmp,*rowLabel=NULL,*colLabel=NULL, *ptr=NULL, *index=NULL;    Paso_Pattern *main_pattern = NULL, *couple_pattern=NULL;
67      Paso_Coupler *coupler;
68    Finley_IndexList* index_list=NULL;    Finley_IndexList* index_list=NULL;
69    Finley_resetError();    Finley_NodeMapping *colMap=NULL, *rowMap=NULL;
70      Paso_Distribution *colDistribution=NULL, *rowDistribution=NULL;
71        
72      index_t i,j;
73      Finley_resetError();
74    time0=Finley_timer();    time0=Finley_timer();
75    
76    if (reduce_col_order) {    if (reduce_col_order) {
77         n=mesh->Nodes->reducedNumDegreesOfFreedom;         colMap=mesh->Nodes->reducedDegreesOfFreedomMapping;
78         colLabel=mesh->Nodes->reducedDegreeOfFreedom;         colDistribution=mesh->Nodes->reducedDegreesOfFreedomDistribution;
79           coupler=mesh->Nodes->reducedDegreesOfFreedomCoupler;
80    
81    } else {    } else {
82         n=mesh->Nodes->numDegreesOfFreedom;         colMap=mesh->Nodes->degreesOfFreedomMapping;
83         colLabel=mesh->Nodes->degreeOfFreedom;         colDistribution=mesh->Nodes->degreesOfFreedomDistribution;
84           coupler=mesh->Nodes->degreesOfFreedomCoupler;
85    }    }
86            
87    if (reduce_row_order) {    if (reduce_row_order) {
88        n=mesh->Nodes->reducedNumDegreesOfFreedom;        rowMap=mesh->Nodes->reducedDegreesOfFreedomMapping;
89        rowLabel=mesh->Nodes->reducedDegreeOfFreedom;        rowDistribution=mesh->Nodes->reducedDegreesOfFreedomDistribution;
90    } else {    } else {
91        n=mesh->Nodes->numDegreesOfFreedom;        rowMap=mesh->Nodes->degreesOfFreedomMapping;
92        rowLabel=mesh->Nodes->degreeOfFreedom;        rowDistribution=mesh->Nodes->degreesOfFreedomDistribution;
93    }    }
94    
95    index_list=TMPMEMALLOC(n,Finley_IndexList);    index_list=TMPMEMALLOC(rowMap->numTargets,Finley_IndexList);
96    ptr=MEMALLOC(n+1,index_t);    if (! Finley_checkPtr(index_list)) {
97    if (! (Finley_checkPtr(index_list) || Finley_checkPtr(ptr)) ) {    
98        #pragma omp parallel private(i,s,itmp)        #pragma omp parallel private(i)
99        {        {
100          #pragma omp for schedule(static)          #pragma omp for schedule(static)
101          for(i=0;i<n;++i) {          for(i=0;i<rowMap->numTargets;++i) {
102               index_list[i].extension=NULL;               index_list[i].extension=NULL;
103               index_list[i].n=0;               index_list[i].n=0;
104          }          }
105          /*  insert contributions from element matrices into colums index index_list: */          /*  insert contributions from element matrices into colums index index_list: */
106          Finley_IndexList_insertElements(index_list,mesh->Elements,          Finley_IndexList_insertElements(index_list,mesh->Elements,
107                                          reduce_row_order,rowLabel,reduce_col_order,colLabel);                                          reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
108          Finley_IndexList_insertElements(index_list,mesh->FaceElements,          Finley_IndexList_insertElements(index_list,mesh->FaceElements,
109                                          reduce_row_order,rowLabel,reduce_col_order,colLabel);                                          reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
110          Finley_IndexList_insertElements(index_list,mesh->ContactElements,          Finley_IndexList_insertElements(index_list,mesh->ContactElements,
111                                          reduce_row_order,rowLabel,reduce_col_order,colLabel);                                          reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
112          Finley_IndexList_insertElements(index_list,mesh->Points,          Finley_IndexList_insertElements(index_list,mesh->Points,
113                                          reduce_row_order,rowLabel,reduce_col_order,colLabel);                                          reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
114          /* get the number of connections per row */  
         #pragma omp for schedule(static)  
         for(i=0;i<n;++i) {  
             ptr[i]=Finley_IndexList_count(&index_list[i]);  
         }  
         /* accumalate ptr */  
         /* OMP */  
         #pragma omp master  
         {  
             s=0;  
             for(i=0;i<n;++i) {  
                  itmp=ptr[i];  
                  ptr[i]=s;  
                  s+=itmp;  
             }  
             ptr[n]=s;  
             /* fill index */  
             index=MEMALLOC(ptr[n],index_t);  
         }  
         #pragma omp barrier  
         if (! Finley_checkPtr(index)) {  
             #pragma omp for schedule(static)  
             for(i=0;i<n;++i) Finley_IndexList_toArray(&index_list[i],&index[ptr[i]]);  
         }  
115       }       }
116    
117         /* create pattern */
118         main_pattern=Finley_IndexList_createPattern(Paso_Distribution_getMyNumComponents(rowDistribution),index_list,0,Paso_Distribution_getMyNumComponents(colDistribution),0);
119         couple_pattern=Finley_IndexList_createPattern(Paso_Distribution_getMyNumComponents(rowDistribution),index_list,Paso_Distribution_getMyNumComponents(colDistribution),colMap->numTargets,-Paso_Distribution_getMyNumComponents(colDistribution));
120         /* if everthing is in order we can create the return value */
121         if (Finley_noError()) {
122              out=Paso_SystemMatrixPattern_alloc(PATTERN_FORMAT_DEFAULT,
123                                                 rowDistribution,
124                                                 colDistribution,
125                                                 main_pattern,
126                                                 couple_pattern,
127                                                 coupler);
128         }
129         /* clean up */
130         if (index_list!=NULL) {
131            #pragma omp parallel for private(i)
132            for(i=0;i<rowMap->numTargets;++i) Finley_IndexList_free(index_list[i].extension);
133         }
134         TMPMEMFREE(index_list);
135         Paso_Pattern_free(main_pattern);
136         Paso_Pattern_free(couple_pattern);
137    }    }
   /* all done */  
   /* clean up */  
   if (index_list!=NULL) {  
     #pragma omp parallel for private(i)  
     for(i=0;i<n;++i) Finley_IndexList_free(index_list[i].extension);  
   }  
   TMPMEMFREE(index_list);  
138    #ifdef Finley_TRACE    #ifdef Finley_TRACE
139    printf("timing: mesh to matrix pattern: %.4e sec\n",Finley_timer()-time0);    printf("timing: mesh to matrix pattern: %.4e sec\n",Finley_timer()-time0);
140    #endif    #endif
141    if (! Finley_noError()) {    Paso_MPIInfo_noError(mesh->MPIInfo);
142      MEMFREE(ptr);    return out;
     MEMFREE(index);  
     return NULL;  
   } else {  
     return Paso_SystemMatrixPattern_alloc(n,ptr,index);  
   }  
143  }  }
 /*  
  * $Log$  
  * Revision 1.5  2005/09/15 03:44:22  jgs  
  * Merge of development branch dev-02 back to main trunk on 2005-09-15  
  *  
  * Revision 1.4  2005/09/01 03:31:35  jgs  
  * Merge of development branch dev-02 back to main trunk on 2005-09-01  
  *  
  * Revision 1.3.2.2  2005/09/07 06:26:19  gross  
  * the solver from finley are put into the standalone package paso now  
  *  
  * Revision 1.3.2.1  2005/08/24 02:02:18  gross  
  * timing output switched off. solver output can be swiched through getSolution(verbose=True) now.  
  *  
  * Revision 1.3  2005/07/08 04:07:52  jgs  
  * Merge of development branch back to main trunk on 2005-07-08  
  *  
  * Revision 1.2  2004/12/15 07:08:33  jgs  
  * *** empty log message ***  
  *  
  * Revision 1.1.2.5  2005/06/30 01:53:55  gross  
  * a bug in coloring fixed  
  *  
  * Revision 1.1.2.4  2005/06/29 02:34:51  gross  
  * some changes towards 64 integers in finley  
  *  
  * Revision 1.1.2.3  2004/11/24 01:37:14  gross  
  * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now  
  *  
  * Revision 1.1.2.1  2004/11/15 01:01:09  gross  
  * and anotther missing file  
  *  
  */  

Legend:
Removed from v.155  
changed lines
  Added in v.1384

  ViewVC Help
Powered by ViewVC 1.1.26