Commit 6b77b398 authored by cianciosa's avatar cianciosa
Browse files

Fix clang warnings for -Wall -Wextra -Wpedanitic. Simplfy warm plasma and use...

Fix clang warnings for -Wall -Wextra -Wpedanitic. Simplfy warm plasma and use warm plasma expansion for weak damping.
parent 7f5eebcb
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -41,8 +41,7 @@ void bench_runner() {
    timeing::measure_diagnostic_threaded timing;

    for (size_t i = 0, ie = threads.size(); i < ie; i++) {
        threads[i] = std::thread([&timing, batch, extra] (const size_t thread_number,
                                                   const size_t num_threads) -> void {
        threads[i] = std::thread([&timing, batch, extra] (const size_t thread_number) -> void {

            const size_t local_num_rays = batch
                                        + (extra > thread_number ? 1 : 0);
@@ -91,7 +90,7 @@ void bench_runner() {
            }
            solve.sync_host();
            timing.end_time(thread_number);
        }, i, threads.size());
        }, i);
    }

    for (std::thread &t : threads) {
@@ -111,6 +110,8 @@ void bench_runner() {
//------------------------------------------------------------------------------
int main(int argc, const char * argv[]) {
    START_GPU
    (void)argc;
    (void)argv;

    bench_runner<float,                1000, 10, 100000> ();
    bench_runner<double,               1000, 10, 100000> ();
+9 −10
Original line number Diff line number Diff line
@@ -131,8 +131,7 @@ void trace_ray(const size_t num_times,
    const size_t extra = num_rays%threads.size();

    for (size_t i = 0, ie = threads.size(); i < ie; i++) {
        threads[i] = std::thread([num_times, sub_steps, num_rays, batch, extra] (const size_t thread_number,
                                                                                 const size_t num_threads) -> void {
        threads[i] = std::thread([num_times, sub_steps, batch, extra] (const size_t thread_number) -> void {

            const size_t num_steps = num_times/sub_steps;
            const size_t local_num_rays = batch
@@ -272,7 +271,7 @@ void trace_ray(const size_t num_times,
                solve.sync_host();
            }

        }, i, threads.size());
        }, i);
    }

    for (std::thread &t : threads) {
@@ -306,8 +305,7 @@ void calculate_power(const size_t num_times,
    const size_t extra = num_rays%threads.size();

    for (size_t i = 0, ie = threads.size(); i < ie; i++) {
        threads[i] = std::thread([num_times, sub_steps, num_rays, batch, extra] (const size_t thread_number,
                                                                                 const size_t num_threads) -> void {
        threads[i] = std::thread([num_times, sub_steps, batch, extra] (const size_t thread_number) -> void {
            std::ostringstream stream;
            stream << "result" << thread_number << ".nc";

@@ -334,13 +332,13 @@ void calculate_power(const size_t num_times,
            //absorption::root_finder<dispersion::hot_plasma<T, dispersion::z_erfi<T, SAFE_MATH>, SAFE_MATH>>
            absorption::weak_damping<T, SAFE_MATH>
                power(kamp, omega, kx, ky, kz, x, y, z, t, eq,
                      stream.str(), local_num_rays, thread_number);
                      stream.str(), thread_number);
            power.compile();

            for (size_t j = 0, je = num_steps + 1; j < je; j++) {
                power.run(j);
            }
        }, i, threads.size());
        }, i);
    }

    for (std::thread &t : threads) {
@@ -374,8 +372,7 @@ void bin_power(const size_t num_times,
    const size_t extra = num_rays%threads.size();

    for (size_t i = 0, ie = threads.size(); i < ie; i++) {
        threads[i] = std::thread([num_times, sub_steps, num_rays, batch, extra] (const size_t thread_number,
                                                                                 const size_t num_threads) -> void {
        threads[i] = std::thread([num_times, sub_steps, batch, extra] (const size_t thread_number) -> void {
            std::ostringstream stream;
            stream << "result" << thread_number << ".nc";

@@ -472,7 +469,7 @@ void bin_power(const size_t num_times,
            }

            sync.join();
        }, i, threads.size());
        }, i);
    }

    for (std::thread &t : threads) {
@@ -490,6 +487,8 @@ void bin_power(const size_t num_times,
//------------------------------------------------------------------------------
int main(int argc, const char * argv[]) {
    START_GPU
    (void)argc;
    (void)argv;
    const timeing::measure_diagnostic total("Total Time");

    jit::verbose = verbose;
+12 −16
Original line number Diff line number Diff line
@@ -86,7 +86,6 @@ namespace absorption {
///  @params[in] t        Inital t.
///  @params[in] eq       The plasma equilibrium.
///  @params[in] filename Result filename, empty names will be blank.
///  @params[in] num_rays Number of rays to write.
///  @params[in] index    Concurrent index.
//------------------------------------------------------------------------------
        root_finder(graph::shared_leaf<typename DISPERSION_FUNCTION::base,
@@ -110,10 +109,9 @@ namespace absorption {
                    equilibrium::shared<typename DISPERSION_FUNCTION::base,
                                        DISPERSION_FUNCTION::safe_math> &eq,
                    const std::string &filename="",
                    const size_t num_rays=0,
                    const size_t index=0) :
        kamp(kamp), w(w), kx(kx), ky(ky), kz(kz), x(x), y(y), z(z), t(t),
        file(filename), dataset(file), index(index), work(index), sync([]{}) {
        work(index), index(index), file(filename), dataset(file), sync([]{}) {
            auto kvec = kx*eq->get_esup1(x, y, z)
                      + ky*eq->get_esup2(x, y, z)
                      + kz*eq->get_esup3(x, y, z);
@@ -280,7 +278,6 @@ namespace absorption {
///  @params[in] t        Inital t.
///  @params[in] eq       The plasma equilibrium.
///  @params[in] filename Result filename, empty names will be blank.
///  @params[in] num_rays Number of rays to write.
///  @params[in] index    Concurrent index.
//------------------------------------------------------------------------------
        weak_damping(graph::shared_leaf<T, SAFE_MATH> kamp,
@@ -294,27 +291,26 @@ namespace absorption {
                     graph::shared_leaf<T, SAFE_MATH> t,
                     equilibrium::shared<T, SAFE_MATH> &eq,
                     const std::string &filename="",
                     const size_t num_rays=0,
                     const size_t index=0) :
        kamp(kamp), w(w), kx(kx), ky(ky), kz(kz), x(x), y(y), z(z), t(t),
        file(filename), dataset(file), index(index), work(index), sync([]{}) {
        work(index), index(index), file(filename), dataset(file), sync([]{}) {
            auto k_vec = kx*eq->get_esup1(x, y, z)
                       + ky*eq->get_esup2(x, y, z)
                       + kz*eq->get_esup3(x, y, z);
            auto k_unit = k_vec->unit();

//            auto Dc = dispersion::cold_plasma<T, SAFE_MATH> ().D(w, kx, ky, kz,
//                                                                 x, y, z, t, eq);
            auto Dw = dispersion::hot_plasma<T,
            auto Dc = dispersion::cold_plasma<T, SAFE_MATH> ().D(w, kx, ky, kz,
                                                                 x, y, z, t, eq);
            auto Dw = dispersion::hot_plasma_expansion<T,
                                                       dispersion::z_erfi<T, SAFE_MATH>,
                                                       SAFE_MATH> ().D(w, kx, ky, kz,
                                                                       x, y, z, t, eq);

            auto none = graph::none<T, SAFE_MATH> ();
            auto kamp1 = k_vec->length() 
                       - Dw/k_unit->dot(Dw->df(kx)*eq->get_esup1(x, y, z) +
                                        Dw->df(ky)*eq->get_esup2(x, y, z) +
                                        Dw->df(kz)*eq->get_esup3(x, y, z));
                       - Dw/k_unit->dot(Dc->df(kx)*eq->get_esup1(x, y, z) +
                                        Dc->df(ky)*eq->get_esup2(x, y, z) +
                                        Dc->df(kz)*eq->get_esup3(x, y, z));

            graph::input_nodes<T, SAFE_MATH> inputs = {
                graph::variable_cast(this->kamp),
+7 −7
Original line number Diff line number Diff line
@@ -975,21 +975,21 @@ namespace dispersion {
            auto zeta = (one - ec/w)/(npara*ve);
            auto Z_func = this->z.Z(zeta);
            auto zeta_func = one + zeta*Z_func;
            auto F = (ve*zeta)/(two*npara)*w*w/(ec*ec);
            auto isigma = wpe2/(two*w*w)*Z_func/(npara*ve);
            auto F = ve*zeta*w/(two*npara*ec);
            auto isigma = P*Z_func/(two*npara*ve);

            auto q_func = one - two*q;
            auto n_func = n2 + npara2;
            auto p_func = one - P;

            auto gamma5 = n2*npara2 - (one - q)*n_func + q_func;
            auto gamma2 = w/ec*(n2 - q_func)
                        + P*w*w/(four*ec*ec)*(n_func - two*q_func)/npara2;
            auto gamma2 = (n2 - q_func)
                        + P*w/(four*ec*npara2)*(n_func - two*q_func);
            auto gamma1 = nperp2*((one - q)*n2 - q_func)
                        + p_func*(n2*npara2 - (one - q)*n_func + q_func);
            auto gamma0 = nperp2*(n2 - two*q_func) + p_func*(two*q_func - n_func);

            return isigma*gamma0 + gamma1 + nperp2*P*zeta_func*(gamma2 + gamma5*F);
            return isigma*gamma0 + gamma1 + nperp2*P*w/ec*zeta_func*(gamma2 + gamma5*F);
        }
    };

@@ -1105,8 +1105,8 @@ namespace dispersion {
                        + p_func*(n2*npara2 - (one - q)*n_func)
                        - q_func*(nperp2 - p_func);

            return none*(one - ec/w)*npara*vtnorm*(gamma1 + gamma2 +
                                                   nperp2/(two*npara)*(w*w/(ec*ec))*vtnorm*zeta*gamma5)*(one/Z_func + zeta);
            return none*(one + ec/w)*npara*vtnorm *
                   (gamma1 + gamma2 + nperp2/(two*npara)*(w*w/(ec*ec))*vtnorm*zeta*gamma5)*(one/Z_func + zeta);
        }
    };

+2 −0
Original line number Diff line number Diff line
@@ -2464,6 +2464,8 @@ template<jit::float_scalar T> void run_tests() {
///  @params[in] argv Array of commandline arguments.
//------------------------------------------------------------------------------
int main(int argc, const char * argv[]) {
    (void)argc;
    (void)argv;
    run_tests<float> ();
    run_tests<double> ();
    run_tests<std::complex<float>> ();
Loading