[cig-commits] r19097 - in short/3D/PyLith/trunk/modulesrc: bc faults feassemble friction include materials meshio mpi problems topology utils

brad at geodynamics.org brad at geodynamics.org
Wed Oct 19 13:33:40 PDT 2011


Author: brad
Date: 2011-10-19 13:33:40 -0700 (Wed, 19 Oct 2011)
New Revision: 19097

Removed:
   short/3D/PyLith/trunk/modulesrc/include/doublearray.i
   short/3D/PyLith/trunk/modulesrc/include/pylithtypes.i
Modified:
   short/3D/PyLith/trunk/modulesrc/bc/bc.i
   short/3D/PyLith/trunk/modulesrc/faults/faults.i
   short/3D/PyLith/trunk/modulesrc/feassemble/QuadratureRefCell.i
   short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.i
   short/3D/PyLith/trunk/modulesrc/friction/friction.i
   short/3D/PyLith/trunk/modulesrc/include/Makefile.am
   short/3D/PyLith/trunk/modulesrc/materials/materials.i
   short/3D/PyLith/trunk/modulesrc/meshio/DataWriter.i
   short/3D/PyLith/trunk/modulesrc/meshio/meshio.i
   short/3D/PyLith/trunk/modulesrc/mpi/mpi.i
   short/3D/PyLith/trunk/modulesrc/problems/problems.i
   short/3D/PyLith/trunk/modulesrc/topology/topology.i
   short/3D/PyLith/trunk/modulesrc/utils/TestArray.i
   short/3D/PyLith/trunk/modulesrc/utils/utils.i
Log:
Added typemaps for PylithScalar to avoid contanimating SWIG generated files with build specific code (e.g., size of PyLithScalar).

Modified: short/3D/PyLith/trunk/modulesrc/bc/bc.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/bc/bc.i	2011-10-19 09:24:50 UTC (rev 19096)
+++ short/3D/PyLith/trunk/modulesrc/bc/bc.i	2011-10-19 20:33:40 UTC (rev 19097)
@@ -45,8 +45,7 @@
  } // exception
 
 %include "typemaps.i"
-%include "../include/doublearray.i"
-%include "../include/pylithtypes.i"
+%include "../include/scalartypemaps.i"
 
 // Numpy interface stuff
 %{

Modified: short/3D/PyLith/trunk/modulesrc/faults/faults.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/faults/faults.i	2011-10-19 09:24:50 UTC (rev 19096)
+++ short/3D/PyLith/trunk/modulesrc/faults/faults.i	2011-10-19 20:33:40 UTC (rev 19097)
@@ -52,10 +52,9 @@
  } // exception
 
 %include "typemaps.i"
-%include "../include/doublearray.i"
+%include "../include/scalartypemaps.i"
 %include "../include/chararray.i"
 %include "../include/eqkinsrcarray.i"
-%include "../include/pylithtypes.i"
 
 // Numpy interface stuff
 %{

Modified: short/3D/PyLith/trunk/modulesrc/feassemble/QuadratureRefCell.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/QuadratureRefCell.i	2011-10-19 09:24:50 UTC (rev 19096)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/QuadratureRefCell.i	2011-10-19 20:33:40 UTC (rev 19097)
@@ -76,49 +76,26 @@
        * @param numQuadPts Number of quadrature points
        * @param spaceDim Number of dimensions in coordinates of cell vertices
        */
-#if defined(PYLITH_USE_SCALAR_SINGLE)
-      %apply(float* IN_ARRAY2, int DIM1, int DIM2) {
+      %apply(PylithScalar* IN_ARRAY2, int DIM1, int DIM2) {
 	(const PylithScalar* basis,
 	 const int numQuadPts1,
 	 const int numBasis1)
 	  };
-      %apply(float* IN_ARRAY3, int DIM1, int DIM2, int DIM3) {
+      %apply(PylithScalar* IN_ARRAY3, int DIM1, int DIM2, int DIM3) {
 	(const PylithScalar* basisDerivRef,
 	 const int numQuadPts2,
 	 const int numBasis2,
 	 const int cellDim2)
 	  };
-      %apply(float* IN_ARRAY2, int DIM1, int DIM2) {
+      %apply(PylithScalar* IN_ARRAY2, int DIM1, int DIM2) {
 	(const PylithScalar* quadPtsRef,
 	 const int numQuadPts3,
 	 const int cellDim3)
 	  };
-      %apply(float* IN_ARRAY1, int DIM1) {
+      %apply(PylithScalar* IN_ARRAY1, int DIM1) {
 	(const PylithScalar* quadWts,
 	 const int numQuadPts4)
 	  };
-#else
-      %apply(double* IN_ARRAY2, int DIM1, int DIM2) {
-	(const PylithScalar* basis,
-	 const int numQuadPts1,
-	 const int numBasis1)
-	  };
-      %apply(double* IN_ARRAY3, int DIM1, int DIM2, int DIM3) {
-	(const PylithScalar* basisDerivRef,
-	 const int numQuadPts2,
-	 const int numBasis2,
-	 const int cellDim2)
-	  };
-      %apply(double* IN_ARRAY2, int DIM1, int DIM2) {
-	(const PylithScalar* quadPtsRef,
-	 const int numQuadPts3,
-	 const int cellDim3)
-	  };
-      %apply(double* IN_ARRAY1, int DIM1) {
-	(const PylithScalar* quadWts,
-	 const int numQuadPts4)
-	  };
-#endif
       void initialize(const PylithScalar* basis,
 		      const int numQuadPts1,
 		      const int numBasis1,

Modified: short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.i	2011-10-19 09:24:50 UTC (rev 19096)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.i	2011-10-19 20:33:40 UTC (rev 19097)
@@ -63,8 +63,7 @@
  } // exception
 
 %include "typemaps.i"
-%include "../include/doublearray.i"
-%include "../include/pylithtypes.i"
+%include "../include/scalartypemaps.i"
 
 // Numpy interface stuff
 %{

Modified: short/3D/PyLith/trunk/modulesrc/friction/friction.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/friction/friction.i	2011-10-19 09:24:50 UTC (rev 19096)
+++ short/3D/PyLith/trunk/modulesrc/friction/friction.i	2011-10-19 20:33:40 UTC (rev 19097)
@@ -49,8 +49,7 @@
  } // exception
 
 %include "typemaps.i"
-%include "../include/doublearray.i"
-%include "../include/pylithtypes.i"
+%include "../include/scalartypemaps.i"
 
 // Numpy interface stuff
 %{

Modified: short/3D/PyLith/trunk/modulesrc/include/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/modulesrc/include/Makefile.am	2011-10-19 09:24:50 UTC (rev 19096)
+++ short/3D/PyLith/trunk/modulesrc/include/Makefile.am	2011-10-19 20:33:40 UTC (rev 19097)
@@ -22,8 +22,7 @@
 dist_subpkgdata_DATA = \
 	numpy.i \
 	chararray.i \
-	doublearray.i \
-	pylithtypes.i \
+	scalartypemaps.i \
 	eqkinsrcarray.i \
 	integratorarray.i \
 	submeshfield.i

Deleted: short/3D/PyLith/trunk/modulesrc/include/doublearray.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/include/doublearray.i	2011-10-19 09:24:50 UTC (rev 19096)
+++ short/3D/PyLith/trunk/modulesrc/include/doublearray.i	2011-10-19 20:33:40 UTC (rev 19097)
@@ -1,91 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard, U.S. Geological Survey
-// Charles A. Williams, GNS Science
-// Matthew G. Knepley, University of Chicago
-//
-// This code was developed as part of the Computational Infrastructure
-// for Geodynamics (http://geodynamics.org).
-//
-// Copyright (c) 2010-2011 University of California, Davis
-//
-// See COPYING for license information.
-//
-// ======================================================================
-//
-
-%{
-static
-int
-convert_doublearray(PyObject* input,
-		    double* const values,
-		    const int size) {
-  if (!PySequence_Check(input)) {
-    PyErr_SetString(PyExc_TypeError, "Expecting a sequence of floats.");
-    return 0;
-  } // if
-  if (PyObject_Length(input) != size) {
-    PyErr_SetString(PyExc_ValueError, "Sequence size mismatch.");
-    return 0;
-  } // if
-  for (int i=0; i < size; i++) {
-    PyObject *o = PySequence_GetItem(input,i);
-    if (!PyFloat_Check(o)) {
-      Py_XDECREF(o);
-      PyErr_SetString(PyExc_ValueError,"Expecting a sequence of floats.");
-      return 0;
-    } // if
-    values[i] = PyFloat_AsDouble(o);
-    Py_DECREF(o);
-  } // for
-  return 1;
-} // convert_doublearray
-%}
-
-// Map a Python sequence of floats into a C double array.
-%typemap(in) double [ANY] (double values[$1_dim0]) {
-  if (!convert_doublearray($input, values, $1_dim0))
-    return NULL;
-  $1 = &values[0];
- } // typemap
-
-
-%{
-static
-int
-convert_floatarray(PyObject* input,
-		    float* const values,
-		    const int size) {
-  if (!PySequence_Check(input)) {
-    PyErr_SetString(PyExc_TypeError, "Expecting a sequence of floats.");
-    return 0;
-  } // if
-  if (PyObject_Length(input) != size) {
-    PyErr_SetString(PyExc_ValueError, "Sequence size mismatch.");
-    return 0;
-  } // if
-  for (int i=0; i < size; i++) {
-    PyObject *o = PySequence_GetItem(input,i);
-    if (!PyFloat_Check(o)) {
-      Py_XDECREF(o);
-      PyErr_SetString(PyExc_ValueError,"Expecting a sequence of floats.");
-      return 0;
-    } // if
-    values[i] = PyFloat_AsDouble(o);
-    Py_DECREF(o);
-  } // for
-  return 1;
-} // convert_floatarray
-%}
-
-// Map a Python sequence of floats into a C float array.
-%typemap(in) float [ANY] (float values[$1_dim0]) {
-  if (!convert_floatarray($input, values, $1_dim0))
-    return NULL;
-  $1 = &values[0];
- } // typemap
-
-
-// End of file

Deleted: short/3D/PyLith/trunk/modulesrc/include/pylithtypes.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/include/pylithtypes.i	2011-10-19 09:24:50 UTC (rev 19096)
+++ short/3D/PyLith/trunk/modulesrc/include/pylithtypes.i	2011-10-19 20:33:40 UTC (rev 19097)
@@ -1,30 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard, U.S. Geological Survey
-// Charles A. Williams, GNS Science
-// Matthew G. Knepley, University of Chicago
-//
-// This code was developed as part of the Computational Infrastructure
-// for Geodynamics (http://geodynamics.org).
-//
-// Copyright (c) 2010-2011 University of California, Davis
-//
-// See COPYING for license information.
-//
-// ======================================================================
-//
-
-%include "petscconf.h"
-
-#if defined(PETSC_USE_REAL_SINGLE)
-#define PYLITH_USE_SCALAR_SINGLE
-typedef float PylithScalar;
-#else
-#define PYLITH_USE_SCALAR_DOUBLE
-typedef double PylithScalar;
-#endif
-
-
-// End of file

Modified: short/3D/PyLith/trunk/modulesrc/materials/materials.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/materials/materials.i	2011-10-19 09:24:50 UTC (rev 19096)
+++ short/3D/PyLith/trunk/modulesrc/materials/materials.i	2011-10-19 20:33:40 UTC (rev 19097)
@@ -56,8 +56,7 @@
  } // exception
 
 %include "typemaps.i"
-%include "../include/doublearray.i"
-%include "../include/pylithtypes.i"
+%include "../include/scalartypemaps.i"
 
 // Numpy interface stuff
 %{

Modified: short/3D/PyLith/trunk/modulesrc/meshio/DataWriter.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/DataWriter.i	2011-10-19 09:24:50 UTC (rev 19096)
+++ short/3D/PyLith/trunk/modulesrc/meshio/DataWriter.i	2011-10-19 20:33:40 UTC (rev 19097)
@@ -54,7 +54,7 @@
        *
        * @param value Time scale
        */
-      void timeScale(const double value);
+      void timeScale(const PylithScalar value);
 
       /** Prepare for writing files.
        *

Modified: short/3D/PyLith/trunk/modulesrc/meshio/meshio.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/meshio.i	2011-10-19 09:24:50 UTC (rev 19096)
+++ short/3D/PyLith/trunk/modulesrc/meshio/meshio.i	2011-10-19 20:33:40 UTC (rev 19097)
@@ -58,7 +58,7 @@
  } // exception
 
 %include "typemaps.i"
-%include "../include/pylithtypes.i"
+%include "../include/scalartypemaps.i"
 
 // Interfaces
 %include "MeshIOObj.i"

Modified: short/3D/PyLith/trunk/modulesrc/mpi/mpi.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/mpi/mpi.i	2011-10-19 09:24:50 UTC (rev 19096)
+++ short/3D/PyLith/trunk/modulesrc/mpi/mpi.i	2011-10-19 20:33:40 UTC (rev 19097)
@@ -25,7 +25,6 @@
 %}
 
 %include "typemaps.i"
-%include "../include/pylithtypes.i"
 
 // Interfaces
 %include "mpi_comm.i"

Modified: short/3D/PyLith/trunk/modulesrc/problems/problems.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/problems/problems.i	2011-10-19 09:24:50 UTC (rev 19096)
+++ short/3D/PyLith/trunk/modulesrc/problems/problems.i	2011-10-19 20:33:40 UTC (rev 19097)
@@ -50,7 +50,7 @@
 
 %include "typemaps.i"
 %include "../include/integratorarray.i"
-%include "../include/pylithtypes.i"
+%include "../include/scalartypemaps.i"
 
 // Interfaces
 %include "Formulation.i"

Modified: short/3D/PyLith/trunk/modulesrc/topology/topology.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/topology.i	2011-10-19 09:24:50 UTC (rev 19096)
+++ short/3D/PyLith/trunk/modulesrc/topology/topology.i	2011-10-19 20:33:40 UTC (rev 19097)
@@ -49,7 +49,7 @@
 %include "typemaps.i"
 %include "../include/chararray.i"
 %include "../include/submeshfield.i"
-%include "../include/pylithtypes.i"
+%include "../include/scalartypemaps.i"
 
 // Numpy interface stuff
 %{

Modified: short/3D/PyLith/trunk/modulesrc/utils/TestArray.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/utils/TestArray.i	2011-10-19 09:24:50 UTC (rev 19096)
+++ short/3D/PyLith/trunk/modulesrc/utils/TestArray.i	2011-10-19 20:33:40 UTC (rev 19097)
@@ -22,17 +22,10 @@
  * @brief Python interface to C++ TestArray object.
  */
 
-#if defined(PYLITH_USE_SCALAR_SINGLE)
-%apply(float* IN_ARRAY1, int DIM1) {
+%apply(PylithScalar* IN_ARRAY1, int DIM1) {
   (const PylithScalar* valuesE,
    const int nvalues)
     };
-#else
-%apply(double* IN_ARRAY1, int DIM1) {
-  (const PylithScalar* valuesE,
-   const int nvalues)
-    };
-#endif
 %inline %{
   /** Check to make sure array of values match expected values.
    *

Modified: short/3D/PyLith/trunk/modulesrc/utils/utils.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/utils/utils.i	2011-10-19 09:24:50 UTC (rev 19096)
+++ short/3D/PyLith/trunk/modulesrc/utils/utils.i	2011-10-19 20:33:40 UTC (rev 19097)
@@ -41,7 +41,7 @@
  } // exception
 
 %include "typemaps.i"
-%include "../include/pylithtypes.i"
+%include "../include/scalartypemaps.i"
 
 // Numpy interface stuff
 %{



More information about the CIG-COMMITS mailing list