CurveMesh.h 5.16 KB
Newer Older
Michael Turner's avatar
Michael Turner committed
1
2
////////////////////////////////////////////////////////////////////////////////
//
Michael Turner's avatar
Michael Turner committed
3
//  File: Curvemesh.h
Michael Turner's avatar
Michael Turner committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//
//  For more information, please see: http://www.nektar.info/
//
//  The MIT License
//
//  Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
//  Department of Aeronautics, Imperial College London (UK), and Scientific
//  Computing and Imaging Institute, University of Utah (USA).
//
//  License for the specific language governing rights and limitations under
//  Permission is hereby granted, free of charge, to any person obtaining a
//  copy of this software and associated documentation files (the "Software"),
//  to deal in the Software without restriction, including without limitation
//  the rights to use, copy, modify, merge, publish, distribute, sublicense,
//  and/or sell copies of the Software, and to permit persons to whom the
//  Software is furnished to do so, subject to the following conditions:
//
//  The above copyright notice and this permission notice shall be included
//  in all copies or substantial portions of the Software.
//
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
//  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
//  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
//  DEALINGS IN THE SOFTWARE.
//
Michael Turner's avatar
Michael Turner committed
32
//  Description: object for individual curve meshes.
Michael Turner's avatar
Michael Turner committed
33
34
35
//
////////////////////////////////////////////////////////////////////////////////

Michael Turner's avatar
Michael Turner committed
36
37
#ifndef NEKTAR_MESHUTILS_SURFACEMESHING_CURVEMESH_H
#define NEKTAR_MESHUTILS_SURFACEMESHING_CURVEMESH_H
Michael Turner's avatar
Michael Turner committed
38
39
40

#include <boost/shared_ptr.hpp>

41
#include <NekMeshUtils/CADSystem/CADCurve.h>
Michael Turner's avatar
Michael Turner committed
42
43
#include <NekMeshUtils/CADSystem/CADVert.h>
#include <NekMeshUtils/MeshElements/Mesh.h>
Michael Turner's avatar
Michael Turner committed
44
45

#include <LibUtilities/BasicUtils/SharedArray.hpp>
Michael Turner's avatar
Michael Turner committed
46
#include <LibUtilities/Interpreter/AnalyticExpressionEvaluator.hpp>
Michael Turner's avatar
Michael Turner committed
47
48
#include <LibUtilities/Memory/NekMemoryManager.hpp>

Michael Turner's avatar
Michael Turner committed
49
50
51
/**
 * @brief class for meshing individual curves (1d meshing)
 */
52
53
namespace Nektar
{
54
namespace NekMeshUtils
55
{
Michael Turner's avatar
Michael Turner committed
56

Michael Turner's avatar
Michael Turner committed
57
58
59
60
//forward
class CurveMesh;
typedef boost::shared_ptr<CurveMesh> CurveMeshSharedPtr;

Michael Turner's avatar
Michael Turner committed
61
62
class CurveMesh
{
63
64
65
66
67
68
public:
    friend class MemoryManager<CurveMesh>;

    /**
     * @brief default constructor
     */
Michael Turner's avatar
Michael Turner committed
69
70
    CurveMesh(int id, MeshSharedPtr m, std::string expr = "0.0")
        : m_id(id), m_mesh(m)
71
    {
Michael Turner's avatar
Michael Turner committed
72
        m_blID = m_bl.DefineFunction("x y z", expr);
73
        m_cadcurve = m_mesh->m_cad->GetCurve(m_id);
Dave Moxey's avatar
Dave Moxey committed
74
    }
75

Michael Turner's avatar
Michael Turner committed
76
77
    CurveMesh(int id, MeshSharedPtr m, std::vector<NodeSharedPtr> ns)
        : m_id(id), m_mesh(m), m_meshpoints(ns)
78
    {
79
        m_cadcurve = m_mesh->m_cad->GetCurve(m_id);
Dave Moxey's avatar
Dave Moxey committed
80
    }
81

82
83
84
85
86
87
88
89
    /**
     * @brief execute meshing
     */
    void Mesh();

    /**
     * @brief get id of first node
     */
90
91
92
93
    NodeSharedPtr GetFirstPoint()
    {
        return m_meshpoints[0];
    }
94
95
96
97

    /**
     * @brief get id of last node
     */
98
99
100
101
    NodeSharedPtr GetLastPoint()
    {
        return m_meshpoints.back();
    }
102
103
104
105

    /**
     * @brief get list of mesh nodes
     */
106
107
108
109
    std::vector<NodeSharedPtr> GetMeshPoints()
    {
        return m_meshpoints;
    }
110

111
112
113
114
115
    std::vector<EdgeSharedPtr> GetMeshEdges()
    {
        return m_meshedges;
    }

116
117
118
    /**
     * @brief get the number of points in the curve
     */
119
120
121
122
    int GetNumPoints()
    {
        return m_meshpoints.size();
    }
123
124
125
126

    /**
     * @brief get the length of the curve
     */
127
128
129
130
    NekDouble GetLength()
    {
        return m_curvelength;
    }
131

Michael Turner's avatar
Michael Turner committed
132
133
134
135
136
137
138
    void PeriodicOverwrite(CurveMeshSharedPtr from);

    int GetId()
    {
        return m_id;
    }

139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
private:
    /**
     * @brief get node spacing sampling function
     */
    void GetSampleFunction();

    /**
     * @brief get node spacing phi function
     */
    void GetPhiFunction();

    /**
     * @brief evaluate paramter ds at curve location s
     */
    NekDouble EvaluateDS(NekDouble s);

    /**
     * @brief evaluate paramter ps at curve location s
     */
    NekDouble EvaluatePS(NekDouble s);

    /// CAD curve
    CADCurveSharedPtr m_cadcurve;
    /// length of the curve in real space
    NekDouble m_curvelength;
    /// number of sampling points used in algorithm
    int m_numSamplePoints;
    /// coords of the ends of the parametric curve
    Array<OneD, NekDouble> m_bounds;
    /// array of function ds evaluations
    std::vector<std::vector<NekDouble> > m_dst;
    /// array of function ps evaluations
    std::vector<std::vector<NekDouble> > m_ps;
    /// spacing function evaluation
    NekDouble Ae;
    /// ds
    NekDouble ds;
176
177
    /// number of edges to be made in the curve as defined by the spacing
    /// funtion
178
179
180
    int Ne;
    /// paramteric coordiates of the mesh nodes
    std::vector<NekDouble> meshsvalue;
181
182
    /// list of mesh edges in the curvemesh
    std::vector<EdgeSharedPtr> m_meshedges;
183
184
185
186
    /// id of the curvemesh
    int m_id;
    ///
    MeshSharedPtr m_mesh;
187
188
    /// ids of the mesh nodes
    std::vector<NodeSharedPtr> m_meshpoints;
Michael Turner's avatar
Michael Turner committed
189
190
    LibUtilities::AnalyticExpressionEvaluator m_bl;
    int m_blID;
Michael Turner's avatar
Michael Turner committed
191
};
Michael Turner's avatar
Michael Turner committed
192

Michael Turner's avatar
Michael Turner committed
193
194
195
196
}
}

#endif