/[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 964 - (show annotations)
Tue Feb 13 05:10:26 2007 UTC (12 years, 8 months ago) by gross
File MIME type: text/plain
File size: 4585 byte(s)
The set/getRefVal functions of Data objects have been removed (mainly to avoid later problems with MPI).
Moreover, a faster access to the reference id of samples has been introduced. I don't think that anybody will
profit form this at this stage but it will allow a faster dump of data objects.


1 /*
2 ************************************************************
3 * Copyright 2006 by ACcESS MNRF *
4 * *
5 * http://www.access.edu.au *
6 * Primary Business: Queensland, Australia *
7 * Licensed under the Open Software License version 3.0 *
8 * http://www.opensource.org/licenses/osl-3.0.php *
9 * *
10 ************************************************************
11 */
12
13 /**************************************************************/
14
15 /* Finley: Mesh: NodeFile */
16
17 /**************************************************************/
18
19 /* Author: gross@access.edu.au */
20 /* Version: $Id$ */
21
22 /**************************************************************/
23
24 #include "NodeFile.h"
25
26 /**************************************************************/
27
28 /* allocates the node table within an node file to hold numNodes of nodes. The LinearTo mapping, if it exists, */
29 /* is deallocated. 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, *degreeOfFreedom2=NULL, *reducedDegreeOfFreedom2=NULL, *toReduced2=NULL;
34 #ifdef PASO_MPI
35 index_t *Dom2=NULL;
36 #endif
37 double *Coordinates2=NULL;
38 dim_t n,i;
39
40 /* allocate memory: */
41 #ifdef PASO_MPI
42 Dom2=MEMALLOC(numNodes,index_t);
43 #endif
44 Id2=MEMALLOC(numNodes,index_t);
45 Coordinates2=MEMALLOC(numNodes*in->numDim,double);
46 Tag2=MEMALLOC(numNodes,index_t);
47 degreeOfFreedom2=MEMALLOC(numNodes,index_t);
48 reducedDegreeOfFreedom2=MEMALLOC(numNodes,index_t);
49 toReduced2=MEMALLOC(numNodes,index_t);
50
51 /* if fine, deallocate the old table and replace by new: */
52 #ifdef PASO_MPI
53 if (Finley_checkPtr(Id2) || Finley_checkPtr(Coordinates2) || Finley_checkPtr(Tag2) || Finley_checkPtr(Dom2) ||
54 Finley_checkPtr(degreeOfFreedom2) || Finley_checkPtr(reducedDegreeOfFreedom2) || Finley_checkPtr(toReduced2) ) {
55 MEMFREE( Dom2 );
56 #else
57 if (Finley_checkPtr(Id2) || Finley_checkPtr(Coordinates2) || Finley_checkPtr(Tag2) ||
58 Finley_checkPtr(degreeOfFreedom2) || Finley_checkPtr(reducedDegreeOfFreedom2) || Finley_checkPtr(toReduced2) ) {
59 #endif
60 MEMFREE(Id2);
61 MEMFREE(Coordinates2);
62 MEMFREE(Tag2);
63 MEMFREE(degreeOfFreedom2);
64 MEMFREE(reducedDegreeOfFreedom2);
65 MEMFREE(toReduced2);
66 } else {
67 Finley_NodeFile_deallocTable(in);
68 #ifdef PASO_MPI
69 in->Dom=Dom2;
70 #endif
71 in->Id=Id2;
72 in->Coordinates=Coordinates2;
73 in->Tag=Tag2;
74 in->degreeOfFreedom=degreeOfFreedom2;
75 in->reducedDegreeOfFreedom=reducedDegreeOfFreedom2;
76 in->toReduced=toReduced2;
77 in->numNodes=numNodes;
78 in->numDegreesOfFreedom=numNodes;
79 in->reducedNumDegreesOfFreedom=numNodes;
80 in->reducedNumNodes=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 #ifdef PASO_MPI
86 in->Dom[n]=-1;
87 #endif
88 in->Id[n]=-1;
89 in->Tag[n]=-1;
90 in->degreeOfFreedom[n]=n;
91 in->reducedDegreeOfFreedom[n]=n;
92 in->toReduced[n]=n;
93 }
94 }
95 return;
96 }
97
98 /* deallocates the node table within an node file: */
99
100 void Finley_NodeFile_deallocTable(Finley_NodeFile* in) {
101 if (in!=NULL) {
102 #ifdef PASO_MPI
103 MEMFREE(in->Dom);
104 #endif
105 MEMFREE(in->Id);
106 MEMFREE(in->Coordinates);
107 MEMFREE(in->Tag);
108 MEMFREE(in->degreeOfFreedom);
109 MEMFREE(in->degreeOfFreedomId);
110 MEMFREE(in->reducedDegreeOfFreedom);
111 MEMFREE(in->reducedDegreeOfFreedomId);
112 MEMFREE(in->toReduced);
113 in->numNodes=0;
114 in->numDegreesOfFreedom=0;
115 in->reducedNumDegreesOfFreedom=0;
116 in->reducedNumNodes=0;
117 }
118 }
119 /*
120 * $Log$
121 * Revision 1.6 2005/09/15 03:44:23 jgs
122 * Merge of development branch dev-02 back to main trunk on 2005-09-15
123 *
124 * Revision 1.5.2.1 2005/09/07 06:26:20 gross
125 * the solver from finley are put into the standalone package paso now
126 *
127 * Revision 1.5 2005/07/08 04:07:55 jgs
128 * Merge of development branch back to main trunk on 2005-07-08
129 *
130 * Revision 1.4 2004/12/15 07:08:33 jgs
131 * *** empty log message ***
132 * Revision 1.1.1.1.2.2 2005/06/29 02:34:54 gross
133 * some changes towards 64 integers in finley
134 *
135 * Revision 1.1.1.1.2.1 2004/11/24 01:37:15 gross
136 * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
137 *
138 *
139 *
140 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26