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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 100 - (hide annotations)
Wed Dec 15 03:48:48 2004 UTC (14 years, 11 months ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/ElementFile_optimizeDistribution.c
File MIME type: text/plain
File size: 3063 byte(s)
*** empty log message ***

1 jgs 82 /* $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 jgs 100 item_list=(Finley_Util_ValueAndIndex*) TMPMEMALLOC((*in)->numElements*sizeof(Finley_Util_ValueAndIndex));
31     index=(maybelong*) TMPMEMALLOC((*in)->numElements*sizeof(maybelong));
32 jgs 82 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 jgs 100 * Revision 1.3 2004/12/15 03:48:45 jgs
61 jgs 97 * *** empty log message ***
62 jgs 82 *
63 jgs 97 * Revision 1.1.1.1 2004/10/26 06:53:57 jgs
64     * initial import of project esys2
65     *
66 jgs 82 * Revision 1.1.1.1 2004/06/24 04:00:40 johng
67     * Initial version of eys using boost-python.
68     *
69     *
70     */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26