feat(libmeanfield): variadic refactor
also added normaliztion operator
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
module;
|
||||
|
||||
#include <concepts>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
export module mean_field:equilibrium.stellar_discretization;
|
||||
|
||||
export import :fem;
|
||||
export import :mapping.domain_mapper;
|
||||
export import :normalization.physical_riesz;
|
||||
|
||||
export namespace mean_field::equilibrium {
|
||||
/*
|
||||
@@ -18,26 +22,78 @@ export namespace mean_field::equilibrium {
|
||||
* mutable field workspaces. Separating those workspaces is a prerequisite
|
||||
* for shared discretization ownership by solved Structure objects.
|
||||
*/
|
||||
class StellarDiscretization final {
|
||||
template <normalization::NormalizationPrescription Normalization>
|
||||
class StellarDiscretizationFor final {
|
||||
public:
|
||||
explicit StellarDiscretization(fem::FEM &finiteElementModel)
|
||||
: StellarDiscretization(
|
||||
using NormalizationPrescriptionType = std::remove_cvref_t<Normalization>;
|
||||
|
||||
explicit StellarDiscretizationFor(fem::FEM &finiteElementModel)
|
||||
requires std::same_as<NormalizationPrescriptionType, normalization::Unnormalized>
|
||||
: StellarDiscretizationFor(
|
||||
finiteElementModel,
|
||||
RequireDomainMapper(finiteElementModel)
|
||||
RequireDomainMapper(finiteElementModel),
|
||||
normalization::Unnormalized{}
|
||||
) {
|
||||
}
|
||||
|
||||
StellarDiscretization(
|
||||
StellarDiscretizationFor(
|
||||
fem::FEM &finiteElementModel,
|
||||
const mapping::DomainMapper &domainMapper
|
||||
)
|
||||
requires std::same_as<NormalizationPrescriptionType, normalization::Unnormalized>
|
||||
: StellarDiscretizationFor(
|
||||
finiteElementModel,
|
||||
domainMapper,
|
||||
normalization::Unnormalized{}
|
||||
) {
|
||||
}
|
||||
|
||||
StellarDiscretizationFor(
|
||||
fem::FEM &,
|
||||
mapping::DomainMapper &&
|
||||
) requires std::same_as<NormalizationPrescriptionType, normalization::Unnormalized> = delete;
|
||||
|
||||
StellarDiscretizationFor(
|
||||
fem::FEM &,
|
||||
const mapping::DomainMapper &&
|
||||
) requires std::same_as<NormalizationPrescriptionType, normalization::Unnormalized> = delete;
|
||||
|
||||
StellarDiscretizationFor(
|
||||
fem::FEM &finiteElementModel,
|
||||
NormalizationPrescriptionType normalizationPrescription
|
||||
)
|
||||
: StellarDiscretizationFor(
|
||||
finiteElementModel,
|
||||
RequireDomainMapper(finiteElementModel),
|
||||
std::move(normalizationPrescription)
|
||||
) {
|
||||
}
|
||||
|
||||
StellarDiscretizationFor(
|
||||
fem::FEM &finiteElementModel,
|
||||
const mapping::DomainMapper &domainMapper,
|
||||
NormalizationPrescriptionType normalizationPrescription
|
||||
)
|
||||
: m_finiteElementModel(std::addressof(finiteElementModel)),
|
||||
m_domainMapper(std::addressof(domainMapper)) {
|
||||
m_domainMapper(std::addressof(domainMapper)),
|
||||
m_normalizationPrescription(std::move(normalizationPrescription)) {
|
||||
if (!finiteElementModel.okay()) {
|
||||
throw std::invalid_argument("A stellar discretization requires a complete finite-element model.");
|
||||
}
|
||||
}
|
||||
|
||||
StellarDiscretizationFor(
|
||||
fem::FEM &,
|
||||
mapping::DomainMapper &&,
|
||||
NormalizationPrescriptionType
|
||||
) = delete;
|
||||
|
||||
StellarDiscretizationFor(
|
||||
fem::FEM &,
|
||||
const mapping::DomainMapper &&,
|
||||
NormalizationPrescriptionType
|
||||
) = delete;
|
||||
|
||||
[[nodiscard]] fem::FEM &finiteElementModel() const noexcept {
|
||||
return *m_finiteElementModel;
|
||||
}
|
||||
@@ -46,6 +102,10 @@ export namespace mean_field::equilibrium {
|
||||
return *m_domainMapper;
|
||||
}
|
||||
|
||||
[[nodiscard]] const NormalizationPrescriptionType &normalizationPrescription() const noexcept {
|
||||
return m_normalizationPrescription;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool isCurrent() const noexcept {
|
||||
return m_finiteElementModel != nullptr && m_domainMapper != nullptr && m_finiteElementModel->okay();
|
||||
}
|
||||
@@ -60,5 +120,64 @@ export namespace mean_field::equilibrium {
|
||||
|
||||
fem::FEM *m_finiteElementModel;
|
||||
const mapping::DomainMapper *m_domainMapper;
|
||||
NormalizationPrescriptionType m_normalizationPrescription;
|
||||
};
|
||||
|
||||
template <normalization::NormalizationPrescription Normalization>
|
||||
StellarDiscretizationFor(fem::FEM &, Normalization)
|
||||
-> StellarDiscretizationFor<std::remove_cvref_t<Normalization>>;
|
||||
|
||||
template <normalization::NormalizationPrescription Normalization>
|
||||
StellarDiscretizationFor(fem::FEM &, const mapping::DomainMapper &, Normalization)
|
||||
-> StellarDiscretizationFor<std::remove_cvref_t<Normalization>>;
|
||||
|
||||
using StellarDiscretization = StellarDiscretizationFor<normalization::Unnormalized>;
|
||||
|
||||
template <typename Candidate> struct IsStellarDiscretization : std::false_type { };
|
||||
|
||||
template <normalization::NormalizationPrescription Normalization>
|
||||
struct IsStellarDiscretization<StellarDiscretizationFor<Normalization>> : std::true_type { };
|
||||
|
||||
template <typename Candidate>
|
||||
concept StellarDiscretizationType = IsStellarDiscretization<std::remove_cvref_t<Candidate>>::value;
|
||||
|
||||
template <normalization::NormalizationPrescription Normalization>
|
||||
[[nodiscard]] auto makeStellarDiscretization(
|
||||
fem::FEM &finiteElementModel,
|
||||
Normalization normalizationPrescription
|
||||
) {
|
||||
return StellarDiscretizationFor<std::remove_cvref_t<Normalization>>{
|
||||
finiteElementModel,
|
||||
std::move(normalizationPrescription)
|
||||
};
|
||||
}
|
||||
|
||||
template <normalization::NormalizationPrescription Normalization>
|
||||
[[nodiscard]] auto makeStellarDiscretization(
|
||||
fem::FEM &finiteElementModel,
|
||||
const mapping::DomainMapper &domainMapper,
|
||||
Normalization normalizationPrescription
|
||||
) {
|
||||
return StellarDiscretizationFor<std::remove_cvref_t<Normalization>>{
|
||||
finiteElementModel,
|
||||
domainMapper,
|
||||
std::move(normalizationPrescription)
|
||||
};
|
||||
}
|
||||
|
||||
template <normalization::NormalizationPrescription Normalization>
|
||||
StellarDiscretizationFor<std::remove_cvref_t<Normalization>>
|
||||
makeStellarDiscretization(
|
||||
fem::FEM &,
|
||||
mapping::DomainMapper &&,
|
||||
Normalization
|
||||
) = delete;
|
||||
|
||||
template <normalization::NormalizationPrescription Normalization>
|
||||
StellarDiscretizationFor<std::remove_cvref_t<Normalization>>
|
||||
makeStellarDiscretization(
|
||||
fem::FEM &,
|
||||
const mapping::DomainMapper &&,
|
||||
Normalization
|
||||
) = delete;
|
||||
} // namespace mean_field::equilibrium
|
||||
|
||||
Reference in New Issue
Block a user