/[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 1552 - (show annotations)
Thu May 8 08:52:41 2008 UTC (11 years, 4 months ago) by gross
File MIME type: text/plain
File size: 5172 byte(s)
some changes to make the implementatiopn of a upwind MPI version easier
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
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 reducedDegreesOfFreedomId2=MEMALLOC(numNodes,index_t);
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 for (i=0;i<in->numDim;i++) in->Coordinates[INDEX2(i,n,in->numDim)]=0.;
85 in->Id[n]=-1;
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 Finley_NodeMapping_free(in->nodesMapping);
114 in->nodesMapping=NULL;
115 Finley_NodeMapping_free(in->reducedNodesMapping);
116 in->reducedNodesMapping=NULL;
117 Finley_NodeMapping_free(in->degreesOfFreedomMapping);
118 in->degreesOfFreedomMapping=NULL;
119 Finley_NodeMapping_free(in->reducedDegreesOfFreedomMapping);
120 in->reducedDegreesOfFreedomMapping=NULL;
121 Paso_Distribution_free(in->nodesDistribution);
122 in->nodesDistribution=NULL;
123 Paso_Distribution_free(in->reducedNodesDistribution);
124 in->nodesDistribution=NULL;
125 Paso_Distribution_free(in->degreesOfFreedomDistribution);
126 in->degreesOfFreedomDistribution=NULL;
127 Paso_Distribution_free(in->reducedDegreesOfFreedomDistribution);
128 in->reducedDegreesOfFreedomDistribution=NULL;
129 Paso_Connector_free(in->degreesOfFreedomConnector);
130 in->degreesOfFreedomConnector=NULL;
131 Paso_Connector_free(in->reducedDegreesOfFreedomConnector);
132 in->reducedDegreesOfFreedomConnector=NULL;
133
134 in->numNodes=0;
135 }
136 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26