38 #include <boost/algorithm/string.hpp>
57 UnsteadySystem(pSession),
58 AdvectionSystem(pSession),
59 m_subSteppingScheme(false),
60 m_SmoothAdvection(false),
70 int numfields =
m_fields.num_elements();
71 std::string velids[] = {
"u",
"v",
"w"};
78 for(j = 0; j < numfields; ++j)
81 if(boost::iequals(velids[i], var))
87 ASSERTL0(j != numfields,
"Failed to find field: " + var);
125 for(
int n = 0; n <
m_fields[0]->GetBndConditions().num_elements(); ++n)
130 m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
132 m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
134 m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
136 m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
138 m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
140 m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
142 "Unknown USERDEFINEDTYPE boundary condition");
148 ASSERTL0(
false,
"Unknown or undefined equation type");
154 std::string vConvectiveType;
158 vConvectiveType =
"NoAdvection";
162 vConvectiveType =
"Convective";
165 vConvectiveType =
"Linearised";
174 vConvectiveType =
m_session->GetTag(
"AdvectiveType");
191 for (i = 0; i <
m_fields.num_elements(); ++i)
195 Array<OneD, const SpatialDomains::BoundaryConditionShPtr > BndConds;
196 Array<OneD, MultiRegions::ExpListSharedPtr> BndExp;
199 BndConds =
m_fields[i]->GetBndConditions();
200 BndExp =
m_fields[i]->GetBndCondExpansions();
201 for(
int n = 0; n < BndConds.num_elements(); ++n)
206 "Radiation boundary condition must be of type Robin <R>");
213 radpts += BndExp[n]->GetTotPoints();
217 m_fieldsRadiationFactor[i] = Array<OneD, NekDouble>(radpts);
221 for(
int n = 0; n < BndConds.num_elements(); ++n)
226 int npoints = BndExp[n]->GetNpoints();
227 Array<OneD, NekDouble> x0(npoints,0.0);
228 Array<OneD, NekDouble> x1(npoints,0.0);
229 Array<OneD, NekDouble> x2(npoints,0.0);
230 Array<OneD, NekDouble> tmpArray;
232 BndExp[n]->GetCoords(x0,x1,x2);
235 boost::static_pointer_cast<
237 >(BndConds[n])->m_robinPrimitiveCoeff;
240 tmpArray = m_fieldsRadiationFactor[i]+ radpts);
265 Array<
OneD, Array<OneD, NekDouble> > &physfield,
266 Array<
OneD, Array<OneD, NekDouble> > &flux)
268 ASSERTL1(flux.num_elements() ==
m_velocity.num_elements(),
"Dimension of flux array and velocity array do not match");
270 for(
int j = 0; j < flux.num_elements(); ++j)
280 Array<
OneD, Array<OneD, NekDouble> > &numflux)
292 Array<OneD, NekDouble> Fwd(2*nTracePts);
295 Array<OneD, NekDouble> Bwd = Fwd + nTracePts;
298 Array<OneD, NekDouble> Vn (nTracePts, 0.0);
301 for(i = 0; i < nDimensions; ++i)
308 for(i = 0; i < numflux.num_elements(); ++i)
311 m_fields[i]->GetFwdBwdTracePhys(physfield[i], Fwd, Bwd);
314 m_fields[i]->GetTrace()->Upwind(Vn, Fwd, Bwd, numflux[i]);
318 Vmath::Vmul(nTracePts, numflux[i], 1, Vn, 1, numflux[i], 1);
326 Array<
OneD, Array<OneD, NekDouble> > &outarray,
327 Array<OneD, NekDouble> &wk)
330 int nqtot =
m_fields[0]->GetTotPoints();
332 Array<OneD, Array<OneD, NekDouble> > velocity(VelDim);
333 Array<OneD, NekDouble > Deriv;
335 for(i = 0; i < VelDim; ++i)
339 velocity[i] = Array<OneD, NekDouble>(nqtot,0.0);
349 if(wk.num_elements())
351 ASSERTL0(wk.num_elements() >= nqtot*VelDim,
352 "Workspace is not sufficient");
357 Deriv = Array<OneD, NekDouble> (nqtot*VelDim);
361 velocity, inarray, outarray,
m_time);
371 int nvariables =
m_fields.num_elements();
373 for (i = 0; i < nvariables; ++i)
375 for(n = 0; n <
m_fields[i]->GetBndConditions().num_elements(); ++n)
377 if(
m_fields[i]->GetBndConditions()[n]->GetUserDefined() ==
381 m_fields[i]->EvaluateBoundaryConditions(time, varName);
398 Array<OneD, const SpatialDomains::BoundaryConditionShPtr > BndConds;
399 Array<OneD, MultiRegions::ExpListSharedPtr> BndExp;
402 BndConds =
m_fields[fieldid]->GetBndConditions();
403 BndExp =
m_fields[fieldid]->GetBndCondExpansions();
409 int elmtid,nq,offset, boundary;
410 Array<OneD, NekDouble> Bvals, U;
414 for(cnt = n = 0; n < BndConds.num_elements(); ++n)
420 for(i = 0; i < BndExp[n]->GetExpSize(); ++i,cnt++)
423 elmt =
m_fields[fieldid]->GetExp(elmtid);
424 offset =
m_fields[fieldid]->GetPhys_Offset(elmtid);
426 U =
m_fields[fieldid]->UpdatePhys() + offset;
427 Bc = BndExp[n]->GetExp(i);
432 nq = Bc->GetTotPoints();
433 Array<OneD, NekDouble> ubc(nq);
434 elmt->GetTracePhysVals(boundary,Bc,U,ubc);
439 Bvals = BndExp[n]->UpdateCoeffs()+BndExp[n]->GetCoeff_Offset(i);
441 Bc->IProductWRTBase(ubc,Bvals);
443 cnt1 += BndExp[n]->GetTotPoints();
451 cnt += BndExp[n]->GetExpSize();
455 ASSERTL0(
false,
"Unknown USERDEFINEDTYPE in pressure boundary condition");
478 bool returnval =
false;
483 int ncoeffs =
m_fields[0]->GetNcoeffs();
485 for(
int i = 0; i <
m_fields.num_elements(); ++i)
506 int n_element =
m_fields[0]->GetExpSize();
509 Array<OneD, int> ExpOrderList (n_element, ExpOrder);
513 Array<OneD, NekDouble> cfl (n_element, 0.0);
514 Array<OneD, NekDouble> stdVelocity(n_element, 0.0);
515 Array<OneD, Array<OneD, NekDouble> > velfields;
519 velfields = Array<OneD, Array<OneD, NekDouble> >(2);
521 for(
int i = 0; i < 2; ++i)
528 velfields = Array<OneD, Array<OneD, NekDouble> >(n_vel);
530 for(
int i = 0; i < n_vel; ++i)
538 for(
int el = 0; el < n_element; ++el)
540 cfl[el] =
m_timestep*(stdVelocity[el] * cLambda *
541 (ExpOrder[el]-1) * (ExpOrder[el]-1));
552 int n_element =
m_fields[0]->GetExpSize();
559 CFL = CFL_loc = cfl[elmtid];
563 elmtid =
m_fields[0]->GetExp(elmtid)->GetGeom()->GetGlobalID();
574 elmtid = elmtid%
m_fields[0]->GetPlane(0)->GetExpSize();
601 if(
m_comm->GetRank() == 0)
603 cout <<
"CFL (zero plane): "<< cfl <<
" (in elmt "
604 << elmtid <<
")" << endl;
612 cout <<
"Reached Steady State to tolerance "