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

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

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

revision 616 by elspeth, Wed Mar 22 02:46:56 2006 UTC revision 1716 by gross, Thu Aug 21 05:03:49 2008 UTC
# Line 1  Line 1 
1  /*  
2   ************************************************************  /* $Id$ */
3   *          Copyright 2006 by ACcESS MNRF                   *  
4   *                                                          *  /*******************************************************
5   *              http://www.access.edu.au                    *   *
6   *       Primary Business: Queensland, Australia            *   *           Copyright 2003-2007 by ACceSS MNRF
7   *  Licensed under the Open Software License version 3.0    *   *       Copyright 2007 by University of Queensland
8   *     http://www.opensource.org/licenses/osl-3.0.php       *   *
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  /*   Finley: ElementFile */  /*   Finley: ElementFile */
19    
20  /*   allocates an element file to hold elements of type id and with integration order order. */  /*   allocates an element file to hold elements of type id and with integration order order. */
21  /*   use Finley_Mesh_allocElementTable to allocate the element table (Id,Nodes,Tag). */  /*   use Finley_Mesh_allocElementTable to allocate the element table (Id,Nodes,Tag,Owner). */
   
 /**************************************************************/  
   
 /*   Author: gross@access.edu.au */  
 /*   Version: $Id$ */  
22    
23  /**************************************************************/  /**************************************************************/
24    
# Line 28  Line 26 
26    
27  /**************************************************************/  /**************************************************************/
28    
29  Finley_ElementFile* Finley_ElementFile_alloc(ElementTypeId id,index_t order){  Finley_ElementFile* Finley_ElementFile_alloc(ElementTypeId id, index_t order, index_t reduced_order, Paso_MPIInfo *MPIInfo)
30    {
31    extern Finley_RefElementInfo Finley_RefElement_InfoList[];    extern Finley_RefElementInfo Finley_RefElement_InfoList[];
32    dim_t NQ;    dim_t NQ, reduced_NQ;
33    Finley_ElementFile *out;    Finley_ElementFile *out;
34        
35    /*   get the number of quadrature nodes needed to achieve integration order order: */    /*   get the number of quadrature nodes needed to achieve integration order order: */
36        
37    if (order<0) order=2*Finley_RefElement_InfoList[id].numOrder;    if (order<0) order=MAX(2*Finley_RefElement_InfoList[id].numOrder,0);
38      if (reduced_order<0) reduced_order=MAX(2*(Finley_RefElement_InfoList[id].numOrder-1),0);
39    NQ= Finley_RefElement_InfoList[id].getNumQuadNodes(order);    NQ= Finley_RefElement_InfoList[id].getNumQuadNodes(order);
40      reduced_NQ= Finley_RefElement_InfoList[id].getNumQuadNodes(reduced_order);
41    if (! Finley_noError()) return NULL;    if (! Finley_noError()) return NULL;
42        
43    /*  allocate the return value */    /*  allocate the return value */
44        
45    out=MEMALLOC(1,Finley_ElementFile);    out=MEMALLOC(1,Finley_ElementFile);
46    if (Finley_checkPtr(out)) return NULL;    if (Finley_checkPtr(out)) return NULL;
47      out->order = order;
48      out->reduced_order = reduced_order;
49    out->ReferenceElement=NULL;    out->ReferenceElement=NULL;
50    out->LinearReferenceElement=NULL;    out->LinearReferenceElement=NULL;
51      out->ReferenceElementReducedOrder=NULL;
52      out->LinearReferenceElementReducedOrder=NULL;
53    out->numElements=0;    out->numElements=0;
54    out->Id=NULL;    out->Id=NULL;
55    out->Nodes=NULL;    out->Nodes=NULL;
# Line 52  Finley_ElementFile* Finley_ElementFile_a Line 57  Finley_ElementFile* Finley_ElementFile_a
57    out->Color=NULL;    out->Color=NULL;
58    out->minColor=0;    out->minColor=0;
59    out->maxColor=-1;    out->maxColor=-1;
60    out->order = order;    out->jacobeans=NULL;
61    out->volume_is_valid=FALSE;      out->jacobeans_reducedQ=NULL;
62    out->volume=NULL;              out->jacobeans_reducedS=NULL;
63    out->DvDV=NULL;                out->jacobeans_reducedS_reducedQ=NULL;
64    out->DSDV_is_valid=FALSE;  
65    out->DSDV=NULL;                out->Owner=NULL;                
66    out->DSLinearDV_is_valid=FALSE;    out->numTagsInUse=0;
67    out->DSLinearDV=NULL;            out->tagsInUse=NULL;
   out->X_is_valid=FALSE;          
   out->X=NULL;                  
68    
69      out->MPIInfo = Paso_MPIInfo_getReference( MPIInfo );
70    
71    /*  allocate the reference element: */    /*  allocate the reference element: */
72        
73    out->ReferenceElement=Finley_RefElement_alloc(id,NQ);    out->ReferenceElement=Finley_RefElement_alloc(id,NQ);
74    if (! Finley_noError()) {    out->jacobeans=Finley_ElementFile_Jacobeans_alloc(out->ReferenceElement);
75       Finley_ElementFile_dealloc(out);    out->ReferenceElementReducedOrder=Finley_RefElement_alloc(id,reduced_NQ);
76       return NULL;    out->jacobeans_reducedQ=Finley_ElementFile_Jacobeans_alloc(out->ReferenceElementReducedOrder);
77    }  
78    out->LinearReferenceElement=Finley_RefElement_alloc(Finley_RefElement_InfoList[id].LinearTypeId,NQ);    out->LinearReferenceElement=Finley_RefElement_alloc(Finley_RefElement_InfoList[id].LinearTypeId,NQ);
79      out->jacobeans_reducedS=Finley_ElementFile_Jacobeans_alloc(out->LinearReferenceElement);
80      out->LinearReferenceElementReducedOrder=Finley_RefElement_alloc(Finley_RefElement_InfoList[id].LinearTypeId,reduced_NQ);
81      out->jacobeans_reducedS_reducedQ=Finley_ElementFile_Jacobeans_alloc(out->LinearReferenceElementReducedOrder);
82    
83      out->numNodes=out->ReferenceElement->Type->numNodes;
84    
85    if (! Finley_noError()) {    if (! Finley_noError()) {
86       Finley_ElementFile_dealloc(out);       Finley_ElementFile_free(out);
87       return NULL;       return NULL;
88    }    }
89    return out;    return out;
# Line 81  Finley_ElementFile* Finley_ElementFile_a Line 91  Finley_ElementFile* Finley_ElementFile_a
91    
92  /*  deallocates an element file: */  /*  deallocates an element file: */
93    
94  void Finley_ElementFile_dealloc(Finley_ElementFile* in) {  void Finley_ElementFile_free(Finley_ElementFile* in) {
95    if (in!=NULL) {    if (in!=NULL) {
96       #ifdef Finley_TRACE       #ifdef Finley_TRACE
97       if (in->ReferenceElement!=NULL) printf("element file for %s is deallocated.\n",in->ReferenceElement->Type->Name);       if (in->ReferenceElement!=NULL) printf("element file for %s is deallocated.\n",in->ReferenceElement->Type->Name);
98       #endif       #endif
99         Finley_ElementFile_freeTable(in);  
100       Finley_RefElement_dealloc(in->ReferenceElement);       Finley_RefElement_dealloc(in->ReferenceElement);
101         Finley_RefElement_dealloc(in->ReferenceElementReducedOrder);
102       Finley_RefElement_dealloc(in->LinearReferenceElement);       Finley_RefElement_dealloc(in->LinearReferenceElement);
103       Finley_ElementFile_deallocTable(in);         Finley_RefElement_dealloc(in->LinearReferenceElementReducedOrder);
104       MEMFREE(in->volume);                 Finley_ElementFile_Jacobeans_dealloc(in->jacobeans);
105       MEMFREE(in->DvDV);                   Finley_ElementFile_Jacobeans_dealloc(in->jacobeans_reducedS);
106       MEMFREE(in->DSDV);                   Finley_ElementFile_Jacobeans_dealloc(in->jacobeans_reducedQ);
107       MEMFREE(in->DSLinearDV);               Finley_ElementFile_Jacobeans_dealloc(in->jacobeans_reducedS_reducedQ);
108       MEMFREE(in->X);                       Paso_MPIInfo_free( in->MPIInfo );
109       MEMFREE(in);             MEMFREE(in);      
110    }    }
111  }  }
112  /*  void Finley_ElementFile_setElementDistribution(Finley_ElementFile* in, dim_t* distribution) {
113  * $Log$    dim_t local_num_elements,e,num_elements=0, size;
114  * Revision 1.6  2005/09/15 03:44:21  jgs    Paso_MPI_rank myRank;
115  * Merge of development branch dev-02 back to main trunk on 2005-09-15    if (in == NULL) {
116  *        distribution[0]=num_elements;
117  * Revision 1.5.2.1  2005/09/07 06:26:18  gross    } else {
118  * the solver from finley are put into the standalone package paso now        if (in->MPIInfo->size>1) {
119  *           num_elements=0;
120  * Revision 1.5  2005/07/08 04:07:48  jgs           myRank=in->MPIInfo->rank;
121  * Merge of development branch back to main trunk on 2005-07-08           size=in->MPIInfo->size;
122  *           #pragma omp parallel private(local_num_elements)
123  * Revision 1.4  2004/12/15 07:08:32  jgs           {
124  * *** empty log message ***              local_num_elements=0;
125  * Revision 1.1.1.1.2.2  2005/06/29 02:34:49  gross              #pragma omp for private(e)
126  * some changes towards 64 integers in finley              for (e=0;e<in->numElements;e++) {
127  *                 if (in->Owner[e] == myRank) local_num_elements++;
128  * Revision 1.1.1.1.2.1  2004/11/24 01:37:13  gross              }
129  * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now              #pragma omp critical
130  *              num_elements+=local_num_elements;
131  *           }
132  *           #ifdef PASO_MPI
133  */             MPI_Allgather(&num_elements,1,MPI_INT,distribution,1,MPI_INT,in->MPIInfo->comm);
134             #else
135               distribution[0]=num_elements;
136             #endif
137          } else {
138            distribution[0]=in->numElements;
139          }
140      }
141    }
142    
143    dim_t Finley_ElementFile_getGlobalNumElements(Finley_ElementFile* in) {
144      dim_t size, *distribution=NULL, out, p;
145      if (in == NULL) {
146          return 0;
147      } else {
148        size=in->MPIInfo->size;
149        distribution=TMPMEMALLOC(size,dim_t);
150        Finley_ElementFile_setElementDistribution(in,distribution);
151        out=0;
152        for (p=0;p<size;++p) out+=distribution[p];
153        TMPMEMFREE(distribution);
154        return out;
155      }
156    }
157    dim_t Finley_ElementFile_getMyNumElements(Finley_ElementFile* in) {
158      dim_t size, *distribution=NULL, out;
159      if (in == NULL) {
160          return 0;
161      } else {
162        size=in->MPIInfo->size;
163        distribution=TMPMEMALLOC(size,dim_t);
164        Finley_ElementFile_setElementDistribution(in,distribution);
165        out=distribution[in->MPIInfo->rank];
166        TMPMEMFREE(distribution);
167        return out;
168      }
169    
170    }
171    index_t Finley_ElementFile_getFirstElement(Finley_ElementFile* in){
172      dim_t size, *distribution=NULL, out, p;
173      if (in == NULL) {
174          return 0;
175      } else {
176        size=in->MPIInfo->size;
177        distribution=TMPMEMALLOC(size,dim_t);
178        Finley_ElementFile_setElementDistribution(in,distribution);
179        out=0;
180        for (p=0;p<in->MPIInfo->rank;++p) out+=distribution[p];
181        TMPMEMFREE(distribution);
182        return out;
183      }
184    }

Legend:
Removed from v.616  
changed lines
  Added in v.1716

  ViewVC Help
Powered by ViewVC 1.1.26