/[escript]/branches/trilinos_from_5897/dudley/src/ElementFile.cpp
ViewVC logotype

Contents of /branches/trilinos_from_5897/dudley/src/ElementFile.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6009 - (show annotations)
Wed Mar 2 04:13:26 2016 UTC (3 years, 1 month ago) by caltinay
File size: 4436 byte(s)
Much needed sync with trunk...

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2016 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17 /****************************************************************************/
18
19 /* Dudley: ElementFile */
20
21 /* allocates an element file to hold elements of type id and with integration order order. */
22 /* use Dudley_Mesh_allocElementTable to allocate the element table (Id,Nodes,Tag,Owner). */
23
24 /****************************************************************************/
25
26 #include "ElementFile.h"
27 #include "ShapeTable.h"
28
29 namespace dudley {
30
31 Dudley_ElementFile *Dudley_ElementFile_alloc(Dudley_ElementTypeId etype, escript::JMPI& MPIInfo)
32 {
33 Dudley_ElementFile* out = new Dudley_ElementFile;
34 out->numElements = 0;
35 out->Id = NULL;
36 out->Nodes = NULL;
37 out->Tag = NULL;
38 out->Color = NULL;
39 out->minColor = 0;
40 out->maxColor = -1;
41 out->jacobians = NULL;
42 out->jacobians_reducedQ = NULL;
43
44 out->Owner = NULL;
45 out->numTagsInUse = 0;
46 out->tagsInUse = NULL;
47
48 out->MPIInfo = MPIInfo;
49
50 out->jacobians = Dudley_ElementFile_Jacobians_alloc();
51 out->jacobians_reducedQ = Dudley_ElementFile_Jacobians_alloc();
52
53 out->etype = etype;
54 out->numDim = Dims[out->etype];
55 out->numNodes = out->numDim + 1;
56 out->numLocalDim = localDims[out->etype];
57 out->numShapes = out->numLocalDim + 1;
58 out->ename = getElementName(out->etype);
59 return out;
60 }
61
62 /* deallocates an element file: */
63 void Dudley_ElementFile_free(Dudley_ElementFile* in)
64 {
65 if (in != NULL)
66 {
67 Dudley_ElementFile_freeTable(in);
68 Dudley_ElementFile_Jacobians_dealloc(in->jacobians);
69 Dudley_ElementFile_Jacobians_dealloc(in->jacobians_reducedQ);
70 delete in;
71 }
72 }
73
74 void Dudley_ElementFile_setElementDistribution(Dudley_ElementFile * in, dim_t * distribution)
75 {
76 dim_t local_num_elements, e, num_elements = 0;
77 int myRank;
78 if (in == NULL) {
79 distribution[0] = num_elements;
80 } else {
81 if (in->MPIInfo->size > 1) {
82 num_elements = 0;
83 myRank = in->MPIInfo->rank;
84 #pragma omp parallel private(local_num_elements)
85 {
86 local_num_elements = 0;
87 #pragma omp for private(e)
88 for (e = 0; e < in->numElements; e++) {
89 if (in->Owner[e] == myRank)
90 local_num_elements++;
91 }
92 #pragma omp critical
93 num_elements += local_num_elements;
94 }
95 #ifdef ESYS_MPI
96 MPI_Allgather(&num_elements, 1, MPI_INT, distribution, 1, MPI_INT, in->MPIInfo->comm);
97 #else
98 distribution[0] = num_elements;
99 #endif
100 } else {
101 distribution[0] = in->numElements;
102 }
103 }
104 }
105
106 dim_t Dudley_ElementFile_getGlobalNumElements(Dudley_ElementFile* in)
107 {
108 if (in == NULL)
109 return 0;
110
111 dim_t size, *distribution = NULL, out, p;
112 size = in->MPIInfo->size;
113 distribution = new dim_t[size];
114 Dudley_ElementFile_setElementDistribution(in, distribution);
115 out = 0;
116 for (p = 0; p < size; ++p)
117 out += distribution[p];
118 delete[] distribution;
119 return out;
120 }
121
122 dim_t Dudley_ElementFile_getMyNumElements(Dudley_ElementFile* in)
123 {
124 if (in == NULL)
125 return 0;
126
127 dim_t size, *distribution = NULL, out;
128 size = in->MPIInfo->size;
129 distribution = new dim_t[size];
130 Dudley_ElementFile_setElementDistribution(in, distribution);
131 out = distribution[in->MPIInfo->rank];
132 delete[] distribution;
133 return out;
134 }
135
136 index_t Dudley_ElementFile_getFirstElement(Dudley_ElementFile* in)
137 {
138 if (in == NULL)
139 return 0;
140
141 dim_t size, *distribution = NULL, out, p;
142 size = in->MPIInfo->size;
143 distribution = new dim_t[size];
144 Dudley_ElementFile_setElementDistribution(in, distribution);
145 out = 0;
146 for (p = 0; p < in->MPIInfo->rank; ++p)
147 out += distribution[p];
148 delete[] distribution;
149 return out;
150 }
151
152 } // namespace dudley
153

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision
svn:mergeinfo /branches/4.0fordebian/dudley/src/ElementFile.cpp:5567-5588 /branches/lapack2681/finley/src/ElementFile.cpp:2682-2741 /branches/pasowrap/dudley/src/ElementFile.cpp:3661-3674 /branches/py3_attempt2/dudley/src/ElementFile.cpp:3871-3891 /branches/restext/finley/src/ElementFile.cpp:2610-2624 /branches/ripleygmg_from_3668/dudley/src/ElementFile.cpp:3669-3791 /branches/stage3.0/finley/src/ElementFile.cpp:2569-2590 /branches/symbolic_from_3470/dudley/src/ElementFile.cpp:3471-3974 /branches/symbolic_from_3470/ripley/test/python/dudley/src/ElementFile.cpp:3517-3974 /release/3.0/finley/src/ElementFile.cpp:2591-2601 /release/4.0/dudley/src/ElementFile.cpp:5380-5406 /trunk/dudley/src/ElementFile.cpp:4257-4344,5898-6007 /trunk/ripley/test/python/dudley/src/ElementFile.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26