Nektar++
Fld2DTo2D5.cpp
Go to the documentation of this file.
1 #include <cstdio>
2 #include <cstdlib>
3 #include <iomanip>
4 #include <vector>
5 
6 #include <MultiRegions/ExpList.h>
10 
11 using namespace std;
12 using namespace Nektar;
13 
14 int main(int argc, char *argv[])
15 {
16  int i, j, k;
17 
18  if (argc != 6)
19  {
20  fprintf(stderr, "Usage: Fld2DTo2D5 2dmeshfile 2dfieldfile 3dmeshfile "
21  "3dfieldfile outfield\n");
22  exit(1);
23  }
24  string datasave(argv[5]);
25 
26  string mesh2d(argv[1]);
27  string mesh3d(argv[3]);
28 
29  // create 2d session
31  LibUtilities::SessionReader::CreateInstance(2, argv);
32  std::vector<std::string> filenames;
33  filenames.push_back(mesh3d);
34  // create 3D session
36  LibUtilities::SessionReader::CreateInstance(2, argv, filenames,
37  vSession2d->GetComm());
38 
40  SpatialDomains::MeshGraph::Read(vSession2d);
42  SpatialDomains::MeshGraph::Read(vSession3d);
43  // 2D
44  string field2dfile(argv[2]);
45  vector<LibUtilities::FieldDefinitionsSharedPtr> field2ddef;
46  vector<vector<NekDouble>> field2ddata;
47  LibUtilities::Import(field2dfile, field2ddef, field2ddata);
48  // 3D
49  string field3dfile(argv[4]);
50  vector<LibUtilities::FieldDefinitionsSharedPtr> field3ddef;
51  vector<vector<NekDouble>> field3ddata;
52  LibUtilities::Import(field3dfile, field3ddef, field3ddata);
53  vector<vector<NekDouble>> field3ddatanew(field3ddef.size());
54  // Set up Expansion information
55  vector<vector<LibUtilities::PointsType>> pointstype2d;
56  vector<vector<LibUtilities::PointsType>> pointstype3d;
57  for (i = 0; i < field2ddef.size(); ++i)
58  {
59  vector<LibUtilities::PointsType> ptype2d;
60  for (j = 0; j < 2; ++j)
61  {
62  ptype2d.push_back(LibUtilities::ePolyEvenlySpaced);
63  }
64  pointstype2d.push_back(ptype2d);
65  }
66  graphShPt2d->SetExpansionInfo(field2ddef, pointstype2d);
67  for (i = 0; i < field3ddef.size(); ++i)
68  {
69  vector<LibUtilities::PointsType> ptype3d;
70  for (j = 0; j < 2; ++j)
71  {
72  ptype3d.push_back(LibUtilities::ePolyEvenlySpaced);
73  }
74  pointstype3d.push_back(ptype3d);
75  }
76  graphShPt3d->SetExpansionInfo(field3ddef, pointstype3d);
77  bool useFFT = false;
78  bool dealiasing = false;
79  // Define Expansion
80  // int expdim2d = graphShPt2d->GetMeshDimension();
81  int nfields2d = field2ddef[0]->m_fields.size();
82  // int expdim3d = graphShPt3d->GetMeshDimension();
83  int nfields3d = field3ddef[0]->m_fields.size();
84  // Gen 2d
88  vSession2d, graphShPt2d);
89  Exp2d[0] = Exp2D;
90  for (i = 1; i < nfields2d; ++i)
91  {
92  Exp2d[i] =
94  }
95  // Gen 3d
98  // Define Homogeneous expansion
99  int nplanes;
100  // vSession3d->LoadParameter("HomModesZ",nplanes,field3ddef[0]->m_numModes[2]);
101  nplanes = field3ddef[0]->m_numModes[2];
102  cout << nplanes << endl;
103  // nplanes + 1 points
104  const LibUtilities::PointsKey Pkey(nplanes,
106  const LibUtilities::BasisKey Bkey(field3ddef[0]->m_basis[2], nplanes, Pkey);
107  NekDouble lz = field3ddef[0]->m_homogeneousLengths[0];
108  Exp3DH1 =
110  vSession3d, Bkey, lz, useFFT, dealiasing, graphShPt3d);
111  Exp3d[0] = Exp3DH1;
112  for (j = 1; j < nfields3d; ++j)
113  {
114  Exp3d[j] = MemoryManager<
115  MultiRegions::ExpList3DHomogeneous1D>::AllocateSharedPtr(*Exp3DH1);
116  }
117 
118  k = 0;
119  for (j = 0; j < nfields2d; ++j)
120  {
121  if (j < nfields2d - 1)
122  {
123  for (int i = 0; i < field2ddata.size(); ++i)
124  {
125  Exp2d[j]->ExtractDataToCoeffs(
126  field2ddef[i], field2ddata[i], field2ddef[i]->m_fields[j],
127  Exp3d[j]->GetPlane(k)->UpdateCoeffs());
128  }
129  }
130  if (j == nfields2d - 1)
131  {
132  for (int i = 0; i < field2ddata.size(); ++i)
133  {
134  Exp2d[j]->ExtractDataToCoeffs(
135  field2ddef[i], field2ddata[i], field2ddef[i]->m_fields[j],
136  Exp3d[j + 1]->GetPlane(k)->UpdateCoeffs());
137  }
138  }
139  }
141  vSession3d->GetVariables().size());
142  for (j = 0; j < fieldcoeffs.size(); ++j)
143  {
144  fieldcoeffs[j] = Exp3d[j]->UpdateCoeffs();
145  for (int i = 0; i < field3ddef.size(); ++i)
146  {
147  Exp3d[0]->AppendFieldData(field3ddef[i], field3ddatanew[i],
148  fieldcoeffs[j]);
149  }
150  }
151  LibUtilities::Write(datasave, field3ddef, field3ddatanew);
152  return 0;
153 }
154 // Only for 2d to 2d5 Hui Xu 23 Aug 2013
int main(int argc, char *argv[])
Definition: Fld2DTo2D5.cpp:14
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:248
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:291
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:1
double NekDouble