/[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 82 - (show annotations)
Tue Oct 26 06:53:54 2004 UTC (15 years ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/NodeFile_allocTable.c
File MIME type: text/plain
File size: 3141 byte(s)
Initial revision

1 /* $Id$ */
2 /**************************************************************/
3
4 /* Finley: Mesh: NodeFile */
5
6 /**************************************************************/
7
8 /* Copyrights by ACcESS Australia 2003 */
9 /* Author: gross@access.edu.au */
10 /* Version: $Id$ */
11
12 /**************************************************************/
13
14 #include "Finley.h"
15 #include "NodeFile.h"
16
17 /**************************************************************/
18
19 /* allocates the node table within an node file to hold numNodes of nodes. The LinearTo mapping, if it exists, */
20 /* is deallocated. use Finley_Mesh_setLinearMesh to create a new one. */
21
22 void Finley_NodeFile_allocTable(Finley_NodeFile* in ,int numNodes) {
23 maybelong *Id2=NULL, *Tag2=NULL, *degreeOfFreedom2=NULL, *reducedDegreeOfFreedom2=NULL, *toReduced2=NULL;
24 double *Coordinates2=NULL;
25 maybelong n,i;
26
27 /* allocate memory: */
28
29 Id2=(maybelong*) MEMALLOC(numNodes*sizeof(maybelong));
30 Coordinates2=(double*) MEMALLOC(numNodes*in->numDim*sizeof(double));
31 Tag2=(maybelong*) MEMALLOC(numNodes*sizeof(maybelong));
32 degreeOfFreedom2=(maybelong*) MEMALLOC(numNodes*sizeof(maybelong));
33 reducedDegreeOfFreedom2=(maybelong*) MEMALLOC(numNodes*sizeof(maybelong));
34 toReduced2=(maybelong*) MEMALLOC(numNodes*sizeof(maybelong));
35
36 /* if fine, deallocate the old table and replace by new: */
37
38 if (Finley_checkPtr(Id2) || Finley_checkPtr(Coordinates2) || Finley_checkPtr(Tag2) ||
39 Finley_checkPtr(degreeOfFreedom2) || Finley_checkPtr(reducedDegreeOfFreedom2) || Finley_checkPtr(toReduced2) ) {
40 MEMFREE(Id2);
41 MEMFREE(Coordinates2);
42 MEMFREE(Tag2);
43 MEMFREE(degreeOfFreedom2);
44 MEMFREE(reducedDegreeOfFreedom2);
45 MEMFREE(toReduced2);
46 } else {
47 Finley_NodeFile_deallocTable(in);
48 in->Id=Id2;
49 in->Coordinates=Coordinates2;
50 in->Tag=Tag2;
51 in->degreeOfFreedom=degreeOfFreedom2;
52 in->reducedDegreeOfFreedom=reducedDegreeOfFreedom2;
53 in->toReduced=toReduced2;
54 in->numNodes=numNodes;
55 in->numDegreesOfFreedom=numNodes;
56 in->reducedNumDegreesOfFreedom=numNodes;
57 in->reducedNumNodes=numNodes;
58 /* this initialization makes sure that data are located on the right processor */
59 #pragma omp parallel for private(n,i) schedule(static)
60 for (n=0;n<numNodes;n++) {
61 for (i=0;i<in->numDim;i++) in->Coordinates[INDEX2(i,n,in->numDim)]=0.;
62 in->Id[n]=-1;
63 in->Tag[n]=-1;
64 in->degreeOfFreedom[n]=n;
65 in->reducedDegreeOfFreedom[n]=n;
66 in->toReduced[n]=n;
67 }
68 }
69 return;
70 }
71
72 /* deallocates the node table within an node file: */
73
74 void Finley_NodeFile_deallocTable(Finley_NodeFile* in) {
75 if (in!=NULL) {
76 MEMFREE(in->Id);
77 MEMFREE(in->Coordinates);
78 MEMFREE(in->Tag);
79 MEMFREE(in->degreeOfFreedom);
80 MEMFREE(in->reducedDegreeOfFreedom);
81 MEMFREE(in->toReduced);
82 in->numNodes=0;
83 in->numDegreesOfFreedom=0;
84 in->reducedNumDegreesOfFreedom=0;
85 in->reducedNumNodes=0;
86 }
87 }
88 /*
89 * $Log$
90 * Revision 1.1 2004/10/26 06:53:57 jgs
91 * Initial revision
92 *
93 * Revision 1.1.1.1 2004/06/24 04:00:40 johng
94 * Initial version of eys using boost-python.
95 *
96 *
97 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26