/[escript]/trunk-mpi-branch/finley/src/NodeFile_allocTable.c
ViewVC logotype

Contents of /trunk-mpi-branch/finley/src/NodeFile_allocTable.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1223 - (show annotations)
Fri Aug 3 02:40:39 2007 UTC (11 years, 8 months ago) by gross
File MIME type: text/plain
File size: 2853 byte(s)
first attemt towards an improved MPI version.  

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 frees. 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;
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
43 /* if fine, freeate the old table and replace by new: */
44 if (Finley_checkPtr(Id2) || Finley_checkPtr(Coordinates2) || Finley_checkPtr(Tag2) || Finley_checkPtr(globalDegreesOfFreedom2) ) {
45 MEMFREE(Id2);
46 MEMFREE(Coordinates2);
47 MEMFREE(Tag2);
48 MEMFREE(globalDegreesOfFreedom2);
49 } else {
50 Finley_NodeFile_freeTable(in);
51 in->Id=Id2;
52 in->Coordinates=Coordinates2;
53 in->globalDegreesOfFreedom=globalDegreesOfFreedom2;
54 in->Tag=Tag2;
55 in->numNodes=numNodes;
56 /* this initialization makes sure that data are located on the right processor */
57 #pragma omp parallel for private(n,i) schedule(static)
58 for (n=0;n<numNodes;n++) {
59 for (i=0;i<in->numDim;i++) in->Coordinates[INDEX2(i,n,in->numDim)]=0.;
60 in->Id[n]=-1;
61 in->Tag[n]=-1;
62 in->globalDegreesOfFreedom[n]=-1;
63 }
64 }
65 return;
66 }
67
68 /* frees the node table within an node file: */
69
70 void Finley_NodeFile_freeTable(Finley_NodeFile* in) {
71 if (in!=NULL) {
72 MEMFREE(in->Id);
73 MEMFREE(in->Coordinates);
74 MEMFREE(in->globalDegreesOfFreedom);
75 MEMFREE(in->Tag);
76 Finley_NodeMapping_free(in->nodesMapping);
77 Finley_NodeMapping_free(in->reducedNodesMapping);
78 Finley_NodeMapping_free(in->degreesOfFreedomMapping);
79 Finley_NodeMapping_free(in->reducedDegreesOfFreedomMapping);
80 in->numNodes=0;
81 }
82 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26