/[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 6939 - (show annotations)
Mon Jan 20 03:37:18 2020 UTC (4 months, 1 week ago) by uqaeller
File size: 3775 byte(s)
Updated the copyright header.


1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2020 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Apache License, version 2.0
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
14 * Development from 2019 by School of Earth and Environmental Sciences
15 **
16 *****************************************************************************/
17
18
19 /****************************************************************************
20
21 Assemblage routines: calculates the minimum distance between two vertices
22 of elements and assigns the value to each quadrature point in out.
23
24 *****************************************************************************/
25
26 #include "Assemble.h"
27 #include "Util.h"
28
29 #include <escript/index.h>
30
31 namespace finley {
32
33 void Assemble_getSize(const NodeFile* nodes, const ElementFile* elements,
34 escript::Data& out)
35 {
36 if (!nodes || !elements)
37 return;
38
39 const_ReferenceElement_ptr refElement(elements->referenceElementSet->
40 borrowReferenceElement(
41 util::hasReducedIntegrationOrder(out)));
42
43 const int numDim = nodes->numDim;
44 const int numQuad = refElement->Parametrization->numQuadNodes;
45 const int NN = elements->numNodes;
46 const int NS = refElement->Parametrization->Type->numShapes;
47 const int NVertices = refElement->Parametrization->Type->numVertices;
48
49 // check the dimensions of out
50 if (!out.numSamplesEqual(numQuad, elements->numElements)) {
51 throw escript::ValueError("Assemble_getSize: illegal number of samples of out Data object");
52 } else if (!out.isDataPointShapeEqual(0, &numDim)) {
53 throw escript::ValueError("Assemble_getSize: illegal data point shape of out Data object");
54 } else if (!out.actsExpanded()) {
55 throw escript::ValueError("Assemble_getSize: expanded Data object is expected for element size.");
56 }
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 for
73 for (index_t e = 0; e < elements->numElements; e++) {
74 // gather local coordinates of nodes into local_X(numDim,NN)
75 util::gather(NS, &elements->Nodes[INDEX2(node_offset, e, NN)],
76 numDim, nodes->Coordinates, &local_X[0]);
77 // calculate minimal differences:
78 double max_diff = 0.;
79 for (int n0 = 0; n0 < NVertices; n0++) {
80 for (int n1 = n0 + 1; n1 < NVertices; n1++) {
81 double diff = 0;
82 for (int i = 0; i < numDim; i++) {
83 const double d = local_X[INDEX2(i,n0,numDim)] - local_X[INDEX2(i,n1,numDim)];
84 diff += d * d;
85 }
86 max_diff = std::max(max_diff, diff);
87 }
88 }
89 max_diff = sqrt(max_diff) * f;
90 // set all values to max_diff
91 double* out_array = out.getSampleDataRW(e);
92 for (int q = 0; q < numQuad; q++)
93 out_array[q] = max_diff;
94 }
95 } // end of parallel region
96 }
97
98 } // namespace finley
99

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision
svn:mergeinfo /branches/4.0fordebian/finley/src/Assemble_getSize.cpp:5567-5588 /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 /branches/trilinos_from_5897/finley/src/Assemble_getSize.cpp:5898-6118 /release/3.0/finley/src/Assemble_getSize.cpp:2591-2601 /release/4.0/finley/src/Assemble_getSize.cpp:5380-5406 /trunk/finley/src/Assemble_getSize.cpp:4257-4344

  ViewVC Help
Powered by ViewVC 1.1.26