62 lines
1.8 KiB
C++
62 lines
1.8 KiB
C++
module;
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <mfem.hpp>
|
|
#include <vector>
|
|
|
|
export module mean_field:operators.prepared_gravity_source;
|
|
export import :fem;
|
|
export import :mapping.domain_mapper;
|
|
|
|
export namespace mean_field::operators {
|
|
class PreparedMappedGravitySourceOperator final : public mfem::Operator {
|
|
public:
|
|
PreparedMappedGravitySourceOperator(
|
|
const fem::FEM &f,
|
|
const mapping::DomainMapperStateless &domain_mapper
|
|
);
|
|
|
|
void Prepare(const mfem::Vector &displacement_true);
|
|
void Mult(
|
|
const mfem::Vector &density_true,
|
|
mfem::Vector &action
|
|
) const override;
|
|
|
|
[[nodiscard]] bool IsPrepared() const noexcept;
|
|
[[nodiscard]] std::uint64_t GetPreparationCount() const noexcept;
|
|
|
|
void MultTranspose(
|
|
const mfem::Vector &potential_true,
|
|
mfem::Vector &action
|
|
) const override;
|
|
|
|
private:
|
|
struct ElementPAData {
|
|
int element_id{-1};
|
|
|
|
mfem::Array<int> density_dofs;
|
|
mfem::Array<int> potential_dofs;
|
|
|
|
mfem::DofTransformation *density_dof_transformation{nullptr};
|
|
mfem::DofTransformation *potential_dof_transformation{nullptr};
|
|
|
|
// Rows are quadrature points; columns are element DOFs.
|
|
mfem::DenseMatrix density_basis;
|
|
mfem::DenseMatrix potential_basis;
|
|
|
|
// Contains quadrature weight, mesh Jacobian, mapped Jacobian,
|
|
// and 4*pi*G.
|
|
mfem::Vector quadrature_data;
|
|
};
|
|
|
|
const fem::FEM &m_fem;
|
|
const mapping::DomainMapperStateless &m_domain_mapper;
|
|
|
|
mfem::Array<int> m_stellar_marker;
|
|
std::vector<ElementPAData> m_elements;
|
|
|
|
std::uint64_t m_preparation_count{0};
|
|
bool m_is_prepared{false};
|
|
};
|
|
} // namespace mean_field::operators
|