/[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 trunk/finley/src/Mesh_getPattern.c revision 2881 by jfenwick, Thu Jan 28 02:03:15 2010 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  /**************************************************************/  /*******************************************************
3    *
4    * Copyright (c) 2003-2010 by University of Queensland
5    * Earth Systems Science Computational Center (ESSCC)
6    * http://www.uq.edu.au/esscc
7    *
8    * Primary Business: Queensland, Australia
9    * Licensed under the Open Software License version 3.0
10    * http://www.opensource.org/licenses/osl-3.0.php
11    *
12    *******************************************************/
13    
 /* Finley: Mesh */  
14    
15  /**************************************************************/  /**************************************************************/
16    
17  /*  Author: gross@access.edu.au */  /* Finley: Mesh */
 /*  Version: $Id$ */  
18    
19  /**************************************************************/  /**************************************************************/
20    
# Line 50  Paso_SystemMatrixPattern* Finley_getPatt Line 45  Paso_SystemMatrixPattern* Finley_getPatt
45     if (Finley_noError()) {     if (Finley_noError()) {
46        if (reduce_row_order) {        if (reduce_row_order) {
47           if (reduce_col_order) {           if (reduce_col_order) {
48              out=Paso_SystemMatrixPattern_reference(mesh->ReducedReducedPattern);              out=Paso_SystemMatrixPattern_getReference(mesh->ReducedReducedPattern);
49           } else {           } else {
50              out=Paso_SystemMatrixPattern_reference(mesh->ReducedFullPattern);              out=Paso_SystemMatrixPattern_getReference(mesh->ReducedFullPattern);
51           }           }
52        } else {        } else {
53           if (reduce_col_order) {           if (reduce_col_order) {
54              out=Paso_SystemMatrixPattern_reference(mesh->FullReducedPattern);              out=Paso_SystemMatrixPattern_getReference(mesh->FullReducedPattern);
55           } else {           } else {
56              out=Paso_SystemMatrixPattern_reference(mesh->FullFullPattern);              out=Paso_SystemMatrixPattern_getReference(mesh->FullFullPattern);
57           }           }
58        }        }
59     }       }  
# Line 66  Paso_SystemMatrixPattern* Finley_getPatt Line 61  Paso_SystemMatrixPattern* Finley_getPatt
61  }  }
62  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) {
63    double time0;    double time0;
64    dim_t i,n;    Paso_SystemMatrixPattern* out=NULL;
65    index_t s,itmp,*rowLabel=NULL,*colLabel=NULL, *ptr=NULL, *index=NULL;    Paso_Pattern *main_pattern = NULL, *col_couple_pattern=NULL, *row_couple_pattern=NULL;
66      Paso_Connector *col_connector, *row_connector;
67    Finley_IndexList* index_list=NULL;    Finley_IndexList* index_list=NULL;
68    Finley_resetError();    Finley_NodeMapping *colMap=NULL, *rowMap=NULL;
69      Paso_Distribution *colDistribution=NULL, *rowDistribution=NULL;
70        
71      index_t i;
72      Finley_resetError();
73    time0=Finley_timer();    time0=Finley_timer();
74    
75    if (reduce_col_order) {    if (reduce_col_order) {
76         n=mesh->Nodes->reducedNumDegreesOfFreedom;         colMap=mesh->Nodes->reducedDegreesOfFreedomMapping;
77         colLabel=mesh->Nodes->reducedDegreeOfFreedom;         colDistribution=mesh->Nodes->reducedDegreesOfFreedomDistribution;
78           col_connector=mesh->Nodes->reducedDegreesOfFreedomConnector;
79    
80    } else {    } else {
81         n=mesh->Nodes->numDegreesOfFreedom;         colMap=mesh->Nodes->degreesOfFreedomMapping;
82         colLabel=mesh->Nodes->degreeOfFreedom;         colDistribution=mesh->Nodes->degreesOfFreedomDistribution;
83           col_connector=mesh->Nodes->degreesOfFreedomConnector;
84    }    }
85            
86    if (reduce_row_order) {    if (reduce_row_order) {
87        n=mesh->Nodes->reducedNumDegreesOfFreedom;        rowMap=mesh->Nodes->reducedDegreesOfFreedomMapping;
88        rowLabel=mesh->Nodes->reducedDegreeOfFreedom;        rowDistribution=mesh->Nodes->reducedDegreesOfFreedomDistribution;
89          row_connector=mesh->Nodes->reducedDegreesOfFreedomConnector;
90    } else {    } else {
91        n=mesh->Nodes->numDegreesOfFreedom;        rowMap=mesh->Nodes->degreesOfFreedomMapping;
92        rowLabel=mesh->Nodes->degreeOfFreedom;        rowDistribution=mesh->Nodes->degreesOfFreedomDistribution;
93          row_connector=mesh->Nodes->degreesOfFreedomConnector;
94    }    }
95    
96    index_list=TMPMEMALLOC(n,Finley_IndexList);    index_list=TMPMEMALLOC(rowMap->numTargets,Finley_IndexList);
97    ptr=MEMALLOC(n+1,index_t);    if (! Finley_checkPtr(index_list)) {
98    if (! (Finley_checkPtr(index_list) || Finley_checkPtr(ptr)) ) {    
99        #pragma omp parallel private(i,s,itmp)        #pragma omp parallel private(i)
100        {        {
101          #pragma omp for schedule(static)          #pragma omp for schedule(static)
102          for(i=0;i<n;++i) {          for(i=0;i<rowMap->numTargets;++i) {
103               index_list[i].extension=NULL;               index_list[i].extension=NULL;
104               index_list[i].n=0;               index_list[i].n=0;
105          }          }
106          /*  insert contributions from element matrices into colums index index_list: */          /*  insert contributions from element matrices into colums index index_list: */
107          Finley_IndexList_insertElements(index_list,mesh->Elements,          Finley_IndexList_insertElements(index_list,mesh->Elements,
108                                          reduce_row_order,rowLabel,reduce_col_order,colLabel);                                          reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
109          Finley_IndexList_insertElements(index_list,mesh->FaceElements,          Finley_IndexList_insertElements(index_list,mesh->FaceElements,
110                                          reduce_row_order,rowLabel,reduce_col_order,colLabel);                                          reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
111          Finley_IndexList_insertElements(index_list,mesh->ContactElements,          Finley_IndexList_insertElements(index_list,mesh->ContactElements,
112                                          reduce_row_order,rowLabel,reduce_col_order,colLabel);                                          reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
113          Finley_IndexList_insertElements(index_list,mesh->Points,          Finley_IndexList_insertElements(index_list,mesh->Points,
114                                          reduce_row_order,rowLabel,reduce_col_order,colLabel);                                          reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
115          /* 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]]);  
         }  
116       }       }
117    
118         /* create pattern */
119         main_pattern=Finley_IndexList_createPattern(0,Paso_Distribution_getMyNumComponents(rowDistribution),index_list,
120                                                     0,Paso_Distribution_getMyNumComponents(colDistribution),
121                                                     0);
122         col_couple_pattern=Finley_IndexList_createPattern(0,Paso_Distribution_getMyNumComponents(rowDistribution),index_list,
123                                                     Paso_Distribution_getMyNumComponents(colDistribution),colMap->numTargets,
124                                                     -Paso_Distribution_getMyNumComponents(colDistribution));
125         row_couple_pattern=Finley_IndexList_createPattern(Paso_Distribution_getMyNumComponents(rowDistribution),rowMap->numTargets,index_list,
126                                                           0,Paso_Distribution_getMyNumComponents(colDistribution),
127                                                           0);
128    
129         /* if everthing is in order we can create the return value */
130         if (Finley_noError()) {
131              out=Paso_SystemMatrixPattern_alloc(PATTERN_FORMAT_DEFAULT,
132                                                 rowDistribution,
133                                                 colDistribution,
134                                                 main_pattern,
135                                                 col_couple_pattern,
136                                                 row_couple_pattern,
137                                                 col_connector,
138                                                 row_connector);
139         }
140         /* clean up */
141         if (index_list!=NULL) {
142            #pragma omp parallel for private(i)
143            for(i=0;i<rowMap->numTargets;++i) Finley_IndexList_free(index_list[i].extension);
144         }
145         TMPMEMFREE(index_list);
146         Paso_Pattern_free(main_pattern);
147         Paso_Pattern_free(col_couple_pattern);
148         Paso_Pattern_free(row_couple_pattern);
149    }    }
   /* 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);  
150    #ifdef Finley_TRACE    #ifdef Finley_TRACE
151    printf("timing: mesh to matrix pattern: %.4e sec\n",Finley_timer()-time0);    printf("timing: mesh to matrix pattern: %.4e sec\n",Finley_timer()-time0);
152    #endif    #endif
153    if (! Finley_noError()) {    Paso_MPIInfo_noError(mesh->MPIInfo);
154      MEMFREE(ptr);    return out;
     MEMFREE(index);  
     return NULL;  
   } else {  
     return Paso_SystemMatrixPattern_alloc(n,ptr,index);  
   }  
155  }  }
 /*  
  * $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.2881

  ViewVC Help
Powered by ViewVC 1.1.26