Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
kdtquery.c
Go to the documentation of this file.
1/** @file kdtquery.c
2 */
3/* Gerris - The GNU Flow Solver
4 * Copyright (C) 2010 National Institute of Water and Atmospheric Research
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 * 02111-1307, USA.
20 */
21
22// #include <glib.h>
23#include <stdlib.h>
24#include <stdio.h>
25
26#include "kdt.h"
27
28int main (int argc, char * argv[])
29{
30 if (argc != 2) {
31 fprintf (stderr, "Usage: %s basename\n", argv[0]);
32 return -1;
33 }
34
35 Kdt * kdt = kdt_new ();
36 if (kdt_open (kdt, argv[1])) {
37 fprintf (stderr, "%s: could not open `%s'\n", argv[0], argv[1]);
38 return -1;
39 }
40
42 int count = 0;
43 // GTimer * t = g_timer_new ();
44 while (scanf ("%f %f %f %f",
45 &query[0].l, &query[1].l,
46 &query[0].h, &query[1].h) == 4) {
47#if 1
48 fprintf (stderr, "%ld\n", kdt_query (kdt, query));
49#else
50 KdtSum s;
51 kdt_sum_init (&s);
52 // g_timer_start (t);
54 query, query, &s);
55 // g_timer_stop (t);
56 // fprintf (stderr, "%d %g %g %g %g\n", n, s.H0, s.Hmax, s.Hmin, g_timer_elapsed (t, NULL));
57 printf ("%ld %g %g %g\n", n, s.H0, s.H1, s.H2);
58#endif
59 if (count > 0 && count % 1000 == 0)
60 fprintf (stderr, "\r%d", count);
61 count++;
62 }
63 if (count >= 1000)
64 fputc ('\n', stderr);
65
67 return 0;
68}
scalar h[]
Definition atmosphere.h:6
define l
int x
Definition common.h:76
else return n
Definition curvature.h:101
scalar s
Definition embed-tree.h:56
void kdt_sum_init(KdtSum *s)
Definition kdt.c:1043
Kdt * kdt_new(void)
Definition kdt.c:632
long kdt_query_sum(const Kdt *kdt, KdtCheck includes, KdtCheck intersects, void *data, const KdtRect query, KdtSum *sum)
Definition kdt.c:1025
long kdt_query(const Kdt *kdt, const KdtRect rect)
Definition kdt.c:834
void kdt_destroy(Kdt *kdt)
Definition kdt.c:757
int kdt_intersects(const KdtRect rect, const KdtRect query)
Definition kdt.c:770
int kdt_includes(const KdtRect rect, const KdtRect query)
Definition kdt.c:776
static long query(const Kdt *kdt, const KdtRect rect, long len)
Definition kdt.c:782
int kdt_open(Kdt *kdt, const char *name)
Definition kdt.c:723
int(* KdtCheck)(const KdtRect rect, void *data)
Definition kdt.h:98
KdtInterval KdtRect[2]
Definition kdt.h:40
int main(int argc, char *argv[])
Definition kdtquery.c:28
Definition kdt.h:77
Definition kdt.c:358