/[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 102 - (show annotations)
Wed Dec 15 07:08:39 2004 UTC (14 years, 10 months ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/ElementFile_optimizeDistribution.c
File MIME type: text/plain
File size: 2832 byte(s)
*** empty log message ***

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 maybelong* index=NULL,e,i;
26
27 if (*in != NULL) {
28 if ((*in)->numElements<1) return;
29 maybelong NN=(*in)->ReferenceElement->Type->numNodes;
30 item_list=TMPMEMALLOC((*in)->numElements,Finley_Util_ValueAndIndex);
31 index=TMPMEMALLOC((*in)->numElements,maybelong);
32 if (! (Finley_checkPtr(item_list) || Finley_checkPtr(index)) ) {
33 out=Finley_ElementFile_alloc((*in)->ReferenceElement->Type->TypeId,(*in)->order);
34 if (Finley_ErrorCode==NO_ERROR) {
35 Finley_ElementFile_allocTable(out,(*in)->numElements);
36 if (Finley_ErrorCode==NO_ERROR) {
37 #pragma omp parallel for private(e,i) schedule(static)
38 for (e=0;e<(*in)->numElements;e++) {
39 item_list[e].index=e;
40 item_list[e].value=(*in)->Nodes[INDEX2(0,e,NN)];
41 for (i=1;i<NN;i++) item_list[e].value=MIN(item_list[e].value,(*in)->Nodes[INDEX2(i,e,NN)]);
42 }
43 Finley_Util_sortValueAndIndex((*in)->numElements,item_list);
44 #pragma omp parallel for private(e) schedule(static)
45 for (e=0;e<(*in)->numElements;e++) index[e]=item_list[e].index;
46 Finley_ElementFile_gather(index,*in,out);
47 Finley_ElementFile_dealloc(*in);
48 *in=out;
49 } else {
50 Finley_ElementFile_dealloc(out);
51 }
52 }
53 }
54 TMPMEMFREE(item_list);
55 TMPMEMFREE(index);
56 }
57 }
58 /*
59 * $Log$
60 * Revision 1.4 2004/12/15 07:08:32 jgs
61 * *** empty log message ***
62 *
63 *
64 *
65 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26