Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Ben Boeckel
Xdmf
Commits
5c280140
Commit
5c280140
authored
Feb 10, 2010
by
Kenneth Leiter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: Add XdmfDomain.
parent
195746b2
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
968 additions
and
93 deletions
+968
-93
CMakeLists.txt
CMakeLists.txt
+1
-0
Xdmf.i
Xdmf.i
+3
-0
Xdmf.py
Xdmf.py
+47
-2
XdmfAttribute.hpp
XdmfAttribute.hpp
+1
-1
XdmfDomain.cpp
XdmfDomain.cpp
+59
-0
XdmfDomain.hpp
XdmfDomain.hpp
+63
-0
XdmfGrid.cpp
XdmfGrid.cpp
+1
-1
XdmfGrid.hpp
XdmfGrid.hpp
+1
-1
XdmfPython.cpp
XdmfPython.cpp
+767
-69
XdmfTopology.hpp
XdmfTopology.hpp
+0
-15
XdmfVisitor.cpp
XdmfVisitor.cpp
+14
-1
XdmfVisitor.hpp
XdmfVisitor.hpp
+3
-0
tests/TestXdmfGrid.cpp
tests/TestXdmfGrid.cpp
+2
-2
tests/TestXdmfVisitor.cpp
tests/TestXdmfVisitor.cpp
+6
-1
No files found.
CMakeLists.txt
View file @
5c280140
...
...
@@ -25,6 +25,7 @@ set(XdmfSources
XdmfAttributeType
XdmfDataItem
XdmfDataItemType
XdmfDomain
XdmfGeometry
XdmfGeometryType
XdmfGrid
...
...
Xdmf.i
View file @
5c280140
...
...
@@ -16,6 +16,7 @@ namespace boost {
%
template
(
XdmfAttributePtr
)
boost
::
shared_ptr
<
XdmfAttribute
>
;
%
template
(
XdmfDataItemPtr
)
boost
::
shared_ptr
<
XdmfDataItem
>
;
%
template
(
XdmfDomainPtr
)
boost
::
shared_ptr
<
XdmfDomain
>
;
%
template
(
XdmfGeometryPtr
)
boost
::
shared_ptr
<
XdmfGeometry
>
;
%
template
(
XdmfGridPtr
)
boost
::
shared_ptr
<
XdmfGrid
>
;
%
template
(
XdmfItemPtr
)
boost
::
shared_ptr
<
XdmfItem
>
;
...
...
@@ -30,6 +31,7 @@ namespace boost {
#
include
<
XdmfAttributeType
.
hpp
>
#
include
<
XdmfDataItem
.
hpp
>
#
include
<
XdmfDataItemType
.
hpp
>
#
include
<
XdmfDomain
.
hpp
>
#
include
<
XdmfGeometry
.
hpp
>
#
include
<
XdmfGeometryType
.
hpp
>
#
include
<
XdmfGrid
.
hpp
>
...
...
@@ -51,6 +53,7 @@ namespace boost {
%
include
XdmfAttribute
.
hpp
%
include
XdmfAttributeCenter
.
hpp
%
include
XdmfAttributeType
.
hpp
%
include
XdmfDomain
.
hpp
%
include
XdmfGeometry
.
hpp
%
include
XdmfGeometryType
.
hpp
%
include
XdmfGrid
.
hpp
...
...
Xdmf.py
View file @
5c280140
...
...
@@ -144,6 +144,28 @@ class XdmfDataItemPtr(_object):
XdmfDataItemPtr_swigregister
=
_Xdmf
.
XdmfDataItemPtr_swigregister
XdmfDataItemPtr_swigregister
(
XdmfDataItemPtr
)
class
XdmfDomainPtr
(
_object
):
__swig_setmethods__
=
{}
__setattr__
=
lambda
self
,
name
,
value
:
_swig_setattr
(
self
,
XdmfDomainPtr
,
name
,
value
)
__swig_getmethods__
=
{}
__getattr__
=
lambda
self
,
name
:
_swig_getattr
(
self
,
XdmfDomainPtr
,
name
)
__repr__
=
_swig_repr
def
__deref__
(
self
):
return
_Xdmf
.
XdmfDomainPtr___deref__
(
self
)
def
__init__
(
self
):
this
=
_Xdmf
.
new_XdmfDomainPtr
()
try
:
self
.
this
.
append
(
this
)
except
:
self
.
this
=
this
__swig_destroy__
=
_Xdmf
.
delete_XdmfDomainPtr
__del__
=
lambda
self
:
None
;
def
New
(
self
):
return
_Xdmf
.
XdmfDomainPtr_New
(
self
)
def
insert
(
self
,
*
args
):
return
_Xdmf
.
XdmfDomainPtr_insert
(
self
,
*
args
)
def
getGrid
(
self
,
*
args
):
return
_Xdmf
.
XdmfDomainPtr_getGrid
(
self
,
*
args
)
def
getNumberOfGrids
(
self
):
return
_Xdmf
.
XdmfDomainPtr_getNumberOfGrids
(
self
)
def
printSelf
(
self
):
return
_Xdmf
.
XdmfDomainPtr_printSelf
(
self
)
def
write
(
self
,
*
args
):
return
_Xdmf
.
XdmfDomainPtr_write
(
self
,
*
args
)
XdmfDomainPtr_swigregister
=
_Xdmf
.
XdmfDomainPtr_swigregister
XdmfDomainPtr_swigregister
(
XdmfDomainPtr
)
class
XdmfGeometryPtr
(
_object
):
__swig_setmethods__
=
{}
__setattr__
=
lambda
self
,
name
,
value
:
_swig_setattr
(
self
,
XdmfGeometryPtr
,
name
,
value
)
...
...
@@ -191,7 +213,7 @@ class XdmfGridPtr(_object):
def
setName
(
self
,
*
args
):
return
_Xdmf
.
XdmfGridPtr_setName
(
self
,
*
args
)
def
insert
(
self
,
*
args
):
return
_Xdmf
.
XdmfGridPtr_insert
(
self
,
*
args
)
def
getAttribute
(
self
,
*
args
):
return
_Xdmf
.
XdmfGridPtr_getAttribute
(
self
,
*
args
)
def
getNumberOfAttribute
(
self
):
return
_Xdmf
.
XdmfGridPtr_getNumberOfAttribute
(
self
)
def
getNumberOfAttribute
s
(
self
):
return
_Xdmf
.
XdmfGridPtr_getNumberOfAttribute
s
(
self
)
def
printSelf
(
self
):
return
_Xdmf
.
XdmfGridPtr_printSelf
(
self
)
def
write
(
self
,
*
args
):
return
_Xdmf
.
XdmfGridPtr_write
(
self
,
*
args
)
XdmfGridPtr_swigregister
=
_Xdmf
.
XdmfGridPtr_swigregister
...
...
@@ -557,6 +579,29 @@ def XdmfAttributeType_GlobalId():
return
_Xdmf
.
XdmfAttributeType_GlobalId
()
XdmfAttributeType_GlobalId
=
_Xdmf
.
XdmfAttributeType_GlobalId
class
XdmfDomain
(
XdmfItem
):
__swig_setmethods__
=
{}
for
_s
in
[
XdmfItem
]:
__swig_setmethods__
.
update
(
getattr
(
_s
,
'__swig_setmethods__'
,{}))
__setattr__
=
lambda
self
,
name
,
value
:
_swig_setattr
(
self
,
XdmfDomain
,
name
,
value
)
__swig_getmethods__
=
{}
for
_s
in
[
XdmfItem
]:
__swig_getmethods__
.
update
(
getattr
(
_s
,
'__swig_getmethods__'
,{}))
__getattr__
=
lambda
self
,
name
:
_swig_getattr
(
self
,
XdmfDomain
,
name
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
raise
AttributeError
(
"No constructor defined"
)
__repr__
=
_swig_repr
__swig_getmethods__
[
"New"
]
=
lambda
x
:
_Xdmf
.
XdmfDomain_New
if
_newclass
:
New
=
staticmethod
(
_Xdmf
.
XdmfDomain_New
)
def
insert
(
self
,
*
args
):
return
_Xdmf
.
XdmfDomain_insert
(
self
,
*
args
)
def
getGrid
(
self
,
*
args
):
return
_Xdmf
.
XdmfDomain_getGrid
(
self
,
*
args
)
def
getNumberOfGrids
(
self
):
return
_Xdmf
.
XdmfDomain_getNumberOfGrids
(
self
)
def
printSelf
(
self
):
return
_Xdmf
.
XdmfDomain_printSelf
(
self
)
def
write
(
self
,
*
args
):
return
_Xdmf
.
XdmfDomain_write
(
self
,
*
args
)
XdmfDomain_swigregister
=
_Xdmf
.
XdmfDomain_swigregister
XdmfDomain_swigregister
(
XdmfDomain
)
def
XdmfDomain_New
():
return
_Xdmf
.
XdmfDomain_New
()
XdmfDomain_New
=
_Xdmf
.
XdmfDomain_New
class
XdmfGeometry
(
XdmfDataItem
):
__swig_setmethods__
=
{}
for
_s
in
[
XdmfDataItem
]:
__swig_setmethods__
.
update
(
getattr
(
_s
,
'__swig_setmethods__'
,{}))
...
...
@@ -674,7 +719,7 @@ class XdmfGrid(XdmfItem):
def
setName
(
self
,
*
args
):
return
_Xdmf
.
XdmfGrid_setName
(
self
,
*
args
)
def
insert
(
self
,
*
args
):
return
_Xdmf
.
XdmfGrid_insert
(
self
,
*
args
)
def
getAttribute
(
self
,
*
args
):
return
_Xdmf
.
XdmfGrid_getAttribute
(
self
,
*
args
)
def
getNumberOfAttribute
(
self
):
return
_Xdmf
.
XdmfGrid_getNumberOfAttribute
(
self
)
def
getNumberOfAttribute
s
(
self
):
return
_Xdmf
.
XdmfGrid_getNumberOfAttribute
s
(
self
)
def
printSelf
(
self
):
return
_Xdmf
.
XdmfGrid_printSelf
(
self
)
def
write
(
self
,
*
args
):
return
_Xdmf
.
XdmfGrid_write
(
self
,
*
args
)
XdmfGrid_swigregister
=
_Xdmf
.
XdmfGrid_swigregister
...
...
XdmfAttribute.hpp
View file @
5c280140
...
...
@@ -68,7 +68,7 @@ public:
void
setAttributeCenter
(
const
XdmfAttributeCenter
&
attributeCenter
);
/**
* Get the name of the AttributeCenter associated with this Attribute.
* Get the name of the
Xdmf
AttributeCenter associated with this Attribute.
*
* @return std::string containing name of the AttributeCenter.
*/
...
...
XdmfDomain.cpp
0 → 100644
View file @
5c280140
/*
* XdmfGrid.cpp
*
* Created on: Jan 25, 2010
* Author: kleiter
*/
#include "XdmfDomain.hpp"
#include "XdmfVisitor.hpp"
XdmfDomain
::
XdmfDomain
()
{
std
::
cout
<<
"Created Domain "
<<
this
<<
std
::
endl
;
}
XdmfDomain
::~
XdmfDomain
()
{
std
::
cout
<<
"Deleted Domain "
<<
this
<<
std
::
endl
;
}
void
XdmfDomain
::
insert
(
boost
::
shared_ptr
<
XdmfGrid
>
grid
)
{
mGrids
.
push_back
(
grid
);
}
boost
::
shared_ptr
<
XdmfGrid
>
XdmfDomain
::
getGrid
(
unsigned
int
index
)
{
if
(
index
>=
mGrids
.
size
())
{
assert
(
false
);
// Out of range --- should we throw exceptions?
}
return
mGrids
[
index
];
}
boost
::
shared_ptr
<
const
XdmfGrid
>
XdmfDomain
::
getGrid
(
unsigned
int
index
)
const
{
if
(
index
>=
mGrids
.
size
())
{
assert
(
false
);
// Out of range --- should we throw exceptions?
}
return
mGrids
[
index
];
}
unsigned
int
XdmfDomain
::
getNumberOfGrids
()
const
{
return
mGrids
.
size
();
}
std
::
string
XdmfDomain
::
printSelf
()
const
{
return
"XdmfDomain"
;
}
void
XdmfDomain
::
write
(
boost
::
shared_ptr
<
XdmfVisitor
>
visitor
)
const
{
visitor
->
visit
(
this
);
}
XdmfDomain.hpp
0 → 100644
View file @
5c280140
// Kenneth Leiter
// Xdmf Smart Pointer Test
#ifndef XDMFDOMAIN_HPP_
#define XDMFDOMAIN_HPP_
// Forward Declarations
class
XdmfGrid
;
// Includes
#include "XdmfItem.hpp"
#include <vector>
class
XdmfDomain
:
public
XdmfItem
{
public:
XdmfNewMacro
(
XdmfDomain
);
/**
* Insert a grid into the domain.
*/
void
insert
(
boost
::
shared_ptr
<
XdmfGrid
>
);
/**
* Get a grid attached to this domain.
*
* @param index of the grid to retrieve.
* @return pointer to the grid attached to this domain.
*/
boost
::
shared_ptr
<
XdmfGrid
>
getGrid
(
unsigned
int
index
);
/**
* Get a grid attached to this domain (const version).
*
* @param index of the grid to retrieve.
* @return pointer to the grid attached to this domain.
*/
boost
::
shared_ptr
<
const
XdmfGrid
>
getGrid
(
unsigned
int
index
)
const
;
/**
* Get the number of grids attached to this domain
*/
unsigned
int
getNumberOfGrids
()
const
;
virtual
std
::
string
printSelf
()
const
;
virtual
void
write
(
boost
::
shared_ptr
<
XdmfVisitor
>
visitor
)
const
;
protected:
XdmfDomain
();
virtual
~
XdmfDomain
();
private:
XdmfDomain
(
const
XdmfDomain
&
);
// Not implemented.
void
operator
=
(
const
XdmfDomain
&
);
// Not implemented.
std
::
vector
<
boost
::
shared_ptr
<
XdmfGrid
>
>
mGrids
;
};
#endif
/* XDMFDOMAIN_HPP_ */
XdmfGrid.cpp
View file @
5c280140
...
...
@@ -98,7 +98,7 @@ boost::shared_ptr<const XdmfAttribute> XdmfGrid::getAttribute(unsigned int index
return
mAttributes
[
index
];
}
unsigned
int
XdmfGrid
::
getNumberOfAttribute
()
const
unsigned
int
XdmfGrid
::
getNumberOfAttribute
s
()
const
{
return
mAttributes
.
size
();
}
...
...
XdmfGrid.hpp
View file @
5c280140
...
...
@@ -99,7 +99,7 @@ public:
/**
* Get the number of attributes attached to this grid
*/
unsigned
int
getNumberOfAttribute
()
const
;
unsigned
int
getNumberOfAttribute
s
()
const
;
virtual
std
::
string
printSelf
()
const
;
...
...
XdmfPython.cpp
View file @
5c280140
This diff is collapsed.
Click to expand it.
XdmfTopology.hpp
View file @
5c280140
...
...
@@ -60,21 +60,6 @@ public:
*/
int
getNodesPerElement
()
const
;
/* *
* Get the point data associated with this Topology;
boost::shared_ptr<XdmfDataItem> getData();
*
* Get the data associated with this Topology (const version)
boost::shared_ptr<const XdmfDataItem> getData() const;
*
* Set the point data associated with this Topology
void setData(boost::shared_ptr<XdmfDataItem> connectivityData);*/
/**
*
*/
...
...
XdmfVisitor.cpp
View file @
5c280140
...
...
@@ -3,6 +3,7 @@
#include "XdmfAttribute.hpp"
#include "XdmfDataItem.hpp"
#include "XdmfDomain.hpp"
#include "XdmfGeometry.hpp"
#include "XdmfGrid.hpp"
#include "XdmfTopology.hpp"
...
...
@@ -51,6 +52,18 @@ void XdmfVisitor::visit(const XdmfDataItem * const dataItem)
xmlData
<<
"
\n
"
<<
std
::
setw
(
mTabIndex
)
<<
""
<<
"</DataItem>
\n
"
;
}
void
XdmfVisitor
::
visit
(
const
XdmfDomain
*
const
domain
)
{
xmlData
<<
std
::
setw
(
mTabIndex
)
<<
""
<<
"<Domain>
\n
"
;
mTabIndex
++
;
for
(
unsigned
int
i
=
0
;
i
<
domain
->
getNumberOfGrids
();
++
i
)
{
visit
(
domain
->
getGrid
(
i
).
get
());
}
mTabIndex
--
;
xmlData
<<
std
::
setw
(
mTabIndex
)
<<
""
<<
"</Domain>
\n
"
;
}
void
XdmfVisitor
::
visit
(
const
XdmfGeometry
*
const
geometry
)
{
xmlData
<<
std
::
setw
(
mTabIndex
)
<<
""
<<
"<Geometry GeometryType=
\"
"
<<
geometry
->
getGeometryTypeAsString
()
<<
"
\"
>
\n
"
;
...
...
@@ -66,7 +79,7 @@ void XdmfVisitor::visit(const XdmfGrid * const grid)
mTabIndex
++
;
visit
(
grid
->
getGeometry
().
get
());
visit
(
grid
->
getTopology
().
get
());
for
(
unsigned
int
i
=
0
;
i
<
grid
->
getNumberOfAttribute
();
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
grid
->
getNumberOfAttribute
s
();
i
++
)
{
visit
(
grid
->
getAttribute
(
i
).
get
());
}
...
...
XdmfVisitor.hpp
View file @
5c280140
...
...
@@ -7,6 +7,7 @@
// Forward Declarations
class
XdmfAttribute
;
class
XdmfDataItem
;
class
XdmfDomain
;
class
XdmfGeometry
;
class
XdmfGrid
;
class
XdmfTopology
;
...
...
@@ -25,6 +26,8 @@ public:
virtual
void
visit
(
const
XdmfDataItem
*
const
geometry
);
virtual
void
visit
(
const
XdmfDomain
*
const
domain
);
virtual
void
visit
(
const
XdmfGeometry
*
const
geometry
);
virtual
void
visit
(
const
XdmfGrid
*
const
grid
);
...
...
tests/TestXdmfGrid.cpp
View file @
5c280140
...
...
@@ -12,9 +12,9 @@ int main(int argc, char* argv[])
boost
::
shared_ptr
<
XdmfAttribute
>
attr
=
XdmfAttribute
::
New
();
attr
->
setName
(
"Attr1"
);
assert
(
grid
->
getNumberOfAttribute
()
==
0
);
assert
(
grid
->
getNumberOfAttribute
s
()
==
0
);
grid
->
insert
(
attr
);
assert
(
grid
->
getNumberOfAttribute
()
==
1
);
assert
(
grid
->
getNumberOfAttribute
s
()
==
1
);
assert
(
grid
->
getAttribute
(
0
)
==
attr
);
return
0
;
...
...
tests/TestXdmfVisitor.cpp
View file @
5c280140
#include "XdmfAttribute.hpp"
#include "XdmfDataItem.hpp"
#include "XdmfDomain.hpp"
#include "XdmfGeometry.hpp"
#include "XdmfGrid.hpp"
#include "XdmfTopology.hpp"
...
...
@@ -45,7 +46,11 @@ int main(int argc, char* argv[])
grid
->
insert
(
nodalAttribute
);
grid
->
insert
(
cellAttribute
);
grid
->
write
(
visitor3
);
boost
::
shared_ptr
<
XdmfDomain
>
domain
=
XdmfDomain
::
New
();
domain
->
insert
(
grid
);
domain
->
write
(
visitor3
);
std
::
cout
<<
visitor3
->
printSelf
()
<<
std
::
endl
;
return
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment