Exemplo n.º 1
0
void NonlinearDriver::printNorms (const Vector& norm, utl::LogStream& os) const
{
  if (norm.size() > 0)
  {
    os <<"\n  Energy norm:    |u^h| = a(u^h,u^h)^0.5 : "<< utl::trunc(norm(1));
    if (calcEn == 2)
    {
      std::streamsize oldPrec = os.precision(10);
      os <<"\t a(u^h,u^h) = "<< utl::trunc(norm(1)*norm(1));
      os.precision(oldPrec);
    }
  }
  if (norm.size() > 1 && utl::trunc(norm(2)) != 0.0)
  {
    os <<"\n  External energy: ((f,u^h)+(t,u^h))^0.5 : "<< norm(2);
    if (calcEn == 2)
    {
      std::streamsize oldPrec = os.precision(10);
      os <<"\t(f,u)+(t,u) = "<< norm(2)*norm(2);
      os.precision(oldPrec);
    }
  }
  if (norm.size() > 2)
    os <<"\n  Stress norm, L2: (sigma^h,sigma^h)^0.5 : "<< norm(3);
  if (norm.size() > 3)
    os <<"\n  Pressure norm, L2:       (p^h,p^h)^0.5 : "<< norm(4)
       <<"\t(p^h = trace(sigma^h)/3)";
  if (norm.size() > 4)
    os <<"\n  Deviatoric stress norm:  (s^d,s^d)^0.5 : "<< norm(5)
       <<"\t(s^d = sigma^h - p^h*I)";
  if (norm.size() > 5)
    os <<"\n  Stress norm, von Mises: vm(sigma^h)    : "<< norm(6);
}
Exemplo n.º 2
0
void SIMoutput::dumpPrimSol (const Vector& psol, utl::LogStream& os,
                             bool withID) const
{
  if (psol.empty()) return;

  size_t i, j, ip;
  unsigned char k, n;
  for (i = 0; i < myModel.size(); i++)
  {
    if (myModel[i]->empty()) continue; // skip empty patches

    Vector patchSol;
    myModel[i]->extractNodalVec(psol,patchSol,mySam->getMADOF());

    if (withID)
    {
      if (myModel.size() > 1)
        os <<"\n# Patch: "<< i+1;
      os <<"\n# inod/gnod\tNodal Coordinates\tSolution\n";
    }
    for (ip = 0, j = 1; j <= myModel[i]->getNoNodes(); j++)
    {
      if ((n = myModel[i]->getNodalDOFs(j)) == 0)
        continue;
      else if (withID)
        os << j <<' '<< myModel[i]->getNodeID(j)
           <<"\t\t"<< myModel[i]->getCoord(j) <<"\t\t";
      os << utl::trunc(patchSol[ip++]);
      for (k = 1; k < n; k++)
        os <<' '<< utl::trunc(patchSol[ip++]);
      os <<'\n';
    }
  }

  os.flush();
}
Exemplo n.º 3
0
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;
}
Exemplo n.º 4
0
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;
}