/[escript]/branches/domexper/finley/src/ReferenceElementSets.c
ViewVC logotype

Contents of /branches/domexper/finley/src/ReferenceElementSets.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3247 - (show annotations)
Wed Oct 6 05:53:06 2010 UTC (8 years, 6 months ago) by caltinay
File MIME type: text/plain
File size: 4502 byte(s)
Fixed name clashes between dudley and finley so both can be used
simultaneously.

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 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 #include "esysUtils/mem.h"
23
24 #define MAX(X,Y) ((X)>(Y)?(X):(Y))
25
26 /**************************************************************/
27
28
29 Finley_ReferenceElementSet* Finley_ReferenceElementSet_alloc(Finley_ElementTypeId id, index_t order, index_t reduced_order) {
30 Finley_ReferenceElementInfo* id_info=NULL;
31 Finley_ShapeFunctionInfo* bf_info=NULL;
32 Finley_ReferenceElementSet *out=NULL;
33 id_info=Finley_ReferenceElement_getInfo(id);
34 if (! Finley_noError()) return NULL;
35 bf_info=Finley_ShapeFunction_getInfo(id_info->BasisFunctions);
36 if (! Finley_noError()) return NULL;
37
38 out=MEMALLOC(1,Finley_ReferenceElementSet);
39 if (Finley_checkPtr(out)) return NULL;
40 out->reference_counter=0;
41 out->referenceElement =NULL;
42 out->referenceElementReducedQuadrature =NULL;
43
44 if (Finley_noError()) {
45 if (order<0) order=MAX(2*(bf_info->numOrder),0);
46 out->referenceElement =Finley_ReferenceElement_alloc(id, order);
47 }
48 if (Finley_noError()) {
49 if (reduced_order<0) reduced_order=MAX(2*(bf_info->numOrder-1),0);
50 out->referenceElementReducedQuadrature=Finley_ReferenceElement_alloc(id, reduced_order);
51 }
52
53 if (Finley_noError()) {
54 if (! (Finley_ReferenceElement_getNumNodes(out->referenceElement) == Finley_ReferenceElement_getNumNodes(out->referenceElementReducedQuadrature) ) ) {
55 Finley_setError(VALUE_ERROR,"Finley_ReferenceElementSet_alloc: numNodes in referenceElement and referenceElementReducedQuadrature don't match.");
56 }
57 }
58
59 if (! Finley_noError()) {
60 Finley_ReferenceElementSet_dealloc(out);
61 return NULL;
62 } else {
63 out->numNodes=Finley_ReferenceElement_getNumNodes(out->referenceElement);
64 return Finley_ReferenceElementSet_reference(out);
65 }
66 }
67
68 /**************************************************************/
69
70 void Finley_ReferenceElementSet_dealloc(Finley_ReferenceElementSet* in) {
71 if (in!=NULL) {
72 in->reference_counter--;
73 if (in->reference_counter<1) {
74 Finley_ReferenceElement_dealloc(in->referenceElement);
75 Finley_ReferenceElement_dealloc(in->referenceElementReducedQuadrature);
76 }
77 }
78 }
79 Finley_ReferenceElementSet* Finley_ReferenceElementSet_reference(Finley_ReferenceElementSet* in) {
80 if (in!=NULL) ++(in->reference_counter);
81 return in;
82 }
83
84 Finley_ReferenceElement* Finley_ReferenceElementSet_borrowReferenceElement(Finley_ReferenceElementSet* in, bool_t reducedIntegrationOrder) {
85 Finley_ReferenceElement* out=NULL;
86 if (in !=NULL) {
87 if (reducedIntegrationOrder) {
88 out=in->referenceElementReducedQuadrature;
89 } else {
90 out=in->referenceElement;
91 }
92 }
93 return out;
94 }
95
96 Finley_ShapeFunction* Finley_ReferenceElementSet_borrowBasisFunctions(Finley_ReferenceElementSet* in, bool_t reducedShapefunction, bool_t reducedIntegrationOrder) {
97 Finley_ShapeFunction* basis=NULL;
98 if (in !=NULL) {
99 if (reducedShapefunction) {
100 if (reducedIntegrationOrder) {
101 basis=in->referenceElementReducedQuadrature->LinearBasisFunctions;
102 } else {
103 basis=in->referenceElement->LinearBasisFunctions;
104 }
105 } else {
106 if (reducedIntegrationOrder) {
107 basis=in->referenceElementReducedQuadrature->BasisFunctions;
108 } else {
109 basis=in->referenceElement->BasisFunctions;
110 }
111 }
112 }
113 return basis;
114 }
115
116 Finley_ShapeFunction* Finley_ReferenceElementSet_borrowParametrization(Finley_ReferenceElementSet* in, bool_t reducedIntegrationOrder) {
117 Finley_ShapeFunction* shape=NULL;
118 if (in !=NULL) {
119 if (reducedIntegrationOrder) {
120 shape=in->referenceElementReducedQuadrature->Parametrization;
121 } else {
122 shape=in->referenceElement->Parametrization;
123 }
124 }
125 return shape;
126 }
127

  ViewVC Help
Powered by ViewVC 1.1.26