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

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