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

Contents of /trunk/finley/src/Assemble_getSize.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4492 - (show annotations)
Tue Jul 2 01:44:11 2013 UTC (5 years, 9 months ago) by caltinay
File size: 3624 byte(s)
Finley changes that were held back while in release mode - moved more stuff
into finley namespace.

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15
16
17 /****************************************************************************
18
19 Assemblage routines: calculates the minimum distance between two vertices
20 of elements and assigns the value to each quadrature point in out.
21
22 *****************************************************************************/
23
24 #include "Assemble.h"
25 #include "Util.h"
26
27 namespace finley {
28
29 void Assemble_getSize(NodeFile* nodes, ElementFile* elements, escript::Data& out)
30 {
31 Finley_resetError();
32
33 if (!nodes || !elements)
34 return;
35
36 ReferenceElement *refElement = ReferenceElementSet_borrowReferenceElement(
37 elements->referenceElementSet,
38 util::hasReducedIntegrationOrder(out));
39
40 const int numDim=nodes->numDim;
41 const int numQuad=refElement->Parametrization->numQuadNodes;
42 const int NN=elements->numNodes;
43 const int NS=refElement->Parametrization->Type->numShapes;
44 const int NVertices=refElement->Parametrization->Type->numVertices;
45
46 // check the dimensions of out
47 if (!out.numSamplesEqual(numQuad, elements->numElements)) {
48 Finley_setError(TYPE_ERROR, "Assemble_getSize: illegal number of samples of out Data object");
49 } else if (!out.isDataPointShapeEqual(0, &numDim)) {
50 Finley_setError(TYPE_ERROR, "Assemble_getSize: illegal data point shape of out Data object");
51 } else if (!out.actsExpanded()) {
52 Finley_setError(TYPE_ERROR, "Assemble_getSize: expanded Data object is expected for element size.");
53 }
54
55 if (!Finley_noError())
56 return;
57
58 // now we can start
59 int node_offset;
60 if (out.getFunctionSpace().getTypeCode()==FINLEY_CONTACT_ELEMENTS_2) {
61 node_offset=refElement->Type->offsets[1];
62 } else {
63 node_offset=refElement->Type->offsets[0];
64 }
65 const double f=pow(0.5, pow((double)(refElement->Type->numSubElements),
66 1./(double)(numDim))-1);
67
68 out.requireWrite();
69 #pragma omp parallel
70 {
71 std::vector<double> local_X(NN*numDim);
72 #pragma omp parallel for
73 for (int e=0; e<elements->numElements; e++) {
74 // gather local coordinates of nodes into
75 // local_X(numDim,NN):
76 util::gather(NS, &(elements->Nodes[INDEX2(node_offset,e,NN)]),
77 numDim, nodes->Coordinates, &local_X[0]);
78 // calculate minimal differences:
79 double max_diff=0.;
80 for (int n0=0; n0<NVertices; n0++) {
81 for (int n1=n0+1; n1<NVertices; n1++) {
82 double diff=0;
83 for (int i=0; i<numDim; i++) {
84 const double d=local_X[INDEX2(i,n0,numDim)]-local_X[INDEX2(i,n1,numDim)];
85 diff += d*d;
86 }
87 max_diff=std::max(max_diff,diff);
88 }
89 }
90 max_diff=sqrt(max_diff)*f;
91 // set all values to max_diff
92 double *out_array=out.getSampleDataRW(e);
93 for (int q=0; q<numQuad; q++)
94 out_array[q]=max_diff;
95 }
96 } // end of parallel region
97 }
98
99 } // namespace finley
100

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision
svn:mergeinfo /branches/lapack2681/finley/src/Assemble_getSize.cpp:2682-2741 /branches/pasowrap/finley/src/Assemble_getSize.cpp:3661-3674 /branches/py3_attempt2/finley/src/Assemble_getSize.cpp:3871-3891 /branches/restext/finley/src/Assemble_getSize.cpp:2610-2624 /branches/ripleygmg_from_3668/finley/src/Assemble_getSize.cpp:3669-3791 /branches/stage3.0/finley/src/Assemble_getSize.cpp:2569-2590 /branches/symbolic_from_3470/finley/src/Assemble_getSize.cpp:3471-3974 /release/3.0/finley/src/Assemble_getSize.cpp:2591-2601 /trunk/finley/src/Assemble_getSize.cpp:4257-4344

  ViewVC Help
Powered by ViewVC 1.1.26