Commit ab7e2262 authored by Andrew J. Burns (Cont's avatar Andrew J. Burns (Cont

creating branch with full Python example code

parent 9c1652ad
......@@ -168,10 +168,14 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
%include std_set.i
%include std_map.i
%include std_vector.i
%template(XdmfMapNodeIdSet) std::set<int>;
%template(XdmfMapNodeIdMap) std::map<int, std::set<int> >;
%template(XdmfMapMap) std::map<int, std::map<int, std::set<int> > >;
%template(AttributeVector) std::vector<shared_ptr<XdmfAttribute> >;
%template(MapVector) std::vector<shared_ptr<XdmfMap> >;
%template(ArrayVector) std::vector<shared_ptr<XdmfArray> >;
%pythoncode {
from XdmfCore import *
......
......@@ -48,6 +48,16 @@ public:
/**
* Create a new XdmfAttribute.
*
* Example of use:
*
* C++
*
* shared_ptr<XdmfAttribute> exampleAttribute = XdmfAttribute::New();
*
* Python
*
* exampleAttribute = XdmfAttribute.New()
*
* @return constructed XdmfAttribute.
*/
static shared_ptr<XdmfAttribute> New();
......@@ -60,6 +70,20 @@ public:
/**
* Get the XdmfAttributeCenter associated with this attribute.
*
* Example of use:
*
* C++
*
* //Assuming that exampleAttribute is a shared pointer to an XdmfAttribute object with its center set
* shared_ptr<const XdmfAttributeCenter> exampleCenter = exampleAttribute->getCenter();
*
* Python
*
* '''
* Assuming that exampleAttribute is a shared pointer to an XdmfAttribute object with its center set
* '''
* exampleCenter = exampleAttribute.getCenter()
*
* @return XdmfAttributeCenter of the attribute.
*/
shared_ptr<const XdmfAttributeCenter> getCenter() const;
......@@ -71,6 +95,20 @@ public:
/**
* Get the name of the attribute.
*
* Example of use:
*
* C++
*
* //Assuming that exampleAttribute is a shared pointer to an XdmfAttribute object
* std::string exampleName = exampleAttribute->getName();
*
* Python
*
* '''
* Assuming that exampleAttribute is a shared pointer to an XdmfAttribute object
* '''
* exampleName = exampleAttribute.getName()
*
* @return a string containing the name of the attribute.
*/
std::string getName() const;
......@@ -78,6 +116,20 @@ public:
/**
* Get the XdmfAttributeType associated with this attribute.
*
* Example of use:
*
* C++
*
* //Assuming that exampleAttribute is a shared pointer to an XdmfAttribute object with its type set
* shared_ptr<const XdmfAttributeType> exampleType = exampleAttribute->getType();
*
* Python
*
* '''
* Assuming that exampleAttribute is a shared pointer to an XdmfAttribute object with its type set
* '''
* exampleType = exampleAttribute.getType()
*
* @return XdmfAttributeType of the attribute.
*/
shared_ptr<const XdmfAttributeType> getType() const;
......@@ -85,6 +137,18 @@ public:
/**
* Set the XdmfAttributeCenter associated with this attribute.
*
* Example of use:
*
* C++
*
* shared_ptr<XdmfAttribute> exampleAttribute = XdmfAttribute::New();
* exampleAttribute->setCenter(XdmfAttributeCenter::Node());
*
* Python
*
* exampleAttribute = XdmfAttribute.New()
* exampleAttribute.setCenter(XdmfAttributeCenter.Node())
*
* @param center the XdmfAttributeCenter to set.
*/
void setCenter(const shared_ptr<const XdmfAttributeCenter> center);
......@@ -92,6 +156,20 @@ public:
/**
* Set the name of the attribute.
*
* Example of use:
*
* C++
*
* shared_ptr<XdmfAttribute> exampleAttribute = XdmfAttribute::New();
* std::string newName = "New Name";
* exampleAttribute->setName(newName);
*
* Python
*
* exampleAttribute = XdmfAttribute.New()
* newName = "New Name"
* exampleAttribute.setName(newName)
*
* @param name a string containing the name to set.
*/
void setName(const std::string & name);
......@@ -99,6 +177,18 @@ public:
/**
* Set the XdmfAttributeType associated with this attribute.
*
* Example of use:
*
* C++
*
* shared_ptr<XdmfAttribute> exampleAttribute = XdmfAttribute::New();
* exampleAttribute->setType(XdmfAttributeType::Node());
*
* Python
*
* exampleAttribute = XdmfAttribute.New()
* exampleAttribute.setType(XdmfAttributeType.Node())
*
* @param type XdmfAttributeType to set.
*/
void setType(const shared_ptr<const XdmfAttributeType> type);
......
......@@ -35,8 +35,15 @@
* where its values are centered on an XdmfGrid. A specific
* XdmfAttributeCenter can be created by calling on of the static
* methods in the class, i.e. XdmfAttributeCenter::Cell().
*
* Xdmf supports the following attribute centers:
*
* Example of use:
* //Assuming that exampleAttribute is a shared pointer to an XdmfAttribute with a set center
* if (exampleAttribute->getCenter() == XdmfAttributeCenter::Grid())
* {
* //do whatever is to be done if the center is grid
* }
*
* Grid
* Cell
* Face
......
......@@ -37,6 +37,14 @@
* XdmfAttributeType can be created by calling one of the static
* methods in the class, i.e. XdmfAttributeType::Scalar().
*
* Example of use:
*
* //Assuming that exampleAttribute is a shared pointer to an XdmfAttribute that has had its type set
* if (exampleAttribute->getType() == XdmfAttributeType:Scalar())
* {
* //do whatever is to be done if the attribute is a scalar
* }
*
* Xdmf supports the following attribute types:
* NoAttributeType
* Scalar
......
......@@ -49,6 +49,20 @@ public:
/**
* Create a new curvilinear grid (Two dimensional).
*
* Example of use:
*
* C++
*
* unsigned int newPointsX = 5;
* unsigned int newPointsY = 5;
* shared_ptr<XdmfCurvilinearGrid> exampleGrid = XdmfCurvilinearGrid::New(newPointsX, newPointsY);
*
* Python
*
* newPointsX = 5
* newPointsY = 5
* exampleGrid = XdmfCurvilinearGrid.New(newPointsX, newPointsY)
*
* @param xNumPoints the number of points in the x direction.
* @param yNumPoints the number of points in the y direction.
*
......@@ -61,6 +75,22 @@ public:
/**
* Create a new curvilinear grid (Three dimensional).
*
* Example of use:
*
* C++
*
* unsigned int newPointsX = 5;
* unsigned int newPointsY = 5;
* unsigned int newPointsZ = 5;
* shared_ptr<XdmfCurvilinearGrid> exampleGrid = XdmfCurvilinearGrid::New(newPointsX, newPointsY, newPointsZ);
*
* Python
*
* newPointsX = 5
* newPointsY = 5
* newPointsZ = 5
* exampleGrid = XdmfCurvilinearGrid.New(newPointsX, newPointsY, newPointsZ)
*
* @param xNumPoints the number of points in the x direction.
* @param yNumPoints the number of points in the y direction.
* @param zNumPoints the number of points in the z direction.
......@@ -75,6 +105,24 @@ public:
/**
* Create a new curvilinear grid (N dimensional).
*
* Example of use:
*
* C++
*
* shared_ptr<XdmfArray> newPoints = XdmfArray::New();
* newPoints->pushBack(5);
* newPoints->pushBack(5);
* newPoints->pushBack(5);
* shared_ptr<XdmfCurvilinearGrid> exampleGrid = XdmfCurvilinearGrid::New(newPoints);
*
* Python
*
* newPoints = XdmfArray.New()
* newPoints.pushBackAsInt32(5)
* newPoints.pushBackAsInt32(5)
* newPoints.pushBackAsInt32(5)
* exampleGrid = XdmfCurvilinearGrid.New(newPoints)
*
* @param numPoints the number of points in each direction.
*
* @return constructed curvilinear grid.
......@@ -91,6 +139,20 @@ public:
* Get the dimensions of the grid, the number of points in each
* direction.
*
* Example of use:
*
* C++
*
* //Assuming that exampleGrid is a shared pointer to an XdmfCurvilinearGrid object
* shared_ptr<XdmfArray> exampleDimensions = exampleGrid->getDimensions();
*
* Python
*
* '''
* Assuming that exampleGrid is a shared pointer to an XdmfCurvilinearGrid object
* '''
* exampleDimensions = exampleGrid.getDimensions()
*
* @return XdmfArray containing dimensions of this grid.
*/
shared_ptr<XdmfArray> getDimensions();
......@@ -99,6 +161,15 @@ public:
* Get the dimensions of the grid, the number of points in each
* direction (const version).
*
* Example of use:
*
* C++
*
* //Assuming that exampleGrid is a shared pointer to an XdmfCurvilinearGrid object
* shared_ptr<const XdmfArray> exampleDimensions = exampleGrid->getDimensions();
*
* Python: Python doesn't have a constant version
*
* @return XdmfArray containing the dimensions of this grid.
*/
shared_ptr<const XdmfArray> getDimensions() const;
......@@ -106,6 +177,20 @@ public:
/**
* Get the geometry associated with this grid.
*
* Example of use:
*
* C++
*
* //Assuming that exampleGrid is a sharedPointer to an XdmfCurvilinearGrid object
* shared_ptr<XdmfGeometry> exampleGeometry = exampleGrid->getGeometry();
*
* Python
*
* '''
* Assuming that exampleGrid is a sharedPointer to an XdmfCurvilinearGrid object
* '''
* exampleGeometry = exampleGrid.getGeometry()
*
* @return the geometry associated with this grid.
*/
shared_ptr<XdmfGeometry> getGeometry();
......@@ -114,6 +199,28 @@ public:
* Set the dimensions of the grid, the number of points in each
* direction.
*
* Example of use:
*
* C++
*
* shared_ptr<XdmfArray> newPoints = XdmfArray::New();
* newPoints->pushBack(5);
* newPoints->pushBack(5);
* newPoints->pushBack(5);
* //Assuming that exampleGrid is a sharedPointer to an XdmfCurvilinearGrid object
* exampleGrid->setDimensions(newPoints);
*
* Python
*
* newPoints = XdmfArray.New()
* newPoints.pushBackAsInt32(5)
* newPoints.pushBackAsInt32(5)
* newPoints.pushBackAsInt32(5)
* '''
* Assuming that exampleGrid is a sharedPointer to an XdmfCurvilinearGrid object
* '''
* exampleGrid.setDimensions(newPoints)
*
* @param dimensions the dimension of the grid.
*/
void setDimensions(const shared_ptr<XdmfArray> dimensions);
......@@ -121,6 +228,34 @@ public:
/**
* Set the geometry associated with this grid.
*
* Example of use:
*
* C++
*
* shared_ptr<XdmfArray> newPoints = XdmfArray::New();
* newPoints->pushBack(5);
* newPoints->pushBack(5);
* newPoints->pushBack(5);
* shared_ptr<XdmfGeometry> newGeometry = XdmfGeometry::New();
* newGeometry->setType(XdmfGeometryType::XYZ());
* newGeometry->insert(0, newPoints, 0, 3, 1, 1);//Start index is 0, 3 values are passed, stride for both arrays is 1
* //Assuming that exampleGrid is a sharedPointer to an XdmfCurvilinearGrid object
* exampleGrid->setGeometry(newGeometry);
*
* Python
*
* newPoints = XdmfArray.New()
* newPoints.pushBackAsInt32(5)
* newPoints.pushBackAsInt32(5)
* newPoints.pushBackAsInt32(5)
* newGeometry = XdmfGeometry.New()
* newGeometry.setType(XdmfGeometryType.XYZ())
* newGeometry.insert(0, newPoints, 0, 3, 1, 1)//Start index is 0, 3 values are passed, stride for both arrays is 1
* '''
* Assuming that exampleGrid is a sharedPointer to an XdmfCurvilinearGrid object
* '''
* exampleGrid.setGeometry(newGeometry)
*
* @param geometry an XdmfGeometry to associate with this grid.
*/
void setGeometry(const shared_ptr<XdmfGeometry> geometry);
......
......@@ -49,6 +49,16 @@ public:
/**
* Create a new XdmfDomain.
*
* Example of use:
*
* C++
*
* shared_ptr<XdmfDomain> exampleDomain = XdmfDomain::New();
*
* Python
*
* exampleDomain = XdmfDomain.New();
*
* @return constructed XdmfDomain.
*/
static shared_ptr<XdmfDomain> New();
......@@ -56,11 +66,11 @@ public:
virtual ~XdmfDomain();
LOKI_DEFINE_VISITABLE(XdmfDomain, XdmfItem);
XDMF_CHILDREN(XdmfGridCollection, GridCollection, Name);
XDMF_CHILDREN(XdmfCurvilinearGrid, CurvilinearGrid, Name);
XDMF_CHILDREN(XdmfRectilinearGrid, RectilinearGrid, Name);
XDMF_CHILDREN(XdmfRegularGrid, RegularGrid, Name);
XDMF_CHILDREN(XdmfUnstructuredGrid, UnstructuredGrid, Name);
XDMF_CHILDREN(XdmfDomain, XdmfGridCollection, GridCollection, Name);
XDMF_CHILDREN(XdmfDomain, XdmfCurvilinearGrid, CurvilinearGrid, Name);
XDMF_CHILDREN(XdmfDomain, XdmfRectilinearGrid, RectilinearGrid, Name);
XDMF_CHILDREN(XdmfDomain, XdmfRegularGrid, RegularGrid, Name);
XDMF_CHILDREN(XdmfDomain, XdmfUnstructuredGrid, UnstructuredGrid, Name);
static const std::string ItemTag;
std::map<std::string, std::string> getItemProperties() const;
......
......@@ -46,6 +46,16 @@ public:
/**
* Create a new XdmfGeometry.
*
* Example of use:
*
* C++
*
* shared_ptr<XdmfGeometry> exampleGeometry = XdmfGeometry::New();
*
* Python
*
* exampleGeometry = XdmfGeometry.New()
*
* @return constructed XdmfGeometry.
*/
static shared_ptr<XdmfGeometry> New();
......@@ -61,12 +71,40 @@ public:
/**
* Get the number of points stored in this geometry.
*
* Example of use:
*
* C++
*
* //assuming that exampleGeometry is a shared pointer to a XdmfGeometry object that has been filled with data
* unsigned int numPoints = exampleGeometry->getNumberPoints();
*
* Python
*
* '''
* assuming that exampleGeometry is a shared pointer to a XdmfGeometry object that has been filled with data
* '''
* numPoints = exampleGeometry.getNumberPoints()
*/
virtual unsigned int getNumberPoints() const;
/**
* Get the XdmfGeometryType associated with this geometry.
*
* Example of use:
*
* C++
*
* //assuming that exampleGeometry is a shared pointer to a XdmfGeometry object
* shared_ptr<const XdmfGeometryType> exampleType = exampleGeometry->getType();
*
* Python
*
* '''
* assuming that exampleGeometry is a shared pointer to a XdmfGeometry object
* '''
* exampleType = exampleGeometry.getType()
*
* @return XdmfGeometryType of this geometry.
*/
shared_ptr<const XdmfGeometryType> getType() const;
......@@ -74,6 +112,18 @@ public:
/**
* Set the XdmfGeometryType associated with this geometry.
*
* Example of use:
*
* C++
*
* shared_ptr<XdmfGeometry> exampleGeometry = XdmfGeometry::New();
* exampleGeometry->setType(XdmfGeometryType::XYZ());
*
* Python
*
* exampleGeometry = XdmfGeometry.New()
* exampleGeometry.setType(XdmfGeometryType.XYZ())
*
* @param type the XdmfGeometryType to set.
*/
void setType(const shared_ptr<const XdmfGeometryType> type);
......
......@@ -37,6 +37,14 @@
* XdmfGeometryType can be created by calling one of the static
* methods in the class, i.e. XdmfAttributeType::XYZ().
*
* Example of use:
*
* //Assuming that exampleGeometry is a shared pointer to an XdmfGeometry with its type set
* if (exampleGeometry->getType() == XdmfGeometry::XYZ())
* {
* //do whatever is to be done if the geometry is xyz
* }
*
* Xdmf supports the following geometry types:
* NoGeometryType
* XYZ
......@@ -58,6 +66,11 @@ public:
/**
* Get the dimensions of this geometry type - i.e. XYZ = 3.
*
* Example of use:
*
* unsigned int exampleDimensions = XdmfGeometryType::XYZ()->getDimensions();
* //The variable exampleDimensions now holds the number of dimensions that XYZ has
*
* @return an int containing number of dimensions.
*/
virtual unsigned int getDimensions() const;
......@@ -65,6 +78,11 @@ public:
/**
* Get the name of this geometry type.
*
* Example of use:
*
* std::string exampleName = XdmfGeometryType::XYZ()->getName();
* //The variable exampleName now holds the name of XYZ
*
* @return the name of this geometry type.
*/
std::string getName() const;
......
......@@ -58,14 +58,30 @@ public:
virtual ~XdmfGrid() = 0;
LOKI_DEFINE_VISITABLE(XdmfGrid, XdmfItem);
XDMF_CHILDREN(XdmfAttribute, Attribute, Name);
XDMF_CHILDREN(XdmfSet, Set, Name);
XDMF_CHILDREN(XdmfMap, Map, Name);
XDMF_CHILDREN(XdmfGrid, XdmfAttribute, Attribute, Name);
XDMF_CHILDREN(XdmfGrid, XdmfSet, Set, Name);
XDMF_CHILDREN(XdmfGrid, XdmfMap, Map, Name);
static const std::string ItemTag;
/**
* Get the geometry associated with this grid.
*
* Example of use:
*
* C++
*
* //using an unstructured grid since XdmfGrid is an abstract class
* //Assumming that exampleGrid is a shared pointer to an XdmfUnstructuredGrid object
* shared_ptr<const XdmfGeometry> exampleGeometry = exampleGrid->getGeometry();
*
* Python
*
* '''
* using an unstructured grid since XdmfGrid is an abstract class
* Assumming that exampleGrid is a shared pointer to an XdmfUnstructuredGrid object
* '''
* exampleGeometry = exampleGrid.getGeometry()
*
* @return the geometry associated with this grid.
*/
shared_ptr<const XdmfGeometry> getGeometry() const;
......@@ -77,6 +93,22 @@ public:
/**
* Get the name of the grid.
*
* Example of use:
*
* C++
*
* //using an unstructured grid since XdmfGrid is an abstract class
* //Assumming that exampleGrid is a shared pointer to an XdmfUnstructuredGrid object
* std::string exampleName = exampleGrid->getName();
*
* Python
*
* '''
* using an unstructured grid since XdmfGrid is an abstract class
* Assumming that exampleGrid is a shared pointer to an XdmfUnstructuredGrid object
* '''
* exampleName = exampleGrid.getName()
*
* @return the name of the grid.
*/
std::string getName() const;
......@@ -84,6 +116,22 @@ public:
/**
* Get the time associated with this grid.
*
* Example of use:
*
* C++
*
* //using an unstructured grid since XdmfGrid is an abstract class
* //Assumming that exampleGrid is a shared pointer to an XdmfUnstructuredGrid object
* shared_ptr<XdmfTime> exampleTime = exampleGrid->getTime();
*
* Python
*
* '''
* using an unstructured grid since XdmfGrid is an abstract class
* Assumming that exampleGrid is a shared pointer to an XdmfUnstructuredGrid object
* '''
* exampleTime = exampleGrid.getTime()
*
* @return pointer to the XdmfTime attached to this grid. If no
* XdmfTime is attached, return a NULL pointer.
*/
......@@ -92,6 +140,16 @@ public:
/**
* Get the time associated with this grid (const version).
*
* Example of use:
*
* C++
*
* //using an unstructured grid since XdmfGrid is an abstract class
* //Assumming that exampleGrid is a shared pointer to an XdmfUnstructuredGrid object
* shared_ptr<const XdmfTime> exampleTime = exampleGrid->getTime();
*
* Python: Python doesn't have a constant version
*
* @return pointer to the XdmfTime attached to this grid. If no
* XdmfTime is attached, return a NULL pointer.
*/
......@@ -100,6 +158,22 @@ public:
/**
* Get the topology associated with this grid.
*
* Example of use:
*
* C++
*
* //using an unstructured grid since XdmfGrid is an abstract class
* //Assumming that exampleGrid is a shared pointer to an XdmfUnstructuredGrid object
* shared_ptr<const XdmfTopology> exampleTopology = exampleGrid->getTopology();
*
* Python
*
* '''
* using an unstructured grid since XdmfGrid is an abstract class
* Assumming that exampleGrid is a shared pointer to an XdmfUnstructuredGrid object
* '''
* exampleTopology = exampleGrid.getTopology()
*
* @return the topology associated with this grid.
*/
shared_ptr<const XdmfTopology> getTopology() const;
......@@ -109,6 +183,24 @@ public:
/**
* Set the name of the grid.
*
* Example of use:
*
* C++
*
* //using an unstructured grid since XdmfGrid is an abstract class
* //Assumming that exampleGrid is a shared pointer to an XdmfUnstructuredGrid object
* std::string newName = "New Name";
* exampleGrid->setName(newName);
*
* Python
*
* '''
* using an unstructured grid since XdmfGrid is an abstract class
* Assumming that exampleGrid is a shared pointer to an XdmfUnstructuredGrid object
* '''
* newName = "New Name"
* exampleGrid.setName(newName)
*
* @param name of the grid to set.
*/
void setName(const std::string & name);
......@@ -116,6 +208,24 @@ public:
/**
* Set the time associated with this grid.
*
* Example of use:
*
* C++
*
* //using an unstructured grid since XdmfGrid is an abstract class
* //Assumming that exampleGrid is a shared pointer to an XdmfUnstructuredGrid object
* shared_ptr<XdmfTime> newTime = XdmfTime::New(20.0);
* exampleGrid->setTime(newTime);
*
* Python
*
* '''
* using an unstructured grid since XdmfGrid is an abstract class
* Assumming that exampleGrid is a shared pointer to an XdmfUnstructuredGrid object
* '''
* newTime = XdmfTime.New(20.0)
* exampleGrid.setTime(newTime)
*
* @param time an XdmfTime to associate with this grid.
*/
void setTime(const shared_ptr<XdmfTime> time);
......
......@@ -51,6 +51,16 @@ public:
/**
* Create a new XdmfGridCollection.
*
* Example of use:
*
* C++
*
* shared_ptr<XdmfGridCollection> exampleCollection = XdmfGridCollection::New();
*
* Python
*
* exampleCollection = XdmfGridCollection.New()
*
* @return constructed XdmfGridCollection.
*/
static shared_ptr<XdmfGridCollection> New();
......@@ -67,6 +77,20 @@ public:
/**
* Get the XdmfGridCollectionType associated with this grid collection.
*
* Example of use:
*
* C++
*
* //Assuming that exampleCollection is a shared pointer to an XdmfGridCollection object with its type set
* shared_ptr<const XdmfGridCollectionType> exampleType = exampleCollection->getType();
*
* Python
*
* '''
* Assuming that exampleCollection is a shared pointer to an XdmfGridCollection object with its type set
* '''
* exampleType = exampleCollection.getType()
*
* @return XdmfGridCollectionType of this collection.
*/
shared_ptr<const XdmfGridCollectionType> getType() const;
......@@ -77,6 +101,30 @@ public:
/**
* Insert an information into the grid collection.
*
* Example of use:
*
* C++
*
* //Assuming that exampleCollection is a shared pointer to an XdmfGridCollection object with its type set
* shared_ptr<XdmfInformation> exampleInformation = XdmfInformation::New();
* std::string newKey = "New Key";
* std::string newValue = "New Value";
* exampleInformation->setKey(newKey);
* exampleInformation->setValue(newValue);
* exampleCollection->insert(exampleInformation);
*
* Python
*
* '''
* Assuming that exampleCollection is a shared pointer to an XdmfGridCollection object with its type set
* '''
* exampleInformation = XdmfInformation.New()
* newKey = "New Key"
* newValue = "New Value"
* exampleInformation.setKey(newKey)
* exampleInformation.setValue(newValue)
* exampleCollection.insert(exampleInformation)
*
* @param information an XdmfInformation to attach to this item.
*/
void insert(const shared_ptr<XdmfInformation> information);
......@@ -85,6 +133,20 @@ public:
* Set the XdmfGridCollectionType associated with this grid
* collection.
*
* Example of use:
*
* C++
*