Skip to content

Commit

Permalink
46 implement yaml parsing (#52)
Browse files Browse the repository at this point in the history
* removing nlohmann::json in favor of yaml-cpp

* duplicating tests for json and yaml

* finished troe parsing

* starting to split the parsers out into multiple files

* splitting all the parsers out

* updating workflow files

* responding to PR comment
  • Loading branch information
K20shores authored Jan 16, 2025
1 parent ced8006 commit dae56fd
Show file tree
Hide file tree
Showing 224 changed files with 5,067 additions and 2,939 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/mac.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
name: Mac

on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
xcode_macos_13:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: macos-13
strategy:
matrix:
Expand All @@ -35,7 +39,6 @@ jobs:
ctest -C ${{ matrix.build_type }} --rerun-failed --output-on-failure . --verbose -j 10
macos_lateset:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: macos-latest
strategy:
matrix:
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
name: Ubuntu

on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
gcc:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -34,7 +38,6 @@ jobs:
ctest -C ${{ matrix.build_type }} --rerun-failed --output-on-failure . --verbose -j 10
clang:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
name: Windows

on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
msvc2022:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: windows-latest
strategy:
matrix:
Expand Down
8 changes: 3 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,22 @@ message(STATUS "CMake build configuration for ${PROJECT_NAME} (${CMAKE_BUILD_TYP
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${PROJECT_SOURCE_DIR}/cmake")

option(ENABLE_TESTS "Build the tests" ON)
option(ENABLE_JSON "Include JSON support" ON)
option(ENABLE_YAML "Include YAML support" ON)
option(OPEN_ATMOS_ENABLE_TESTS "Build the tests" ON)

################################################################################
# Dependencies

include(cmake/dependencies.cmake)

################################################################################
# micm targets and documentation
# project source code

add_subdirectory(src)

################################################################################
# Tests

if(PROJECT_IS_TOP_LEVEL AND ENABLE_TESTS)
if(PROJECT_IS_TOP_LEVEL AND OPEN_ATMOS_ENABLE_TESTS)
enable_testing()
add_subdirectory(test)

Expand Down
25 changes: 6 additions & 19 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include(FetchContent)
################################################################################
# google test

if(PROJECT_IS_TOP_LEVEL AND ENABLE_TESTS)
if(PROJECT_IS_TOP_LEVEL AND OPEN_ATMOS_ENABLE_TESTS)
FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
Expand All @@ -15,24 +15,11 @@ if(PROJECT_IS_TOP_LEVEL AND ENABLE_TESTS)
FetchContent_MakeAvailable(googletest)
endif()

################################################################################
# nlohmann::json

if(ENABLE_JSON)
FetchContent_Declare(json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.2
)
FetchContent_MakeAvailable(json)
endif()

################################################################################
# yaml-cpp

if(ENABLE_YAML)
FetchContent_Declare(yaml
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
GIT_TAG 0.8.0
)
FetchContent_MakeAvailable(yaml)
endif()
FetchContent_Declare(yaml
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
GIT_TAG 0.8.0
)
FetchContent_MakeAvailable(yaml)
41 changes: 0 additions & 41 deletions include/open_atmos/mechanism_configuration/json_parser.hpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <fstream>
#include <iostream>
#include <open_atmos/mechanism_configuration/parse_status.hpp>
#include <open_atmos/mechanism_configuration/utils.hpp>
#include <open_atmos/types.hpp>
#include <string>
#include <unordered_map>
Expand All @@ -20,7 +21,7 @@ namespace open_atmos
{
namespace mechanism_configuration
{
class YamlParser
class Parser
{
public:
/// @brief Reads a configuration from a YAML node
Expand Down
158 changes: 158 additions & 0 deletions include/open_atmos/mechanism_configuration/parser_types.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
// Copyright (C) 2023-2024 National Center for Atmospheric Research, University of Illinois at Urbana-Champaign
//
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <yaml-cpp/yaml.h>

#include <open_atmos/mechanism_configuration/parse_status.hpp>
#include <open_atmos/mechanism_configuration/utils.hpp>
#include <open_atmos/types.hpp>
#include <vector>

namespace open_atmos
{
namespace mechanism_configuration
{
class CondensedPhaseArrheniusParser : public IReactionParser
{
public:
ConfigParseStatus parse(
const YAML::Node& object,
const std::vector<types::Species>& existing_species,
const std::vector<types::Phase>& existing_phases,
open_atmos::types::Reactions& reactions) override;
};

class TroeParser : public IReactionParser
{
public:
ConfigParseStatus parse(
const YAML::Node& object,
const std::vector<types::Species>& existing_species,
const std::vector<types::Phase>& existing_phases,
open_atmos::types::Reactions& reactions) override;
};

class BranchedParser : public IReactionParser
{
public:
ConfigParseStatus parse(
const YAML::Node& object,
const std::vector<types::Species>& existing_species,
const std::vector<types::Phase>& existing_phases,
open_atmos::types::Reactions& reactions) override;
};

class TunnelingParser : public IReactionParser
{
public:
ConfigParseStatus parse(
const YAML::Node& object,
const std::vector<types::Species>& existing_species,
const std::vector<types::Phase>& existing_phases,
open_atmos::types::Reactions& reactions) override;
};

class SurfaceParser : public IReactionParser
{
public:
ConfigParseStatus parse(
const YAML::Node& object,
const std::vector<types::Species>& existing_species,
const std::vector<types::Phase>& existing_phases,
open_atmos::types::Reactions& reactions) override;
};

class CondensedPhasePhotolysisParser : public IReactionParser
{
public:
ConfigParseStatus parse(
const YAML::Node& object,
const std::vector<types::Species>& existing_species,
const std::vector<types::Phase>& existing_phases,
open_atmos::types::Reactions& reactions) override;
};

class SimpolPhaseTransferParser : public IReactionParser
{
public:
ConfigParseStatus parse(
const YAML::Node& object,
const std::vector<types::Species>& existing_species,
const std::vector<types::Phase>& existing_phases,
open_atmos::types::Reactions& reactions) override;
};

class EmissionParser : public IReactionParser
{
public:
ConfigParseStatus parse(
const YAML::Node& object,
const std::vector<types::Species>& existing_species,
const std::vector<types::Phase>& existing_phases,
open_atmos::types::Reactions& reactions) override;
};

class PhotolysisParser : public IReactionParser
{
public:
ConfigParseStatus parse(
const YAML::Node& object,
const std::vector<types::Species>& existing_species,
const std::vector<types::Phase>& existing_phases,
open_atmos::types::Reactions& reactions) override;
};

class FirstOrderLossParser : public IReactionParser
{
public:
ConfigParseStatus parse(
const YAML::Node& object,
const std::vector<types::Species>& existing_species,
const std::vector<types::Phase>& existing_phases,
open_atmos::types::Reactions& reactions) override;
};

class AqueousEquilibriumParser : public IReactionParser
{
public:
ConfigParseStatus parse(
const YAML::Node& object,
const std::vector<types::Species>& existing_species,
const std::vector<types::Phase>& existing_phases,
open_atmos::types::Reactions& reactions) override;
};

class WetDepositionParser : public IReactionParser
{
public:
ConfigParseStatus parse(
const YAML::Node& object,
const std::vector<types::Species>& existing_species,
const std::vector<types::Phase>& existing_phases,
open_atmos::types::Reactions& reactions) override;
};

class HenrysLawParser : public IReactionParser
{
public:
ConfigParseStatus parse(
const YAML::Node& object,
const std::vector<types::Species>& existing_species,
const std::vector<types::Phase>& existing_phases,
open_atmos::types::Reactions& reactions) override;
};

class ArrheniusParser : public IReactionParser
{
public:
ConfigParseStatus parse(
const YAML::Node& object,
const std::vector<types::Species>& existing_species,
const std::vector<types::Phase>& existing_phases,
open_atmos::types::Reactions& reactions) override;
};
} // namespace mechanism_configuration
} // namespace open_atmos
Loading

0 comments on commit dae56fd

Please sign in to comment.