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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26