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

Contents of /trunk/finley/src/NodeFile_allocTable.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2548 - (show annotations)
Mon Jul 20 06:20:06 2009 UTC (9 years, 11 months ago) by jfenwick
File MIME type: text/plain
File size: 5563 byte(s)
Updating copyright notices
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2009 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14
15 /**************************************************************/
16
17 /* Finley: Mesh: NodeFile */
18
19 /**************************************************************/
20
21 #include "NodeFile.h"
22 #include "Util.h"
23
24 /**************************************************************/
25
26 /* allocates the node table within an node file to hold numNodes of nodes. The LinearTo mapping, if it exists, */
27 /* is frees. use Finley_Mesh_setLinearMesh to create a new one. */
28
29 void Finley_NodeFile_allocTable(Finley_NodeFile* in ,dim_t numNodes)
30 {
31 index_t *Id2=NULL, *Tag2=NULL, *globalDegreesOfFreedom2=NULL, *globalReducedDOFIndex2=NULL,
32 *globalReducedNodesIndex2=NULL, *globalNodesIndex2=NULL, *reducedNodesId2=NULL, *degreesOfFreedomId2=NULL,
33 *reducedDegreesOfFreedomId2=NULL;
34 double *Coordinates2=NULL;
35 dim_t n,i;
36
37 /* allocate memory: */
38 Id2=MEMALLOC(numNodes,index_t);
39 Coordinates2=MEMALLOC(numNodes*in->numDim,double);
40 Tag2=MEMALLOC(numNodes,index_t);
41 globalDegreesOfFreedom2=MEMALLOC(numNodes,index_t);
42 globalReducedDOFIndex2=MEMALLOC(numNodes,index_t);
43 globalReducedNodesIndex2=MEMALLOC(numNodes,index_t);
44 globalNodesIndex2=MEMALLOC(numNodes,index_t);
45 reducedNodesId2=MEMALLOC(numNodes,index_t);
46 degreesOfFreedomId2=MEMALLOC(numNodes,index_t);
47 reducedDegreesOfFreedomId2=MEMALLOC(numNodes,index_t);
48
49 /* if fine, freeate the old table and replace by new: */
50 if (Finley_checkPtr(Id2) || Finley_checkPtr(Coordinates2) || Finley_checkPtr(Tag2)
51 || Finley_checkPtr(globalDegreesOfFreedom2)
52 || Finley_checkPtr(globalReducedDOFIndex2)
53 || Finley_checkPtr(globalReducedNodesIndex2)
54 || Finley_checkPtr(globalNodesIndex2)
55 || Finley_checkPtr(reducedNodesId2)
56 || Finley_checkPtr(degreesOfFreedomId2) ) {
57 MEMFREE(Id2);
58 MEMFREE(Coordinates2);
59 MEMFREE(Tag2);
60 MEMFREE(globalDegreesOfFreedom2);
61 MEMFREE(globalReducedDOFIndex2);
62 MEMFREE(globalReducedNodesIndex2);
63 MEMFREE(globalNodesIndex2);
64 MEMFREE(reducedNodesId2);
65 MEMFREE(degreesOfFreedomId2);
66 MEMFREE(reducedDegreesOfFreedomId2);
67 } else {
68 Finley_NodeFile_freeTable(in);
69 in->Id=Id2;
70 in->Coordinates=Coordinates2;
71 in->globalDegreesOfFreedom=globalDegreesOfFreedom2;
72 in->Tag=Tag2;
73 in->globalReducedDOFIndex=globalReducedDOFIndex2;
74 in->globalReducedNodesIndex=globalReducedNodesIndex2;
75 in->globalNodesIndex=globalNodesIndex2;
76 in->reducedNodesId=reducedNodesId2;
77 in->degreesOfFreedomId=degreesOfFreedomId2;
78 in->reducedDegreesOfFreedomId=reducedDegreesOfFreedomId2;
79 in->numNodes=numNodes;
80 /* this initialization makes sure that data are located on the right processor */
81 #pragma omp parallel for private(n,i) schedule(static)
82 for (n=0;n<numNodes;n++) {
83 in->Id[n]=-1;
84 for (i=0;i<in->numDim;i++) in->Coordinates[INDEX2(i,n,in->numDim)]=0.;
85 in->Tag[n]=-1;
86 in->globalDegreesOfFreedom[n]=-1;
87 in->globalReducedDOFIndex[n]=-1;
88 in->globalReducedNodesIndex[n]=-1;
89 in->globalNodesIndex[n]=-1;
90 in->reducedNodesId[n]=-1;
91 in->degreesOfFreedomId[n]=-1;
92 in->reducedDegreesOfFreedomId[n]=-1;
93 }
94 }
95 return;
96 }
97
98 /* frees the node table within an node file: */
99
100 void Finley_NodeFile_freeTable(Finley_NodeFile* in) {
101 if (in!=NULL) {
102 MEMFREE(in->Id);
103 MEMFREE(in->Coordinates);
104 MEMFREE(in->globalDegreesOfFreedom);
105 MEMFREE(in->globalReducedDOFIndex);
106 MEMFREE(in->globalReducedNodesIndex);
107 MEMFREE(in->globalNodesIndex);
108 MEMFREE(in->Tag);
109 MEMFREE(in->reducedNodesId);
110 MEMFREE(in->degreesOfFreedomId);
111 MEMFREE(in->reducedDegreesOfFreedomId);
112 MEMFREE(in->tagsInUse);
113 in->numTagsInUse=0;
114 Finley_NodeMapping_free(in->nodesMapping);
115 in->nodesMapping=NULL;
116 Finley_NodeMapping_free(in->reducedNodesMapping);
117 in->reducedNodesMapping=NULL;
118 Finley_NodeMapping_free(in->degreesOfFreedomMapping);
119 in->degreesOfFreedomMapping=NULL;
120 Finley_NodeMapping_free(in->reducedDegreesOfFreedomMapping);
121 in->reducedDegreesOfFreedomMapping=NULL;
122 Paso_Distribution_free(in->nodesDistribution);
123 in->nodesDistribution=NULL;
124 Paso_Distribution_free(in->reducedNodesDistribution);
125 in->nodesDistribution=NULL;
126 Paso_Distribution_free(in->degreesOfFreedomDistribution);
127 in->degreesOfFreedomDistribution=NULL;
128 Paso_Distribution_free(in->reducedDegreesOfFreedomDistribution);
129 in->reducedDegreesOfFreedomDistribution=NULL;
130 Paso_Connector_free(in->degreesOfFreedomConnector);
131 in->degreesOfFreedomConnector=NULL;
132 Paso_Connector_free(in->reducedDegreesOfFreedomConnector);
133 in->reducedDegreesOfFreedomConnector=NULL;
134
135 in->numTagsInUse=0;
136 in->numNodes=0;
137 }
138 }
139
140 void Finley_NodeFile_setTagsInUse(Finley_NodeFile* in)
141 {
142 index_t *tagsInUse=NULL;
143 dim_t numTagsInUse;
144 if (in != NULL) {
145 Finley_Util_setValuesInUse(in->Tag, in->numNodes, &numTagsInUse, &tagsInUse, in->MPIInfo);
146 if (Finley_noError()) {
147 MEMFREE(in->tagsInUse);
148 in->tagsInUse=tagsInUse;
149 in->numTagsInUse=numTagsInUse;
150 }
151 }
152 }
153

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26