Пример #1
0
Файл: bd.c Проект: matthagy/pbd
static void
update_particle_membership(void)
{
        /* lose all concept of external particles */
        truncate_array(CEX_positions, CEX_N_internal_particles);
        clear_send_indices();
        int n_sent = annote_exited_particles();
        exchange_send_lengths();
        int n_recv = setup_exchange_exit_temps();
        exchange_exited_particles();
        remove_exited_particles(n_sent);
        insert_entered_particles();
        clear_send_indices();
        /* update internal data structures */
        CEX_N_internal_particles += n_recv - n_sent;
        assert(ARR_LENGTH(CEX_positions) == CEX_N_internal_particles);
        CEX_prealloc_array(CEX_forces, CEX_N_internal_particles);
        ARR_LENGTH(CEX_forces) = CEX_N_internal_particles;
        CEX_prealloc_array(CEX_nl_displace, CEX_N_internal_particles);
        ARR_LENGTH(CEX_nl_displace) = CEX_N_internal_particles;
        CEX_prealloc_array(CEX_new_positions, CEX_N_internal_particles);
        ARR_LENGTH(CEX_new_positions) = CEX_N_internal_particles;
        CEX_prealloc_array(CEX_random_vectors, CEX_N_internal_particles);
        ARR_LENGTH(CEX_random_vectors) = CEX_N_internal_particles;
}
Пример #2
0
void vpFlush() {
  digitalWrite(SR_LATCH, LOW);
  for (int reg = ARR_LENGTH(shiftRegister)-1; reg >= 0; reg--) {
    shiftOut(SR_SERIAL, SR_CLOCK, MSBFIRST, shiftRegister[reg]);
  }
  digitalWrite(SR_LATCH, HIGH);
}
Пример #3
0
static void
test_vec_array()
{
        array_t *pos, *rpos;

        pos = CEX_make_vec_array(0);
        add_vec(pos, 0,0,0);
        add_vec(pos, 5,0,M_PI);
        add_vec(pos, 23e12,-5e-13,34.23);
        rpos = CEX_reversed_array(pos);
        CEX_extend_array(pos, rpos);
        CEX_extend_array(pos, pos);
        CEX_free_array(rpos);
        
        msg_t *msg = CEX_make_write_msg(0);
        CEX_msg_write_vec_array(msg, pos);
        setup_read(msg);
        array_t *pos2 = CEX_msg_read_vec_array(msg);
        REQ_MSG_EOFP(msg);
        CEX_free_msg(msg);
        REQ_VARR(pos2);
        assert(ARR_LENGTH(pos) == ARR_LENGTH(pos2));
        for (int i=0; i <ARR_LENGTH(pos); i++) {
                vec_t v1 = ARR_INDEX_AS(vec_t, pos, i);
                vec_t v2 = ARR_INDEX_AS(vec_t, pos2, i);
#if 0
                xprintf("%d " Vec3_FRMT("%.5e") " " Vec3_FRMT("%.5e"),
                        i, Vec3_ARGS(v1), Vec3_ARGS(v2));
#endif
                EXPECT_DOUBLE(1e-10, v1.x, v2.x);
                EXPECT_DOUBLE(1e-10, v2.y, v2.y);
                EXPECT_DOUBLE(1e-10, v1.z, v2.z);
        }
        CEX_free_array(pos);
        CEX_free_array(pos2);
}
Пример #4
0
static void
test_char_array()
{
        const char *test = "this is a test string";
        array_t *arr = CEX_make_char_array_from_string(test);
        msg_t *msg = CEX_make_write_msg(0);
        CEX_msg_write_char_array(msg, arr);
        CEX_free_array(arr);
        setup_read(msg);
        array_t *rarr = CEX_msg_read_char_array(msg);
        char buffer[ARR_LENGTH(rarr)+1];
        CEX_char_array_as_string(rarr, buffer);
        assert(strcmp(test, buffer)==0);
        CEX_free_array(rarr);
}