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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6620 - (show annotations)
Mon Aug 14 08:31:59 2017 UTC (5 weeks, 2 days ago) by gross
File size: 4536 byte(s)
gather function fixed.
1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2017 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 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17
18 /****************************************************************************
19
20 Finley: Mesh
21
22 removes matching face elements from the mesh
23
24 *****************************************************************************/
25
26 #include "FinleyDomain.h"
27
28 #include <escript/index.h>
29
30 namespace finley {
31
32 void FinleyDomain::glueFaces(double safetyFactor, double tolerance, bool optimize)
33 {
34 if (m_mpiInfo->size > 1) {
35 throw escript::NotImplementedError("glueFaces: MPI is not supported yet.");
36 }
37 if (!m_faceElements)
38 return;
39
40 const_ReferenceElement_ptr faceRefElement(m_faceElements->
41 referenceElementSet->borrowReferenceElement(false));
42 const int NNFace = faceRefElement->Type->numNodesOnFace;
43 const int NN = m_faceElements->numNodes;
44 const int numDim = m_nodes->numDim;
45 const int* faceNodes = faceRefElement->Type->faceNodes;
46
47 if (NNFace <= 0) {
48 std::stringstream ss;
49 ss << "Mesh::glueFaces: glueing faces cannot be applied to face "
50 "elements of type " << faceRefElement->Type->Name;
51 throw escript::ValueError(ss.str());
52 }
53
54 // allocate work arrays
55 int* elem1 = new int[m_faceElements->numElements];
56 int* elem0 = new int[m_faceElements->numElements];
57 IndexVector elem_mask(m_faceElements->numElements, 0);
58 int* matching_nodes_in_elem1 = new int[m_faceElements->numElements*NN];
59 IndexVector new_node_label(m_nodes->getNumNodes());
60 // find the matching face elements
61 int numPairs;
62 findMatchingFaces(safetyFactor, tolerance, &numPairs, elem0, elem1,
63 matching_nodes_in_elem1);
64 for (index_t n = 0; n < m_nodes->getNumNodes(); n++)
65 new_node_label[n] = n;
66 // mark matching face elements to be removed
67 for (int e = 0; e < numPairs; e++) {
68 elem_mask[elem0[e]] = 1;
69 elem_mask[elem1[e]] = 1;
70 for (int i = 0; i < NNFace; i++) {
71 const int face_node = faceNodes[i];
72 new_node_label[matching_nodes_in_elem1[INDEX2(face_node,e,NN)]] =
73 m_faceElements->Nodes[INDEX2(face_node,elem0[e],NN)];
74 }
75 }
76 // create an index of face elements
77 dim_t new_numFaceElements = 0;
78 for (index_t e = 0; e < m_faceElements->numElements; e++) {
79 if (elem_mask[e] < 1) {
80 elem_mask[new_numFaceElements] = e;
81 new_numFaceElements++;
82 }
83 }
84 // get the new number of nodes
85 IndexVector new_node_mask(m_nodes->getNumNodes(), -1);
86 IndexVector new_node_list;
87 dim_t newNumNodes = 0;
88 for (index_t n = 0; n < m_nodes->getNumNodes(); n++)
89 new_node_mask[new_node_label[n]] = 1;
90 for (index_t n = 0; n < m_nodes->getNumNodes(); n++) {
91 if (new_node_mask[n] > 0) {
92 new_node_mask[n] = newNumNodes;
93 new_node_list.push_back(n);
94 newNumNodes++;
95 }
96 }
97
98 for (index_t n = 0; n < m_nodes->getNumNodes(); n++)
99 new_node_label[n] = new_node_mask[new_node_label[n]];
100
101
102 // allocate new node and element files
103 NodeFile* newNodeFile = new NodeFile(numDim, m_mpiInfo);
104 newNodeFile->allocTable(newNumNodes);
105
106 ElementFile* newFaceElementsFile = new ElementFile(
107 m_faceElements->referenceElementSet, m_mpiInfo);
108 newFaceElementsFile->allocTable(new_numFaceElements);
109 // get the new nodes
110 newNodeFile->gather(&new_node_list[0], m_nodes);
111
112 // they are the new nodes
113 delete m_nodes;
114 m_nodes = newNodeFile;
115 // get the face elements which are still in use
116 newFaceElementsFile->gather(&elem_mask[0], m_faceElements);
117
118
119 // they are the new face elements
120 delete m_faceElements;
121 m_faceElements = newFaceElementsFile;
122
123 // assign new node ids to elements
124
125
126
127 relabelElementNodes(new_node_label, 0);
128 prepare(optimize);
129 delete[] elem1;
130 delete[] elem0;
131 delete[] matching_nodes_in_elem1;
132 }
133
134 } // namespace finley
135

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26