Nektar++
Fld2DTo2D5.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: Fld2DTo2D5.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:
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#include <cstdio>
36#include <cstdlib>
37#include <iomanip>
38#include <vector>
39
45
46using namespace std;
47using namespace Nektar;
48
49int main(int argc, char *argv[])
50{
51 int i, j, k;
52
53 if (argc != 6)
54 {
55 fprintf(stderr, "Usage: Fld2DTo2D5 2dmeshfile 2dfieldfile 3dmeshfile "
56 "3dfieldfile outfield\n");
57 exit(1);
58 }
59 string datasave(argv[5]);
60
61 string mesh2d(argv[1]);
62 string mesh3d(argv[3]);
63
64 // create 2d session
66 LibUtilities::SessionReader::CreateInstance(2, argv);
67 std::vector<std::string> filenames;
68 filenames.push_back(mesh3d);
69 // create 3D session
71 LibUtilities::SessionReader::CreateInstance(2, argv, filenames,
72 vSession2d->GetComm());
73
75 SpatialDomains::MeshGraphIO::Read(vSession2d);
77 SpatialDomains::MeshGraphIO::Read(vSession3d);
78 // 2D
79 string field2dfile(argv[2]);
80 vector<LibUtilities::FieldDefinitionsSharedPtr> field2ddef;
81 vector<vector<NekDouble>> field2ddata;
82 LibUtilities::Import(field2dfile, field2ddef, field2ddata);
83 // 3D
84 string field3dfile(argv[4]);
85 vector<LibUtilities::FieldDefinitionsSharedPtr> field3ddef;
86 vector<vector<NekDouble>> field3ddata;
87 LibUtilities::Import(field3dfile, field3ddef, field3ddata);
88 vector<vector<NekDouble>> field3ddatanew(field3ddef.size());
89 // Set up Expansion information
90 vector<vector<LibUtilities::PointsType>> pointstype2d;
91 vector<vector<LibUtilities::PointsType>> pointstype3d;
92 for (i = 0; i < field2ddef.size(); ++i)
93 {
94 vector<LibUtilities::PointsType> ptype2d;
95 for (j = 0; j < 2; ++j)
96 {
97 ptype2d.push_back(LibUtilities::ePolyEvenlySpaced);
98 }
99 pointstype2d.push_back(ptype2d);
100 }
101 graphShPt2d->SetExpansionInfo(field2ddef, pointstype2d);
102 for (i = 0; i < field3ddef.size(); ++i)
103 {
104 vector<LibUtilities::PointsType> ptype3d;
105 for (j = 0; j < 2; ++j)
106 {
107 ptype3d.push_back(LibUtilities::ePolyEvenlySpaced);
108 }
109 pointstype3d.push_back(ptype3d);
110 }
111 graphShPt3d->SetExpansionInfo(field3ddef, pointstype3d);
112 bool useFFT = false;
113 bool dealiasing = false;
114 // Define Expansion
115 // int expdim2d = graphShPt2d->GetMeshDimension();
116 int nfields2d = field2ddef[0]->m_fields.size();
117 // int expdim3d = graphShPt3d->GetMeshDimension();
118 int nfields3d = field3ddef[0]->m_fields.size();
119 // Gen 2d
123 vSession2d, graphShPt2d);
124 Exp2d[0] = Exp2D;
125 for (i = 1; i < nfields2d; ++i)
126 {
127 Exp2d[i] =
129 }
130 // Gen 3d
133 // Define Homogeneous expansion
134 int nplanes;
135 // vSession3d->LoadParameter("HomModesZ",nplanes,field3ddef[0]->m_numModes[2]);
136 nplanes = field3ddef[0]->m_numModes[2];
137 cout << nplanes << endl;
138 // nplanes + 1 points
139 const LibUtilities::PointsKey Pkey(nplanes,
141 const LibUtilities::BasisKey Bkey(field3ddef[0]->m_basis[2], nplanes, Pkey);
142 NekDouble lz = field3ddef[0]->m_homogeneousLengths[0];
143 Exp3DH1 =
145 vSession3d, Bkey, lz, useFFT, dealiasing, graphShPt3d);
146 Exp3d[0] = Exp3DH1;
147 for (j = 1; j < nfields3d; ++j)
148 {
149 Exp3d[j] = MemoryManager<
150 MultiRegions::ExpList3DHomogeneous1D>::AllocateSharedPtr(*Exp3DH1);
151 }
152
153 k = 0;
154 for (j = 0; j < nfields2d; ++j)
155 {
156 if (j < nfields2d - 1)
157 {
158 for (int i = 0; i < field2ddata.size(); ++i)
159 {
160 Exp2d[j]->ExtractDataToCoeffs(
161 field2ddef[i], field2ddata[i], field2ddef[i]->m_fields[j],
162 Exp3d[j]->GetPlane(k)->UpdateCoeffs());
163 }
164 }
165 if (j == nfields2d - 1)
166 {
167 for (int i = 0; i < field2ddata.size(); ++i)
168 {
169 Exp2d[j]->ExtractDataToCoeffs(
170 field2ddef[i], field2ddata[i], field2ddef[i]->m_fields[j],
171 Exp3d[j + 1]->GetPlane(k)->UpdateCoeffs());
172 }
173 }
174 }
176 vSession3d->GetVariables().size());
177 for (j = 0; j < fieldcoeffs.size(); ++j)
178 {
179 fieldcoeffs[j] = Exp3d[j]->UpdateCoeffs();
180 for (int i = 0; i < field3ddef.size(); ++i)
181 {
182 Exp3d[0]->AppendFieldData(field3ddef[i], field3ddatanew[i],
183 fieldcoeffs[j]);
184 }
185 }
186 LibUtilities::Write(datasave, field3ddef, field3ddatanew);
187 return 0;
188}
189// Only for 2d to 2d5 Hui Xu 23 Aug 2013
int main(int argc, char *argv[])
Definition: Fld2DTo2D5.cpp:49
Describes the specification for a Basis.
Definition: Basis.h:45
Defines a specification for a set of points.
Definition: Points.h:50
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
Abstraction of a two-dimensional multi-elemental expansion which is merely a collection of local expa...
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
void Write(const std::string &outFile, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, const FieldMetaDataMap &fieldinfomap, const bool backup)
This function allows for data to be written to an FLD file when a session and/or communicator is not ...
Definition: FieldIO.cpp:245
@ ePolyEvenlySpaced
1D Evenly-spaced points using Lagrange polynomial
Definition: PointsType.h:73
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< ExpList3DHomogeneous1D > ExpList3DHomogeneous1DSharedPtr
Shared pointer to an ExpList3DHomogeneous1D object.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174
double NekDouble
STL namespace.