[MOAB-dev] commit/MOAB: tautges: Getting rid of all the individual .h files in src/moab/point_locator/lotte/

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Sep 12 11:33:20 CDT 2013


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/96041dbdbb25/
Changeset:   96041dbdbb25
Branch:      master
User:        tautges
Date:        2013-09-12 18:33:01
Summary:     Getting rid of all the individual .h files in src/moab/point_locator/lotte/
(i.e. types.h, findpt.h, etc), putting them in a new FindPtFuncs.h, and updating all the
associated uses of those headers.

Passes tests on debug, optimized, and parallel builds.

Affected #:  20 files

diff --git a/src/Makefile.am b/src/Makefile.am
index 6c4b890..28ef5c2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -74,16 +74,10 @@ libMOAB_la_SOURCES = \
   OrientedBox.cpp \
   OrientedBox.hpp \
   OrientedBoxTreeTool.cpp \
-  moab/point_locater/lotte/minmax.h \
-  moab/point_locater/lotte/extrafindpt.h \
   lotte/poly.c \
-  moab/point_locater/lotte/poly.h \
   lotte/findpt.c \
-  moab/point_locater/lotte/findpt.h \
   lotte/errmem.c \
-  moab/point_locater/lotte/errmem.h \
   lotte/tensor.c \
-  moab/point_locater/lotte/tensor.h \
   PolyElementSeq.cpp \
   PolyElementSeq.hpp \
   ProgOptions.cpp \
@@ -173,10 +167,6 @@ nobase_libMOAB_la_include_HEADERS = \
   moab/point_locater/element_maps/linear_tet_map.hpp  \
   moab/point_locater/element_maps/spectral_hex_map.hpp  \
   moab/point_locater/element_maps/quadratic_hex_map.hpp  \
-  moab/point_locater/lotte/types.h  \
-  moab/point_locater/lotte/errmem.h  \
-  moab/point_locater/lotte/findpt.h  \
-  moab/point_locater/lotte/poly.h  \
   moab/point_locater/point_locater.hpp \
   moab/point_locater/parametrizer.hpp \
   moab/Matrix3.hpp \

diff --git a/src/lotte/errmem.c b/src/lotte/errmem.c
index 0196d83..b890bce 100644
--- a/src/lotte/errmem.c
+++ b/src/lotte/errmem.c
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
+#include "moab/FindPtFuncs.h"
 
 void fail(const char *fmt, ...)
 {

diff --git a/src/lotte/findpt.c b/src/lotte/findpt.c
index 00fe8b7..160c7ab 100644
--- a/src/lotte/findpt.c
+++ b/src/lotte/findpt.c
@@ -5,12 +5,10 @@
 #include <float.h>
 #include <string.h>  /* for memcpy */
 
-#include "errmem.h"
-#include "types.h"
-#include "minmax.h"
-#include "poly.h"
-#include "tensor.h"
-#include "extrafindpt.h"
+#include "moab/FindPtFuncs.h"
+
+const unsigned opt_no_constraints_2 = 3+1;
+const unsigned opt_no_constraints_3 = 9+3+1;
 
 /*--------------------------------------------------------------------------
    Lobatto Polynomial Bounds
@@ -484,14 +482,6 @@ static void obbox_free_3(obbox_data_3 *p)
   free(p);
 }
 
-typedef struct {
-  real x[2], A[4], axis_bnd[4];
-} obbox_2;
-
-typedef struct {
-  real x[3], A[9], axis_bnd[6];
-} obbox_3;
-
 int obbox_axis_test_2(const obbox_2 *p, const real x[2])
 {
   return (x[0]<p->axis_bnd[0] || x[0]>p->axis_bnd[1] ||
@@ -767,34 +757,6 @@ void obbox_calc_3(const obbox_data_3 *p, real tol,
      
   --------------------------------------------------------------------------*/
 
-typedef struct {
-  unsigned hash_n;
-  real bnd[4]; /* bounds for all elements */
-  real fac[2]; /* fac[i] = hash_n / (bnd[2*i+1]-bnd[2*i]) */
-  obbox_2 *obb; /* obb[nel] -- bounding box info for each element */
-  uint *offset; /* hash table -- for cell i,j:
-                         uint index = j*hash_n+i,
-                                  b = offset[index  ],
-                                  e = offset[index+1];
-                         elements in cell are
-                           offset[b], offset[b+1], ..., offset[e-1] */
-  unsigned max; /* maximum # of elements in any cell */
-} hash_data_2;
-
-typedef struct {
-  unsigned hash_n;
-  real bnd[6]; /* bounds for all elements */
-  real fac[3]; /* fac[i] = hash_n / (bnd[2*i+1]-bnd[2*i]) */
-  obbox_3 *obb; /* obb[nel] -- bounding box info for each element */
-  uint *offset; /* hash table -- for cell i,j,k:
-                         uint index = (k*hash_n+j)*hash_n+i,
-                                  b = offset[index  ],
-                                  e = offset[index+1];
-                         elements in cell are
-                           offset[b], offset[b+1], ..., offset[e-1] */
-  unsigned max; /* maximum # of elements in any cell */
-} hash_data_3;
-
 static int ifloor(real x)
 {
   /*
@@ -1885,12 +1847,6 @@ double opt_findpt_2(opt_data_2 *p, const real *const elx[2],
      
   --------------------------------------------------------------------------*/
 
-typedef struct {
-  uint el;
-  real r[3];
-  real dist;
-} findpt_listel;
-
 /* heap sort on A[0:n-1] with key A[i]->dist
    precondition: n!=0 */
 static void findpt_list_sort(findpt_listel **A, unsigned n)
@@ -1925,34 +1881,6 @@ static void findpt_list_sort(findpt_listel **A, unsigned n)
   }
 }
 
-typedef struct {
-  const real *xw[2];   /* geometry data */
-  real *z[2];          /* lobatto nodes */
-  lagrange_data ld[2]; /* interpolation, derivative weights & data */
-  unsigned nptel;      /* nodes per element */
-  hash_data_2 *hash;   /* geometric hashing data */
-  findpt_listel *list, **sorted, **end; /* pre-allocated list of elements to
-                                           check (found by hashing), and
-                                           pre-allocated list of pointers into
-                                           the first list for sorting */
-  opt_data_2 *od; /* data for the optimization algorithm */
-  real *od_work;
-} findpt_data_2;
-
-typedef struct {
-  const real *xw[3];   /* geometry data */
-  real *z[3];          /* lobatto nodes */
-  lagrange_data ld[3]; /* interpolation, derivative weights & data */
-  unsigned nptel;      /* nodes per element */
-  hash_data_3 *hash;   /* geometric hashing data */
-  findpt_listel *list, **sorted, **end; /* pre-allocated list of elements to
-                                           check (found by hashing), and
-                                           pre-allocated list of pointers into
-                                           the first list for sorting */
-  opt_data_3 *od; /* data for the optimization algorithm */
-  real *od_work;
-} findpt_data_3;
-
 findpt_data_2 *findpt_setup_2(
           const real *const xw[2], const unsigned n[2], uint nel,
           uint max_hash_size, real bbox_tol)

diff --git a/src/lotte/poly.c b/src/lotte/poly.c
index 6b5cba6..b8a93b7 100644
--- a/src/lotte/poly.c
+++ b/src/lotte/poly.c
@@ -5,8 +5,7 @@
 #include <string.h>  /* for memcpy */
 #include <float.h>
 
-#include "errmem.h"
-#include "types.h"
+#include "moab/FindPtFuncs.h"
 
 /* 
   For brevity's sake, some names have been shortened
@@ -354,15 +353,6 @@ void lagrange_weights_deriv(const real *z, unsigned n,
      lagrange_free(&p);  // deallocate memory allocated by setup
   --------------------------------------------------------------------------*/
 
-typedef struct {
-  unsigned n;                /* number of Lagrange nodes            */
-  const real *z;             /* Lagrange nodes (user-supplied)      */
-  real *J, *D, *D2;          /* weights for 0th,1st,2nd derivatives */
-  real *J_z0, *D_z0, *D2_z0; /* ditto at z[0]   (computed at setup) */
-  real *J_zn, *D_zn, *D2_zn; /* ditto at z[n-1] (computed at setup) */
-  real *w, *d, *u0, *v0, *u1, *v1, *u2, *v2; /* work data            */
-} lagrange_data;
-
 void lagrange_0(lagrange_data *p, real x)
 {
   unsigned i, n=p->n;

diff --git a/src/lotte/tensor.c b/src/lotte/tensor.c
index 19e54b7..510dc38 100644
--- a/src/lotte/tensor.c
+++ b/src/lotte/tensor.c
@@ -1,4 +1,4 @@
-#include "types.h"
+#include "moab/FindPtFuncs.h"
 
 /*--------------------------------------------------------------------------
    Matrix-Matrix Multiplication

diff --git a/src/moab/point_locater/element_maps/spectral_hex_map.hpp b/src/moab/point_locater/element_maps/spectral_hex_map.hpp
index 11bd573..895bc36 100644
--- a/src/moab/point_locater/element_maps/spectral_hex_map.hpp
+++ b/src/moab/point_locater/element_maps/spectral_hex_map.hpp
@@ -3,14 +3,7 @@
 
 #include "moab/Matrix3.hpp"
 #include "moab/CartVect.hpp"
-extern "C"{
-   #include "moab/point_locater/lotte/types.h"
-   #include "moab/point_locater/lotte/poly.h"
-   #include "moab/point_locater/lotte/tensor.h"
-   #include "moab/point_locater/lotte/findpt.h"
-   #include "moab/point_locater/lotte/extrafindpt.h"
-   #include "moab/point_locater/lotte/errmem.h"
-}
+#include "moab/FindPtFuncs.h"
 #include <sstream>
 #include <iomanip>
 #include <iostream>

diff --git a/src/moab/point_locater/lotte/errmem.h b/src/moab/point_locater/lotte/errmem.h
deleted file mode 100644
index d881f4a..0000000
--- a/src/moab/point_locater/lotte/errmem.h
+++ /dev/null
@@ -1,85 +0,0 @@
-#ifndef ERRMEM_H
-#define ERRMEM_H
-
-/* requires:
-     <stdlib.h> for malloc, calloc, realloc, free
-*/
-
-/*--------------------------------------------------------------------------
-   Error Reporting
-   Memory Allocation Wrappers to Catch Out-of-memory
-  --------------------------------------------------------------------------*/
-
-/* #include "malloc.h" */
-#include <stdlib.h>
-
-#ifdef __GNUC__
-void fail(const char *fmt, ...) __attribute__ ((noreturn));
-#define MAYBE_UNUSED __attribute__ ((unused))
-#else
-void fail(const char *fmt, ...);
-#define MAYBE_UNUSED
-#endif
-
-#if 0
-{}
-#endif
-
-static void *smalloc(size_t size, const char *file) MAYBE_UNUSED;
-static void *smalloc(size_t size, const char *file)
-{
-  void *res = malloc(size);
-  if(!res && size) fail("%s: allocation of %d bytes failed\n",file,(int)size);
-  return res;
-}
-
-static void *scalloc(size_t nmemb, size_t size, const char *file) MAYBE_UNUSED;
-static void *scalloc(size_t nmemb, size_t size, const char *file)
-{
-  void *res = calloc(nmemb, size);
-  if(!res && nmemb)
-    fail("%s: allocation of %d bytes failed\n",file,(int)size*nmemb);
-  return res;
-}
-
-static void *srealloc(void *ptr, size_t size, const char *file) MAYBE_UNUSED;
-static void *srealloc(void *ptr, size_t size, const char *file)
-{
-  void *res = realloc(ptr, size);
-  if(!res && size) fail("%s: allocation of %d bytes failed\n",file,(int)size);
-  return res;
-}
-
-#define tmalloc(type, count) \
-  ((type*) smalloc((count)*sizeof(type),__FILE__) )
-#define tcalloc(type, count) \
-  ((type*) scalloc((count),sizeof(type),__FILE__) )
-#define trealloc(type, ptr, count) \
-  ((type*) srealloc((ptr),(count)*sizeof(type),__FILE__) )
-/*
-typedef struct { size_t size; void *ptr; } buffer;
-
-static void buffer_init_(buffer *b, size_t size, const char *file) MAYBE_UNUSED;
-static void buffer_init_(buffer *b, size_t size, const char *file)
-{
-  b->size=size, b->ptr=smalloc(size,file);
-}
-static void buffer_reserve_(buffer *b, size_t min, const char *file)
-  MAYBE_UNUSED;
-static void buffer_reserve_(buffer *b, size_t min, const char *file)
-{
-  size_t size = b->size;
-  if(size<min) {
-    size+=size/2+1;
-    if(size<min) size=min;
-    b->ptr=srealloc(b->ptr,size,file);
-  }
-}
-static void buffer_free(buffer *b) MAYBE_UNUSED;
-static void buffer_free(buffer *b) { free(b->ptr); }
-
-#define buffer_init(b,size) buffer_init_(b,size,__FILE__)
-#define buffer_reserve(b,min) buffer_reserve_(b,min,__FILE__)
-*/
-#endif
-

diff --git a/src/moab/point_locater/lotte/extrafindpt.h b/src/moab/point_locater/lotte/extrafindpt.h
deleted file mode 100644
index 38aa1a1..0000000
--- a/src/moab/point_locater/lotte/extrafindpt.h
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef EXTRA_FINDPT_H
-#define EXTRA_FINDPT_H
-/* extra stuff that james didn't expose */
-
-typedef struct {
-  unsigned constraints;
-  unsigned dn, d1, d2;
-  real *x[3], *fdn[3];
-} opt_face_data_3;
-
-typedef struct {
-  unsigned constraints;
-  unsigned de, d1, d2;
-  real *x[3], *fd1[3], *fd2[3];
-} opt_edge_data_3;
-
-typedef struct {
-  unsigned constraints;
-  real x[3], jac[9];
-} opt_point_data_3;
-
-typedef struct {
-  lagrange_data *ld;
-  unsigned size[4];
-  const real *elx[3];
-  opt_face_data_3 fd;
-  opt_edge_data_3 ed;
-  opt_point_data_3 pd;
-  real *work;
-  real x[3], jac[9];
-} opt_data_3;
-
-
-void opt_alloc_3(opt_data_3 *p, lagrange_data *ld);
-void opt_free_3(opt_data_3 *p);
-double opt_findpt_3(opt_data_3 *p, const real *const elx[3],
-                           const real xstar[3], real r[3], unsigned *constr);
-void opt_vol_set_intp_3(opt_data_3 *p, const real r[3]);
-
-const unsigned opt_no_constraints_2 = 3+1;
-const unsigned opt_no_constraints_3 = 9+3+1;
-
-/* for 2d spectralQuad */
-/*--------------------------------------------------------------------------
-
-   2 - D
-
-  --------------------------------------------------------------------------*/
-
-typedef struct {
-  unsigned constraints;
-  unsigned de, d1;
-  real *x[2], *fd1[2];
-} opt_edge_data_2;
-
-typedef struct {
-  unsigned constraints;
-  real x[2], jac[4];
-} opt_point_data_2;
-
-typedef struct {
-  lagrange_data *ld;
-  unsigned size[3];
-  const real *elx[2];
-  opt_edge_data_2 ed;
-  opt_point_data_2 pd;
-  real *work;
-  real x[2], jac[4];
-} opt_data_2;
-void opt_alloc_2(opt_data_2 *p, lagrange_data *ld);
-void opt_free_2(opt_data_2 *p);
-double opt_findpt_2(opt_data_2 *p, const real *const elx[2],
-                           const real xstar[2], real r[2], unsigned *constr);
-
-
-
-#endif /*EXTRA_FINDPT_H */

diff --git a/src/moab/point_locater/lotte/findpt.h b/src/moab/point_locater/lotte/findpt.h
deleted file mode 100644
index 477e49e..0000000
--- a/src/moab/point_locater/lotte/findpt.h
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef FINDPT_H
-#define FINDPT_H
-
-/* requires "types.h", "poly.h", "tensor.h" */
-#if !defined(TYPES_H) || !defined(POLY_H) || !defined(TENSOR_H)
-#warning "findpt.h" requires "types.h", "poly.h", "tensor.h"
-#endif
-
-typedef struct {
-  const real *xw[2];   /* geometry data */
-  real *z[2];          /* lobatto nodes */
-  lagrange_data ld[2]; /* interpolation, derivative weights & data */
-  unsigned nptel;      /* nodes per element */
-  struct findpt_hash_data_2 *hash;   /* geometric hashing data */
-  struct findpt_listel *list, **sorted, **end;
-                                        /* pre-allocated list of elements to
-                                           check (found by hashing), and
-                                           pre-allocated list of pointers into
-                                           the first list for sorting */
-  struct findpt_opt_data_2 *od; /* data for the optimization algorithm */
-  real *od_work;
-} findpt_data_2;
-
-typedef struct {
-  const real *xw[3];   /* geometry data */
-  real *z[3];          /* lobatto nodes */
-  lagrange_data ld[3]; /* interpolation, derivative weights & data */
-  unsigned nptel;      /* nodes per element */
-  struct findpt_hash_data_3 *hash;   /* geometric hashing data */
-  struct findpt_listel *list, **sorted, **end;
-                                        /* pre-allocated list of elements to
-                                           check (found by hashing), and
-                                           pre-allocated list of pointers into
-                                           the first list for sorting */
-  struct findpt_opt_data_3 *od; /* data for the optimization algorithm */
-  real *od_work;
-} findpt_data_3;
-
-findpt_data_2 *findpt_setup_2(
-          const real *const xw[2], const unsigned n[2], uint nel,
-          uint max_hash_size, real bbox_tol);
-findpt_data_3 *findpt_setup_3(
-          const real *const xw[3], const unsigned n[3], uint nel,
-          uint max_hash_size, real bbox_tol);
-
-void findpt_free_2(findpt_data_2 *p);
-void findpt_free_3(findpt_data_3 *p);
-
-const real *findpt_allbnd_2(const findpt_data_2 *p);
-const real *findpt_allbnd_3(const findpt_data_3 *p);
-
-typedef int (*findpt_func)(void *, const real *, int, uint *, real *, real *);
-int findpt_2(findpt_data_2 *p, const real x[2], int guess,
-             uint *el, real r[2], real *dist);
-int findpt_3(findpt_data_3 *p, const real x[3], int guess,
-             uint *el, real r[3], real *dist);
-
-void findpt_weights_2(findpt_data_2 *p, const real r[2]) ;
-
-void findpt_weights_3(findpt_data_3 *p, const real r[3]);
-
-double findpt_eval_2(findpt_data_2 *p, const real *u);
-
-double findpt_eval_3(findpt_data_3 *p, const real *u);
-
-#endif
-

diff --git a/src/moab/point_locater/lotte/minmax.h b/src/moab/point_locater/lotte/minmax.h
deleted file mode 100644
index 9fb5ed1..0000000
--- a/src/moab/point_locater/lotte/minmax.h
+++ /dev/null
@@ -1,82 +0,0 @@
-#ifndef MINMAX_H
-#define MINMAX_H
-
-/* requires <math.h> and "types.h" */
-
-#ifndef TYPES_H
-#warning "minmax.h" depends on "types.h"
-#endif
-
-/*--------------------------------------------------------------------------
-   Min, Max, Norm
-  --------------------------------------------------------------------------*/
-
-#ifdef __GNUC__
-#define MAYBE_UNUSED __attribute__ ((unused))
-#else
-#define MAYBE_UNUSED
-#endif
-
-#define DECLMINMAX(type, prefix) \
-  static type prefix##min_2(type a, type b) MAYBE_UNUSED;               \
-  static type prefix##min_2(type a, type b) {                           \
-    return b<a?b:a;                                                     \
-  }                                                                     \
-  static type prefix##max_2(type a, type b) MAYBE_UNUSED;               \
-  static type prefix##max_2(type a, type b) {                           \
-    return a>b?a:b;                                                     \
-  }                                                                     \
-  static void prefix##minmax_2(type *min, type *max, type a,            \
-                               type b) MAYBE_UNUSED;                    \
-  static void prefix##minmax_2(type *min, type *max, type a, type b) {  \
-    if(b<a) *min=b, *max=a;                                             \
-    else *min=a, *max=b;                                                \
-  }                                                                     \
-  static type prefix##min_3(type a, type b, type c) MAYBE_UNUSED;       \
-  static type prefix##min_3(type a, type b, type c) {                   \
-    return b<a?(c<b?c:b):(c<a?c:a);                                     \
-  }                                                                     \
-  static type prefix##max_3(type a, type b, type c) MAYBE_UNUSED;       \
-  static type prefix##max_3(type a, type b, type c) {                   \
-    return a>b?(a>c?a:c):(b>c?b:c);                                     \
-  }                                                                     \
-  static void prefix##minmax_3(type *min, type *max, type a, type b,    \
-                               type c) MAYBE_UNUSED;                    \
-  static void prefix##minmax_3(type *min, type *max, type a, type b,    \
-                               type c) {                                \
-    if(b<a) *min=prefix##min_2(b,c), *max=prefix##max_2(a,c);           \
-    else    *min=prefix##min_2(a,c), *max=prefix##max_2(b,c);           \
-  }
-
-DECLMINMAX(int, i)
-DECLMINMAX(unsigned, u)
-DECLMINMAX(real, r)
-#undef DECLMINMAX
-
-static real r1norm_1(real a) MAYBE_UNUSED;
-static real r1norm_1(real a) {
-  return fabsr(a);
-}
-static real r1norm_2(real a, real b) MAYBE_UNUSED;
-static real r1norm_2(real a, real b) {
-  return fabsr(a)+fabsr(b);
-}
-static real r1norm_3(real a, real b, real c) MAYBE_UNUSED;
-static real r1norm_3(real a, real b, real c) {
-  return fabsr(a)+fabsr(b)+fabsr(c);
-}
-static real r2norm_1(real a) MAYBE_UNUSED;
-static real r2norm_1(real a) {
-  return sqrtr(a*a);
-}
-static real r2norm_2(real a, real b) MAYBE_UNUSED;
-static real r2norm_2(real a, real b) {
-  return sqrtr(a*a+b*b);
-}
-static real r2norm_3(real a, real b, real c) MAYBE_UNUSED;
-static real r2norm_3(real a, real b, real c) {
-  return sqrtr(a*a+b*b+c*c);
-}
-
-#endif
-

diff --git a/src/moab/point_locater/lotte/poly.h b/src/moab/point_locater/lotte/poly.h
deleted file mode 100644
index ef3bf6c..0000000
--- a/src/moab/point_locater/lotte/poly.h
+++ /dev/null
@@ -1,155 +0,0 @@
-#ifndef POLY_H
-#define POLY_H
-
-/* requires "types.h" */
-#ifndef TYPES_H
-#warning "poly.h" requires "types.h"
-#endif
-
-/* 
-  For brevity's sake, some names have been shortened
-  Quadrature rules
-    Gauss   -> Gauss-Legendre quadrature (open)
-    Lobatto -> Gauss-Lobatto-Legendre quadrature (closed at both ends)
-  Polynomial bases
-    Legendre -> Legendre basis
-    Gauss    -> Lagrangian basis using Gauss   quadrature nodes
-    Lobatto  -> Lagrangian basis using Lobatto quadrature nodes
-*/
-
-/*--------------------------------------------------------------------------
-   Legendre Polynomial Matrix Computation
-   (compute P_i(x_j) for i = 0, ..., n and a given set of x)
-  --------------------------------------------------------------------------*/
-
-/* precondition: n >= 1
-   inner index is x index (0 ... m-1);
-   outer index is Legendre polynomial number (0 ... n)
- */
-void legendre_matrix(const real *x, int m, real *P, int n);
-
-/* precondition: n >= 1
-   inner index is Legendre polynomial number (0 ... n)
-   outer index is x index (0 ... m-1);
- */
-void legendre_matrix_t(const real *x, int m, real *P, int n);
-
-/* precondition: n >= 1
-   compute P_i(x) with i = 0 ... n
- */
-void legendre_row(real x, real *P, int n);
-
-
-/*--------------------------------------------------------------------------
-   Quadrature Nodes and Weights Calculation
-   
-   call the _nodes function before calling the _weights function
-  --------------------------------------------------------------------------*/
-
-void gauss_nodes(real *z, int n);   /* n nodes (order = 2n-1) */
-void lobatto_nodes(real *z, int n); /* n nodes (order = 2n-3) */
-
-void gauss_weights(const real *z, real *w, int n);
-void lobatto_weights(const real *z, real *w, int n);
-
-/*--------------------------------------------------------------------------
-   Lagrangian to Legendre Change-of-basis Matrix
-  --------------------------------------------------------------------------*/
-
-/* precondition: n >= 2
-   given the Gauss quadrature rule (z,w,n), compute the square matrix J
-   for transforming from the Gauss basis to the Legendre basis:
-   
-      u_legendre(i) = sum_j J(i,j) u_gauss(j)
-
-   computes J   = .5 (2i+1) w  P (z )
-             ij              j  i  j
-             
-   in column major format (inner index is i, the Legendre index)
- */
-void gauss_to_legendre(const real *z, const real *w, int n, real *J);
-
-/* precondition: n >= 2
-   same as above, but
-   in row major format (inner index is j, the Gauss index)
- */
-void gauss_to_legendre_t(const real *z, const real *w, int n, real *J);
-
-/* precondition: n >= 3
-   given the Lobatto quadrature rule (z,w,n), compute the square matrix J
-   for transforming from the Lobatto basis to the Legendre basis:
-   
-      u_legendre(i) = sum_j J(i,j) u_lobatto(j)
-
-   in column major format (inner index is i, the Legendre index)
- */
-void lobatto_to_legendre(const real *z, const real *w, int n, real *J);
-
-/*--------------------------------------------------------------------------
-   Lagrangian basis function evaluation
-  --------------------------------------------------------------------------*/
-
-/* given the Lagrangian nodes (z,n) and evaluation points (x,m)
-   evaluate all Lagrangian basis functions at all points x
-   
-   inner index of output J is the basis function index (row-major format)
-   provide work array with space for 4*n doubles
- */
-void lagrange_weights(const real *z, unsigned n,
-                      const real *x, unsigned m,
-                      real *J, real *work);
-
-/* given the Lagrangian nodes (z,n) and evaluation points (x,m)
-   evaluate all Lagrangian basis functions and their derivatives
-   
-   inner index of outputs J,D is the basis function index (row-major format)
-   provide work array with space for 6*n doubles
- */
-void lagrange_weights_deriv(const real *z, unsigned n,
-                            const real *x, unsigned m,
-                            real *J, real *D, real *work);
-
-/*--------------------------------------------------------------------------
-   Speedy Lagrangian Interpolation
-   
-   Usage:
-   
-     lagrange_data p;
-     lagrange_setup(&p,z,n);    *  setup for nodes z[0 ... n-1] *
-     
-     the weights
-       p->J [0 ... n-1]     interpolation weights
-       p->D [0 ... n-1]     1st derivative weights
-       p->D2[0 ... n-1]     2nd derivative weights
-     are computed for a given x with:
-       lagrange_0(p,x);  *  compute p->J *
-       lagrange_1(p,x);  *  compute p->J, p->D *
-       lagrange_2(p,x);  *  compute p->J, p->D, p->D2 *
-       lagrange_2u(p);   *  compute p->D2 after call of lagrange_1(p,x); *
-     These functions use the z array supplied to setup
-       (that pointer should not be freed between calls)
-     Weights for x=z[0] and x=z[n-1] are computed during setup; access as:
-       p->J_z0, etc. and p->J_zn, etc.
-
-     lagrange_free(&p);  *  deallocate memory allocated by setup *
-  --------------------------------------------------------------------------*/
-
-typedef struct {
-  unsigned n;                /* number of Lagrange nodes            */
-  const real *z;             /* Lagrange nodes (user-supplied)      */
-  real *J, *D, *D2;          /* weights for 0th,1st,2nd derivatives */
-  real *J_z0, *D_z0, *D2_z0; /* ditto at z[0]   (computed at setup) */
-  real *J_zn, *D_zn, *D2_zn; /* ditto at z[n-1] (computed at setup) */
-  real *w, *d, *u0, *v0, *u1, *v1, *u2, *v2; /* work data           */
-} lagrange_data;
-
-void lagrange_setup(lagrange_data *p, const real *z, unsigned n);
-void lagrange_free(lagrange_data *p);
-
-void lagrange_0(lagrange_data *p, real x) ;
-void lagrange_1(lagrange_data *p, real x) ;
-void lagrange_2(lagrange_data *p, real x) ;
-void lagrange_2u(lagrange_data *p) ;
-
-#endif
-

diff --git a/src/moab/point_locater/lotte/tensor.h b/src/moab/point_locater/lotte/tensor.h
deleted file mode 100644
index c5dd010..0000000
--- a/src/moab/point_locater/lotte/tensor.h
+++ /dev/null
@@ -1,102 +0,0 @@
-#ifndef TENSOR_H
-#define TENSOR_H
-
-/* requires "types.h" */
-
-#ifndef TYPES_H
-#warning "tensor.h" requires "types.h"
-#endif
-
-/*--------------------------------------------------------------------------
-   1-,2-,3-d Tensor Application
-   
-   the 3d case:
-   tensor_f3(R,mr,nr, S,ms,ns, T,mt,nt, u,v, work1,work2)
-     gives v = [ R (x) S (x) T ] u
-     where R is mr x nr, S is ms x ns, T is mt x nt,
-       each in row- or column-major format according to f := r | c
-     u is nr x ns x nt in column-major format (inner index is r)
-     v is mr x ms x mt in column-major format (inner index is r)
-  --------------------------------------------------------------------------*/
-
-void tensor_c1(const real *R, unsigned mr, unsigned nr, 
-               const real *u, real *v);
-void tensor_r1(const real *R, unsigned mr, unsigned nr, 
-               const real *u, real *v);
-
-/* work holds mr*ns reals */
-void tensor_c2(const real *R, unsigned mr, unsigned nr,
-               const real *S, unsigned ms, unsigned ns,
-               const real *u, real *v, real *work);
-void tensor_r2(const real *R, unsigned mr, unsigned nr,
-               const real *S, unsigned ms, unsigned ns,
-               const real *u, real *v, real *work);
-
-/* work1 holds mr*ns*nt reals,
-   work2 holds mr*ms*nt reals */
-void tensor_c3(const real *R, unsigned mr, unsigned nr,
-               const real *S, unsigned ms, unsigned ns,
-               const real *T, unsigned mt, unsigned nt,
-               const real *u, real *v, real *work1, real *work2);
-void tensor_r3(const real *R, unsigned mr, unsigned nr,
-               const real *S, unsigned ms, unsigned ns,
-               const real *T, unsigned mt, unsigned nt,
-               const real *u, real *v, real *work1, real *work2);
-
-/*--------------------------------------------------------------------------
-   1-,2-,3-d Tensor Application of Row Vectors (for Interpolation)
-   
-   the 3d case:
-   v = tensor_i3(Jr,nr, Js,ns, Jt,nt, u, work)
-   same effect as tensor_r3(Jr,1,nr, Js,1,ns, Jt,1,nt, u,&v, work1,work2):
-     gives v = [ Jr (x) Js (x) Jt ] u
-     where Jr, Js, Jt are row vectors (interpolation weights)
-     u is nr x ns x nt in column-major format (inner index is r)
-     v is a scalar
-  --------------------------------------------------------------------------*/
-
-real tensor_i1(const real *Jr, unsigned nr, const real *u);
-
-/* work holds ns reals */
-real tensor_i2(const real *Jr, unsigned nr,
-               const real *Js, unsigned ns,
-               const real *u, real *work);
-
-/* work holds ns*nt + nt reals */
-real tensor_i3(const real *Jr, unsigned nr,
-               const real *Js, unsigned ns,
-               const real *Jt, unsigned nt,
-               const real *u, real *work);
-
-/*--------------------------------------------------------------------------
-   1-,2-,3-d Tensor Application of Row Vectors
-             for simultaneous Interpolation and Gradient computation
-   
-   the 3d case:
-   v = tensor_ig3(Jr,Dr,nr, Js,Ds,ns, Jt,Dt,nt, u,g, work)
-     gives v   = [ Jr (x) Js (x) Jt ] u
-           g_0 = [ Dr (x) Js (x) Jt ] u
-           g_1 = [ Jr (x) Ds (x) Jt ] u
-           g_2 = [ Jr (x) Js (x) Dt ] u
-     where Jr,Dr,Js,Ds,Jt,Dt are row vectors
-       (interpolation & derivative weights)
-     u is nr x ns x nt in column-major format (inner index is r)
-     v is a scalar, g is an array of 3 reals
-  --------------------------------------------------------------------------*/
-
-real tensor_ig1(const real *Jr, const real *Dr, unsigned nr,
-                const real *u, real *g);
-
-/* work holds 2*ns reals */
-real tensor_ig2(const real *Jr, const real *Dr, unsigned nr,
-                const real *Js, const real *Ds, unsigned ns,
-                const real *u, real *g, real *work);
-
-/* work holds 2*ns*nt + 3*ns reals */
-real tensor_ig3(const real *Jr, const real *Dr, unsigned nr,
-                const real *Js, const real *Ds, unsigned ns,
-                const real *Jt, const real *Dt, unsigned nt,
-                const real *u, real *g, real *work);
-
-#endif
-

diff --git a/src/moab/point_locater/lotte/types.h b/src/moab/point_locater/lotte/types.h
deleted file mode 100644
index c17018e..0000000
--- a/src/moab/point_locater/lotte/types.h
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef TYPES_H
-#define TYPES_H
-#include "float.h"
-
-/* integer type to use for everything */
-#if   defined(USE_LONG)
-#  define INTEGER long
-#elif defined(USE_LONG_LONG)
-#  define INTEGER long long
-#elif defined(USE_SHORT)
-#  define INTEGER short
-#else
-#  define INTEGER int
-#endif
-
-/* when defined, use the given type for global indices instead of INTEGER */
-#if   defined(USE_GLOBAL_LONG_LONG)
-#  define GLOBAL_INT long long
-#elif defined(USE_GLOBAL_LONG)
-#  define GLOBAL_INT long
-#else
-#  define GLOBAL_INT long
-#endif
-
-/* floating point type to use for everything */
-#if   defined(USE_FLOAT)
-   typedef float real;
-#  define floorr floorf
-#  define ceilr  ceilf
-#  define sqrtr  sqrtf
-#  define fabsr  fabsf
-#  define cosr   cosf
-#  define sinr   sinf
-#  define EPS   (128*FLT_EPSILON)
-#  define PI 3.1415926535897932384626433832795028841971693993751058209749445923F
-#elif defined(USE_LONG_DOUBLE)
-   typedef long double real;
-#  define floorr floorl
-#  define ceilr  ceill
-#  define sqrtr  sqrtl
-#  define fabsr  fabsl
-#  define cosr   cosl
-#  define sinr   sinl
-#  define EPS   (128*LDBL_EPSILON)
-#  define PI 3.1415926535897932384626433832795028841971693993751058209749445923L
-#else
-   typedef double real;
-#  define floorr floor
-#  define ceilr  ceil
-#  define sqrtr  sqrt
-#  define fabsr  fabs
-#  define cosr   cos
-#  define sinr   sin
-#  define EPS   (128*DBL_EPSILON)
-#  define PI 3.1415926535897932384626433832795028841971693993751058209749445923
-#endif
-
-/* apparently uint and ulong can be defined already in standard headers */
-#define uint uint_
-#define ulong ulong_
-#define sint sint_
-#define slong slong_
-
-typedef   signed INTEGER sint;
-typedef unsigned INTEGER uint;
-#undef INTEGER
-
-#ifdef GLOBAL_INT
-  typedef   signed GLOBAL_INT slong;
-  typedef unsigned GLOBAL_INT ulong;
-#else
-  typedef sint slong;
-  typedef uint ulong;
-#endif
-
-#endif
-

diff --git a/test/scdtest2.cpp b/test/scdtest2.cpp
new file mode 100644
index 0000000..e744746
--- /dev/null
+++ b/test/scdtest2.cpp
@@ -0,0 +1,80 @@
+#include "moab/ScdInterface.hpp"
+#include "moab/Core.hpp"
+#include "TestUtil.hpp"
+
+#include <iostream>
+
+#ifdef USE_MPI
+#include "moab/ParallelComm.hpp"
+#endif
+
+using namespace moab;
+
+void test_john()
+{
+  Core moab;
+  ScdInterface *scd;
+  ErrorCode rval = moab.Interface::query_interface(scd);
+  CHECK_ERR(rval);
+  int gdims[] = {0, 0, 0, 48, 40, 0};
+  int ldims[6];
+
+  std::cout << "x dims are " << gdims[3] << "\n";
+  std::cout << "y dims are " << gdims[4] << "\n";
+  
+#ifdef USE_MPI
+  ParallelComm pcomm(&moab, MPI_COMM_WORLD);
+  int procs = pcomm.proc_config().proc_size(),
+      rank = pcomm.proc_config().proc_rank();
+  ScdParData pardata;
+  std::copy(gdims, gdims+6, pardata.gDims);
+  pardata.gPeriodic[0] = pardata.gPeriodic[1] = 0;
+  pardata.partMethod = ScdParData::SQIJ;
+  int pDims[2];
+  
+  rval = ScdInterface::compute_partition(procs, rank, pardata, ldims, NULL, pDims); CHECK_ERR(rval);
+  std::cout << "processors in x are " << pDims[0] << "\n";
+  std::cout << "processors in y are " << pDims[1] << "\n";
+#else
+  std::copy(gdims, gdims+6, ldims);
+#endif
+
+  std::cout << "local dims are " 
+            << ldims[0] << " " << ldims[1] << " " << ldims[2] << " " 
+            << ldims[3] << " " << ldims[4] << " " << ldims[5] << "\n";
+
+  ScdBox* box;
+
+#ifdef USE_MPI
+  rval = scd->construct_box(HomCoord(ldims, 3), HomCoord(ldims+3, 3), NULL, 0, box, NULL, &pardata); CHECK_ERR(rval);
+  rval = pcomm.resolve_shared_ents(0); CHECK_ERR(rval);
+#else
+  rval = scd->construct_box(HomCoord(ldims, 3), HomCoord(ldims+3, 3), NULL, 0, box); CHECK_ERR(rval);
+#endif
+
+  moab.list_entities(0,0);
+  std::vector<EntityHandle> conn;
+  Range quads, verts;
+  rval = moab.get_entities_by_type(0, MBQUAD, quads); CHECK_ERR(rval);
+  rval = moab.get_adjacencies(quads, 0, false, verts, Interface::UNION); CHECK_ERR(rval);
+  Tag gid_tag;
+  rval = moab.tag_get_handle("GLOBAL_ID", gid_tag); CHECK_ERR(rval);
+  int *qgids, *vgids, count;
+  rval = moab.tag_iterate(gid_tag, quads.begin(), quads.end(), count, (void*&)qgids); 
+  CHECK_ERR(rval); CHECK_EQUAL(count, (int)quads.size());
+  rval = moab.tag_iterate(gid_tag, verts.begin(), verts.end(), count, (void*&)vgids); 
+  CHECK_ERR(rval); CHECK_EQUAL(count, (int)verts.size());
+  for (Range::iterator rit = quads.begin(); rit != quads.end(); rit++) {
+    rval = moab.get_connectivity(&(*rit), 1, conn); CHECK_ERR(rval);
+    std::cout << "Connectivity array for quad " << qgids[*rit-*quads.begin()] << " is: ";
+    for (int i = 0; i < 4; i++) std::cout << vgids[conn[i]-*verts.begin()] << " ";
+    std::cout << std::endl;
+  }
+  
+}
+
+int main(int, char**) 
+{
+    // test partition methods
+  RUN_TEST(test_john);
+}

diff --git a/tools/mbcoupler/Coupler.cpp b/tools/mbcoupler/Coupler.cpp
index 7f9a3f6..223991c 100644
--- a/tools/mbcoupler/Coupler.cpp
+++ b/tools/mbcoupler/Coupler.cpp
@@ -10,11 +10,6 @@
 #include <stdio.h>
 #include <algorithm>
 
-//extern "C" 
-//{
-  //#include "minmax.h"
-  //}
-
 #include "assert.h"
 
 #define ERROR(a) {if (iBase_SUCCESS != err) std::cerr << a << std::endl;}

diff --git a/tools/mbcoupler/ElemUtil.cpp b/tools/mbcoupler/ElemUtil.cpp
index c0010d0..873cc44 100644
--- a/tools/mbcoupler/ElemUtil.cpp
+++ b/tools/mbcoupler/ElemUtil.cpp
@@ -3,7 +3,6 @@
 #include <assert.h>
 
 #include "ElemUtil.hpp"
-#include "types.h"
 
 namespace moab {
 namespace ElemUtil {

diff --git a/tools/mbcoupler/ElemUtil.hpp b/tools/mbcoupler/ElemUtil.hpp
index a3f9a1c..9b4bf9a 100644
--- a/tools/mbcoupler/ElemUtil.hpp
+++ b/tools/mbcoupler/ElemUtil.hpp
@@ -7,13 +7,9 @@
 
 // to access data structures for spectral elements
 
-extern "C"{
-#include "moab/point_locater/lotte/types.h"
-#include "moab/point_locater/lotte/poly.h"
-#include "moab/point_locater/lotte/tensor.h"
-//#include "findpt.h"
-#include "moab/point_locater/lotte/extrafindpt.h"
-#include "moab/point_locater/lotte/errmem.h"
+extern "C" 
+{
+#include "moab/FindPtFuncs.h"
 }
 
 namespace moab {

diff --git a/tools/mbcoupler/findpt_test.cpp b/tools/mbcoupler/findpt_test.cpp
index 1322df5..2f884a7 100644
--- a/tools/mbcoupler/findpt_test.cpp
+++ b/tools/mbcoupler/findpt_test.cpp
@@ -6,8 +6,7 @@ using namespace moab;
 using namespace ElemUtil;
 
 extern "C"{
-#include "errmem.h" //for tmalloc, convenient but not C++
-#include "types.h"
+#include "moab/FindPtFuncs.h"
 }
 
 

diff --git a/tools/mbcoupler/ssn_test.cpp b/tools/mbcoupler/ssn_test.cpp
index 426c91e..21adf72 100644
--- a/tools/mbcoupler/ssn_test.cpp
+++ b/tools/mbcoupler/ssn_test.cpp
@@ -13,14 +13,10 @@
 #include <sstream>
 #include <cstring>
 #include <cstdlib>
-
 extern "C" 
 {
-#include "types.h"
-#include "minmax.h"
-#include "errmem.h"
+#include "moab/FindPtFuncs.h"
 }
-
 #include "moab/TupleList.hpp"
 #include "moab/gs.hpp"
 #include "moab/Types.hpp"

diff --git a/tools/point_search.cpp b/tools/point_search.cpp
index 63b272e..97cfdf2 100644
--- a/tools/point_search.cpp
+++ b/tools/point_search.cpp
@@ -14,6 +14,11 @@
  */
 
 //Point Locater
+extern "C" 
+{
+#include "moab/FindPtFuncs.h"
+}
+
 #include "moab/point_locater/point_locater.hpp"
 #include "moab/point_locater/io.hpp"
 #include "moab/point_locater/tree/element_tree.hpp"

Repository URL: https://bitbucket.org/fathomteam/moab/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the moab-dev mailing list