feat(mean_field): added dimensions, discritization, and start of eos
The full rewrite of mean_field into something maintainable is progressing. dimensions is mostly done, discritization (domain, blocks, and fields) is done, and eos is progressing quickly
This commit is contained in:
23
src/include/serif/eos/relations/catalog.hpp
Normal file
23
src/include/serif/eos/relations/catalog.hpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "serif/utils/misc/concepts/type_uniqueness.hpp"
|
||||
#include "serif/utils/misc/std_helper/variadic_cleaning.hpp"
|
||||
#include "serif/dimensions/quantities.hpp"
|
||||
|
||||
namespace serif::eos::relations {
|
||||
using utils::misc::std_helper::CountVariadicArguments;
|
||||
using utils::misc::concepts::AllTypesAreUnique;
|
||||
|
||||
template <typename Output, typename... Inputs>
|
||||
struct Relation final {
|
||||
using OutputQuantity = Output;
|
||||
using InputQuantities = dimensions::QuantityList<Inputs...>;
|
||||
|
||||
static constexpr std::size_t inputCount = CountVariadicArguments<Inputs...>();
|
||||
};
|
||||
|
||||
template <typename... Relations>
|
||||
struct RelationCatalog final {
|
||||
static constexpr std::size_t size = CountVariadicArguments<Relations...>();
|
||||
};
|
||||
}
|
||||
18
src/include/serif/eos/relations/concepts.hpp
Normal file
18
src/include/serif/eos/relations/concepts.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include "serif/eos/relations/traits.hpp"
|
||||
|
||||
|
||||
namespace serif::eos::relations {
|
||||
template <typename Catalog, typename RelationT>
|
||||
concept CatalogContainingRelation = relation_catalog_contains_relation_v<Catalog, RelationT>;
|
||||
|
||||
template <typename RelationT, typename Quantity>
|
||||
concept RelationContainingInput = relation_contains_input_v<RelationT, Quantity>;
|
||||
|
||||
template <typename RelationCandidate>
|
||||
concept ValidThermodynamicRelation = is_thermodynamic_relation_v<RelationCandidate>;
|
||||
|
||||
template <typename CandidateCatalog>
|
||||
concept ValidRelationCatalog = is_valid_relation_catalog_v<CandidateCatalog>;
|
||||
}
|
||||
|
||||
26
src/include/serif/eos/relations/relations.hpp
Normal file
26
src/include/serif/eos/relations/relations.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "serif/eos/relations/catalog.hpp"
|
||||
#include "serif/dimensions/dimensions.hpp"
|
||||
|
||||
namespace serif::eos::relations {
|
||||
using PressureFromDensity = Relation<
|
||||
dimensions::Pressure,
|
||||
dimensions::Density>;
|
||||
|
||||
using PressureFromSpecificEnthalpy = Relation<
|
||||
dimensions::Pressure,
|
||||
dimensions::SpecificEnthalpy>;
|
||||
|
||||
using SpecificEnthalpyFromDensity = Relation<
|
||||
dimensions::SpecificEnthalpy,
|
||||
dimensions::Density>;
|
||||
|
||||
using SpecificEnthalpyFromPressure = Relation<
|
||||
dimensions::SpecificEnthalpy,
|
||||
dimensions::Pressure>;
|
||||
|
||||
using DensityFromSpecificEnthalpy = Relation<
|
||||
dimensions::Density,
|
||||
dimensions::SpecificEnthalpy>;
|
||||
}
|
||||
54
src/include/serif/eos/relations/traits.hpp
Normal file
54
src/include/serif/eos/relations/traits.hpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include "serif/eos/relations/catalog.hpp"
|
||||
|
||||
namespace serif::eos::relations {
|
||||
template <typename Catalog, typename RelationT>
|
||||
struct CatalogContainsRelation : std::false_type {};
|
||||
|
||||
template <typename... Relations, typename RelationT>
|
||||
struct CatalogContainsRelation<RelationCatalog<Relations...>, RelationT> :
|
||||
std::bool_constant<(std::same_as<RelationT, Relations> || ...)> {}; // Fold over all Relations and return true type if any of them match RelationT
|
||||
|
||||
template <typename RelationT, typename Quantity>
|
||||
struct RelationContainsInput : std::false_type {};
|
||||
|
||||
template <typename Output, typename... Inputs, typename Quantity>
|
||||
struct RelationContainsInput<Relation<Output, Inputs...>, Quantity> :
|
||||
std::bool_constant<(std::same_as<Quantity, Inputs> || ...)> {};
|
||||
|
||||
template <typename RelationCandidate>
|
||||
struct IsThermodynamicRelation : std::false_type {};
|
||||
|
||||
template <typename Output, typename... Inputs>
|
||||
struct IsThermodynamicRelation<Relation<Output, Inputs...>> :
|
||||
std::bool_constant<
|
||||
dimensions::ThermodynamicQuantityType<Output> && // Ensure the OutputQuantity is a valid thermodynamic quantity
|
||||
(dimensions::ThermodynamicQuantityType<Inputs> && ...) && // Fold over all InputQuantities to ensure they are valid thermodynamic quantities
|
||||
AllTypesAreUnique<Inputs...>> {}; // Ensure all InputQuantities are unique types
|
||||
|
||||
template <typename CandidateCatalog>
|
||||
struct IsValidRelationCatalog : std::false_type {};
|
||||
|
||||
template <typename... Relations>
|
||||
struct IsValidRelationCatalog<RelationCatalog<Relations...>> :
|
||||
std::bool_constant<
|
||||
(sizeof...(Relations) > 0) && // Ensure the catalog is not empty
|
||||
(IsThermodynamicRelation<Relations>::value && ...) && // Fold over all Relations and ensure they are all valid
|
||||
AllTypesAreUnique<Relations...>> {}; // Ensure all Relations are unique types (e.g. no duplicate relations)
|
||||
|
||||
template <typename Catalog, typename RelationT>
|
||||
inline constexpr bool relation_catalog_contains_relation_v = CatalogContainsRelation<std::remove_cv_t<Catalog>, std::remove_cv_t<RelationT>>::value;
|
||||
|
||||
template <typename RelationT, typename Quantity>
|
||||
inline constexpr bool relation_contains_input_v = RelationContainsInput<std::remove_cv_t<RelationT>, std::remove_cv_t<Quantity>>::value;
|
||||
|
||||
template <typename RelationCandidate>
|
||||
constexpr bool is_thermodynamic_relation_v = IsThermodynamicRelation<RelationCandidate>::value;
|
||||
|
||||
template <typename CatalogCandidate>
|
||||
constexpr bool is_valid_relation_catalog_v = IsValidRelationCatalog<CatalogCandidate>::value;
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user