[cig-commits] r6559 - in short/3D/PyLith/trunk: . libsrc/feassemble
libsrc/materials libsrc/meshio
brad at geodynamics.org
brad at geodynamics.org
Thu Apr 12 14:11:37 PDT 2007
Author: brad
Date: 2007-04-12 14:11:36 -0700 (Thu, 12 Apr 2007)
New Revision: 6559
Modified:
short/3D/PyLith/trunk/TODO
short/3D/PyLith/trunk/libsrc/feassemble/ExplicitElasticity.cc
short/3D/PyLith/trunk/libsrc/feassemble/ParameterManager.cc
short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.cc
short/3D/PyLith/trunk/libsrc/materials/Material.cc
short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc
Log:
Added more error checking on Sieve smart pointers.
Modified: short/3D/PyLith/trunk/TODO
===================================================================
--- short/3D/PyLith/trunk/TODO 2007-04-12 20:17:39 UTC (rev 6558)
+++ short/3D/PyLith/trunk/TODO 2007-04-12 21:11:36 UTC (rev 6559)
@@ -2,17 +2,12 @@
MAIN PRIORITIES (Brad)
======================================================================
-Error checking
-
- add isNull() assertions before using ALE::Obj.
-
0. Update unit testing.
b. Update MeshIOAscii tests (groups of vertices and cells)
1. Finish implementing ExplicitElasticity and Explicit
a. Double check loops for calcConstant() and calcJacobian()
- b. Make sure memory allocation/deallocation is outside loop over cells
b. Create unit test (construction of constant term and Jacobian)
2. Start implementing faults
Modified: short/3D/PyLith/trunk/libsrc/feassemble/ExplicitElasticity.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/ExplicitElasticity.cc 2007-04-12 20:17:39 UTC (rev 6558)
+++ short/3D/PyLith/trunk/libsrc/feassemble/ExplicitElasticity.cc 2007-04-12 21:11:36 UTC (rev 6559)
@@ -68,6 +68,7 @@
const ALE::Obj<Mesh>& mesh)
{ // integrateConstant
assert(0 != _quadrature);
+ assert(0 != _material);
assert(!b.isNull());
assert(!dispT.isNull());
assert(!dispTmdt.isNull());
@@ -75,6 +76,7 @@
// Get information about section
const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
+ assert(!cells.isNull());
const Mesh::label_sequence::iterator cellsEnd = cells->end();
const ALE::Obj<real_section_type>& coordinates =
@@ -290,12 +292,14 @@
const ALE::Obj<Mesh>& mesh)
{ // integrateJacobian
assert(0 != _quadrature);
+ assert(0 != _material);
assert(0 != mat);
assert(!dispT.isNull());
assert(!mesh.isNull());
// Get information about section
const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
+ assert(!cells.isNull());
const Mesh::label_sequence::iterator cellsEnd = cells->end();
const ALE::Obj<real_section_type>& coordinates =
Modified: short/3D/PyLith/trunk/libsrc/feassemble/ParameterManager.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/ParameterManager.cc 2007-04-12 20:17:39 UTC (rev 6558)
+++ short/3D/PyLith/trunk/libsrc/feassemble/ParameterManager.cc 2007-04-12 21:11:36 UTC (rev 6559)
@@ -37,6 +37,8 @@
void
pylith::feassemble::ParameterManager::addReal(const char* name)
{ // addReal
+ assert(!_mesh.isNull());
+
map_real_type::iterator iter = _real.find(name);
if (iter != _real.end()) {
std::ostringstream msg;
Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.cc 2007-04-12 20:17:39 UTC (rev 6558)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.cc 2007-04-12 21:11:36 UTC (rev 6559)
@@ -122,6 +122,8 @@
void
pylith::materials::ElasticMaterial::_getParameters(const Mesh::point_type& cell)
{ // _getParameters
+ assert(0 != _parameters);
+
const int numQuadPts = _numQuadPts;
assert(_paramsCell.size() == numQuadPts);
@@ -131,6 +133,7 @@
for (int iParam=0; iParam < numParams; ++iParam) {
const ALE::Obj<real_section_type> parameter =
_parameters->getReal(paramNames[iParam]);
+ assert(!parameter.isNull());
assert(parameter->getFiberDimension(cell) == numQuadPts);
const real_section_type::value_type* parameterCell =
Modified: short/3D/PyLith/trunk/libsrc/materials/Material.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/Material.cc 2007-04-12 20:17:39 UTC (rev 6558)
+++ short/3D/PyLith/trunk/libsrc/materials/Material.cc 2007-04-12 21:11:36 UTC (rev 6559)
@@ -68,6 +68,7 @@
assert(0 != _db);
assert(0 != cs);
assert(0 != quadrature);
+ assert(!mesh.isNull());
typedef ALE::Mesh::real_section_type real_section_type;
@@ -76,6 +77,7 @@
mesh->getRealSection("coordinates");
const ALE::Obj<ALE::Mesh::label_sequence>& cells =
mesh->getLabelStratum("material-id", _id);
+ assert(!cells.isNull());
const ALE::Mesh::label_sequence::iterator cellsEnd = cells->end();
// Check to make sure we have cells
@@ -87,6 +89,7 @@
// Create sections to hold parameters for physical properties
delete _parameters; _parameters = new feassemble::ParameterManager(mesh);
+ assert(0 != _parameters);
const int numQuadPts = quadrature->numQuadPts();
const int fiberDim = numQuadPts; // number of values in field per cell
@@ -98,6 +101,7 @@
for (int iParam=0; iParam < numParams; ++iParam) {
_parameters->addReal(paramNames[iParam]);
paramSections[iParam] = _parameters->getReal(paramNames[iParam]);
+ assert(!paramSections[iParam].isNull());
paramSections[iParam]->setFiberDimension(cells, fiberDim);
mesh->allocate(paramSections[iParam]);
} // for
Modified: short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc 2007-04-12 20:17:39 UTC (rev 6558)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc 2007-04-12 21:11:36 UTC (rev 6559)
@@ -41,6 +41,7 @@
pylith::meshio::MeshIO::getMeshDim(void) const
{ // getMeshDim
assert(0 != _mesh);
+ assert(!_mesh->isNull());
return (*_mesh)->getDimension();
} // getMeshDim
@@ -82,6 +83,7 @@
assert(0 != _mesh);
*_mesh = new Mesh(PETSC_COMM_WORLD, meshDim);
+ _mesh->addRef();
assert(!_mesh->isNull());
(*_mesh)->setDebug(_debug);
@@ -105,12 +107,13 @@
int* pSpaceDim) const
{ // _getVertices
assert(0 != _mesh);
- ALE::Obj<Mesh>& mesh = *_mesh;
- mesh.addRef();
+ assert(!_mesh->isNull());
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
+ const ALE::Obj<Mesh::label_sequence>& vertices = (*_mesh)->depthStratum(0);
+ assert(!vertices.isNull());
const ALE::Obj<Mesh::real_section_type>& coordsField =
- mesh->getRealSection("coordinates");
+ (*_mesh)->getRealSection("coordinates");
+ assert(!coordsField.isNull());
const int numVertices = vertices->size();
const int spaceDim =
@@ -149,19 +152,20 @@
int* pMeshDim) const
{ // _getCells
assert(0 != _mesh);
- ALE::Obj<Mesh>& mesh = *_mesh;
- mesh.addRef();
+ assert(!_mesh->isNull());
- const ALE::Obj<sieve_type>& sieve = mesh->getSieve();
- const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
+ const ALE::Obj<sieve_type>& sieve = (*_mesh)->getSieve();
+ assert(!sieve.isNull());
+ const ALE::Obj<Mesh::label_sequence>& cells = (*_mesh)->heightStratum(0);
+ assert(!cells.isNull());
- const int meshDim = mesh->getDimension();
+ const int meshDim = (*_mesh)->getDimension();
const int numCells = cells->size();
const int numCorners = sieve->nCone(*cells->begin(),
- mesh->depth())->size();
+ (*_mesh)->depth())->size();
const ALE::Obj<Mesh::numbering_type>& vNumbering =
- mesh->getFactory()->getLocalNumbering(mesh, 0);
+ (*_mesh)->getFactory()->getLocalNumbering(*_mesh, 0);
int* cellsArray = 0;
const int size = numCells * numCorners;
@@ -199,10 +203,10 @@
const int numCells)
{ // _setMaterials
assert(0 != _mesh);
- ALE::Obj<Mesh>& mesh = *_mesh;
- mesh.addRef();
+ assert(!_mesh->isNull());
- const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
+ const ALE::Obj<Mesh::label_sequence>& cells = (*_mesh)->heightStratum(0);
+ assert(!cells.isNull());
if (cells->size() != numCells) {
std::ostringstream msg;
@@ -212,13 +216,13 @@
throw std::runtime_error(msg.str());
} // if
- const ALE::Obj<label_type>& labelMaterials = mesh->createLabel("material-id");
+ const ALE::Obj<label_type>& labelMaterials = (*_mesh)->createLabel("material-id");
int i = 0;
for(Mesh::label_sequence::iterator e_iter = cells->begin();
e_iter != cells->end();
++e_iter)
- mesh->setValue(labelMaterials, *e_iter, materialIds[i++]);
+ (*_mesh)->setValue(labelMaterials, *e_iter, materialIds[i++]);
} // _setMaterials
// ----------------------------------------------------------------------
@@ -228,10 +232,10 @@
int* pNumCells) const
{ // _getMaterials
assert(0 != _mesh);
- ALE::Obj<Mesh>& mesh = *_mesh;
- mesh.addRef();
+ assert(!_mesh->isNull());
- const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
+ const ALE::Obj<Mesh::label_sequence>& cells = (*_mesh)->heightStratum(0);
+ assert(!cells.isNull());
const int numCells = cells->size();
int* materialsArray = 0;
@@ -239,7 +243,8 @@
if (0 != pMaterialIds && size > 0) {
materialsArray = new int[size];
- const ALE::Obj<label_type>& labelMaterials = mesh->getLabel("material-id");
+ const ALE::Obj<label_type>& labelMaterials =
+ (*_mesh)->getLabel("material-id");
const int idDefault = 0;
int i = 0;
@@ -247,7 +252,7 @@
e_iter != cells->end();
++e_iter)
materialsArray[i++] =
- mesh->getValue(labelMaterials, *e_iter, idDefault);
+ (*_mesh)->getValue(labelMaterials, *e_iter, idDefault);
} // if
if (0 != pMaterialIds)
@@ -265,23 +270,23 @@
const int* points)
{ // _buildMesh
assert(0 != _mesh);
+ assert(!_mesh->isNull());
- ALE::Obj<Mesh>& mesh = *_mesh;
- mesh.addRef();
+ const ALE::Obj<Mesh::int_section_type>& groupField =
+ (*_mesh)->getIntSection(name);
+ assert(!groupField.isNull());
- const ALE::Obj<Mesh::int_section_type>& groupField = mesh->getIntSection(name);
-
if (CELL == type) {
for(int i = 0; i < numPoints; ++i) {
groupField->setFiberDimension(points[i], 1);
}
} else if (VERTEX == type) {
- const int numCells = mesh->heightStratum(0)->size();
+ const int numCells = (*_mesh)->heightStratum(0)->size();
for(int i = 0; i < numPoints; ++i) {
groupField->setFiberDimension(points[i]+numCells, 1);
}
} // if
- mesh->allocate(groupField);
+ (*_mesh)->allocate(groupField);
} // _buildMesh
// ----------------------------------------------------------------------
@@ -296,34 +301,42 @@
// Get group entities
void
pylith::meshio::MeshIO::_getGroup(const char *name,
- PointType& type,
- int& numPoints,
- int *points[]) const
+ PointType& type,
+ int& numPoints,
+ int *points[]) const
{ // _getMaterials
assert(0 != _mesh);
- ALE::Obj<Mesh>& mesh = *_mesh;
- mesh.addRef();
+ assert(!_mesh->isNull());
+ assert(0 != points);
- const ALE::Obj<Mesh::int_section_type>& groupField = mesh->getIntSection(name);
- const Mesh::int_section_type::chart_type& chart = groupField->getChart();
- const Mesh::point_type firstPoint = *chart.begin();
- ALE::Obj<Mesh::numbering_type> numbering;
+ const ALE::Obj<Mesh::int_section_type>& groupField =
+ (*_mesh)->getIntSection(name);
+ assert(!groupField.isNull());
+ const Mesh::int_section_type::chart_type& chart =
+ groupField->getChart();
+ const Mesh::point_type firstPoint = *chart.begin();
+ ALE::Obj<Mesh::numbering_type> numbering;
- if (mesh->height(firstPoint) == 0) {
- type = CELL;
- numbering = mesh->getFactory()->getNumbering(mesh, mesh->depth());
+ if ((*_mesh)->height(firstPoint) == 0) {
+ type = CELL;
+ numbering = (*_mesh)->getFactory()->getNumbering(*_mesh,
+ (*_mesh)->depth());
} else {
- type = VERTEX;
- numbering = mesh->getFactory()->getNumbering(mesh, 0);
- }
+ type = VERTEX;
+ numbering = (*_mesh)->getFactory()->getNumbering(*_mesh, 0);
+ } // if/else
numPoints = chart.size();
int *indices = new int[numPoints];
- int i = 0;
+ int i = 0;
- for(Mesh::int_section_type::chart_type::iterator c_iter = chart.begin(); c_iter != chart.end(); ++c_iter) {
+ for(Mesh::int_section_type::chart_type::iterator c_iter = chart.begin();
+ c_iter != chart.end();
+ ++c_iter) {
+ assert(!numbering.isNull());
indices[i++] = numbering->getIndex(*c_iter);
}
*points = indices;
} // _getMaterials
+
// End of file
More information about the cig-commits
mailing list