本文整理汇总了C++中utl::LogStream::flags方法的典型用法代码示例。如果您正苦于以下问题:C++ LogStream::flags方法的具体用法?C++ LogStream::flags怎么用?C++ LogStream::flags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utl::LogStream
的用法示例。
在下文中一共展示了LogStream::flags方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dumpVector
bool SIMoutput::dumpVector (const Vector& vsol, const char* fname,
utl::LogStream& os, std::streamsize precision) const
{
if (vsol.empty() || myPoints.empty())
return true;
size_t i, j, k;
Matrix sol1;
Vector lsol;
for (i = 0; i < myModel.size(); i++)
{
if (myModel[i]->empty()) continue; // skip empty patches
std::vector<ResPtPair>::const_iterator pit;
ResPointVec::const_iterator p;
std::array<RealArray,3> params;
IntVec points;
// Find all evaluation points within this patch, if any
for (j = 0, pit = myPoints.begin(); pit != myPoints.end(); ++pit)
for (p = pit->second.begin(); p != pit->second.end(); j++, ++p)
if (this->getLocalPatchIndex(p->patch) == (int)(i+1))
if (opt.discretization >= ASM::Spline)
{
points.push_back(p->inod > 0 ? p->inod : -(j+1));
for (k = 0; k < myModel[i]->getNoParamDim(); k++)
params[k].push_back(p->u[k]);
}
else if (p->inod > 0)
points.push_back(p->inod);
if (points.empty()) continue; // no points in this patch
// Evaluate/extracto nodal solution variables
myModel[i]->extractNodeVec(vsol,lsol);
if (opt.discretization >= ASM::Spline)
{
if (!myModel[i]->evalSolution(sol1,lsol,params.data(),false))
return false;
}
else
{
if (!myModel[i]->getSolution(sol1,lsol,points))
return false;
}
// Formatted output, use scientific notation with fixed field width
std::streamsize flWidth = 8 + precision;
std::streamsize oldPrec = os.precision(precision);
std::ios::fmtflags oldF = os.flags(std::ios::scientific | std::ios::right);
for (j = 0; j < points.size(); j++)
{
if (points[j] < 0)
os <<" Point #"<< -points[j];
else
{
points[j] = myModel[i]->getNodeID(points[j]);
os <<" Node #"<< points[j];
}
os <<":\t"<< fname <<" =";
for (k = 1; k <= sol1.rows(); k++)
os << std::setw(flWidth) << utl::trunc(sol1(k,j+1));
os << std::endl;
}
os.precision(oldPrec);
os.flags(oldF);
}
return true;
}
示例2: dumpResults
bool SIMoutput::dumpResults (const Vector& psol, double time,
utl::LogStream& os, const ResPointVec& gPoints,
bool formatted, std::streamsize precision) const
{
if (gPoints.empty())
return true;
size_t i, j, k;
Matrix sol1, sol2;
Vector reactionFS;
const Vector* reactionForces = myEqSys->getReactions();
for (i = 0; i < myModel.size(); i++)
{
if (myModel[i]->empty()) continue; // skip empty patches
ResPointVec::const_iterator p;
std::array<RealArray,3> params;
IntVec points;
// Find all evaluation points within this patch, if any
for (j = 0, p = gPoints.begin(); p != gPoints.end(); j++, p++)
if (this->getLocalPatchIndex(p->patch) == (int)(i+1))
if (opt.discretization >= ASM::Spline)
{
points.push_back(p->inod > 0 ? p->inod : -(j+1));
for (k = 0; k < myModel[i]->getNoParamDim(); k++)
params[k].push_back(p->u[k]);
}
else if (p->inod > 0)
points.push_back(p->inod);
if (points.empty()) continue; // no points in this patch
myModel[i]->extractNodeVec(psol,myProblem->getSolution());
if (opt.discretization >= ASM::Spline)
{
// Evaluate the primary solution variables
if (!myModel[i]->evalSolution(sol1,myProblem->getSolution(),
params.data(),false))
return false;
// Evaluate the secondary solution variables
LocalSystem::patch = i;
if (myProblem->getNoFields(2) > 0)
{
const_cast<SIMoutput*>(this)->setPatchMaterial(i+1);
if (!myModel[i]->evalSolution(sol2,*myProblem,params.data(),false))
return false;
}
}
else
// Extract nodal primary solution variables
if (!myModel[i]->getSolution(sol1,myProblem->getSolution(),points))
return false;
// Formatted output, use scientific notation with fixed field width
std::streamsize flWidth = 8 + precision;
std::streamsize oldPrec = os.precision(precision);
std::ios::fmtflags oldF = os.flags(std::ios::scientific | std::ios::right);
for (j = 0; j < points.size(); j++)
{
if (!formatted)
os << time <<" ";
else if (points[j] < 0)
os <<" Point #"<< -points[j] <<":\tsol1 =";
else
{
points[j] = myModel[i]->getNodeID(points[j]);
os <<" Node #"<< points[j] <<":\tsol1 =";
}
for (k = 1; k <= sol1.rows(); k++)
os << std::setw(flWidth) << utl::trunc(sol1(k,j+1));
if (opt.discretization >= ASM::Spline)
{
if (formatted && sol2.rows() > 0)
os <<"\n\t\tsol2 =";
for (k = 1; k <= sol2.rows(); k++)
os << std::setw(flWidth) << utl::trunc(sol2(k,j+1));
}
if (reactionForces && points[j] > 0)
// Print nodal reaction forces for nodes with prescribed DOFs
if (mySam->getNodalReactions(points[j],*reactionForces,reactionFS))
{
if (formatted)
os <<"\n\t\treac =";
for (k = 0; k < reactionFS.size(); k++)
os << std::setw(flWidth) << utl::trunc(reactionFS[k]);
}
os << std::endl;
}
os.precision(oldPrec);
os.flags(oldF);
}
return true;
//.........这里部分代码省略.........