/[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 1315 - (show annotations)
Tue Sep 25 02:41:13 2007 UTC (12 years ago) by ksteube
File MIME type: text/plain
File size: 3437 byte(s)
Copied more files from MPI branch to trunk

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

  ViewVC Help
Powered by ViewVC 1.1.26