40 #include <boost/algorithm/string.hpp>
57 : UnsteadySystem(pSession),
69 "Could not create mapping in VCSMapping.");
71 std::string vExtrapolation =
"Mapping";
84 int physTot =
m_fields[0]->GetTotPoints();
86 int intMethod =
m_intScheme->GetIntegrationMethod();
114 m_session->MatchSolverInfo(
"MappingImplicitPressure",
"True",
116 m_session->MatchSolverInfo(
"MappingImplicitViscous",
"True",
118 m_session->MatchSolverInfo(
"MappingNeglectViscous",
"True",
127 m_session->LoadParameter(
"MappingPressureTolerance",
129 m_session->LoadParameter(
"MappingViscousTolerance",
131 m_session->LoadParameter(
"MappingPressureRelaxation",
133 m_session->LoadParameter(
"MappingViscousRelaxation",
147 UnsteadySystem::v_DoInitialise();
151 boost::lexical_cast<std::string>(
m_kinvis);
168 int physTot =
m_fields[0]->GetTotPoints();
215 std::vector<SolverUtils::ForcingSharedPtr>::const_iterator x;
218 (*x)->Apply(
m_fields, inarray, outarray, time);
244 int physTot =
m_fields[0]->GetTotPoints();
253 for(
int i = 0; i < nvel; ++i)
257 m_fields[i]->HomogeneousBwdTrans(fields[i],wk);
266 m_fields[i]->HomogeneousFwdTrans(wk,wk);
269 Vmath::Vadd(physTot,wk,1,Forcing[0],1,Forcing[0],1);
271 Vmath::Smul(physTot,1.0/aii_Dt,Forcing[0],1,Forcing[0],1);
278 bool wavespace =
m_fields[0]->GetWaveSpace();
285 for(
int i = 0; i < tmp.num_elements(); i++)
301 m_mapping->DotGradJacobian(velocity, wk);
305 for(
int i = 0; i < nvel; ++i)
309 Vmath::Vmul(physTot, Jac, 1, tmp[i], 1, tmp[i], 1);
313 for(
int i = 0; i < nvel; ++i)
323 m_mapping->DotGradJacobian(tmp, velocity[0]);
326 Vmath::Vadd(physTot, velocity[0], 1, wk, 1, wk, 1);
338 m_fields[0]->HomogeneousFwdTrans(wk,wk);
341 Vmath::Vsub(physTot, Forcing[0], 1, wk, 1, Forcing[0], 1);
343 m_fields[0]->SetWaveSpace(wavespace);
357 int physTot =
m_fields[0]->GetTotPoints();
376 for (
int i=0; i<nvel; i++)
383 for (
int i=0; i<nvel; i++)
401 for (
int i=0; i<nvel; i++)
409 for (
int i=0; i<nvel; i++)
411 m_pressure->HomogeneousFwdTrans(Forcing[i],Forcing[i]);
418 for(
int i = 0; i < nvel; ++i)
420 Blas::Daxpy(physTot,-aii_dtinv,inarray[i],1,Forcing[i],1);
421 Blas::Dscal(physTot,1.0/
m_kinvis,&(Forcing[i])[0],1);
437 int physTot =
m_fields[0]->GetTotPoints();
439 bool converged =
false;
445 m_session->LoadParameter(
"MappingMaxIter",maxIter,5000);
455 for(
int i = 0; i < nvel; ++i)
479 "VCSMapping exceeded maximum number of iterations.");
490 for(
int i = 0; i < nvel; ++i)
493 previous_iter, gradP[i]);
496 m_pressure->HomogeneousBwdTrans(gradP[i], wk1[i]);
517 m_pressure->HomogeneousFwdTrans(F_corrected, F_corrected);
532 Vmath::Vadd(physTot, wk1[0], 1, F_corrected, 1, F_corrected, 1);
546 if ( forcing_L2 != 0)
563 std::cout <<
" Pressure system (mapping) converged in " << s <<
564 " iterations with error = " << error << std::endl;
583 int physTot =
m_fields[0]->GetTotPoints();
585 bool converged =
false;
590 m_session->LoadParameter(
"MappingMaxIter",maxIter,5000);
601 for(
int i = 0; i < nvel; ++i)
620 for(
int i = 0; i < nvel; ++i)
622 forcing_L2[i] =
m_fields[0]->L2(Forcing[i],wk[0]);
633 "VCSMapping exceeded maximum number of iterations.");
644 for (
int i = 0; i < nvel; ++i)
646 m_fields[0]->HomogeneousBwdTrans(previous_iter[i],
652 for (
int i = 0; i < nvel; ++i)
659 m_mapping->VelocityLaplacian(wk, F_corrected,
664 for (
int i = 0; i < nvel; ++i)
666 m_fields[0]->HomogeneousFwdTrans(F_corrected[i],
672 for (
int i = 0; i < nvel; ++i)
680 for (
int i = 0; i < nvel; ++i)
695 m_fields[i]->HelmSolve(F_corrected[i],
703 error =
m_fields[i]->L2(outarray[i], previous_iter[i]);
705 if ( forcing_L2[i] != 0)
719 if (error > max_error)
725 Vmath::Vcopy(physTot, outarray[i], 1, previous_iter[i], 1);
730 std::cout <<
" Velocity system (mapping) converged in " << s <<
731 " iterations with error = " << max_error << std::endl;
742 int physTot =
m_fields[0]->GetTotPoints();
760 m_fields[0]->HomogeneousBwdTrans(vel[i],velPhys[i]);
781 Vmath::Vadd(physTot, tmp[i], 1, Forcing[i], 1, Forcing[i], 1);
791 Vmath::Vadd(physTot, tmp[i], 1, Forcing[i], 1, Forcing[i], 1);
801 Vmath::Vadd(physTot, tmp[i], 1, Forcing[i], 1, Forcing[i], 1);
810 m_fields[0]->HomogeneousFwdTrans(Forcing[i],Forcing[i]);
817 Vmath::Vadd(physTot, outarray[i], 1, Forcing[i], 1, outarray[i], 1);
825 int physTot =
m_fields[0]->GetTotPoints();
831 m_mapping->ApplyChristoffelContravar(velPhys, wk);
834 for (
int i = 0; i< nvel; i++)
837 for (
int j = 0; j< nvel; j++)
840 outarray[i],1,outarray[i],1);
851 int physTot =
m_fields[0]->GetTotPoints();
857 for (
int i = 0; i< nvel; i++)
864 m_mapping->ContravarFromCartesian(tmp, coordVel);
867 m_mapping->ApplyChristoffelContravar(velPhys, wk);
868 for (
int i=0; i< nvel; i++)
872 m_fields[0]->PhysDeriv(velPhys[i], tmp[0], tmp[1]);
873 for (
int j=0; j< nvel; j++)
881 m_fields[0]->HomogeneousBwdTrans(tmp[2],tmp[2]);
889 outarray[i], 1, outarray[i], 1);
894 bool wavespace =
m_fields[0]->GetWaveSpace();
898 m_mapping->ApplyChristoffelContravar(coordVel, wk);
899 for (
int i=0; i< nvel; i++)
903 m_fields[0]->PhysDeriv(coordVel[i], tmp[0], tmp[1]);
907 m_fields[0]->PhysDeriv(coordVel[i], tmp[0], tmp[1], tmp[2]);
910 for (
int j=0; j< nvel; j++)
917 outarray[i], 1, outarray[i], 1);
922 m_fields[0]->SetWaveSpace(wavespace);
928 int physTot =
m_fields[0]->GetTotPoints();
940 for(
int i = 0; i < nvel; ++i)
945 for(
int i = 0; i < nvel; ++i)
957 m_mapping->VelocityLaplacian(velPhys, outarray, 1.0);
#define ASSERTL0(condition, msg)
virtual void v_InitObject()
Init object for UnsteadySystem class.
NekDouble m_pressureTolerance
virtual void v_DoInitialise(void)
Sets up initial conditions.
void ApplyIncNSMappingForcing(Array< OneD, Array< OneD, NekDouble > > &outarray)
SolverUtils::AdvectionSharedPtr m_advObject
Advection term.
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
NekDouble m_kinvis
Kinematic viscosity.
VCSMapping(const LibUtilities::SessionReaderSharedPtr &pSession)
Constructor.
ExtrapolateFactory & GetExtrapolateFactory()
NekDouble m_timestep
Time step size.
virtual void v_SolveViscous(const Array< OneD, const Array< OneD, NekDouble > > &Forcing, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble aii_Dt)
void MappingAccelerationCorrection(const Array< OneD, Array< OneD, NekDouble > > &vel, const Array< OneD, Array< OneD, NekDouble > > &velPhys, Array< OneD, Array< OneD, NekDouble > > &outarray)
Array< OneD, int > m_velocity
int which identifies which components of m_fields contains the velocity (u,v,w);
NekDouble m_sVVDiffCoeff
Diffusion coefficient of SVV modes.
ExtrapolateSharedPtr m_extrapolation
GlobalMapping::MappingSharedPtr m_mapping
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
virtual void v_SetUpViscousForcing(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &Forcing, const NekDouble aii_Dt)
std::map< ConstFactorType, NekDouble > ConstFactorMap
void Vdiv(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x/y.
int m_nConvectiveFields
Number of fields to be convected;.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
NekDouble m_viscousRelaxation
void MappingViscousCorrection(const Array< OneD, Array< OneD, NekDouble > > &velPhys, Array< OneD, Array< OneD, NekDouble > > &outarray)
Array< OneD, Array< OneD, NekDouble > > m_gradP
IMEX 2nd order scheme using Backward Different Formula & Extrapolation.
virtual void v_SolvePressure(const Array< OneD, NekDouble > &Forcing)
virtual void v_SetUpPressureForcing(const Array< OneD, const Array< OneD, NekDouble > > &fields, Array< OneD, Array< OneD, NekDouble > > &Forcing, const NekDouble aii_Dt)
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
std::vector< SolverUtils::ForcingSharedPtr > m_forcing
Forcing terms.
bool m_SmoothAdvection
bool to identify if advection term smoothing is requested
static SolverUtils::EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession)
Creates an instance of this class.
LibUtilities::FieldMetaDataMap m_fieldMetaDataMap
Map to identify relevant solver info to dump in output fields.
void Neg(int n, T *x, const int incx)
Negate x = -x.
virtual void v_SolvePressure(const Array< OneD, NekDouble > &Forcing)
Array< OneD, Array< OneD, NekDouble > > m_presForcingCorrection
void MappingAdvectionCorrection(const Array< OneD, Array< OneD, NekDouble > > &velPhys, Array< OneD, Array< OneD, NekDouble > > &outarray)
EquationSystemFactory & GetEquationSystemFactory()
static std::string className
Name of class.
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
MultiRegions::Direction const DirCartesianMap[]
virtual void v_SolveViscous(const Array< OneD, const Array< OneD, NekDouble > > &Forcing, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble aii_Dt)
void MappingPressureCorrection(Array< OneD, Array< OneD, NekDouble > > &outarray)
void EvaluateAdvectionTerms(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, Array< OneD, NekDouble > &wk=NullNekDouble1DArray)
NekDouble m_sVVCutoffRatio
cutt off ratio from which to start decayhing modes
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
bool m_useSpecVanVisc
bool to identify if spectral vanishing viscosity is active.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
IMEX 3rd order scheme using Backward Different Formula & Extrapolation.
LibUtilities::TimeIntegrationWrapperSharedPtr m_intScheme
Wrapper to the time integration scheme.
NekDouble m_viscousTolerance
virtual void v_InitObject()
Init object for UnsteadySystem class.
MultiRegions::ExpListSharedPtr m_pressure
Pointer to field holding pressure field.
IMEX 1st order scheme using Euler Backwards/Euler Forwards.
void Zero(int n, T *x, const int incx)
Zero vector.
virtual void v_SetUpPressureForcing(const Array< OneD, const Array< OneD, NekDouble > > &fields, Array< OneD, Array< OneD, NekDouble > > &Forcing, const NekDouble aii_Dt)
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
static GLOBAL_MAPPING_EXPORT MappingSharedPtr Load(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
Return a pointer to the mapping, creating it on first call.
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
virtual void v_EvaluateAdvection_SetPressureBCs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
NekDouble m_pressureRelaxation
static FlagList NullFlagList
An empty flag list.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.