Skip to content

Commit

Permalink
Increase timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilyBourne committed Feb 12, 2024
1 parent 8a770db commit 9ecda87
Show file tree
Hide file tree
Showing 9 changed files with 523 additions and 393 deletions.
5 changes: 3 additions & 2 deletions src/geometryXVx/rhs/collisions_inter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

CollisionsInter::CollisionsInter(IDomainSpXVx const& mesh, double nustar0)
: m_nustar0(nustar0)
, m_nustar_profile(ddc::select<IDimSp, IDimX>(mesh))
, m_nustar_profile_alloc(ddc::select<IDimSp, IDimX>(mesh))
{
// validity checks
if (ddc::select<IDimSp>(mesh).size() != 2) {
Expand All @@ -20,7 +20,8 @@ CollisionsInter::CollisionsInter(IDomainSpXVx const& mesh, double nustar0)
throw std::invalid_argument("Collision operator should not be used with nustar0=0.");
}

compute_nustar_profile(m_nustar_profile.span_view(), m_nustar0);
m_nustar_profile = m_nustar_profile_alloc.span_view();
compute_nustar_profile(m_nustar_profile, m_nustar0);
ddc::expose_to_pdi("collinter_nustar0", m_nustar0);
}

Expand Down
3 changes: 2 additions & 1 deletion src/geometryXVx/rhs/collisions_inter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class CollisionsInter : public IRightHandSide
{
private:
double m_nustar0;
DFieldSpX m_nustar_profile;
device_t<DFieldSpX> m_nustar_profile_alloc;
device_t<DSpanSpX> m_nustar_profile;

public:
/**
Expand Down
353 changes: 182 additions & 171 deletions src/geometryXVx/rhs/collisions_intra.cpp

Large diffs are not rendered by default.

87 changes: 47 additions & 40 deletions src/geometryXVx/rhs/collisions_intra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,6 @@ class CollisionsIntra : public IRightHandSide
};

private:
static ddc::Coordinate<GhostedVx> ghosted_from_coord(ddc::Coordinate<RDimVx> const& coord)
{
return ddc::Coordinate<GhostedVx>(ddc::get<RDimVx>(coord));
}
static ddc::Coordinate<RDimVx> coord_from_ghosted(ddc::Coordinate<GhostedVx> const& coord)
{
return ddc::Coordinate<RDimVx>(ddc::get<GhostedVx>(coord));
}
static ddc::Coordinate<GhostedVxStaggered> ghosted_staggered_from_coord(
ddc::Coordinate<RDimVx> const& coord)
{
return ddc::Coordinate<GhostedVxStaggered>(ddc::get<RDimVx>(coord));
}
static ddc::Coordinate<RDimVx> coord_from_ghosted_staggered(
ddc::Coordinate<GhostedVxStaggered> const& coord)
{
return ddc::Coordinate<RDimVx>(ddc::get<GhostedVxStaggered>(coord));
}

static IndexVx index_from_ghosted(ddc::DiscreteElement<GhostedVx> const& index_ghosted)
{
return IndexVx(index_ghosted.uid() - 1);
}
static ddc::DiscreteElement<GhostedVx> ghosted_from_index(IndexVx const& index)
{
return ddc::DiscreteElement<GhostedVx>(index.uid() + 1);
}

static constexpr bool uniform_edge_v
= std::is_same_v<IDimVx, ddc::UniformPointSampling<RDimVx>>;

Expand Down Expand Up @@ -133,10 +105,45 @@ class CollisionsIntra : public IRightHandSide
using IndexSpXVx_ghosted_staggered
= ddc::DiscreteElement<IDimSp, IDimX, ghosted_vx_staggered_point_sampling>;


private:
static ddc::Coordinate<GhostedVx> ghosted_from_coord(ddc::Coordinate<RDimVx> const& coord)
{
return ddc::Coordinate<GhostedVx>(ddc::get<RDimVx>(coord));
}
static ddc::Coordinate<RDimVx> coord_from_ghosted(ddc::Coordinate<GhostedVx> const& coord)
{
return ddc::Coordinate<RDimVx>(ddc::get<GhostedVx>(coord));
}
static ddc::Coordinate<GhostedVxStaggered> ghosted_staggered_from_coord(
ddc::Coordinate<RDimVx> const& coord)
{
return ddc::Coordinate<GhostedVxStaggered>(ddc::get<RDimVx>(coord));
}
static ddc::Coordinate<RDimVx> coord_from_ghosted_staggered(
ddc::Coordinate<GhostedVxStaggered> const& coord)
{
return ddc::Coordinate<RDimVx>(ddc::get<GhostedVxStaggered>(coord));
}
static IndexVx index_from_ghosted(ddc::DiscreteElement<GhostedVx> const& index_ghosted)
{
return IndexVx(index_ghosted.uid() - 1);
}
KOKKOS_FUNCTION static IndexVx_ghosted ghosted_from_index(IndexVx const& index)
{
return IndexVx_ghosted(index.uid() + 1);
}
KOKKOS_FUNCTION static IndexVx_ghosted_staggered ghosted_staggered_from_index(
IndexVx const& index)
{
return IndexVx_ghosted_staggered(index.uid() + 1);
}

private:
double m_nustar0;
double m_fthresh;
DFieldSpX m_nustar_profile;
device_t<DFieldSpX> m_nustar_profile_alloc;
device_t<DSpanSpX> m_nustar_profile;

ddc::DiscreteDomain<ghosted_vx_point_sampling> m_gridvx_ghosted;
ddc::DiscreteDomain<ghosted_vx_staggered_point_sampling> m_gridvx_ghosted_staggered;
Expand Down Expand Up @@ -209,11 +216,11 @@ class CollisionsIntra : public IRightHandSide
* @param[in] fthresh A constant value used for imposing Dirichlet boundary condition to solve the linear system.
*/
void compute_rhs_vector(
DSpanSpXVx RR,
DViewSpXVx AA,
DViewSpXVx BB,
DViewSpXVx CC,
DViewSpXVx allfdistribu,
device_t<DSpanSpXVx> RR,
device_t<DViewSpXVx> AA,
device_t<DViewSpXVx> BB,
device_t<DViewSpXVx> CC,
device_t<DViewSpXVx> allfdistribu,
double fthresh) const;
/**
* @brief Compute the coefficients of the tridiagonal matrix of the collision operator linear system.
Expand All @@ -226,12 +233,12 @@ class CollisionsIntra : public IRightHandSide
* @param[in] deltat The time step.
*/
void compute_matrix_coeff(
DSpanSpXVx AA,
DSpanSpXVx BB,
DSpanSpXVx CC,
ddc::ChunkSpan<double, IDomainSpXVx_ghosted> Dcoll,
ddc::ChunkSpan<double, IDomainSpXVx_ghosted_staggered> Dcoll_staggered,
ddc::ChunkSpan<double, IDomainSpXVx_ghosted> Nucoll,
device_t<DSpanSpXVx> AA,
device_t<DSpanSpXVx> BB,
device_t<DSpanSpXVx> CC,
device_t<ddc::ChunkSpan<double, IDomainSpXVx_ghosted>> Dcoll,
device_t<ddc::ChunkSpan<double, IDomainSpXVx_ghosted_staggered>> Dcoll_staggered,
device_t<ddc::ChunkSpan<double, IDomainSpXVx_ghosted>> Nucoll,
double deltat) const;

/**
Expand Down
47 changes: 33 additions & 14 deletions src/geometryXVx/rhs/collisions_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,47 @@ IndexSp find_ion(IDomainSp const dom_sp)
* but could be space dependent (for instance to have no collisions in some specific
* parts of the simulation box).
*/
void compute_nustar_profile(DSpanSpX nustar_profile, double nustar0)
void compute_nustar_profile(device_t<DSpanSpX> nustar_profile, double nustar0)
{
double const Lx = ddcHelper::total_interval_length(ddc::get_domain<IDimX>(nustar_profile));
ddc::for_each(nustar_profile.domain(), [&](IndexSpX const ispx) {
double const coeff = std::sqrt(mass(ielec()) / mass(ddc::select<IDimSp>(ispx)))
* std::pow(charge(ddc::select<IDimSp>(ispx)), 4) / Lx;
nustar_profile(ispx) = coeff * nustar0;
});

auto masses_alloc = create_mirror_view_and_copy(
Kokkos::DefaultExecutionSpace(),
ddc::host_discrete_space<SpeciesInformation>().masses());
auto masses(masses_alloc.span_view());

auto charges_alloc = create_mirror_view_and_copy(
Kokkos::DefaultExecutionSpace(),
ddc::host_discrete_space<SpeciesInformation>().charges());
auto charges(charges_alloc.span_view());

ddc::for_each(
ddc::policies::parallel_device,
nustar_profile.domain(),
KOKKOS_LAMBDA(IndexSpX const ispx) {
double const coeff
= Kokkos::sqrt(masses(ielec()) / masses(ddc::select<IDimSp>(ispx)))
* Kokkos::pow(charges(ddc::select<IDimSp>(ispx)), 4) / Lx;
nustar_profile(ispx) = coeff * nustar0;
});
}

/**
* Computes the space and species dependent collision frequency collfreq.
*/
void compute_collfreq(
DSpanSpX collfreq,
DViewSpX nustar_profile,
DViewSpX density,
DViewSpX temperature)
device_t<DSpanSpX> collfreq,
device_t<DViewSpX> nustar_profile,
device_t<DViewSpX> density,
device_t<DViewSpX> temperature)
{
ddc::for_each(collfreq.domain(), [&](IndexSpX const ispx) {
collfreq(ispx) = nustar_profile(ispx) * density(ispx) / std::pow(temperature(ispx), 1.5);
});
ddc::for_each(
ddc::policies::parallel_device,
collfreq.domain(),
KOKKOS_LAMBDA(IndexSpX const ispx) {
collfreq(ispx) = nustar_profile(ispx) * density(ispx)
/ Kokkos::pow(temperature(ispx), 1.5);
});
}

/**
Expand All @@ -81,7 +100,7 @@ void compute_collfreq_ab(
nustar_profile(ielec(), ix) * density(ielec(), ix)
/ Kokkos::pow(temperature(ielec(), ix), 1.5));

collfreq_ab(ielec(), ix) = std::sqrt(2.) * charge_ratio * charge_ratio
collfreq_ab(ielec(), ix) = Kokkos::sqrt(2.) * charge_ratio * charge_ratio
* collfreq_elec * density(iion, ix)
/ density(ielec(), ix) * (1. + me_on_mi)
/ Kokkos::
Expand Down
Loading

0 comments on commit 9ecda87

Please sign in to comment.