[cig-commits] r13420 - in cs/spatialdata-0.1/trunk: libsrc libsrc/units modulesrc/units spatialdata spatialdata/units tests/libtests/units tests/pytests/units
brad at geodynamics.org
brad at geodynamics.org
Fri Nov 28 13:22:34 PST 2008
Author: brad
Date: 2008-11-28 13:22:34 -0800 (Fri, 28 Nov 2008)
New Revision: 13420
Added:
cs/spatialdata-0.1/trunk/libsrc/units/Nondimensional.cc
cs/spatialdata-0.1/trunk/libsrc/units/Nondimensional.hh
cs/spatialdata-0.1/trunk/libsrc/units/Nondimensional.icc
cs/spatialdata-0.1/trunk/spatialdata/units/Nondimensional.py
cs/spatialdata-0.1/trunk/tests/libtests/units/TestNondimensional.cc
cs/spatialdata-0.1/trunk/tests/libtests/units/TestNondimensional.hh
cs/spatialdata-0.1/trunk/tests/pytests/units/TestNondimensional.py
Removed:
cs/spatialdata-0.1/trunk/libsrc/units/NondimElastic.cc
cs/spatialdata-0.1/trunk/libsrc/units/NondimElastic.hh
cs/spatialdata-0.1/trunk/libsrc/units/NondimElastic.icc
cs/spatialdata-0.1/trunk/spatialdata/units/NondimElastic.py
cs/spatialdata-0.1/trunk/tests/libtests/units/TestNondimElastic.cc
cs/spatialdata-0.1/trunk/tests/libtests/units/TestNondimElastic.hh
cs/spatialdata-0.1/trunk/tests/pytests/units/TestNondimElastic.py
Modified:
cs/spatialdata-0.1/trunk/libsrc/Makefile.am
cs/spatialdata-0.1/trunk/libsrc/units/Makefile.am
cs/spatialdata-0.1/trunk/modulesrc/units/units.pyxe.src
cs/spatialdata-0.1/trunk/spatialdata/Makefile.am
cs/spatialdata-0.1/trunk/spatialdata/__init__.py
cs/spatialdata-0.1/trunk/spatialdata/units/NondimElasticDynamic.py
cs/spatialdata-0.1/trunk/spatialdata/units/NondimElasticQuasistatic.py
cs/spatialdata-0.1/trunk/spatialdata/units/__init__.py
cs/spatialdata-0.1/trunk/tests/libtests/units/Makefile.am
cs/spatialdata-0.1/trunk/tests/pytests/units/Makefile.am
cs/spatialdata-0.1/trunk/tests/pytests/units/testunits.py
Log:
Cleaned up Nondimensional interface.
Modified: cs/spatialdata-0.1/trunk/libsrc/Makefile.am
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/Makefile.am 2008-11-27 22:11:02 UTC (rev 13419)
+++ cs/spatialdata-0.1/trunk/libsrc/Makefile.am 2008-11-28 21:22:34 UTC (rev 13420)
@@ -39,7 +39,7 @@
spatialdb/SimpleIOAscii.cc \
spatialdb/UniformDB.cc \
spatialdb/cspatialdb.cc \
- units/NondimElastic.cc \
+ units/Nondimensional.cc \
utils/LineParser.cc \
utils/PointsStream.cc
Modified: cs/spatialdata-0.1/trunk/libsrc/units/Makefile.am
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/units/Makefile.am 2008-11-27 22:11:02 UTC (rev 13419)
+++ cs/spatialdata-0.1/trunk/libsrc/units/Makefile.am 2008-11-28 21:22:34 UTC (rev 13420)
@@ -14,8 +14,8 @@
include $(top_srcdir)/subpackage.am
subpkginclude_HEADERS = \
- NondimElastic.hh \
- NondimElastic.icc
+ Nondimensional.hh \
+ Nondimensional.icc
noinst_HEADERS =
Deleted: cs/spatialdata-0.1/trunk/libsrc/units/NondimElastic.cc
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/units/NondimElastic.cc 2008-11-27 22:11:02 UTC (rev 13419)
+++ cs/spatialdata-0.1/trunk/libsrc/units/NondimElastic.cc 2008-11-28 21:22:34 UTC (rev 13420)
@@ -1,219 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#include <portinfo>
-
-#include "NondimElastic.hh" // implementation of class methods
-
-#include <sstream> // USES std::ostringstream
-#include <stdexcept> // USES std::runtime_error
-#include <assert.h> // USES assert()
-
-// ----------------------------------------------------------------------
-// Default constructor
-spatialdata::units::NondimElastic::NondimElastic(void) :
- _length(1.0),
- _pressure(1.0),
- _time(1.0),
- _density(1.0)
-{ // constructor
-} // constructor
-
-// ----------------------------------------------------------------------
-// Default destructor
-spatialdata::units::NondimElastic::~NondimElastic(void)
-{ // destructor
-} // destructor
-
-// ----------------------------------------------------------------------
-// Copy constructor.
-spatialdata::units::NondimElastic::NondimElastic(const NondimElastic& dim) :
- _length(dim._length),
- _pressure(dim._pressure),
- _time(dim._time),
- _density(dim._density)
-{ // copy constructor
-} // copy constructor
-
-// ----------------------------------------------------------------------
-// Assignment operator.
-const spatialdata::units::NondimElastic&
-spatialdata::units::NondimElastic::operator=(const NondimElastic& dim)
-{ // operator=
- if (this != &dim) {
- _length = dim._length;
- _pressure = dim._pressure;
- _time = dim._time;
- _density = dim._density;
- } // if
-
- return *this;
-} // operator=
-
-// ----------------------------------------------------------------------
-// Set value to nondimensionalize length scale in meters (SI units).
-void
-spatialdata::units::NondimElastic::lengthScale(const double value)
-{ // lengthScale
- if (value <= 0.0) {
- std::ostringstream msg;
- msg << "Length scale (" << value << ") must be positive.";
- throw std::runtime_error(msg.str());
- } // if
- _length = value;
-} // lengthScale
-
-// ----------------------------------------------------------------------
-// Set value to nondimensionalize pressure scale in Pascals (SI units).
-void
-spatialdata::units::NondimElastic::pressureScale(const double value)
-{ // pressureScale
- if (value <= 0.0) {
- std::ostringstream msg;
- msg << "Pressure scale (" << value << ") must be positive.";
- throw std::runtime_error(msg.str());
- } // if
- _pressure = value;
-} // pressureScale
-
-// ----------------------------------------------------------------------
-// Set value to nondimensionalize time scale in seconds (SI units).
-void
-spatialdata::units::NondimElastic::timeScale(const double value)
-{ // timeScale
- if (value <= 0.0) {
- std::ostringstream msg;
- msg << "Time scale (" << value << ") must be positive.";
- throw std::runtime_error(msg.str());
- } // if
- _time = value;
-} // timeScale
-
-// ----------------------------------------------------------------------
-// Set value to nondimensionalize density scale in kg/m^3 (SI units).
-void
-spatialdata::units::NondimElastic::densityScale(const double value)
-{ // densityScale
- if (value <= 0.0) {
- std::ostringstream msg;
- msg << "Density scale (" << value << ") must be positive.";
- throw std::runtime_error(msg.str());
- } // if
- _density = value;
-} // densityScale
-
-// ----------------------------------------------------------------------
-// Make length scales dimensionless.
-void
-spatialdata::units::NondimElastic::utonLength(double* const values,
- const int nvalues) const
-{ // utonLength
- assert( (0 < nvalues && 0 != values) ||
- (0 == nvalues && 0 == values) );
-
- for (int i=0; i < nvalues; ++i)
- values[i] /= _length;
-} // utonLength
-
-// ----------------------------------------------------------------------
-// Add dimensions to length scale.
-void
-spatialdata::units::NondimElastic::ntouLength(double* const values,
- const int nvalues) const
-{ // ntouLength
- assert( (0 < nvalues && 0 != values) ||
- (0 == nvalues && 0 == values) );
-
- for (int i=0; i < nvalues; ++i)
- values[i] *= _length;
-} // ntouLength
-
-// ----------------------------------------------------------------------
-// Make pressure scales dimensionless.
-void
-spatialdata::units::NondimElastic::utonPressure(double* const values,
- const int nvalues) const
-{ // utonPressure
- assert( (0 < nvalues && 0 != values) ||
- (0 == nvalues && 0 == values) );
-
- for (int i=0; i < nvalues; ++i)
- values[i] /= _pressure;
-} // utonPressure
-
-// ----------------------------------------------------------------------
-// Add dimensions to pressure scale.
-void
-spatialdata::units::NondimElastic::ntouPressure(double* const values,
- const int nvalues) const
-{ // ntouPressure
- assert( (0 < nvalues && 0 != values) ||
- (0 == nvalues && 0 == values) );
-
- for (int i=0; i < nvalues; ++i)
- values[i] *= _pressure;
-} // ntouPressure
-
-// ----------------------------------------------------------------------
-// Make time scales dimensionless.
-void
-spatialdata::units::NondimElastic::utonTime(double* const values,
- const int nvalues) const
-{ // utonTime
- assert( (0 < nvalues && 0 != values) ||
- (0 == nvalues && 0 == values) );
-
- for (int i=0; i < nvalues; ++i)
- values[i] /= _time;
-} // utonTime
-
-// ----------------------------------------------------------------------
-// Add dimensions to time scale.
-void
-spatialdata::units::NondimElastic::ntouTime(double* const values,
- const int nvalues) const
-{ // ntouTime
- assert( (0 < nvalues && 0 != values) ||
- (0 == nvalues && 0 == values) );
-
- for (int i=0; i < nvalues; ++i)
- values[i] *= _time;
-} // ntouTime
-
-// ----------------------------------------------------------------------
-// Make density scales dimensionless.
-void
-spatialdata::units::NondimElastic::utonDensity(double* const values,
- const int nvalues) const
-{ // utonDensity
- assert( (0 < nvalues && 0 != values) ||
- (0 == nvalues && 0 == values) );
-
- for (int i=0; i < nvalues; ++i)
- values[i] /= _density;
-} // utonDensity
-
-// ----------------------------------------------------------------------
-// Add dimensions to density scale.
-void
-spatialdata::units::NondimElastic::ntouDensity(double* const values,
- const int nvalues) const
-{ // ntouDensity
- assert( (0 < nvalues && 0 != values) ||
- (0 == nvalues && 0 == values) );
-
- for (int i=0; i < nvalues; ++i)
- values[i] *= _density;
-} // ntouDensity
-
-
-// End of file
Deleted: cs/spatialdata-0.1/trunk/libsrc/units/NondimElastic.hh
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/units/NondimElastic.hh 2008-11-27 22:11:02 UTC (rev 13419)
+++ cs/spatialdata-0.1/trunk/libsrc/units/NondimElastic.hh 2008-11-28 21:22:34 UTC (rev 13420)
@@ -1,217 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-/** @file libsrc/units/NondimElastic.hh
- *
- * @brief C++ Nondimensionalization for elasticity.
- *
- * C++ object for managing scales associated with elasticity.
- */
-
-#if !defined(spatialdata_units_nondimelastic_hh)
-#define spatialdata_units_nondimelastic_hh
-
-namespace spatialdata {
- namespace units {
- class NondimElastic;
-
- class TestNondimElastic; // Unit testing
- } // units
-} // spatialdata
-
-/// C++ object for managing parameters defining a coordinate system
-class spatialdata::units::NondimElastic
-{ // class NondimElastic
- friend class TestNondimElastic; // Unit testing
-
-public :
- // PUBLIC METHODS /////////////////////////////////////////////////////
-
- /// Default constructor
- NondimElastic(void);
-
- /// Default destructor
- ~NondimElastic(void);
-
- /** Copy constructor.
- *
- * @param dim Object to copy.
- */
- NondimElastic(const NondimElastic& dim);
-
- /** Assignment operator.
- *
- * @param dim Object to copy.
- * @returns Copy of this.
- */
- const NondimElastic& operator=(const NondimElastic& dim);
-
- /** Set value to nondimensionalize length scale in meters (SI units).
- *
- * @param value Length scale in meters (SI units).
- */
- void lengthScale(const double value);
-
- /** Set value to nondimensionalize pressure scale in Pascals (SI units).
- *
- * @param value Pressure scale in Pascals (SI units).
- */
- void pressureScale(const double value);
-
- /** Set value to nondimensionalize time scale in seconds (SI units).
- *
- * @param value Time scale in seconds (SI units).
- */
- void timeScale(const double value);
-
- /** Set value to nondimensionalize density scale in kg/m^3 (SI units).
- *
- * @param value Density scale in kg/m^3 (SI units).
- */
- void densityScale(const double value);
-
- /** Make length scale dimensionless.
- *
- * @param value Length in meters (SI units).
- * @returns Dimensionless length.
- */
- double utonLength(const double value) const;
-
- /** Make length scales dimensionless.
- *
- * @param values Array of lengths in meters (SI units).
- * @param int Number of values.
- */
- void utonLength(double* const values,
- const int nvalues) const;
-
- /** Add dimensions to length scale.
- *
- * @param value Dimensionless length.
- * @returns Length in meters (SI units).
- */
- double ntouLength(const double value) const;
-
- /** Add dimensions to length scale.
- *
- * @param values Array of dimensionless lengths.
- * @param int Number of values.
- */
- void ntouLength(double* const values,
- const int nvalues) const;
-
- /** Make pressure scale dimensionless.
- *
- * @param value Pressure in Pascals (SI units).
- * @returns Dimensionless pressure.
- */
- double utonPressure(const double value) const;
-
- /** Make pressure scales dimensionless.
- *
- * @param values Array of pressures in Pascals (SI units).
- * @param int Number of values.
- */
- void utonPressure(double* const values,
- const int nvalues) const;
-
- /** Add dimensions to pressure scale.
- *
- * @param value Dimensionless pressure.
- * @returns Pressure in meters (SI units).
- */
- double ntouPressure(const double value) const;
-
- /** Add dimensions to pressure scale.
- *
- * @param values Array of dimensionless pressures.
- * @param int Number of values.
- */
- void ntouPressure(double* const values,
- const int nvalues) const;
-
- /** Make time scale dimensionless.
- *
- * @param value Time in seconds (SI units).
- * @returns Dimensionless time.
- */
- double utonTime(const double value) const;
-
- /** Make time scales dimensionless.
- *
- * @param values Array of times in seconds (SI units).
- * @param int Number of values.
- */
- void utonTime(double* const values,
- const int nvalues) const;
-
- /** Add dimensions to time scale.
- *
- * @param value Dimensionless time.
- * @returns Time in meters (SI units).
- */
- double ntouTime(const double value) const;
-
- /** Add dimensions to time scale.
- *
- * @param values Array of dimensionless times.
- * @param int Number of values.
- */
- void ntouTime(double* const values,
- const int nvalues) const;
-
- /** Make density scale dimensionless.
- *
- * @param value Density in kg/m^3 (SI units).
- * @returns Dimensionless density.
- */
- double utonDensity(const double value) const;
-
- /** Make density scales dimensionless.
- *
- * @param values Array of densities in kg/m^3 (SI units).
- * @param int Number of values.
- */
- void utonDensity(double* const values,
- const int nvalues) const;
-
- /** Add dimensions to density scale.
- *
- * @param value Dimensionless density.
- * @returns Density in meters (SI units).
- */
- double ntouDensity(const double value) const;
-
- /** Add dimensions to density scale.
- *
- * @param values Array of dimensionless densities.
- * @param int Number of values.
- */
- void ntouDensity(double* const values,
- const int nvalues) const;
-
-private :
- // PRIVATE MEMBERS ////////////////////////////////////////////////////
-
- double _length; ///< Length scale
- double _pressure; ///< Pressure scale
- double _time; ///< Time scale
- double _density; ///< Density scale
-
-}; // class NondimElastic
-
-#include "NondimElastic.icc" // inline methods
-
-#endif // spatialdata_units_nondimelastic_hh
-
-
-// End of file
Deleted: cs/spatialdata-0.1/trunk/libsrc/units/NondimElastic.icc
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/units/NondimElastic.icc 2008-11-27 22:11:02 UTC (rev 13419)
+++ cs/spatialdata-0.1/trunk/libsrc/units/NondimElastic.icc 2008-11-28 21:22:34 UTC (rev 13420)
@@ -1,74 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#if !defined(spatialdata_units_nondimelastic_hh)
-#error "NondimElastic.icc must only be included from NondimElastic.hh"
-#endif
-
-// Make length scale dimensionless.
-inline
-double
-spatialdata::units::NondimElastic::utonLength(const double value) const {
- return value / _length;
-} // utonLength
-
-// Add dimensions to length scale.
-inline
-double
-spatialdata::units::NondimElastic::ntouLength(const double value) const {
- return value * _length;
-} // ntouLength
-
-// Make pressure scale dimensionless.
-inline
-double
-spatialdata::units::NondimElastic::utonPressure(const double value) const {
- return value / _pressure;
-} // utonPressure
-
-// Add dimensions to pressure scale.
-inline
-double
-spatialdata::units::NondimElastic::ntouPressure(const double value) const {
- return value * _pressure;
-} // ntouPressure
-
-// Make time scale dimensionless.
-inline
-double
-spatialdata::units::NondimElastic::utonTime(const double value) const {
- return value / _time;
-} // utonTime
-
-// Add dimensions to time scale.
-inline
-double
-spatialdata::units::NondimElastic::ntouTime(const double value) const {
- return value * _time;
-} // ntouTime
-
-// Make density scale dimensionless.
-inline
-double
-spatialdata::units::NondimElastic::utonDensity(const double value) const {
- return value / _density;
-} // utonDensity
-
-// Add dimensions to density scale.
-inline
-double
-spatialdata::units::NondimElastic::ntouDensity(const double value) const {
- return value * _density;
-} // ntouDensity
-
-
-// End of file
Copied: cs/spatialdata-0.1/trunk/libsrc/units/Nondimensional.cc (from rev 13418, cs/spatialdata-0.1/trunk/libsrc/units/NondimElastic.cc)
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/units/Nondimensional.cc (rev 0)
+++ cs/spatialdata-0.1/trunk/libsrc/units/Nondimensional.cc 2008-11-28 21:22:34 UTC (rev 13420)
@@ -0,0 +1,144 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include <portinfo>
+
+#include "Nondimensional.hh" // implementation of class methods
+
+#include <sstream> // USES std::ostringstream
+#include <stdexcept> // USES std::runtime_error
+#include <assert.h> // USES assert()
+
+// ----------------------------------------------------------------------
+// Default constructor
+spatialdata::units::Nondimensional::Nondimensional(void) :
+ _length(1.0),
+ _pressure(1.0),
+ _time(1.0),
+ _density(1.0)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Default destructor
+spatialdata::units::Nondimensional::~Nondimensional(void)
+{ // destructor
+} // destructor
+
+// ----------------------------------------------------------------------
+// Copy constructor.
+spatialdata::units::Nondimensional::Nondimensional(const Nondimensional& dim) :
+ _length(dim._length),
+ _pressure(dim._pressure),
+ _time(dim._time),
+ _density(dim._density)
+{ // copy constructor
+} // copy constructor
+
+// ----------------------------------------------------------------------
+// Assignment operator.
+const spatialdata::units::Nondimensional&
+spatialdata::units::Nondimensional::operator=(const Nondimensional& dim)
+{ // operator=
+ if (this != &dim) {
+ _length = dim._length;
+ _pressure = dim._pressure;
+ _time = dim._time;
+ _density = dim._density;
+ } // if
+
+ return *this;
+} // operator=
+
+// ----------------------------------------------------------------------
+// Set value to nondimensionalize length scale in meters (SI units).
+void
+spatialdata::units::Nondimensional::lengthScale(const double value)
+{ // lengthScale
+ if (value <= 0.0) {
+ std::ostringstream msg;
+ msg << "Length scale (" << value << ") must be positive.";
+ throw std::runtime_error(msg.str());
+ } // if
+ _length = value;
+} // lengthScale
+
+// ----------------------------------------------------------------------
+// Set value to nondimensionalize pressure scale in Pascals (SI units).
+void
+spatialdata::units::Nondimensional::pressureScale(const double value)
+{ // pressureScale
+ if (value <= 0.0) {
+ std::ostringstream msg;
+ msg << "Pressure scale (" << value << ") must be positive.";
+ throw std::runtime_error(msg.str());
+ } // if
+ _pressure = value;
+} // pressureScale
+
+// ----------------------------------------------------------------------
+// Set value to nondimensionalize time scale in seconds (SI units).
+void
+spatialdata::units::Nondimensional::timeScale(const double value)
+{ // timeScale
+ if (value <= 0.0) {
+ std::ostringstream msg;
+ msg << "Time scale (" << value << ") must be positive.";
+ throw std::runtime_error(msg.str());
+ } // if
+ _time = value;
+} // timeScale
+
+// ----------------------------------------------------------------------
+// Set value to nondimensionalize density scale in kg/m^3 (SI units).
+void
+spatialdata::units::Nondimensional::densityScale(const double value)
+{ // densityScale
+ if (value <= 0.0) {
+ std::ostringstream msg;
+ msg << "Density scale (" << value << ") must be positive.";
+ throw std::runtime_error(msg.str());
+ } // if
+ _density = value;
+} // densityScale
+
+// ----------------------------------------------------------------------
+// Make values dimensionless.
+void
+spatialdata::units::Nondimensional::nondimensionalize(double* const values,
+ const int nvalues,
+ const double scale) const
+{ // nondimensionalize
+ assert( (0 < nvalues && 0 != values) ||
+ (0 == nvalues && 0 == values) );
+
+ for (int i=0; i < nvalues; ++i)
+ values[i] /= scale;
+} // nondimensionalize
+
+// ----------------------------------------------------------------------
+// Make value dimensionless.
+void
+spatialdata::units::Nondimensional::dimensionalize(double* const values,
+ const int nvalues,
+ const double scale) const
+{ // dimensionalize
+ assert( (0 < nvalues && 0 != values) ||
+ (0 == nvalues && 0 == values) );
+
+ for (int i=0; i < nvalues; ++i)
+ values[i] *= scale;
+} // dimensionalize
+
+
+
+// End of file
Copied: cs/spatialdata-0.1/trunk/libsrc/units/Nondimensional.hh (from rev 13418, cs/spatialdata-0.1/trunk/libsrc/units/NondimElastic.hh)
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/units/Nondimensional.hh (rev 0)
+++ cs/spatialdata-0.1/trunk/libsrc/units/Nondimensional.hh 2008-11-28 21:22:34 UTC (rev 13420)
@@ -0,0 +1,159 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file libsrc/units/Nondimensional.hh
+ *
+ * @brief C++ Manager for nondimensionalization of problems.
+ *
+ * C++ object for managing nondimensionalization of problems.
+ */
+
+#if !defined(spatialdata_units_nondimensional_hh)
+#define spatialdata_units_nondimensional_hh
+
+namespace spatialdata {
+ namespace units {
+ class Nondimensional;
+
+ class TestNondimensional; // Unit testing
+ } // units
+} // spatialdata
+
+/// C++ object for managing parameters defining a coordinate system
+class spatialdata::units::Nondimensional
+{ // class Nondimensional
+ friend class TestNondimensional; // Unit testing
+
+public :
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+
+ /// Default constructor
+ Nondimensional(void);
+
+ /// Default destructor
+ ~Nondimensional(void);
+
+ /** Copy constructor.
+ *
+ * @param dim Object to copy.
+ */
+ Nondimensional(const Nondimensional& dim);
+
+ /** Assignment operator.
+ *
+ * @param dim Object to copy.
+ * @returns Copy of this.
+ */
+ const Nondimensional& operator=(const Nondimensional& dim);
+
+ /** Set value to nondimensionalize length scale in meters (SI units).
+ *
+ * @param value Length scale in meters (SI units).
+ */
+ void lengthScale(const double value);
+
+ /** Get value to nondimensionalize length scale in meters (SI units).
+ *
+ * @returns Length scale in meters (SI units).
+ */
+ double lengthScale(void) const;
+
+ /** Set value to nondimensionalize pressure scale in Pascals (SI units).
+ *
+ * @param value Pressure scale in Pascals (SI units).
+ */
+ void pressureScale(const double value);
+
+ /** Get value to nondimensionalize pressure scale in Pascals (SI units).
+ *
+ * @returns Pressure scale in Pascals (SI units).
+ */
+ double pressureScale(void) const;
+
+ /** Set value to nondimensionalize time scale in seconds (SI units).
+ *
+ * @param value Time scale in seconds (SI units).
+ */
+ void timeScale(const double value);
+
+ /** Get value to nondimensionalize time scale in seconds (SI units).
+ *
+ * @returns Time scale in seconds (SI units).
+ */
+ double timeScale(void) const;
+
+ /** Set value to nondimensionalize density scale in kg/m^3 (SI units).
+ *
+ * @param value Density scale in kg/m^3 (SI units).
+ */
+ void densityScale(const double value);
+
+ /** Get value to nondimensionalize density scale in kg/m^3 (SI units).
+ *
+ * @returns Density scale in kg/m^3 (SI units).
+ */
+ double densityScale(void) const;
+
+ /** Make value dimensionless.
+ *
+ * @param value Value with dimensions in SI units.
+ * @param scale Scale used to nondimensionalize value.
+ * @returns Dimensionless value.
+ */
+ double nondimensionalize(const double value,
+ const double scale) const;
+
+ /** Make value dimensionless.
+ *
+ * @param value Dimensionless value.
+ * @param value Value with dimensions in SI units.
+ * @returns Scale used to nondimensionalize value.
+ */
+ double dimensionalize(const double value,
+ const double scale) const;
+
+ /** Make values dimensionless.
+ *
+ * @param values Array of values with dimensions in SI units.
+ * @param nvalues Number of values.
+ * @param scale Scale used to nondimensionalize value.
+ */
+ void nondimensionalize(double* const values,
+ const int nvalues,
+ const double scale) const;
+
+ /** Make value dimensionless.
+ *
+ * @param values Array of dimensionless values.
+ * @param nvalues Number of values.
+ * @param scale Scale used to nondimensionalize value.
+ */
+ void dimensionalize(double* const values,
+ const int nvalues,
+ const double scale) const;
+
+private :
+ // PRIVATE MEMBERS ////////////////////////////////////////////////////
+
+ double _length; ///< Length scale
+ double _pressure; ///< Pressure scale
+ double _time; ///< Time scale
+ double _density; ///< Density scale
+
+}; // class Nondimensional
+
+#include "Nondimensional.icc" // inline methods
+
+#endif // spatialdata_units_nondimensional_hh
+
+
+// End of file
Copied: cs/spatialdata-0.1/trunk/libsrc/units/Nondimensional.icc (from rev 13418, cs/spatialdata-0.1/trunk/libsrc/units/NondimElastic.icc)
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/units/Nondimensional.icc (rev 0)
+++ cs/spatialdata-0.1/trunk/libsrc/units/Nondimensional.icc 2008-11-28 21:22:34 UTC (rev 13420)
@@ -0,0 +1,62 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(spatialdata_units_nondimensional_hh)
+#error "Nondimensional.icc must only be included from Nondimensional.hh"
+#endif
+
+// Get value to nondimensionalize length scale in meters (SI units).
+inline
+double
+spatialdata::units::Nondimensional::lengthScale(void) const {
+ return _length;
+}
+
+// Get value to nondimensionalize pressure scale in Pascals (SI units).
+inline
+double
+spatialdata::units::Nondimensional::pressureScale(void) const {
+ return _pressure;
+}
+
+// Get value to nondimensionalize time scale in seconds (SI units).
+inline
+double
+spatialdata::units::Nondimensional::timeScale(void) const {
+ return _time;
+}
+
+// Get value to nondimensionalize density scale in kg/m^3 (SI units).
+inline
+double
+spatialdata::units::Nondimensional::densityScale(void) const {
+ return _density;
+}
+
+// Make value dimensionless.
+inline
+double
+spatialdata::units::Nondimensional::nondimensionalize(const double value,
+ const double scale) const {
+ return value / scale;
+}
+
+// Make value dimensionless.
+inline
+double
+spatialdata::units::Nondimensional::dimensionalize(const double value,
+ const double scale) const {
+ return value * scale;
+}
+
+
+// End of file
Modified: cs/spatialdata-0.1/trunk/modulesrc/units/units.pyxe.src
===================================================================
--- cs/spatialdata-0.1/trunk/modulesrc/units/units.pyxe.src 2008-11-27 22:11:02 UTC (rev 13419)
+++ cs/spatialdata-0.1/trunk/modulesrc/units/units.pyxe.src 2008-11-28 21:22:34 UTC (rev 13420)
@@ -11,7 +11,7 @@
#
#header{
-#include "spatialdata/units/NondimElastic.hh"
+#include "spatialdata/units/Nondimensional.hh"
#include <stdexcept>
#include <Python.h>
@@ -31,22 +31,22 @@
void* malloc(size_t size)
void free(void* mem)
-cdef void NondimElastic_destructor(void* obj):
+cdef void Nondimensional_destructor(void* obj):
"""
- Destroy NondimElastic object.
+ Destroy Nondimensional object.
"""
# create shim for destructor
- #embed{ void NondimElastic_destructor_cpp(void* pObj)
- spatialdata::units::NondimElastic* pDim =
- (spatialdata::units::NondimElastic*) pObj;
+ #embed{ void Nondimensional_destructor_cpp(void* pObj)
+ spatialdata::units::Nondimensional* pDim =
+ (spatialdata::units::Nondimensional*) pObj;
delete pDim;
#}embed
- NondimElastic_destructor_cpp(obj)
+ Nondimensional_destructor_cpp(obj)
return
# ----------------------------------------------------------------------
-cdef class NondimElastic:
+cdef class Nondimensional:
cdef void* thisptr # Pointer to C++ object
cdef readonly object handle # PyCObject holding pointer to C++ object
@@ -55,12 +55,12 @@
def __init__(self):
"""Constructor."""
# create shim for constructor
- #embed{ void* NondimElastic_constructor()
- return (void*)(new spatialdata::units::NondimElastic);
+ #embed{ void* Nondimensional_constructor()
+ return (void*)(new spatialdata::units::Nondimensional);
#}embed
- self.name = "spatialdata_units_NondimElastic"
- self.thisptr = NondimElastic_constructor()
+ self.name = "spatialdata_units_Nondimensional"
+ self.thisptr = Nondimensional_constructor()
self.handle = self._createHandle()
return
@@ -69,9 +69,9 @@
def __set__(self, value):
"""Set value to nondimensionalize length scale in meters (SI units)."""
# create shim for method 'length'
- #embed{ void NondimElastic_length_set(void* pObj, double value)
+ #embed{ void Nondimensional_length_set(void* pObj, double value)
try {
- ((spatialdata::units::NondimElastic*) pObj)->lengthScale(value);
+ ((spatialdata::units::Nondimensional*) pObj)->lengthScale(value);
} catch (const std::exception& err) {
PyErr_SetString(PyExc_RuntimeError,
const_cast<char*>(err.what()));
@@ -80,16 +80,16 @@
"Caught unknown C++ exception.");
} // try/catch
#}embed
- NondimElastic_length_set(self.thisptr, value)
+ Nondimensional_length_set(self.thisptr, value)
property pressure:
def __set__(self, value):
"""Set value to nondimensionalize pressure scale in Pascals (SI units)."""
# create shim for method 'pressure'
- #embed{ void NondimElastic_pressure_set(void* pObj, double value)
+ #embed{ void Nondimensional_pressure_set(void* pObj, double value)
try {
- ((spatialdata::units::NondimElastic*) pObj)->pressureScale(value);
+ ((spatialdata::units::Nondimensional*) pObj)->pressureScale(value);
} catch (const std::exception& err) {
PyErr_SetString(PyExc_RuntimeError,
const_cast<char*>(err.what()));
@@ -98,16 +98,16 @@
"Caught unknown C++ exception.");
} // try/catch
#}embed
- NondimElastic_pressure_set(self.thisptr, value)
+ Nondimensional_pressure_set(self.thisptr, value)
property time:
def __set__(self, value):
"""Set value to nondimensionalize time scale in seconds (SI units)."""
# create shim for method 'time'
- #embed{ void NondimElastic_time_set(void* pObj, double value)
+ #embed{ void Nondimensional_time_set(void* pObj, double value)
try {
- ((spatialdata::units::NondimElastic*) pObj)->timeScale(value);
+ ((spatialdata::units::Nondimensional*) pObj)->timeScale(value);
} catch (const std::exception& err) {
PyErr_SetString(PyExc_RuntimeError,
const_cast<char*>(err.what()));
@@ -116,16 +116,16 @@
"Caught unknown C++ exception.");
} // try/catch
#}embed
- NondimElastic_time_set(self.thisptr, value)
+ Nondimensional_time_set(self.thisptr, value)
property density:
def __set__(self, value):
"""Set value to nondimensionalize density scale in kg/m^3 (SI units)."""
# create shim for method 'density'
- #embed{ void NondimElastic_density_set(void* pObj, double value)
+ #embed{ void Nondimensional_density_set(void* pObj, double value)
try {
- ((spatialdata::units::NondimElastic*) pObj)->densityScale(value);
+ ((spatialdata::units::Nondimensional*) pObj)->densityScale(value);
} catch (const std::exception& err) {
PyErr_SetString(PyExc_RuntimeError,
const_cast<char*>(err.what()));
@@ -134,12 +134,12 @@
"Caught unknown C++ exception.");
} // try/catch
#}embed
- NondimElastic_density_set(self.thisptr, value)
+ Nondimensional_density_set(self.thisptr, value)
def _createHandle(self):
"""Wrap pointer to C++ object in PyCObject."""
- return PyCObject_FromVoidPtr(self.thisptr, NondimElastic_destructor)
+ return PyCObject_FromVoidPtr(self.thisptr, Nondimensional_destructor)
# End of file
Modified: cs/spatialdata-0.1/trunk/spatialdata/Makefile.am
===================================================================
--- cs/spatialdata-0.1/trunk/spatialdata/Makefile.am 2008-11-27 22:11:02 UTC (rev 13419)
+++ cs/spatialdata-0.1/trunk/spatialdata/Makefile.am 2008-11-28 21:22:34 UTC (rev 13420)
@@ -37,7 +37,7 @@
spatialdb/generator/Values.py \
spatialdb/generator/__init__.py \
units/__init__.py \
- units/NondimElastic.py \
+ units/Nondimensional.py \
units/NondimElasticQuasistatic.py \
units/NondimElasticDynamic.py \
utils/ChangeCoordSys.py \
Modified: cs/spatialdata-0.1/trunk/spatialdata/__init__.py
===================================================================
--- cs/spatialdata-0.1/trunk/spatialdata/__init__.py 2008-11-27 22:11:02 UTC (rev 13419)
+++ cs/spatialdata-0.1/trunk/spatialdata/__init__.py 2008-11-28 21:22:34 UTC (rev 13420)
@@ -16,6 +16,7 @@
__all__ = ['geocoords',
'spatialdb',
+ 'units',
'utils']
Deleted: cs/spatialdata-0.1/trunk/spatialdata/units/NondimElastic.py
===================================================================
--- cs/spatialdata-0.1/trunk/spatialdata/units/NondimElastic.py 2008-11-27 22:11:02 UTC (rev 13419)
+++ cs/spatialdata-0.1/trunk/spatialdata/units/NondimElastic.py 2008-11-28 21:22:34 UTC (rev 13420)
@@ -1,161 +0,0 @@
-#!/usr/bin/env python
-#
-# ----------------------------------------------------------------------
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# <LicenseText>
-#
-# ----------------------------------------------------------------------
-#
-
-## @file spatialdata/units/NondimElastic.py
-##
-## @brief Python manager for nondimensionalizing elasticity problems.
-##
-## Factory: nondimensional
-
-from pyre.components.Component import Component
-
-# NondimElastic class
-class NondimElastic(Component):
- """
- Python manager for nondimensionalizing elasticity problems.
-
- Factory: nondimensional
- """
-
- # INVENTORY //////////////////////////////////////////////////////////
-
- class Inventory(Component.Inventory):
- """Python object for managing NondimElastic facilities and properties."""
-
- ## @class Inventory
- ## Python object for managing NondimElastic facilities and properties.
- ##
- ## \b Properties
- ## @li None
- ##
- ## \b Facilities
- ## @li None
-
- # PUBLIC METHODS /////////////////////////////////////////////////////
-
- def __init__(self, name="nondimelastic"):
- """
- Constructor.
- """
- Component.__init__(self, name, facility="nondimelastic")
-
- self.cppHandle = None
- from pyre.units.length import meter
- from pyre.units.pressure import pascal
- from pyre.units.time import second
- from pyre.units.mass import kilogram
-
- self._length = 1.0*meter
- self._pressure = 1.0*pascal
- self._time = 1.0*second
- self._density = 1.0*kilogram/meter**3
- return
-
-
- def initialize(self):
- """
- Initialize coordinate system.
- """
- self._createCppHandle()
- self.cppHandle.length = self._length.value
- self.cppHandle.pressure = self._pressure.value
- self.cppHandle.time = self._time.value
- self.cppHandle.density = self._density.value
- return
-
-
- def utonLength(self, value):
- """
- Make length scale dimensionless.
- """
- return value / self._length
-
-
- def ntouLength(self, value):
- """
- Add dimensions to length scale.
- """
- return value * self._length
-
-
- def utonPressure(self, value):
- """
- Make pressure scale dimensionless.
- """
- return value / self._pressure
-
-
- def ntouPressure(self, value):
- """
- Add dimensions to pressure scale.
- """
- return value * self._pressure
-
-
- def utonTime(self, value):
- """
- Make time scale dimensionless.
- """
- return value / self._time
-
-
- def ntouTime(self, value):
- """
- Add dimensions to time scale.
- """
- return value * self._time
-
-
- def utonDensity(self, value):
- """
- Make density scale dimensionless.
- """
- return value / self._density
-
-
- def ntouDensity(self, value):
- """
- Add dimensions to density scale.
- """
- return value * self._density
-
-
- # PRIVATE METHODS ////////////////////////////////////////////////////
-
- def _configure(self):
- """
- Setup members using inventory.
- """
- Component._configure(self)
- return
-
-
- def _createCppHandle(self):
- """
- Create handle to C++ object.
- """
- if None == self.cppHandle:
- import spatialdata.units.units as bindings
- self.cppHandle = bindings.NondimElastic()
- return
-
-
-# FACTORIES ////////////////////////////////////////////////////////////
-
-def nondimensional():
- """
- Factory associated with NondimElastic.
- """
- return NondimElastic()
-
-
-# End of file
Modified: cs/spatialdata-0.1/trunk/spatialdata/units/NondimElasticDynamic.py
===================================================================
--- cs/spatialdata-0.1/trunk/spatialdata/units/NondimElasticDynamic.py 2008-11-27 22:11:02 UTC (rev 13419)
+++ cs/spatialdata-0.1/trunk/spatialdata/units/NondimElasticDynamic.py 2008-11-28 21:22:34 UTC (rev 13420)
@@ -17,10 +17,10 @@
##
## Factory: nondimensional
-from NondimElastic import NondimElastic
+from Nondimensional import Nondimensional
# NondimElasticDynamic class
-class NondimElasticDynamic(NondimElastic):
+class NondimElasticDynamic(Nondimensional):
"""
Python manager for nondimensionalizing dynamic elasticity problems.
@@ -29,7 +29,7 @@
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(NondimElastic.Inventory):
+ class Inventory(Nondimensional.Inventory):
"""
Python object for managing NondimElasticDynamic facilities and
properties.
@@ -70,11 +70,11 @@
# PUBLIC METHODS /////////////////////////////////////////////////////
- def __init__(self, name="nondimelastic"):
+ def __init__(self, name="nondimelasticdynamic"):
"""
Constructor.
"""
- NondimElastic.__init__(self, name)
+ Nondimensional.__init__(self, name)
return
@@ -84,7 +84,7 @@
"""
Setup members using inventory.
"""
- NondimElastic._configure(self)
+ Nondimensional._configure(self)
vs = self.inventory.shearWaveSpeed
period = self.inventory.wavePeriod
density = self.inventory.massDensity
Modified: cs/spatialdata-0.1/trunk/spatialdata/units/NondimElasticQuasistatic.py
===================================================================
--- cs/spatialdata-0.1/trunk/spatialdata/units/NondimElasticQuasistatic.py 2008-11-27 22:11:02 UTC (rev 13419)
+++ cs/spatialdata-0.1/trunk/spatialdata/units/NondimElasticQuasistatic.py 2008-11-28 21:22:34 UTC (rev 13420)
@@ -17,10 +17,10 @@
##
## Factory: nondimensional
-from NondimElastic import NondimElastic
+from Nondimensional import Nondimensional
# NondimElasticQuasistatic class
-class NondimElasticQuasistatic(NondimElastic):
+class NondimElasticQuasistatic(Nondimensional):
"""
Python manager for nondimensionalizing quasi-static elasticity problems.
@@ -29,7 +29,7 @@
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(NondimElastic.Inventory):
+ class Inventory(Nondimensional.Inventory):
"""
Python object for managing NondimElasticQuasistatic facilities and
properties.
@@ -70,11 +70,11 @@
# PUBLIC METHODS /////////////////////////////////////////////////////
- def __init__(self, name="nondimelastic"):
+ def __init__(self, name="nondimelasticquasistatic"):
"""
Constructor.
"""
- NondimElastic.__init__(self, name)
+ Nondimensional.__init__(self, name)
return
@@ -84,7 +84,7 @@
"""
Setup members using inventory.
"""
- NondimElastic._configure(self)
+ Nondimensional._configure(self)
self._length = self.inventory.lengthScale
self._pressure = self.inventory.shearModulus
self._time = self.inventory.relaxationTime
Copied: cs/spatialdata-0.1/trunk/spatialdata/units/Nondimensional.py (from rev 13418, cs/spatialdata-0.1/trunk/spatialdata/units/NondimElastic.py)
===================================================================
--- cs/spatialdata-0.1/trunk/spatialdata/units/Nondimensional.py (rev 0)
+++ cs/spatialdata-0.1/trunk/spatialdata/units/Nondimensional.py 2008-11-28 21:22:34 UTC (rev 13420)
@@ -0,0 +1,148 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file spatialdata/units/Nondimensional.py
+##
+## @brief Python manager for nondimensionalizing problems.
+##
+## Factory: nondimensional
+
+from pyre.components.Component import Component
+
+# Nondimensional class
+class Nondimensional(Component):
+ """
+ Python manager for nondimensionalizing problems.
+
+ Factory: nondimensional
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(Component.Inventory):
+ """Python object for managing Nondimensional facilities and properties."""
+
+ ## @class Inventory
+ ## Python object for managing Nondimensional facilities and properties.
+ ##
+ ## \b Properties
+ ## @li None
+ ##
+ ## \b Facilities
+ ## @li None
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="nondimensional"):
+ """
+ Constructor.
+ """
+ Component.__init__(self, name, facility="nondimensional")
+
+ self.cppHandle = None
+ from pyre.units.length import meter
+ from pyre.units.pressure import pascal
+ from pyre.units.time import second
+ from pyre.units.mass import kilogram
+
+ self._length = 1.0*meter
+ self._pressure = 1.0*pascal
+ self._time = 1.0*second
+ self._density = 1.0*kilogram/meter**3
+ return
+
+
+ def initialize(self):
+ """
+ Initialize coordinate system.
+ """
+ self._createCppHandle()
+ self.cppHandle.length = self._length.value
+ self.cppHandle.pressure = self._pressure.value
+ self.cppHandle.time = self._time.value
+ self.cppHandle.density = self._density.value
+ return
+
+
+ def lengthScale(self):
+ """
+ Get length scale.
+ """
+ return self._length
+
+
+ def pressureScale(self):
+ """
+ Get pressure scale.
+ """
+ return self._pressure
+
+
+ def timeScale(self):
+ """
+ Get time scale.
+ """
+ return self._time
+
+
+ def densityScale(self):
+ """
+ Get density scale.
+ """
+ return self._density
+
+
+ def nondimensionalize(self, value, scale):
+ """
+ Make value dimensionless.
+ """
+ return value / scale
+
+
+ def dimensionalize(self, value, scale):
+ """
+ Make value dimensional.
+ """
+ return value * scale
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Setup members using inventory.
+ """
+ Component._configure(self)
+ return
+
+
+ def _createCppHandle(self):
+ """
+ Create handle to C++ object.
+ """
+ if None == self.cppHandle:
+ import spatialdata.units.units as bindings
+ self.cppHandle = bindings.Nondimensional()
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def nondimensional():
+ """
+ Factory associated with Nondimensional.
+ """
+ return Nondimensional()
+
+
+# End of file
Modified: cs/spatialdata-0.1/trunk/spatialdata/units/__init__.py
===================================================================
--- cs/spatialdata-0.1/trunk/spatialdata/units/__init__.py 2008-11-27 22:11:02 UTC (rev 13419)
+++ cs/spatialdata-0.1/trunk/spatialdata/units/__init__.py 2008-11-28 21:22:34 UTC (rev 13420)
@@ -14,7 +14,7 @@
##
## @brief Python spatialdata units module initialization.
-__all__ = ['NondimElastic',
+__all__ = ['Nondimensional',
'NondimElasticQuasistatic',
'NondimElasticDynamic',
]
Modified: cs/spatialdata-0.1/trunk/tests/libtests/units/Makefile.am
===================================================================
--- cs/spatialdata-0.1/trunk/tests/libtests/units/Makefile.am 2008-11-27 22:11:02 UTC (rev 13419)
+++ cs/spatialdata-0.1/trunk/tests/libtests/units/Makefile.am 2008-11-28 21:22:34 UTC (rev 13420)
@@ -18,11 +18,11 @@
check_PROGRAMS = testunits
testunits_SOURCES = \
- TestNondimElastic.cc \
+ TestNondimensional.cc \
testunits.cc
noinst_HEADERS = \
- TestNondimElastic.hh
+ TestNondimensional.hh
testunits_LDFLAGS =
Deleted: cs/spatialdata-0.1/trunk/tests/libtests/units/TestNondimElastic.cc
===================================================================
--- cs/spatialdata-0.1/trunk/tests/libtests/units/TestNondimElastic.cc 2008-11-27 22:11:02 UTC (rev 13419)
+++ cs/spatialdata-0.1/trunk/tests/libtests/units/TestNondimElastic.cc 2008-11-28 21:22:34 UTC (rev 13420)
@@ -1,398 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "TestNondimElastic.hh" // Implementation of class methods
-
-#include "spatialdata/units/NondimElastic.hh" // USES NondimElastic
-
-#include <valarray> // USES std::valarray
-
-// ----------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_REGISTRATION( spatialdata::units::TestNondimElastic );
-
-// ----------------------------------------------------------------------
-// Test constructor.
-void
-spatialdata::units::TestNondimElastic::testConstructor(void)
-{ // testConstructor
- NondimElastic dim;
- CPPUNIT_ASSERT_EQUAL(1.0, dim._length);
- CPPUNIT_ASSERT_EQUAL(1.0, dim._pressure);
- CPPUNIT_ASSERT_EQUAL(1.0, dim._time);
- CPPUNIT_ASSERT_EQUAL(1.0, dim._density);
-} // testConstructor
-
-// ----------------------------------------------------------------------
-// Test copy constructor.
-void
-spatialdata::units::TestNondimElastic::testCopyConstructor(void)
-{ // testCopyConstructor
- NondimElastic dim;
- dim._length = 2.0;
- dim._pressure = 3.0;
- dim._time = 4.0;
- dim._density = 5.0;
-
- NondimElastic dim2(dim);
- CPPUNIT_ASSERT_EQUAL(2.0, dim2._length);
- CPPUNIT_ASSERT_EQUAL(3.0, dim2._pressure);
- CPPUNIT_ASSERT_EQUAL(4.0, dim2._time);
- CPPUNIT_ASSERT_EQUAL(5.0, dim2._density);
-} // testCopyConstructor
-
-// ----------------------------------------------------------------------
-// Test assignment.
-void
-spatialdata::units::TestNondimElastic::testAssignment(void)
-{ // testAssignment
- NondimElastic dim;
- dim._length = 2.0;
- dim._pressure = 3.0;
- dim._time = 4.0;
- dim._density = 5.0;
-
- NondimElastic dim2;
- dim2 = dim;
- CPPUNIT_ASSERT_EQUAL(2.0, dim2._length);
- CPPUNIT_ASSERT_EQUAL(3.0, dim2._pressure);
- CPPUNIT_ASSERT_EQUAL(4.0, dim2._time);
- CPPUNIT_ASSERT_EQUAL(5.0, dim2._density);
-} // testAssignment
-
-// ----------------------------------------------------------------------
-// Test lengthScale().
-void
-spatialdata::units::TestNondimElastic::testLengthScale(void)
-{ // testLengthScale
- NondimElastic dim;
-
- const double scale = 4.0;
- dim.lengthScale(scale);
- CPPUNIT_ASSERT_EQUAL(scale, dim._length);
- CPPUNIT_ASSERT_EQUAL(1.0, dim._pressure);
- CPPUNIT_ASSERT_EQUAL(1.0, dim._time);
- CPPUNIT_ASSERT_EQUAL(1.0, dim._density);
-} // testLengthScale
-
-// ----------------------------------------------------------------------
-// Test pressureScale().
-void
-spatialdata::units::TestNondimElastic::testPressureScale(void)
-{ // testPressureScale
- NondimElastic dim;
-
- const double scale = 4.0;
- dim.pressureScale(scale);
- CPPUNIT_ASSERT_EQUAL(1.0, dim._length);
- CPPUNIT_ASSERT_EQUAL(scale, dim._pressure);
- CPPUNIT_ASSERT_EQUAL(1.0, dim._time);
- CPPUNIT_ASSERT_EQUAL(1.0, dim._density);
-} // testPressureScale
-
-// ----------------------------------------------------------------------
-// Test timeScale().
-void
-spatialdata::units::TestNondimElastic::testTimeScale(void)
-{ // testTimeScale
- NondimElastic dim;
-
- const double scale = 4.0;
- dim.timeScale(scale);
- CPPUNIT_ASSERT_EQUAL(1.0, dim._length);
- CPPUNIT_ASSERT_EQUAL(1.0, dim._pressure);
- CPPUNIT_ASSERT_EQUAL(scale, dim._time);
- CPPUNIT_ASSERT_EQUAL(1.0, dim._density);
-} // testTimeScale
-
-// ----------------------------------------------------------------------
-// Test densityScale().
-void
-spatialdata::units::TestNondimElastic::testDensityScale(void)
-{ // testDensityScale
- NondimElastic dim;
-
- const double scale = 4.0;
- dim.densityScale(scale);
- CPPUNIT_ASSERT_EQUAL(1.0, dim._length);
- CPPUNIT_ASSERT_EQUAL(1.0, dim._pressure);
- CPPUNIT_ASSERT_EQUAL(1.0, dim._time);
- CPPUNIT_ASSERT_EQUAL(scale, dim._density);
-} // testDensityScale
-
-// ----------------------------------------------------------------------
-// Test utonLength().
-void
-spatialdata::units::TestNondimElastic::testUtonLength(void)
-{ // testUtonLength
- const double scale = 4.0;
- const double value = 3.0;
- const double valueE = 0.75;
-
- NondimElastic dim;
- dim.lengthScale(scale);
- CPPUNIT_ASSERT_EQUAL(valueE, dim.utonLength(value));
-} // testUtonLength
-
-// ----------------------------------------------------------------------
-// Test ntouLength().
-void
-spatialdata::units::TestNondimElastic::testNtouLength(void)
-{ // testNtouLength
- const double scale = 4.0;
- const double value = 0.75;
- const double valueE = 3.0;
-
- NondimElastic dim;
- dim.lengthScale(scale);
- CPPUNIT_ASSERT_EQUAL(valueE, dim.ntouLength(value));
-} // testNtouLength
-
-// ----------------------------------------------------------------------
-// Test utonLength() with arrays.
-void
-spatialdata::units::TestNondimElastic::testUtonLengthArray(void)
-{ // testUtonLengthArray
- const double scale = 10.0;
- const int nvalues = 3;
- const double values[] = { 2.0, 5.0, 7.0 };
- const double valuesE[] = { 0.2, 0.5, 0.7 };
-
- NondimElastic dim;
- dim.lengthScale(scale);
- std::valarray<double> v(values, nvalues);
- dim.utonLength(&v[0], nvalues);
-
- for (int i=0; i < nvalues; ++i)
- CPPUNIT_ASSERT_EQUAL(valuesE[i], v[i]);
-} // testUtonLengthArray
-
-// ----------------------------------------------------------------------
-// Test ntouLength() with arrays.
-void
-spatialdata::units::TestNondimElastic::testNtouLengthArray(void)
-{ // testNtouLengthArray
- const double scale = 10.0;
- const int nvalues = 3;
- const double values[] = { 0.2, 0.5, 0.7 };
- const double valuesE[] = { 2.0, 5.0, 7.0 };
-
- NondimElastic dim;
- dim.lengthScale(scale);
- std::valarray<double> v(values, nvalues);
- dim.ntouLength(&v[0], nvalues);
-
- for (int i=0; i < nvalues; ++i)
- CPPUNIT_ASSERT_EQUAL(valuesE[i], v[i]);
-} // testNtouLengthArray
-
-// ----------------------------------------------------------------------
-// Test utonPressure().
-void
-spatialdata::units::TestNondimElastic::testUtonPressure(void)
-{ // testUtonPressure
- const double scale = 4.0;
- const double value = 3.0;
- const double valueE = 0.75;
-
- NondimElastic dim;
- dim.pressureScale(scale);
- CPPUNIT_ASSERT_EQUAL(valueE, dim.utonPressure(value));
-} // testUtonPressure
-
-// ----------------------------------------------------------------------
-// Test ntouPressure().
-void
-spatialdata::units::TestNondimElastic::testNtouPressure(void)
-{ // testNtouPressure
- const double scale = 4.0;
- const double value = 0.75;
- const double valueE = 3.0;
-
- NondimElastic dim;
- dim.pressureScale(scale);
- CPPUNIT_ASSERT_EQUAL(valueE, dim.ntouPressure(value));
-} // testNtouPressure
-
-// ----------------------------------------------------------------------
-// Test utonPressure() with arrays.
-void
-spatialdata::units::TestNondimElastic::testUtonPressureArray(void)
-{ // testUtonPressureArray
- const double scale = 10.0;
- const int nvalues = 3;
- const double values[] = { 2.0, 5.0, 7.0 };
- const double valuesE[] = { 0.2, 0.5, 0.7 };
-
- NondimElastic dim;
- dim.pressureScale(scale);
- std::valarray<double> v(values, nvalues);
- dim.utonPressure(&v[0], nvalues);
-
- for (int i=0; i < nvalues; ++i)
- CPPUNIT_ASSERT_EQUAL(valuesE[i], v[i]);
-} // testUtonPressureArray
-
-// ----------------------------------------------------------------------
-// Test ntouPressure() with arrays.
-void
-spatialdata::units::TestNondimElastic::testNtouPressureArray(void)
-{ // testNtouPressureArray
- const double scale = 10.0;
- const int nvalues = 3;
- const double values[] = { 0.2, 0.5, 0.7 };
- const double valuesE[] = { 2.0, 5.0, 7.0 };
-
- NondimElastic dim;
- dim.pressureScale(scale);
- std::valarray<double> v(values, nvalues);
- dim.ntouPressure(&v[0], nvalues);
-
- for (int i=0; i < nvalues; ++i)
- CPPUNIT_ASSERT_EQUAL(valuesE[i], v[i]);
-} // testNtouPressureArray
-
-// ----------------------------------------------------------------------
-// Test utonTime().
-void
-spatialdata::units::TestNondimElastic::testUtonTime(void)
-{ // testUtonTime
- const double scale = 4.0;
- const double value = 3.0;
- const double valueE = 0.75;
-
- NondimElastic dim;
- dim.timeScale(scale);
- CPPUNIT_ASSERT_EQUAL(valueE, dim.utonTime(value));
-} // testUtonTime
-
-// ----------------------------------------------------------------------
-// Test ntouTime().
-void
-spatialdata::units::TestNondimElastic::testNtouTime(void)
-{ // testNtouTime
- const double scale = 4.0;
- const double value = 0.75;
- const double valueE = 3.0;
-
- NondimElastic dim;
- dim.timeScale(scale);
- CPPUNIT_ASSERT_EQUAL(valueE, dim.ntouTime(value));
-} // testNtouTime
-
-// ----------------------------------------------------------------------
-// Test utonTime() with arrays.
-void
-spatialdata::units::TestNondimElastic::testUtonTimeArray(void)
-{ // testUtonTimeArray
- const double scale = 10.0;
- const int nvalues = 3;
- const double values[] = { 2.0, 5.0, 7.0 };
- const double valuesE[] = { 0.2, 0.5, 0.7 };
-
- NondimElastic dim;
- dim.timeScale(scale);
- std::valarray<double> v(values, nvalues);
- dim.utonTime(&v[0], nvalues);
-
- for (int i=0; i < nvalues; ++i)
- CPPUNIT_ASSERT_EQUAL(valuesE[i], v[i]);
-} // testUtonTimeArray
-
-// ----------------------------------------------------------------------
-// Test ntouTime() with arrays.
-void
-spatialdata::units::TestNondimElastic::testNtouTimeArray(void)
-{ // testNtouTimeArray
- const double scale = 10.0;
- const int nvalues = 3;
- const double values[] = { 0.2, 0.5, 0.7 };
- const double valuesE[] = { 2.0, 5.0, 7.0 };
-
- NondimElastic dim;
- dim.timeScale(scale);
- std::valarray<double> v(values, nvalues);
- dim.ntouTime(&v[0], nvalues);
-
- for (int i=0; i < nvalues; ++i)
- CPPUNIT_ASSERT_EQUAL(valuesE[i], v[i]);
-} // testNtouTimeArray
-
-// ----------------------------------------------------------------------
-// Test utonDensity().
-void
-spatialdata::units::TestNondimElastic::testUtonDensity(void)
-{ // testUtonDensity
- const double scale = 4.0;
- const double value = 3.0;
- const double valueE = 0.75;
-
- NondimElastic dim;
- dim.densityScale(scale);
- CPPUNIT_ASSERT_EQUAL(valueE, dim.utonDensity(value));
-} // testUtonDensity
-
-// ----------------------------------------------------------------------
-// Test ntouDensity().
-void
-spatialdata::units::TestNondimElastic::testNtouDensity(void)
-{ // testNtouDensity
- const double scale = 4.0;
- const double value = 0.75;
- const double valueE = 3.0;
-
- NondimElastic dim;
- dim.densityScale(scale);
- CPPUNIT_ASSERT_EQUAL(valueE, dim.ntouDensity(value));
-} // testNtouDensity
-
-// ----------------------------------------------------------------------
-// Test utonDensity() with arrays.
-void
-spatialdata::units::TestNondimElastic::testUtonDensityArray(void)
-{ // testUtonDensityArray
- const double scale = 10.0;
- const int nvalues = 3;
- const double values[] = { 2.0, 5.0, 7.0 };
- const double valuesE[] = { 0.2, 0.5, 0.7 };
-
- NondimElastic dim;
- dim.densityScale(scale);
- std::valarray<double> v(values, nvalues);
- dim.utonDensity(&v[0], nvalues);
-
- for (int i=0; i < nvalues; ++i)
- CPPUNIT_ASSERT_EQUAL(valuesE[i], v[i]);
-} // testUtonDensityArray
-
-// ----------------------------------------------------------------------
-// Test ntouDensity() with arrays.
-void
-spatialdata::units::TestNondimElastic::testNtouDensityArray(void)
-{ // testNtouDensityArray
- const double scale = 10.0;
- const int nvalues = 3;
- const double values[] = { 0.2, 0.5, 0.7 };
- const double valuesE[] = { 2.0, 5.0, 7.0 };
-
- NondimElastic dim;
- dim.densityScale(scale);
- std::valarray<double> v(values, nvalues);
- dim.ntouDensity(&v[0], nvalues);
-
- for (int i=0; i < nvalues; ++i)
- CPPUNIT_ASSERT_EQUAL(valuesE[i], v[i]);
-} // testNtouDensityArray
-
-
-// End of file
Deleted: cs/spatialdata-0.1/trunk/tests/libtests/units/TestNondimElastic.hh
===================================================================
--- cs/spatialdata-0.1/trunk/tests/libtests/units/TestNondimElastic.hh 2008-11-27 22:11:02 UTC (rev 13419)
+++ cs/spatialdata-0.1/trunk/tests/libtests/units/TestNondimElastic.hh 2008-11-28 21:22:34 UTC (rev 13420)
@@ -1,142 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/** @file tests/libtests/units/TestNondimElastic.hh
- *
- * @brief C++ TestNondimElastic object
- *
- * C++ unit testing for NondimElastic.
- */
-
-#if !defined(spatialdata_units_testnondimelastic_hh)
-#define spatialdata_units_testnondimelastic_hh
-
-#include <cppunit/extensions/HelperMacros.h>
-
-/// Namespace for spatialdata package
-namespace spatialdata {
- namespace units {
- class TestNondimElastic;
- } // units
-} // spatialdata
-
-/// C++ unit testing for NondimElastic
-class spatialdata::units::TestNondimElastic : public CppUnit::TestFixture
-{ // class TestNondimElastic
-
- // CPPUNIT TEST SUITE /////////////////////////////////////////////////
- CPPUNIT_TEST_SUITE( TestNondimElastic );
-
- CPPUNIT_TEST( testConstructor );
- CPPUNIT_TEST( testCopyConstructor );
- CPPUNIT_TEST( testAssignment );
- CPPUNIT_TEST( testLengthScale );
- CPPUNIT_TEST( testPressureScale );
- CPPUNIT_TEST( testTimeScale );
- CPPUNIT_TEST( testDensityScale );
- CPPUNIT_TEST( testUtonLength );
- CPPUNIT_TEST( testNtouLength );
- CPPUNIT_TEST( testUtonLengthArray );
- CPPUNIT_TEST( testNtouLengthArray );
- CPPUNIT_TEST( testUtonPressure );
- CPPUNIT_TEST( testNtouPressure );
- CPPUNIT_TEST( testUtonPressureArray );
- CPPUNIT_TEST( testNtouPressureArray );
- CPPUNIT_TEST( testUtonTime );
- CPPUNIT_TEST( testNtouTime );
- CPPUNIT_TEST( testUtonTimeArray );
- CPPUNIT_TEST( testNtouTimeArray );
- CPPUNIT_TEST( testUtonDensity );
- CPPUNIT_TEST( testNtouDensity );
- CPPUNIT_TEST( testUtonDensityArray );
- CPPUNIT_TEST( testNtouDensityArray );
-
- CPPUNIT_TEST_SUITE_END();
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Test constructor.
- void testConstructor(void);
-
- /// Test copy constructor.
- void testCopyConstructor(void);
-
- /// Test assignment.
- void testAssignment(void);
-
- /// Test lengthScale().
- void testLengthScale(void);
-
- /// Test pressureScale().
- void testPressureScale(void);
-
- /// Test timeScale().
- void testTimeScale(void);
-
- /// Test densityScale().
- void testDensityScale(void);
-
- /// Test utonLength().
- void testUtonLength(void);
-
- /// Test ntouLength().
- void testNtouLength(void);
-
- /// Test utonLength() with arrays.
- void testUtonLengthArray(void);
-
- /// Test ntouLength() with arrays.
- void testNtouLengthArray(void);
-
- /// Test utonPressure().
- void testUtonPressure(void);
-
- /// Test ntouPressure().
- void testNtouPressure(void);
-
- /// Test utonPressure() with arrays.
- void testUtonPressureArray(void);
-
- /// Test ntouPressure() with arrays.
- void testNtouPressureArray(void);
-
- /// Test utonTime().
- void testUtonTime(void);
-
- /// Test ntouTime().
- void testNtouTime(void);
-
- /// Test utonTime() with arrays.
- void testUtonTimeArray(void);
-
- /// Test ntouTime() with arrays.
- void testNtouTimeArray(void);
-
- /// Test utonDensity().
- void testUtonDensity(void);
-
- /// Test ntouDensity().
- void testNtouDensity(void);
-
- /// Test utonDensity() with arrays.
- void testUtonDensityArray(void);
-
- /// Test ntouDensity() with arrays.
- void testNtouDensityArray(void);
-
-}; // class TestNondimElastic
-
-#endif // spatialdata_units_testnondimelastic_hh
-
-
-// End of file
Copied: cs/spatialdata-0.1/trunk/tests/libtests/units/TestNondimensional.cc (from rev 13418, cs/spatialdata-0.1/trunk/tests/libtests/units/TestNondimElastic.cc)
===================================================================
--- cs/spatialdata-0.1/trunk/tests/libtests/units/TestNondimensional.cc (rev 0)
+++ cs/spatialdata-0.1/trunk/tests/libtests/units/TestNondimensional.cc 2008-11-28 21:22:34 UTC (rev 13420)
@@ -0,0 +1,196 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestNondimensional.hh" // Implementation of class methods
+
+#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
+
+#include <valarray> // USES std::valarray
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( spatialdata::units::TestNondimensional );
+
+// ----------------------------------------------------------------------
+// Test constructor.
+void
+spatialdata::units::TestNondimensional::testConstructor(void)
+{ // testConstructor
+ Nondimensional dim;
+ CPPUNIT_ASSERT_EQUAL(1.0, dim._length);
+ CPPUNIT_ASSERT_EQUAL(1.0, dim._pressure);
+ CPPUNIT_ASSERT_EQUAL(1.0, dim._time);
+ CPPUNIT_ASSERT_EQUAL(1.0, dim._density);
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test copy constructor.
+void
+spatialdata::units::TestNondimensional::testCopyConstructor(void)
+{ // testCopyConstructor
+ Nondimensional dim;
+ dim._length = 2.0;
+ dim._pressure = 3.0;
+ dim._time = 4.0;
+ dim._density = 5.0;
+
+ Nondimensional dim2(dim);
+ CPPUNIT_ASSERT_EQUAL(2.0, dim2._length);
+ CPPUNIT_ASSERT_EQUAL(3.0, dim2._pressure);
+ CPPUNIT_ASSERT_EQUAL(4.0, dim2._time);
+ CPPUNIT_ASSERT_EQUAL(5.0, dim2._density);
+} // testCopyConstructor
+
+// ----------------------------------------------------------------------
+// Test assignment.
+void
+spatialdata::units::TestNondimensional::testAssignment(void)
+{ // testAssignment
+ Nondimensional dim;
+ dim._length = 2.0;
+ dim._pressure = 3.0;
+ dim._time = 4.0;
+ dim._density = 5.0;
+
+ Nondimensional dim2;
+ dim2 = dim;
+ CPPUNIT_ASSERT_EQUAL(2.0, dim2._length);
+ CPPUNIT_ASSERT_EQUAL(3.0, dim2._pressure);
+ CPPUNIT_ASSERT_EQUAL(4.0, dim2._time);
+ CPPUNIT_ASSERT_EQUAL(5.0, dim2._density);
+} // testAssignment
+
+// ----------------------------------------------------------------------
+// Test lengthScale().
+void
+spatialdata::units::TestNondimensional::testLengthScale(void)
+{ // testLengthScale
+ Nondimensional dim;
+
+ const double scale = 4.0;
+ dim.lengthScale(scale);
+ CPPUNIT_ASSERT_EQUAL(scale, dim.lengthScale());
+ CPPUNIT_ASSERT_EQUAL(1.0, dim.pressureScale());
+ CPPUNIT_ASSERT_EQUAL(1.0, dim.timeScale());
+ CPPUNIT_ASSERT_EQUAL(1.0, dim.densityScale());
+} // testLengthScale
+
+// ----------------------------------------------------------------------
+// Test pressureScale().
+void
+spatialdata::units::TestNondimensional::testPressureScale(void)
+{ // testPressureScale
+ Nondimensional dim;
+
+ const double scale = 4.0;
+ dim.pressureScale(scale);
+ CPPUNIT_ASSERT_EQUAL(1.0, dim.lengthScale());
+ CPPUNIT_ASSERT_EQUAL(scale, dim.pressureScale());
+ CPPUNIT_ASSERT_EQUAL(1.0, dim.timeScale());
+ CPPUNIT_ASSERT_EQUAL(1.0, dim.densityScale());
+} // testPressureScale
+
+// ----------------------------------------------------------------------
+// Test timeScale().
+void
+spatialdata::units::TestNondimensional::testTimeScale(void)
+{ // testTimeScale
+ Nondimensional dim;
+
+ const double scale = 4.0;
+ dim.timeScale(scale);
+ CPPUNIT_ASSERT_EQUAL(1.0, dim.lengthScale());
+ CPPUNIT_ASSERT_EQUAL(1.0, dim.pressureScale());
+ CPPUNIT_ASSERT_EQUAL(scale, dim.timeScale());
+ CPPUNIT_ASSERT_EQUAL(1.0, dim.densityScale());
+} // testTimeScale
+
+// ----------------------------------------------------------------------
+// Test densityScale().
+void
+spatialdata::units::TestNondimensional::testDensityScale(void)
+{ // testDensityScale
+ Nondimensional dim;
+
+ const double scale = 4.0;
+ dim.densityScale(scale);
+ CPPUNIT_ASSERT_EQUAL(1.0, dim.lengthScale());
+ CPPUNIT_ASSERT_EQUAL(1.0, dim.pressureScale());
+ CPPUNIT_ASSERT_EQUAL(1.0, dim.timeScale());
+ CPPUNIT_ASSERT_EQUAL(scale, dim.densityScale());
+} // testDensityScale
+
+// ----------------------------------------------------------------------
+// Test nondimensionalize().
+void
+spatialdata::units::TestNondimensional::testNondimensionalize(void)
+{ // testNondimensionalize
+ const double scale = 4.0;
+ const double value = 3.0;
+ const double valueE = 0.75;
+
+ Nondimensional dim;
+ CPPUNIT_ASSERT_EQUAL(valueE, dim.nondimensionalize(value, scale));
+} // testNondimensionalize
+
+// ----------------------------------------------------------------------
+// Test dimensionalize().
+void
+spatialdata::units::TestNondimensional::testDimensionalize(void)
+{ // testDimensionalize
+ const double scale = 4.0;
+ const double value = 0.75;
+ const double valueE = 3.0;
+
+ Nondimensional dim;
+ CPPUNIT_ASSERT_EQUAL(valueE, dim.dimensionalize(value, scale));
+} // testNondimensionalize
+
+// ----------------------------------------------------------------------
+// Test nondimensionalize() with arrays.
+void
+spatialdata::units::TestNondimensional::testNondimensionalizeArray(void)
+{ // testNondimensionalizeArray
+ const double scale = 10.0;
+ const int nvalues = 3;
+ const double values[] = { 2.0, 5.0, 7.0 };
+ const double valuesE[] = { 0.2, 0.5, 0.7 };
+
+ Nondimensional dim;
+ std::valarray<double> v(values, nvalues);
+ dim.nondimensionalize(&v[0], nvalues, scale);
+
+ for (int i=0; i < nvalues; ++i)
+ CPPUNIT_ASSERT_EQUAL(valuesE[i], v[i]);
+} // testNondimensionalizeArray
+
+// ----------------------------------------------------------------------
+// Test dimensionalize() with arrays.
+void
+spatialdata::units::TestNondimensional::testDimensionalizeArray(void)
+{ // testDimensionalizeArray
+ const double scale = 10.0;
+ const int nvalues = 3;
+ const double values[] = { 0.2, 0.5, 0.7 };
+ const double valuesE[] = { 2.0, 5.0, 7.0 };
+
+ Nondimensional dim;
+ std::valarray<double> v(values, nvalues);
+ dim.dimensionalize(&v[0], nvalues, scale);
+
+ for (int i=0; i < nvalues; ++i)
+ CPPUNIT_ASSERT_EQUAL(valuesE[i], v[i]);
+} // testDimensionalizeArray
+
+
+// End of file
Copied: cs/spatialdata-0.1/trunk/tests/libtests/units/TestNondimensional.hh (from rev 13418, cs/spatialdata-0.1/trunk/tests/libtests/units/TestNondimElastic.hh)
===================================================================
--- cs/spatialdata-0.1/trunk/tests/libtests/units/TestNondimensional.hh (rev 0)
+++ cs/spatialdata-0.1/trunk/tests/libtests/units/TestNondimensional.hh 2008-11-28 21:22:34 UTC (rev 13420)
@@ -0,0 +1,94 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file tests/libtests/units/TestNondimensional.hh
+ *
+ * @brief C++ TestNondimensional object
+ *
+ * C++ unit testing for Nondimensional.
+ */
+
+#if !defined(spatialdata_units_testnondimensional_hh)
+#define spatialdata_units_testnondimensional_hh
+
+#include <cppunit/extensions/HelperMacros.h>
+
+/// Namespace for spatialdata package
+namespace spatialdata {
+ namespace units {
+ class TestNondimensional;
+ } // units
+} // spatialdata
+
+/// C++ unit testing for Nondimensional
+class spatialdata::units::TestNondimensional : public CppUnit::TestFixture
+{ // class TestNondimensional
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestNondimensional );
+
+ CPPUNIT_TEST( testConstructor );
+ CPPUNIT_TEST( testCopyConstructor );
+ CPPUNIT_TEST( testAssignment );
+ CPPUNIT_TEST( testLengthScale );
+ CPPUNIT_TEST( testPressureScale );
+ CPPUNIT_TEST( testTimeScale );
+ CPPUNIT_TEST( testDensityScale );
+ CPPUNIT_TEST( testNondimensionalize );
+ CPPUNIT_TEST( testDimensionalize );
+ CPPUNIT_TEST( testNondimensionalizeArray );
+ CPPUNIT_TEST( testDimensionalizeArray );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Test constructor.
+ void testConstructor(void);
+
+ /// Test copy constructor.
+ void testCopyConstructor(void);
+
+ /// Test assignment.
+ void testAssignment(void);
+
+ /// Test lengthScale().
+ void testLengthScale(void);
+
+ /// Test pressureScale().
+ void testPressureScale(void);
+
+ /// Test timeScale().
+ void testTimeScale(void);
+
+ /// Test densityScale().
+ void testDensityScale(void);
+
+ /// Test nondimensionalize().
+ void testNondimensionalize(void);
+
+ /// Test dimensionalize().
+ void testDimensionalize(void);
+
+ /// Test nondimensionalie() with arrays.
+ void testNondimensionalizeArray(void);
+
+ /// Test dimensionalize() with arrays.
+ void testDimensionalizeArray(void);
+
+}; // class TestNondimensional
+
+#endif // spatialdata_units_testnondimensional_hh
+
+
+// End of file
Modified: cs/spatialdata-0.1/trunk/tests/pytests/units/Makefile.am
===================================================================
--- cs/spatialdata-0.1/trunk/tests/pytests/units/Makefile.am 2008-11-27 22:11:02 UTC (rev 13419)
+++ cs/spatialdata-0.1/trunk/tests/pytests/units/Makefile.am 2008-11-28 21:22:34 UTC (rev 13420)
@@ -16,7 +16,7 @@
TESTS_ENVIRONMENT = $(PYTHON)
noinst_PYTHON = \
- TestNondimElastic.py
+ TestNondimensional.py
TestNondimElasticQuasistati.py \
TestNondimElasticDynamic.py
Deleted: cs/spatialdata-0.1/trunk/tests/pytests/units/TestNondimElastic.py
===================================================================
--- cs/spatialdata-0.1/trunk/tests/pytests/units/TestNondimElastic.py 2008-11-27 22:11:02 UTC (rev 13419)
+++ cs/spatialdata-0.1/trunk/tests/pytests/units/TestNondimElastic.py 2008-11-28 21:22:34 UTC (rev 13420)
@@ -1,157 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-import unittest
-
-from spatialdata.units.NondimElastic import NondimElastic
-
-from pyre.units.length import meter
-from pyre.units.pressure import pascal
-from pyre.units.time import second
-from pyre.units.mass import kilogram
-
-class TestNondimElastic(unittest.TestCase):
-
- def test_constructor(self):
- dim = NondimElastic()
- dim._configure()
-
- self.assertEqual(1.0*meter, dim._length)
- self.assertEqual(1.0*pascal, dim._pressure)
- self.assertEqual(1.0*second, dim._time)
- self.assertEqual(1.0*kilogram/meter**3, dim._density)
-
- return
-
-
- def test_initialize(self):
- dim = NondimElastic()
- dim._configure()
- dim.initialize()
-
- self.failIf(dim.cppHandle is None)
- return
-
-
- def test_utonLength(self):
- dim = NondimElastic()
- dim._configure()
- dim.initialize()
-
- scale = 8.0*meter
- value = 2.0*meter
- valueE = 0.25
-
- dim._length = scale
- self.assertEqual(valueE, dim.utonLength(value))
- return
-
-
- def test_ntouLength(self):
- dim = NondimElastic()
- dim._configure()
- dim.initialize()
-
- scale = 8.0*meter
- valueE = 2.0*meter
- value = 0.25
-
- dim._length = scale
- self.assertEqual(valueE, dim.ntouLength(value))
- return
-
-
- def test_utonPressure(self):
- dim = NondimElastic()
- dim._configure()
- dim.initialize()
-
- scale = 8.0*pascal
- value = 2.0*pascal
- valueE = 0.25
-
- dim._pressure = scale
- self.assertEqual(valueE, dim.utonPressure(value))
- return
-
-
- def test_ntouPressure(self):
- dim = NondimElastic()
- dim._configure()
- dim.initialize()
-
- scale = 8.0*pascal
- valueE = 2.0*pascal
- value = 0.25
-
- dim._pressure = scale
- self.assertEqual(valueE, dim.ntouPressure(value))
- return
-
-
- def test_utonTime(self):
- dim = NondimElastic()
- dim._configure()
- dim.initialize()
-
- scale = 8.0*second
- value = 2.0*second
- valueE = 0.25
-
- dim._time = scale
- self.assertEqual(valueE, dim.utonTime(value))
- return
-
-
- def test_ntouTime(self):
- dim = NondimElastic()
- dim._configure()
- dim.initialize()
-
- scale = 8.0*second
- valueE = 2.0*second
- value = 0.25
-
- dim._time = scale
- self.assertEqual(valueE, dim.ntouTime(value))
- return
-
-
- def test_utonDensity(self):
- dim = NondimElastic()
- dim._configure()
- dim.initialize()
-
- scale = 8.0*kilogram/meter**3
- value = 2.0*kilogram/meter**3
- valueE = 0.25
-
- dim._density = scale
- self.assertEqual(valueE, dim.utonDensity(value))
- return
-
-
- def test_ntouDensity(self):
- dim = NondimElastic()
- dim._configure()
- dim.initialize()
-
- scale = 8.0*kilogram/meter**3
- valueE = 2.0*kilogram/meter**3
- value = 0.25
-
- dim._density = scale
- self.assertEqual(valueE, dim.ntouDensity(value))
- return
-
-
-# End of file
Copied: cs/spatialdata-0.1/trunk/tests/pytests/units/TestNondimensional.py (from rev 13418, cs/spatialdata-0.1/trunk/tests/pytests/units/TestNondimElastic.py)
===================================================================
--- cs/spatialdata-0.1/trunk/tests/pytests/units/TestNondimensional.py (rev 0)
+++ cs/spatialdata-0.1/trunk/tests/pytests/units/TestNondimensional.py 2008-11-28 21:22:34 UTC (rev 13420)
@@ -0,0 +1,119 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+import unittest
+
+from spatialdata.units.Nondimensional import Nondimensional
+
+from pyre.units.length import meter
+from pyre.units.pressure import pascal
+from pyre.units.time import second
+from pyre.units.mass import kilogram
+
+class TestNondimensional(unittest.TestCase):
+
+ def test_constructor(self):
+ dim = Nondimensional()
+ dim._configure()
+
+ self.assertEqual(1.0*meter, dim._length)
+ self.assertEqual(1.0*pascal, dim._pressure)
+ self.assertEqual(1.0*second, dim._time)
+ self.assertEqual(1.0*kilogram/meter**3, dim._density)
+
+ return
+
+
+ def test_initialize(self):
+ dim = Nondimensional()
+ dim._configure()
+ dim.initialize()
+
+ self.failIf(dim.cppHandle is None)
+ return
+
+
+ def test_lengthScale(self):
+ dim = Nondimensional()
+ dim._configure()
+ dim._length = 2.0*meter
+
+ self.assertEqual(2.0*meter, dim.lengthScale())
+ self.assertEqual(1.0*pascal, dim.pressureScale())
+ self.assertEqual(1.0*second, dim.timeScale())
+ self.assertEqual(1.0*kilogram/meter**3, dim.densityScale())
+ return
+
+
+ def test_pressureScale(self):
+ dim = Nondimensional()
+ dim._configure()
+ dim._pressure = 2.0*pascal
+
+ self.assertEqual(1.0*meter, dim.lengthScale())
+ self.assertEqual(2.0*pascal, dim.pressureScale())
+ self.assertEqual(1.0*second, dim.timeScale())
+ self.assertEqual(1.0*kilogram/meter**3, dim.densityScale())
+ return
+
+
+ def test_timeScale(self):
+ dim = Nondimensional()
+ dim._configure()
+ dim._time = 2.0*second
+
+ self.assertEqual(1.0*meter, dim.lengthScale())
+ self.assertEqual(1.0*pascal, dim.pressureScale())
+ self.assertEqual(2.0*second, dim.timeScale())
+ self.assertEqual(1.0*kilogram/meter**3, dim.densityScale())
+ return
+
+
+ def test_densityScale(self):
+ dim = Nondimensional()
+ dim._configure()
+ dim._density = 2.0*kilogram/meter**3
+
+ self.assertEqual(1.0*meter, dim.lengthScale())
+ self.assertEqual(1.0*pascal, dim.pressureScale())
+ self.assertEqual(1.0*second, dim.timeScale())
+ self.assertEqual(2.0*kilogram/meter**3, dim.densityScale())
+ return
+
+
+ def test_nondimensionalize(self):
+ dim = Nondimensional()
+ dim._configure()
+ dim.initialize()
+
+ scale = 8.0*meter
+ value = 2.0*meter
+ valueE = 0.25
+
+ self.assertEqual(valueE, dim.nondimensionalize(value, scale))
+ return
+
+
+ def test_dimensionalize(self):
+ dim = Nondimensional()
+ dim._configure()
+ dim.initialize()
+
+ scale = 8.0*meter
+ value = 0.25
+ valueE = 2.0*meter
+
+ self.assertEqual(valueE, dim.dimensionalize(value, scale))
+ return
+
+
+# End of file
Modified: cs/spatialdata-0.1/trunk/tests/pytests/units/testunits.py
===================================================================
--- cs/spatialdata-0.1/trunk/tests/pytests/units/testunits.py 2008-11-27 22:11:02 UTC (rev 13419)
+++ cs/spatialdata-0.1/trunk/tests/pytests/units/testunits.py 2008-11-28 21:22:34 UTC (rev 13420)
@@ -16,8 +16,8 @@
suite = unittest.TestSuite()
- from TestNondimElastic import TestNondimElastic
- suite.addTest(unittest.makeSuite(TestNondimElastic))
+ from TestNondimensional import TestNondimensional
+ suite.addTest(unittest.makeSuite(TestNondimensional))
from TestNondimElasticQuasistatic import TestNondimElasticQuasistatic
suite.addTest(unittest.makeSuite(TestNondimElasticQuasistatic))
More information about the CIG-COMMITS
mailing list