Skip to content
Snippets Groups Projects
Select Git revision
  • e5bb02ab548eff8c67b79cebcade78fd277d2c14
  • develop default protected
  • feature/variational-hydro
  • origin/stage/bouguettaia
  • feature/gmsh-reader
  • feature/reconstruction
  • save_clemence
  • feature/kinetic-schemes
  • feature/local-dt-fsi
  • feature/composite-scheme-sources
  • feature/composite-scheme-other-fluxes
  • 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
  • master protected
  • 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

GmshReader.cpp

Blame
  • DevUtilsModule.cpp 4.52 KiB
    #include <language/modules/DevUtilsModule.hpp>
    
    #include <dev/ParallelChecker.hpp>
    #include <language/utils/ASTDotPrinter.hpp>
    #include <language/utils/ASTExecutionInfo.hpp>
    #include <language/utils/ASTPrinter.hpp>
    #include <language/utils/BuiltinFunctionEmbedder.hpp>
    #include <language/utils/SymbolTable.hpp>
    
    #include <fstream>
    
    class DiscreteFunctionVariant;
    template <>
    inline ASTNodeDataType ast_node_data_type_from<std::shared_ptr<const DiscreteFunctionVariant>> =
      ASTNodeDataType::build<ASTNodeDataType::type_id_t>("Vh");
    
    class ItemValueVariant;
    template <>
    inline ASTNodeDataType ast_node_data_type_from<std::shared_ptr<const ItemValueVariant>> =
      ASTNodeDataType::build<ASTNodeDataType::type_id_t>("item_value");
    
    class ItemArrayVariant;
    template <>
    inline ASTNodeDataType ast_node_data_type_from<std::shared_ptr<const ItemArrayVariant>> =
      ASTNodeDataType::build<ASTNodeDataType::type_id_t>("item_array");
    
    DevUtilsModule::DevUtilsModule()
    {
      this->_addBuiltinFunction("getAST", std::function(
    
                                            []() -> std::string {
                                              const auto& root_node = ASTExecutionInfo::current().rootNode();
    
                                              std::ostringstream os;
                                              os << ASTPrinter{root_node};
    
                                              return os.str();
                                            }
    
                                            ));
    
      this->_addBuiltinFunction("saveASTDot", std::function(
    
                                                [](const std::string& dot_filename) -> void {
                                                  const auto& root_node = ASTExecutionInfo::current().rootNode();
    
                                                  std::ofstream fout(dot_filename);
    
                                                  if (not fout) {
                                                    std::ostringstream os;
                                                    os << "could not create file '" << dot_filename << "'\n";
                                                    throw NormalError(os.str());
                                                  }
    
                                                  ASTDotPrinter dot_printer{root_node};
                                                  fout << dot_printer;
    
                                                  if (not fout) {
                                                    std::ostringstream os;
                                                    os << "could not write AST to '" << dot_filename << "'\n";
                                                    throw NormalError(os.str());
                                                  }
                                                }
    
                                                ));
    
      this->_addBuiltinFunction("getFunctionAST", std::function(
    
                                                    [](const FunctionSymbolId& function_symbol_id) -> std::string {
                                                      const auto& function_descriptor = function_symbol_id.descriptor();
    
                                                      std::ostringstream os;
                                                      os << function_descriptor.name() << ": domain mapping\n";
                                                      os << ASTPrinter(function_descriptor.domainMappingNode());
                                                      os << function_descriptor.name() << ": definition\n";
                                                      os << ASTPrinter(function_descriptor.definitionNode());
    
                                                      return os.str();
                                                    }
    
                                                    ));
    
      this->_addBuiltinFunction("parallel_check",
                                std::function(
    
                                  [](const std::shared_ptr<const DiscreteFunctionVariant>& discrete_function,
                                     const std::string& name) {
                                    parallel_check(*discrete_function, name, ASTBacktrace::getInstance().sourceLocation());
                                  }
    
                                  ));
    
      this->_addBuiltinFunction("parallel_check",
                                std::function(
    
                                  [](const std::shared_ptr<const ItemValueVariant>& item_value, const std::string& name) {
                                    parallel_check(*item_value, name, ASTBacktrace::getInstance().sourceLocation());
                                  }
    
                                  ));
    }
    
    void
    DevUtilsModule::registerOperators() const
    {}