[cig-commits] r21762 - short/3D/PyLith/trunk/libsrc/pylith/meshio
brad at geodynamics.org
brad at geodynamics.org
Mon Apr 8 09:19:21 PDT 2013
Author: brad
Date: 2013-04-08 09:19:21 -0700 (Mon, 08 Apr 2013)
New Revision: 21762
Modified:
short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputManager.cc
Log:
Start code cleanup.
Modified: short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputManager.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputManager.cc 2013-04-08 16:16:35 UTC (rev 21761)
+++ short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputManager.cc 2013-04-08 16:19:21 UTC (rev 21762)
@@ -63,40 +63,52 @@
// Set coordinate system in output. The vertex fields in the output
template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager<mesh_type, field_type>::coordsys(
- const spatialdata::geocoords::CoordSys* cs)
+pylith::meshio::OutputManager<mesh_type, field_type>::coordsys(const spatialdata::geocoords::CoordSys* cs)
{ // coordsys
- delete _coordsys; _coordsys = (0 != cs) ? cs->clone() : 0;
+ PYLITH_METHOD_BEGIN;
+
+ delete _coordsys; _coordsys = (cs) ? cs->clone() : 0;
+
+ PYLITH_METHOD_END;
} // coordsys
// ----------------------------------------------------------------------
// Set writer to write data to file.
template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager<mesh_type, field_type>::writer(
- DataWriter<mesh_type, field_type>* const datawriter)
+pylith::meshio::OutputManager<mesh_type, field_type>::writer(DataWriter<mesh_type, field_type>* const datawriter)
{ // writer
+ PYLITH_METHOD_BEGIN;
+
_writer = datawriter; // :TODO: Use shared pointer
+
+ PYLITH_METHOD_END;
} // writer
// ----------------------------------------------------------------------
// Set filter for vertex data.
template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager<mesh_type, field_type>::vertexFilter(
- VertexFilter<field_type>* const filter)
+pylith::meshio::OutputManager<mesh_type, field_type>::vertexFilter(VertexFilter<field_type>* const filter)
{ // vertexFilter
+ PYLITH_METHOD_BEGIN;
+
_vertexFilter = filter; // :TODO: Use shared pointer
+
+ PYLITH_METHOD_END;
} // vertexFilter
// ----------------------------------------------------------------------
// Set filter for cell data.
template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager<mesh_type, field_type>::cellFilter(
- CellFilter<mesh_type, field_type>* const filter)
+pylith::meshio::OutputManager<mesh_type, field_type>::cellFilter(CellFilter<mesh_type, field_type>* const filter)
{ // cellFilter
+ PYLITH_METHOD_BEGIN;
+
_cellFilter = filter; // :TODO: Use shared pointer
+
+ PYLITH_METHOD_END;
} // cellFilter
// ----------------------------------------------------------------------
@@ -105,19 +117,22 @@
const pylith::topology::Fields<field_type>*
pylith::meshio::OutputManager<mesh_type, field_type>::fields(void) const
{ // fields
- return _fields;
+ PYLITH_METHOD_BEGIN;
+
+ PYLITH_METHOD_RETURN(_fields);
} // fields
// ----------------------------------------------------------------------
// Prepare for output.
template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager<mesh_type, field_type>::open(
- const mesh_type& mesh,
- const int numTimeSteps,
- const char* label,
- const int labelId)
+pylith::meshio::OutputManager<mesh_type, field_type>::open(const mesh_type& mesh,
+ const int numTimeSteps,
+ const char* label,
+ const int labelId)
{ // open
+ PYLITH_METHOD_BEGIN;
+
if (!_writer) {
std::ostringstream msg;
if (label) {
@@ -130,6 +145,8 @@
assert(_writer);
_writer->open(mesh, numTimeSteps, label, labelId);
+
+ PYLITH_METHOD_END;
} // open
// ----------------------------------------------------------------------
@@ -138,22 +155,29 @@
void
pylith::meshio::OutputManager<mesh_type, field_type>::close(void)
{ // close
+ PYLITH_METHOD_BEGIN;
+
assert(_writer);
_writer->close();
+
+ PYLITH_METHOD_END;
} // close
// ----------------------------------------------------------------------
// Setup file for writing fields at time step.
template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager<mesh_type, field_type>::openTimeStep(
- const PylithScalar t,
- const mesh_type& mesh,
- const char* label,
- const int labelId)
+pylith::meshio::OutputManager<mesh_type, field_type>::openTimeStep(const PylithScalar t,
+ const mesh_type& mesh,
+ const char* label,
+ const int labelId)
{ // openTimeStep
+ PYLITH_METHOD_BEGIN;
+
assert(_writer);
_writer->openTimeStep(t, mesh, label, labelId);
+
+ PYLITH_METHOD_END;
} // openTimeStep
// ----------------------------------------------------------------------
@@ -162,45 +186,53 @@
void
pylith::meshio::OutputManager<mesh_type, field_type>::closeTimeStep(void)
{ // closeTimeStep
+ PYLITH_METHOD_BEGIN;
+
assert(_writer);
_writer->closeTimeStep();
+
+ PYLITH_METHOD_END;
} // closeTimeStep
// ----------------------------------------------------------------------
// Append finite-element vertex field to file.
template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager<mesh_type, field_type>::appendVertexField(
- const PylithScalar t,
- field_type& field,
- const mesh_type& mesh)
+pylith::meshio::OutputManager<mesh_type, field_type>::appendVertexField(const PylithScalar t,
+ field_type& field,
+ const mesh_type& mesh)
{ // appendVertexField
- field_type& fieldFiltered =
- (0 == _vertexFilter) ? field : _vertexFilter->filter(field);
+ PYLITH_METHOD_BEGIN;
+
+ field_type& fieldFiltered = (!_vertexFilter) ? field : _vertexFilter->filter(field);
field_type& fieldDimensioned = _dimension(fieldFiltered);
_writer->writeVertexField(t, fieldDimensioned, mesh);
+
+ PYLITH_METHOD_END;
} // appendVertexField
// ----------------------------------------------------------------------
// Append finite-element cell field to file.
template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager<mesh_type, field_type>::appendCellField(
- const PylithScalar t,
- field_type& field,
- const char* label,
- const int labelId)
+pylith::meshio::OutputManager<mesh_type, field_type>::appendCellField(const PylithScalar t,
+ field_type& field,
+ const char* label,
+ const int labelId)
{ // appendCellField
- field_type& fieldFiltered =
- (0 == _cellFilter) ? field : _cellFilter->filter(field, label, labelId);
+ PYLITH_METHOD_BEGIN;
+
+ field_type& fieldFiltered = (!_cellFilter) ? field : _cellFilter->filter(field, label, labelId);
field_type& fieldDimensioned = _dimension(fieldFiltered);
try {
_writer->writeCellField(t, fieldDimensioned, label, labelId);
} catch(std::runtime_error e) {
std::cout << "ERROR: " << e.what() << std::endl<<std::endl<<std::endl;
- }
+ } // try/catch
+
+ PYLITH_METHOD_END;
} // appendCellField
// ----------------------------------------------------------------------
@@ -209,12 +241,14 @@
field_type&
pylith::meshio::OutputManager<mesh_type, field_type>::_dimension(field_type& fieldIn)
{ // _dimension
+ PYLITH_METHOD_BEGIN;
+
if (1.0 == fieldIn.scale())
- return fieldIn;
+ PYLITH_METHOD_RETURN(fieldIn);
if (fieldIn.addDimensionOkay()) {
fieldIn.dimensionalize();
- return fieldIn;
+ PYLITH_METHOD_RETURN(fieldIn);
} else {
std::string fieldName = "buffer (other)";
switch (fieldIn.vectorFieldType())
@@ -267,11 +301,11 @@
fieldOut.addDimensionOkay(true);
fieldOut.dimensionalize();
- return fieldOut;
+ PYLITH_METHOD_RETURN(fieldOut);
} // if/else
// Satisfy return value. Should never get this far.
- return fieldIn;
+ PYLITH_METHOD_RETURN(fieldIn);
} // _dimension
More information about the CIG-COMMITS
mailing list