[cig-commits] r17184 - in short/3D/PyLith/trunk: libsrc/topology unittests/libtests/topology
brad at geodynamics.org
brad at geodynamics.org
Sat Sep 11 15:12:43 PDT 2010
Author: brad
Date: 2010-09-11 15:12:43 -0700 (Sat, 11 Sep 2010)
New Revision: 17184
Modified:
short/3D/PyLith/trunk/libsrc/topology/FieldsNew.cc
short/3D/PyLith/trunk/libsrc/topology/FieldsNew.hh
short/3D/PyLith/trunk/libsrc/topology/UniformSectionDS.cc
short/3D/PyLith/trunk/libsrc/topology/UniformSectionDS.hh
short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsNewMesh.cc
Log:
Switched UniformSectionDS::getFibration() and FieldsNew::field() to return IGeneralSection with shared storage.
Modified: short/3D/PyLith/trunk/libsrc/topology/FieldsNew.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/FieldsNew.cc 2010-09-10 00:10:23 UTC (rev 17183)
+++ short/3D/PyLith/trunk/libsrc/topology/FieldsNew.cc 2010-09-11 22:12:43 UTC (rev 17184)
@@ -221,7 +221,7 @@
// ----------------------------------------------------------------------
// Get field.
template<typename mesh_type>
-const pylith::topology::Field<mesh_type, typename pylith::topology::FieldsNew<mesh_type>::section_type>&
+const pylith::topology::Field<mesh_type>&
pylith::topology::FieldsNew<mesh_type>::get(const char* name) const
{ // get
typename map_type::const_iterator f_iter = _fields.find(name);
@@ -248,7 +248,7 @@
// ----------------------------------------------------------------------
// Get field.
template<typename mesh_type>
-pylith::topology::Field<mesh_type, typename pylith::topology::FieldsNew<mesh_type>::section_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);
@@ -264,8 +264,8 @@
delete f_iter->second.field; f_iter->second.field = 0;
assert(!_section.isNull());
f_iter->second.field =
- new Field<mesh_type, section_type>(_mesh, _section->getFibration(fibration),
- f_iter->second.metadata);
+ new Field<mesh_type>(_mesh, _section->getFibration(fibration),
+ f_iter->second.metadata);
assert(0 != f_iter->second.field);
return *f_iter->second.field;
Modified: short/3D/PyLith/trunk/libsrc/topology/FieldsNew.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/FieldsNew.hh 2010-09-10 00:10:23 UTC (rev 17183)
+++ short/3D/PyLith/trunk/libsrc/topology/FieldsNew.hh 2010-09-11 22:12:43 UTC (rev 17184)
@@ -111,13 +111,13 @@
*
* @param name Name of field.
*/
- const Field<mesh_type, section_type>& get(const char* name) const;
+ const Field<mesh_type>& get(const char* name) const;
/** Get field.
*
* @param name Name of field.
*/
- Field<mesh_type, section_type>& get(const char* name);
+ Field<mesh_type>& get(const char* name);
/** Get mesh associated with fields.
*
@@ -151,7 +151,7 @@
struct FieldInfo {
FieldBase::Metadata metadata; ///< Metadata for field.
- Field<mesh_type, section_type>* field; ///< Single 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.
Modified: short/3D/PyLith/trunk/libsrc/topology/UniformSectionDS.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/UniformSectionDS.cc 2010-09-10 00:10:23 UTC (rev 17183)
+++ short/3D/PyLith/trunk/libsrc/topology/UniformSectionDS.cc 2010-09-11 22:12:43 UTC (rev 17184)
@@ -707,7 +707,8 @@
const std::vector<Obj<atlas_type> >& spaces = section->getSpaces();
this->_spaces.clear();
- const typename std::vector<Obj<atlas_type> >::const_iteraor spacesEnd = spaces.end();
+ const typename std::vector<Obj<atlas_type> >::const_iteraor spacesEnd
+ = spaces.end();
for(typename std::vector<Obj<atlas_type> >::const_iterator s_iter=spaces.begin();
s_iter != spacesEnd;
++s_iter)
@@ -718,47 +719,51 @@
template<typename point_type,
typename value_type,
typename alloc_type>
-ALE::Obj<ALE::IUniformSectionDS<point_type, value_type, alloc_type> >
+ALE::Obj<ALE::IGeneralSection<point_type, value_type, alloc_type> >
ALE::IUniformSectionDS<point_type, value_type, alloc_type>::getFibration(const int space) const {
+ typedef typename ALE::IGeneralSection<point_type, value_type, alloc_type>::chart_type IGeneralSection_chart_type;
+ typedef typename ALE::IGeneralSection<point_type, value_type, alloc_type>::atlas_type IGeneralSection_atlas_type;
+
+ Obj<IGeneralSection<point_type, value_type, alloc_type> > field =
+ new IGeneralSection<point_type, value_type, alloc_type>(this->comm(),
+ this->debug());
+ field->setChart(this->getChart());
const chart_type& chart = this->getChart();
- const int localFiberDim = this->getFiberDimension(*chart.begin(), space);
- int fiberDim = 0;
- MPI_Allreduce((void *) &localFiberDim, (void *) &fiberDim, 1,
- MPI_INT, MPI_MAX, this->comm());
- assert(fiberDim > 0);
- Obj<IUniformSectionDS> field = new IUniformSectionDS(this->comm(),
- fiberDim,
- this->debug());
- field->_atlas->setChart(chart);
-
// Copy sizes
const typename chart_type::const_iterator chartEnd = chart.end();
- for(typename chart_type::const_iterator c_iter=chart.begin();
- c_iter != chartEnd;
- ++c_iter) {
- const int fDim = this->getFiberDimension(*c_iter, space);
- if (fDim)
- field->setFiberDimension(*c_iter, fDim);
+ for(typename chart_type::const_iterator c_iter = chart.begin(); c_iter != chartEnd; ++c_iter) {
+ const int fiberDim = this->getFiberDimension(*c_iter, space);
+
+ if (fiberDim)
+ field->setFiberDimension(*c_iter, fiberDim);
} // for
- field->allocatePoint();
+ field->allocateStorage();
+ Obj<IGeneralSection_atlas_type> newAtlas =
+ new IGeneralSection_atlas_type(this->comm(), this->debug());
+ const IGeneralSection_chart_type& newChart = field->getChart();
- // Copy values
- value_type* spaceValues = (fiberDim > 0) ? new value_type[fiberDim] : NULL;
- const chart_type& newChart = field->getChart();
- const typename chart_type::const_iterator newChartEnd = newChart.end();
- for(typename chart_type::const_iterator c_iter = newChart.begin();
- c_iter != newChartEnd;
- ++c_iter)
- if (field->getFiberDimension(*c_iter) > 0) {
- assert(fiberDim <= field->getFiberDimension(*c_iter));
- const value_type* allValues = this->restrictPoint(*c_iter);
- for (int i=0; i < fiberDim; ++i)
- spaceValues[i] = allValues[i];
- field->updatePoint(*c_iter, spaceValues);
- } // if
- delete[] spaceValues; spaceValues = NULL;
+ // Copy offsets
+ newAtlas->setChart(newChart);
+ newAtlas->allocatePoint();
+ const typename IGeneralSection_chart_type::const_iterator newChartEnd =
+ newChart.end();
+ for (typename IGeneralSection_chart_type::const_iterator c_iter=newChart.begin();
+ c_iter != newChartEnd;
+ ++c_iter) {
+ typename IGeneralSection<point_type, value_type, alloc_type>::index_type idx;
+
+ idx.prefix = field->getFiberDimension(*c_iter);
+ idx.index = this->_atlas->restrictPoint(*c_iter)[0];
+ for(int s = 0; s < space; ++s)
+ idx.index += this->getFiberDimension(*c_iter, s);
+ newAtlas->addPoint(*c_iter);
+ newAtlas->updatePoint(*c_iter, &idx);
+ } // for
+ field->replaceStorage(this->_array, true, this->sizeWithBC());
+ field->setAtlas(newAtlas);
+
return field;
} // getFibration
Modified: short/3D/PyLith/trunk/libsrc/topology/UniformSectionDS.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/UniformSectionDS.hh 2010-09-10 00:10:23 UTC (rev 17183)
+++ short/3D/PyLith/trunk/libsrc/topology/UniformSectionDS.hh 2010-09-11 22:12:43 UTC (rev 17184)
@@ -177,7 +177,8 @@
template<typename OtherSection>
void copyFibration(const Obj<OtherSection>& section);
- Obj<IUniformSectionDS> getFibration(const int space) const;
+ Obj<ALE::IGeneralSection<point_type, value_type, alloc_type> >
+ getFibration(const int space) const;
// PROTECTED MEMBERS ////////////////////////////////////////////////////
protected:
Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsNewMesh.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsNewMesh.cc 2010-09-10 00:10:23 UTC (rev 17183)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsNewMesh.cc 2010-09-11 22:12:43 UTC (rev 17184)
@@ -218,14 +218,14 @@
fields.add("field B", "displacement", 4, FieldBase::OTHER, 2.0, true);
fields.allocate(FieldBase::VERTICES_FIELD);
- Field<Mesh, section_type>& fieldA = fields.get("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());
- Field<Mesh, section_type>& fieldB = fields.get("field B");
+ Field<Mesh>& fieldB = fields.get("field B");
CPPUNIT_ASSERT_EQUAL(std::string("displacement"),
std::string(fieldB.label()));
CPPUNIT_ASSERT_EQUAL(FieldBase::OTHER,
@@ -246,14 +246,14 @@
fields.add("field B", "displacement", 4, FieldBase::OTHER, 2.0, true);
fields.allocate(FieldBase::VERTICES_FIELD);
- const Field<Mesh, section_type>& fieldA = fields.get("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 Field<Mesh, section_type>& fieldB = fields.get("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,
More information about the CIG-COMMITS
mailing list