/[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 3981 - (show annotations)
Fri Sep 21 02:47:54 2012 UTC (7 years, 2 months ago) by jfenwick
File MIME type: text/plain
File size: 5744 byte(s)
First pass of updating copyright notices
1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2012 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15
16
17 /************************************************************************************/
18
19 /* Finley: Mesh: NodeFile */
20
21 /************************************************************************************/
22
23 #include "NodeFile.h"
24 #include "Util.h"
25
26 /************************************************************************************/
27
28 /* allocates the node table within a node file to hold numNodes of nodes. The LinearTo mapping, if it exists, */
29 /* is freed. 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, free 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 MEMFREE(Id2);
60 MEMFREE(Coordinates2);
61 MEMFREE(Tag2);
62 MEMFREE(globalDegreesOfFreedom2);
63 MEMFREE(globalReducedDOFIndex2);
64 MEMFREE(globalReducedNodesIndex2);
65 MEMFREE(globalNodesIndex2);
66 MEMFREE(reducedNodesId2);
67 MEMFREE(degreesOfFreedomId2);
68 MEMFREE(reducedDegreesOfFreedomId2);
69 } else {
70 Finley_NodeFile_freeTable(in);
71 in->Id=Id2;
72 in->Coordinates=Coordinates2;
73 in->globalDegreesOfFreedom=globalDegreesOfFreedom2;
74 in->Tag=Tag2;
75 in->globalReducedDOFIndex=globalReducedDOFIndex2;
76 in->globalReducedNodesIndex=globalReducedNodesIndex2;
77 in->globalNodesIndex=globalNodesIndex2;
78 in->reducedNodesId=reducedNodesId2;
79 in->degreesOfFreedomId=degreesOfFreedomId2;
80 in->reducedDegreesOfFreedomId=reducedDegreesOfFreedomId2;
81 in->numNodes=numNodes;
82 /* this initialization makes sure that data are located on the right processor */
83 #pragma omp parallel for private(n,i) schedule(static)
84 for (n=0;n<numNodes;n++) {
85 in->Id[n]=-1;
86 for (i=0;i<in->numDim;i++) in->Coordinates[INDEX2(i,n,in->numDim)]=0.;
87 in->Tag[n]=-1;
88 in->globalDegreesOfFreedom[n]=-1;
89 in->globalReducedDOFIndex[n]=-1;
90 in->globalReducedNodesIndex[n]=-1;
91 in->globalNodesIndex[n]=-1;
92 in->reducedNodesId[n]=-1;
93 in->degreesOfFreedomId[n]=-1;
94 in->reducedDegreesOfFreedomId[n]=-1;
95 }
96 }
97 return;
98 }
99
100 /* frees the node table within a node file: */
101
102 void Finley_NodeFile_freeTable(Finley_NodeFile* in) {
103 if (in!=NULL) {
104 MEMFREE(in->Id);
105 MEMFREE(in->Coordinates);
106 MEMFREE(in->globalDegreesOfFreedom);
107 MEMFREE(in->globalReducedDOFIndex);
108 MEMFREE(in->globalReducedNodesIndex);
109 MEMFREE(in->globalNodesIndex);
110 MEMFREE(in->Tag);
111 MEMFREE(in->reducedNodesId);
112 MEMFREE(in->degreesOfFreedomId);
113 MEMFREE(in->reducedDegreesOfFreedomId);
114 MEMFREE(in->tagsInUse);
115 in->numTagsInUse=0;
116 Finley_NodeMapping_free(in->nodesMapping);
117 in->nodesMapping=NULL;
118 Finley_NodeMapping_free(in->reducedNodesMapping);
119 in->reducedNodesMapping=NULL;
120 Finley_NodeMapping_free(in->degreesOfFreedomMapping);
121 in->degreesOfFreedomMapping=NULL;
122 Finley_NodeMapping_free(in->reducedDegreesOfFreedomMapping);
123 in->reducedDegreesOfFreedomMapping=NULL;
124 Paso_Distribution_free(in->nodesDistribution);
125 in->nodesDistribution=NULL;
126 Paso_Distribution_free(in->reducedNodesDistribution);
127 in->nodesDistribution=NULL;
128 Paso_Distribution_free(in->degreesOfFreedomDistribution);
129 in->degreesOfFreedomDistribution=NULL;
130 Paso_Distribution_free(in->reducedDegreesOfFreedomDistribution);
131 in->reducedDegreesOfFreedomDistribution=NULL;
132 Paso_Connector_free(in->degreesOfFreedomConnector);
133 in->degreesOfFreedomConnector=NULL;
134 Paso_Connector_free(in->reducedDegreesOfFreedomConnector);
135 in->reducedDegreesOfFreedomConnector=NULL;
136
137 in->numTagsInUse=0;
138 in->numNodes=0;
139 }
140 }
141
142 void Finley_NodeFile_setTagsInUse(Finley_NodeFile* in)
143 {
144 index_t *tagsInUse=NULL;
145 dim_t numTagsInUse;
146 if (in != NULL) {
147 Finley_Util_setValuesInUse(in->Tag, in->numNodes, &numTagsInUse, &tagsInUse, in->MPIInfo);
148 if (Finley_noError()) {
149 MEMFREE(in->tagsInUse);
150 in->tagsInUse=tagsInUse;
151 in->numTagsInUse=numTagsInUse;
152 }
153 }
154 }
155

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26