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

Diff of /branches/domexper/dudley/src/Assemble_interpolate.c

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

revision 1028 by gross, Wed Mar 14 00:15:24 2007 UTC revision 1062 by gross, Mon Mar 26 06:17:53 2007 UTC
# Line 33  Line 33 
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_nodesi, NN, NS;    index_t dof_offset,*resort_nodesi, NN, NS;
36      bool_t reduced_integration=FALSE;
37    dim_t q,i,NS_DOF,NN_DOF,numNodes,e, numQuad;    dim_t q,i,NS_DOF,NN_DOF,numNodes,e, numQuad;
38      Finley_RefElement* reference_element=NULL;
39    dim_t numComps=getDataPointSize(data);    dim_t numComps=getDataPointSize(data);
40    index_t id[MAX_numNodes], *resort_nodes;    index_t id[MAX_numNodes], *resort_nodes;
41    type_t data_type=getFunctionSpaceType(data);    type_t data_type=getFunctionSpaceType(data);
42    type_t type;    type_t type;
43    Finley_resetError();    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    NN=elements->ReferenceElement->Type->numNodes;    NN=elements->ReferenceElement->Type->numNodes;
50    NS=elements->ReferenceElement->Type->numShapes;    NS=elements->ReferenceElement->Type->numShapes;
51    numQuad=elements->ReferenceElement->numQuadNodes;    reduced_integration = Finley_Assemble_reducedIntegrationOrder(interpolated_data);
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 53  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_setError(TYPE_ERROR,"__FILE__: Cannot interpolate data");         Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: 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 84  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_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");
109    } else if (! numSamplesEqual(data,1,numNodes)) {    } else if (! numSamplesEqual(data,1,numNodes)) {
110         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");
111    } else if (numComps!=getDataPointSize(interpolated_data)) {    } else if (numComps!=getDataPointSize(interpolated_data)) {
112         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.");
113    }  else if (!isExpanded(interpolated_data)) {    }  else if (!isExpanded(interpolated_data)) {
114         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.");
115    }    }
116    
117    /* now we can start */    /* now we can start */
# 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  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.26