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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3259 - (show annotations)
Mon Oct 11 01:48:14 2010 UTC (9 years, 2 months ago) by jfenwick
File MIME type: text/plain
File size: 4094 byte(s)
Merging dudley and scons updates from branches

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 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
14
15 /**************************************************************/
16
17 /* Finley: Mesh: this will redistribute the Nodes and Elements including overlap */
18 /* according to the dof_distribiution. It will create an element coloring but will not create any mappings. */
19
20 /**************************************************************/
21
22 #include "Mesh.h"
23
24 /**************************************************************/
25
26 void Finley_Mesh_distributeByRankOfDOF(Finley_Mesh* self, index_t *dof_distribution) {
27
28 index_t min_dof_id, max_dof_id, *tmp_node_localDOF_map=NULL, *tmp_node_localDOF_mask=NULL;
29 Esys_MPI_rank* mpiRankOfDOF=NULL;
30 register index_t k;
31 dim_t len,n,numDOFs;
32
33 if (self==NULL) return;
34 mpiRankOfDOF=TMPMEMALLOC(self->Nodes->numNodes,Esys_MPI_rank);
35 if (!Finley_checkPtr(mpiRankOfDOF)) {
36
37
38 Finley_NodeFile_assignMPIRankToDOFs(self->Nodes,mpiRankOfDOF,dof_distribution);
39
40 /* first the elements are redistributed according to mpiRankOfDOF */
41 /* at the input the Node tables refering to a the local labeling of the nodes */
42 /* while at the output they refer to the global labeling which is rectified in the next step */
43 if (Finley_noError()) Finley_ElementFile_distributeByRankOfDOF(self->Elements,mpiRankOfDOF, self->Nodes->Id);
44 if (Finley_noError()) Finley_ElementFile_distributeByRankOfDOF(self->FaceElements,mpiRankOfDOF, self->Nodes->Id);
45 if (Finley_noError()) Finley_ElementFile_distributeByRankOfDOF(self->ContactElements,mpiRankOfDOF, self->Nodes->Id);
46 if (Finley_noError()) Finley_ElementFile_distributeByRankOfDOF(self->Points,mpiRankOfDOF, self->Nodes->Id);
47
48 /* resolve the node ids */
49 if (Finley_noError()) Finley_Mesh_resolveNodeIds(self);
50
51 /* create a local labeling of the DOFs */
52 Finley_NodeFile_setDOFRange(&min_dof_id,&max_dof_id,self->Nodes);
53 len=max_dof_id-min_dof_id+1;
54 tmp_node_localDOF_mask=TMPMEMALLOC(len,index_t); /* local mask for used nodes */
55 tmp_node_localDOF_map=TMPMEMALLOC(self->Nodes->numNodes,index_t);
56 if (! ( (Finley_checkPtr(tmp_node_localDOF_mask) && Finley_checkPtr(tmp_node_localDOF_map) ) ) ) {
57
58 #pragma omp parallel for private(n) schedule(static)
59 for (n=0;n<len;n++) tmp_node_localDOF_mask[n]=-1;
60
61 #pragma omp parallel for private (n) schedule(static)
62 for (n=0;n<self->Nodes->numNodes;n++) tmp_node_localDOF_map[n]=-1;
63
64 #pragma omp parallel for private(n) schedule(static)
65 for (n=0;n<self->Nodes->numNodes;n++) {
66 #ifdef BOUNDS_CHECK
67 if ((self->Nodes->globalDegreesOfFreedom[n]-min_dof_id) >= len || (self->Nodes->globalDegreesOfFreedom[n]-min_dof_id) < 0) { printf("BOUNDS_CHECK %s %d\n", __FILE__, __LINE__); exit(1); }
68 #endif
69 tmp_node_localDOF_mask[self->Nodes->globalDegreesOfFreedom[n]-min_dof_id]=n;
70 }
71
72 numDOFs=0;
73 for (n=0;n<len;n++) {
74 k=tmp_node_localDOF_mask[n];
75 if (k>=0) {
76 tmp_node_localDOF_mask[n]=numDOFs;
77 numDOFs++;
78 }
79 }
80 #pragma omp parallel for private (n,k)
81 for (n=0;n<self->Nodes->numNodes;n++) {
82 k=tmp_node_localDOF_mask[self->Nodes->globalDegreesOfFreedom[n]-min_dof_id];
83 tmp_node_localDOF_map[n]=k;
84 }
85 /* create element coloring */
86 if (Finley_noError()) Finley_Mesh_createColoring(self,tmp_node_localDOF_map);
87
88 }
89 TMPMEMFREE(tmp_node_localDOF_mask);
90 TMPMEMFREE(tmp_node_localDOF_map);
91 }
92 TMPMEMFREE(mpiRankOfDOF);
93 return;
94 }

  ViewVC Help
Powered by ViewVC 1.1.26