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

Contents of /branches/domexper/dudley/src/Assemble_getSize.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3152 - (show annotations)
Fri Sep 3 05:48:31 2010 UTC (9 years, 2 months ago) by jfenwick
File MIME type: text/plain
File size: 3576 byte(s)
Collapsed duplicate fields
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 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
14
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 #include "Assemble.h"
26 #include "Util.h"
27 #ifdef _OPENMP
28 #include <omp.h>
29 #endif
30
31 /**************************************************************/
32 void Dudley_Assemble_getSize(Dudley_NodeFile* nodes, Dudley_ElementFile* elements, escriptDataC* element_size) {
33
34 Dudley_ShapeFunction *shape=NULL;
35 Dudley_ReferenceElement* refElement=NULL;
36 double *local_X=NULL,*element_size_array;
37 dim_t e,n0,n1,q,i, NVertices, NN, NS, numQuad, numDim;
38 double d,diff,min_diff;
39 Dudley_resetError();
40
41 if (nodes==NULL || elements==NULL) return;
42 refElement=Dudley_ReferenceElementSet_borrowReferenceElement(elements->referenceElementSet,Dudley_Assemble_reducedIntegrationOrder(element_size));
43 shape= refElement->BasisFunctions;
44 numDim=nodes->numDim;
45 numQuad=shape->numQuadNodes;
46 NN=elements->numNodes;
47 NS=refElement->BasisFunctions->Type->numShapes;
48 NVertices=refElement->BasisFunctions->Type->numVertices;
49
50
51 /* check the dimensions of element_size */
52
53 if (! numSamplesEqual(element_size,numQuad,elements->numElements)) {
54 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_getSize: illegal number of samples of element size Data object");
55 } else if (! isDataPointShapeEqual(element_size,0,&(numDim))) {
56 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_getSize: illegal data point shape of element size Data object");
57 } else if (!isExpanded(element_size)) {
58 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_getSize: expanded Data object is expected for element size.");
59 }
60 /* now we can start: */
61
62 if (Dudley_noError()) {
63 requireWrite(element_size);
64 #pragma omp parallel private(local_X)
65 {
66 /* allocation of work arrays */
67 local_X=THREAD_MEMALLOC(NN*numDim,double);
68 if (! Dudley_checkPtr(local_X) ) {
69 /* open the element loop */
70 #pragma omp for private(e,min_diff,diff,n0,n1,d,q,i,element_size_array) schedule(static)
71 for(e=0;e<elements->numElements;e++) {
72 /* gather local coordinates of nodes into local_X(numDim,NN): */
73 Dudley_Util_Gather_double(NS,&(elements->Nodes[INDEX2(0,e,NN)]),numDim,nodes->Coordinates,local_X);
74 /* calculate minimal differences */
75 min_diff=-1;
76 for (n0=0;n0<NVertices;n0++) {
77 for (n1=n0+1;n1<NVertices;n1++) {
78 diff=0;
79 for (i=0;i<numDim;i++) {
80 d=local_X[INDEX2(i,n0,numDim)]-local_X[INDEX2(i,n1,numDim)];
81 diff+=d*d;
82 }
83 if (min_diff<0) {
84 min_diff=diff;
85 } else {
86 min_diff=MIN(min_diff,diff);
87 }
88 }
89 }
90 min_diff=sqrt(MAX(min_diff,0));
91 /* set all values to min_diff */
92 element_size_array=getSampleDataRW(element_size,e);
93 for (q=0;q<numQuad;q++) element_size_array[q]=min_diff;
94 }
95 }
96 THREAD_MEMFREE(local_X);
97 } /* end of parallel region */
98 }
99 return;
100 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26