OPAL (Object Oriented Parallel Accelerator Library)
2024.2
OPAL
ippl
src
DataSource
FileFieldDataSource.hpp
Go to the documentation of this file.
1
// -*- C++ -*-
2
/***************************************************************************
3
*
4
* The IPPL Framework
5
*
6
* This program was prepared by PSI.
7
* All rights in the program are reserved by PSI.
8
* Neither PSI nor the author(s)
9
* makes any warranty, express or implied, or assumes any liability or
10
* responsibility for the use of this software
11
*
12
* Visit www.amas.web.psi for more details
13
*
14
***************************************************************************/
15
16
// -*- C++ -*-
17
/***************************************************************************
18
*
19
* The IPPL Framework
20
*
21
*
22
* Visit http://people.web.psi.ch/adelmann/ for more details
23
*
24
***************************************************************************/
25
26
// include files
27
#include "
DataSource/FileFieldDataSource.h
"
28
#include "
DataSource/FileDataConnect.h
"
29
#include "
Utility/DiscField.h
"
30
#include "
Message/Communicate.h
"
31
#include "
Utility/IpplInfo.h
"
32
33
35
// constructor: the name, the connection, the transfer method,
36
// the field to connect, and the parent node.
37
template
<
class
T,
unsigned
Dim,
class
M,
class
C>
38
FileFieldDataSource<T,Dim,M,C>::FileFieldDataSource
(
const
char
*nm,
39
DataConnect
*dc,
40
int
tm,
41
Field<T,Dim,M,C>
& F)
42
:
DataSourceObject
(nm,&F,dc,tm), DF(0), myField(F), FieldID(0), counter(0) {
43
44
45
46
47
std::string filestring =
"file"
;
48
if
(std::string(dc->
DSID
()) != filestring) {
49
ERRORMSG
(
"Illegal DataConnect object for FILE Data Object."
<<
endl
);
50
Connection
= 0;
51
}
else
if
(tm !=
DataSource::OUTPUT
&& tm !=
DataSource::INPUT
) {
52
ERRORMSG
(
"FILE connections may only be of type INPUT or OUTPUT."
<<
endl
);
53
Connection
= 0;
54
}
else
{
55
// find which DiscField to use ... first look for one in the DataConnect
56
FieldID
= dc->
size
();
57
FileDataConnect
*fdc = (
FileDataConnect
*)dc;
58
if
(dc->
size
() == 0) {
59
// this is the first field in the FileDataConnect, so make a new
60
// DiscField
61
if
(
TransferMethod
==
DataSource::OUTPUT
)
62
DF
=
new
DiscField<Dim>
(nm, dc->
name
(), fdc->
getNumObjects
(),
63
fdc->
getTypeString
());
64
else
65
DF
=
new
DiscField<Dim>
(nm, dc->
name
());
66
}
67
else
{
68
// use the DiscField in the first DataSource
69
DataSourceObject
*dso = (*(dc->
begin
()))->findDataSourceObject(dc);
70
if
(dso == 0) {
71
ERRORMSG
(
"Could not find proper DiscField while connecting "
<< nm <<
endl
);
72
}
73
else
{
74
DF
= ((
FileFieldDataSource<T,Dim,M,C>
*)dso)->DF;
75
}
76
}
77
}
78
}
79
80
82
// destructor
83
template
<
class
T,
unsigned
Dim,
class
M,
class
C>
84
FileFieldDataSource<T,Dim,M,C>::~FileFieldDataSource
() {
85
86
87
88
if
(DF != 0 && getConnection()->size() == 0)
89
delete
DF;
90
}
91
92
94
// Update the object, that is, make sure the receiver of the data has a
95
// current and consistent snapshot of the current stat dc->name()e. Return success.
96
template
<
class
T,
unsigned
Dim,
class
M,
class
C>
97
bool
FileFieldDataSource<T,Dim,M,C>::update
() {
98
99
100
101
if
(TransferMethod ==
DataSource::OUTPUT
)
102
DF->write(myField, FieldID);
103
else
if
(TransferMethod ==
DataSource::INPUT
)
104
DF->read(myField, FieldID, counter++);
105
return
true
;
106
}
107
108
110
// Indicate to the receiver that we're allowing the FieldDisc time to
111
// manipulate the data (e.g., for a viz program, to rotate it, change
112
// representation, etc.).
113
// This should only return when the manipulation is done.
114
template
<
class
T,
unsigned
Dim,
class
M,
class
C>
115
void
FileFieldDataSource<T,Dim,M,C>::interact
(
const
char
*) {}
116
117
118
/***************************************************************************
119
* $RCSfile: FileFieldDataSource.cpp,v $ $Author: adelmann $
120
* $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:25 $
121
* IPPL_VERSION_ID: $Id: FileFieldDataSource.cpp,v 1.1.1.1 2003/01/23 07:40:25 adelmann Exp $
122
***************************************************************************/
FileFieldDataSource.h
FileDataConnect.h
Communicate.h
endl
Inform & endl(Inform &inf)
Definition
Inform.cpp:42
IpplInfo.h
ERRORMSG
#define ERRORMSG(msg)
Definition
IpplInfo.h:350
DiscField.h
DataConnect
Definition
DataConnect.h:32
DataConnect::size
unsigned int size() const
Definition
DataConnect.h:82
DataConnect::DSID
const char * DSID() const
Definition
DataConnect.h:55
DataConnect::begin
iterator begin()
Definition
DataConnect.h:71
DataSource::OUTPUT
@ OUTPUT
Definition
DataSource.h:64
DataSource::INPUT
@ INPUT
Definition
DataSource.h:64
DataSourceObject
Definition
DataSourceObject.h:53
DataSourceObject::Connection
DataConnect * Connection
Definition
DataSourceObject.h:98
DataSourceObject::TransferMethod
int TransferMethod
Definition
DataSourceObject.h:107
Field
Definition
Field.h:33
FileDataConnect
Definition
FileDataConnect.h:25
FileDataConnect::getTypeString
const char * getTypeString() const
Definition
FileDataConnect.h:49
FileDataConnect::getNumObjects
unsigned int getNumObjects() const
Definition
FileDataConnect.h:46
FileFieldDataSource
Definition
FileFieldDataSource.h:31
FileFieldDataSource::~FileFieldDataSource
virtual ~FileFieldDataSource()
Definition
FileFieldDataSource.hpp:84
FileFieldDataSource::DF
DiscField< Dim > * DF
Definition
FileFieldDataSource.h:57
FileFieldDataSource::update
virtual bool update()
Definition
FileFieldDataSource.hpp:97
FileFieldDataSource::interact
virtual void interact(const char *=0)
Definition
FileFieldDataSource.hpp:115
FileFieldDataSource::FileFieldDataSource
FileFieldDataSource(const char *, DataConnect *, int, Field< T, Dim, M, C > &)
Definition
FileFieldDataSource.hpp:38
FileFieldDataSource::FieldID
int FieldID
Definition
FileFieldDataSource.h:63
DiscField
Definition
DiscField.h:49
NamedObj::name
const char * name() const
Definition
NamedObj.h:35
Generated on Tue Apr 14 2026 07:18:43 for OPAL (Object Oriented Parallel Accelerator Library) by
1.9.8