[cig-commits] r18412 - in short/3D/PyLith/branches/multifields: . libsrc/pylith/bc libsrc/pylith/friction libsrc/pylith/topology modulesrc/bc modulesrc/friction modulesrc/topology unittests/libtests/bc unittests/libtests/faults unittests/libtests/feassemble unittests/libtests/friction unittests/libtests/materials unittests/libtests/meshio unittests/libtests/topology unittests/libtests/utils
brad at geodynamics.org
brad at geodynamics.org
Sat May 21 09:24:29 PDT 2011
Author: brad
Date: 2011-05-21 09:24:29 -0700 (Sat, 21 May 2011)
New Revision: 18412
Added:
short/3D/PyLith/branches/multifields/libsrc/pylith/topology/PackedFields.cc
short/3D/PyLith/branches/multifields/libsrc/pylith/topology/PackedFields.hh
short/3D/PyLith/branches/multifields/libsrc/pylith/topology/PackedFields.icc
short/3D/PyLith/branches/multifields/modulesrc/topology/PackedFields.i
short/3D/PyLith/branches/multifields/unittests/libtests/topology/TestPackedFieldsMesh.cc
short/3D/PyLith/branches/multifields/unittests/libtests/topology/TestPackedFieldsMesh.hh
Removed:
short/3D/PyLith/branches/multifields/libsrc/pylith/topology/FieldsNew.cc
short/3D/PyLith/branches/multifields/libsrc/pylith/topology/FieldsNew.hh
short/3D/PyLith/branches/multifields/libsrc/pylith/topology/FieldsNew.icc
short/3D/PyLith/branches/multifields/modulesrc/topology/FieldsNew.i
short/3D/PyLith/branches/multifields/unittests/libtests/topology/TestFieldsNewMesh.cc
short/3D/PyLith/branches/multifields/unittests/libtests/topology/TestFieldsNewMesh.hh
Modified:
short/3D/PyLith/branches/multifields/TODO
short/3D/PyLith/branches/multifields/libsrc/pylith/bc/AbsorbingDampers.cc
short/3D/PyLith/branches/multifields/libsrc/pylith/bc/BCIntegratorSubMesh.cc
short/3D/PyLith/branches/multifields/libsrc/pylith/bc/BCIntegratorSubMesh.hh
short/3D/PyLith/branches/multifields/libsrc/pylith/bc/BCIntegratorSubMesh.icc
short/3D/PyLith/branches/multifields/libsrc/pylith/bc/BoundaryConditionPoints.cc
short/3D/PyLith/branches/multifields/libsrc/pylith/bc/BoundaryConditionPoints.hh
short/3D/PyLith/branches/multifields/libsrc/pylith/bc/DirichletBC.cc
short/3D/PyLith/branches/multifields/libsrc/pylith/bc/DirichletBoundary.cc
short/3D/PyLith/branches/multifields/libsrc/pylith/bc/DirichletBoundary.hh
short/3D/PyLith/branches/multifields/libsrc/pylith/bc/Neumann.cc
short/3D/PyLith/branches/multifields/libsrc/pylith/bc/PointForce.cc
short/3D/PyLith/branches/multifields/libsrc/pylith/bc/TimeDependentPoints.cc
short/3D/PyLith/branches/multifields/libsrc/pylith/friction/FrictionModel.cc
short/3D/PyLith/branches/multifields/libsrc/pylith/friction/FrictionModel.hh
short/3D/PyLith/branches/multifields/libsrc/pylith/topology/Makefile.am
short/3D/PyLith/branches/multifields/libsrc/pylith/topology/topologyfwd.hh
short/3D/PyLith/branches/multifields/modulesrc/bc/BCIntegratorSubMesh.i
short/3D/PyLith/branches/multifields/modulesrc/bc/BoundaryConditionPoints.i
short/3D/PyLith/branches/multifields/modulesrc/friction/FrictionModel.i
short/3D/PyLith/branches/multifields/modulesrc/topology/Makefile.am
short/3D/PyLith/branches/multifields/modulesrc/topology/topology.i
short/3D/PyLith/branches/multifields/unittests/libtests/bc/Makefile.am
short/3D/PyLith/branches/multifields/unittests/libtests/bc/TestAbsorbingDampers.cc
short/3D/PyLith/branches/multifields/unittests/libtests/bc/TestDirichletBC.cc
short/3D/PyLith/branches/multifields/unittests/libtests/bc/TestNeumann.cc
short/3D/PyLith/branches/multifields/unittests/libtests/bc/TestPointForce.cc
short/3D/PyLith/branches/multifields/unittests/libtests/bc/TestTimeDependentPoints.cc
short/3D/PyLith/branches/multifields/unittests/libtests/faults/Makefile.am
short/3D/PyLith/branches/multifields/unittests/libtests/feassemble/Makefile.am
short/3D/PyLith/branches/multifields/unittests/libtests/friction/Makefile.am
short/3D/PyLith/branches/multifields/unittests/libtests/friction/TestFrictionModel.cc
short/3D/PyLith/branches/multifields/unittests/libtests/materials/Makefile.am
short/3D/PyLith/branches/multifields/unittests/libtests/meshio/Makefile.am
short/3D/PyLith/branches/multifields/unittests/libtests/topology/Makefile.am
short/3D/PyLith/branches/multifields/unittests/libtests/utils/Makefile.am
Log:
Merge from trunk. Changed FieldsNew -> PackedFields.
Modified: short/3D/PyLith/branches/multifields/TODO
===================================================================
--- short/3D/PyLith/branches/multifields/TODO 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/TODO 2011-05-21 16:24:29 UTC (rev 18412)
@@ -126,10 +126,11 @@
* Reimplement Fields to use a single section. [BRAD]
Fields
- FieldsNew -> CombinedFields
+ FieldsNew -> PackedFields
SolutionFields
- Use CombinedFields for acc, vel, disp(t+dt), disp(t), etc?
- Use Field for dispIncr(t->t+dt), residual(t)
+ Use Field for acc, vel, disp(t+dt), disp(t), etc?
+ Use Field for dispIncr(t->t+dt)
+ Use Field for residual(t)
* Cleanup
Modified: short/3D/PyLith/branches/multifields/libsrc/pylith/bc/AbsorbingDampers.cc
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/bc/AbsorbingDampers.cc 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/bc/AbsorbingDampers.cc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -20,7 +20,7 @@
#include "AbsorbingDampers.hh" // implementation of object methods
-#include "pylith/topology/FieldsNew.hh" // HOLDSA FieldsNew
+#include "pylith/topology/PackedFields.hh" // HOLDSA PackedFields
#include "pylith/topology/Field.hh" // USES Field
#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
#include "pylith/topology/Jacobian.hh" // USES Jacobian
@@ -108,7 +108,7 @@
delete _parameters;
_parameters =
- new topology::FieldsNew<topology::SubMesh>(*_boundaryMesh);
+ new topology::PackedFields<topology::SubMesh>(*_boundaryMesh);
assert(0 != _parameters);
_parameters->add("damping constants", "damping_constants", fiberDim);
_parameters->allocate(cells);
Modified: short/3D/PyLith/branches/multifields/libsrc/pylith/bc/BCIntegratorSubMesh.cc
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/bc/BCIntegratorSubMesh.cc 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/bc/BCIntegratorSubMesh.cc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -21,7 +21,7 @@
#include "BCIntegratorSubMesh.hh" // implementation of object methods
#include "pylith/topology/SubMesh.hh" // USES SubMesh
-#include "pylith/topology/FieldsNew.hh" // USES FieldsNew
+#include "pylith/topology/PackedFields.hh" // USES PackedFields
// ----------------------------------------------------------------------
typedef pylith::topology::SubMesh::SieveMesh SieveSubMesh;
Modified: short/3D/PyLith/branches/multifields/libsrc/pylith/bc/BCIntegratorSubMesh.hh
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/bc/BCIntegratorSubMesh.hh 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/bc/BCIntegratorSubMesh.hh 2011-05-21 16:24:29 UTC (rev 18412)
@@ -63,7 +63,7 @@
*
* @returns Parameter fields.
*/
- const topology::FieldsNew<topology::SubMesh>*
+ const topology::PackedFields<topology::SubMesh>*
parameterFields(void) const;
/** Get boundary mesh.
@@ -90,7 +90,7 @@
topology::SubMesh* _boundaryMesh; ///< Boundary mesh.
/// Parameters for boundary condition.
- topology::FieldsNew<topology::SubMesh>* _parameters;
+ topology::PackedFields<topology::SubMesh>* _parameters;
// NOT IMPLEMENTED ////////////////////////////////////////////////////
private :
Modified: short/3D/PyLith/branches/multifields/libsrc/pylith/bc/BCIntegratorSubMesh.icc
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/bc/BCIntegratorSubMesh.icc 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/bc/BCIntegratorSubMesh.icc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -24,7 +24,7 @@
// Get parameter fields.
inline
-const pylith::topology::FieldsNew<pylith::topology::SubMesh>*
+const pylith::topology::PackedFields<pylith::topology::SubMesh>*
pylith::bc::BCIntegratorSubMesh::parameterFields(void) const {
return _parameters;
} // parameterFields
Modified: short/3D/PyLith/branches/multifields/libsrc/pylith/bc/BoundaryConditionPoints.cc
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/bc/BoundaryConditionPoints.cc 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/bc/BoundaryConditionPoints.cc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -21,7 +21,7 @@
#include "BoundaryConditionPoints.hh" // implementation of object methods
#include "pylith/topology/Mesh.hh" // USES Mesh
-#include "pylith/topology/FieldsNew.hh" // HOLDSA FieldsNew
+#include "pylith/topology/PackedFields.hh" // HOLDSA PackedFields
#include "pylith/topology/Field.hh" // USES Field
#include <stdexcept> // USES std::runtime_error()
@@ -54,7 +54,7 @@
// ----------------------------------------------------------------------
// Get parameter fields.
-const pylith::topology::FieldsNew<pylith::topology::Mesh>*
+const pylith::topology::PackedFields<pylith::topology::Mesh>*
pylith::bc::BoundaryConditionPoints::parameterFields(void) const
{ // parameterFields
return _parameters;
Modified: short/3D/PyLith/branches/multifields/libsrc/pylith/bc/BoundaryConditionPoints.hh
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/bc/BoundaryConditionPoints.hh 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/bc/BoundaryConditionPoints.hh 2011-05-21 16:24:29 UTC (rev 18412)
@@ -30,7 +30,7 @@
// Include directives ---------------------------------------------------
#include "BoundaryCondition.hh" // ISA BoundaryCondition
-#include "pylith/topology/topologyfwd.hh" // HOLDSA FieldsNew
+#include "pylith/topology/topologyfwd.hh" // HOLDSA PackedFields
#include "pylith/utils/array.hh" // HASA int_array
// BoundaryConditionPoints ----------------------------------------------
@@ -59,7 +59,7 @@
*
* @returns Parameter fields.
*/
- const topology::FieldsNew<topology::Mesh>* parameterFields(void) const;
+ const topology::PackedFields<topology::Mesh>* parameterFields(void) const;
// PROTECTED METHODS //////////////////////////////////////////////////
protected :
@@ -74,7 +74,7 @@
protected :
/// Parameters for boundary condition.
- topology::FieldsNew<topology::Mesh>* _parameters;
+ topology::PackedFields<topology::Mesh>* _parameters;
int_array _points; ///< Points for boundary condition.
Modified: short/3D/PyLith/branches/multifields/libsrc/pylith/bc/DirichletBC.cc
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/bc/DirichletBC.cc 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/bc/DirichletBC.cc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -22,7 +22,7 @@
#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/topology/Field.hh" // USES Field
-#include "pylith/topology/FieldsNew.hh" // USES FieldsNew
+#include "pylith/topology/PackedFields.hh" // USES PackedFields
#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
Modified: short/3D/PyLith/branches/multifields/libsrc/pylith/bc/DirichletBoundary.cc
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/bc/DirichletBoundary.cc 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/bc/DirichletBoundary.cc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -23,7 +23,7 @@
#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/topology/SubMesh.hh" // USES SubMesh
#include "pylith/topology/Field.hh" // USES Field
-#include "pylith/topology/FieldsNew.hh" // USES FieldsNew
+#include "pylith/topology/PackedFields.hh" // USES PackedFields
#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
@@ -90,7 +90,7 @@
logger.stagePush("BoundaryConditions");
if (0 == _outputFields)
- _outputFields = new topology::FieldsNew<topology::SubMesh>(*_boundaryMesh);
+ _outputFields = new topology::PackedFields<topology::SubMesh>(*_boundaryMesh);
assert(0 != _outputFields);
_outputFields->add("buffer (vector)", "buffer_vector",
spaceDim,
Modified: short/3D/PyLith/branches/multifields/libsrc/pylith/bc/DirichletBoundary.hh
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/bc/DirichletBoundary.hh 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/bc/DirichletBoundary.hh 2011-05-21 16:24:29 UTC (rev 18412)
@@ -107,7 +107,7 @@
topology::SubMesh* _boundaryMesh; ///< Boundary mesh.
/// Fields manager (holds temporary field for output).
- topology::FieldsNew<topology::SubMesh>* _outputFields;
+ topology::PackedFields<topology::SubMesh>* _outputFields;
// NOT IMPLEMENTED ////////////////////////////////////////////////////
private :
Modified: short/3D/PyLith/branches/multifields/libsrc/pylith/bc/Neumann.cc
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/bc/Neumann.cc 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/bc/Neumann.cc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -21,7 +21,7 @@
#include "Neumann.hh" // implementation of object methods
#include "pylith/topology/SubMesh.hh" // USES SubMesh
-#include "pylith/topology/FieldsNew.hh" // HOLDSA FieldsNew
+#include "pylith/topology/PackedFields.hh" // HOLDSA PackedFields
#include "pylith/topology/Field.hh" // USES Field
#include "pylith/topology/Fields.hh" // USES Fields
#include "spatialdata/spatialdb/SpatialDB.hh" // USES SpatialDB
@@ -245,7 +245,7 @@
delete _parameters;
_parameters =
- new topology::FieldsNew<topology::SubMesh>(*_boundaryMesh);
+ new topology::PackedFields<topology::SubMesh>(*_boundaryMesh);
// Create section to hold time dependent values
_parameters->add("value", "traction",
Modified: short/3D/PyLith/branches/multifields/libsrc/pylith/bc/PointForce.cc
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/bc/PointForce.cc 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/bc/PointForce.cc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -21,7 +21,7 @@
#include "PointForce.hh" // implementation of object methods
#include "pylith/topology/Field.hh" // USES Field
-#include "pylith/topology/FieldsNew.hh" // USES FieldsNew
+#include "pylith/topology/PackedFields.hh" // USES PackedFields
#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
Modified: short/3D/PyLith/branches/multifields/libsrc/pylith/bc/TimeDependentPoints.cc
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/bc/TimeDependentPoints.cc 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/bc/TimeDependentPoints.cc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -22,7 +22,7 @@
#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/topology/Field.hh" // USES Field
-#include "pylith/topology/FieldsNew.hh" // USES FieldsNew
+#include "pylith/topology/PackedFields.hh" // USES PackedFields
#include "spatialdata/spatialdb/SpatialDB.hh" // USES SpatialDB
#include "spatialdata/spatialdb/TimeHistory.hh" // USES TimeHistory
#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
@@ -119,7 +119,7 @@
logger.stagePush("BoundaryConditions");
delete _parameters;
- _parameters = new topology::FieldsNew<topology::Mesh>(mesh);
+ _parameters = new topology::PackedFields<topology::Mesh>(mesh);
_parameters->add("value", "value", numBCDOF, topology::FieldBase::OTHER,
valueScale);
Modified: short/3D/PyLith/branches/multifields/libsrc/pylith/friction/FrictionModel.cc
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/friction/FrictionModel.cc 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/friction/FrictionModel.cc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -22,7 +22,7 @@
#include "pylith/topology/SubMesh.hh" // USES Mesh
#include "pylith/topology/Field.hh" // USES Field
-#include "pylith/topology/FieldsNew.hh" // USES FieldsNew
+#include "pylith/topology/PackedFields.hh" // USES PackedFields
#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/utils/array.hh" // USES double_array, std::vector
@@ -43,7 +43,7 @@
typedef pylith::topology::SubMesh::RealUniformSection SubRealUniformSection;
typedef pylith::topology::Field<pylith::topology::SubMesh>::RestrictVisitor RestrictVisitor;
-typedef pylith::topology::FieldsNew<pylith::topology::SubMesh>::UpdateAddVisitor UpdateAddVisitor;
+typedef pylith::topology::PackedFields<pylith::topology::SubMesh>::UpdateAddVisitor UpdateAddVisitor;
// ----------------------------------------------------------------------
// Default constructor.
@@ -131,7 +131,7 @@
// Create fields to hold physical properties and state variables.
delete _fieldsPropsStateVars;
- _fieldsPropsStateVars = new topology::FieldsNew<topology::SubMesh>(faultMesh);
+ _fieldsPropsStateVars = new topology::PackedFields<topology::SubMesh>(faultMesh);
assert(_fieldsPropsStateVars);
_setupPropsStateVars();
@@ -245,7 +245,7 @@
// ----------------------------------------------------------------------
// Get the field with all properties and state variables.
-const pylith::topology::FieldsNew<pylith::topology::SubMesh>&
+const pylith::topology::PackedFields<pylith::topology::SubMesh>&
pylith::friction::FrictionModel::fieldsPropsStateVars(void) const
{ // fieldsPropsStateVars
assert(_fieldsPropsStateVars);
Modified: short/3D/PyLith/branches/multifields/libsrc/pylith/friction/FrictionModel.hh
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/friction/FrictionModel.hh 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/friction/FrictionModel.hh 2011-05-21 16:24:29 UTC (rev 18412)
@@ -145,7 +145,7 @@
*
* @returns Properties field.
*/
- const topology::FieldsNew<topology::SubMesh>& fieldsPropsStateVars() const;
+ const topology::PackedFields<topology::SubMesh>& fieldsPropsStateVars() const;
/** Retrieve properties and state variables for a point.
*
@@ -309,7 +309,7 @@
/// Field containing physical properties and state variables of
/// friction model.
- topology::FieldsNew<topology::SubMesh>* _fieldsPropsStateVars;
+ topology::PackedFields<topology::SubMesh>* _fieldsPropsStateVars;
/// Buffer for properties and state variables at vertex.
double_array _propsStateVarsVertex;
Deleted: short/3D/PyLith/branches/multifields/libsrc/pylith/topology/FieldsNew.cc
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/topology/FieldsNew.cc 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/topology/FieldsNew.cc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -1,372 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#include <sstream> // USES std::ostringstream
-#include <stdexcept> // USES std::runtime_error
-
-// ----------------------------------------------------------------------
-// Default constructor.
-template<typename mesh_type>
-pylith::topology::FieldsNew<mesh_type>::FieldsNew(const mesh_type& mesh) :
- _mesh(mesh)
-{ // constructor
-} // constructor
-
-// ----------------------------------------------------------------------
-// Destructor.
-template<typename mesh_type>
-pylith::topology::FieldsNew<mesh_type>::~FieldsNew(void)
-{ // destructor
- deallocate();
-} // destructor
-
-// ----------------------------------------------------------------------
-// Deallocate PETSc and local data structures.
-template<typename mesh_type>
-void
-pylith::topology::FieldsNew<mesh_type>::deallocate(void)
-{ // deallocate
- if (!_section.isNull())
- _section->clear();
-
- const typename map_type::const_iterator fieldsEnd = _fields.end();
- for (typename map_type::iterator f_iter = _fields.begin();
- f_iter != fieldsEnd;
- ++f_iter) {
- delete f_iter->second.field; f_iter->second.field = 0;
- } // for
-} // deallocate
-
-// ----------------------------------------------------------------------
-// Add field.
-template<typename mesh_type>
-void
-pylith::topology::FieldsNew<mesh_type>::add(const char* name,
- const char* label,
- const int fiberDim,
- const FieldBase::VectorFieldEnum vectorFieldType,
- const double scale,
- const bool dimsOkay)
-{ // add
- if (hasField(name)) {
- std::ostringstream msg;
- msg << "Could not add field '" << name
- << "' to fields manager, because it already exists.";
- throw std::runtime_error(msg.str());
- } // if
-
- // Set metadata
- FieldInfo info;
- info.metadata.label = label;
- info.metadata.vectorFieldType = vectorFieldType;
- info.metadata.scale = scale;
- info.metadata.dimsOkay = dimsOkay;
-
- // Set fibration and fiber dimension
- info.fibration = _fields.size();
- info.fiberDim = fiberDim;
- int sindex = 0;
- const typename map_type::const_iterator fieldsEnd = _fields.end();
- for (typename map_type::iterator f_iter=_fields.begin();
- f_iter != fieldsEnd;
- ++f_iter)
- sindex += f_iter->second.fiberDim;
- info.sindex = sindex;
-
- info.field = 0;
-
- _fields[name] = info;
-} // add
-
-// ----------------------------------------------------------------------
-// Create and allocate Sieve section.
-template<typename mesh_type>
-void
-pylith::topology::FieldsNew<mesh_type>::allocate(const ALE::Obj<typename mesh_type::SieveMesh::label_sequence>& points)
-{ // allocate
- typedef typename mesh_type::SieveMesh::point_type point_type;
- typedef typename mesh_type::SieveMesh::label_sequence label_sequence;
-
- ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
- logger.stagePush("Fields");
-
- // Set fiber dimension
- const int dim = fiberDim();
- assert(dim > 0);
- _section = new section_type(_mesh.comm(), _mesh.debug());
- assert(!_section.isNull());
-
- assert(!points.isNull());
- if (points->size() > 0) {
- const point_type pointMin =
- *std::min_element(points->begin(), points->end());
- const point_type pointMax =
- *std::max_element(points->begin(), points->end());
- _section->setChart(typename section_type::chart_type(pointMin, pointMax+1));
- const typename label_sequence::const_iterator pointsEnd = points->end();
- for (typename label_sequence::const_iterator p_iter = points->begin();
- p_iter != pointsEnd;
- ++p_iter)
- _section->setFiberDimension(*p_iter, dim);
-
- } else // Create empty chart
- _section->setChart(typename section_type::chart_type(0, 0));
-
- // Set spaces
- const typename map_type::const_iterator fieldsEnd = _fields.end();
- for (typename map_type::iterator f_iter=_fields.begin();
- f_iter != fieldsEnd;
- ++f_iter)
- _section->addSpace();
- for (typename map_type::iterator f_iter=_fields.begin();
- f_iter != fieldsEnd;
- ++f_iter)
- _section->spaceFiberDimension(f_iter->second.fibration,
- f_iter->second.fiberDim);
- // Allocate section
- const ALE::Obj<typename mesh_type::SieveMesh>& sieveMesh = _mesh.sieveMesh();
- assert(!sieveMesh.isNull());
- sieveMesh->allocate(_section);
-
- logger.stagePop();
-} // allocate
-
-// ----------------------------------------------------------------------
-// Create and allocate Sieve section.
-template<typename mesh_type>
-void
-pylith::topology::FieldsNew<mesh_type>::allocate(const int_array& points)
-{ // allocate
- typedef typename mesh_type::SieveMesh::point_type point_type;
-
- ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
- logger.stagePush("Field");
-
- // Set fiber dimension
- const int dim = fiberDim();
- assert(dim > 0);
- _section = new section_type(_mesh.comm(), _mesh.debug());
- assert(!_section.isNull());
-
- const int npts = points.size();
- if (npts > 0) {
- const point_type pointMin = points.min();
- const point_type pointMax = points.max();
- _section->setChart(typename section_type::chart_type(pointMin, pointMax+1));
- for (int i=0; i < npts; ++i)
- _section->setFiberDimension(points[i], dim);
-
- } else // create empty chart
- _section->setChart(typename section_type::chart_type(0, 0));
-
- // Set spaces
- const typename map_type::const_iterator fieldsEnd = _fields.end();
- for (typename map_type::iterator f_iter=_fields.begin();
- f_iter != fieldsEnd;
- ++f_iter)
- _section->addSpace();
- for (typename map_type::iterator f_iter=_fields.begin();
- f_iter != fieldsEnd;
- ++f_iter)
- _section->spaceFiberDimension(f_iter->second.fibration,
- f_iter->second.fiberDim);
-
- // Allocate section
- const ALE::Obj<typename mesh_type::SieveMesh>& sieveMesh = _mesh.sieveMesh();
- assert(!sieveMesh.isNull());
- sieveMesh->allocate(_section);
-
- logger.stagePop();
-} // allocate
-
-// ----------------------------------------------------------------------
-// Create and allocate Sieve section.
-template<typename mesh_type>
-void
-pylith::topology::FieldsNew<mesh_type>::allocate(const FieldBase::DomainEnum domain,
- const int stratum)
-{ // allocate
- const ALE::Obj<typename mesh_type::SieveMesh>& sieveMesh = _mesh.sieveMesh();
- assert(!sieveMesh.isNull());
-
- ALE::Obj<typename mesh_type::SieveMesh::label_sequence> points;
- if (FieldBase::VERTICES_FIELD == domain)
- points = sieveMesh->depthStratum(stratum);
- else if (FieldBase::CELLS_FIELD == domain)
- points = sieveMesh->heightStratum(stratum);
- else {
- std::cerr << "Unknown value for DomainEnum: " << domain << std::endl;
- assert(0);
- throw std::logic_error("Bad domain enum in Field.");
- } // else
-
- allocate(points);
-} // allocate
-
-// ----------------------------------------------------------------------
-// Get field.
-template<typename mesh_type>
-pylith::topology::Field<mesh_type>&
-pylith::topology::FieldsNew<mesh_type>::get(const char* name)
-{ // get
- typename map_type::iterator f_iter = _fields.find(name);
- if (f_iter == _fields.end()) {
- std::ostringstream msg;
- msg << "Could not find field '" << name
- << "' in fields manager for retrieval.";
- throw std::runtime_error(msg.str());
- } // if
- const int fibration = f_iter->second.fibration;
- assert(fibration >= 0 && fibration < _fields.size());
-
- if (!f_iter->second.field) {
- delete f_iter->second.field; f_iter->second.field = 0;
- assert(!_section.isNull());
- f_iter->second.field =
- new Field<mesh_type>(_mesh, _section->getFibration(fibration),
- f_iter->second.metadata);
- assert(0 != f_iter->second.field);
- } // if
-
- return *f_iter->second.field;
-} // get
-
-// ----------------------------------------------------------------------
-// Compute total fiber dimension for section.
-template<typename mesh_type>
-int
-pylith::topology::FieldsNew<mesh_type>::fiberDim(void) const
-{ // fiberDim
- int fiberDim = 0;
- const typename map_type::const_iterator fieldsEnd = _fields.end();
- for (typename map_type::const_iterator f_iter=_fields.begin();
- f_iter != fieldsEnd;
- ++f_iter)
- fiberDim += f_iter->second.fiberDim;
-
- if (fiberDim < 0) {
- std::ostringstream msg;
- msg << "Fiber dimension (" << fiberDim << ") for Fields object must "
- << "be nonnegative.";
- throw std::runtime_error(msg.str());
- } // if
-
-
- return fiberDim;
-} // fiberDim
-
-// ----------------------------------------------------------------------
-// Get index of first value of field in section.
-template<typename mesh_type>
-int
-pylith::topology::FieldsNew<mesh_type>::sectionIndex(const char* name) const
-{ // sectionIndex
- typename map_type::const_iterator f_iter = _fields.find(name);
- if (f_iter == _fields.end()) {
- std::ostringstream msg;
- msg << "Could not find field '" << name
- << "' in fields manager for retrieval of section index.";
- throw std::runtime_error(msg.str());
- } // if
-
- return f_iter->second.sindex;
-} // sectionIndex
-
-// ----------------------------------------------------------------------
-// Get fiber dimension of field in section.
-template<typename mesh_type>
-int
-pylith::topology::FieldsNew<mesh_type>::sectionFiberDim(const char* name) const
-{ // sectionFiberDim
- typename map_type::const_iterator f_iter = _fields.find(name);
- if (f_iter == _fields.end()) {
- std::ostringstream msg;
- msg << "Could not find field '" << name
- << "' in fields manager for retrieval of section index.";
- throw std::runtime_error(msg.str());
- } // if
-
- return f_iter->second.fiberDim;
-} // sectionFiberDim
-
-// ----------------------------------------------------------------------
-// Complete section by assembling across processors.
-template<typename mesh_type>
-void
-pylith::topology::FieldsNew<mesh_type>::complete(void)
-{ // complete
- ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
- logger.stagePush("Completion");
-
- const ALE::Obj<typename mesh_type::SieveMesh>& sieveMesh = _mesh.sieveMesh();
- assert(!sieveMesh.isNull());
-
- if (!_section.isNull())
- ALE::Completion::completeSectionAdd(sieveMesh->getSendOverlap(),
- sieveMesh->getRecvOverlap(),
- _section, _section);
-
- logger.stagePop();
-} // complete
-
-// ----------------------------------------------------------------------
-// Get names of all fields
-template<typename mesh_type>
-void
-pylith::topology::FieldsNew<mesh_type>::fieldNames(int *numNames,
- char*** names) const
-{ // fieldNames
- assert(numNames);
- assert(names);
-
- *numNames = _fields.size();
- *names = new char*[_fields.size()];
- assert(*names);
- const typename map_type::const_iterator namesEnd = _fields.end();
- int i = 0;
- for (typename map_type::const_iterator name = _fields.begin();
- name != namesEnd;
- ++name) {
- const char len = name->first.length();
- char* newName = 0;
- if (len > 0) {
- newName = new char[len+1];
- strncpy(newName, name->first.c_str(), len+1);
- } else {
- newName = new char[1];
- newName[0] ='\0';
- } // if/else
- (*names)[i++] = newName;
- } // for
-} // fieldNames
-
-// ----------------------------------------------------------------------
-// View fields and section.
-template<typename mesh_type>
-void
-pylith::topology::FieldsNew<mesh_type>::view(const char* label)
-{ // view
- std::cout << "Fields '" << label << "':\n";
- const typename map_type::const_iterator fieldsEnd = _fields.end();
- for (typename map_type::const_iterator f_iter = _fields.begin();
- f_iter != fieldsEnd;
- ++f_iter)
- std::cout << " Field: " << f_iter->first
- << ", fibration: " << f_iter->second.fibration
- << ", fiber dim: " << f_iter->second.fiberDim
- << ", first value index: " << f_iter->second.sindex
- << std::endl;
- _section->view("Section");
-} // view
-
-
-// End of file
Deleted: short/3D/PyLith/branches/multifields/libsrc/pylith/topology/FieldsNew.hh
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/topology/FieldsNew.hh 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/topology/FieldsNew.hh 2011-05-21 16:24:29 UTC (rev 18412)
@@ -1,208 +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 University of California, Davis
-//
-// See COPYING for license information.
-//
-// ======================================================================
-//
-
-/**
- * @file libsrc/topology/Fields.hh
- *
- * @brief Set of real fields over a finite-element mesh. All fields are
- * associated with the same points. We use uniform sections so the
- * fiber dimension is set at compile time.
- */
-
-#if !defined(pylith_topology_fieldsnew_hh)
-#define pylith_topology_fieldsnew_hh
-
-// Include directives ---------------------------------------------------
-#include "topologyfwd.hh" // forward declarations
-
-#include "pylith/topology/FieldBase.hh" // USES FieldBase::Metadata
-
-#include <string> // USES std::string
-
-// Fields ---------------------------------------------------------------
-/// Container for managing multiple fields over a finite-element mesh.
-template<typename mesh_type>
-class pylith::topology::FieldsNew
-{ // Fields
- friend class TestFieldsNewMesh; // unit testing
- friend class TestFieldsNewSubMesh; // unit testing
-
-// PUBLIC TYPEDEFS //////////////////////////////////////////////////////
-public:
-
- // Convenience typedefs
- typedef typename mesh_type::RealUniformSection section_type;
-
- typedef ALE::ISieveVisitor::RestrictVisitor<section_type> RestrictVisitor;
- typedef ALE::ISieveVisitor::UpdateAddVisitor<section_type> UpdateAddVisitor;
- typedef ALE::ISieveVisitor::UpdateAllVisitor<section_type> UpdateAllVisitor;
-
-// PUBLIC MEMBERS ///////////////////////////////////////////////////////
-public :
-
- /** Default constructor.
- *
- * @param mesh Finite-element mesh.
- */
- FieldsNew(const mesh_type& mesh);
-
- /// Destructor.
- virtual
- ~FieldsNew(void);
-
- /// Deallocate PETSc and local data structures.
- virtual
- void deallocate(void);
-
- /** Check if fields contains a given field.
- *
- * @param name Name of field.
- * @return True if fields contains field, false otherwise.
- */
- bool hasField(const char* name) const;
-
- /** Add field.
- *
- * @param name Name of field.
- * @param label Label for field.
- * @param fiberDim Fiber dimension for field.
- */
- void add(const char* name,
- const char* label,
- const int fiberDim,
- FieldBase::VectorFieldEnum vectorFieldType =FieldBase::OTHER,
- const double scale =1.0,
- const bool dimsOkay =false);
-
- /** Create and allocate Sieve section.
- *
- * @param points Points over which to define section.
- */
- void allocate(const ALE::Obj<typename mesh_type::SieveMesh::label_sequence>& points);
-
- /** Create and allocate Sieve section.
- *
- * @param points Points over which to define section.
- */
- void allocate(const int_array& points);
-
- /** Create and allocate Sieve section.
- *
- * @param domain Type of points over which to define section.
- * @param stratum Stratum depth (for vertices) and height (for cells).
- */
- void allocate(const FieldBase::DomainEnum domain,
- const int stratum =0);
-
- /** Get field.
- *
- * @param name Name of field.
- * @returns Field.
- */
- Field<mesh_type>& get(const char* name);
-
- /** Get mesh associated with fields.
- *
- * @returns Finite-element mesh.
- */
- const mesh_type& mesh(void) const;
-
- /** Get section containing fields.
- *
- * @returns Sieve section
- */
- const ALE::Obj<section_type>& section(void) const;
-
- /** Compute total fiber dimension for section.
- *
- * @returns Fiber dimension.
- */
- int fiberDim(void) const;
-
- /** Get index of first value of field in section.
- *
- * @param name Name of field.
- * @returns Index of first value of field in section.
- */
- int sectionIndex(const char* name) const;
-
- /** Get fiber dimension of field in section.
- *
- * @param name Name of field.
- * @returns Fiber dimension of field in section.
- */
- int sectionFiberDim(const char* name) const;
-
- /// Complete section by assembling across processors.
- void complete(void);
-
- /** Return the names of all fields.
- *
- * @param numNames Number of fields,
- * @param names Names of fields.
- */
- void fieldNames(int* numNames,
- char*** names) const;
-
- /** View fields and section.
- *
- * @param label Label for fields.
- */
- void view(const char* label);
-
-// PROTECTED STRUCTS ////////////////////////////////////////////////////
-protected :
-
- struct FieldInfo {
- FieldBase::Metadata metadata; ///< Metadata for field.
- Field<mesh_type>* field; ///< Single field.
- int fiberDim; ///< Fiber dimension of field.
- int fibration; ///< Index of fibration associated with field.
- int sindex; ///< Index of first value of field in section.
- }; // FieldInfo
-
-// PROTECTED TYPEDEFS ///////////////////////////////////////////////////
-protected :
-
- typedef std::map<std::string, FieldInfo> map_type;
-
-// PROTECTED METHODS ////////////////////////////////////////////////////
-protected :
-
-// PROTECTED MEMBERS ////////////////////////////////////////////////////
-protected :
-
- map_type _fields; ///< Fields without constraints over a common set of points.
- ALE::Obj<section_type> _section; ///< Section containing fields.
- const mesh_type& _mesh; ///< Mesh associated with fields.
-
-// NOT IMPLEMENTED //////////////////////////////////////////////////////
-private :
-
- FieldsNew(const FieldsNew&); ///< Not implemented
- const FieldsNew& operator=(const FieldsNew&); ///< Not implemented
-
-}; // FieldsNew
-
-#include "FieldsNew.icc"
-#include "FieldsNew.cc"
-
-#endif // pylith_topology_fieldsnew_hh
-
-
-// End of file
Deleted: short/3D/PyLith/branches/multifields/libsrc/pylith/topology/FieldsNew.icc
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/topology/FieldsNew.icc 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/topology/FieldsNew.icc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -1,49 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#if !defined(pylith_topology_fieldsnew_hh)
-#error "FieldsNew.icc must be included only from FieldsNew.hh"
-#endif
-
-// ----------------------------------------------------------------------
-// Check if fields contains a given field.
-template<typename mesh_type>
-inline
-bool
-pylith::topology::FieldsNew<mesh_type>::hasField(const char* name) const
-{ // hasField
- typename map_type::const_iterator iter = _fields.find(name);
- return iter != _fields.end();
-} // hasField
-
-// ----------------------------------------------------------------------
-// Get mesh associated with fields.
-template<typename mesh_type>
-inline
-const mesh_type&
-pylith::topology::FieldsNew<mesh_type>::mesh(void) const
-{ // mesh
- return _mesh;
-} // mesh
-
-// ----------------------------------------------------------------------
-// Get section containing fields.
-template<typename mesh_type>
-inline
-const ALE::Obj<typename pylith::topology::FieldsNew<mesh_type>::section_type>&
-pylith::topology::FieldsNew<mesh_type>::section(void) const
-{ // section
- return _section;
-} // section
-
-
-// End of file
Modified: short/3D/PyLith/branches/multifields/libsrc/pylith/topology/Makefile.am
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/topology/Makefile.am 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/topology/Makefile.am 2011-05-21 16:24:29 UTC (rev 18412)
@@ -27,9 +27,9 @@
Field.cc \
Fields.hh \
Fields.icc \
- FieldsNew.hh \
- FieldsNew.icc \
- FieldsNew.cc \
+ PackedFields.hh \
+ PackedFields.icc \
+ PackedFields.cc \
Jacobian.hh \
Mesh.hh \
Mesh.icc \
Copied: short/3D/PyLith/branches/multifields/libsrc/pylith/topology/PackedFields.cc (from rev 18409, short/3D/PyLith/branches/multifields/libsrc/pylith/topology/FieldsNew.cc)
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/topology/PackedFields.cc (rev 0)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/topology/PackedFields.cc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -0,0 +1,372 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include <sstream> // USES std::ostringstream
+#include <stdexcept> // USES std::runtime_error
+
+// ----------------------------------------------------------------------
+// Default constructor.
+template<typename mesh_type>
+pylith::topology::PackedFields<mesh_type>::PackedFields(const mesh_type& mesh) :
+ _mesh(mesh)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor.
+template<typename mesh_type>
+pylith::topology::PackedFields<mesh_type>::~PackedFields(void)
+{ // destructor
+ deallocate();
+} // destructor
+
+// ----------------------------------------------------------------------
+// Deallocate PETSc and local data structures.
+template<typename mesh_type>
+void
+pylith::topology::PackedFields<mesh_type>::deallocate(void)
+{ // deallocate
+ if (!_section.isNull())
+ _section->clear();
+
+ const typename map_type::const_iterator fieldsEnd = _fields.end();
+ for (typename map_type::iterator f_iter = _fields.begin();
+ f_iter != fieldsEnd;
+ ++f_iter) {
+ delete f_iter->second.field; f_iter->second.field = 0;
+ } // for
+} // deallocate
+
+// ----------------------------------------------------------------------
+// Add field.
+template<typename mesh_type>
+void
+pylith::topology::PackedFields<mesh_type>::add(const char* name,
+ const char* label,
+ const int fiberDim,
+ const FieldBase::VectorFieldEnum vectorFieldType,
+ const double scale,
+ const bool dimsOkay)
+{ // add
+ if (hasField(name)) {
+ std::ostringstream msg;
+ msg << "Could not add field '" << name
+ << "' to fields manager, because it already exists.";
+ throw std::runtime_error(msg.str());
+ } // if
+
+ // Set metadata
+ FieldInfo info;
+ info.metadata.label = label;
+ info.metadata.vectorFieldType = vectorFieldType;
+ info.metadata.scale = scale;
+ info.metadata.dimsOkay = dimsOkay;
+
+ // Set fibration and fiber dimension
+ info.fibration = _fields.size();
+ info.fiberDim = fiberDim;
+ int sindex = 0;
+ const typename map_type::const_iterator fieldsEnd = _fields.end();
+ for (typename map_type::iterator f_iter=_fields.begin();
+ f_iter != fieldsEnd;
+ ++f_iter)
+ sindex += f_iter->second.fiberDim;
+ info.sindex = sindex;
+
+ info.field = 0;
+
+ _fields[name] = info;
+} // add
+
+// ----------------------------------------------------------------------
+// Create and allocate Sieve section.
+template<typename mesh_type>
+void
+pylith::topology::PackedFields<mesh_type>::allocate(const ALE::Obj<typename mesh_type::SieveMesh::label_sequence>& points)
+{ // allocate
+ typedef typename mesh_type::SieveMesh::point_type point_type;
+ typedef typename mesh_type::SieveMesh::label_sequence label_sequence;
+
+ ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
+ logger.stagePush("Fields");
+
+ // Set fiber dimension
+ const int dim = fiberDim();
+ assert(dim > 0);
+ _section = new section_type(_mesh.comm(), _mesh.debug());
+ assert(!_section.isNull());
+
+ assert(!points.isNull());
+ if (points->size() > 0) {
+ const point_type pointMin =
+ *std::min_element(points->begin(), points->end());
+ const point_type pointMax =
+ *std::max_element(points->begin(), points->end());
+ _section->setChart(typename section_type::chart_type(pointMin, pointMax+1));
+ const typename label_sequence::const_iterator pointsEnd = points->end();
+ for (typename label_sequence::const_iterator p_iter = points->begin();
+ p_iter != pointsEnd;
+ ++p_iter)
+ _section->setFiberDimension(*p_iter, dim);
+
+ } else // Create empty chart
+ _section->setChart(typename section_type::chart_type(0, 0));
+
+ // Set spaces
+ const typename map_type::const_iterator fieldsEnd = _fields.end();
+ for (typename map_type::iterator f_iter=_fields.begin();
+ f_iter != fieldsEnd;
+ ++f_iter)
+ _section->addSpace();
+ for (typename map_type::iterator f_iter=_fields.begin();
+ f_iter != fieldsEnd;
+ ++f_iter)
+ _section->spaceFiberDimension(f_iter->second.fibration,
+ f_iter->second.fiberDim);
+ // Allocate section
+ const ALE::Obj<typename mesh_type::SieveMesh>& sieveMesh = _mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ sieveMesh->allocate(_section);
+
+ logger.stagePop();
+} // allocate
+
+// ----------------------------------------------------------------------
+// Create and allocate Sieve section.
+template<typename mesh_type>
+void
+pylith::topology::PackedFields<mesh_type>::allocate(const int_array& points)
+{ // allocate
+ typedef typename mesh_type::SieveMesh::point_type point_type;
+
+ ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
+ logger.stagePush("Field");
+
+ // Set fiber dimension
+ const int dim = fiberDim();
+ assert(dim > 0);
+ _section = new section_type(_mesh.comm(), _mesh.debug());
+ assert(!_section.isNull());
+
+ const int npts = points.size();
+ if (npts > 0) {
+ const point_type pointMin = points.min();
+ const point_type pointMax = points.max();
+ _section->setChart(typename section_type::chart_type(pointMin, pointMax+1));
+ for (int i=0; i < npts; ++i)
+ _section->setFiberDimension(points[i], dim);
+
+ } else // create empty chart
+ _section->setChart(typename section_type::chart_type(0, 0));
+
+ // Set spaces
+ const typename map_type::const_iterator fieldsEnd = _fields.end();
+ for (typename map_type::iterator f_iter=_fields.begin();
+ f_iter != fieldsEnd;
+ ++f_iter)
+ _section->addSpace();
+ for (typename map_type::iterator f_iter=_fields.begin();
+ f_iter != fieldsEnd;
+ ++f_iter)
+ _section->spaceFiberDimension(f_iter->second.fibration,
+ f_iter->second.fiberDim);
+
+ // Allocate section
+ const ALE::Obj<typename mesh_type::SieveMesh>& sieveMesh = _mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ sieveMesh->allocate(_section);
+
+ logger.stagePop();
+} // allocate
+
+// ----------------------------------------------------------------------
+// Create and allocate Sieve section.
+template<typename mesh_type>
+void
+pylith::topology::PackedFields<mesh_type>::allocate(const FieldBase::DomainEnum domain,
+ const int stratum)
+{ // allocate
+ const ALE::Obj<typename mesh_type::SieveMesh>& sieveMesh = _mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+
+ ALE::Obj<typename mesh_type::SieveMesh::label_sequence> points;
+ if (FieldBase::VERTICES_FIELD == domain)
+ points = sieveMesh->depthStratum(stratum);
+ else if (FieldBase::CELLS_FIELD == domain)
+ points = sieveMesh->heightStratum(stratum);
+ else {
+ std::cerr << "Unknown value for DomainEnum: " << domain << std::endl;
+ assert(0);
+ throw std::logic_error("Bad domain enum in Field.");
+ } // else
+
+ allocate(points);
+} // allocate
+
+// ----------------------------------------------------------------------
+// Get field.
+template<typename mesh_type>
+pylith::topology::Field<mesh_type>&
+pylith::topology::PackedFields<mesh_type>::get(const char* name)
+{ // get
+ typename map_type::iterator f_iter = _fields.find(name);
+ if (f_iter == _fields.end()) {
+ std::ostringstream msg;
+ msg << "Could not find field '" << name
+ << "' in fields manager for retrieval.";
+ throw std::runtime_error(msg.str());
+ } // if
+ const int fibration = f_iter->second.fibration;
+ assert(fibration >= 0 && fibration < _fields.size());
+
+ if (!f_iter->second.field) {
+ delete f_iter->second.field; f_iter->second.field = 0;
+ assert(!_section.isNull());
+ f_iter->second.field =
+ new Field<mesh_type>(_mesh, _section->getFibration(fibration),
+ f_iter->second.metadata);
+ assert(0 != f_iter->second.field);
+ } // if
+
+ return *f_iter->second.field;
+} // get
+
+// ----------------------------------------------------------------------
+// Compute total fiber dimension for section.
+template<typename mesh_type>
+int
+pylith::topology::PackedFields<mesh_type>::fiberDim(void) const
+{ // fiberDim
+ int fiberDim = 0;
+ const typename map_type::const_iterator fieldsEnd = _fields.end();
+ for (typename map_type::const_iterator f_iter=_fields.begin();
+ f_iter != fieldsEnd;
+ ++f_iter)
+ fiberDim += f_iter->second.fiberDim;
+
+ if (fiberDim < 0) {
+ std::ostringstream msg;
+ msg << "Fiber dimension (" << fiberDim << ") for Fields object must "
+ << "be nonnegative.";
+ throw std::runtime_error(msg.str());
+ } // if
+
+
+ return fiberDim;
+} // fiberDim
+
+// ----------------------------------------------------------------------
+// Get index of first value of field in section.
+template<typename mesh_type>
+int
+pylith::topology::PackedFields<mesh_type>::sectionIndex(const char* name) const
+{ // sectionIndex
+ typename map_type::const_iterator f_iter = _fields.find(name);
+ if (f_iter == _fields.end()) {
+ std::ostringstream msg;
+ msg << "Could not find field '" << name
+ << "' in fields manager for retrieval of section index.";
+ throw std::runtime_error(msg.str());
+ } // if
+
+ return f_iter->second.sindex;
+} // sectionIndex
+
+// ----------------------------------------------------------------------
+// Get fiber dimension of field in section.
+template<typename mesh_type>
+int
+pylith::topology::PackedFields<mesh_type>::sectionFiberDim(const char* name) const
+{ // sectionFiberDim
+ typename map_type::const_iterator f_iter = _fields.find(name);
+ if (f_iter == _fields.end()) {
+ std::ostringstream msg;
+ msg << "Could not find field '" << name
+ << "' in fields manager for retrieval of section index.";
+ throw std::runtime_error(msg.str());
+ } // if
+
+ return f_iter->second.fiberDim;
+} // sectionFiberDim
+
+// ----------------------------------------------------------------------
+// Complete section by assembling across processors.
+template<typename mesh_type>
+void
+pylith::topology::PackedFields<mesh_type>::complete(void)
+{ // complete
+ ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
+ logger.stagePush("Completion");
+
+ const ALE::Obj<typename mesh_type::SieveMesh>& sieveMesh = _mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+
+ if (!_section.isNull())
+ ALE::Completion::completeSectionAdd(sieveMesh->getSendOverlap(),
+ sieveMesh->getRecvOverlap(),
+ _section, _section);
+
+ logger.stagePop();
+} // complete
+
+// ----------------------------------------------------------------------
+// Get names of all fields
+template<typename mesh_type>
+void
+pylith::topology::PackedFields<mesh_type>::fieldNames(int *numNames,
+ char*** names) const
+{ // fieldNames
+ assert(numNames);
+ assert(names);
+
+ *numNames = _fields.size();
+ *names = new char*[_fields.size()];
+ assert(*names);
+ const typename map_type::const_iterator namesEnd = _fields.end();
+ int i = 0;
+ for (typename map_type::const_iterator name = _fields.begin();
+ name != namesEnd;
+ ++name) {
+ const char len = name->first.length();
+ char* newName = 0;
+ if (len > 0) {
+ newName = new char[len+1];
+ strncpy(newName, name->first.c_str(), len+1);
+ } else {
+ newName = new char[1];
+ newName[0] ='\0';
+ } // if/else
+ (*names)[i++] = newName;
+ } // for
+} // fieldNames
+
+// ----------------------------------------------------------------------
+// View fields and section.
+template<typename mesh_type>
+void
+pylith::topology::PackedFields<mesh_type>::view(const char* label)
+{ // view
+ std::cout << "Fields '" << label << "':\n";
+ const typename map_type::const_iterator fieldsEnd = _fields.end();
+ for (typename map_type::const_iterator f_iter = _fields.begin();
+ f_iter != fieldsEnd;
+ ++f_iter)
+ std::cout << " Field: " << f_iter->first
+ << ", fibration: " << f_iter->second.fibration
+ << ", fiber dim: " << f_iter->second.fiberDim
+ << ", first value index: " << f_iter->second.sindex
+ << std::endl;
+ _section->view("Section");
+} // view
+
+
+// End of file
Copied: short/3D/PyLith/branches/multifields/libsrc/pylith/topology/PackedFields.hh (from rev 18409, short/3D/PyLith/branches/multifields/libsrc/pylith/topology/FieldsNew.hh)
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/topology/PackedFields.hh (rev 0)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/topology/PackedFields.hh 2011-05-21 16:24:29 UTC (rev 18412)
@@ -0,0 +1,208 @@
+// -*- 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 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ======================================================================
+//
+
+/**
+ * @file libsrc/topology/Fields.hh
+ *
+ * @brief Set of real fields over a finite-element mesh. All fields are
+ * associated with the same points. We use uniform sections so the
+ * fiber dimension is set at compile time.
+ */
+
+#if !defined(pylith_topology_packedfields_hh)
+#define pylith_topology_packedfields_hh
+
+// Include directives ---------------------------------------------------
+#include "topologyfwd.hh" // forward declarations
+
+#include "pylith/topology/FieldBase.hh" // USES FieldBase::Metadata
+
+#include <string> // USES std::string
+
+// Fields ---------------------------------------------------------------
+/// Container for managing multiple fields over a finite-element mesh.
+template<typename mesh_type>
+class pylith::topology::PackedFields
+{ // Fields
+ friend class TestPackedFieldsMesh; // unit testing
+ friend class TestPackedFieldsSubMesh; // unit testing
+
+// PUBLIC TYPEDEFS //////////////////////////////////////////////////////
+public:
+
+ // Convenience typedefs
+ typedef typename mesh_type::RealUniformSection section_type;
+
+ typedef ALE::ISieveVisitor::RestrictVisitor<section_type> RestrictVisitor;
+ typedef ALE::ISieveVisitor::UpdateAddVisitor<section_type> UpdateAddVisitor;
+ typedef ALE::ISieveVisitor::UpdateAllVisitor<section_type> UpdateAllVisitor;
+
+// PUBLIC MEMBERS ///////////////////////////////////////////////////////
+public :
+
+ /** Default constructor.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ PackedFields(const mesh_type& mesh);
+
+ /// Destructor.
+ virtual
+ ~PackedFields(void);
+
+ /// Deallocate PETSc and local data structures.
+ virtual
+ void deallocate(void);
+
+ /** Check if fields contains a given field.
+ *
+ * @param name Name of field.
+ * @return True if fields contains field, false otherwise.
+ */
+ bool hasField(const char* name) const;
+
+ /** Add field.
+ *
+ * @param name Name of field.
+ * @param label Label for field.
+ * @param fiberDim Fiber dimension for field.
+ */
+ void add(const char* name,
+ const char* label,
+ const int fiberDim,
+ FieldBase::VectorFieldEnum vectorFieldType =FieldBase::OTHER,
+ const double scale =1.0,
+ const bool dimsOkay =false);
+
+ /** Create and allocate Sieve section.
+ *
+ * @param points Points over which to define section.
+ */
+ void allocate(const ALE::Obj<typename mesh_type::SieveMesh::label_sequence>& points);
+
+ /** Create and allocate Sieve section.
+ *
+ * @param points Points over which to define section.
+ */
+ void allocate(const int_array& points);
+
+ /** Create and allocate Sieve section.
+ *
+ * @param domain Type of points over which to define section.
+ * @param stratum Stratum depth (for vertices) and height (for cells).
+ */
+ void allocate(const FieldBase::DomainEnum domain,
+ const int stratum =0);
+
+ /** Get field.
+ *
+ * @param name Name of field.
+ * @returns Field.
+ */
+ Field<mesh_type>& get(const char* name);
+
+ /** Get mesh associated with fields.
+ *
+ * @returns Finite-element mesh.
+ */
+ const mesh_type& mesh(void) const;
+
+ /** Get section containing fields.
+ *
+ * @returns Sieve section
+ */
+ const ALE::Obj<section_type>& section(void) const;
+
+ /** Compute total fiber dimension for section.
+ *
+ * @returns Fiber dimension.
+ */
+ int fiberDim(void) const;
+
+ /** Get index of first value of field in section.
+ *
+ * @param name Name of field.
+ * @returns Index of first value of field in section.
+ */
+ int sectionIndex(const char* name) const;
+
+ /** Get fiber dimension of field in section.
+ *
+ * @param name Name of field.
+ * @returns Fiber dimension of field in section.
+ */
+ int sectionFiberDim(const char* name) const;
+
+ /// Complete section by assembling across processors.
+ void complete(void);
+
+ /** Return the names of all fields.
+ *
+ * @param numNames Number of fields,
+ * @param names Names of fields.
+ */
+ void fieldNames(int* numNames,
+ char*** names) const;
+
+ /** View fields and section.
+ *
+ * @param label Label for fields.
+ */
+ void view(const char* label);
+
+// PROTECTED STRUCTS ////////////////////////////////////////////////////
+protected :
+
+ struct FieldInfo {
+ FieldBase::Metadata metadata; ///< Metadata for field.
+ Field<mesh_type>* field; ///< Single field.
+ int fiberDim; ///< Fiber dimension of field.
+ int fibration; ///< Index of fibration associated with field.
+ int sindex; ///< Index of first value of field in section.
+ }; // FieldInfo
+
+// PROTECTED TYPEDEFS ///////////////////////////////////////////////////
+protected :
+
+ typedef std::map<std::string, FieldInfo> map_type;
+
+// PROTECTED METHODS ////////////////////////////////////////////////////
+protected :
+
+// PROTECTED MEMBERS ////////////////////////////////////////////////////
+protected :
+
+ map_type _fields; ///< Fields without constraints over a common set of points.
+ ALE::Obj<section_type> _section; ///< Section containing fields.
+ const mesh_type& _mesh; ///< Mesh associated with fields.
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+ PackedFields(const PackedFields&); ///< Not implemented
+ const PackedFields& operator=(const PackedFields&); ///< Not implemented
+
+}; // PackedFields
+
+#include "PackedFields.icc"
+#include "PackedFields.cc"
+
+#endif // pylith_topology_packedfields_hh
+
+
+// End of file
Copied: short/3D/PyLith/branches/multifields/libsrc/pylith/topology/PackedFields.icc (from rev 18409, short/3D/PyLith/branches/multifields/libsrc/pylith/topology/FieldsNew.icc)
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/topology/PackedFields.icc (rev 0)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/topology/PackedFields.icc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -0,0 +1,49 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_topology_packedfields_hh)
+#error "PackedFields.icc must be included only from PackedFields.hh"
+#endif
+
+// ----------------------------------------------------------------------
+// Check if fields contains a given field.
+template<typename mesh_type>
+inline
+bool
+pylith::topology::PackedFields<mesh_type>::hasField(const char* name) const
+{ // hasField
+ typename map_type::const_iterator iter = _fields.find(name);
+ return iter != _fields.end();
+} // hasField
+
+// ----------------------------------------------------------------------
+// Get mesh associated with fields.
+template<typename mesh_type>
+inline
+const mesh_type&
+pylith::topology::PackedFields<mesh_type>::mesh(void) const
+{ // mesh
+ return _mesh;
+} // mesh
+
+// ----------------------------------------------------------------------
+// Get section containing fields.
+template<typename mesh_type>
+inline
+const ALE::Obj<typename pylith::topology::PackedFields<mesh_type>::section_type>&
+pylith::topology::PackedFields<mesh_type>::section(void) const
+{ // section
+ return _section;
+} // section
+
+
+// End of file
Modified: short/3D/PyLith/branches/multifields/libsrc/pylith/topology/topologyfwd.hh
===================================================================
--- short/3D/PyLith/branches/multifields/libsrc/pylith/topology/topologyfwd.hh 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/libsrc/pylith/topology/topologyfwd.hh 2011-05-21 16:24:29 UTC (rev 18412)
@@ -59,7 +59,7 @@
template<typename mesh_type,
typename section_type =ALE::IGeneralSection<pylith::SieveMesh::point_type, double> > class Field;
template<typename field_type> class Fields;
- template<typename mesh_type> class FieldsNew;
+ template<typename mesh_type> class PackedFields;
class SolutionFields;
Modified: short/3D/PyLith/branches/multifields/modulesrc/bc/BCIntegratorSubMesh.i
===================================================================
--- short/3D/PyLith/branches/multifields/modulesrc/bc/BCIntegratorSubMesh.i 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/modulesrc/bc/BCIntegratorSubMesh.i 2011-05-21 16:24:29 UTC (rev 18412)
@@ -46,7 +46,7 @@
*
* @returns Parameter fields.
*/
- const pylith::topology::FieldsNew<pylith::topology::Mesh>* parameterFields(void) const;
+ const pylith::topology::PackedFields<pylith::topology::Mesh>* parameterFields(void) const;
/** Get boundary mesh.
*
Modified: short/3D/PyLith/branches/multifields/modulesrc/bc/BoundaryConditionPoints.i
===================================================================
--- short/3D/PyLith/branches/multifields/modulesrc/bc/BoundaryConditionPoints.i 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/modulesrc/bc/BoundaryConditionPoints.i 2011-05-21 16:24:29 UTC (rev 18412)
@@ -45,7 +45,7 @@
*
* @returns Parameter fields.
*/
- const pylith::topology::FieldsNew<pylith::topology::Mesh>* parameterFields(void) const;
+ const pylith::topology::PackedFields<pylith::topology::Mesh>* parameterFields(void) const;
}; // class BoundaryConditionPoints
Modified: short/3D/PyLith/branches/multifields/modulesrc/friction/FrictionModel.i
===================================================================
--- short/3D/PyLith/branches/multifields/modulesrc/friction/FrictionModel.i 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/modulesrc/friction/FrictionModel.i 2011-05-21 16:24:29 UTC (rev 18412)
@@ -124,7 +124,7 @@
*
* @returns Properties field.
*/
- const pylith::topology::FieldsNew<pylith::topology::SubMesh>& fieldsPropsStateVars() const;
+ const pylith::topology::PackedFields<pylith::topology::SubMesh>& fieldsPropsStateVars() const;
/** Retrieve parameters for physical properties and state variables
* for vertex.
Deleted: short/3D/PyLith/branches/multifields/modulesrc/topology/FieldsNew.i
===================================================================
--- short/3D/PyLith/branches/multifields/modulesrc/topology/FieldsNew.i 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/modulesrc/topology/FieldsNew.i 2011-05-21 16:24:29 UTC (rev 18412)
@@ -1,151 +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 University of California, Davis
-//
-// See COPYING for license information.
-//
-// ======================================================================
-//
-
-/**
- * @file modulesrc/topology/FieldsNew.i
- *
- * @brief Python interface to C++ FieldsNew object.
- */
-
-namespace pylith {
- namespace topology {
-
- template<typename mesh_type>
- class FieldsNew
- { // FieldsNew
-
- // PUBLIC MEMBERS /////////////////////////////////////////////////
- public :
-
- /** Default constructor.
- *
- * @param mesh Finite-element mesh.
- */
- FieldsNew(const mesh_type& mesh);
-
- /// Destructor.
- virtual
- ~FieldsNew(void);
-
- /// Deallocate PETSc and local data structures.
- virtual
- void deallocate(void);
-
- /** Check if fields contains a given field.
- *
- * @param name Name of field.
- * @return True if fields contains field, false otherwise.
- */
- bool hasField(const char* name) const;
-
- /** Add field.
- *
- * @param name Name of field.
- * @param label Label for field.
- * @param fiberDim Fiber dimension for field.
- */
- void add(const char* name,
- const char* label,
- const int fiberDim,
- FieldBase::VectorFieldEnum vectorFieldType =FieldBase::OTHER,
- const double scale =1.0,
- const bool dimsOkay =false);
-
- /** Create and allocate Sieve section.
- *
- * @param points Points over which to define section.
- */
- void allocate(const ALE::Obj<typename mesh_type::SieveMesh::label_sequence>& points);
-
- /** Create and allocate Sieve section.
- *
- * @param points Points over which to define section.
- */
- void allocate(const pylith::int_array& points);
-
- /** Create and allocate Sieve section.
- *
- * @param domain Type of points over which to define section.
- * @param stratum Stratum depth (for vertices) and height (for cells).
- */
- void allocate(const FieldBase::DomainEnum domain,
- const int stratum =0);
-
- /** Get field.
- *
- * @param name Name of field.
- * @returns Field.
- */
- Field<mesh_type>& get(const char* name);
-
- /** Get mesh associated with fields.
- *
- * @returns Finite-element mesh.
- */
- const mesh_type& mesh(void) const;
-
- /** Get section containing fields.
- *
- * @returns Sieve section
- */
- const ALE::Obj<typename mesh_type::RealUniformSection>& section(void) const;
-
- /** Compute total fiber dimension for section.
- *
- * @returns Fiber dimension.
- */
- int fiberDim(void) const;
-
- /** Get index of first value of field in section.
- *
- * @param name Name of field.
- * @returns Index of first value of field in section.
- */
- int sectionIndex(const char* name) const;
-
- /** Get fiber dimension of field in section.
- *
- * @param name Name of field.
- * @returns Fiber dimension of field in section.
- */
- int sectionFiberDim(const char* name) const;
-
- /// Complete section by assembling across processors.
- void complete(void);
-
- /** Return the names of all fields.
- *
- * @param numValues Number of fields,
- * @param values Names of fields.
- */
- void fieldNames(int* numValues,
- char*** values) const;
-
- /** View fields and section.
- *
- * @param label Label for fields.
- */
- void view(const char* label);
-
- }; // FieldsNew
-
- } // topology
-} // pylith
-
-
-// End of file
Modified: short/3D/PyLith/branches/multifields/modulesrc/topology/Makefile.am
===================================================================
--- short/3D/PyLith/branches/multifields/modulesrc/topology/Makefile.am 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/modulesrc/topology/Makefile.am 2011-05-21 16:24:29 UTC (rev 18412)
@@ -31,7 +31,7 @@
FieldBase.i \
Field.i \
Fields.i \
- FieldsNew.i \
+ PackedFields.i \
SolutionFields.i \
Jacobian.i \
Distributor.i \
Copied: short/3D/PyLith/branches/multifields/modulesrc/topology/PackedFields.i (from rev 18409, short/3D/PyLith/branches/multifields/modulesrc/topology/FieldsNew.i)
===================================================================
--- short/3D/PyLith/branches/multifields/modulesrc/topology/PackedFields.i (rev 0)
+++ short/3D/PyLith/branches/multifields/modulesrc/topology/PackedFields.i 2011-05-21 16:24:29 UTC (rev 18412)
@@ -0,0 +1,151 @@
+// -*- 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 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/topology/PackedFields.i
+ *
+ * @brief Python interface to C++ PackedFields object.
+ */
+
+namespace pylith {
+ namespace topology {
+
+ template<typename mesh_type>
+ class PackedFields
+ { // PackedFields
+
+ // PUBLIC MEMBERS /////////////////////////////////////////////////
+ public :
+
+ /** Default constructor.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ PackedFields(const mesh_type& mesh);
+
+ /// Destructor.
+ virtual
+ ~PackedFields(void);
+
+ /// Deallocate PETSc and local data structures.
+ virtual
+ void deallocate(void);
+
+ /** Check if fields contains a given field.
+ *
+ * @param name Name of field.
+ * @return True if fields contains field, false otherwise.
+ */
+ bool hasField(const char* name) const;
+
+ /** Add field.
+ *
+ * @param name Name of field.
+ * @param label Label for field.
+ * @param fiberDim Fiber dimension for field.
+ */
+ void add(const char* name,
+ const char* label,
+ const int fiberDim,
+ FieldBase::VectorFieldEnum vectorFieldType =FieldBase::OTHER,
+ const double scale =1.0,
+ const bool dimsOkay =false);
+
+ /** Create and allocate Sieve section.
+ *
+ * @param points Points over which to define section.
+ */
+ void allocate(const ALE::Obj<typename mesh_type::SieveMesh::label_sequence>& points);
+
+ /** Create and allocate Sieve section.
+ *
+ * @param points Points over which to define section.
+ */
+ void allocate(const pylith::int_array& points);
+
+ /** Create and allocate Sieve section.
+ *
+ * @param domain Type of points over which to define section.
+ * @param stratum Stratum depth (for vertices) and height (for cells).
+ */
+ void allocate(const FieldBase::DomainEnum domain,
+ const int stratum =0);
+
+ /** Get field.
+ *
+ * @param name Name of field.
+ * @returns Field.
+ */
+ Field<mesh_type>& get(const char* name);
+
+ /** Get mesh associated with fields.
+ *
+ * @returns Finite-element mesh.
+ */
+ const mesh_type& mesh(void) const;
+
+ /** Get section containing fields.
+ *
+ * @returns Sieve section
+ */
+ const ALE::Obj<typename mesh_type::RealUniformSection>& section(void) const;
+
+ /** Compute total fiber dimension for section.
+ *
+ * @returns Fiber dimension.
+ */
+ int fiberDim(void) const;
+
+ /** Get index of first value of field in section.
+ *
+ * @param name Name of field.
+ * @returns Index of first value of field in section.
+ */
+ int sectionIndex(const char* name) const;
+
+ /** Get fiber dimension of field in section.
+ *
+ * @param name Name of field.
+ * @returns Fiber dimension of field in section.
+ */
+ int sectionFiberDim(const char* name) const;
+
+ /// Complete section by assembling across processors.
+ void complete(void);
+
+ /** Return the names of all fields.
+ *
+ * @param numValues Number of fields,
+ * @param values Names of fields.
+ */
+ void fieldNames(int* numValues,
+ char*** values) const;
+
+ /** View fields and section.
+ *
+ * @param label Label for fields.
+ */
+ void view(const char* label);
+
+ }; // PackedFields
+
+ } // topology
+} // pylith
+
+
+// End of file
Modified: short/3D/PyLith/branches/multifields/modulesrc/topology/topology.i
===================================================================
--- short/3D/PyLith/branches/multifields/modulesrc/topology/topology.i 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/modulesrc/topology/topology.i 2011-05-21 16:24:29 UTC (rev 18412)
@@ -27,7 +27,7 @@
#include "pylith/topology/FieldBase.hh"
#include "pylith/topology/Field.hh"
#include "pylith/topology/Fields.hh"
-#include "pylith/topology/FieldsNew.hh"
+#include "pylith/topology/PackedFields.hh"
#include "pylith/topology/SolutionFields.hh"
#include "pylith/topology/Jacobian.hh"
#include "pylith/topology/Distributor.hh"
@@ -66,7 +66,7 @@
%include "FieldBase.i"
%include "Field.i"
%include "Fields.i"
-%include "FieldsNew.i"
+%include "PackedFields.i"
%include "SolutionFields.i"
%include "Jacobian.i"
%include "Distributor.i"
@@ -79,8 +79,8 @@
%template(MeshFields) pylith::topology::Fields<pylith::topology::Field<pylith::topology::Mesh> >;
%template(SubMeshFields) pylith::topology::Fields<pylith::topology::Field<pylith::topology::SubMesh> >;
-%template(MeshFieldsNew) pylith::topology::FieldsNew<pylith::topology::Mesh>;
-%template(SubMeshFieldsNew) pylith::topology::FieldsNew<pylith::topology::SubMesh>;
+%template(MeshPackedFields) pylith::topology::PackedFields<pylith::topology::Mesh>;
+%template(SubMeshPackedFields) pylith::topology::PackedFields<pylith::topology::SubMesh>;
// End of file
Modified: short/3D/PyLith/branches/multifields/unittests/libtests/bc/Makefile.am
===================================================================
--- short/3D/PyLith/branches/multifields/unittests/libtests/bc/Makefile.am 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/unittests/libtests/bc/Makefile.am 2011-05-21 16:24:29 UTC (rev 18412)
@@ -197,7 +197,7 @@
testbc_LDADD = \
-lcppunit \
- $(top_builddir)/libsrc/libpylith.la \
+ $(top_builddir)/libsrc/pylith/libpylith.la \
-lspatialdata \
$(PETSC_LIB) $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
Modified: short/3D/PyLith/branches/multifields/unittests/libtests/bc/TestAbsorbingDampers.cc
===================================================================
--- short/3D/PyLith/branches/multifields/unittests/libtests/bc/TestAbsorbingDampers.cc 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/unittests/libtests/bc/TestAbsorbingDampers.cc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -27,7 +27,7 @@
#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/topology/SubMesh.hh" // USES SubMesh
-#include "pylith/topology/FieldsNew.hh" // USES FieldsNew
+#include "pylith/topology/PackedFields.hh" // USES PackedFields
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
#include "pylith/topology/Jacobian.hh" // USES Jacobian
Modified: short/3D/PyLith/branches/multifields/unittests/libtests/bc/TestDirichletBC.cc
===================================================================
--- short/3D/PyLith/branches/multifields/unittests/libtests/bc/TestDirichletBC.cc 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/unittests/libtests/bc/TestDirichletBC.cc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -26,7 +26,7 @@
#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/topology/Field.hh" // USES Field
-#include "pylith/topology/FieldsNew.hh" // USES FieldsNew
+#include "pylith/topology/PackedFields.hh" // USES PackedFields
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
Modified: short/3D/PyLith/branches/multifields/unittests/libtests/bc/TestNeumann.cc
===================================================================
--- short/3D/PyLith/branches/multifields/unittests/libtests/bc/TestNeumann.cc 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/unittests/libtests/bc/TestNeumann.cc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -27,7 +27,7 @@
#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/topology/SubMesh.hh" // USES SubMesh
-#include "pylith/topology/FieldsNew.hh" // USES FieldsNew
+#include "pylith/topology/PackedFields.hh" // USES PackedFields
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
Modified: short/3D/PyLith/branches/multifields/unittests/libtests/bc/TestPointForce.cc
===================================================================
--- short/3D/PyLith/branches/multifields/unittests/libtests/bc/TestPointForce.cc 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/unittests/libtests/bc/TestPointForce.cc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -26,7 +26,7 @@
#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/topology/Field.hh" // USES Field
-#include "pylith/topology/FieldsNew.hh" // USES FieldsNew
+#include "pylith/topology/PackedFields.hh" // USES PackedFields
#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
Modified: short/3D/PyLith/branches/multifields/unittests/libtests/bc/TestTimeDependentPoints.cc
===================================================================
--- short/3D/PyLith/branches/multifields/unittests/libtests/bc/TestTimeDependentPoints.cc 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/unittests/libtests/bc/TestTimeDependentPoints.cc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -24,7 +24,7 @@
#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/topology/Field.hh" // USES Field
-#include "pylith/topology/FieldsNew.hh" // USES FieldsNew
+#include "pylith/topology/PackedFields.hh" // USES PackedFields
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
Modified: short/3D/PyLith/branches/multifields/unittests/libtests/faults/Makefile.am
===================================================================
--- short/3D/PyLith/branches/multifields/unittests/libtests/faults/Makefile.am 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/unittests/libtests/faults/Makefile.am 2011-05-21 16:24:29 UTC (rev 18412)
@@ -226,7 +226,7 @@
testfaults_LDADD = \
-lcppunit -ldl \
- $(top_builddir)/libsrc/libpylith.la \
+ $(top_builddir)/libsrc/pylith/libpylith.la \
-lspatialdata \
$(PETSC_LIB) $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
Modified: short/3D/PyLith/branches/multifields/unittests/libtests/feassemble/Makefile.am
===================================================================
--- short/3D/PyLith/branches/multifields/unittests/libtests/feassemble/Makefile.am 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/unittests/libtests/feassemble/Makefile.am 2011-05-21 16:24:29 UTC (rev 18412)
@@ -365,7 +365,7 @@
testfeassemble_LDADD = \
-lcppunit -ldl \
- $(top_builddir)/libsrc/libpylith.la \
+ $(top_builddir)/libsrc/pylith/libpylith.la \
-lspatialdata \
$(PETSC_LIB) $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
Modified: short/3D/PyLith/branches/multifields/unittests/libtests/friction/Makefile.am
===================================================================
--- short/3D/PyLith/branches/multifields/unittests/libtests/friction/Makefile.am 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/unittests/libtests/friction/Makefile.am 2011-05-21 16:24:29 UTC (rev 18412)
@@ -67,7 +67,7 @@
testfriction_LDADD = \
-lcppunit -ldl \
- $(top_builddir)/libsrc/libpylith.la \
+ $(top_builddir)/libsrc/pylith/libpylith.la \
-lspatialdata \
$(PETSC_LIB) $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
Modified: short/3D/PyLith/branches/multifields/unittests/libtests/friction/TestFrictionModel.cc
===================================================================
--- short/3D/PyLith/branches/multifields/unittests/libtests/friction/TestFrictionModel.cc 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/unittests/libtests/friction/TestFrictionModel.cc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -28,7 +28,7 @@
#include "pylith/topology/SubMesh.hh" // USES SubMesh
#include "pylith/topology/Field.hh" // USES Field
-#include "pylith/topology/FieldsNew.hh" // USES FieldsNew
+#include "pylith/topology/PackedFields.hh" // USES PackedFields
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
#include "pylith/faults/FaultCohesiveDyn.hh" // USES FaultCohesiveDyn
#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
Modified: short/3D/PyLith/branches/multifields/unittests/libtests/materials/Makefile.am
===================================================================
--- short/3D/PyLith/branches/multifields/unittests/libtests/materials/Makefile.am 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/unittests/libtests/materials/Makefile.am 2011-05-21 16:24:29 UTC (rev 18412)
@@ -116,7 +116,7 @@
testmaterials_LDADD = \
-lcppunit -ldl \
- $(top_builddir)/libsrc/libpylith.la \
+ $(top_builddir)/libsrc/pylith/libpylith.la \
-lspatialdata \
$(PETSC_LIB) $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
Modified: short/3D/PyLith/branches/multifields/unittests/libtests/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/branches/multifields/unittests/libtests/meshio/Makefile.am 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/unittests/libtests/meshio/Makefile.am 2011-05-21 16:24:29 UTC (rev 18412)
@@ -211,7 +211,7 @@
testmeshio_LDADD = \
-lcppunit -ldl \
- $(top_builddir)/libsrc/libpylith.la \
+ $(top_builddir)/libsrc/pylith/libpylith.la \
-lspatialdata \
$(PETSC_LIB) $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
Modified: short/3D/PyLith/branches/multifields/unittests/libtests/topology/Makefile.am
===================================================================
--- short/3D/PyLith/branches/multifields/unittests/libtests/topology/Makefile.am 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/unittests/libtests/topology/Makefile.am 2011-05-21 16:24:29 UTC (rev 18412)
@@ -34,7 +34,7 @@
TestFieldSubMesh.cc \
TestFieldsMesh.cc \
TestFieldsSubMesh.cc \
- TestFieldsNewMesh.cc \
+ TestPackedFieldsMesh.cc \
TestSolutionFields.cc \
TestJacobian.cc \
TestRefineUniform.cc \
@@ -49,7 +49,7 @@
TestFieldSubMesh.hh \
TestFieldsMesh.hh \
TestFieldsSubMesh.hh \
- TestFieldsNewMesh.hh \
+ TestPackedFieldsMesh.hh \
TestSolutionFields.hh \
TestJacobian.hh \
TestRefineUniform.hh
@@ -84,7 +84,7 @@
testtopology_LDADD = \
-lcppunit -ldl \
- $(top_builddir)/libsrc/libpylith.la \
+ $(top_builddir)/libsrc/pylith/libpylith.la \
-lspatialdata \
$(PETSC_LIB) $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
Deleted: short/3D/PyLith/branches/multifields/unittests/libtests/topology/TestFieldsNewMesh.cc
===================================================================
--- short/3D/PyLith/branches/multifields/unittests/libtests/topology/TestFieldsNewMesh.cc 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/unittests/libtests/topology/TestFieldsNewMesh.cc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -1,449 +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 University of California, Davis
-//
-// See COPYING for license information.
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "TestFieldsNewMesh.hh" // Implementation of class methods
-
-#include "pylith/topology/Mesh.hh" // USES Mesh
-#include "pylith/topology/Field.hh" // USES Field
-#include "pylith/topology/FieldsNew.hh" // USES FieldsNew
-
-#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
-
-// ----------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_REGISTRATION( pylith::topology::TestFieldsNewMesh );
-
-// ----------------------------------------------------------------------
-typedef pylith::topology::FieldsNew<pylith::topology::Mesh> FieldsNewMesh;
-typedef pylith::topology::Mesh::SieveMesh SieveMesh;
-typedef pylith::topology::Mesh::RealUniformSection RealUniformSection;
-
-// ----------------------------------------------------------------------
-void
-pylith::topology::TestFieldsNewMesh::setUp(void)
-{ // setUp
- _mesh = new Mesh;
- meshio::MeshIOAscii importer;
- importer.filename("data/tri3.mesh");
- importer.read(_mesh);
-} // setUp
-
-// ----------------------------------------------------------------------
-void
-pylith::topology::TestFieldsNewMesh::tearDown(void)
-{ // tearDown
- delete _mesh; _mesh = 0;
-} // tearDown
-
-// ----------------------------------------------------------------------
-// Test constructor.
-void
-pylith::topology::TestFieldsNewMesh::testConstructor(void)
-{ // testConstructor
- CPPUNIT_ASSERT(0 != _mesh);
- FieldsNewMesh fields(*_mesh);
-} // testConstructor
-
-// ----------------------------------------------------------------------
-// Test hasField().
-void
-pylith::topology::TestFieldsNewMesh::testHasField(void)
-{ // testHasField
- CPPUNIT_ASSERT(0 != _mesh);
- FieldsNewMesh fields(*_mesh);
-
- fields.add("field A", "velocity", 3, FieldBase::VECTOR);
-
- CPPUNIT_ASSERT_EQUAL(true, fields.hasField("field A"));
- CPPUNIT_ASSERT_EQUAL(false, fields.hasField("field B"));
- CPPUNIT_ASSERT_EQUAL(false, fields.hasField("field C"));
-
- fields.add("field B", "displacement", 3, FieldBase::VECTOR);
-
- CPPUNIT_ASSERT_EQUAL(true, fields.hasField("field A"));
- CPPUNIT_ASSERT_EQUAL(true, fields.hasField("field B"));
- CPPUNIT_ASSERT_EQUAL(false, fields.hasField("field C"));
-
-} // testHasField
-
-// ----------------------------------------------------------------------
-// Test add().
-void
-pylith::topology::TestFieldsNewMesh::testAdd(void)
-{ // testAdd
- CPPUNIT_ASSERT(0 != _mesh);
- FieldsNewMesh fields(*_mesh);
-
- fields.add("field A", "velocity", 3, FieldBase::VECTOR);
- fields.add("field B", "displacement", 4, FieldBase::OTHER, 2.0, true);
-
- const size_t size = 2;
- CPPUNIT_ASSERT_EQUAL(size, fields._fields.size());
-} // testAdd
-
-// ----------------------------------------------------------------------
-// Test allocate(sequence).
-void
-pylith::topology::TestFieldsNewMesh::testAllocateSequence(void)
-{ // testAllocateSequence
- const int fiberDim = 7;
-
- CPPUNIT_ASSERT(0 != _mesh);
- FieldsNewMesh fields(*_mesh);
-
- fields.add("field A", "velocity", 3, FieldBase::VECTOR);
- fields.add("field B", "other", 4, FieldBase::OTHER);
-
- const ALE::Obj<SieveMesh>& sieveMesh = _mesh->sieveMesh();
- CPPUNIT_ASSERT(!sieveMesh.isNull());
- const ALE::Obj<SieveMesh::label_sequence>& vertices =
- sieveMesh->depthStratum(0);
- CPPUNIT_ASSERT(!vertices.isNull());
-
- fields.allocate(vertices);
-
- const size_t size = 2;
- CPPUNIT_ASSERT_EQUAL(size, fields._fields.size());
-
- const ALE::Obj<RealUniformSection>& section = fields.section();
- CPPUNIT_ASSERT(!section.isNull());
- for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != vertices->end();
- ++v_iter)
- CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
-} // testAllocateSequence
-
-// ----------------------------------------------------------------------
-// Test allocate(array).
-void
-pylith::topology::TestFieldsNewMesh::testAllocateArray(void)
-{ // testAllocateSequence
- const int fiberDim = 7;
- const int nptsIn = 3;
- const int ptsIn[nptsIn] = {
- 1, 3, 4,
- };
- const int nptsOut = 1;
- const int ptsOut[nptsOut] = {
- 2,
- };
-
- CPPUNIT_ASSERT(0 != _mesh);
- FieldsNewMesh fields(*_mesh);
-
- fields.add("field A", "velocity", 3, FieldBase::VECTOR);
- fields.add("field B", "other", 4, FieldBase::OTHER);
-
- int_array verticesIn(nptsIn);
- for (int i=0; i < nptsIn; ++i)
- verticesIn = ptsIn[i];
-
- int_array verticesOut(nptsOut);
- for (int i=0; i < nptsOut; ++i)
- verticesOut = ptsOut[i];
-
- fields.allocate(verticesIn);
-
- const size_t size = 2;
- CPPUNIT_ASSERT_EQUAL(size, fields._fields.size());
-
- const ALE::Obj<RealUniformSection>& section = fields.section();
- CPPUNIT_ASSERT(!section.isNull());
- for (int i=0; i < nptsIn; ++i)
- CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(verticesIn[i]));
- for (int i=0; i < nptsOut; ++i)
- CPPUNIT_ASSERT_EQUAL(0, section->getFiberDimension(verticesOut[i]));
-} // testAllocateArray
-
-// ----------------------------------------------------------------------
-// Test allocate(domain).
-void
-pylith::topology::TestFieldsNewMesh::testAllocateDomain(void)
-{ // testAllocateDomain
- const int fiberDim = 7;
-
- CPPUNIT_ASSERT(0 != _mesh);
- FieldsNewMesh fields(*_mesh);
-
- fields.add("field A", "velocity", 3, FieldBase::VECTOR);
- fields.add("field B", "other", 4, FieldBase::OTHER);
- fields.allocate(Field<Mesh>::VERTICES_FIELD);
-
- const size_t size = 2;
- CPPUNIT_ASSERT_EQUAL(size, fields._fields.size());
-
- const ALE::Obj<RealUniformSection>& section = fields.section();
- CPPUNIT_ASSERT(!section.isNull());
- const ALE::Obj<SieveMesh>& sieveMesh = _mesh->sieveMesh();
- CPPUNIT_ASSERT(!sieveMesh.isNull());
- const ALE::Obj<SieveMesh::label_sequence>& vertices =
- sieveMesh->depthStratum(0);
- CPPUNIT_ASSERT(!vertices.isNull());
- for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != vertices->end();
- ++v_iter)
- CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
-} // testAllocateDomain
-
-// ----------------------------------------------------------------------
-// Test get().
-void
-pylith::topology::TestFieldsNewMesh::testGet(void)
-{ // testGet
- CPPUNIT_ASSERT(0 != _mesh);
- FieldsNewMesh fields(*_mesh);
-
- fields.add("field A", "velocity", 3, FieldBase::VECTOR);
- fields.add("field B", "displacement", 4, FieldBase::OTHER, 2.0, true);
- fields.allocate(FieldBase::VERTICES_FIELD);
-
- const ALE::Obj<Mesh::SieveMesh>& sieveMesh = _mesh->sieveMesh();
- CPPUNIT_ASSERT(!sieveMesh.isNull());
- const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
- sieveMesh->depthStratum(0);
- CPPUNIT_ASSERT(!vertices.isNull());
- const Mesh::SieveMesh::label_sequence::iterator verticesBegin =
- vertices->begin();
- const Mesh::SieveMesh::label_sequence::iterator verticesEnd =
- vertices->end();
-
- // Check field A
- Field<Mesh>& fieldA = fields.get("field A");
- CPPUNIT_ASSERT_EQUAL(std::string("velocity"), std::string(fieldA.label()));
- CPPUNIT_ASSERT_EQUAL(FieldBase::VECTOR,
- fieldA.vectorFieldType());
- CPPUNIT_ASSERT_EQUAL(1.0, fieldA.scale());
- CPPUNIT_ASSERT_EQUAL(false, fieldA.addDimensionOkay());
-
- const ALE::Obj<Mesh::RealSection>& sectionA = fieldA.section();
- CPPUNIT_ASSERT(!sectionA.isNull());
- for(Mesh::SieveMesh::label_sequence::iterator v_iter = verticesBegin;
- v_iter != verticesEnd;
- ++v_iter) {
- const int fiberDim = sectionA->getFiberDimension(*v_iter);
- CPPUNIT_ASSERT_EQUAL(3, fiberDim);
- const double* values = sectionA->restrictPoint(*v_iter);
- CPPUNIT_ASSERT(values);
- } // for
-
-
- // Check field B
- Field<Mesh>& fieldB = fields.get("field B");
- CPPUNIT_ASSERT_EQUAL(std::string("displacement"),
- std::string(fieldB.label()));
- CPPUNIT_ASSERT_EQUAL(FieldBase::OTHER,
- fieldB.vectorFieldType());
- CPPUNIT_ASSERT_EQUAL(2.0, fieldB.scale());
- CPPUNIT_ASSERT_EQUAL(true, fieldB.addDimensionOkay());
-
- const ALE::Obj<Mesh::RealSection>& sectionB = fieldB.section();
- CPPUNIT_ASSERT(!sectionB.isNull());
- for(Mesh::SieveMesh::label_sequence::iterator v_iter = verticesBegin;
- v_iter != verticesEnd;
- ++v_iter) {
- const int fiberDim = sectionB->getFiberDimension(*v_iter);
- CPPUNIT_ASSERT_EQUAL(4, fiberDim);
- const double* values = sectionB->restrictPoint(*v_iter);
- CPPUNIT_ASSERT(values);
- } // for
-
- // Make sure we can clone field B
- Field<Mesh> fieldC(*_mesh);
- fieldC.cloneSection(fieldB);
- fieldC.copy(fieldB);
-} // testGet
-
-// ----------------------------------------------------------------------
-// Test get() const.
-void
-pylith::topology::TestFieldsNewMesh::testGetConst(void)
-{ // testGetConst
- CPPUNIT_ASSERT(0 != _mesh);
- FieldsNewMesh fields(*_mesh);
-
- fields.add("field A", "velocity", 3, FieldBase::VECTOR);
- fields.add("field B", "displacement", 4, FieldBase::OTHER, 2.0, true);
- fields.allocate(FieldBase::VERTICES_FIELD);
-
- const ALE::Obj<Mesh::SieveMesh>& sieveMesh = _mesh->sieveMesh();
- CPPUNIT_ASSERT(!sieveMesh.isNull());
- const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
- sieveMesh->depthStratum(0);
- CPPUNIT_ASSERT(!vertices.isNull());
- const Mesh::SieveMesh::label_sequence::iterator verticesBegin =
- vertices->begin();
- const Mesh::SieveMesh::label_sequence::iterator verticesEnd =
- vertices->end();
-
- // Check field A
- const Field<Mesh>& fieldA = fields.get("field A");
- CPPUNIT_ASSERT_EQUAL(std::string("velocity"), std::string(fieldA.label()));
- CPPUNIT_ASSERT_EQUAL(FieldBase::VECTOR,
- fieldA.vectorFieldType());
- CPPUNIT_ASSERT_EQUAL(1.0, fieldA.scale());
- CPPUNIT_ASSERT_EQUAL(false, fieldA.addDimensionOkay());
-
- const ALE::Obj<Mesh::RealSection>& sectionA = fieldA.section();
- CPPUNIT_ASSERT(!sectionA.isNull());
- for(Mesh::SieveMesh::label_sequence::iterator v_iter = verticesBegin;
- v_iter != verticesEnd;
- ++v_iter) {
- const int fiberDim = sectionA->getFiberDimension(*v_iter);
- CPPUNIT_ASSERT_EQUAL(3, fiberDim);
- } // for
-
-
- // Check field B
- const Field<Mesh>& fieldB = fields.get("field B");
- CPPUNIT_ASSERT_EQUAL(std::string("displacement"),
- std::string(fieldB.label()));
- CPPUNIT_ASSERT_EQUAL(FieldBase::OTHER,
- fieldB.vectorFieldType());
- CPPUNIT_ASSERT_EQUAL(2.0, fieldB.scale());
- CPPUNIT_ASSERT_EQUAL(true, fieldB.addDimensionOkay());
-
- const ALE::Obj<Mesh::RealSection>& sectionB = fieldB.section();
- CPPUNIT_ASSERT(!sectionB.isNull());
- for(Mesh::SieveMesh::label_sequence::iterator v_iter = verticesBegin;
- v_iter != verticesEnd;
- ++v_iter) {
- const int fiberDim = sectionB->getFiberDimension(*v_iter);
- CPPUNIT_ASSERT_EQUAL(4, fiberDim);
- } // for
-} // testGetConst
-
-// ----------------------------------------------------------------------
-// Test mesh().
-void
-pylith::topology::TestFieldsNewMesh::testMesh(void)
-{ // testMesh
- CPPUNIT_ASSERT(0 != _mesh);
- FieldsNewMesh fields(*_mesh);
-
- const Mesh& mesh = fields.mesh();
-} // testMesh
-
-// ----------------------------------------------------------------------
-// Test fiberDim().
-void
-pylith::topology::TestFieldsNewMesh::testFiberDim(void)
-{ // testFiberDim
- CPPUNIT_ASSERT(0 != _mesh);
- FieldsNewMesh fields(*_mesh);
-
- fields.add("field A", "velocity", 3, FieldBase::VECTOR);
- fields.add("field B", "displacement", 4, FieldBase::OTHER, 2.0, true);
-
- CPPUNIT_ASSERT_EQUAL(7, fields.fiberDim());
-} // testFiberDim
-
-// ----------------------------------------------------------------------
-// Test sectionIndex().
-void
-pylith::topology::TestFieldsNewMesh::testSectionIndex(void)
-{ // testSectionIndex
- CPPUNIT_ASSERT(0 != _mesh);
- FieldsNewMesh fields(*_mesh);
-
- fields.add("field A", "velocity", 3, FieldBase::VECTOR);
- fields.add("field B", "displacement", 4, FieldBase::OTHER, 2.0, true);
-
- CPPUNIT_ASSERT_EQUAL(0, fields.sectionIndex("field A"));
- CPPUNIT_ASSERT_EQUAL(3, fields.sectionIndex("field B"));
-} // testSectionIndex
-
-// ----------------------------------------------------------------------
-// Test sectionFiberDim().
-void
-pylith::topology::TestFieldsNewMesh::testSectionFiberDim(void)
-{ // testSectionFiberDim
- CPPUNIT_ASSERT(0 != _mesh);
- FieldsNewMesh fields(*_mesh);
-
- fields.add("field A", "velocity", 3, FieldBase::VECTOR);
- fields.add("field B", "displacement", 4, FieldBase::OTHER, 2.0, true);
-
- CPPUNIT_ASSERT_EQUAL(3, fields.sectionFiberDim("field A"));
- CPPUNIT_ASSERT_EQUAL(4, fields.sectionFiberDim("field B"));
-} // testSectionFiberDim
-
-// ----------------------------------------------------------------------
-// Test complete().
-void
-pylith::topology::TestFieldsNewMesh::testComplete(void)
-{ // testComplete
- CPPUNIT_ASSERT(0 != _mesh);
- FieldsNewMesh fields(*_mesh);
-
- fields.add("field A", "velocity", 3, FieldBase::VECTOR);
- fields.add("field B", "displacement", 4, FieldBase::OTHER, 2.0, true);
- fields.allocate(FieldBase::VERTICES_FIELD);
-
- fields.complete();
-} // testComplete
-
-// ----------------------------------------------------------------------
-// Test fieldNames() const.
-void
-pylith::topology::TestFieldsNewMesh::testFieldNames(void)
-{ // testFieldNames
- const int numFieldsE = 2;
- const char* namesE[2] = {
- "field A",
- "field B"
- };
-
- CPPUNIT_ASSERT(0 != _mesh);
- FieldsNewMesh fields(*_mesh);
-
- fields.add("field A", "velocity", 3, FieldBase::VECTOR);
- fields.add("field B", "displacement", 4, FieldBase::OTHER, 2.0, true);
-
- int numFields = 0;
- char** names = 0;
- fields.fieldNames(&numFields, &names);
-
- CPPUNIT_ASSERT_EQUAL(numFieldsE, numFields);
-
- for (int i=0; i < numFields; ++i)
- CPPUNIT_ASSERT_EQUAL(std::string(namesE[i]), std::string(names[i]));
-
- for (int i=0; i < numFields; ++i) {
- delete[] names[i]; names[i] = 0;
- } // for
- delete[] names; names = 0;
-} // testFieldNames
-
-// ----------------------------------------------------------------------
-// Test view().
-void
-pylith::topology::TestFieldsNewMesh::testView(void)
-{ // testView
- CPPUNIT_ASSERT(0 != _mesh);
- FieldsNewMesh fields(*_mesh);
-
- fields.add("field A", "velocity", 3, FieldBase::VECTOR);
- fields.add("field B", "displacement", 4, FieldBase::OTHER, 2.0, true);
- fields.allocate(FieldBase::VERTICES_FIELD);
-
- fields.view("TEST VIEW");
-} // testView
-
-
-// End of file
Deleted: short/3D/PyLith/branches/multifields/unittests/libtests/topology/TestFieldsNewMesh.hh
===================================================================
--- short/3D/PyLith/branches/multifields/unittests/libtests/topology/TestFieldsNewMesh.hh 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/unittests/libtests/topology/TestFieldsNewMesh.hh 2011-05-21 16:24:29 UTC (rev 18412)
@@ -1,131 +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 University of California, Davis
-//
-// See COPYING for license information.
-//
-// ----------------------------------------------------------------------
-//
-
-/**
- * @file unittests/libtests/topology/TestFieldsNewMesh.hh
- *
- * @brief C++ unit testing for FieldsNew<Mesh>.
- */
-
-#if !defined(pylith_topology_testfieldsnewmesh_hh)
-#define pylith_topology_testfieldsnewmesh_hh
-
-// Include directives ---------------------------------------------------
-#include <cppunit/extensions/HelperMacros.h>
-
-#include "pylith/topology/topologyfwd.hh" // forward declarations
-
-// Forward declarations -------------------------------------------------
-/// Namespace for pylith package
-namespace pylith {
- namespace topology {
- class TestFieldsNewMesh;
- } // topology
-} // pylith
-
-// TestField -------------------------------------------------------------
-/// C++ unit testing for Field.
-class pylith::topology::TestFieldsNewMesh : public CppUnit::TestFixture
-{ // class TestField
-
- // CPPUNIT TEST SUITE /////////////////////////////////////////////////
- CPPUNIT_TEST_SUITE( TestFieldsNewMesh );
-
- CPPUNIT_TEST( testConstructor );
- CPPUNIT_TEST( testHasField );
- CPPUNIT_TEST( testAdd );
- CPPUNIT_TEST( testAllocateSequence );
- CPPUNIT_TEST( testAllocateArray );
- CPPUNIT_TEST( testAllocateDomain );
- CPPUNIT_TEST( testGet );
- CPPUNIT_TEST( testGetConst );
- CPPUNIT_TEST( testMesh );
- CPPUNIT_TEST( testFiberDim );
- CPPUNIT_TEST( testSectionIndex );
- CPPUNIT_TEST( testSectionFiberDim );
- CPPUNIT_TEST( testComplete );
- CPPUNIT_TEST( testFieldNames );
- CPPUNIT_TEST( testView );
-
- CPPUNIT_TEST_SUITE_END();
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Setup test case.
- void setUp(void);
-
- /// Tear down test case.
- void tearDown(void);
-
- /// Test constructor.
- void testConstructor(void);
-
- /// Test hasField().
- void testHasField(void);
-
- /// Test add().
- void testAdd(void);
-
- /// Test allocate(label_sequence).
- void testAllocateSequence(void);
-
- /// Test allocate(int_array).
- void testAllocateArray(void);
-
- /// Test allocate(domain).
- void testAllocateDomain(void);
-
- /// Test getField().
- void testGet(void);
-
- /// Test getField() for const FieldsNew.
- void testGetConst(void);
-
- /// Test mesh().
- void testMesh(void);
-
- /// Test fiberDim().
- void testFiberDim(void);
-
- /// Test sectionIndex().
- void testSectionIndex(void);
-
- /// Test sectionFiberDim().
- void testSectionFiberDim(void);
-
- /// Test complete().
- void testComplete(void);
-
- /// Test fieldNames().
- void testFieldNames(void);
-
- /// Test view().
- void testView(void);
-
-// PRIVATE MEMBERS /////////////////////////////////////////////////////
-private :
-
- Mesh* _mesh;
-
-}; // class TestFieldsNewMesh
-
-#endif // pylith_topology_testfieldsnewmesh_hh
-
-
-// End of file
Copied: short/3D/PyLith/branches/multifields/unittests/libtests/topology/TestPackedFieldsMesh.cc (from rev 18409, short/3D/PyLith/branches/multifields/unittests/libtests/topology/TestFieldsNewMesh.cc)
===================================================================
--- short/3D/PyLith/branches/multifields/unittests/libtests/topology/TestPackedFieldsMesh.cc (rev 0)
+++ short/3D/PyLith/branches/multifields/unittests/libtests/topology/TestPackedFieldsMesh.cc 2011-05-21 16:24:29 UTC (rev 18412)
@@ -0,0 +1,449 @@
+// -*- 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 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestPackedFieldsMesh.hh" // Implementation of class methods
+
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/PackedFields.hh" // USES PackedFields
+
+#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::topology::TestPackedFieldsMesh );
+
+// ----------------------------------------------------------------------
+typedef pylith::topology::PackedFields<pylith::topology::Mesh> PackedFieldsMesh;
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::RealUniformSection RealUniformSection;
+
+// ----------------------------------------------------------------------
+void
+pylith::topology::TestPackedFieldsMesh::setUp(void)
+{ // setUp
+ _mesh = new Mesh;
+ meshio::MeshIOAscii importer;
+ importer.filename("data/tri3.mesh");
+ importer.read(_mesh);
+} // setUp
+
+// ----------------------------------------------------------------------
+void
+pylith::topology::TestPackedFieldsMesh::tearDown(void)
+{ // tearDown
+ delete _mesh; _mesh = 0;
+} // tearDown
+
+// ----------------------------------------------------------------------
+// Test constructor.
+void
+pylith::topology::TestPackedFieldsMesh::testConstructor(void)
+{ // testConstructor
+ CPPUNIT_ASSERT(0 != _mesh);
+ PackedFieldsMesh fields(*_mesh);
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test hasField().
+void
+pylith::topology::TestPackedFieldsMesh::testHasField(void)
+{ // testHasField
+ CPPUNIT_ASSERT(0 != _mesh);
+ PackedFieldsMesh fields(*_mesh);
+
+ fields.add("field A", "velocity", 3, FieldBase::VECTOR);
+
+ CPPUNIT_ASSERT_EQUAL(true, fields.hasField("field A"));
+ CPPUNIT_ASSERT_EQUAL(false, fields.hasField("field B"));
+ CPPUNIT_ASSERT_EQUAL(false, fields.hasField("field C"));
+
+ fields.add("field B", "displacement", 3, FieldBase::VECTOR);
+
+ CPPUNIT_ASSERT_EQUAL(true, fields.hasField("field A"));
+ CPPUNIT_ASSERT_EQUAL(true, fields.hasField("field B"));
+ CPPUNIT_ASSERT_EQUAL(false, fields.hasField("field C"));
+
+} // testHasField
+
+// ----------------------------------------------------------------------
+// Test add().
+void
+pylith::topology::TestPackedFieldsMesh::testAdd(void)
+{ // testAdd
+ CPPUNIT_ASSERT(0 != _mesh);
+ PackedFieldsMesh fields(*_mesh);
+
+ fields.add("field A", "velocity", 3, FieldBase::VECTOR);
+ fields.add("field B", "displacement", 4, FieldBase::OTHER, 2.0, true);
+
+ const size_t size = 2;
+ CPPUNIT_ASSERT_EQUAL(size, fields._fields.size());
+} // testAdd
+
+// ----------------------------------------------------------------------
+// Test allocate(sequence).
+void
+pylith::topology::TestPackedFieldsMesh::testAllocateSequence(void)
+{ // testAllocateSequence
+ const int fiberDim = 7;
+
+ CPPUNIT_ASSERT(0 != _mesh);
+ PackedFieldsMesh fields(*_mesh);
+
+ fields.add("field A", "velocity", 3, FieldBase::VECTOR);
+ fields.add("field B", "other", 4, FieldBase::OTHER);
+
+ const ALE::Obj<SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ fields.allocate(vertices);
+
+ const size_t size = 2;
+ CPPUNIT_ASSERT_EQUAL(size, fields._fields.size());
+
+ const ALE::Obj<RealUniformSection>& section = fields.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter)
+ CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
+} // testAllocateSequence
+
+// ----------------------------------------------------------------------
+// Test allocate(array).
+void
+pylith::topology::TestPackedFieldsMesh::testAllocateArray(void)
+{ // testAllocateSequence
+ const int fiberDim = 7;
+ const int nptsIn = 3;
+ const int ptsIn[nptsIn] = {
+ 1, 3, 4,
+ };
+ const int nptsOut = 1;
+ const int ptsOut[nptsOut] = {
+ 2,
+ };
+
+ CPPUNIT_ASSERT(0 != _mesh);
+ PackedFieldsMesh fields(*_mesh);
+
+ fields.add("field A", "velocity", 3, FieldBase::VECTOR);
+ fields.add("field B", "other", 4, FieldBase::OTHER);
+
+ int_array verticesIn(nptsIn);
+ for (int i=0; i < nptsIn; ++i)
+ verticesIn = ptsIn[i];
+
+ int_array verticesOut(nptsOut);
+ for (int i=0; i < nptsOut; ++i)
+ verticesOut = ptsOut[i];
+
+ fields.allocate(verticesIn);
+
+ const size_t size = 2;
+ CPPUNIT_ASSERT_EQUAL(size, fields._fields.size());
+
+ const ALE::Obj<RealUniformSection>& section = fields.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ for (int i=0; i < nptsIn; ++i)
+ CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(verticesIn[i]));
+ for (int i=0; i < nptsOut; ++i)
+ CPPUNIT_ASSERT_EQUAL(0, section->getFiberDimension(verticesOut[i]));
+} // testAllocateArray
+
+// ----------------------------------------------------------------------
+// Test allocate(domain).
+void
+pylith::topology::TestPackedFieldsMesh::testAllocateDomain(void)
+{ // testAllocateDomain
+ const int fiberDim = 7;
+
+ CPPUNIT_ASSERT(0 != _mesh);
+ PackedFieldsMesh fields(*_mesh);
+
+ fields.add("field A", "velocity", 3, FieldBase::VECTOR);
+ fields.add("field B", "other", 4, FieldBase::OTHER);
+ fields.allocate(Field<Mesh>::VERTICES_FIELD);
+
+ const size_t size = 2;
+ CPPUNIT_ASSERT_EQUAL(size, fields._fields.size());
+
+ const ALE::Obj<RealUniformSection>& section = fields.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ const ALE::Obj<SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter)
+ CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
+} // testAllocateDomain
+
+// ----------------------------------------------------------------------
+// Test get().
+void
+pylith::topology::TestPackedFieldsMesh::testGet(void)
+{ // testGet
+ CPPUNIT_ASSERT(0 != _mesh);
+ PackedFieldsMesh fields(*_mesh);
+
+ fields.add("field A", "velocity", 3, FieldBase::VECTOR);
+ fields.add("field B", "displacement", 4, FieldBase::OTHER, 2.0, true);
+ fields.allocate(FieldBase::VERTICES_FIELD);
+
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ const Mesh::SieveMesh::label_sequence::iterator verticesBegin =
+ vertices->begin();
+ const Mesh::SieveMesh::label_sequence::iterator verticesEnd =
+ vertices->end();
+
+ // Check field A
+ Field<Mesh>& fieldA = fields.get("field A");
+ CPPUNIT_ASSERT_EQUAL(std::string("velocity"), std::string(fieldA.label()));
+ CPPUNIT_ASSERT_EQUAL(FieldBase::VECTOR,
+ fieldA.vectorFieldType());
+ CPPUNIT_ASSERT_EQUAL(1.0, fieldA.scale());
+ CPPUNIT_ASSERT_EQUAL(false, fieldA.addDimensionOkay());
+
+ const ALE::Obj<Mesh::RealSection>& sectionA = fieldA.section();
+ CPPUNIT_ASSERT(!sectionA.isNull());
+ for(Mesh::SieveMesh::label_sequence::iterator v_iter = verticesBegin;
+ v_iter != verticesEnd;
+ ++v_iter) {
+ const int fiberDim = sectionA->getFiberDimension(*v_iter);
+ CPPUNIT_ASSERT_EQUAL(3, fiberDim);
+ const double* values = sectionA->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(values);
+ } // for
+
+
+ // Check field B
+ Field<Mesh>& fieldB = fields.get("field B");
+ CPPUNIT_ASSERT_EQUAL(std::string("displacement"),
+ std::string(fieldB.label()));
+ CPPUNIT_ASSERT_EQUAL(FieldBase::OTHER,
+ fieldB.vectorFieldType());
+ CPPUNIT_ASSERT_EQUAL(2.0, fieldB.scale());
+ CPPUNIT_ASSERT_EQUAL(true, fieldB.addDimensionOkay());
+
+ const ALE::Obj<Mesh::RealSection>& sectionB = fieldB.section();
+ CPPUNIT_ASSERT(!sectionB.isNull());
+ for(Mesh::SieveMesh::label_sequence::iterator v_iter = verticesBegin;
+ v_iter != verticesEnd;
+ ++v_iter) {
+ const int fiberDim = sectionB->getFiberDimension(*v_iter);
+ CPPUNIT_ASSERT_EQUAL(4, fiberDim);
+ const double* values = sectionB->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(values);
+ } // for
+
+ // Make sure we can clone field B
+ Field<Mesh> fieldC(*_mesh);
+ fieldC.cloneSection(fieldB);
+ fieldC.copy(fieldB);
+} // testGet
+
+// ----------------------------------------------------------------------
+// Test get() const.
+void
+pylith::topology::TestPackedFieldsMesh::testGetConst(void)
+{ // testGetConst
+ CPPUNIT_ASSERT(0 != _mesh);
+ PackedFieldsMesh fields(*_mesh);
+
+ fields.add("field A", "velocity", 3, FieldBase::VECTOR);
+ fields.add("field B", "displacement", 4, FieldBase::OTHER, 2.0, true);
+ fields.allocate(FieldBase::VERTICES_FIELD);
+
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ const Mesh::SieveMesh::label_sequence::iterator verticesBegin =
+ vertices->begin();
+ const Mesh::SieveMesh::label_sequence::iterator verticesEnd =
+ vertices->end();
+
+ // Check field A
+ const Field<Mesh>& fieldA = fields.get("field A");
+ CPPUNIT_ASSERT_EQUAL(std::string("velocity"), std::string(fieldA.label()));
+ CPPUNIT_ASSERT_EQUAL(FieldBase::VECTOR,
+ fieldA.vectorFieldType());
+ CPPUNIT_ASSERT_EQUAL(1.0, fieldA.scale());
+ CPPUNIT_ASSERT_EQUAL(false, fieldA.addDimensionOkay());
+
+ const ALE::Obj<Mesh::RealSection>& sectionA = fieldA.section();
+ CPPUNIT_ASSERT(!sectionA.isNull());
+ for(Mesh::SieveMesh::label_sequence::iterator v_iter = verticesBegin;
+ v_iter != verticesEnd;
+ ++v_iter) {
+ const int fiberDim = sectionA->getFiberDimension(*v_iter);
+ CPPUNIT_ASSERT_EQUAL(3, fiberDim);
+ } // for
+
+
+ // Check field B
+ const Field<Mesh>& fieldB = fields.get("field B");
+ CPPUNIT_ASSERT_EQUAL(std::string("displacement"),
+ std::string(fieldB.label()));
+ CPPUNIT_ASSERT_EQUAL(FieldBase::OTHER,
+ fieldB.vectorFieldType());
+ CPPUNIT_ASSERT_EQUAL(2.0, fieldB.scale());
+ CPPUNIT_ASSERT_EQUAL(true, fieldB.addDimensionOkay());
+
+ const ALE::Obj<Mesh::RealSection>& sectionB = fieldB.section();
+ CPPUNIT_ASSERT(!sectionB.isNull());
+ for(Mesh::SieveMesh::label_sequence::iterator v_iter = verticesBegin;
+ v_iter != verticesEnd;
+ ++v_iter) {
+ const int fiberDim = sectionB->getFiberDimension(*v_iter);
+ CPPUNIT_ASSERT_EQUAL(4, fiberDim);
+ } // for
+} // testGetConst
+
+// ----------------------------------------------------------------------
+// Test mesh().
+void
+pylith::topology::TestPackedFieldsMesh::testMesh(void)
+{ // testMesh
+ CPPUNIT_ASSERT(0 != _mesh);
+ PackedFieldsMesh fields(*_mesh);
+
+ const Mesh& mesh = fields.mesh();
+} // testMesh
+
+// ----------------------------------------------------------------------
+// Test fiberDim().
+void
+pylith::topology::TestPackedFieldsMesh::testFiberDim(void)
+{ // testFiberDim
+ CPPUNIT_ASSERT(0 != _mesh);
+ PackedFieldsMesh fields(*_mesh);
+
+ fields.add("field A", "velocity", 3, FieldBase::VECTOR);
+ fields.add("field B", "displacement", 4, FieldBase::OTHER, 2.0, true);
+
+ CPPUNIT_ASSERT_EQUAL(7, fields.fiberDim());
+} // testFiberDim
+
+// ----------------------------------------------------------------------
+// Test sectionIndex().
+void
+pylith::topology::TestPackedFieldsMesh::testSectionIndex(void)
+{ // testSectionIndex
+ CPPUNIT_ASSERT(0 != _mesh);
+ PackedFieldsMesh fields(*_mesh);
+
+ fields.add("field A", "velocity", 3, FieldBase::VECTOR);
+ fields.add("field B", "displacement", 4, FieldBase::OTHER, 2.0, true);
+
+ CPPUNIT_ASSERT_EQUAL(0, fields.sectionIndex("field A"));
+ CPPUNIT_ASSERT_EQUAL(3, fields.sectionIndex("field B"));
+} // testSectionIndex
+
+// ----------------------------------------------------------------------
+// Test sectionFiberDim().
+void
+pylith::topology::TestPackedFieldsMesh::testSectionFiberDim(void)
+{ // testSectionFiberDim
+ CPPUNIT_ASSERT(0 != _mesh);
+ PackedFieldsMesh fields(*_mesh);
+
+ fields.add("field A", "velocity", 3, FieldBase::VECTOR);
+ fields.add("field B", "displacement", 4, FieldBase::OTHER, 2.0, true);
+
+ CPPUNIT_ASSERT_EQUAL(3, fields.sectionFiberDim("field A"));
+ CPPUNIT_ASSERT_EQUAL(4, fields.sectionFiberDim("field B"));
+} // testSectionFiberDim
+
+// ----------------------------------------------------------------------
+// Test complete().
+void
+pylith::topology::TestPackedFieldsMesh::testComplete(void)
+{ // testComplete
+ CPPUNIT_ASSERT(0 != _mesh);
+ PackedFieldsMesh fields(*_mesh);
+
+ fields.add("field A", "velocity", 3, FieldBase::VECTOR);
+ fields.add("field B", "displacement", 4, FieldBase::OTHER, 2.0, true);
+ fields.allocate(FieldBase::VERTICES_FIELD);
+
+ fields.complete();
+} // testComplete
+
+// ----------------------------------------------------------------------
+// Test fieldNames() const.
+void
+pylith::topology::TestPackedFieldsMesh::testFieldNames(void)
+{ // testFieldNames
+ const int numFieldsE = 2;
+ const char* namesE[2] = {
+ "field A",
+ "field B"
+ };
+
+ CPPUNIT_ASSERT(0 != _mesh);
+ PackedFieldsMesh fields(*_mesh);
+
+ fields.add("field A", "velocity", 3, FieldBase::VECTOR);
+ fields.add("field B", "displacement", 4, FieldBase::OTHER, 2.0, true);
+
+ int numFields = 0;
+ char** names = 0;
+ fields.fieldNames(&numFields, &names);
+
+ CPPUNIT_ASSERT_EQUAL(numFieldsE, numFields);
+
+ for (int i=0; i < numFields; ++i)
+ CPPUNIT_ASSERT_EQUAL(std::string(namesE[i]), std::string(names[i]));
+
+ for (int i=0; i < numFields; ++i) {
+ delete[] names[i]; names[i] = 0;
+ } // for
+ delete[] names; names = 0;
+} // testFieldNames
+
+// ----------------------------------------------------------------------
+// Test view().
+void
+pylith::topology::TestPackedFieldsMesh::testView(void)
+{ // testView
+ CPPUNIT_ASSERT(0 != _mesh);
+ PackedFieldsMesh fields(*_mesh);
+
+ fields.add("field A", "velocity", 3, FieldBase::VECTOR);
+ fields.add("field B", "displacement", 4, FieldBase::OTHER, 2.0, true);
+ fields.allocate(FieldBase::VERTICES_FIELD);
+
+ fields.view("TEST VIEW");
+} // testView
+
+
+// End of file
Copied: short/3D/PyLith/branches/multifields/unittests/libtests/topology/TestPackedFieldsMesh.hh (from rev 18409, short/3D/PyLith/branches/multifields/unittests/libtests/topology/TestFieldsNewMesh.hh)
===================================================================
--- short/3D/PyLith/branches/multifields/unittests/libtests/topology/TestPackedFieldsMesh.hh (rev 0)
+++ short/3D/PyLith/branches/multifields/unittests/libtests/topology/TestPackedFieldsMesh.hh 2011-05-21 16:24:29 UTC (rev 18412)
@@ -0,0 +1,131 @@
+// -*- 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 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/topology/TestPackedFieldsMesh.hh
+ *
+ * @brief C++ unit testing for PackedFields<Mesh>.
+ */
+
+#if !defined(pylith_topology_testpackedfieldsmesh_hh)
+#define pylith_topology_testpackedfieldsmesh_hh
+
+// Include directives ---------------------------------------------------
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "pylith/topology/topologyfwd.hh" // forward declarations
+
+// Forward declarations -------------------------------------------------
+/// Namespace for pylith package
+namespace pylith {
+ namespace topology {
+ class TestPackedFieldsMesh;
+ } // topology
+} // pylith
+
+// TestField -------------------------------------------------------------
+/// C++ unit testing for Field.
+class pylith::topology::TestPackedFieldsMesh : public CppUnit::TestFixture
+{ // class TestField
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestPackedFieldsMesh );
+
+ CPPUNIT_TEST( testConstructor );
+ CPPUNIT_TEST( testHasField );
+ CPPUNIT_TEST( testAdd );
+ CPPUNIT_TEST( testAllocateSequence );
+ CPPUNIT_TEST( testAllocateArray );
+ CPPUNIT_TEST( testAllocateDomain );
+ CPPUNIT_TEST( testGet );
+ CPPUNIT_TEST( testGetConst );
+ CPPUNIT_TEST( testMesh );
+ CPPUNIT_TEST( testFiberDim );
+ CPPUNIT_TEST( testSectionIndex );
+ CPPUNIT_TEST( testSectionFiberDim );
+ CPPUNIT_TEST( testComplete );
+ CPPUNIT_TEST( testFieldNames );
+ CPPUNIT_TEST( testView );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup test case.
+ void setUp(void);
+
+ /// Tear down test case.
+ void tearDown(void);
+
+ /// Test constructor.
+ void testConstructor(void);
+
+ /// Test hasField().
+ void testHasField(void);
+
+ /// Test add().
+ void testAdd(void);
+
+ /// Test allocate(label_sequence).
+ void testAllocateSequence(void);
+
+ /// Test allocate(int_array).
+ void testAllocateArray(void);
+
+ /// Test allocate(domain).
+ void testAllocateDomain(void);
+
+ /// Test getField().
+ void testGet(void);
+
+ /// Test getField() for const PackedFields.
+ void testGetConst(void);
+
+ /// Test mesh().
+ void testMesh(void);
+
+ /// Test fiberDim().
+ void testFiberDim(void);
+
+ /// Test sectionIndex().
+ void testSectionIndex(void);
+
+ /// Test sectionFiberDim().
+ void testSectionFiberDim(void);
+
+ /// Test complete().
+ void testComplete(void);
+
+ /// Test fieldNames().
+ void testFieldNames(void);
+
+ /// Test view().
+ void testView(void);
+
+// PRIVATE MEMBERS /////////////////////////////////////////////////////
+private :
+
+ Mesh* _mesh;
+
+}; // class TestPackedFieldsMesh
+
+#endif // pylith_topology_testpackedfieldsmesh_hh
+
+
+// End of file
Modified: short/3D/PyLith/branches/multifields/unittests/libtests/utils/Makefile.am
===================================================================
--- short/3D/PyLith/branches/multifields/unittests/libtests/utils/Makefile.am 2011-05-21 15:29:34 UTC (rev 18411)
+++ short/3D/PyLith/branches/multifields/unittests/libtests/utils/Makefile.am 2011-05-21 16:24:29 UTC (rev 18412)
@@ -35,7 +35,7 @@
testutils_LDADD = \
-lcppunit -ldl \
- $(top_builddir)/libsrc/libpylith.la \
+ $(top_builddir)/libsrc/pylith/libpylith.la \
-lspatialdata \
$(PETSC_LIB) $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
More information about the CIG-COMMITS
mailing list