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 48 of file Fld2DTo2D5.cpp.

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}
Describes the specification for a Basis.
Definition: Basis.h:45
Defines a specification for a set of points.
Definition: Points.h:50
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 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:288
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:245
@ ePolyEvenlySpaced
1D Evenly-spaced points using Lagrange polynomial
Definition: PointsType.h:73
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().