Commit 56d14b50 authored by Sergey Yakovlev's avatar Sergey Yakovlev

Changed TimingCGHelmSolve2D

Also added SetSolveInfo to SessionReader
Need to change HDG timing in 2D and adjust scripts accordingly
parent c00066a1
......@@ -57,7 +57,9 @@ int main(int argc, char *argv[])
if (vComm->GetRank() == 0)
{
cout << "Solving 2D Helmholtz:" << endl;
cout << "Solving 2D Helmholtz: " << endl;
cout << " Communication: " << vSession->GetComm()->GetType() << endl;
cout << " Solver type : " << vSession->GetSolverInfo("GlobalSysSoln") << endl;
cout << " Lambda : " << factors[StdRegions::eFactorLambda] << endl;
cout << " No. modes : " << bkey0.GetNumModes() << endl;
cout << endl;
......
......@@ -58,8 +58,16 @@ int main(int argc, char *argv[])
if (vComm->GetRank() == 0)
{
cout << "Solving 3D Helmholtz:" << endl;
cout << " Lambda : " << factors[StdRegions::eFactorLambda] << endl;
cout << " No. modes : " << bkey0.GetNumModes() << endl;
cout << " - Communication: "
<< vSession->GetComm()->GetType() << " ("
<< vSession->GetComm()->GetSize()
<< " processes)" << endl;
cout << " - Solver type : "
<< vSession->GetSolverInfo("GlobalSysSoln") << endl;
cout << " - Lambda : "
<< factors[StdRegions::eFactorLambda] << endl;
cout << " - No. modes : "
<< bkey0.GetNumModes() << endl;
cout << endl;
}
//----------------------------------------------
......
......@@ -669,6 +669,20 @@ namespace Nektar
return iter->second;
}
/**
*
*/
void SessionReader::SetSolverInfo(
const std::string &pProperty, const std::string &pValue)
{
std::string vProperty = boost::to_upper_copy(pProperty);
SolverInfoMap::iterator iter = m_solverInfo.find(vProperty);
ASSERTL1(iter != m_solverInfo.end(),
"Unable to find requested property: " + pProperty);
iter->second = pValue;
}
/**
*
......
......@@ -227,6 +227,9 @@ namespace Nektar
/// Returns the value of the specified solver info property.
LIB_UTILITIES_EXPORT const std::string& GetSolverInfo(
const std::string &pProperty) const;
/// Sets the value of the specified solver info property.
LIB_UTILITIES_EXPORT void SetSolverInfo(
const std::string &pProperty, const std::string &pValue);
/// Returns the value of the specified solver info property as enum
template<typename T>
inline const T GetSolverInfoAsEnum(const std::string &pName) const;
......
......@@ -86,7 +86,7 @@ namespace Nektar
const std::string &variable,
const bool SetUpJustDG,
const bool DeclareCoeffPhysArrays)
: ExpList2D(pSession, graph2D, DeclareCoeffPhysArrays),
: ExpList2D(pSession,graph2D,DeclareCoeffPhysArrays,variable),
m_bndCondExpansions(),
m_bndConditions(),
m_trace(NullExpListSharedPtr),
......
......@@ -3,6 +3,7 @@
<CONDITIONS>
<PARAMETERS>
<P> w = 3 </P>
<P> Lambda = 1 </P>
</PARAMETERS>
......@@ -12,15 +13,22 @@
<!--These composites must be defined in the geometry file.-->
<BOUNDARYREGIONS>
<B ID="0"> C[1-4] </B>
<!--
<B ID="0"> C[1] </B>
<B ID="1"> C[2] </B>
<B ID="2"> C[3] </B>
<B ID="3"> C[4] </B>
-->
</BOUNDARYREGIONS>
<!--The region numbers below correspond to the regions specified in the
BoundaryRegion definition above.-->
<BOUNDARYCONDITIONS>
<REGION REF="0">
<D VAR="u" VALUE="sin(w*PI*x)*sin(w*PI*y)" />
</REGION>
<!--
<REGION REF="0">
<D VAR="u" VALUE="sin(PI*x)*sin(PI*y)" />
</REGION>
......@@ -33,14 +41,15 @@
<REGION REF="3">
<D VAR="u" VALUE="sin(PI*x)*sin(PI*y)" />
</REGION>
-->
</BOUNDARYCONDITIONS>
<FUNCTION NAME="Forcing">
<E VAR="u" VALUE="-(Lambda + 2*PI*PI)*sin(PI*x)*sin(PI*y)" />
<E VAR="u" VALUE="-(Lambda + 2*w*w*PI*PI)*sin(PI*x)*sin(PI*y)" />
</FUNCTION>
<FUNCTION NAME="ExactSolution">
<E VAR="u" VALUE="sin(PI*x)*sin(PI*y)" />
<E VAR="u" VALUE="sin(w*PI*x)*sin(w*PI*y)" />
</FUNCTION>
......
......@@ -45,9 +45,11 @@ int main(int argc, char *argv[])
boost::filesystem::path basePath(BASE_PATH);
int Type = atoi(argv[1]);
std::string TypeStr;
int MeshSize = atoi(argv[2]);
int NumModes = atoi(argv[3]);
int optLevel = atoi(argv[4]);
std::string optLevelStr;
//----------------------------------------------
// Retrieve the necessary input files
......@@ -63,18 +65,21 @@ int main(int argc, char *argv[])
{
MeshFileDirectory << "RegularQuadMeshes";
MeshFileName << "UnitSquare_RegularQuadMesh_h_1_" << MeshSize << ".xml";
TypeStr = "RQuad";
}
break;
case 2:
{
MeshFileDirectory << "DeformedQuadMeshes";
MeshFileName << "UnitSquare_DeformedQuadMesh_h_1_" << MeshSize << ".xml";
TypeStr = "DQuad";
}
break;
case 3:
{
MeshFileDirectory << "RegularTriMeshes";
MeshFileName << "UnitSquare_RegularTriMesh_h_1_" << MeshSize << ".xml";
TypeStr = "RTri";
}
break;
default:
......@@ -95,16 +100,19 @@ int main(int argc, char *argv[])
case 0:
{
GlobOptFileName << "NoGlobalMat.xml";
optLevelStr = "SumFac";
}
break;
case 2:
{
GlobOptFileName << "DoBlockMat.xml";
optLevelStr = "BlkMat";
}
break;
case 3:
{
GlobOptFileName << "DoGlobalMat.xml";
optLevelStr = "GlbMat";
}
break;
case 4:
......@@ -193,10 +201,7 @@ int main(int argc, char *argv[])
// Define forcing function for first variable defined in file
fce = Array<OneD,NekDouble>(nq);
LibUtilities::EquationSharedPtr ffunc = vSession->GetFunction("Forcing",0);
for(i = 0; i < nq; ++i)
{
fce[i] = ffunc->Evaluate(xc0[i],xc1[i],xc2[i]);
}
ffunc->Evaluate(xc0,xc1,xc2,fce);
//----------------------------------------------
//----------------------------------------------
......@@ -228,20 +233,15 @@ int main(int argc, char *argv[])
//----------------------------------------------
// evaluate exact solution
sol = Array<OneD,NekDouble>(nq);
for(i = 0; i < nq; ++i)
{
sol[i] = ex_sol->Evaluate(xc0[i],xc1[i],xc2[i]);
}
ex_sol->Evaluate(xc0,xc1,xc2,sol);
//----------------------------------------------
//--------------------------------------------
// Calculate L_inf error
Sol = MemoryManager<MultiRegions::ContField2D>::AllocateSharedPtr(*Exp);
Sol->SetPhys(sol);
Sol->SetPhysState(true);
NekDouble L2Error = Exp->L2 (Sol->GetPhys());
NekDouble LinfError = Exp->Linf(Sol->GetPhys());
NekDouble L2Error = Exp->L2 (sol);
NekDouble LinfError = Exp->Linf(sol);
//--------------------------------------------
// alternative error calculation
const LibUtilities::PointsKey PkeyT1(30,LibUtilities::eGaussLobattoLegendre);
......@@ -280,10 +280,7 @@ int main(int argc, char *argv[])
// evaluate exact solution
Array<OneD,NekDouble> ErrorSol(ErrorNq);
for(i = 0; i < ErrorNq; ++i)
{
ErrorSol[i] = ex_sol->Evaluate(ErrorXc0[i],ErrorXc1[i],ErrorXc2[i]);
}
ex_sol->Evaluate(ErrorXc0,ErrorXc1,ErrorXc2,ErrorSol);
// calcualte spectral/hp approximation on the quad points of this new
// expansion basis
......@@ -358,21 +355,26 @@ int main(int argc, char *argv[])
int nGlobBndCoeffs = Exp->GetLocalToGlobalMap()->GetNumGlobalBndCoeffs();
int nLocDirCoeffs = Exp->GetLocalToGlobalMap()->GetNumLocalDirBndCoeffs();
int nGlobDirCoeffs = Exp->GetLocalToGlobalMap()->GetNumGlobalDirBndCoeffs();
int nGlobBandwidth = Exp->GetLocalToGlobalMap()->GetBndSystemBandWidth();
int nGlobBndRank = nGlobBndCoeffs - nGlobDirCoeffs;
MultiRegions::GlobalMatrixKey key(StdRegions::eHelmholtz,Exp->GetLocalToGlobalMap(),factors);
int nnz = Exp->GetGlobalMatrixNnz(key);
ofstream outfile("TimingCGHelmSolve2D.dat");
outfile.precision(0);
outfile << setw(10) << Type << " ";
outfile << setw(10) << optLevelStr << " ";
outfile << setw(10) << TypeStr << " ";
outfile << setw(10) << NumElements << " ";
outfile << setw(10) << NumModes << " ";
outfile << setw(10) << NumCalls << " ";
outfile << setw(10) << fixed << noshowpoint << exeTime << " ";
outfile << setw(10) << NumCalls << " ";
outfile << setw(10) << fixed << noshowpoint << ((NekDouble) (exeTime/((NekDouble)NumCalls))) << " ";
outfile.precision(7);
outfile << setw(15) << scientific << noshowpoint << L2Error << " ";
outfile << setw(15) << scientific << noshowpoint << L2Error << " ";
outfile << setw(15) << scientific << noshowpoint << L2ErrorBis << " ";
outfile << setw(15) << scientific << noshowpoint << LinfError << " ";
outfile << setw(15) << scientific << noshowpoint << LinfError << " ";
outfile << setw(15) << scientific << noshowpoint << LinfErrorBis << " ";
outfile << setw(10) << nLocCoeffs << " ";
outfile << setw(10) << nGlobCoeffs << " ";
......@@ -380,8 +382,9 @@ int main(int argc, char *argv[])
outfile << setw(10) << nGlobBndCoeffs << " ";
outfile << setw(10) << nLocDirCoeffs << " ";
outfile << setw(10) << nGlobDirCoeffs << " ";
outfile << setw(10) << nGlobBndRank << " ";
outfile << setw(10) << nGlobBandwidth << " ";
outfile << setw(10) << nnz << " ";
outfile << setw(10) << optLevel << " ";
outfile << endl;
outfile.close();
......@@ -395,12 +398,12 @@ int main(int argc, char *argv[])
std::string PortablePath(const boost::filesystem::path& path)
{
boost::filesystem::path temp = path;
#if BOOST_VERSION > 104200
#if BOOST_VERSION > 104200
temp.make_preferred();
return temp.string();
#else
#else
return temp.file_string();
#endif
#endif
}
......@@ -201,10 +201,7 @@ int main(int argc, char *argv[])
// Define forcing function for first variable defined in file
fce = Array<OneD,NekDouble>(nq);
LibUtilities::EquationSharedPtr ffunc = vSession->GetFunction("Forcing",0);
for(i = 0; i < nq; ++i)
{
fce[i] = ffunc->Evaluate(xc0[i],xc1[i],xc2[i]);
}
ffunc->Evaluate(xc0,xc1,xc2,fce);
//----------------------------------------------
//----------------------------------------------
......@@ -236,20 +233,15 @@ int main(int argc, char *argv[])
//----------------------------------------------
// evaluate exact solution
sol = Array<OneD,NekDouble>(nq);
for(i = 0; i < nq; ++i)
{
sol[i] = ex_sol->Evaluate(xc0[i],xc1[i],xc2[i]);
}
ex_sol->Evaluate(xc0,xc1,xc2,sol);
//----------------------------------------------
//--------------------------------------------
// Calculate L_inf error
Sol = MemoryManager<MultiRegions::ContField3D>::AllocateSharedPtr(*Exp);
Sol->SetPhys(sol);
Sol->SetPhysState(true);
NekDouble L2Error = Exp->L2 (Sol->GetPhys());
NekDouble LinfError = Exp->Linf(Sol->GetPhys());
NekDouble L2Error = Exp->L2 (sol);
NekDouble LinfError = Exp->Linf(sol);
//--------------------------------------------
// alternative error calculation
const LibUtilities::PointsKey PkeyT1(30,LibUtilities::eGaussLobattoLegendre);
......@@ -292,10 +284,7 @@ int main(int argc, char *argv[])
// evaluate exact solution
Array<OneD,NekDouble> ErrorSol(ErrorNq);
for(i = 0; i < ErrorNq; ++i)
{
ErrorSol[i] = ex_sol->Evaluate(ErrorXc0[i],ErrorXc1[i],ErrorXc2[i]);
}
ex_sol->Evaluate(ErrorXc0,ErrorXc1,ErrorXc2,ErrorSol);
// calcualte spectral/hp approximation on the quad points of this new
// expansion basis
......
......@@ -205,10 +205,7 @@ int main(int argc, char *argv[])
// Define forcing function for first variable defined in file
fce = Array<OneD,NekDouble>(nq);
LibUtilities::EquationSharedPtr ffunc = vSession->GetFunction("Forcing",0);
for(i = 0; i < nq; ++i)
{
fce[i] = ffunc->Evaluate(xc0[i],xc1[i],xc2[i]);
}
ffunc->Evaluate(xc0,xc1,xc2,fce);
//----------------------------------------------
//----------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment