/[escript]/branches/domexper/dudley/src/ElementFile.c
ViewVC logotype

Contents of /branches/domexper/dudley/src/ElementFile.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3220 - (show annotations)
Wed Sep 29 00:33:16 2010 UTC (8 years, 6 months ago) by jfenwick
File MIME type: text/plain
File size: 4954 byte(s)
Removing references to Quadrature.? and ShapeFns

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
14
15 /**************************************************************/
16
17 /* Dudley: ElementFile */
18
19 /* allocates an element file to hold elements of type id and with integration order order. */
20 /* use Dudley_Mesh_allocElementTable to allocate the element table (Id,Nodes,Tag,Owner). */
21
22 /**************************************************************/
23
24 #include "ElementFile.h"
25 #include "ShapeTable.h"
26
27 /**************************************************************/
28
29 Dudley_ElementFile* Dudley_ElementFile_alloc(ElementTypeId etype, Paso_MPIInfo *MPIInfo)
30 {
31 Dudley_ElementFile *out;
32
33
34 if (! Dudley_noError()) return NULL;
35
36 /* allocate the return value */
37
38 out=MEMALLOC(1,Dudley_ElementFile);
39 if (Dudley_checkPtr(out)) return NULL;
40 // out->referenceElementSet=Dudley_ReferenceElementSet_reference(referenceElementSet);
41 out->numElements=0;
42 out->Id=NULL;
43 out->Nodes=NULL;
44 out->Tag=NULL;
45 out->Color=NULL;
46 out->minColor=0;
47 out->maxColor=-1;
48 out->jacobeans=NULL;
49 out->jacobeans_reducedQ=NULL;
50
51 out->Owner=NULL;
52 out->numTagsInUse=0;
53 out->tagsInUse=NULL;
54
55 out->MPIInfo = Paso_MPIInfo_getReference( MPIInfo );
56
57 out->jacobeans=Dudley_ElementFile_Jacobeans_alloc();
58 out->jacobeans_reducedQ=Dudley_ElementFile_Jacobeans_alloc();
59
60 if (! Dudley_noError()) {
61 Dudley_ElementFile_free(out);
62 return NULL;
63 }
64 out->etype=etype;
65
66
67 //need to extract these fields without using the reference element
68
69 // out->numNodes=out->referenceElementSet->numNodes;
70 // out->numDim=referenceElementSet->referenceElement->BasisFunctions->Type->numDim;
71 out->numDim=Dims[out->etype];
72 out->numNodes=out->numDim+1;
73 out->numLocalDim=localDims[out->etype];
74 out->numShapes=out->numLocalDim+1;
75 out->ename=getElementName(out->etype);
76 return out;
77 }
78
79 /* deallocates an element file: */
80
81 void Dudley_ElementFile_free(Dudley_ElementFile* in) {
82 if (in!=NULL) {
83 Dudley_ElementFile_freeTable(in);
84 // Dudley_ReferenceElementSet_dealloc(in->referenceElementSet);
85 Dudley_ElementFile_Jacobeans_dealloc(in->jacobeans);
86 /*
87 Dudley_ElementFile_Jacobeans_dealloc(in->jacobeans_reducedS);
88 */
89 Dudley_ElementFile_Jacobeans_dealloc(in->jacobeans_reducedQ);
90 /*
91 Dudley_ElementFile_Jacobeans_dealloc(in->jacobeans_reducedS_reducedQ);
92 */
93 Paso_MPIInfo_free( in->MPIInfo );
94 MEMFREE(in);
95 }
96 }
97 void Dudley_ElementFile_setElementDistribution(Dudley_ElementFile* in, dim_t* distribution) {
98 dim_t local_num_elements,e,num_elements=0, size;
99 Paso_MPI_rank myRank;
100 if (in == NULL) {
101 distribution[0]=num_elements;
102 } else {
103 if (in->MPIInfo->size>1) {
104 num_elements=0;
105 myRank=in->MPIInfo->rank;
106 size=in->MPIInfo->size;
107 #pragma omp parallel private(local_num_elements)
108 {
109 local_num_elements=0;
110 #pragma omp for private(e)
111 for (e=0;e<in->numElements;e++) {
112 if (in->Owner[e] == myRank) local_num_elements++;
113 }
114 #pragma omp critical
115 num_elements+=local_num_elements;
116 }
117 #ifdef PASO_MPI
118 MPI_Allgather(&num_elements,1,MPI_INT,distribution,1,MPI_INT,in->MPIInfo->comm);
119 #else
120 distribution[0]=num_elements;
121 #endif
122 } else {
123 distribution[0]=in->numElements;
124 }
125 }
126 }
127
128 dim_t Dudley_ElementFile_getGlobalNumElements(Dudley_ElementFile* in) {
129 dim_t size, *distribution=NULL, out, p;
130 if (in == NULL) {
131 return 0;
132 } else {
133 size=in->MPIInfo->size;
134 distribution=TMPMEMALLOC(size,dim_t);
135 Dudley_ElementFile_setElementDistribution(in,distribution);
136 out=0;
137 for (p=0;p<size;++p) out+=distribution[p];
138 TMPMEMFREE(distribution);
139 return out;
140 }
141 }
142 dim_t Dudley_ElementFile_getMyNumElements(Dudley_ElementFile* in) {
143 dim_t size, *distribution=NULL, out;
144 if (in == NULL) {
145 return 0;
146 } else {
147 size=in->MPIInfo->size;
148 distribution=TMPMEMALLOC(size,dim_t);
149 Dudley_ElementFile_setElementDistribution(in,distribution);
150 out=distribution[in->MPIInfo->rank];
151 TMPMEMFREE(distribution);
152 return out;
153 }
154
155 }
156 index_t Dudley_ElementFile_getFirstElement(Dudley_ElementFile* in){
157 dim_t size, *distribution=NULL, out, p;
158 if (in == NULL) {
159 return 0;
160 } else {
161 size=in->MPIInfo->size;
162 distribution=TMPMEMALLOC(size,dim_t);
163 Dudley_ElementFile_setElementDistribution(in,distribution);
164 out=0;
165 for (p=0;p<in->MPIInfo->rank;++p) out+=distribution[p];
166 TMPMEMFREE(distribution);
167 return out;
168 }
169 }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26