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

Diff of /trunk/finley/src/Assemble_interpolate.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/esys2/finley/src/finleyC/Assemble_interpolate.c revision 123 by jgs, Fri Jul 8 04:08:13 2005 UTC trunk/finley/src/Assemble_interpolate.c revision 1062 by gross, Mon Mar 26 06:17:53 2007 UTC
# Line 1  Line 1 
1  /* $Id$ */  /*
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    
# Line 6  Line 16 
16    
17  /**************************************************************/  /**************************************************************/
18    
19  /*   Copyrights by ACcESS Australia, 2003,2004 */  /*  Author: gross@access.edu.au */
20  /*   author: gross@access.edu.au */  /*  Version: $Id$ */
 /*   Version: $Id$ */  
21    
22  /**************************************************************/  /**************************************************************/
23    
 #include "Common.h"  
 #include "escript/Data/DataC.h"  
 #include "Finley.h"  
24  #include "Assemble.h"  #include "Assemble.h"
 #include "NodeFile.h"  
 #include "ElementFile.h"  
25  #include "Util.h"  #include "Util.h"
26  #ifdef _OPENMP  #ifdef _OPENMP
27  #include <omp.h>  #include <omp.h>
# Line 28  Line 32 
32    
33  void Finley_Assemble_interpolate(Finley_NodeFile *nodes, Finley_ElementFile* elements,escriptDataC* data,escriptDataC* interpolated_data) {  void Finley_Assemble_interpolate(Finley_NodeFile *nodes, Finley_ElementFile* elements,escriptDataC* data,escriptDataC* interpolated_data) {
34    double* local_data=NULL,*S=NULL,*data_array;    double* local_data=NULL,*S=NULL,*data_array;
35    index_t dof_offset,*resort_nodes;    index_t dof_offset,*resort_nodesi, NN, NS;
36    dim_t q,i,NS_DOF,NN_DOF,numNodes,e;    bool_t reduced_integration=FALSE;
37      dim_t q,i,NS_DOF,NN_DOF,numNodes,e, numQuad;
38      Finley_RefElement* reference_element=NULL;
39      dim_t numComps=getDataPointSize(data);
40      index_t id[MAX_numNodes], *resort_nodes;
41      type_t data_type=getFunctionSpaceType(data);
42    type_t type;    type_t type;
43      Finley_resetError();
44    #define NODES 0    #define NODES 0
45      #define REDUCED_NODES 3
46    #define DOF 1    #define DOF 1
47    #define REDUCED_DOF 2    #define REDUCED_DOF 2
48    if (nodes==NULL || elements==NULL) return;    if (nodes==NULL || elements==NULL) return;
49    dim_t NN=elements->ReferenceElement->Type->numNodes;    NN=elements->ReferenceElement->Type->numNodes;
50    dim_t NS=elements->ReferenceElement->Type->numShapes;    NS=elements->ReferenceElement->Type->numShapes;
51    dim_t numComps=getDataPointSize(data);    reduced_integration = Finley_Assemble_reducedIntegrationOrder(interpolated_data);
   type_t data_type=getFunctionSpaceType(data);  
   dim_t numQuad=elements->ReferenceElement->numQuadNodes;  
   index_t id[NN];  
52    for (i=0;i<NN;i++) id[i]=i;    for (i=0;i<NN;i++) id[i]=i;
53    
54    /* set some parameter */    /* set some parameter */
# Line 48  void Finley_Assemble_interpolate(Finley_ Line 56  void Finley_Assemble_interpolate(Finley_
56    if (data_type==FINLEY_NODES) {    if (data_type==FINLEY_NODES) {
57         type=NODES;         type=NODES;
58         resort_nodes=id;         resort_nodes=id;
59         NN_DOF=elements->ReferenceElement->Type->numNodes;         if (reduced_integration) {
60         NS_DOF=elements->ReferenceElement->Type->numShapes;            reference_element=elements->ReferenceElementReducedOrder;
61         S=elements->ReferenceElement->S;         } else {
62              reference_element=elements->ReferenceElement;
63           }
64         numNodes=nodes->numNodes;         numNodes=nodes->numNodes;
65      } else if (data_type==FINLEY_REDUCED_NODES) {
66           type=REDUCED_NODES;
67           if (reduced_integration) {
68               reference_element=elements->LinearReferenceElementReducedOrder;
69           } else {
70               reference_element=elements->LinearReferenceElement;
71           }
72           /* TODO */
73           Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: input from reduced nodes is not supported yet.");
74    } else if (data_type==FINLEY_DEGREES_OF_FREEDOM) {    } else if (data_type==FINLEY_DEGREES_OF_FREEDOM) {
75         type=DOF;         type=DOF;
76         resort_nodes=id;         resort_nodes=id;
77         NN_DOF=elements->ReferenceElement->Type->numNodes;         if (reduced_integration) {
78         NS_DOF=elements->ReferenceElement->Type->numShapes;             reference_element=elements->ReferenceElementReducedOrder;
79         S=elements->ReferenceElement->S;         } else {
80               reference_element=elements->ReferenceElement;
81           }
82         numNodes=nodes->numDegreesOfFreedom;         numNodes=nodes->numDegreesOfFreedom;
83    } else if (data_type==FINLEY_REDUCED_DEGREES_OF_FREEDOM) {    } else if (data_type==FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
84         type=REDUCED_DOF;         type=REDUCED_DOF;
85         resort_nodes=elements->ReferenceElement->Type->linearNodes;         resort_nodes=elements->ReferenceElement->Type->linearNodes;
86         NN_DOF=elements->LinearReferenceElement->Type->numNodes;         if (reduced_integration) {
87         NS_DOF=elements->LinearReferenceElement->Type->numShapes;             reference_element=elements->LinearReferenceElementReducedOrder;
88         S=elements->LinearReferenceElement->S;         } else {
89               reference_element=elements->LinearReferenceElement;
90           }
91         numNodes=nodes->reducedNumDegreesOfFreedom;         numNodes=nodes->reducedNumDegreesOfFreedom;
92     } else {     } else {
93         Finley_ErrorCode=TYPE_ERROR;         Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: Cannot interpolate data");
        sprintf(Finley_ErrorMsg,"Cannot interpolate data");  
94    }    }
95      NN_DOF=reference_element->Type->numNodes;
96      NS_DOF=reference_element->Type->numShapes;
97      S=reference_element->S;
98      numQuad=reference_element->numQuadNodes;
99    if (getFunctionSpaceType(interpolated_data)==FINLEY_CONTACT_ELEMENTS_2) {    if (getFunctionSpaceType(interpolated_data)==FINLEY_CONTACT_ELEMENTS_2) {
100         dof_offset=NN_DOF-NS_DOF;         dof_offset=NN_DOF-NS_DOF;
101    } else {    } else {
# Line 80  void Finley_Assemble_interpolate(Finley_ Line 105  void Finley_Assemble_interpolate(Finley_
105    /* check the dimensions of interpolated_data and data */    /* check the dimensions of interpolated_data and data */
106    
107    if (! numSamplesEqual(interpolated_data,numQuad,elements->numElements)) {    if (! numSamplesEqual(interpolated_data,numQuad,elements->numElements)) {
108         Finley_ErrorCode=TYPE_ERROR;         Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of output Data object");
        sprintf(Finley_ErrorMsg,"illegal number of samples of output Data object");  
109    } else if (! numSamplesEqual(data,1,numNodes)) {    } else if (! numSamplesEqual(data,1,numNodes)) {
110         Finley_ErrorCode=TYPE_ERROR;         Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of input Data object");
        sprintf(Finley_ErrorMsg,"illegal number of samples of input Data object");  
111    } else if (numComps!=getDataPointSize(interpolated_data)) {    } else if (numComps!=getDataPointSize(interpolated_data)) {
112         Finley_ErrorCode=TYPE_ERROR;         Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: number of components of input and interpolated Data do not match.");
        sprintf(Finley_ErrorMsg,"number of components of input and interpolated Data do not match.");  
113    }  else if (!isExpanded(interpolated_data)) {    }  else if (!isExpanded(interpolated_data)) {
114         Finley_ErrorCode=TYPE_ERROR;         Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: expanded Data object is expected for output data.");
        sprintf(Finley_ErrorMsg,"expanded Data object is expected for output data.");  
115    }    }
116    
117    /* now we can start */    /* now we can start */
118    
119    if (Finley_ErrorCode==NO_ERROR) {    if (Finley_noError()) {
120         #pragma omp parallel private(local_data)         #pragma omp parallel private(local_data)
121         {         {
122            local_data=NULL;            local_data=NULL;
# Line 116  void Finley_Assemble_interpolate(Finley_ Line 137  void Finley_Assemble_interpolate(Finley_
137                             Finley_copyDouble(numComps,data_array,local_data+q*numComps);                             Finley_copyDouble(numComps,data_array,local_data+q*numComps);
138                          }                          }
139                          break;                          break;
140                     case REDUCED_NODES:
141                            for (q=0;q<NS_DOF;q++) {
142                               i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
143                               data_array=getSampleData(data,i); /* TODO */
144                               Finley_copyDouble(numComps,data_array,local_data+q*numComps);
145                            }
146                            break;
147                   case DOF:                   case DOF:
148                          for (q=0;q<NS_DOF;q++) {                          for (q=0;q<NS_DOF;q++) {
149                             i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];                             i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
# Line 143  void Finley_Assemble_interpolate(Finley_ Line 171  void Finley_Assemble_interpolate(Finley_
171       } /* end of parallel region */       } /* end of parallel region */
172    }    }
173    #undef NODES    #undef NODES
174      #undef REDUCED_NODES
175    #undef DOF    #undef DOF
176    #undef REDUCED_DOF    #undef REDUCED_DOF
177  }  }
178  /*  /*
179   * $Log$   * $Log$
180     * Revision 1.6  2005/09/15 03:44:21  jgs
181     * Merge of development branch dev-02 back to main trunk on 2005-09-15
182     *
183     * Revision 1.5.2.1  2005/09/07 06:26:18  gross
184     * the solver from finley are put into the standalone package paso now
185     *
186   * Revision 1.5  2005/07/08 04:07:48  jgs   * Revision 1.5  2005/07/08 04:07:48  jgs
187   * Merge of development branch back to main trunk on 2005-07-08   * Merge of development branch back to main trunk on 2005-07-08
188   *   *

Legend:
Removed from v.123  
changed lines
  Added in v.1062

  ViewVC Help
Powered by ViewVC 1.1.26