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

Contents of /trunk-mpi-branch/finley/src/Mesh_distributeByRankOfDOF.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1264 - (show annotations)
Tue Aug 21 04:37:35 2007 UTC (12 years, 9 months ago) by gross
File MIME type: text/plain
File size: 3688 byte(s)
bug for case np=1 fixed. Should also fix problems for non-mpi version.
1 /*
2 ************************************************************
3 * Copyright 2007 by ACcESS MNRF *
4 * *
5 * http://www.access.edu.au *
6 * Primary Business: Queensland, Australia *
7 * Licensed under the Open Software License version 3.0 *
8 * http://www.opensource.org/licenses/osl-3.0.php *
9 * *
10 ************************************************************
11 */
12
13 /**************************************************************/
14
15 /* Finley: Mesh: this will redistribute the Nodes and Elements including overlap */
16 /* according to the dof_distribiution. It will create an element coloring but will not create any mappings. */
17
18 /**************************************************************/
19
20 /* Author: gross@access.edu.au */
21 /* Version: $Id:$ */
22
23 /**************************************************************/
24
25 #include "Mesh.h"
26
27 /**************************************************************/
28
29 void Finley_Mesh_distributeByRankOfDOF(Finley_Mesh* self, index_t *dof_distribution) {
30
31 index_t min_id, max_id, *tmp_node_localDOF_map=NULL, *tmp_node_localDOF_mask=NULL;
32 Paso_MPI_rank* mpiRankOfDOF=NULL;
33 register index_t k;
34 dim_t len,n,numDOFs;
35
36 if (self==NULL) return;
37 mpiRankOfDOF=TMPMEMALLOC(self->Nodes->numNodes,Paso_MPI_rank);
38 if (!Finley_checkPtr(mpiRankOfDOF)) {
39
40 Finley_NodeFile_assignMPIRankToDOFs(self->Nodes,mpiRankOfDOF,dof_distribution);
41 /* first the elements are redistributed according to mpiRankOfDOF */
42 /* at the input the Node tables refering to a the local labeling of the nodes */
43 /* while at the output they refer to the global labeling which is rectified in the next step */
44 if (Finley_noError()) Finley_ElementFile_distributeByRankOfDOF(self->Elements,mpiRankOfDOF, self->Nodes->Id);
45 if (Finley_noError()) Finley_ElementFile_distributeByRankOfDOF(self->FaceElements,mpiRankOfDOF, self->Nodes->Id);
46 if (Finley_noError()) Finley_ElementFile_distributeByRankOfDOF(self->ContactElements,mpiRankOfDOF, self->Nodes->Id);
47 if (Finley_noError()) Finley_ElementFile_distributeByRankOfDOF(self->Points,mpiRankOfDOF, self->Nodes->Id);
48
49 /* resolve the node ids */
50 if (Finley_noError()) Finley_Mesh_resolveNodeIds(self);
51
52 /* create a local labeling of the DOFs */
53 Finley_NodeFile_setDOFRange(&min_id,&max_id,self->Nodes);
54 len=max_id-min_id+1;
55 tmp_node_localDOF_mask=TMPMEMALLOC(len,index_t); /* local mask for used nodes */
56 tmp_node_localDOF_map=TMPMEMALLOC(len,index_t);
57 if (! ( (Finley_checkPtr(tmp_node_localDOF_mask) && Finley_checkPtr(tmp_node_localDOF_map) ) ) ) {
58
59 #pragma omp parallel for private(n) schedule(static)
60 for (n=0;n<len;n++) tmp_node_localDOF_mask[n]=-1;
61 #pragma omp parallel for private(n) schedule(static)
62 for (n=0;n<self->Nodes->numNodes;n++) tmp_node_localDOF_mask[self->Nodes->globalDegreesOfFreedom[n]-min_id]=n;
63
64 numDOFs=0;
65 for (n=0;n<len;n++) {
66 k=tmp_node_localDOF_mask[n];
67 if (k>=0) {
68 tmp_node_localDOF_map[k]=numDOFs;
69 numDOFs++;
70 }
71 }
72 /* create element coloring */
73 if (Finley_noError()) Finley_Mesh_createColoring(self,tmp_node_localDOF_map);
74
75 }
76 TMPMEMFREE(tmp_node_localDOF_mask);
77 TMPMEMFREE(tmp_node_localDOF_map);
78 }
79 TMPMEMFREE(mpiRankOfDOF);
80 return;
81 }

  ViewVC Help
Powered by ViewVC 1.1.26