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

Contents of /trunk/finley/src/ElementFile_optimizeDistribution.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 123 - (show annotations)
Fri Jul 8 04:08:13 2005 UTC (14 years, 7 months ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/ElementFile_optimizeDistribution.c
File MIME type: text/plain
File size: 3192 byte(s)
Merge of development branch back to main trunk on 2005-07-08

1 /* $Id$ */
2 /**************************************************************/
3 /* */
4 /* Finley: ElementFile */
5 /* */
6 /* reorders the elements in the element file such that the elements are stored close to the nodes */
7 /* */
8 /**************************************************************/
9
10 /* Copyrights by ACcESS Australia 2003/04 */
11 /* Author: gross@access.edu.au */
12 /* Version: $Id$ */
13
14 /**************************************************************/
15
16 #include "Finley.h"
17 #include "Util.h"
18 #include "ElementFile.h"
19
20 /**************************************************************/
21
22 void Finley_ElementFile_optimizeDistribution(Finley_ElementFile** in) {
23 Finley_Util_ValueAndIndex* item_list=NULL;
24 Finley_ElementFile* out=NULL;
25 dim_t e,i;
26 index_t *index=NULL;
27
28 if (*in != NULL) {
29 if ((*in)->numElements<1) return;
30 dim_t NN=(*in)->ReferenceElement->Type->numNodes;
31 item_list=TMPMEMALLOC((*in)->numElements,Finley_Util_ValueAndIndex);
32 index=TMPMEMALLOC((*in)->numElements,index_t);
33 if (! (Finley_checkPtr(item_list) || Finley_checkPtr(index)) ) {
34 out=Finley_ElementFile_alloc((*in)->ReferenceElement->Type->TypeId,(*in)->order);
35 if (Finley_ErrorCode==NO_ERROR) {
36 Finley_ElementFile_allocTable(out,(*in)->numElements);
37 if (Finley_ErrorCode==NO_ERROR) {
38 #pragma omp parallel for private(e,i) schedule(static)
39 for (e=0;e<(*in)->numElements;e++) {
40 item_list[e].index=e;
41 item_list[e].value=(*in)->Nodes[INDEX2(0,e,NN)];
42 for (i=1;i<NN;i++) item_list[e].value=MIN(item_list[e].value,(*in)->Nodes[INDEX2(i,e,NN)]);
43 }
44 Finley_Util_sortValueAndIndex((*in)->numElements,item_list);
45 #pragma omp parallel for private(e) schedule(static)
46 for (e=0;e<(*in)->numElements;e++) index[e]=item_list[e].index;
47 Finley_ElementFile_gather(index,*in,out);
48 Finley_ElementFile_dealloc(*in);
49 *in=out;
50 } else {
51 Finley_ElementFile_dealloc(out);
52 }
53 }
54 }
55 TMPMEMFREE(item_list);
56 TMPMEMFREE(index);
57 }
58 }
59 /*
60 * $Log$
61 * Revision 1.5 2005/07/08 04:07:50 jgs
62 * Merge of development branch back to main trunk on 2005-07-08
63 *
64 * Revision 1.4 2004/12/15 07:08:32 jgs
65 * *** empty log message ***
66 * Revision 1.1.1.1.2.2 2005/06/29 02:34:50 gross
67 * some changes towards 64 integers in finley
68 *
69 * Revision 1.1.1.1.2.1 2004/11/24 01:37:13 gross
70 * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
71 *
72 *
73 *
74 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26