Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/mechanism_configuration/v1/mechanism.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

#pragma once

#include <mechanism_configuration/v1/types.hpp>
#include <mechanism_configuration/mechanism.hpp>
#include <mechanism_configuration/v1/model_types.hpp>
#include <mechanism_configuration/v1/reaction_types.hpp>
#include <mechanism_configuration/mechanism.hpp>
#include <mechanism_configuration/v1/types.hpp>

#include <string>
#include <vector>
Expand All @@ -31,7 +31,7 @@ namespace mechanism_configuration
/// @brief Represents a general model
/// @note This is optional. It can be omitted if no model is defined.
Models models;
/// @brief Represents a collection of different reaction types, each stored in a vector
/// @brief Represents a collection of different reaction types, each stored in a vector
/// corresponding to a specific mechanism
Reactions reactions;
};
Expand Down
2 changes: 1 addition & 1 deletion include/mechanism_configuration/v1/mechanism_parsers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

#include <yaml-cpp/yaml.h>

#include <vector>
#include <utility>
#include <vector>

namespace mechanism_configuration
{
Expand Down
17 changes: 4 additions & 13 deletions include/mechanism_configuration/v1/model_parsers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#pragma once

#include <mechanism_configuration/errors.hpp>
#include <mechanism_configuration/v1/types.hpp>
#include <mechanism_configuration/v1/model_types.hpp>
#include <mechanism_configuration/v1/types.hpp>

#include <yaml-cpp/yaml.h>

Expand All @@ -25,10 +25,7 @@ namespace mechanism_configuration
/// @param existing_phases A list of previously defined phases
/// @param models The container to which the parsed models will be added
/// @return A list of any parsing errors encountered
virtual Errors parse(
const YAML::Node& object,
const std::vector<types::Phase>& existing_phases,
types::Models& models) = 0;
virtual Errors parse(const YAML::Node& object, const std::vector<types::Phase>& existing_phases, types::Models& models) = 0;

/// @brief Destructor
virtual ~IModelParser() = default;
Expand All @@ -39,21 +36,15 @@ namespace mechanism_configuration
{
public:
/// @brief Parses a YAML node containing gas-phase model information
Errors parse(
const YAML::Node& object,
const std::vector<types::Phase>& existing_phases,
types::Models& models) override;
Errors parse(const YAML::Node& object, const std::vector<types::Phase>& existing_phases, types::Models& models) override;
};

/// @brief Parser for modal aerosol models
class ModalModelParser : public IModelParser
{
public:
/// @brief Parses a YAML node containing modal aerosol model information
Errors parse(
const YAML::Node& object,
const std::vector<types::Phase>& existing_phases,
types::Models& models) override;
Errors parse(const YAML::Node& object, const std::vector<types::Phase>& existing_phases, types::Models& models) override;
};

} // namespace v1
Expand Down
8 changes: 4 additions & 4 deletions include/mechanism_configuration/v1/model_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#pragma once

#include <string>
#include <vector>
#include <unordered_map>
#include <vector>

namespace mechanism_configuration
{
Expand Down Expand Up @@ -52,6 +52,6 @@ namespace mechanism_configuration
GasModel gas_model;
ModalModel modal_model;
};
}
}
}
} // namespace types
} // namespace v1
} // namespace mechanism_configuration
2 changes: 1 addition & 1 deletion include/mechanism_configuration/v1/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#pragma once

#include <mechanism_configuration/v1/mechanism.hpp>
#include <mechanism_configuration/parser_result.hpp>
#include <mechanism_configuration/v1/mechanism.hpp>

#include <filesystem>

Expand Down
3 changes: 1 addition & 2 deletions include/mechanism_configuration/v1/reaction_parsers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#pragma once

#include <mechanism_configuration/errors.hpp>
#include <mechanism_configuration/v1/types.hpp>
#include <mechanism_configuration/v1/reaction_types.hpp>
#include <mechanism_configuration/v1/types.hpp>

#include <yaml-cpp/yaml.h>

Expand Down Expand Up @@ -180,7 +180,6 @@ namespace mechanism_configuration
types::Reactions& reactions) override;
};


class TunnelingParser : public IReactionParser
{
public:
Expand Down
2 changes: 1 addition & 1 deletion include/mechanism_configuration/v1/validation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ namespace mechanism_configuration
// ----------------------------------------
// Model types
// ----------------------------------------

// Gas model
static constexpr const char* GasModel_key = "GAS_PHASE";
// also
Expand Down
7 changes: 2 additions & 5 deletions src/v1/models/gas_model_paser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@
#include <mechanism_configuration/v1/utils.hpp>
#include <mechanism_configuration/validate_schema.hpp>

#include <utility>
#include <utility>

namespace mechanism_configuration
{
namespace v1
{
Errors GasModelParser::parse(
const YAML::Node& object,
const std::vector<types::Phase>& existing_phases,
types::Models& models)
Errors GasModelParser::parse(const YAML::Node& object, const std::vector<types::Phase>& existing_phases, types::Models& models)
{
Errors errors;
types::GasModel model;
Expand Down
21 changes: 9 additions & 12 deletions src/v1/models/modal_model_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,26 @@
#include <mechanism_configuration/v1/utils.hpp>
#include <mechanism_configuration/validate_schema.hpp>

#include <utility>
#include <utility>

namespace mechanism_configuration
{
namespace v1
{
Errors ModalModelParser::parse(
const YAML::Node& object,
const std::vector<types::Phase>& existing_phases,
types::Models& models)
Errors ModalModelParser::parse(const YAML::Node& object, const std::vector<types::Phase>& existing_phases, types::Models& models)
{
Errors errors;
types::ModalModel model;

std::vector<std::string> required_top_level_keys = { validation::type, validation::modes };
std::vector<std::string> optional_top_level_keys = { validation::name };

std::vector<std::string> required_second_level_keys = { validation::name,
validation::geometric_mean_diameter, validation::geometric_standard_deviation, validation::phase };
std::vector<std::string> optional_second_level_keys = { };
std::vector<std::string> required_second_level_keys = {
validation::name, validation::geometric_mean_diameter, validation::geometric_standard_deviation, validation::phase
};
std::vector<std::string> optional_second_level_keys = {};

auto has_error_top_level_keys = ValidateSchema(object, required_top_level_keys , optional_top_level_keys);
auto has_error_top_level_keys = ValidateSchema(object, required_top_level_keys, optional_top_level_keys);
errors.insert(errors.end(), has_error_top_level_keys.begin(), has_error_top_level_keys.end());

// Check the top level keys are valid
Expand All @@ -42,8 +40,7 @@ namespace mechanism_configuration
bool no_errors_in_second_level_keys = true;
for (const auto& mode_object : object[validation::modes])
{
auto has_error_second_level_keys = ValidateSchema(mode_object,
required_second_level_keys , optional_second_level_keys);
auto has_error_second_level_keys = ValidateSchema(mode_object, required_second_level_keys, optional_second_level_keys);
errors.insert(errors.end(), has_error_second_level_keys.begin(), has_error_second_level_keys.end());

if (!has_error_second_level_keys.empty())
Expand All @@ -60,7 +57,7 @@ namespace mechanism_configuration
{
model.name = object[validation::name].as<std::string>();
}

for (const auto& mode_object : object[validation::modes])
{
types::Mode mode;
Expand Down
2 changes: 1 addition & 1 deletion src/v1/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// University of Illinois at Urbana-Champaign
// SPDX-License-Identifier: Apache-2.0

#include <mechanism_configuration/v1/parser.hpp>
#include <mechanism_configuration/v1/mechanism_parsers.hpp>
#include <mechanism_configuration/v1/parser.hpp>
#include <mechanism_configuration/v1/utils.hpp>
#include <mechanism_configuration/v1/validation.hpp>
#include <mechanism_configuration/validate_schema.hpp>
Expand Down