Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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 cylinder curved edges
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) : ProcessCurvedEdges(m)
62 {
63  m_config["r"] = ConfigOption(false, "0.0", "Radius of cylinder.");
64  m_config["xc"] = ConfigOption(false, "0.0", "Radius of cylinder.");
65  m_config["yc"] = ConfigOption(false, "0.0", "Radius of cylinder.");
66 }
67 
68 /**
69  * @brief Destructor.
70  */
72 {
73 }
74 
76 {
77  NodeSharedPtr n1 = edge->m_n1;
78  NodeSharedPtr n2 = edge->m_n2;
79 
80  int nq = m_config["N"].as<int>();
81  double r = m_config["r"].as<double>();
82  double xc = m_config["xc"].as<double>();
83  double yc = m_config["yc"].as<double>();
84  double t1 = atan2(n1->m_y - yc, n1->m_x - xc);
85  double t2 = atan2(n2->m_y - yc, n2->m_x - xc);
86  double dt;
87  double dz;
88 
89  if (t1 < -M_PI / 2.0 && t2 > 0.0)
90  {
91  t1 += 2 * M_PI;
92  }
93  if (t2 < -M_PI / 2.0 && t1 > 0.0)
94  {
95  t2 += 2 * M_PI;
96  }
97 
98  dt = (t2 - t1) / (nq - 1);
99  dz = (n2->m_z - n1->m_z) / (nq - 1);
100 
101  edge->m_edgeNodes.resize(nq - 2);
102  for (int i = 1; i < nq - 1; ++i)
103  {
104  edge->m_edgeNodes[i - 1] = NodeSharedPtr(new Node(
105  0, xc + r * cos(t1 + i * dt),
106  yc + r * sin(t1 + i * dt), n1->m_z + i * dz));
107  }
108  edge->m_curveType = LibUtilities::ePolyEvenlySpaced;
109 }
110 }
111 }
void v_GenerateEdgeNodes(NekMeshUtils::EdgeSharedPtr edge)
Definition: ProcessCyl.cpp:75
virtual ~ProcessCyl()
Destructor.
Definition: ProcessCyl.cpp:71
STL namespace.
pair< ModuleType, string > ModuleKey
1D Evenly-spaced points using Lagrange polynomial
Definition: PointsType.h:65
Represents a command-line configuration option.
boost::shared_ptr< Node > NodeSharedPtr
Definition: Node.h:50
std::map< std::string, ConfigOption > m_config
List of configuration values.
boost::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
Definition: Edge.h:135
boost::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
Definition: Mesh.h:147
std::pair< ModuleType, std::string > ModuleKey
ModuleFactory & GetModuleFactory()
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:215