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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1230 - (show annotations)
Thu Aug 9 06:19:35 2007 UTC (12 years, 9 months ago) by gross
File MIME type: text/plain
File size: 5026 byte(s)
the mappings of nodes of local and global DOFs added but program still crashes.

1 /*
2 ************************************************************
3 * Copyright 2006 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: NodeFile */
16
17 /**************************************************************/
18
19 /* Author: gross@access.edu.au */
20 /* Version: $Id$ */
21
22 /**************************************************************/
23
24 #include "NodeFile.h"
25
26 /**************************************************************/
27
28 /* allocates the node table within an node file to hold numNodes of nodes. The LinearTo mapping, if it exists, */
29 /* is frees. use Finley_Mesh_setLinearMesh to create a new one. */
30
31 void Finley_NodeFile_allocTable(Finley_NodeFile* in ,dim_t numNodes)
32 {
33 index_t *Id2=NULL, *Tag2=NULL, *globalDegreesOfFreedom2=NULL, *globalReducedDOFIndex2=NULL,
34 *globalReducedNodesIndex2=NULL, *globalNodesIndex2=NULL, *reducedNodesId2=NULL, *degreesOfFreedomId2=NULL,
35 *reducedDegreesOfFreedomId2=NULL;
36 double *Coordinates2=NULL;
37 dim_t n,i;
38
39 /* allocate memory: */
40 Id2=MEMALLOC(numNodes,index_t);
41 Coordinates2=MEMALLOC(numNodes*in->numDim,double);
42 Tag2=MEMALLOC(numNodes,index_t);
43 globalDegreesOfFreedom2=MEMALLOC(numNodes,index_t);
44 globalReducedDOFIndex2=MEMALLOC(numNodes,index_t);
45 globalReducedNodesIndex2=MEMALLOC(numNodes,index_t);
46 globalNodesIndex2=MEMALLOC(numNodes,index_t);
47 reducedNodesId2=MEMALLOC(numNodes,index_t);
48 degreesOfFreedomId2=MEMALLOC(numNodes,index_t);
49 reducedDegreesOfFreedomId2=MEMALLOC(numNodes,index_t);
50
51 /* if fine, freeate the old table and replace by new: */
52 if (Finley_checkPtr(Id2) || Finley_checkPtr(Coordinates2) || Finley_checkPtr(Tag2)
53 || Finley_checkPtr(globalDegreesOfFreedom2)
54 || Finley_checkPtr(globalReducedDOFIndex2)
55 || Finley_checkPtr(globalReducedNodesIndex2)
56 || Finley_checkPtr(globalNodesIndex2)
57 || Finley_checkPtr(reducedNodesId2)
58 || Finley_checkPtr(degreesOfFreedomId2) ) {
59 reducedDegreesOfFreedomId2=MEMALLOC(numNodes,index_t);
60 MEMFREE(Id2);
61 MEMFREE(Coordinates2);
62 MEMFREE(Tag2);
63 MEMFREE(globalDegreesOfFreedom2);
64 MEMFREE(globalReducedDOFIndex2);
65 MEMFREE(globalReducedNodesIndex2);
66 MEMFREE(globalNodesIndex2);
67 MEMFREE(reducedNodesId2);
68 MEMFREE(degreesOfFreedomId2);
69 MEMFREE(reducedDegreesOfFreedomId2);
70 } else {
71 Finley_NodeFile_freeTable(in);
72 in->Id=Id2;
73 in->Coordinates=Coordinates2;
74 in->globalDegreesOfFreedom=globalDegreesOfFreedom2;
75 in->Tag=Tag2;
76 in->globalReducedDOFIndex=globalReducedDOFIndex2;
77 in->globalReducedNodesIndex=globalReducedNodesIndex2;
78 in->globalNodesIndex=globalNodesIndex2;
79 in->reducedNodesId=reducedNodesId2;
80 in->degreesOfFreedomId=degreesOfFreedomId2;
81 in->reducedDegreesOfFreedomId=reducedDegreesOfFreedomId2;
82 in->numNodes=numNodes;
83 /* this initialization makes sure that data are located on the right processor */
84 #pragma omp parallel for private(n,i) schedule(static)
85 for (n=0;n<numNodes;n++) {
86 for (i=0;i<in->numDim;i++) in->Coordinates[INDEX2(i,n,in->numDim)]=0.;
87 in->Id[n]=-1;
88 in->Tag[n]=-1;
89 in->globalDegreesOfFreedom[n]=-1;
90 in->globalReducedDOFIndex[n]=-1;
91 in->globalReducedNodesIndex[n]=-1;
92 in->globalNodesIndex[n]=-1;
93 in->reducedNodesId[n]=-1;
94 in->degreesOfFreedomId[n]=-1;
95 in->reducedDegreesOfFreedomId[n]=-1;
96 }
97 }
98 return;
99 }
100
101 /* frees the node table within an node file: */
102
103 void Finley_NodeFile_freeTable(Finley_NodeFile* in) {
104 if (in!=NULL) {
105 MEMFREE(in->Id);
106 MEMFREE(in->Coordinates);
107 MEMFREE(in->globalDegreesOfFreedom);
108 MEMFREE(in->globalReducedDOFIndex);
109 MEMFREE(in->globalReducedNodesIndex);
110 MEMFREE(in->globalNodesIndex);
111 MEMFREE(in->Tag);
112 MEMFREE(in->reducedNodesId);
113 MEMFREE(in->degreesOfFreedomId);
114 MEMFREE(in->reducedDegreesOfFreedomId);
115 Finley_NodeMapping_free(in->nodesMapping);
116 Finley_NodeMapping_free(in->reducedNodesMapping);
117 Finley_NodeMapping_free(in->degreesOfFreedomMapping);
118 Finley_NodeMapping_free(in->reducedDegreesOfFreedomMapping);
119 Paso_Distribution_free(in->nodesDistribution);
120 Paso_Distribution_free(in->reducedNodesDistribution);
121 Paso_Distribution_free(in->degreesOfFreedomDistribution);
122 Paso_Distribution_free(in->reducedDegreesOfFreedomDistribution);
123 Paso_Coupler_free(in->degreesOfFreedomCoupler);
124 Paso_Coupler_free(in->reducedDegreesOfFreedomCoupler);
125
126 in->numNodes=0;
127 }
128 }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26