Nektar++
ExtractCriticalLayer.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: ExtractCriticalLayer.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: Extract location of critical layer from streak file
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#include <cstdio>
36#include <cstdlib>
37
40
41using namespace std;
42using namespace Nektar;
43
45
46int main(int argc, char *argv[])
47{
48 int i;
49 NekDouble cr = 0;
50
51 if (argc != 3)
52 {
53 fprintf(stderr,
54 "Usage: ./ExtractCriticalLayer meshfile fieldfile \n");
55 exit(1);
56 }
57
58 //------------------------------------------------------------
59 // Create Session file.
61 LibUtilities::SessionReader::CreateInstance(argc, argv);
62 //-----------------------------------------------------------
63
64 //-------------------------------------------------------------
65 // Read in mesh from input file
67 SpatialDomains::MeshGraphIO::Read(vSession);
68 //------------------------------------------------------------
69
70 //-------------------------------------------------------------
71 // Define Streak Expansion
73
75 graphShPt);
76 //---------------------------------------------------------------
77
78 //----------------------------------------------
79 // Import field file.
80 string fieldfile(argv[argc - 1]);
81 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
82 vector<vector<NekDouble>> fielddata;
83 LibUtilities::Import(fieldfile, fielddef, fielddata);
84 //----------------------------------------------
85
86 //----------------------------------------------
87 // Copy data from field file
88 string streak_field("w");
89 for (unsigned int i = 0; i < fielddata.size(); ++i)
90 {
91 streak->ExtractDataToCoeffs(fielddef[i], fielddata[i], streak_field,
92 streak->UpdateCoeffs());
93 }
94 //----------------------------------------------
95
96 int npts;
97 vSession->LoadParameter("NumCriticalLayerPts", npts, 30);
98 Array<OneD, NekDouble> x_c(npts);
99 Array<OneD, NekDouble> y_c(npts);
100
101 NekDouble trans;
102 vSession->LoadParameter("WidthOfLayers", trans, 0.1);
103
104 Computestreakpositions(streak, x_c, y_c, cr, trans);
105
106 cout << "# x_c y_c" << endl;
107 for (i = 0; i < npts; ++i)
108 {
109 fprintf(stdout, "%12.10lf %12.10lf \n", x_c[i], y_c[i]);
110 // cout << x_c[i] << " " << y_c[i] << endl;
111 }
112}
int main(int argc, char *argv[])
void Computestreakpositions(MultiRegions::ExpListSharedPtr &streak, Array< OneD, NekDouble > &xc, Array< OneD, NekDouble > &yc, NekDouble cr, NekDouble trans)
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
void Import(const std::string &infilename, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, FieldMetaDataMap &fieldinfomap, const Array< OneD, int > &ElementIDs)
This function allows for data to be imported from an FLD file when a session and/or communicator is n...
Definition: FieldIO.cpp:288
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174
double NekDouble
STL namespace.