Ejemplo n.º 1
0
// Save report of document comparison
// -- input is index of documents to compare
// -- uses file dialog to locate filename and type of output
// -- saves comparison in either .pdf or .xml format
void DocumentListCtrl::SaveReportFor (int document1, int document2, bool unique, bool ignore)
{
  wxFileName filename1 (GetPathname (document1));
  wxFileName filename2 (GetPathname (document2));
  wxString newname = wxString::Format ("%s-%s", 
      filename1.GetName().c_str(), 
      filename2.GetName().c_str());
  wxFileDialog dialog (NULL, "Create and save report",
      wxEmptyString,
      newname,
      "pdf|*.pdf|xml|*.xml", 
      wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR);
  if (dialog.ShowModal () == wxID_OK)
  {
    wxBusyCursor wait;
    wxBusyInfo info ("Saving comparison report, please wait ...", this);
    wxFileName path (dialog.GetPath ()); 
   	if (dialog.GetFilterIndex () == 0 || (path.GetExt () == "pdf"))
   	{
    	path.SetExt ("pdf"); // force .pdf as extension
    	PdfReport pdfreport (_ferretparent->GetDocumentList (), unique, ignore);
    	pdfreport.WritePdfReport (path.GetFullPath (), document1, document2);
    }
    else // if (dialog.GetFilterIndex () == 1 || (path.GetExt () == "xml"))
    {
      path.SetExt ("xml"); // force .xml as extension
      XmlReport xmlreport (_ferretparent->GetDocumentList (), unique, ignore);
      xmlreport.WriteXmlReport (path.GetFullPath (), document1, document2);
    }
  }
}
Ejemplo n.º 2
0
   void checkSphSphLubricationForce()
   {
      const uint_t timestep (timeloop_->getCurrentTimeStep()+1);

      // variables for output of total force - requires MPI-reduction
      pe::Vec3 forceSphr1(0);
      pe::Vec3 forceSphr2(0);

      // temporary variables
      real_t gap        (0);

      // calculate gap between the two spheres
      for( auto blockIt = blocks_->begin(); blockIt != blocks_->end(); ++blockIt )
      {
         for( auto curSphereIt = pe::BodyIterator::begin<pe::Sphere>( *blockIt, bodyStorageID_); curSphereIt != pe::BodyIterator::end<pe::Sphere>(); ++curSphereIt )
         {
            pe::SphereID sphereI = ( curSphereIt.getBodyID() );
            if ( sphereI->getID() == id1_ )
            {
               for( auto blockIt2 = blocks_->begin(); blockIt2 != blocks_->end(); ++blockIt2 )
               {
                  for( auto oSphereIt = pe::BodyIterator::begin<pe::Sphere>( *blockIt2, bodyStorageID_); oSphereIt != pe::BodyIterator::end<pe::Sphere>(); ++oSphereIt )
                  {
                     pe::SphereID sphereJ = ( oSphereIt.getBodyID() );
                     if ( sphereJ->getID() == id2_ )
                     {
                        gap = pe::getSurfaceDistance( sphereI, sphereJ );
                        break;
                     }
                  }
               }
               break;
            }
         }
      }

      WALBERLA_MPI_SECTION()
      {
         mpi::reduceInplace( gap, mpi::MAX );
      }
      WALBERLA_ROOT_SECTION()
      {
         if (gap < real_comparison::Epsilon<real_t>::value )
         {
            // shadow copies have not been synced yet as the spheres are outside the overlap region
            gap = walberla::math::Limits<real_t>::inf();
            WALBERLA_LOG_INFO_ON_ROOT( "Spheres still too far apart to calculate gap!" );
         } else {
            WALBERLA_LOG_INFO_ON_ROOT( "Gap between sphere 1 and 2: " << gap );
         }
      }


      // get force on spheres
      for( auto blockIt = blocks_->begin(); blockIt != blocks_->end(); ++blockIt )
      {
         for( auto bodyIt = pe::BodyIterator::begin<pe::Sphere>( *blockIt, bodyStorageID_); bodyIt != pe::BodyIterator::end<pe::Sphere>(); ++bodyIt )
         {
            if( bodyIt->getID() == id1_ )
            {
               forceSphr1 += bodyIt->getForce();
            } else if( bodyIt->getID() == id2_ )
            {
               forceSphr2 += bodyIt->getForce();
            }
         }
      }

      // MPI reduction of pe forces over all processes
      WALBERLA_MPI_SECTION()
      {
         mpi::reduceInplace( forceSphr1[0], mpi::SUM );
         mpi::reduceInplace( forceSphr1[1], mpi::SUM );
         mpi::reduceInplace( forceSphr1[2], mpi::SUM );
         mpi::reduceInplace( forceSphr2[0], mpi::SUM );
         mpi::reduceInplace( forceSphr2[1], mpi::SUM );
         mpi::reduceInplace( forceSphr2[2], mpi::SUM );
      }
      WALBERLA_LOG_INFO_ON_ROOT("Total force on sphere " << id1_ << " : " << forceSphr1);
      WALBERLA_LOG_INFO_ON_ROOT("Total force on sphere " << id2_ << " : " << forceSphr2);

      if ( print_ )
      {
         WALBERLA_ROOT_SECTION()
         {
            std::ofstream file1;
            std::string filename1("Gap_LubricationForceBody1.txt");
            file1.open( filename1.c_str(), std::ofstream::app );
            file1.setf( std::ios::unitbuf );
            file1.precision(15);
            file1 << gap << " " << forceSphr1[0] << std::endl;
            file1.close();

            std::ofstream file2;
            std::string filename2("Gap_LubricationForceBody2.txt");
            file2.open( filename2.c_str(), std::ofstream::app );
            file2.setf( std::ios::unitbuf );
            file2.precision(15);
            file2 << gap << " " << forceSphr2[0] << std::endl;
            file2.close();
         }
      }


      WALBERLA_ROOT_SECTION()
      {
         if ( timestep == uint_t(1000) )
         {
            // both force x-components should be the same only with inverted signs
            WALBERLA_CHECK_FLOAT_EQUAL ( forceSphr2[0], -forceSphr1[0] );

            // according to the formula from Ding & Aidun 2003
            // F = 3/2 * M_PI * rho_L * nu_L * relative velocity of both spheres * r * r * 1/gap
            // the correct analytically calculated value is 339.2920063998
            // in this geometry setup the relative error is 0.1246489711 %
            real_t analytical = real_c(3.0)/real_c(2.0) * walberla::math::M_PI * real_c(1.0) * nu_L_ * real_c(2.0) * real_c(vel_[0]) * radius_ * radius_ * real_c(1.0)/gap;
            real_t relErr     = std::fabs( analytical - forceSphr2[0] ) / analytical * real_c(100.0);
            WALBERLA_CHECK_LESS( relErr, real_t(1) );
         }
      }
   }
Ejemplo n.º 3
0
void recurse_directory(const fs::path& p)
{
    try
    {
        boost::regex expr(include);

        std::string extension(fs::extension(p));

        if(  extension == ".h"
                || extension == ".c"
                || extension == ".hpp"
                || extension == ".cpp"
          )
        {
            fs::ifstream file(p);
            std::string line;
            while(file)
            {
                std::getline(file, line);

                std::string::const_iterator begin(line.begin());
                std::string::const_iterator end(line.end());
                boost::match_flag_type flags(boost::match_default);
                boost::match_results<std::string::const_iterator> what;

                while(boost::regex_search(begin, end , what, expr, flags))
                {
                    std::string filename1(p.string());
                    std::string filename2(what[1].first, what[1].second);
                    filename2 = fs::path(filename2).string();

                    std::cout << '"' << filename1 << "\" -> \""
                              << filename2 << "\";" << std::endl;

                    begin = what[0].second;
                    flags |= boost::match_prev_avail;
                    flags |= boost::match_not_bob;
                }
            }
        }
        else
        {
            if(fs::is_directory(p))
            {
                std::string cluster;
                try
                {
                    cluster = fs::basename(fs::absolute(p).filename());
                }
                catch(std::exception& e)
                {
                    std::clog << "exception in: " << __FILE__ << " at: " << __LINE__
                              << ": " << e.what() << std::endl;
                }

                std::cout << "subgraph \"cluster_" << cluster
                          << "\"{\nlabel = \"" << cluster << "\";" << std::endl;

                fs::directory_iterator end;
                for(fs::directory_iterator it(p); it != end; ++it)
                {
                    std::string extension(fs::extension(*it));

                    if(  extension == ".h"
                            || extension == ".c"
                            || extension == ".hpp"
                            || extension == ".cpp"
                      )
                    {
                        std::cout << '"' << it->path().filename() << "\";" << std::endl;
                    }
                }
                std::cout << '}' << std::endl;

                for(fs::directory_iterator it(p); it != end; ++it)
                {
                    recurse_directory(*it);
                }

            }
        }
    }
    catch(std::exception& e)
    {
        std::clog << "exception in: " << __FILE__ << " at: " << __LINE__
                  << ": " << e.what() << std::endl;
    }
}