Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
VortexWaveInteractionSolver.cpp File Reference
#include <VortexWaveInteraction/VortexWaveInteraction.h>
Include dependency graph for VortexWaveInteractionSolver.cpp:

Go to the source code of this file.

Functions

void DoFixedForcingIteration (VortexWaveInteraction &vwi)
void Mvdir (string dir, NekDouble dir_ending)
int main (int argc, char *argv[])

Function Documentation

void DoFixedForcingIteration ( VortexWaveInteraction vwi)

Definition at line 115 of file VortexWaveInteractionSolver.cpp.

References Nektar::VortexWaveInteraction::AppendEvlToFile(), ASSERTL0, Nektar::VortexWaveInteraction::CalcNonLinearWaveForce(), Nektar::VortexWaveInteraction::CheckEigIsStationary(), Nektar::VortexWaveInteraction::CheckIfAtNeutralPoint(), Nektar::eFixedAlpha, Nektar::eFixedAlphaWaveForcing, Nektar::eFixedWaveForcing, Nektar::eFixedWaveForcingWithSubIterationOnAlpha, Nektar::VortexWaveInteraction::ExecuteLoop(), Nektar::VortexWaveInteraction::ExecuteWave(), Nektar::VortexWaveInteraction::GetAlpha(), Nektar::VortexWaveInteraction::GetEigRelTol(), Nektar::VortexWaveInteraction::GetIterEnd(), Nektar::VortexWaveInteraction::GetIterStart(), Nektar::VortexWaveInteraction::GetMaxOuterIterations(), Nektar::VortexWaveInteraction::GetMinInnerIterations(), Nektar::VortexWaveInteraction::GetNOuterIterations(), Nektar::VortexWaveInteraction::GetPrevAlpha(), Nektar::VortexWaveInteraction::GetVWIIterationType(), Nektar::VortexWaveInteraction::IfIterInterface(), Nektar::VortexWaveInteraction::MoveFile(), Nektar::VortexWaveInteraction::SaveLoopDetails(), Nektar::VortexWaveInteraction::SetEigRelTol(), Nektar::VortexWaveInteraction::SetMinInnerIterations(), Nektar::VortexWaveInteraction::UpdateAlpha(), Nektar::VortexWaveInteraction::UpdateDAlphaDWaveForceMag(), and Nektar::VortexWaveInteraction::UpdateWaveForceMag().

Referenced by main().

{
// Reset eigenvalue checker in case used in previous iterations
switch(vwi.GetVWIIterationType())
{
{
int i;
int nouter_iter = vwi.GetNOuterIterations();
bool exit_iteration = false;
while(exit_iteration == false)
{
// Reset eigenvalue checker in case used in previous iterations
for(i = vwi.GetIterStart(); i < vwi.GetIterEnd(); ++i)
{
vwi.ExecuteLoop();
vwi.SaveLoopDetails("Save", i);
vwi.AppendEvlToFile("conv.his",i);
{
vwi.SaveLoopDetails("Save_Outer", nouter_iter);
break;
}
}
// check to see if growth was converged.
if(i == vwi.GetIterEnd())
{
cout << "Failed to converge growth rate in" <<
" inner iteration after " << vwi.GetIterEnd()
<< " loops" << endl;
exit(1);
}
vwi.AppendEvlToFile("OuterIter.his",nouter_iter++);
exit_iteration = vwi.CheckIfAtNeutralPoint();
if(exit_iteration == false)
{
vwi.UpdateWaveForceMag(nouter_iter);
}
if(nouter_iter >= vwi.GetMaxOuterIterations())
{
cerr << "Failed to converge after "<< vwi.GetMaxOuterIterations() << " outer iterations" << endl;
exit_iteration = true;
}
}
}
{
int i;
int nouter_iter = vwi.GetNOuterIterations();
bool exit_iteration = false;
NekDouble saveEigRelTol = vwi.GetEigRelTol();
int saveMinIters = vwi.GetMinInnerIterations();
int init_search = 0;
if(init_search)
{
// initial set m_eigelTol to 1e-1 and inner iterations to 1 for
// quick search
vwi.SetEigRelTol(1e-1);
}
while(exit_iteration == false)
{
// Reset eigenvalue checker in case used in previous iterations
for(i = vwi.GetIterStart(); i < vwi.GetIterEnd(); ++i)
{
vwi.ExecuteLoop();
vwi.SaveLoopDetails("Save", i);
vwi.AppendEvlToFile("conv.his",i);
{
vwi.SaveLoopDetails("Save_Outer", nouter_iter);
break;
}
}
// check to see if growth was converged.
if(i == vwi.GetIterEnd() )
{
cout << "Failed to converge growth rate in" <<
" inner iteration after " << vwi.GetIterEnd()
<< " loops" << endl;
exit(1);
}
vwi.AppendEvlToFile("OuterIter.his",nouter_iter++);
exit_iteration = vwi.CheckIfAtNeutralPoint();
cout << "m_alpha[0] is " << vwi.GetAlpha() << endl;
if(exit_iteration == false)
{
vwi.UpdateAlpha(nouter_iter);
if(vwi.IfIterInterface()==true)
{
}
}
// Redo iteration if at first coarse search
if((exit_iteration == true) && (init_search == 1))
{
init_search = 0;
vwi.SetEigRelTol(saveEigRelTol);
vwi.SetMinInnerIterations(saveMinIters);
nouter_iter = 1;
exit_iteration = false;
}
if(nouter_iter >= vwi.GetMaxOuterIterations())
{
cerr << "Failed to converge after "<< vwi.GetMaxOuterIterations() << " outer iterations" << endl;
exit_iteration = true;
}
}
}
break;
for(int i = vwi.GetIterStart(); i < vwi.GetIterEnd(); ++i)
{
vwi.ExecuteLoop();
vwi.SaveLoopDetails("Save",i);
vwi.AppendEvlToFile("conv.his",i);
}
break;
{
int i;
int nouter_iter = vwi.GetNOuterIterations();
bool exit_iteration = false;
while(exit_iteration == false)
{
bool exit_alphaIter = false;
vwi.ExecuteLoop(false);
// Sub iterate Alpha
for(i = 0; i < vwi.GetIterEnd(); ++i)
{
vwi.SaveLoopDetails("Save", i);
vwi.AppendEvlToFile("AlphaIter.his",i);
exit_alphaIter = vwi.CheckIfAtNeutralPoint();
if(exit_alphaIter == false)
{
vwi.UpdateAlpha(i+1);
vwi.ExecuteWave();
}
else
{
break;
}
}
// check to see if growth was converged.
if(i == vwi.GetIterEnd())
{
cout << "Failed to converge growth rate in" <<
" inner iteration after " << vwi.GetIterEnd()
<< " loops" << endl;
exit(1);
}
vwi.MoveFile("AlphaIter.his","Save_Outer", nouter_iter);
vwi.SaveLoopDetails("Save_Outer", nouter_iter);
vwi.AppendEvlToFile("OuterIter.his",nouter_iter++);
// assume that if only previous inner loop has
// only done one iteration then we are at neutral
// point
if (i == 0 && vwi.IfIterInterface()==false)
{
exit_iteration = true;
}
if(nouter_iter >= vwi.GetMaxOuterIterations())
{
cerr << "Failed to converge after "<< vwi.GetMaxOuterIterations() << " outer iterations" << endl;
exit_iteration = true;
}
}
}
break;
default:
ASSERTL0(false,"Unknown iteration type");
}
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 48 of file VortexWaveInteractionSolver.cpp.

References Nektar::VortexWaveInteraction::AppendEvlToFile(), DoFixedForcingIteration(), Nektar::eFixedAlphaWaveForcing, Nektar::VortexWaveInteraction::ExecuteLoop(), Nektar::VortexWaveInteraction::GetAlpha(), Nektar::VortexWaveInteraction::GetAlphaStep(), Nektar::VortexWaveInteraction::GetMaxWaveForceMagIter(), Nektar::VortexWaveInteraction::GetVWIIterationType(), Nektar::VortexWaveInteraction::GetWaveForceMag(), Nektar::VortexWaveInteraction::GetWaveForceMagStep(), Mvdir(), Nektar::VortexWaveInteraction::SetAlpha(), Nektar::VortexWaveInteraction::SetPrevAlpha(), and Nektar::VortexWaveInteraction::SetWaveForceMag().

{
try
{
VortexWaveInteraction vwi(argc,argv);
for(int i = 0; i < vwi.GetMaxWaveForceMagIter(); ++i)
{
NekDouble WaveForce = vwi.GetWaveForceMag();
vwi.AppendEvlToFile("ConvergedSolns",WaveForce);
vwi.SetWaveForceMag(WaveForce + vwi.GetWaveForceMagStep());
vwi.SetPrevAlpha(vwi.GetAlpha());
//vwi.SetAlpha(vwi.GetAlpha() + vwi.GetDAlphaDWaveForceMag()*vwi.GetWaveForceMagStep());
vwi.SetAlpha(vwi.GetAlpha() + (vwi.GetWaveForceMagStep() > 0?vwi.GetAlphaStep():(-vwi.GetAlphaStep())));
// Save data directories.
if(vwi.GetVWIIterationType() == eFixedAlphaWaveForcing)
{
Mvdir("Save",WaveForce);
}
else
{
Mvdir("Save_Outer",WaveForce);
// Execute Another loop so that not same initial conditions as last iteration
vwi.ExecuteLoop();
}
}
}
catch (const std::runtime_error&)
{
return 1;
}
catch (const std::string& eStr)
{
cout << "Error: " << eStr << endl;
}
}
void Mvdir ( string  dir,
NekDouble  dir_ending 
)

Definition at line 92 of file VortexWaveInteractionSolver.cpp.

References ASSERTL0.

Referenced by main().

{
// save OuterIter.his if exists
string saveOuterIter = "mv -f OuterIter.his "+ dir;
if(system(saveOuterIter.c_str()))
{
ASSERTL0(false,saveOuterIter.c_str());
}
// Mv directory
string newdir = dir + boost::lexical_cast<std::string>(dir_ending);
string syscall = "mv -f " + dir + " " + newdir;
if(system(syscall.c_str()))
{
ASSERTL0(false,syscall.c_str());
}
// make new directory
syscall = "mkdir " + dir;
system(syscall.c_str());
}