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

Annotation of /branches/domexper/dudley/src/ReferenceElementSets.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3086 - (hide annotations)
Thu Aug 5 05:07:58 2010 UTC (9 years, 6 months ago) by jfenwick
File MIME type: text/plain
File size: 4432 byte(s)
Another pass at removing finley

1 gross 2749
2     /*******************************************************
3     *
4 jfenwick 2881 * Copyright (c) 2003-2010 by University of Queensland
5 gross 2749 * 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 jfenwick 3086 Dudley: Reference elements set managing the reference elements for the full and reduced intergation order
18 gross 2749
19     **************************************************************************************************************/
20    
21     #include "ReferenceElementSets.h"
22    
23     /**************************************************************/
24    
25    
26 jfenwick 3086 Dudley_ReferenceElementSet* Dudley_ReferenceElementSet_alloc(ElementTypeId id, index_t order, index_t reduced_order) {
27     Dudley_ReferenceElementInfo* id_info=NULL;
28     Dudley_ShapeFunctionInfo* bf_info=NULL;
29     Dudley_ReferenceElementSet *out=NULL;
30     id_info=Dudley_ReferenceElement_getInfo(id);
31     if (! Dudley_noError()) return NULL;
32     bf_info=Dudley_ShapeFunction_getInfo(id_info->BasisFunctions);
33     if (! Dudley_noError()) return NULL;
34 gross 2749
35 jfenwick 3086 out=MEMALLOC(1,Dudley_ReferenceElementSet);
36     if (Dudley_checkPtr(out)) return NULL;
37 gross 2749 out->reference_counter=0;
38     out->referenceElement =NULL;
39     out->referenceElementReducedQuadrature =NULL;
40    
41 jfenwick 3086 if (Dudley_noError()) {
42 gross 2749 if (order<0) order=MAX(2*(bf_info->numOrder),0);
43 jfenwick 3086 out->referenceElement =Dudley_ReferenceElement_alloc(id, order);
44 gross 2749 }
45 jfenwick 3086 if (Dudley_noError()) {
46 gross 2749 if (reduced_order<0) reduced_order=MAX(2*(bf_info->numOrder-1),0);
47 jfenwick 3086 out->referenceElementReducedQuadrature=Dudley_ReferenceElement_alloc(id, reduced_order);
48 gross 2749 }
49    
50 jfenwick 3086 if (Dudley_noError()) {
51     if (! (Dudley_ReferenceElement_getNumNodes(out->referenceElement) == Dudley_ReferenceElement_getNumNodes(out->referenceElementReducedQuadrature) ) ) {
52     Dudley_setError(VALUE_ERROR,"Dudley_ReferenceElementSet_alloc: numNodes in referenceElement and referenceElementReducedQuadrature don't match.");
53 gross 2749 }
54     }
55    
56 jfenwick 3086 if (! Dudley_noError()) {
57     Dudley_ReferenceElementSet_dealloc(out);
58 gross 2749 return NULL;
59     } else {
60 jfenwick 3086 out->numNodes=Dudley_ReferenceElement_getNumNodes(out->referenceElement);
61     return Dudley_ReferenceElementSet_reference(out);
62 gross 2749 }
63     }
64    
65     /**************************************************************/
66    
67 jfenwick 3086 void Dudley_ReferenceElementSet_dealloc(Dudley_ReferenceElementSet* in) {
68 gross 2749 if (in!=NULL) {
69     in->reference_counter--;
70     if (in->reference_counter<1) {
71 jfenwick 3086 Dudley_ReferenceElement_dealloc(in->referenceElement);
72     Dudley_ReferenceElement_dealloc(in->referenceElementReducedQuadrature);
73 gross 2749 }
74     }
75     }
76 jfenwick 3086 Dudley_ReferenceElementSet* Dudley_ReferenceElementSet_reference(Dudley_ReferenceElementSet* in) {
77 gross 2749 if (in!=NULL) ++(in->reference_counter);
78     return in;
79     }
80    
81 jfenwick 3086 Dudley_ReferenceElement* Dudley_ReferenceElementSet_borrowReferenceElement(Dudley_ReferenceElementSet* in, bool_t reducedIntegrationOrder) {
82     Dudley_ReferenceElement* out=NULL;
83 gross 2749 if (in !=NULL) {
84     if (reducedIntegrationOrder) {
85     out=in->referenceElementReducedQuadrature;
86     } else {
87     out=in->referenceElement;
88     }
89     }
90     return out;
91     }
92    
93 jfenwick 3086 Dudley_ShapeFunction* Dudley_ReferenceElementSet_borrowBasisFunctions(Dudley_ReferenceElementSet* in, bool_t reducedShapefunction, bool_t reducedIntegrationOrder) {
94     Dudley_ShapeFunction* basis=NULL;
95 gross 2749 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 jfenwick 3086 Dudley_ShapeFunction* Dudley_ReferenceElementSet_borrowParametrization(Dudley_ReferenceElementSet* in, bool_t reducedIntegrationOrder) {
114     Dudley_ShapeFunction* shape=NULL;
115 gross 2749 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