/[escript]/trunk/finley/src/Mesh_prepare.cpp
ViewVC logotype

Annotation of /trunk/finley/src/Mesh_prepare.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (hide annotations)
Thu Sep 25 23:11:13 2008 UTC (10 years, 8 months ago) by ksteube
Original Path: trunk/finley/src/Mesh_prepare.c
File MIME type: text/plain
File size: 6320 byte(s)
Copyright updated in all files

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26