Nektar++
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 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: create cylinder curved edges
32 //
33 ////////////////////////////////////////////////////////////////////////////////
34 
35 #include <LocalRegions/SegExp.h>
36 #include <LocalRegions/QuadExp.h>
37 #include <LocalRegions/TriExp.h>
39 
41 
43 
44 #include "ProcessCyl.h"
45 
46 using namespace std;
47 using namespace Nektar::NekMeshUtils;
48 
49 namespace Nektar
50 {
51 namespace Utilities
52 {
53 
54 ModuleKey ProcessCyl::className = GetModuleFactory().RegisterCreatorFunction(
55  ModuleKey(eProcessModule, "cyl"), ProcessCyl::create);
56 
57 /**
58  * @brief Default constructor.
59  */
60 ProcessCyl::ProcessCyl(MeshSharedPtr m) : ProcessCurvedEdges(m)
61 {
62  m_config["r"] = ConfigOption(false, "0.0", "Radius of cylinder.");
63  m_config["xc"] = ConfigOption(false, "0.0", "Radius of cylinder.");
64  m_config["yc"] = ConfigOption(false, "0.0", "Radius of cylinder.");
65 }
66 
67 /**
68  * @brief Destructor.
69  */
71 {
72 }
73 
75 {
76  NodeSharedPtr n1 = edge->m_n1;
77  NodeSharedPtr n2 = edge->m_n2;
78 
79  int nq = m_config["N"].as<int>();
80  double r = m_config["r"].as<double>();
81  double xc = m_config["xc"].as<double>();
82  double yc = m_config["yc"].as<double>();
83  double t1 = atan2(n1->m_y - yc, n1->m_x - xc);
84  double t2 = atan2(n2->m_y - yc, n2->m_x - xc);
85  double dt;
86  double dz;
87 
88  if (t1 < -M_PI / 2.0 && t2 > 0.0)
89  {
90  t1 += 2 * M_PI;
91  }
92  if (t2 < -M_PI / 2.0 && t1 > 0.0)
93  {
94  t2 += 2 * M_PI;
95  }
96 
97  dt = (t2 - t1) / (nq - 1);
98  dz = (n2->m_z - n1->m_z) / (nq - 1);
99 
100  edge->m_edgeNodes.resize(nq - 2);
101  for (int i = 1; i < nq - 1; ++i)
102  {
103  edge->m_edgeNodes[i - 1] = NodeSharedPtr(new Node(
104  0, xc + r * cos(t1 + i * dt),
105  yc + r * sin(t1 + i * dt), n1->m_z + i * dz));
106  }
107  edge->m_curveType = LibUtilities::ePolyEvenlySpaced;
108 }
109 }
110 }
void v_GenerateEdgeNodes(NekMeshUtils::EdgeSharedPtr edge)
Definition: ProcessCyl.cpp:74
virtual ~ProcessCyl()
Destructor.
Definition: ProcessCyl.cpp:70
STL namespace.
std::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
Definition: Edge.h:136
std::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
Definition: Mesh.h:156
std::shared_ptr< Node > NodeSharedPtr
Definition: CADVert.h:49
1D Evenly-spaced points using Lagrange polynomial
Definition: PointsType.h:64
std::pair< ModuleType, std::string > ModuleKey
Represents a command-line configuration option.
std::map< std::string, ConfigOption > m_config
List of configuration values.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:199
std::pair< ModuleType, std::string > ModuleKey
ModuleFactory & GetModuleFactory()