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

Annotation of /branches/doubleplusgood/finley/src/Mesh.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3981 - (hide annotations)
Fri Sep 21 02:47:54 2012 UTC (7 years, 2 months ago) by jfenwick
Original Path: trunk/finley/src/Mesh.c
File MIME type: text/plain
File size: 7037 byte(s)
First pass of updating copyright notices
1 jfenwick 3981 /*****************************************************************************
2 ksteube 1811 *
3 jfenwick 3911 * Copyright (c) 2003-2012 by University of Queensland
4 jfenwick 3981 * http://www.uq.edu.au
5 ksteube 1811 *
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 jfenwick 3981 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
11     * Development since 2012 by School of Earth Sciences
12     *
13     *****************************************************************************/
14 ksteube 1312
15 ksteube 1811
16 jfenwick 3981 /************************************************************************************/
17 jgs 82
18     /* Finley: Mesh */
19    
20 jfenwick 3981 /************************************************************************************/
21 jgs 82
22     #include "Mesh.h"
23    
24 jfenwick 3981 /************************************************************************************/
25 jgs 82
26     /* allocates a Mesh with name name for elements of type id using an integration order. If order is negative, */
27 caltinay 3639 /* the most appropriate order is selected independently. */
28 jgs 82
29 jfenwick 3259 Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, Esys_MPIInfo *mpi_info)
30 bcumming 730 {
31 jgs 82 Finley_Mesh *out;
32    
33     /* allocate the return value */
34    
35 jgs 102 out=MEMALLOC(1,Finley_Mesh);
36 jgs 82 if (Finley_checkPtr(out)) return NULL;
37     out->Name=NULL;
38     out->Nodes=NULL;
39     out->Elements=NULL;
40     out->FaceElements=NULL;
41     out->Points=NULL;
42     out->ContactElements=NULL;
43 gross 1044 out->TagMap=NULL;
44 jgs 82 out->reference_counter=0;
45 jgs 102
46     out->FullFullPattern=NULL;
47     out->FullReducedPattern=NULL;
48     out->ReducedFullPattern=NULL;
49     out->ReducedReducedPattern=NULL;
50 jfenwick 3259 out->MPIInfo = Esys_MPIInfo_getReference( mpi_info );
51 bcumming 730 if (! Finley_noError()) {
52 ksteube 1312 Finley_Mesh_free(out);
53 bcumming 730 return NULL;
54     }
55 jgs 82 /* copy name: */
56    
57 jgs 102 out->Name=MEMALLOC(strlen(name)+1,char);
58 jgs 82 if (Finley_checkPtr(out->Name)) {
59 ksteube 1312 Finley_Mesh_free(out);
60 jgs 82 return NULL;
61     }
62     strcpy(out->Name,name);
63    
64     /* allocate node table: */
65 bcumming 730 out->Nodes=Finley_NodeFile_alloc( numDim, mpi_info );
66 jgs 150 if (! Finley_noError()) {
67 ksteube 1312 Finley_Mesh_free(out);
68 jgs 82 return NULL;
69     }
70 gross 2856 out->approximationOrder=-1;
71     out->reducedApproximationOrder=-1;
72     out->integrationOrder=-1;
73     out->reducedIntegrationOrder=-1;
74    
75 jgs 82 out->Elements=NULL;
76     out->FaceElements=NULL;
77     out->Points=NULL;
78     out->ContactElements=NULL;
79     out->reference_counter++;
80     return out;
81     }
82    
83 jgs 102 /* returns a reference to Finley_Mesh in */
84    
85     Finley_Mesh* Finley_Mesh_reference(Finley_Mesh* in) {
86     if (in!=NULL) ++(in->reference_counter);
87     return in;
88     }
89    
90 caltinay 3639 /* frees a mesh: */
91 jgs 82
92 ksteube 1312 void Finley_Mesh_free(Finley_Mesh* in) {
93 jgs 82 if (in!=NULL) {
94     in->reference_counter--;
95     if (in->reference_counter<1) {
96     MEMFREE(in->Name);
97 ksteube 1312 Finley_NodeFile_free(in->Nodes);
98 gross 1804 Finley_ElementFile_free(in->FaceElements);
99 ksteube 1312 Finley_ElementFile_free(in->Elements);
100     Finley_ElementFile_free(in->ContactElements);
101     Finley_ElementFile_free(in->Points);
102 gross 1044 Finley_TagMap_free(in->TagMap);
103 ksteube 1312 Paso_SystemMatrixPattern_free(in->FullFullPattern);
104     Paso_SystemMatrixPattern_free(in->FullReducedPattern);
105     Paso_SystemMatrixPattern_free(in->ReducedFullPattern);
106     Paso_SystemMatrixPattern_free(in->ReducedReducedPattern);
107 jfenwick 3259 Esys_MPIInfo_free( in->MPIInfo );
108 jgs 82 MEMFREE(in);
109     }
110     }
111     }
112    
113 jfenwick 3981 /************************************************************************************/
114 jgs 82
115     /* returns the spatial dimension of the mesh: */
116    
117 jgs 123 dim_t Finley_Mesh_getDim(Finley_Mesh *in) {
118 jgs 82 return in->Nodes->numDim;
119     }
120    
121 ksteube 1312 void Finley_Mesh_setElements(Finley_Mesh* self,Finley_ElementFile *elements) {
122     Finley_ElementFile_free(self->Elements);
123     self->Elements=elements;
124 jgs 82 }
125 ksteube 1312 void Finley_Mesh_setFaceElements(Finley_Mesh* self,Finley_ElementFile *elements) {
126     Finley_ElementFile_free(self->FaceElements);
127     self->FaceElements=elements;
128 jgs 82 }
129 ksteube 1312 void Finley_Mesh_setContactElements(Finley_Mesh* self,Finley_ElementFile *elements) {
130     Finley_ElementFile_free(self->ContactElements);
131     self->ContactElements=elements;
132 jgs 82 }
133 ksteube 1312 void Finley_Mesh_setPoints(Finley_Mesh* self,Finley_ElementFile *elements) {
134     Finley_ElementFile_free(self->Points);
135     self->Points=elements;
136     }
137 gross 2533 int Finley_Mesh_getStatus(Finley_Mesh* in) {
138     if (in == NULL) {
139     return -1;
140     } else if (in->Nodes == NULL) {
141     return -1;
142     } else {
143     return in->Nodes->status;
144     }
145     }
146 gross 2856
147 jfenwick 3259 void Finley_Mesh_setOrders(Finley_Mesh *in)
148 gross 2856 {
149     const dim_t order_max=9999999;
150     dim_t locals[4];
151 jfenwick 3259 #ifdef ESYS_MPI
152 gross 2856 dim_t globals[4];
153     #endif
154     locals[0]=order_max; locals[1]=order_max; locals[2]=order_max; locals[3]=order_max;
155    
156     if ( in->Elements!=NULL) {
157     if (in->Elements->numElements > 0) {
158     locals[0]=MIN(locals[0], in->Elements->referenceElementSet->referenceElement->BasisFunctions->Type->numOrder);
159     locals[1]=MIN(locals[1], in->Elements->referenceElementSet->referenceElement->LinearBasisFunctions->Type->numOrder);
160     locals[2]=MIN(locals[2], in->Elements->referenceElementSet->referenceElement->integrationOrder);
161     locals[3]=MIN(locals[3], in->Elements->referenceElementSet->referenceElementReducedQuadrature->integrationOrder);
162     }
163     }
164     if ( in->FaceElements!=NULL) {
165     if (in->FaceElements->numElements > 0) {
166     locals[0]=MIN(locals[0], in->FaceElements->referenceElementSet->referenceElement->BasisFunctions->Type->numOrder);
167     locals[1]=MIN(locals[1], in->FaceElements->referenceElementSet->referenceElement->LinearBasisFunctions->Type->numOrder);
168     locals[2]=MIN(locals[2], in->FaceElements->referenceElementSet->referenceElement->integrationOrder);
169     locals[3]=MIN(locals[3], in->FaceElements->referenceElementSet->referenceElementReducedQuadrature->integrationOrder);
170     }
171    
172    
173     }
174     if ( in->ContactElements!=NULL) {
175     if (in->ContactElements->numElements > 0) {
176     locals[0]=MIN(locals[0], in->ContactElements->referenceElementSet->referenceElement->BasisFunctions->Type->numOrder);
177     locals[1]=MIN(locals[1], in->ContactElements->referenceElementSet->referenceElement->LinearBasisFunctions->Type->numOrder);
178     locals[2]=MIN(locals[2], in->ContactElements->referenceElementSet->referenceElement->integrationOrder);
179     locals[3]=MIN(locals[3], in->ContactElements->referenceElementSet->referenceElementReducedQuadrature->integrationOrder);
180     }
181    
182     }
183    
184 jfenwick 3259 #ifdef ESYS_MPI
185 gross 2856 MPI_Allreduce( locals, globals, 4, MPI_INT, MPI_MIN, in->MPIInfo->comm );
186     in->approximationOrder=(globals[0] < order_max ? globals[0] : -1 );
187     in->reducedApproximationOrder=(globals[1] < order_max ? globals[1] : -1 );
188     in->integrationOrder=(globals[2] < order_max ? globals[2] : -1 );
189     in->reducedIntegrationOrder=(globals[3] < order_max ? globals[3] : -1 );
190     #else
191     in->approximationOrder=(locals[0] < order_max ? locals[0] : -1 );
192     in->reducedApproximationOrder=(locals[1] < order_max ? locals[1] : -1 );
193     in->integrationOrder=(locals[2] < order_max ? locals[2] : -1 );
194     in->reducedIntegrationOrder=(locals[3] < order_max ? locals[3] : -1 );
195     #endif
196    
197    
198     }
199    

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26