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

Annotation of /branches/domexper/dudley/src/Mesh_prepare.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3086 - (hide annotations)
Thu Aug 5 05:07:58 2010 UTC (9 years, 6 months ago) by jfenwick
File MIME type: text/plain
File size: 6346 byte(s)
Another pass at removing finley

1 jgs 150
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4 jfenwick 2881 * Copyright (c) 2003-2010 by University of Queensland
5 ksteube 1811 * 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 jgs 82
14 ksteube 1811
15 jgs 82 /**************************************************************/
16    
17 jfenwick 3086 /* Dudley: Mesh: prepares the mesh for further calculations */
18 jgs 82
19     /**************************************************************/
20    
21     #include "Mesh.h"
22    
23     /**************************************************************/
24    
25 jfenwick 3086 void Dudley_Mesh_prepare(Dudley_Mesh* in, bool_t optimize) {
26 ksteube 1312 dim_t newGlobalNumDOFs=0, numReducedNodes=0,i;
27 gross 1749 index_t* distribution=NULL, *maskReducedNodes=NULL, *indexReducedNodes=NULL, *node_distribution=NULL;
28 ksteube 1312 if (in==NULL) return;
29     if (in->Nodes == NULL) return;
30 jgs 82
31 gross 2856 Mesh_setOrders(in);
32    
33 ksteube 1312 /* first step is to distribute the elements according to a global distribution of DOF */
34 jgs 82
35 ksteube 1312 distribution=TMPMEMALLOC(in->MPIInfo->size+1,index_t);
36 gross 1749 node_distribution=TMPMEMALLOC(in->MPIInfo->size+1,index_t);
37 jfenwick 3086 if (! (Dudley_checkPtr(distribution) || Dudley_checkPtr(node_distribution))) {
38 ksteube 1312 /* first we create dense labeling for the DOFs */
39 gross 1766
40 jfenwick 3086 newGlobalNumDOFs=Dudley_NodeFile_createDenseDOFLabeling(in->Nodes);
41 jgs 82
42 ksteube 1312 /* create a distribution of the global DOFs and determine
43     the MPI_rank controling the DOFs on this processor */
44     Paso_MPIInfo_setDistribution(in->MPIInfo,0,newGlobalNumDOFs-1,distribution);
45 gross 964
46 ksteube 1312 /* now the mesh is re-distributed according to the mpiRankOfDOF vector */
47     /* this will redistribute the Nodes and Elements including overlap and will create an element coloring
48     but will not create any mappings (see later in this function) */
49 jfenwick 3086 if (Dudley_noError()) Dudley_Mesh_distributeByRankOfDOF(in,distribution);
50 ksteube 1312 }
51 gross 964
52 ksteube 1312 /* at this stage we are able to start an optimization of the DOF distribution using ParaMetis */
53     /* on return distribution is altered and new DOF ids have been assigned */
54 jfenwick 3086 if (Dudley_noError() && optimize && in->MPIInfo->size>1) {
55     Dudley_Mesh_optimizeDOFDistribution(in,distribution);
56     if (Dudley_noError()) Dudley_Mesh_distributeByRankOfDOF(in,distribution);
57 ksteube 1312 }
58 gross 1766 /* the local labeling of the degrees of free is optimized */
59 jfenwick 3086 if (Dudley_noError() && optimize) {
60     Dudley_Mesh_optimizeDOFLabeling(in,distribution);
61 ksteube 1312 }
62     /* rearrange elements with the attempt to bring elements closer to memory locations of the nodes (distributed shared memory!): */
63 jfenwick 3086 if (Dudley_noError()) Dudley_Mesh_optimizeElementOrdering(in);
64 ksteube 1312
65    
66     /* create the global indices */
67 jfenwick 3086 if (Dudley_noError()) {
68 gross 1766
69    
70 ksteube 1312 maskReducedNodes=TMPMEMALLOC(in->Nodes->numNodes,index_t);
71     indexReducedNodes=TMPMEMALLOC(in->Nodes->numNodes,index_t);
72 jfenwick 3086 if (! ( Dudley_checkPtr(maskReducedNodes) || Dudley_checkPtr(indexReducedNodes) ) ) {
73 ksteube 1312
74 gross 1766 /* useful DEBUG:
75     {index_t MIN_id,MAX_id;
76     printf("Mesh_prepare: global DOF : %d\n",newGlobalNumDOFs);
77 jfenwick 3086 Dudley_NodeFile_setGlobalIdRange(&MIN_id,&MAX_id,in->Nodes);
78 gross 1766 printf("Mesh_prepare: global node id range = %d :%d\n", MIN_id,MAX_id);
79 jfenwick 3086 Dudley_NodeFile_setIdRange(&MIN_id,&MAX_id,in->Nodes);
80 gross 1766 printf("Mesh_prepare: local node id range = %d :%d\n", MIN_id,MAX_id);
81     }
82     */
83 ksteube 1312 #pragma omp parallel for private(i) schedule(static)
84     for (i=0;i<in->Nodes->numNodes;++i) maskReducedNodes[i]=-1;
85    
86 jfenwick 3086 Dudley_Mesh_markNodes(maskReducedNodes,0,in,TRUE);
87 ksteube 1312
88 jfenwick 3086 numReducedNodes=Dudley_Util_packMask(in->Nodes->numNodes,maskReducedNodes,indexReducedNodes);
89 ksteube 1312
90 jfenwick 3086 Dudley_NodeFile_createDenseNodeLabeling(in->Nodes, node_distribution, distribution);
91     Dudley_NodeFile_createDenseReducedDOFLabeling(in->Nodes,maskReducedNodes);
92     Dudley_NodeFile_createDenseReducedNodeLabeling(in->Nodes,maskReducedNodes);
93 ksteube 1312 /* create the missing mappings */
94 gross 1766
95 jfenwick 3086 if (Dudley_noError()) Dudley_Mesh_createNodeFileMappings(in,numReducedNodes,indexReducedNodes,distribution, node_distribution);
96 ksteube 1312 }
97    
98     TMPMEMFREE(maskReducedNodes);
99     TMPMEMFREE(indexReducedNodes);
100     }
101    
102     TMPMEMFREE(distribution);
103 gross 1749 TMPMEMFREE(node_distribution);
104 ksteube 1312
105 jfenwick 3086 Dudley_Mesh_setTagsInUse(in);
106 ksteube 1312 return;
107 gross 964 }
108 ksteube 1312
109 jgs 82 /* */
110     /* tries to reduce the coloring for all element files: */
111     /* */
112 jfenwick 3086 void Dudley_Mesh_createColoring(Dudley_Mesh* in, index_t *node_localDOF_map) {
113     if (Dudley_noError()) Dudley_ElementFile_createColoring(in->Elements,in->Nodes->numNodes,node_localDOF_map);
114     if (Dudley_noError()) Dudley_ElementFile_createColoring(in->FaceElements,in->Nodes->numNodes,node_localDOF_map);
115     if (Dudley_noError()) Dudley_ElementFile_createColoring(in->Points,in->Nodes->numNodes,node_localDOF_map);
116     if (Dudley_noError()) Dudley_ElementFile_createColoring(in->ContactElements,in->Nodes->numNodes,node_localDOF_map);
117 jgs 82 }
118     /* */
119     /* redistribute elements to minimize communication during assemblage */
120     /* */
121 jfenwick 3086 void Dudley_Mesh_optimizeElementOrdering(Dudley_Mesh* in) {
122     if (Dudley_noError()) Dudley_ElementFile_optimizeOrdering(&(in->Elements));
123     if (Dudley_noError()) Dudley_ElementFile_optimizeOrdering(&(in->FaceElements));
124     if (Dudley_noError()) Dudley_ElementFile_optimizeOrdering(&(in->Points));
125     if (Dudley_noError()) Dudley_ElementFile_optimizeOrdering(&(in->ContactElements));
126 jgs 82 }
127 gross 1716
128     /* */
129     /* redistribute elements to minimize communication during assemblage */
130 jfenwick 3086 void Dudley_Mesh_setTagsInUse(Dudley_Mesh* in)
131 gross 1716 {
132 jfenwick 3086 if (Dudley_noError()) Dudley_NodeFile_setTagsInUse(in->Nodes);
133     if (Dudley_noError()) Dudley_ElementFile_setTagsInUse(in->Elements);
134     if (Dudley_noError()) Dudley_ElementFile_setTagsInUse(in->FaceElements);
135     if (Dudley_noError()) Dudley_ElementFile_setTagsInUse(in->Points);
136     if (Dudley_noError()) Dudley_ElementFile_setTagsInUse(in->ContactElements);
137 gross 1716 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26