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

Annotation of /trunk/finley/src/Assemble_getSize.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 471 - (hide annotations)
Fri Jan 27 01:33:02 2006 UTC (13 years, 8 months ago) by jgs
File MIME type: text/plain
File size: 5428 byte(s)
reorganise finley src tree to remove inc dir and src/finley directory

1 jgs 150 /*
2     ******************************************************************************
3     * *
4     * COPYRIGHT ACcESS 2003,2004,2005 - All Rights Reserved *
5     * *
6     * This software is the property of ACcESS. No part of this code *
7     * may be copied in any form or by any means without the expressed written *
8     * consent of ACcESS. Copying, use or modification of this software *
9     * by any unauthorised person is illegal unless that person has a software *
10     * license agreement with ACcESS. *
11     * *
12     ******************************************************************************
13     */
14 jgs 82
15     /**************************************************************/
16    
17     /* assemblage routines: */
18    
19     /* calculates the minimum distance between two vertices of elements and assigns the value to each */
20     /* quadrature point in element_size */
21    
22    
23     /**************************************************************/
24    
25 jgs 150 /* Copyrights by ACcESS Australia, 2003,2004,2005 */
26 jgs 82 /* author: gross@access.edu.au */
27 jgs 150 /* version: $Id$ */
28 jgs 82
29     /**************************************************************/
30    
31     #include "Assemble.h"
32     #include "Util.h"
33     #ifdef _OPENMP
34     #include <omp.h>
35     #endif
36    
37     /**************************************************************/
38     void Finley_Assemble_getSize(Finley_NodeFile* nodes, Finley_ElementFile* elements, escriptDataC* element_size) {
39    
40     double *local_X=NULL,*element_size_array;
41 jgs 123 dim_t e,n0,n1,q,i;
42     index_t node_offset;
43 jgs 82 double d,diff,min_diff;
44 jgs 150 Finley_resetError();
45 jgs 82
46     if (nodes==NULL || elements==NULL) return;
47 jgs 123 dim_t NVertices=elements->ReferenceElement->Type->numVertices;
48     dim_t NN=elements->ReferenceElement->Type->numNodes;
49     dim_t NS=elements->ReferenceElement->Type->numShapes;
50     dim_t numQuad=elements->ReferenceElement->numQuadNodes;
51     dim_t numDim=nodes->numDim;
52 jgs 82
53     /* set a few more parameters */
54    
55     if (getFunctionSpaceType(element_size)==FINLEY_CONTACT_ELEMENTS_2) {
56     node_offset=NN-NS;
57     } else {
58     node_offset=0;
59     }
60    
61     /* check the dimensions of element_size */
62    
63     if (numDim!=elements->ReferenceElement->Type->numDim) {
64 jgs 150 Finley_setError(TYPE_ERROR,"__FILE__: Gradient: Spatial and element dimension must match.");
65 jgs 82 } else if (! numSamplesEqual(element_size,numQuad,elements->numElements)) {
66 jgs 150 Finley_setError(TYPE_ERROR,"__FILE__: illegal number of samples of element size Data object");
67 jgs 82 } else if (! isDataPointShapeEqual(element_size,0,&(numDim))) {
68 jgs 150 Finley_setError(TYPE_ERROR,"__FILE__: illegal data point shape of element size Data object");
69 jgs 82 } else if (!isExpanded(element_size)) {
70 jgs 150 Finley_setError(TYPE_ERROR,"__FILE__: expanded Data object is expected for element size.");
71 jgs 82 }
72     /* now we can start: */
73    
74 jgs 150 if (Finley_noError()) {
75 jgs 82 #pragma omp parallel private(local_X)
76     {
77     /* allocation of work arrays */
78 jgs 102 local_X=THREAD_MEMALLOC(NN*numDim,double);
79 jgs 82 if (! Finley_checkPtr(local_X) ) {
80     /* open the element loop */
81 jgs 115 #pragma omp for private(e,min_diff,diff,n0,n1,d,q,i,element_size_array) schedule(static)
82 jgs 82 for(e=0;e<elements->numElements;e++) {
83     /* gather local coordinates of nodes into local_X(numDim,NN): */
84     Finley_Util_Gather_double(NS,&(elements->Nodes[INDEX2(node_offset,e,NN)]),numDim,nodes->Coordinates,local_X);
85     /* calculate minimal differences */
86     min_diff=-1;
87     for (n0=0;n0<NVertices;n0++) {
88     for (n1=n0+1;n1<NVertices;n1++) {
89     diff=0;
90     for (i=0;i<numDim;i++) {
91     d=local_X[INDEX2(i,n0,numDim)]-local_X[INDEX2(i,n1,numDim)];
92     diff+=d*d;
93     }
94     if (min_diff<0) {
95     min_diff=diff;
96     } else {
97     min_diff=MIN(min_diff,diff);
98     }
99     }
100     }
101     min_diff=sqrt(MAX(min_diff,0));
102     /* set all values to min_diff */
103     element_size_array=getSampleData(element_size,e);
104     for (q=0;q<numQuad;q++) element_size_array[q]=min_diff;
105     }
106     }
107     THREAD_MEMFREE(local_X);
108     }
109     }
110     return;
111     }
112 jgs 123 /*
113     * $Log$
114 jgs 150 * Revision 1.7 2005/09/15 03:44:21 jgs
115     * Merge of development branch dev-02 back to main trunk on 2005-09-15
116     *
117     * Revision 1.6.2.1 2005/09/07 06:26:17 gross
118     * the solver from finley are put into the standalone package paso now
119     *
120 jgs 123 * Revision 1.6 2005/07/08 04:07:47 jgs
121     * Merge of development branch back to main trunk on 2005-07-08
122     *
123     * Revision 1.1.1.1.2.3 2005/06/29 02:34:48 gross
124     * some changes towards 64 integers in finley
125     *
126     * Revision 1.1.1.1.2.2 2005/03/02 23:35:05 gross
127     * reimplementation of the ILU in Finley. block size>1 still needs some testing
128     *
129     * Revision 1.1.1.1.2.1 2004/11/24 01:37:12 gross
130     * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
131     *
132     * Revision 1.1.1.1 2004/10/26 06:53:57 jgs
133     * initial import of project esys2
134     *
135     * Revision 1.3 2004/07/30 04:37:06 gross
136     * escript and finley are linking now and RecMeshTest.py has been passed
137     *
138     * Revision 1.2 2004/07/21 05:00:54 gross
139     * name changes in DataC
140     *
141     * Revision 1.1 2004/07/02 04:21:13 gross
142     * Finley C code has been included
143     *
144     *
145     */

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26