Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90369112
dumper.hh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Nov 1, 00:59
Size
6 KB
Mime Type
text/x-c++
Expires
Sun, Nov 3, 00:59 (2 d)
Engine
blob
Format
Raw Data
Handle
22063367
Attached To
rIOHELPER iohelper
dumper.hh
View Options
/*
Copyright 2008 Guillaume ANCIAUX (guillaume.anciaux@epfl.ch)
This file is part of ParaViewHelper.
ParaViewHelper is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ParaViewHelper is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ParaViewHelper. If not, see <http://www.gnu.org/licenses/>.
*/
/* -------------------------------------------------------------------------- */
#ifndef __IOHELPER_DUMPER_H__
#define __IOHELPER_DUMPER_H__
/* -------------------------------------------------------------------------- */
#include <map>
#include <string>
#include "iohelper_common.hh"
#include "field_interface.hh"
#include "field.hh"
#include "container_array.hh"
/* -------------------------------------------------------------------------- */
#include "visitor.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_IOHELPER__
/** Class Dumper
* Interface of a dumper
*/
class
Dumper
{
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public
:
Dumper
(
const
std
::
string
prefix
,
const
std
::
string
base_name
=
""
);
virtual
~
Dumper
();
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
//! dump to file
virtual
void
dump
(
const
std
::
string
&
name
=
""
)
=
0
;
//! initialisation of the dumper
void
init
();
//! TODO set comment
void
printNodeDataFields
();
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
//! give vector with coordinates
void
setPoints
(
Real
*
points
,
int
dimension
,
int
nb
,
const
std
::
string
&
name
);
//! set number of filtered elements
void
setNumberFilteredElements
(
int
nb_filtered
);
//! give vector to connectivity
virtual
void
setConnectivity
(
int
*
connectivity
,
ElemType
element_type
,
UInt
nb_elem
,
int
mode
);
//! give vector to per node data
template
<
typename
T
>
void
addNodeDataField
(
const
std
::
string
&
name
,
T
*
data
,
UInt
dimension
,
UInt
size
,
UInt
stride
=
1
);
//! give a generic container as per node data
template
<
typename
Cont
>
void
addNodeDataField
(
const
std
::
string
&
name
,
Cont
&
data
);
//! give vector to per element data
template
<
typename
T
>
void
addElemDataField
(
const
std
::
string
&
name
,
T
*
data
,
UInt
dimension
,
UInt
size
,
UInt
stride
=
1
);
//! give a generic container as per elem data
template
<
typename
Cont
>
void
addElemDataField
(
const
std
::
string
&
name
,
Cont
&
data
);
//! set prefix directory
void
setPrefix
(
const
std
::
string
&
dir
);
//! set mode
virtual
void
setMode
(
int
mode
){
this
->
mode
=
mode
;
}
//! set rank and world size params for parallel treatment
void
setParallelContext
(
int
me
,
int
wld_size
);
//! set current value for the dump step
void
setDumpStep
(
int
s
){
dump_step
=
s
;};
//! get basename
std
::
string
getBaseName
();
//! get fullname
std
::
string
getFullName
(
const
std
::
string
&
b
=
""
);
//! increment the dumpstep
void
incDumpStep
(
UInt
s
=
1
){
dump_step
+=
s
;};
std
::
string
getPrefix
()
{
return
prefix
;
}
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private
:
std
::
string
prefix
;
std
::
string
base_name
;
int
dump_step
;
protected
:
//! flag to produce zipped files
UInt
mode
;
typedef
std
::
map
<
std
::
string
,
FieldInterface
*>
field_map
;
//! vector of additional per node data
field_map
per_node_data
;
//! vector of additional per element data
field_map
per_element_data
;
//! the directory separator (might be system dependent)
char
directory_separator
;
//! for parallel runs is the total number of processors
Int
world_size
;
//! for parallel runs is rank of the process
Int
my_rank
;
//! fortran or C style connectivity indexing
Int
connectivity_mode
;
//! for parallel runs is rank of the process that should write the data to file
Int
root_rank
;
};
/* -------------------------------------------------------------------------- */
template
<
typename
T
>
void
Dumper
::
addNodeDataField
(
const
std
::
string
&
name
,
T
*
data
,
UInt
dimension
,
UInt
size
,
UInt
stride
)
{
ContainerArray
<
T
>
*
cont
=
new
ContainerArray
<
T
>
(
data
,
dimension
,
size
,
stride
);
addNodeDataField
(
name
,
*
cont
);
}
/* -------------------------------------------------------------------------- */
template
<
typename
Cont
>
void
Dumper
::
addNodeDataField
(
const
std
::
string
&
name
,
Cont
&
data
){
Field
<
Cont
>
*
test
=
new
Field
<
Cont
>
(
data
,
name
);
per_node_data
[
name
]
=
test
;
}
/* -------------------------------------------------------------------------- */
template
<
typename
T
>
void
Dumper
::
addElemDataField
(
const
std
::
string
&
name
,
T
*
data
,
UInt
dimension
,
UInt
size
,
UInt
stride
){
ContainerArray
<
T
>
*
cont
=
new
ContainerArray
<
T
>
(
data
,
dimension
,
size
,
stride
);
addElemDataField
(
name
,
*
cont
);
// if (stride == 0) stride = dimension;
// if (per_element_data.count(name) != 0) delete(per_element_data[name]);
// if (connec == NULL) FATAL("connectivity should be provided before elemental fields ! Please use SetConnectivity function before AddElemDataField");
// Field<Real> * temp = new Field<Real>(data,dimension,connec->getNbDof(),stride);
// temp->setName(name);
// per_element_data[name] = temp;
}
/* -------------------------------------------------------------------------- */
template
<
typename
Cont
>
void
Dumper
::
addElemDataField
(
const
std
::
string
&
name
,
Cont
&
data
){
Field
<
Cont
>
*
test
=
new
Field
<
Cont
>
(
data
,
name
);
per_element_data
[
name
]
=
test
;
}
/* -------------------------------------------------------------------------- */
__END_IOHELPER__
#endif
/* __IOHELPER_DUMPER_H__ */
Event Timeline
Log In to Comment