Nektar++
Functions
Fld2DTo2D5.cpp File Reference
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <vector>
#include <MultiRegions/ExpList.h>
#include <MultiRegions/ExpList2DHomogeneous1D.h>
#include <MultiRegions/ExpList3DHomogeneous1D.h>
#include <MultiRegions/ExpList3DHomogeneous2D.h>

Go to the source code of this file.

Functions

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

Function Documentation

◆ main()

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

Definition at line 14 of file Fld2DTo2D5.cpp.

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->SetExpansionInfo(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->SetExpansionInfo(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
85  (vSession2d,graphShPt2d);
86  Exp2d[0] = Exp2D;
87  for(i = 1; i < nfields2d; ++i)
88  {
90  }
91  //Gen 3d
94  // Define Homogeneous expansion
95  int nplanes;
96  //vSession3d->LoadParameter("HomModesZ",nplanes,field3ddef[0]->m_numModes[2]);
97  nplanes = field3ddef[0]->m_numModes[2];
98  cout<< nplanes << endl;
99  // nplanes + 1 points
101  const LibUtilities::BasisKey Bkey(field3ddef[0]->m_basis[2],nplanes,Pkey);
102  NekDouble lz = field3ddef[0]->m_homogeneousLengths[0];
103  Exp3DH1 = MemoryManager<MultiRegions::ExpList3DHomogeneous1D>::AllocateSharedPtr(vSession3d,Bkey,lz,useFFT,dealiasing,graphShPt3d);
104  Exp3d[0] = Exp3DH1;
105  for(j = 1; j < nfields3d; ++j)
106  {
108  }
109 
110  k=0;
111  for(j = 0; j < nfields2d; ++j)
112  {
113  if (j< nfields2d-1)
114  {
115  for(int i = 0; i < field2ddata.size(); ++i)
116  {
117  Exp2d[j]->ExtractDataToCoeffs(
118  field2ddef[i],
119  field2ddata[i],
120  field2ddef[i]->m_fields[j],
121  Exp3d[j]->GetPlane(k)->UpdateCoeffs());
122  }
123  }
124  if (j==nfields2d-1)
125  {
126  for(int i = 0; i < field2ddata.size(); ++i)
127  {
128  Exp2d[j]->ExtractDataToCoeffs(
129  field2ddef[i],
130  field2ddata[i],
131  field2ddef[i]->m_fields[j],
132  Exp3d[j+1]->GetPlane(k)->UpdateCoeffs());
133  }
134  }
135  }
136  Array<OneD, Array<OneD, NekDouble> > fieldcoeffs(vSession3d->GetVariables().size());
137  for(j = 0; j < fieldcoeffs.size(); ++j)
138  {
139  fieldcoeffs[j] = Exp3d[j]->UpdateCoeffs();
140  for(int i = 0; i < field3ddef.size(); ++i)
141  {
142  Exp3d[0]->AppendFieldData(field3ddef[i], field3ddatanew[i],fieldcoeffs[j]);
143  }
144  }
145  LibUtilities::Write(datasave,field3ddef,field3ddatanew);
146  return 0;
147 }
Describes the specification for a Basis.
Definition: Basis.h:50
Defines a specification for a set of points.
Definition: Points.h:60
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
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:293
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:249
@ ePolyEvenlySpaced
1D Evenly-spaced points using Lagrange polynomial
Definition: PointsType.h:64
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

References Nektar::LibUtilities::ePolyEvenlySpaced, Nektar::LibUtilities::Import(), and Nektar::LibUtilities::Write().