12 using namespace Nektar;
14 int main(
int argc,
char *argv[])
20 Array<OneD,MultiRegions::ExpListSharedPtr> &Exp,
int nvariables);
26 fprintf(stderr,
"Usage: SplitFld meshfile fieldfile\n");
37 string meshfile(argv[argc-2]);
50 string fieldfile(argv[argc-1]);
51 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
52 vector<vector<NekDouble> > fielddata;
58 nfields = fielddef[0]->m_fields.size();
59 Array<OneD, MultiRegions::ExpListSharedPtr> Exp;
60 Exp = Array<OneD, MultiRegions::ExpListSharedPtr>(nfields);
62 std::string solvtype = vSession->GetSolverInfo(
"SOLVERTYPE");
63 if(solvtype ==
"CoupledLinearisedNS" && vSession->DefinesSolverInfo(
"HOMOGENEOUS") )
66 SetFields(graphShPt,boundaryConditions,vSession,Exp,nfields-1);
70 int lastfield = nfields-1;
71 cout<<
"Set pressure: "<<lastfield<<endl;
72 int nplanes = fielddef[0]->m_numModes[2];
75 NekDouble lz = fielddef[0]->m_homogeneousLengths[0];
78 Exp[lastfield] = Exp3DH1;
84 SetFields(graphShPt,boundaryConditions,vSession,Exp,nfields);
90 for(
int j = 0; j < nfields; ++j)
92 for(
int i = 0; i < fielddef.size(); ++i)
94 Exp[j]->ExtractDataToCoeffs(fielddef [i],
96 fielddef [i]->m_fields[j],
97 Exp[j]->UpdateCoeffs());
99 Exp[j]->BwdTrans_IterPerExp(Exp[j]->GetCoeffs(),Exp[j]->UpdatePhys());
106 string fldfilename(argv[2]);
107 string out = fldfilename.substr(0, fldfilename.find_last_of(
"."));
108 string endfile(
"split.fld");
117 Array<OneD, Array<OneD, NekDouble> > fieldcoeffs(Exp.num_elements());
120 for(
int i = 0; i < Exp.num_elements(); ++i)
122 fieldcoeffs[i] = Exp[i]->UpdateCoeffs();
134 for(
int j =0; j<nfields; j++)
137 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
138 = Exp[j]->GetFieldDefinitions();
139 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
141 for(
int i = 0; i < FieldDef.size(); ++i)
143 var = fielddef[i]->m_fields[j];
145 FieldDef[i]->m_fields.push_back(var);
146 Exp[j]->AppendFieldData(FieldDef[i], FieldData[i],fieldcoeffs[j]);
149 outfile +=
"_"+var+
"_"+endfile;
166 Array<OneD,MultiRegions::ExpListSharedPtr> &Exp,
int nvariables)
173 bool DeclareCoeffPhysArrays =
true;
189 enum HomogeneousType HomogeneousType = eNotHomogeneous;
191 if(session->DefinesSolverInfo(
"HOMOGENEOUS"))
193 std::string HomoStr = session->GetSolverInfo(
"HOMOGENEOUS");
196 if((HomoStr ==
"HOMOGENEOUS1D")||(HomoStr ==
"Homogeneous1D")||
197 (HomoStr ==
"1D")||(HomoStr ==
"Homo1D"))
199 HomogeneousType = eHomogeneous1D;
200 npointsZ = session->GetParameter(
"HomModesZ");
201 LhomZ = session->GetParameter(
"LZ");
205 if((HomoStr ==
"HOMOGENEOUS2D")||(HomoStr ==
"Homogeneous2D")||
206 (HomoStr ==
"2D")||(HomoStr ==
"Homo2D"))
208 HomogeneousType = eHomogeneous2D;
209 npointsY = session->GetParameter(
"HomModesY");
210 LhomY = session->GetParameter(
"LY");
211 npointsZ = session->GetParameter(
"HomModesZ");
212 LhomZ = session->GetParameter(
"LZ");
216 if((HomoStr ==
"HOMOGENEOUS3D")||(HomoStr ==
"Homogeneous3D")||
217 (HomoStr ==
"3D")||(HomoStr ==
"Homo3D"))
219 HomogeneousType = eHomogeneous3D;
220 npointsX = session->GetParameter(
"HomModesX");
221 LhomX = session->GetParameter(
"LX");
222 npointsY = session->GetParameter(
"HomModesY");
223 LhomY = session->GetParameter(
"LY");
224 npointsZ = session->GetParameter(
"HomModesZ");
225 LhomZ = session->GetParameter(
"LZ");
229 if(session->DefinesSolverInfo(
"USEFFT"))
236 int expdim = mesh->GetMeshDimension();
245 if(HomogeneousType == eHomogeneous2D)
252 for(i = 0 ; i < nvariables; i++)
255 ::AllocateSharedPtr(session,BkeyY,BkeyZ,LhomY,LhomZ,useFFT,deal,mesh,session->GetVariable(i));
260 for(i = 0 ; i < nvariables; i++)
271 if(HomogeneousType == eHomogeneous1D)
275 for(i = 0 ; i < nvariables; i++)
289 for(i = 1 ; i < nvariables; i++)
300 if(HomogeneousType == eHomogeneous3D)
302 ASSERTL0(
false,
"3D fully periodic problems not implemented yet");
312 for(i = 1 ; i < nvariables; i++)
321 ASSERTL0(
false,
"Expansion dimension not recognised");