Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ProcessCyl.cpp
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: ProcessCyl.cpp
4 //
5 // For more information, please see: http://www.nektar.info/
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: create mesh from cad using mesh utils
33 //
34 ////////////////////////////////////////////////////////////////////////////////
35 
36 #include <LocalRegions/SegExp.h>
37 #include <LocalRegions/QuadExp.h>
38 #include <LocalRegions/TriExp.h>
40 
42 
44 
45 #include "ProcessCyl.h"
46 
47 using namespace std;
48 using namespace Nektar::NekMeshUtils;
49 
50 namespace Nektar
51 {
52 namespace Utilities
53 {
54 
55 ModuleKey ProcessCyl::className = GetModuleFactory().RegisterCreatorFunction(
56  ModuleKey(eProcessModule, "cyl"), ProcessCyl::create);
57 
58 /**
59  * @brief Default constructor.
60  */
61 ProcessCyl::ProcessCyl(MeshSharedPtr m) : ProcessModule(m)
62 {
63  m_config["surf"] =
64  ConfigOption(false, "-1", "Tag identifying surface to process.");
65  m_config["r"] = ConfigOption(false, "0.0", "Radius of cylinder.");
66  m_config["N"] = ConfigOption(false, "7", "Number of points along edge.");
67 }
68 
69 /**
70  * @brief Destructor.
71  */
73 {
74 }
75 
77 {
78  set<pair<int, int> > tmp;
79  int surfTag = m_config["surf"].as<int>();
80  int prismedge[2][3] = {{0, 5, 4}, {2, 6, 7}};
81  Node zax(0, 0, 0, 1);
82  int dim = m_mesh->m_expDim;
83 
84  for (int i = 0; i < m_mesh->m_element[dim].size(); ++i)
85  {
86  ElementSharedPtr el = m_mesh->m_element[dim][i];
87  int nSurf = dim == 3 ? el->GetFaceCount() : el->GetEdgeCount();
88 
89  for (int j = 0; j < nSurf; ++j)
90  {
91  int bl = el->GetBoundaryLink(j);
92  if (bl == -1)
93  {
94  continue;
95  }
96 
97  ElementSharedPtr bEl = m_mesh->m_element[dim - 1][bl];
98  vector<int> tags = bEl->GetTagList();
99 
100  if (find(tags.begin(), tags.end(), surfTag) == tags.end())
101  {
102  continue;
103  }
104 
105  ASSERTL0(j == 1 || j == 3, "rofl");
106 
107  // Check all edge interior points.
108  for (int k = 0; k < 3; ++k)
109  {
110  EdgeSharedPtr edge = el->GetEdge(prismedge[(j - 1) / 2][k]);
111  GenerateEdgeNodes(edge);
112  }
113  }
114  }
115 }
116 
118 {
119  NodeSharedPtr n1 = edge->m_n1;
120  NodeSharedPtr n2 = edge->m_n2;
121 
122  int nq = m_config["N"].as<int>();
123  double r = m_config["r"].as<double>();
124  double t1 = atan2(n1->m_y, n1->m_x);
125  double t2 = atan2(n2->m_y, n2->m_x);
126  double dt;
127  double dz;
128 
129  if (t1 < -M_PI / 2.0 && t2 > 0.0)
130  {
131  t1 += 2 * M_PI;
132  }
133  if (t2 < -M_PI / 2.0 && t1 > 0.0)
134  {
135  t2 += 2 * M_PI;
136  }
137 
138  dt = (t2 - t1) / (nq - 1);
139  dz = (n2->m_z - n1->m_z) / (nq - 1);
140 
141  edge->m_edgeNodes.resize(nq - 2);
142  Node dx = (*n2 - *n1) * (1.0 / (nq - 1.0));
143  for (int i = 1; i < nq - 1; ++i)
144  {
145  edge->m_edgeNodes[i - 1] = NodeSharedPtr(new Node(
146  0, r * cos(t1 + i * dt), r * sin(t1 + i * dt), n1->m_z + i * dz));
147  }
148  edge->m_curveType = LibUtilities::ePolyEvenlySpaced;
149 }
150 }
151 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
pair< ModuleType, string > ModuleKey
virtual ~ProcessCyl()
Destructor.
Definition: ProcessCyl.cpp:72
map< string, ConfigOption > m_config
List of configuration values.
STL namespace.
MeshSharedPtr m_mesh
Mesh object.
Represents a point in the domain.
Definition: Node.h:60
1D Evenly-spaced points using Lagrange polynomial
Definition: PointsType.h:63
boost::shared_ptr< Node > NodeSharedPtr
Definition: Node.h:50
virtual void Process()
Write mesh to output file.
Definition: ProcessCyl.cpp:76
Represents a command-line configuration option.
boost::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
Definition: Edge.h:196
boost::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
Definition: Mesh.h:137
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
Definition: StdRegions.hpp:315
boost::shared_ptr< Element > ElementSharedPtr
Definition: Edge.h:52
void GenerateEdgeNodes(EdgeSharedPtr edge)
Definition: ProcessCyl.cpp:117
ModuleFactory & GetModuleFactory()
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:215