/[escript]/branches/arrayview_from_1695_trunk/finley/src/Mesh_distributeByRankOfDOF.c
ViewVC logotype

Annotation of /branches/arrayview_from_1695_trunk/finley/src/Mesh_distributeByRankOfDOF.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1781 - (hide annotations)
Thu Sep 11 05:03:14 2008 UTC (10 years, 8 months ago) by jfenwick
File MIME type: text/plain
File size: 4129 byte(s)
Branch commit

Merged changes from trunk version 1695 up to and including version 1779.


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 jfenwick 1781 index_t min_dof_id, max_dof_id, *tmp_node_localDOF_map=NULL, *tmp_node_localDOF_mask=NULL;
30 ksteube 1315 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 jfenwick 1781
39 ksteube 1315 Finley_NodeFile_assignMPIRankToDOFs(self->Nodes,mpiRankOfDOF,dof_distribution);
40 jfenwick 1781
41 ksteube 1315 /* 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 jfenwick 1781 Finley_NodeFile_setDOFRange(&min_dof_id,&max_dof_id,self->Nodes);
54     len=max_dof_id-min_dof_id+1;
55 ksteube 1315 tmp_node_localDOF_mask=TMPMEMALLOC(len,index_t); /* local mask for used nodes */
56 ksteube 1340 tmp_node_localDOF_map=TMPMEMALLOC(self->Nodes->numNodes,index_t);
57 ksteube 1315 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 jfenwick 1781
62 ksteube 1340 #pragma omp parallel for private (n) schedule(static)
63     for (n=0;n<self->Nodes->numNodes;n++) tmp_node_localDOF_map[n]=-1;
64 jfenwick 1781
65 ksteube 1315 #pragma omp parallel for private(n) schedule(static)
66 ksteube 1326 for (n=0;n<self->Nodes->numNodes;n++) {
67 jfenwick 1781 #ifdef BOUNDS_CHECK
68     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); }
69     #endif
70     tmp_node_localDOF_mask[self->Nodes->globalDegreesOfFreedom[n]-min_dof_id]=n;
71 ksteube 1326 }
72 ksteube 1315
73     numDOFs=0;
74     for (n=0;n<len;n++) {
75     k=tmp_node_localDOF_mask[n];
76     if (k>=0) {
77 ksteube 1340 tmp_node_localDOF_mask[n]=numDOFs;
78 ksteube 1315 numDOFs++;
79     }
80     }
81 ksteube 1340 #pragma omp parallel for private (n,k)
82     for (n=0;n<self->Nodes->numNodes;n++) {
83 jfenwick 1781 k=tmp_node_localDOF_mask[self->Nodes->globalDegreesOfFreedom[n]-min_dof_id];
84 ksteube 1340 tmp_node_localDOF_map[n]=k;
85     }
86 ksteube 1315 /* create element coloring */
87     if (Finley_noError()) Finley_Mesh_createColoring(self,tmp_node_localDOF_map);
88    
89     }
90     TMPMEMFREE(tmp_node_localDOF_mask);
91     TMPMEMFREE(tmp_node_localDOF_map);
92     }
93     TMPMEMFREE(mpiRankOfDOF);
94     return;
95     }

  ViewVC Help
Powered by ViewVC 1.1.26