Skip to content
Snippets Groups Projects
Select Git revision
  • 953d8c9c40c65bae1b97e9a2d1058ce873a9491e
  • develop default protected
  • feature/advection
  • feature/composite-scheme-other-fluxes
  • origin/stage/bouguettaia
  • save_clemence
  • feature/local-dt-fsi
  • feature/variational-hydro
  • feature/gmsh-reader
  • feature/reconstruction
  • feature/kinetic-schemes
  • feature/composite-scheme-sources
  • feature/serraille
  • feature/composite-scheme
  • hyperplastic
  • feature/polynomials
  • feature/gks
  • feature/implicit-solver-o2
  • feature/coupling_module
  • feature/implicit-solver
  • feature/merge-local-dt-fsi
  • v0.5.0 protected
  • v0.4.1 protected
  • v0.4.0 protected
  • v0.3.0 protected
  • v0.2.0 protected
  • v0.1.0 protected
  • Kidder
  • v0.0.4 protected
  • v0.0.3 protected
  • v0.0.2 protected
  • v0 protected
  • v0.0.1 protected
33 results

conanfile.py

Blame
  • GnuplotWriterBase.cpp 3.02 KiB
    #include <output/GnuplotWriterBase.hpp>
    
    #include <output/OutputNamedItemValueSet.hpp>
    #include <utils/RevisionInfo.hpp>
    
    #include <ctime>
    #include <iomanip>
    #include <sstream>
    
    std::string
    GnuplotWriterBase::_getDateAndVersionComment() const
    {
      std::ostringstream os;
    
      std::time_t now = std::time(nullptr);
      os << "#  Generated by pugs: " << std::ctime(&now);
      os << "#  version: " << RevisionInfo::version() << '\n';
      os << "#  tag:  " << RevisionInfo::gitTag() << '\n';
      os << "#  HEAD: " << RevisionInfo::gitHead() << '\n';
      os << "#  hash: " << RevisionInfo::gitHash() << " (" << ((RevisionInfo::gitIsClean()) ? "clean" : "dirty") << ")\n";
      os << '\n';
    
      return os.str();
    }
    
    std::string
    GnuplotWriterBase::_getFilename() const
    {
      std::ostringstream sout;
      sout << m_base_filename;
      if (m_period_manager.has_value()) {
        sout << '.' << std::setfill('0') << std::setw(4) << m_period_manager->nbSavedTimes();
      }
      sout << ".gnu";
      return sout.str();
    }
    
    void
    GnuplotWriterBase::_writePreamble(const size_t& dimension,
                                      const OutputNamedItemDataSet& output_named_item_data_set,
                                      const bool& store_coordinates,
                                      std::ostream& fout) const
    {
      fout << "# list of data\n";
      uint64_t i = 0;
    
      fout << "#";
      if (store_coordinates) {
        fout << " 1:x";
        if (dimension > 1) {
          fout << " 2:y";
        }
        i = dimension;
      }
    
      for (const auto& i_named_item_data : output_named_item_data_set) {
        const std::string name        = i_named_item_data.first;
        const auto& item_data_variant = i_named_item_data.second;
        std::visit(
          [&](auto&& item_data) {
            using ItemDataType = std::decay_t<decltype(item_data)>;
            using DataType     = std::decay_t<typename ItemDataType::data_type>;
            if constexpr (is_item_value_v<ItemDataType>) {
              if constexpr (std::is_arithmetic_v<DataType>) {
                fout << ' ' << i++ << ':' << name;
              } else if constexpr (is_tiny_vector_v<DataType>) {
                for (size_t j = 0; j < DataType{}.dimension(); ++j) {
                  fout << ' ' << i++ << ':' << name << '[' << j << ']';
                }
              } else if constexpr (is_tiny_matrix_v<DataType>) {
                for (size_t j = 0; j < DataType{}.numberOfRows(); ++j) {
                  for (size_t k = 0; k < DataType{}.numberOfColumns(); ++k) {
                    fout << ' ' << i++ << ':' << name << '(' << j << ',' << k << ')';
                  }
                }
              } else {
                throw UnexpectedError("invalid data type");
              }
            } else if constexpr (is_item_array_v<ItemDataType>) {
              if constexpr (std::is_arithmetic_v<DataType>) {
                for (size_t j = 0; j < item_data.sizeOfArrays(); ++j) {
                  fout << ' ' << i++ << ':' << name << '[' << j << ']';
                }
              } else {
                throw UnexpectedError("invalid data type");
              }
            } else {
              throw UnexpectedError("invalid ItemData type");
            }
          },
          item_data_variant);
      }
      fout << "\n\n";
    }