/[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

revision 471 by jgs, Fri Jan 27 01:33:02 2006 UTC revision 1981 by jfenwick, Thu Nov 6 05:27:33 2008 UTC
# Line 1  Line 1 
 /*  
  ******************************************************************************  
  *                                                                            *  
  *       COPYRIGHT  ACcESS 2003,2004,2005 -  All Rights Reserved              *  
  *                                                                            *  
  * This software is the property of ACcESS. No part of this code              *  
  * may be copied in any form or by any means without the expressed written    *  
  * consent of ACcESS.  Copying, use or modification of this software          *  
  * by any unauthorised person is illegal unless that person has a software    *  
  * license agreement with ACcESS.                                             *  
  *                                                                            *  
  ******************************************************************************  
 */  
1    
2  /**************************************************************/  /*******************************************************
3    *
4    * Copyright (c) 2003-2008 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    
 /*    assemblage routines: interpolates nodal data in a data array onto elements (=integration points) */  
14    
15  /**************************************************************/  /**************************************************************/
16    
17  /*  Author: gross@access.edu.au */  /*    assemblage routines: interpolates nodal data in a data array onto elements (=integration points) */
 /*  Version: $Id$ */  
18    
19  /**************************************************************/  /**************************************************************/
20    
# Line 34  Line 29 
29    
30  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) {
31    double* local_data=NULL,*S=NULL,*data_array;    double* local_data=NULL,*S=NULL,*data_array;
32    index_t dof_offset,*resort_nodes;    index_t dof_offset, NN, NS;
33    dim_t q,i,NS_DOF,NN_DOF,numNodes,e;    bool_t reduced_integration=FALSE;
34      dim_t q,i,NS_DOF,NN_DOF,numNodes=0,e, numQuad;
35      Finley_RefElement* reference_element=NULL;
36      dim_t numComps=getDataPointSize(data);
37      index_t id[MAX_numNodes], *resort_nodes=0, *map=0;
38      type_t data_type=getFunctionSpaceType(data);
39    type_t type;    type_t type;
40      size_t numComps_size;
41      Finley_resetError();
42    #define NODES 0    #define NODES 0
43      #define REDUCED_NODES 3
44    #define DOF 1    #define DOF 1
45    #define REDUCED_DOF 2    #define REDUCED_DOF 2
46    if (nodes==NULL || elements==NULL) return;    if (nodes==NULL || elements==NULL) return;
47    dim_t NN=elements->ReferenceElement->Type->numNodes;    
48    dim_t NS=elements->ReferenceElement->Type->numShapes;    NN=elements->numNodes;
49    dim_t numComps=getDataPointSize(data);    NS=elements->ReferenceElement->Type->numShapes;
50    type_t data_type=getFunctionSpaceType(data);    reduced_integration = Finley_Assemble_reducedIntegrationOrder(interpolated_data);
   dim_t numQuad=elements->ReferenceElement->numQuadNodes;  
   index_t id[NN];  
51    for (i=0;i<NN;i++) id[i]=i;    for (i=0;i<NN;i++) id[i]=i;
   Finley_resetError();  
52    
53    /* set some parameter */    /* set some parameter */
54    
55    if (data_type==FINLEY_NODES) {    if (data_type==FINLEY_NODES) {
56         type=NODES;         type=NODES;
57         resort_nodes=id;         resort_nodes=id;
58         NN_DOF=elements->ReferenceElement->Type->numNodes;         if (reduced_integration) {
59         NS_DOF=elements->ReferenceElement->Type->numShapes;            reference_element=elements->ReferenceElementReducedOrder;
60         S=elements->ReferenceElement->S;         } else {
61         numNodes=nodes->numNodes;            reference_element=elements->ReferenceElement;
62           }
63           numNodes=Finley_NodeFile_getNumNodes(nodes);
64           map=Finley_NodeFile_borrowTargetNodes(nodes);
65      } else if (data_type==FINLEY_REDUCED_NODES) {
66           type=REDUCED_NODES;
67           resort_nodes=elements->ReferenceElement->Type->linearNodes;
68           if (reduced_integration) {
69               reference_element=elements->LinearReferenceElementReducedOrder;
70           } else {
71               reference_element=elements->LinearReferenceElement;
72           }
73           numNodes=Finley_NodeFile_getNumReducedNodes(nodes);
74           map=Finley_NodeFile_borrowTargetReducedNodes(nodes);
75    } else if (data_type==FINLEY_DEGREES_OF_FREEDOM) {    } else if (data_type==FINLEY_DEGREES_OF_FREEDOM) {
76           if (elements->MPIInfo->size>1) {
77              Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: for more than one processor DEGREES_OF_FREEDOM data are not accepted as input.");
78              return;
79           }
80         type=DOF;         type=DOF;
81         resort_nodes=id;         resort_nodes=id;
82         NN_DOF=elements->ReferenceElement->Type->numNodes;         if (reduced_integration) {
83         NS_DOF=elements->ReferenceElement->Type->numShapes;             reference_element=elements->ReferenceElementReducedOrder;
84         S=elements->ReferenceElement->S;         } else {
85         numNodes=nodes->numDegreesOfFreedom;             reference_element=elements->ReferenceElement;
86           }
87           numNodes=Finley_NodeFile_getNumDegreesOfFreedom(nodes);
88           map=Finley_NodeFile_borrowTargetDegreesOfFreedom(nodes);
89    } else if (data_type==FINLEY_REDUCED_DEGREES_OF_FREEDOM) {    } else if (data_type==FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
90           if (elements->MPIInfo->size>1) {
91              Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: for more than one processor REDUCED_DEGREES_OF_FREEDOM data are not accepted as input.");
92              return;
93           }
94         type=REDUCED_DOF;         type=REDUCED_DOF;
95         resort_nodes=elements->ReferenceElement->Type->linearNodes;         resort_nodes=elements->ReferenceElement->Type->linearNodes;
96         NN_DOF=elements->LinearReferenceElement->Type->numNodes;         if (reduced_integration) {
97         NS_DOF=elements->LinearReferenceElement->Type->numShapes;             reference_element=elements->LinearReferenceElementReducedOrder;
98         S=elements->LinearReferenceElement->S;         } else {
99         numNodes=nodes->reducedNumDegreesOfFreedom;             reference_element=elements->LinearReferenceElement;
100           }
101           numNodes=Finley_NodeFile_getNumReducedDegreesOfFreedom(nodes);
102           map=Finley_NodeFile_borrowTargetReducedDegreesOfFreedom(nodes);
103     } else {     } else {
104         Finley_setError(TYPE_ERROR,"__FILE__: Cannot interpolate data");         Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: Cannot interpolate data");
105    }    }
106      NN_DOF=reference_element->Type->numNodes;
107      NS_DOF=reference_element->Type->numShapes;
108      S=reference_element->S;
109      numQuad=reference_element->numQuadNodes;
110    if (getFunctionSpaceType(interpolated_data)==FINLEY_CONTACT_ELEMENTS_2) {    if (getFunctionSpaceType(interpolated_data)==FINLEY_CONTACT_ELEMENTS_2) {
111         dof_offset=NN_DOF-NS_DOF;         dof_offset=NN_DOF-NS_DOF;
112    } else {    } else {
# Line 86  void Finley_Assemble_interpolate(Finley_ Line 116  void Finley_Assemble_interpolate(Finley_
116    /* check the dimensions of interpolated_data and data */    /* check the dimensions of interpolated_data and data */
117    
118    if (! numSamplesEqual(interpolated_data,numQuad,elements->numElements)) {    if (! numSamplesEqual(interpolated_data,numQuad,elements->numElements)) {
119         Finley_setError(TYPE_ERROR,"__FILE__: illegal number of samples of output Data object");         Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of output Data object");
120    } else if (! numSamplesEqual(data,1,numNodes)) {    } else if (! numSamplesEqual(data,1,numNodes)) {
121         Finley_setError(TYPE_ERROR,"__FILE__: illegal number of samples of input Data object");         Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of input Data object");
122    } else if (numComps!=getDataPointSize(interpolated_data)) {    } else if (numComps!=getDataPointSize(interpolated_data)) {
123         Finley_setError(TYPE_ERROR,"__FILE__: number of components of input and interpolated Data do not match.");         Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: number of components of input and interpolated Data do not match.");
124    }  else if (!isExpanded(interpolated_data)) {    }  else if (!isExpanded(interpolated_data)) {
125         Finley_setError(TYPE_ERROR,"__FILE__: expanded Data object is expected for output data.");         Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: expanded Data object is expected for output data.");
126    }    }
127    
128    /* now we can start */    /* now we can start */
129    
130    if (Finley_noError()) {    if (Finley_noError()) {
131         #pragma omp parallel private(local_data)         #pragma omp parallel private(local_data, numComps_size)
132         {         {
133            local_data=NULL;            local_data=NULL;
134            /* allocation of work arrays */            /* allocation of work arrays */
135            local_data=THREAD_MEMALLOC(NS*numComps,double);            local_data=THREAD_MEMALLOC(NS*numComps,double);
136            if (! Finley_checkPtr(local_data)) {            if (! Finley_checkPtr(local_data)) {
137    
138                numComps_size=(size_t)numComps*sizeof(double);
139          /* open the element loop */          /* open the element loop */
140    
141              #pragma omp for private(e,q,i,data_array) schedule(static)              #pragma omp for private(e,q,i,data_array) schedule(static)
142          for(e=0;e<elements->numElements;e++) {          for(e=0;e<elements->numElements;e++) {
143            /* gather local data into local_data(numComps,NS_DOF): */                for (q=0;q<NS_DOF;q++) {
144                switch (type) {                        i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
145                   case NODES:                        data_array=getSampleData(data,map[i]);
146                          for (q=0;q<NS_DOF;q++) {                        memcpy(local_data+q*numComps, data_array, numComps_size);
                            i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];  
                            data_array=getSampleData(data,i);  
                            Finley_copyDouble(numComps,data_array,local_data+q*numComps);  
                         }  
                         break;  
                  case DOF:  
                         for (q=0;q<NS_DOF;q++) {  
                            i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];  
                            data_array=getSampleData(data,nodes->degreeOfFreedom[i]);  
                            Finley_copyDouble(numComps,data_array,local_data+q*numComps);  
                         }  
                         break;  
                  case REDUCED_DOF:  
                         for (q=0;q<NS_DOF;q++) {  
                            i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];  
                            data_array=getSampleData(data,nodes->reducedDegreeOfFreedom[i]);  
                            Finley_copyDouble(numComps,data_array,local_data+q*numComps);  
                         }  
                         break;  
147                }                }
   
148            /*  calculate interpolated_data=local_data*S */            /*  calculate interpolated_data=local_data*S */
149    
150            Finley_Util_SmallMatMult(numComps,numQuad,getSampleData(interpolated_data,e),NS_DOF,local_data,S);            Finley_Util_SmallMatMult(numComps,numQuad,getSampleData(interpolated_data,e),NS_DOF,local_data,S);
# Line 145  void Finley_Assemble_interpolate(Finley_ Line 156  void Finley_Assemble_interpolate(Finley_
156       } /* end of parallel region */       } /* end of parallel region */
157    }    }
158    #undef NODES    #undef NODES
159      #undef REDUCED_NODES
160    #undef DOF    #undef DOF
161    #undef REDUCED_DOF    #undef REDUCED_DOF
162  }  }
 /*  
  * $Log$  
  * Revision 1.6  2005/09/15 03:44:21  jgs  
  * Merge of development branch dev-02 back to main trunk on 2005-09-15  
  *  
  * Revision 1.5.2.1  2005/09/07 06:26:18  gross  
  * the solver from finley are put into the standalone package paso now  
  *  
  * Revision 1.5  2005/07/08 04:07:48  jgs  
  * Merge of development branch back to main trunk on 2005-07-08  
  *  
  * Revision 1.4  2004/12/15 07:08:32  jgs  
  * *** empty log message ***  
  * Revision 1.1.1.1.2.3  2005/06/29 02:34:48  gross  
  * some changes towards 64 integers in finley  
  *  
  * Revision 1.1.1.1.2.2  2004/11/24 01:37:12  gross  
  * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now  
  *  
  *  
  *  
  */  

Legend:
Removed from v.471  
changed lines
  Added in v.1981

  ViewVC Help
Powered by ViewVC 1.1.26