/[escript]/branches/doubleplusgood/finley/src/NodeFile_allocTable.cpp
ViewVC logotype

Contents of /branches/doubleplusgood/finley/src/NodeFile_allocTable.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4327 - (show annotations)
Wed Mar 20 05:09:11 2013 UTC (6 years, 6 months ago) by jfenwick
File size: 5694 byte(s)
some finley memory
1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 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=new index_t[numNodes];
41 Coordinates2=new double[numNodes*in->numDim];
42 Tag2=new index_t[numNodes];
43 globalDegreesOfFreedom2=new index_t[numNodes];
44 globalReducedDOFIndex2=new index_t[numNodes];
45 globalReducedNodesIndex2=new index_t[numNodes];
46 globalNodesIndex2=new index_t[numNodes];
47 reducedNodesId2=new index_t[numNodes];
48 degreesOfFreedomId2=new index_t[numNodes];
49 reducedDegreesOfFreedomId2=new index_t[numNodes];
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 delete[] Id2;
60 delete[] Coordinates2;
61 delete[] Tag2;
62 delete[] globalDegreesOfFreedom2;
63 delete[] globalReducedDOFIndex2;
64 delete[] globalReducedNodesIndex2;
65 delete[] globalNodesIndex2;
66 delete[] reducedNodesId2;
67 delete[] degreesOfFreedomId2;
68 delete[] 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 delete[] in->Id;
105 delete[] in->Coordinates;
106 delete[] in->globalDegreesOfFreedom;
107 delete[] in->globalReducedDOFIndex;
108 delete[] in->globalReducedNodesIndex;
109 delete[] in->globalNodesIndex;
110 delete[] in->Tag;
111 delete[] in->reducedNodesId;
112 delete[] in->degreesOfFreedomId;
113 delete[] in->reducedDegreesOfFreedomId;
114 delete[] 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 delete[] 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