/[escript]/trunk/finley/src/ReferenceElementSets.c
ViewVC logotype

Contents of /trunk/finley/src/ReferenceElementSets.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2749 - (show annotations)
Tue Nov 17 07:34:16 2009 UTC (10 years, 6 months ago) by gross
File MIME type: text/plain
File size: 4432 byte(s)
missing files.
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2009 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14
15 /***************************************************************************************************************
16
17 Finley: Reference elements set managing the reference elements for the full and reduced intergation order
18
19 **************************************************************************************************************/
20
21 #include "ReferenceElementSets.h"
22
23 /**************************************************************/
24
25
26 Finley_ReferenceElementSet* Finley_ReferenceElementSet_alloc(ElementTypeId id, index_t order, index_t reduced_order) {
27 Finley_ReferenceElementInfo* id_info=NULL;
28 Finley_ShapeFunctionInfo* bf_info=NULL;
29 Finley_ReferenceElementSet *out=NULL;
30 id_info=Finley_ReferenceElement_getInfo(id);
31 if (! Finley_noError()) return NULL;
32 bf_info=Finley_ShapeFunction_getInfo(id_info->BasisFunctions);
33 if (! Finley_noError()) return NULL;
34
35 out=MEMALLOC(1,Finley_ReferenceElementSet);
36 if (Finley_checkPtr(out)) return NULL;
37 out->reference_counter=0;
38 out->referenceElement =NULL;
39 out->referenceElementReducedQuadrature =NULL;
40
41 if (Finley_noError()) {
42 if (order<0) order=MAX(2*(bf_info->numOrder),0);
43 out->referenceElement =Finley_ReferenceElement_alloc(id, order);
44 }
45 if (Finley_noError()) {
46 if (reduced_order<0) reduced_order=MAX(2*(bf_info->numOrder-1),0);
47 out->referenceElementReducedQuadrature=Finley_ReferenceElement_alloc(id, reduced_order);
48 }
49
50 if (Finley_noError()) {
51 if (! (Finley_ReferenceElement_getNumNodes(out->referenceElement) == Finley_ReferenceElement_getNumNodes(out->referenceElementReducedQuadrature) ) ) {
52 Finley_setError(VALUE_ERROR,"Finley_ReferenceElementSet_alloc: numNodes in referenceElement and referenceElementReducedQuadrature don't match.");
53 }
54 }
55
56 if (! Finley_noError()) {
57 Finley_ReferenceElementSet_dealloc(out);
58 return NULL;
59 } else {
60 out->numNodes=Finley_ReferenceElement_getNumNodes(out->referenceElement);
61 return Finley_ReferenceElementSet_reference(out);
62 }
63 }
64
65 /**************************************************************/
66
67 void Finley_ReferenceElementSet_dealloc(Finley_ReferenceElementSet* in) {
68 if (in!=NULL) {
69 in->reference_counter--;
70 if (in->reference_counter<1) {
71 Finley_ReferenceElement_dealloc(in->referenceElement);
72 Finley_ReferenceElement_dealloc(in->referenceElementReducedQuadrature);
73 }
74 }
75 }
76 Finley_ReferenceElementSet* Finley_ReferenceElementSet_reference(Finley_ReferenceElementSet* in) {
77 if (in!=NULL) ++(in->reference_counter);
78 return in;
79 }
80
81 Finley_ReferenceElement* Finley_ReferenceElementSet_borrowReferenceElement(Finley_ReferenceElementSet* in, bool_t reducedIntegrationOrder) {
82 Finley_ReferenceElement* out=NULL;
83 if (in !=NULL) {
84 if (reducedIntegrationOrder) {
85 out=in->referenceElementReducedQuadrature;
86 } else {
87 out=in->referenceElement;
88 }
89 }
90 return out;
91 }
92
93 Finley_ShapeFunction* Finley_ReferenceElementSet_borrowBasisFunctions(Finley_ReferenceElementSet* in, bool_t reducedShapefunction, bool_t reducedIntegrationOrder) {
94 Finley_ShapeFunction* basis=NULL;
95 if (in !=NULL) {
96 if (reducedShapefunction) {
97 if (reducedIntegrationOrder) {
98 basis=in->referenceElementReducedQuadrature->LinearBasisFunctions;
99 } else {
100 basis=in->referenceElement->LinearBasisFunctions;
101 }
102 } else {
103 if (reducedIntegrationOrder) {
104 basis=in->referenceElementReducedQuadrature->BasisFunctions;
105 } else {
106 basis=in->referenceElement->BasisFunctions;
107 }
108 }
109 }
110 return basis;
111 }
112
113 Finley_ShapeFunction* Finley_ReferenceElementSet_borrowParametrization(Finley_ReferenceElementSet* in, bool_t reducedIntegrationOrder) {
114 Finley_ShapeFunction* shape=NULL;
115 if (in !=NULL) {
116 if (reducedIntegrationOrder) {
117 shape=in->referenceElementReducedQuadrature->Parametrization;
118 } else {
119 shape=in->referenceElement->Parametrization;
120 }
121 }
122 return shape;
123 }
124

  ViewVC Help
Powered by ViewVC 1.1.26