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 
40 #include <MultiRegions/ExpList.h>
44 
45 using namespace std;
46 using namespace Nektar;
47 
48 int main(int argc, char *argv[])
49 {
50  int i, j, k;
51 
52  if (argc != 6)
53  {
54  fprintf(stderr, "Usage: Fld2DTo2D5 2dmeshfile 2dfieldfile 3dmeshfile "
55  "3dfieldfile outfield\n");
56  exit(1);
57  }
58  string datasave(argv[5]);
59 
60  string mesh2d(argv[1]);
61  string mesh3d(argv[3]);
62 
63  // create 2d session
65  LibUtilities::SessionReader::CreateInstance(2, argv);
66  std::vector<std::string> filenames;
67  filenames.push_back(mesh3d);
68  // create 3D session
70  LibUtilities::SessionReader::CreateInstance(2, argv, filenames,
71  vSession2d->GetComm());
72 
74  SpatialDomains::MeshGraph::Read(vSession2d);
76  SpatialDomains::MeshGraph::Read(vSession3d);
77  // 2D
78  string field2dfile(argv[2]);
79  vector<LibUtilities::FieldDefinitionsSharedPtr> field2ddef;
80  vector<vector<NekDouble>> field2ddata;
81  LibUtilities::Import(field2dfile, field2ddef, field2ddata);
82  // 3D
83  string field3dfile(argv[4]);
84  vector<LibUtilities::FieldDefinitionsSharedPtr> field3ddef;
85  vector<vector<NekDouble>> field3ddata;
86  LibUtilities::Import(field3dfile, field3ddef, field3ddata);
87  vector<vector<NekDouble>> field3ddatanew(field3ddef.size());
88  // Set up Expansion information
89  vector<vector<LibUtilities::PointsType>> pointstype2d;
90  vector<vector<LibUtilities::PointsType>> pointstype3d;
91  for (i = 0; i < field2ddef.size(); ++i)
92  {
93  vector<LibUtilities::PointsType> ptype2d;
94  for (j = 0; j < 2; ++j)
95  {
96  ptype2d.push_back(LibUtilities::ePolyEvenlySpaced);
97  }
98  pointstype2d.push_back(ptype2d);
99  }
100  graphShPt2d->SetExpansionInfo(field2ddef, pointstype2d);
101  for (i = 0; i < field3ddef.size(); ++i)
102  {
103  vector<LibUtilities::PointsType> ptype3d;
104  for (j = 0; j < 2; ++j)
105  {
106  ptype3d.push_back(LibUtilities::ePolyEvenlySpaced);
107  }
108  pointstype3d.push_back(ptype3d);
109  }
110  graphShPt3d->SetExpansionInfo(field3ddef, pointstype3d);
111  bool useFFT = false;
112  bool dealiasing = false;
113  // Define Expansion
114  // int expdim2d = graphShPt2d->GetMeshDimension();
115  int nfields2d = field2ddef[0]->m_fields.size();
116  // int expdim3d = graphShPt3d->GetMeshDimension();
117  int nfields3d = field3ddef[0]->m_fields.size();
118  // Gen 2d
122  vSession2d, graphShPt2d);
123  Exp2d[0] = Exp2D;
124  for (i = 1; i < nfields2d; ++i)
125  {
126  Exp2d[i] =
128  }
129  // Gen 3d
132  // Define Homogeneous expansion
133  int nplanes;
134  // vSession3d->LoadParameter("HomModesZ",nplanes,field3ddef[0]->m_numModes[2]);
135  nplanes = field3ddef[0]->m_numModes[2];
136  cout << nplanes << endl;
137  // nplanes + 1 points
138  const LibUtilities::PointsKey Pkey(nplanes,
140  const LibUtilities::BasisKey Bkey(field3ddef[0]->m_basis[2], nplanes, Pkey);
141  NekDouble lz = field3ddef[0]->m_homogeneousLengths[0];
142  Exp3DH1 =
144  vSession3d, Bkey, lz, useFFT, dealiasing, graphShPt3d);
145  Exp3d[0] = Exp3DH1;
146  for (j = 1; j < nfields3d; ++j)
147  {
148  Exp3d[j] = MemoryManager<
149  MultiRegions::ExpList3DHomogeneous1D>::AllocateSharedPtr(*Exp3DH1);
150  }
151 
152  k = 0;
153  for (j = 0; j < nfields2d; ++j)
154  {
155  if (j < nfields2d - 1)
156  {
157  for (int i = 0; i < field2ddata.size(); ++i)
158  {
159  Exp2d[j]->ExtractDataToCoeffs(
160  field2ddef[i], field2ddata[i], field2ddef[i]->m_fields[j],
161  Exp3d[j]->GetPlane(k)->UpdateCoeffs());
162  }
163  }
164  if (j == nfields2d - 1)
165  {
166  for (int i = 0; i < field2ddata.size(); ++i)
167  {
168  Exp2d[j]->ExtractDataToCoeffs(
169  field2ddef[i], field2ddata[i], field2ddef[i]->m_fields[j],
170  Exp3d[j + 1]->GetPlane(k)->UpdateCoeffs());
171  }
172  }
173  }
175  vSession3d->GetVariables().size());
176  for (j = 0; j < fieldcoeffs.size(); ++j)
177  {
178  fieldcoeffs[j] = Exp3d[j]->UpdateCoeffs();
179  for (int i = 0; i < field3ddef.size(); ++i)
180  {
181  Exp3d[0]->AppendFieldData(field3ddef[i], field3ddatanew[i],
182  fieldcoeffs[j]);
183  }
184  }
185  LibUtilities::Write(datasave, field3ddef, field3ddatanew);
186  return 0;
187 }
188 // Only for 2d to 2d5 Hui Xu 23 Aug 2013
int main(int argc, char *argv[])
Definition: Fld2DTo2D5.cpp:48
Describes the specification for a Basis.
Definition: Basis.h:50
Defines a specification for a set of points.
Definition: Points.h:59
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 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:247
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:290
std::shared_ptr< SessionReader > SessionReaderSharedPtr
@ ePolyEvenlySpaced
1D Evenly-spaced points using Lagrange polynomial
Definition: PointsType.h:75
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:172
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble