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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1384 - (hide annotations)
Fri Jan 11 02:29:38 2008 UTC (11 years, 9 months ago) by phornby
Original Path: temp_trunk_copy/finley/src/Mesh_distributeByRankOfDOF.c
File MIME type: text/plain
File size: 4071 byte(s)
Make a temp copy of the trunk before checking in the windows changes


1 ksteube 1315
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 ksteube 1340 tmp_node_localDOF_map=TMPMEMALLOC(self->Nodes->numNodes,index_t);
55 ksteube 1315 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 ksteube 1340 #pragma omp parallel for private (n) schedule(static)
60     for (n=0;n<self->Nodes->numNodes;n++) tmp_node_localDOF_map[n]=-1;
61 ksteube 1315 #pragma omp parallel for private(n) schedule(static)
62 ksteube 1326 for (n=0;n<self->Nodes->numNodes;n++) {
63     #ifdef BOUNDS_CHECK
64     if ((self->Nodes->globalDegreesOfFreedom[n]-min_id) >= len || (self->Nodes->globalDegreesOfFreedom[n]-min_id) < 0) { printf("BOUNDS_CHECK %s %d\n", __FILE__, __LINE__); exit(1); }
65     #endif
66     tmp_node_localDOF_mask[self->Nodes->globalDegreesOfFreedom[n]-min_id]=n;
67     }
68 ksteube 1315
69     numDOFs=0;
70     for (n=0;n<len;n++) {
71     k=tmp_node_localDOF_mask[n];
72     if (k>=0) {
73 ksteube 1340 tmp_node_localDOF_mask[n]=numDOFs;
74 ksteube 1315 numDOFs++;
75     }
76     }
77 ksteube 1340 #pragma omp parallel for private (n,k)
78     for (n=0;n<self->Nodes->numNodes;n++) {
79     k=tmp_node_localDOF_mask[self->Nodes->globalDegreesOfFreedom[n]-min_id];
80     tmp_node_localDOF_map[n]=k;
81     }
82 ksteube 1315 /* create element coloring */
83     if (Finley_noError()) Finley_Mesh_createColoring(self,tmp_node_localDOF_map);
84    
85     }
86     TMPMEMFREE(tmp_node_localDOF_mask);
87     TMPMEMFREE(tmp_node_localDOF_map);
88     }
89     TMPMEMFREE(mpiRankOfDOF);
90     return;
91     }

  ViewVC Help
Powered by ViewVC 1.1.26