From cf8f263f55fe6b417b9d1164e7e6b8157b431836 Mon Sep 17 00:00:00 2001 From: Kenneth Leiter Date: Tue, 26 Oct 2010 12:15:11 -0400 Subject: [PATCH] ENH: Cleanup comments and inheritance syntax a bit. Remove unnecessary Geometry Types not needed since splitting structured and unstructured grids into separate hierarchies. --- XdmfGeometryType.cpp | 40 -------------------------------------- XdmfGeometryType.hpp | 10 ---------- XdmfGrid.cpp | 6 +++--- XdmfGrid.hpp | 5 ++++- XdmfGridCollection.cpp | 4 +++- XdmfGridCurvilinear.cpp | 3 ++- XdmfGridRectilinear.cpp | 3 +-- XdmfGridRegular.cpp | 3 +-- XdmfGridUnstructured.cpp | 4 +++- XdmfGridUnstructured.hpp | 9 ++++----- XdmfTopologyType.hpp | 6 ------ core/XdmfCoreReader.hpp | 2 ++ utils/XdmfExodusWriter.cpp | 22 +++++---------------- 13 files changed, 28 insertions(+), 89 deletions(-) diff --git a/XdmfGeometryType.cpp b/XdmfGeometryType.cpp index 734a772e..9dff2201 100644 --- a/XdmfGeometryType.cpp +++ b/XdmfGeometryType.cpp @@ -26,30 +26,6 @@ boost::shared_ptr XdmfGeometryType::XY() return p; } -boost::shared_ptr XdmfGeometryType::X_Y_Z() -{ - static boost::shared_ptr p(new XdmfGeometryType("X_Y_Z", 3)); - return p; -} - -boost::shared_ptr XdmfGeometryType::X_Y() -{ - static boost::shared_ptr p(new XdmfGeometryType("X_Y", 2)); - return p; -} - -boost::shared_ptr XdmfGeometryType::VXVYVZ() -{ - static boost::shared_ptr p(new XdmfGeometryType("VXVYVZ", 3)); - return p; -} - -boost::shared_ptr XdmfGeometryType::VXVY() -{ - static boost::shared_ptr p(new XdmfGeometryType("VXVY", 2)); - return p; -} - XdmfGeometryType::XdmfGeometryType(const std::string& name, const int& dimensions) : mDimensions(dimensions), mName(name) @@ -83,22 +59,6 @@ boost::shared_ptr XdmfGeometryType::New(const std::map NoGeometryType(); static boost::shared_ptr XYZ(); static boost::shared_ptr XY(); - static boost::shared_ptr X_Y_Z(); - static boost::shared_ptr X_Y(); - static boost::shared_ptr VXVYVZ(); - static boost::shared_ptr VXVY(); /** * Get the dimensions of this geometry type - i.e. XYZ = 3. diff --git a/XdmfGrid.cpp b/XdmfGrid.cpp index 6104d4ca..58cc2330 100644 --- a/XdmfGrid.cpp +++ b/XdmfGrid.cpp @@ -16,9 +16,9 @@ XDMF_CHILDREN_IMPLEMENTATION(XdmfGrid, XdmfAttribute, Attribute, Name) XDMF_CHILDREN_IMPLEMENTATION(XdmfGrid, XdmfSet, Set, Name) -XdmfGrid::XdmfGrid(const std::string & name) : - mGeometry(XdmfGeometry::New()), - mTopology(XdmfTopology::New()), +XdmfGrid::XdmfGrid(const boost::shared_ptr geometry, const boost::shared_ptr topology, const std::string & name) : + mGeometry(geometry), + mTopology(topology), mMap(boost::shared_ptr()), mName(name), mTime(boost::shared_ptr()) diff --git a/XdmfGrid.hpp b/XdmfGrid.hpp index 0c1b9a92..501905c5 100644 --- a/XdmfGrid.hpp +++ b/XdmfGrid.hpp @@ -19,6 +19,8 @@ class XdmfTopology; * that stores point locations and an XdmfTopology that store connectivity information. XdmfAttributes can be inserted * into the XdmfGrid to specify fields centered on various parts of the mesh. XdmfSets can be inserted into XdmfGrids * to specify collections of mesh elements. + * + * XdmfGrid is an abstract base class. There are several implementations for representing both structured and unstructured grids. */ class XdmfGrid : public virtual XdmfItem { @@ -111,7 +113,8 @@ public: protected: - XdmfGrid(const std::string & name = "Grid"); + XdmfGrid(const boost::shared_ptr geometry, const boost::shared_ptr topology, const std::string & name = "Grid"); + virtual void populateItem(const std::map & itemProperties, std::vector > & childItems, const XdmfCoreReader * const reader); boost::shared_ptr mGeometry; diff --git a/XdmfGridCollection.cpp b/XdmfGridCollection.cpp index 111b7b31..1231de2a 100644 --- a/XdmfGridCollection.cpp +++ b/XdmfGridCollection.cpp @@ -5,6 +5,8 @@ * Author: kleiter */ +#include "XdmfGeometry.hpp" +#include "XdmfTopology.hpp" #include "XdmfGridCollection.hpp" #include "XdmfGridCollectionType.hpp" @@ -16,7 +18,7 @@ boost::shared_ptr XdmfGridCollection::New() XdmfGridCollection::XdmfGridCollection() : XdmfDomain(), - XdmfGrid("Collection"), + XdmfGrid(XdmfGeometry::New(), XdmfTopology::New(), "Collection"), mType(XdmfGridCollectionType::NoCollectionType()) { } diff --git a/XdmfGridCurvilinear.cpp b/XdmfGridCurvilinear.cpp index 418260db..b2f97f33 100644 --- a/XdmfGridCurvilinear.cpp +++ b/XdmfGridCurvilinear.cpp @@ -7,6 +7,7 @@ #include #include "XdmfArray.hpp" +#include "XdmfGeometry.hpp" #include "XdmfGridCurvilinear.hpp" #include "XdmfTopology.hpp" #include "XdmfTopologyType.hpp" @@ -141,9 +142,9 @@ boost::shared_ptr XdmfGridCurvilinear::New(const boost::sha } XdmfGridCurvilinear::XdmfGridCurvilinear(const boost::shared_ptr numPoints) : + XdmfGrid(XdmfGeometry::New(), XdmfGridCurvilinearImpl::XdmfTopologyCurvilinear::New(this)), mImpl(new XdmfGridCurvilinearImpl(numPoints)) { - mTopology = XdmfGridCurvilinearImpl::XdmfTopologyCurvilinear::New(this); } XdmfGridCurvilinear::~XdmfGridCurvilinear() diff --git a/XdmfGridRectilinear.cpp b/XdmfGridRectilinear.cpp index 33e26a29..e1d53ef2 100644 --- a/XdmfGridRectilinear.cpp +++ b/XdmfGridRectilinear.cpp @@ -235,10 +235,9 @@ boost::shared_ptr XdmfGridRectilinear::New(const std::vecto } XdmfGridRectilinear::XdmfGridRectilinear(const std::vector > & axesCoordinates) : + XdmfGrid(XdmfGridRectilinearImpl::XdmfGeometryRectilinear::New(this), XdmfGridRectilinearImpl::XdmfTopologyRectilinear::New(this)), mImpl(new XdmfGridRectilinearImpl(axesCoordinates)) { - mGeometry = XdmfGridRectilinearImpl::XdmfGeometryRectilinear::New(this); - mTopology = XdmfGridRectilinearImpl::XdmfTopologyRectilinear::New(this); } XdmfGridRectilinear::~XdmfGridRectilinear() diff --git a/XdmfGridRegular.cpp b/XdmfGridRegular.cpp index 42bf4231..4049bc05 100644 --- a/XdmfGridRegular.cpp +++ b/XdmfGridRegular.cpp @@ -259,10 +259,9 @@ boost::shared_ptr XdmfGridRegular::New(const boost::shared_ptr< XdmfGridRegular::XdmfGridRegular(const boost::shared_ptr brickSize, const boost::shared_ptr numPoints, const boost::shared_ptr origin) : + XdmfGrid(XdmfGridRegularImpl::XdmfGeometryRegular::New(this), XdmfGridRegularImpl::XdmfTopologyRegular::New(this)), mImpl(new XdmfGridRegularImpl(brickSize, numPoints, origin)) { - mGeometry = XdmfGridRegularImpl::XdmfGeometryRegular::New(this); - mTopology = XdmfGridRegularImpl::XdmfTopologyRegular::New(this); } XdmfGridRegular::~XdmfGridRegular() diff --git a/XdmfGridUnstructured.cpp b/XdmfGridUnstructured.cpp index 3a26ee82..80d506c4 100644 --- a/XdmfGridUnstructured.cpp +++ b/XdmfGridUnstructured.cpp @@ -5,7 +5,9 @@ * Author: kleiter */ +#include "XdmfGeometry.hpp" #include "XdmfGridUnstructured.hpp" +#include "XdmfTopology.hpp" boost::shared_ptr XdmfGridUnstructured::New() { @@ -14,7 +16,7 @@ boost::shared_ptr XdmfGridUnstructured::New() } XdmfGridUnstructured::XdmfGridUnstructured() : - XdmfGrid() + XdmfGrid(XdmfGeometry::New(), XdmfTopology::New()) { } diff --git a/XdmfGridUnstructured.hpp b/XdmfGridUnstructured.hpp index ca773f95..e287c10f 100644 --- a/XdmfGridUnstructured.hpp +++ b/XdmfGridUnstructured.hpp @@ -5,12 +5,11 @@ #include "XdmfGrid.hpp" /** - * @brief A mesh containing elements, points, and fields attached to the mesh. + * @brief An unstructured grid consisting of elements, points, and fields attached to the mesh. * - * XdmfGrid represents a mesh. It is required to contain two other Xdmf data structures, an XdmfGeometry - * that stores point locations and an XdmfTopology that store connectivity information. XdmfAttributes can be inserted - * into the XdmfGrid to specify fields centered on various parts of the mesh. XdmfSets can be inserted into XdmfGrids - * to specify collections of mesh elements. + * After creating an unstructured grid, the XdmfGeometry and XdmfTopology must be set. The XdmfTopology + * describes the element types contained in the grid and their connectivity. The XdmfGeometry describes the + * location of nodes. */ class XdmfGridUnstructured : public XdmfGrid { diff --git a/XdmfTopologyType.hpp b/XdmfTopologyType.hpp index 25acff66..4aef0d56 100644 --- a/XdmfTopologyType.hpp +++ b/XdmfTopologyType.hpp @@ -36,12 +36,6 @@ * Hexahedron_125 - 125 Node Tri-Quartic Hexahedron * Hexahedron_125_GLL - 125 Node Spectral Tri-Quartic Hexahedron with Gauss-Lobatto-Legendre points. * Mixed - Mixture of Unstructured Topologies - * TwoDSMesh - * TwoDRectMesh - * TwoDCoRectMesh - * ThreeDSMesh - * ThreeDRectMesh - * ThreeDCoRectMesh */ class XdmfTopologyType : public XdmfItemProperty { diff --git a/core/XdmfCoreReader.hpp b/core/XdmfCoreReader.hpp index 95c7f3ea..797a99c2 100644 --- a/core/XdmfCoreReader.hpp +++ b/core/XdmfCoreReader.hpp @@ -15,6 +15,8 @@ class XdmfItem; * * Reads an Xdmf structured file stored on disk into an Xdmf structure in memory. All light data is parsed in order to create appropriate * Xdmf objects. Heavy data controllers are created and attached to XdmfArrays but no heavy data is read into memory. + * + * XdmfCoreReader is an abstract base class. */ class XdmfCoreReader { diff --git a/utils/XdmfExodusWriter.cpp b/utils/XdmfExodusWriter.cpp index 11bb672e..e4add58a 100644 --- a/utils/XdmfExodusWriter.cpp +++ b/utils/XdmfExodusWriter.cpp @@ -146,25 +146,13 @@ void XdmfExodusWriter::write(const std::string & filePath, const boost::shared_p double * y = new double[num_nodes]; double * z = new double[num_nodes]; // Write nodal coordinate values to exodus - if(currGrid->getGeometry()->getType() == XdmfGeometryType::XYZ() || currGrid->getGeometry()->getType() == XdmfGeometryType::XY()) + currGrid->getGeometry()->getValues(0, x, num_nodes, 3); + currGrid->getGeometry()->getValues(1, y, num_nodes, 3); + if(currGrid->getGeometry()->getType() == XdmfGeometryType::XYZ()) { - currGrid->getGeometry()->getValues(0, x, num_nodes, 3); - currGrid->getGeometry()->getValues(1, y, num_nodes, 3); - if(currGrid->getGeometry()->getType() == XdmfGeometryType::XYZ()) - { - currGrid->getGeometry()->getValues(2, z, num_nodes, 3); - } - ex_put_coord(exodusHandle, x ,y ,z); - } - else if(currGrid->getGeometry()->getType() == XdmfGeometryType::X_Y_Z() || currGrid->getGeometry()->getType() == XdmfGeometryType::X_Y()) - { - currGrid->getGeometry()->getValues(0, x, num_nodes); - currGrid->getGeometry()->getValues(num_nodes, y, num_nodes); - if(currGrid->getGeometry()->getType() == XdmfGeometryType::X_Y_Z()) - { - currGrid->getGeometry()->getValues(num_nodes * 2, z, num_nodes); - } + currGrid->getGeometry()->getValues(2, z, num_nodes, 3); } + ex_put_coord(exodusHandle, x ,y ,z); delete [] x; delete [] y; delete [] z; -- GitLab