Nektar++
Functions
Fld2DTo2D5.cpp File Reference
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <vector>
#include <MultiRegions/ExpList.h>
#include <MultiRegions/ExpList1D.h>
#include <MultiRegions/ExpList2D.h>
#include <MultiRegions/ExpList2DHomogeneous1D.h>
#include <MultiRegions/ExpList3DHomogeneous1D.h>
#include <MultiRegions/ExpList3DHomogeneous2D.h>
Include dependency graph for Fld2DTo2D5.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 14 of file Fld2DTo2D5.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::LibUtilities::SessionReader::CreateInstance(), Nektar::LibUtilities::ePolyEvenlySpaced, Nektar::LibUtilities::Import(), Nektar::SpatialDomains::MeshGraph::Read(), and Nektar::LibUtilities::Write().

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
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, vSession2d->GetComm());
37 
38  SpatialDomains::MeshGraphSharedPtr graphShPt2d = SpatialDomains::MeshGraph::Read(vSession2d);
39  SpatialDomains::MeshGraphSharedPtr graphShPt3d = SpatialDomains::MeshGraph::Read(vSession3d);
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 }
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:50
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:106
1D Evenly-spaced points using Lagrange polynomial
Definition: PointsType.h:63
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
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:72
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:432
Describes the specification for a Basis.
Definition: Basis.h:50