9#include <similie/exterior/form.hpp>
10#include <similie/physics/combine_physics.hpp>
11#include <similie/physics/coupling/electric_coupling_physics.hpp>
12#include <similie/physics/coupling/magnetic_coupling_physics.hpp>
41 PhysicsConcept FluidPhysics,
42 PhysicsConcept ElectromagneticPhysics,
47 ElectromagneticPhysics,
48 coupling::ElectricCouplingPhysics,
49 coupling::MagneticCouplingPhysics>
51 static constexpr bool has_electric
52 =
requires(
typename ElectromagneticPhysics::State state) { state.displacement; };
53 static constexpr bool has_magnetic
54 =
requires(
typename ElectromagneticPhysics::State state) { state.induction; };
59 static constexpr std::size_t
N = FluidPhysics::N + ElectromagneticPhysics::N;
63 typename FluidPhysics::State
fluid;
68 FluidPhysics
const& fluid,
69 ElectromagneticPhysics
const& electromagnetic)
72 ElectromagneticPhysics,
73 coupling::ElectricCouplingPhysics,
74 coupling::MagneticCouplingPhysics>(
77 coupling::ElectricCouplingPhysics(),
78 coupling::MagneticCouplingPhysics())
88 Vector const& total_current,
89 Vector const& velocity)
const
93 if constexpr (has_electric) {
96 = this->
template get<1>().electric_field(state.
electromagnetic.displacement);
98 shared.electric_field = this->
template get<1>().ohm_electric_field(
103 if constexpr (has_magnetic)
106 result += this->
template get<3>()(shared);
112 Vector const& total_current)
const
113 requires(has_electric)
120 if constexpr (has_electric && has_magnetic)
121 return Scalar(this->
template get<1>().hamiltonian(
124 else if constexpr (has_electric)
130 [[nodiscard]] KOKKOS_FUNCTION
typename ElectromagneticPhysics::State
field_rate(
131 Scalar const& current_divergence,
132 Vector const& curl_magnetic_field,
133 Vector const& curl_electric_field,
134 Vector const& total_current)
const
136 if constexpr (has_electric && has_magnetic)
137 return this->
template get<1>()(
142 else if constexpr (has_electric)
143 return {this->
template get<1>()(current_divergence), {}};
145 return {this->
template get<1>()(curl_electric_field)};
149 requires(has_electric)
151 if constexpr (has_magnetic)
152 return this->
template get<1>().current(
153 state.electromagnetic.charge_density,
155 state.electromagnetic.displacement,
156 state.electromagnetic.induction);
158 return this->
template get<1>().current(
159 state.electromagnetic.charge_density,
161 state.electromagnetic.displacement);
164 [[nodiscard]] KOKKOS_FUNCTION
typename FluidPhysics::State
fluid_state(
State const& state)
const
166 typename FluidPhysics::State result = state.
fluid;
175 return current(state, this->
template get<0>().primitives(
fluid_state(state)).velocity);
178 template <
class Flu
id = Flu
idPhysics>
179 [[nodiscard]] KOKKOS_FUNCTION
typename Fluid::Flux
flux(
181 typename Fluid::VelocityGradient
const& velocity_gradient,
182 Vector const& temperature_gradient,
184 Vector const& total_current)
const
186 KOKKOS_ASSERT(normal >= 0 && normal < 3);
187 typename Fluid::State
const hydro =
fluid_state(state);
188 typename Fluid::PrimitiveVariables
const primitive
189 = this->
template get<0>().primitives(hydro);
190 typename Fluid::Flux result
191 = this->
template get<0>()
192 .flux(hydro, primitive, velocity_gradient, temperature_gradient, normal);
196 "Electric quasistatics uses fluid energy with J.E exchange");
197 if constexpr (has_electric) {
198 Vector const poynting = this->
template get<1>().poynting_flux(
201 result.total_energy += poynting[normal];
203 Vector const electric = this->
template get<1>().ohm_electric_field(
208 = this->
template get<1>()
210 result.total_energy += poynting[normal];
216 template <
class Flu
id = Flu
idPhysics>
217 [[nodiscard]] KOKKOS_FUNCTION
typename Fluid::Flux
flux(
219 typename Fluid::VelocityGradient
const& velocity_gradient,
220 Vector const& temperature_gradient,
222 requires(has_electric)
224 return flux(state, velocity_gradient, temperature_gradient, normal, {});
227 template <
class Flu
idFlux>
230 FluidFlux
const& fluid_flux_divergence,
231 Scalar const& current_divergence,
232 Vector const& curl_magnetic_field,
233 Vector const& curl_electric_field,
234 Vector const& total_current)
const
236 typename FluidPhysics::State rate = this->
template get<0>()(fluid_flux_divergence);
240 this->
template get<0>().primitives(
fluid_state(state)).velocity);
241 for (
int a = 0; a < 3; ++a)
261 [[nodiscard]] KOKKOS_FUNCTION
Vector
264 Vector result = this->
template get<0>().transport(velocity, state.
fluid.vorticity);
267 for (
int a = 0; a < 3; ++a)
268 result[a] += exchange.
momentum_source[a] / this->template get<0>().density;
275 Vector const& bernoulli_gradient,
276 Vector const& velocity_laplacian,
277 Vector const& total_current)
const
279 Vector result = this->
template get<0>().momentum_rate(
281 state.
fluid.vorticity,
286 for (
int a = 0; a < 3; ++a)
287 result[a] += exchange.
momentum_source[a] / this->template get<0>().density;
292 Vector const& transport_curl,
293 Vector const& vorticity_laplacian,
294 Scalar const& current_divergence,
295 Vector const& curl_magnetic_field,
296 Vector const& curl_electric_field,
297 Vector const& total_current)
const
299 typename FluidPhysics::State rate {};
300 rate.vorticity = this->
template get<0>()(transport_curl, vorticity_laplacian);
Assemble fluid and electric, magnetic, or full Maxwell sectors with shared exchange laws.
KOKKOS_FUNCTION CoupledFluidElectromagnetism(FluidPhysics const &fluid, ElectromagneticPhysics const &electromagnetic)
KOKKOS_FUNCTION ElectromagneticPhysics::State field_rate(Scalar const ¤t_divergence, Vector const &curl_magnetic_field, Vector const &curl_electric_field, Vector const &total_current) const
KOKKOS_FUNCTION Vector transport(State const &state, Vector const &velocity, Vector const &total_current) const
KOKKOS_FUNCTION Fluid::Flux flux(State const &state, typename Fluid::VelocityGradient const &velocity_gradient, Vector const &temperature_gradient, int normal, Vector const &total_current) const
KOKKOS_FUNCTION FluidPhysics::State fluid_state(State const &state) const
static constexpr bool IS_LINEAR
static constexpr std::size_t N
KOKKOS_FUNCTION coupling::ElectromagneticExchange coupling_sources(State const &state, Vector const &total_current, Vector const &velocity) const
Evaluate both exchanges using the reconstructed current form.
KOKKOS_FUNCTION Vector momentum_rate(State const &state, Vector const &velocity, Vector const &bernoulli_gradient, Vector const &velocity_laplacian, Vector const &total_current) const
sil::exterior::Form< double > Scalar
KOKKOS_FUNCTION State operator()(Vector const &transport_curl, Vector const &vorticity_laplacian, Scalar const ¤t_divergence, Vector const &curl_magnetic_field, Vector const &curl_electric_field, Vector const &total_current) const
KOKKOS_FUNCTION Fluid::Flux flux(State const &state, typename Fluid::VelocityGradient const &velocity_gradient, Vector const &temperature_gradient, int normal) const
ElectromagneticPhysics::State electromagnetic
KOKKOS_FUNCTION Vector current(State const &state, Vector const &velocity) const
FluidPhysics::State fluid
sil::exterior::Form< std::array< double, 3 > > Vector
KOKKOS_FUNCTION Vector current(State const &state) const
KOKKOS_FUNCTION Scalar field_energy(State const &state) const
KOKKOS_FUNCTION State operator()(State const &state, FluidFlux const &fluid_flux_divergence, Scalar const ¤t_divergence, Vector const &curl_magnetic_field, Vector const &curl_electric_field, Vector const &total_current) const
KOKKOS_FUNCTION Scalar combined_energy(State const &state) const
KOKKOS_FUNCTION coupling::ElectromagneticExchange coupling_sources(State const &state, Vector const &total_current) const
sil::exterior::Form< std::array< double, 3 > > current
Device-compatible composition of physics objects with independent state laws.
sil::exterior::Form< double > fluid_energy_source
sil::exterior::Form< std::array< double, 3 > > momentum_source