Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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>
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,
21  "Usage: Fld2DTo2D5 2dmeshfile 2dfieldfile 3dmeshfile 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
32  std::vector<std::string> filenames;
33  filenames.push_back(mesh3d);
34  //create 3D session
36  = LibUtilities::SessionReader::CreateInstance(2, argv, filenames, vSession2d->GetComm());
37 
40  //2D
41  string field2dfile(argv[2]);
42  vector<LibUtilities::FieldDefinitionsSharedPtr> field2ddef;
43  vector<vector<NekDouble> > field2ddata;
44  LibUtilities::Import(field2dfile,field2ddef,field2ddata);
45  //3D
46  string field3dfile(argv[4]);
47  vector<LibUtilities::FieldDefinitionsSharedPtr> field3ddef;
48  vector<vector<NekDouble> > field3ddata;
49  LibUtilities::Import(field3dfile,field3ddef,field3ddata);
50  vector<vector<NekDouble> > field3ddatanew(field3ddef.size());
51  // Set up Expansion information
52  vector< vector<LibUtilities::PointsType> > pointstype2d;
53  vector< vector<LibUtilities::PointsType> > pointstype3d;
54  for(i = 0; i < field2ddef.size(); ++i)
55  {
56  vector<LibUtilities::PointsType> ptype2d;
57  for(j = 0; j < 2; ++j)
58  {
59  ptype2d.push_back(LibUtilities::ePolyEvenlySpaced);
60  }
61  pointstype2d.push_back(ptype2d);
62  }
63  graphShPt2d->SetExpansions(field2ddef,pointstype2d);
64  for(i = 0; i < field3ddef.size(); ++i)
65  {
66  vector<LibUtilities::PointsType> ptype3d;
67  for(j = 0; j < 2; ++j)
68  {
69  ptype3d.push_back(LibUtilities::ePolyEvenlySpaced);
70  }
71  pointstype3d.push_back(ptype3d);
72  }
73  graphShPt3d->SetExpansions(field3ddef,pointstype3d);
74  bool useFFT = false;
75  bool dealiasing = false;
76  // Define Expansion
77  //int expdim2d = graphShPt2d->GetMeshDimension();
78  int nfields2d = field2ddef[0]->m_fields.size();
79  //int expdim3d = graphShPt3d->GetMeshDimension();
80  int nfields3d = field3ddef[0]->m_fields.size();
81  //Gen 2d
84  Exp2D = MemoryManager<MultiRegions::ExpList2D>::AllocateSharedPtr(vSession2d,graphShPt2d);
85  Exp2d[0] = Exp2D;
86  for(i = 1; i < nfields2d; ++i)
87  {
89  }
90  //Gen 3d
93  // Define Homogeneous expansion
94  int nplanes;
95  //vSession3d->LoadParameter("HomModesZ",nplanes,field3ddef[0]->m_numModes[2]);
96  nplanes = field3ddef[0]->m_numModes[2];
97  cout<< nplanes << endl;
98  // nplanes + 1 points
100  const LibUtilities::BasisKey Bkey(field3ddef[0]->m_basis[2],nplanes,Pkey);
101  NekDouble lz = field3ddef[0]->m_homogeneousLengths[0];
102  Exp3DH1 = MemoryManager<MultiRegions::ExpList3DHomogeneous1D>::AllocateSharedPtr(vSession3d,Bkey,lz,useFFT,dealiasing,graphShPt3d);
103  Exp3d[0] = Exp3DH1;
104  for(j = 1; j < nfields3d; ++j)
105  {
107  }
108 
109  k=0;
110  for(j = 0; j < nfields2d; ++j)
111  {
112  if (j< nfields2d-1)
113  {
114  for(int i = 0; i < field2ddata.size(); ++i)
115  {
116  Exp2d[j]->ExtractDataToCoeffs(
117  field2ddef[i],
118  field2ddata[i],
119  field2ddef[i]->m_fields[j],
120  Exp3d[j]->GetPlane(k)->UpdateCoeffs());
121  }
122  }
123  if (j==nfields2d-1)
124  {
125  for(int i = 0; i < field2ddata.size(); ++i)
126  {
127  Exp2d[j]->ExtractDataToCoeffs(
128  field2ddef[i],
129  field2ddata[i],
130  field2ddef[i]->m_fields[j],
131  Exp3d[j+1]->GetPlane(k)->UpdateCoeffs());
132  }
133  }
134  }
135  Array<OneD, Array<OneD, NekDouble> > fieldcoeffs(vSession3d->GetVariables().size());
136  for(j = 0; j < fieldcoeffs.num_elements(); ++j)
137  {
138  fieldcoeffs[j] = Exp3d[j]->UpdateCoeffs();
139  for(int i = 0; i < field3ddef.size(); ++i)
140  {
141  Exp3d[0]->AppendFieldData(field3ddef[i], field3ddatanew[i],fieldcoeffs[j]);
142  }
143  }
144  LibUtilities::Write(datasave,field3ddef,field3ddatanew);
145  return 0;
146 }
147 // Only for 2d to 2d5 Hui Xu 23 Aug 2013
static boost::shared_ptr< MeshGraph > Read(const LibUtilities::SessionReaderSharedPtr &pSession, DomainRangeShPtr &rng=NullDomainRangeShPtr)
Definition: MeshGraph.cpp:119
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
void Import(const std::string &infilename, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, FieldMetaDataMap &fieldinfomap, const Array< OneD, int > ElementiDs)
Imports an FLD file.
Definition: FieldIO.cpp:115
1D Evenly-spaced points using Lagrange polynomial
Definition: PointsType.h:63
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
Defines a specification for a set of points.
Definition: Points.h:58
double NekDouble
boost::shared_ptr< ExpList2D > ExpList2DSharedPtr
Shared pointer to an ExpList2D object.
Definition: ExpList2D.h:49
int main(int argc, char *argv[])
Definition: Fld2DTo2D5.cpp:14
boost::shared_ptr< ExpList3DHomogeneous1D > ExpList3DHomogeneous1DSharedPtr
Shared pointer to an ExpList3DHomogeneous1D object.
void Write(const std::string &outFile, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, const FieldMetaDataMap &fieldinfomap)
Write a field file in serial only.
Definition: FieldIO.cpp:81
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:442
Describes the specification for a Basis.
Definition: Basis.h:50