Commit a0f86d60 authored by Jerry Clarke's avatar Jerry Clarke
Browse files

Adding a <Time> capability

parent a9faaa00
......@@ -43,6 +43,7 @@ swig -v -c++ -make_default -includeall -shadow -java $(ICE_INCLUDES) -o XdmfJava
#include <XdmfTopology.h>
#include <XdmfGeometry.h>
#include <XdmfGrid.h>
#include <XdmfTime.h>
/*
#include <XdmfParameter.h>
#include <XdmfTransform.h>
......@@ -114,6 +115,7 @@ inline XDMF_LONG64 XDMF_strtoll(char *str, void*, int)
%include XdmfTopology.h
%include XdmfGeometry.h
%include XdmfGrid.h
%include XdmfTime.h
/*
%include XdmfParameter.h
%include XdmfTransform.h
......
......@@ -897,5 +897,32 @@ XdmfGrid_swigregister = _Xdmf.XdmfGrid_swigregister
XdmfGrid_swigregister(XdmfGrid)
HandleToXdmfGrid = _Xdmf.HandleToXdmfGrid
class XdmfTime(XdmfElement):
__swig_setmethods__ = {}
for _s in [XdmfElement]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfTime, name, value)
__swig_getmethods__ = {}
for _s in [XdmfElement]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, XdmfTime, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _Xdmf.new_XdmfTime(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _Xdmf.delete_XdmfTime
__del__ = lambda self : None;
def GetClassName(*args): return _Xdmf.XdmfTime_GetClassName(*args)
def Insert(*args): return _Xdmf.XdmfTime_Insert(*args)
def UpdateInformation(*args): return _Xdmf.XdmfTime_UpdateInformation(*args)
def SetValue(*args): return _Xdmf.XdmfTime_SetValue(*args)
def Build(*args): return _Xdmf.XdmfTime_Build(*args)
def GetValue(*args): return _Xdmf.XdmfTime_GetValue(*args)
def GetArray(*args): return _Xdmf.XdmfTime_GetArray(*args)
def SetArray(*args): return _Xdmf.XdmfTime_SetArray(*args)
def GetDataItem(*args): return _Xdmf.XdmfTime_GetDataItem(*args)
def SetDataItem(*args): return _Xdmf.XdmfTime_SetDataItem(*args)
XdmfTime_swigregister = _Xdmf.XdmfTime_swigregister
XdmfTime_swigregister(XdmfTime)
......@@ -531,6 +531,9 @@ XdmfInt32 XdmfDataItem::Build(){
XdmfDataDesc *aDataDesc = this->DataDesc;
if(XdmfElement::Build() != XDMF_SUCCESS) return(XDMF_FAIL);
if(this->Array) aDataDesc = this->Array;
XdmfDebug("aDataDesc = " << aDataDesc);
XdmfDebug("aDataDesc Dimensions = " << aDataDesc->GetShapeAsString());
XdmfDebug("aDataDesc NumberType = " << XdmfTypeToClassString(aDataDesc->GetNumberType()));
this->Set("Dimensions", aDataDesc->GetShapeAsString());
this->Set("NumberType", XdmfTypeToClassString(aDataDesc->GetNumberType()));
switch (aDataDesc->GetElementSize()) {
......
......@@ -45,7 +45,7 @@ XdmfInformation::Insert( XdmfElement *Child){
XdmfInt32 XdmfInformation::UpdateInformation(){
XdmfConstString aValue;
XdmfElement::UpdateInformation();
if(XdmfElement::UpdateInformation() != XDMF_SUCCESS) return(XDMF_FAIL);
aValue = this->Get("Name");
if(aValue) this->SetName(aValue);
aValue = this->Get("Value");
......
This diff is collapsed.
/*******************************************************************/
/* XDMF */
/* eXtensible Data Model and Format */
/* */
/* Id : Id */
/* Date : $Date$ */
/* Version : $Revision$ */
/* */
/* Author: */
/* Jerry A. Clarke */
/* clarke@arl.army.mil */
/* US Army Research Laboratory */
/* Aberdeen Proving Ground, MD */
/* */
/* Copyright @ 2002 US Army Research Laboratory */
/* All Rights Reserved */
/* See Copyright.txt or http://www.arl.hpc.mil/ice for details */
/* */
/* This software is distributed WITHOUT ANY WARRANTY; without */
/* even the implied warranty of MERCHANTABILITY or FITNESS */
/* FOR A PARTICULAR PURPOSE. See the above copyright notice */
/* for more information. */
/* */
/*******************************************************************/
#include "XdmfTime.h"
#include "XdmfDOM.h"
#include "XdmfArray.h"
#include "XdmfDataItem.h"
XdmfTime::XdmfTime() {
this->SetElementName("Time");
this->Value = 0.0;
this->Array = NULL;
this->DataItem = new XdmfDataItem;
this->TimeType = XDMF_TIME_SINGLE;
this->Function = NULL;
}
XdmfTime::~XdmfTime() {
if(this->DataItem) delete this->DataItem;
}
XdmfInt32
XdmfTime::Insert( XdmfElement *Child){
if(Child && XDMF_WORD_CMP(Child->GetElementName(), "Time")){
return(XdmfElement::Insert(Child));
}else{
XdmfErrorMessage("Time can only Insert Time elements");
}
return(XDMF_FAIL);
}
XdmfInt32 XdmfTime::UpdateInformation(){
XdmfConstString attribute;
XdmfFloat64 dValue;
if(XdmfElement::UpdateInformation() != XDMF_SUCCESS) return(XDMF_FAIL);
attribute = this->Get("TimeType");
if(!attribute) attribute = this->Get("Type");
if( XDMF_WORD_CMP(attribute, "Single") ){
this->TimeType = XDMF_TIME_SINGLE;
}else if( XDMF_WORD_CMP(attribute, "Uniform") ){
this->TimeType = XDMF_TIME_UNIFORM;
}else if( XDMF_WORD_CMP(attribute, "HyperSlab") ){
this->TimeType = XDMF_TIME_HYPERSLAB;
}else if( XDMF_WORD_CMP(attribute, "Function") ){
this->TimeType = XDMF_TIME_FUNCTION;
}else{
if(attribute){
XdmfErrorMessage("Unknown Time Type : " << attribute);
return(XDMF_FAIL);
}
// Default
this->TimeType = XDMF_TIME_SINGLE;
}
attribute = this->Get("Function");
if(attribute){
this->TimeType = XDMF_TIME_FUNCTION;
this->SetFunction(attribute);
}
attribute = this->Get("Value");
if(attribute){
istrstream Value_ist(const_cast<char*>(attribute), strlen(attribute) );
Value_ist >> dValue;
this->SetValue(dValue);
}else{
XdmfXmlNode node;
if(this->TimeType == XDMF_TIME_SINGLE){
XdmfErrorMessage("TimeType is Single but there is no Value Attribute");
return(XDMF_FAIL);
}
node = this->DOM->FindDataElement(0, this->GetElement());
if(!node){
XdmfErrorMessage("No Time Value is set and there is no DataItem");
return(XDMF_FAIL);
}
if(this->DataItem->SetDOM(this->DOM) == XDMF_FAIL) return(XDMF_FAIL);
if(this->DataItem->SetElement(node) == XDMF_FAIL) return(XDMF_FAIL);
if(this->DataItem->UpdateInformation() == XDMF_FAIL) return(XDMF_FAIL);
if(this->DataItem->Update() == XDMF_FAIL) return(XDMF_FAIL);
this->Array = this->DataItem->GetArray();
}
return(XDMF_SUCCESS);
}
XdmfInt32 XdmfTime::Build(){
if(XdmfElement::Build() != XDMF_SUCCESS) return(XDMF_FAIL);
this->Set("TimeType", this->GetTimeTypeAsString());
if(this->TimeType == XDMF_TIME_FUNCTION){
this->Set("Function", this->Function);
return(XDMF_SUCCESS);
}
if(this->Array){
XdmfDataItem *di = NULL;
XdmfXmlNode node;
XdmfDebug("Build for XdmfTime = " << this);
//! Is there already a DataItem
node = this->DOM->FindDataElement(0, this->GetElement());
if(node) {
di = (XdmfDataItem *)this->GetCurrentXdmfElement(node);
XdmfDebug("DataItem = " << di);
}
if(!di){
di = new XdmfDataItem;
node = this->DOM->InsertNew(this->GetElement(), "DataItem");
di->SetDOM(this->DOM);
di->SetElement(node);
if(this->Array->GetNumberOfElements() > 100) di->SetFormat(XDMF_FORMAT_HDF);
}
if(this->Array != di->GetArray()){
XdmfDebug("Setting Array since " << this->Array << " != " << di->GetArray());
di->SetArray(this->Array);
}
XdmfDebug("Building DataItem");
di->Build();
}else{
ostrstream StringOutput;
StringOutput << this->Value << ends;
this->Set("Value", StringOutput.str());
}
return(XDMF_SUCCESS);
}
XdmfConstString
XdmfTime::GetTimeTypeAsString(void){
switch(this->TimeType){
case XDMF_TIME_UNIFORM :
return("Uniform");
case XDMF_TIME_HYPERSLAB:
return("HyperSlab");
case XDMF_TIME_FUNCTION:
return("Function");
default :
return("Single");
}
}
/*******************************************************************/
/* XDMF */
/* eXtensible Data Model and Format */
/* */
/* Id : Id */
/* Date : $Date$ */
/* Version : $Revision$ */
/* */
/* Author: */
/* Jerry A. Clarke */
/* clarke@arl.army.mil */
/* US Army Research Laboratory */
/* Aberdeen Proving Ground, MD */
/* */
/* Copyright @ 2002 US Army Research Laboratory */
/* All Rights Reserved */
/* See Copyright.txt or http://www.arl.hpc.mil/ice for details */
/* */
/* This software is distributed WITHOUT ANY WARRANTY; without */
/* even the implied warranty of MERCHANTABILITY or FITNESS */
/* FOR A PARTICULAR PURPOSE. See the above copyright notice */
/* for more information. */
/* */
/*******************************************************************/
#ifndef __XdmfTime_h
#define __XdmfTime_h
#include "XdmfElement.h"
/*! XdmfTime represents a Time specification.
Time is a child of the <Grid> element :
<Time TypeType="Single* | Uniform | HyperSlab | Function"
NumberOfIterations="1* | N"
Value="(no default)">
<DataItem ....
</Time>
TimeType can be :
Single - A Single Time for the entire Grid
Uniform - a Time Series
HyperSlab - Start Stride Count
Function - XdmfFloat64 *Function(GridIndex)
*/
class XdmfDataItem;
class XdmfArray;
#define XDMF_TIME_SINGLE 0x00
#define XDMF_TIME_UNIFORM 0x01
#define XDMF_TIME_HYPERSLAB 0x02
#define XDMF_TIME_FUNCTION 0x03
class XDMF_EXPORT XdmfTime : public XdmfElement {
public:
XdmfTime();
virtual ~XdmfTime();
XdmfConstString GetClassName() { return ( "XdmfTime" ) ; };
//! Insert an Element
XdmfInt32 Insert (XdmfElement *Child);
//! Update From XML
XdmfInt32 UpdateInformation();
/*! Set the internal value. This is not reflected in the DOM
Until Build() is called.
*/
XdmfSetValueMacro(Value, XdmfFloat64);
//! Update the DOM
XdmfInt32 Build();
/*! Get the internal Value.
*/
XdmfGetValueMacro(Value, XdmfFloat64);
//! Get the Array
XdmfGetValueMacro(Array, XdmfArray *);
//! Set the Array
XdmfSetValueMacro(Array, XdmfArray *);
//! Get the Array
XdmfGetValueMacro(DataItem, XdmfDataItem *);
//! Set the DataItem
XdmfSetValueMacro(DataItem, XdmfDataItem *);
//! Get the Type
XdmfGetValueMacro(TimeType, XdmfInt32);
//! Get the Type as a String
XdmfConstString GetTimeTypeAsString(void);
//! Set the Type
XdmfSetValueMacro(TimeType, XdmfInt32);
//! Get the Function
XdmfGetStringMacro(Function);
//! Set the Function
XdmfSetStringMacro(Function);
protected:
XdmfInt32 TimeType;
XdmfFloat64 Value;
XdmfArray *Array;
XdmfDataItem *DataItem;
XdmfString Function;
};
#endif // __XdmfTime_h
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment