44 {
"nc",
"1-nc",
"2-nc",
"3-nc",
"conn",
"mesh",
45 "pconn",
"ridges",
"1-ridges",
"2-ridges",
"pmesh",
"atts",
"all" };
49 {
'n',
'n',
'n',
'n',
'e',
'p',
'p',
'p',
'p',
'p',
'p',
'p',
'p'};
59 { 3, 1, 1, 1, 0, 0, 1, 2, 1, 1, 0, 0, 0 };
64 const std::string &name,
int id)
65 : _pane( pane), _id(id), _gap(0), _status(0)
86 if ( _parent)
return root()->get_addr(
i,
j);
90 if ( _ncomp>1)
return this[
j+1].get_addr(
i);
93 if ( i<0 || i>=size_of_items())
96 return ((
char*)_ptr)+
i*_nbytes_strd;
198 _nitems = nitems; _ngitems = ngitems;
202 for (
int i=1;
i<=_ncomp; ++
i) {
203 this[
i]._nitems = nitems;
this[
i]._ngitems = ngitems;
211 int nitems=size_of_items(), ncomp=size_of_components();
220 if ( p && strd!=1 && strd<ncomp)
223 if ( p && cap<nitems)
230 _nbytes_strd = basesize*strd;
232 if ( _status == STATUS_ALLOCATED) deallocate();
235 _ptr = ((
char*)p) + (
offset*cap)*_nbytes_strd;
237 _ptr = ((
char*)p) +
offset*basesize;
241 _status = is_const?STATUS_SET_CONST:STATUS_SET;
243 if ( ncomp >1 && _id>=0)
for (
int i=1;
i<=ncomp; ++
i) {
244 this[
i].set_pointer( _ptr, _strd, _cap,
i-1, is_const);
252 if (direction==COPY_IN) {
257 if ( _status==STATUS_NOT_INITIALIZED && _parent)
258 { _cap = root()->_cap; _strd = root()->_strd; _nbytes_strd=root()->_nbytes_strd; }
261 int nitems=size_of_items(), ncomp=size_of_components();
263 if (
n ==0) {
if ( direction==COPY_IN)
return;
else n = nitems; }
264 if ( strd==0) strd=ncomp;
271 if ( strd!=1 && strd<ncomp)
275 if ( offset<0 || n+offset>_cap)
281 char *ptr0 = (
char*)pointer();
284 if ( _strd == strd && (_strd == ncomp ||
n==_cap && strd==1) ) {
286 if ( direction == COPY_IN)
287 std::memcpy( ptr0, buf,
n*ncomp*basesize);
289 std::memcpy( buf, ptr0,
n*ncomp*basesize);
291 else if ( _strd>1 && strd>1) {
293 char *p_buf=(
char*)buf;
295 int strd_att_in_bytes = _nbytes_strd;
296 int strd_buf_in_bytes = strd*basesize;
297 int vecsize = ncomp*basesize;
300 if ( direction == COPY_IN)
301 std::memcpy( p_att, p_buf, vecsize);
303 std::memcpy( p_buf, p_att, vecsize);
304 p_buf += strd_buf_in_bytes;
305 p_att += strd_att_in_bytes;
310 char *p_buf=(
char*)buf;
313 int strd_att_in_bytes = _nbytes_strd;
314 int strd_buf_in_bytes = strd*basesize;
315 int step_att_in_bytes= (_strd==1?_cap:1)*basesize;
316 int step_buf_in_bytes = (strd==1?
n:1)*basesize;
318 for (
int j=0, offset_buf=0, offset_att=0;
j<ncomp; ++
j) {
319 if ( direction == COPY_IN)
320 std::memcpy( p_att+offset_att, p_buf+offset_buf, basesize);
322 std::memcpy( p_buf+offset_buf, p_att+offset_att, basesize);
323 offset_buf += step_buf_in_bytes;
324 offset_att += step_att_in_bytes;
326 p_buf += strd_buf_in_bytes;
327 p_att += strd_att_in_bytes;
336 if ( !is_panel() && !is_windowed() || size_of_ghost_items())
340 int offset = size_of_items();
341 copy_array( const_cast<void*>(from), strd, nitem, offset);
342 set_size( offset+nitem);
347 int nitems=size_of_items(), ncomp=size_of_components();
349 if ( strd!=1 && strd<ncomp)
356 if ( !force && (_parent || _status==STATUS_SET || _status==STATUS_SET_CONST))
361 int type = data_type();
365 if ( _status == STATUS_NOT_INITIALIZED || force)
366 { nold = -1; old_cap = 0; }
375 if ( nold < nnew || strd != _strd) {
377 char *old_ptr = (
char*)_ptr;
378 int old_strd = _strd;
381 _ptr =
new char[nnew];
382 std::fill_n( (
char*)_ptr, nnew, 0);
388 _cap = cap; _strd = strd; _nbytes_strd =
get_sizeof( data_type(), strd);
391 if ( old_cap && _ptr) {
392 if ( _ncomp ==1 || _id<0)
393 copy_array( old_ptr, old_strd,
std::min(old_cap,_cap));
395 for (
int i=1;
i<=ncomp; ++
i) {
397 char *old_ptr_i = (
char*)ai->
_ptr; old_strd=ai->
_strd;
403 if ( ai->
_status == STATUS_ALLOCATED && old_ptr_i)
409 if ( _ncomp >1 && _id>=0)
for (
int i=1;
i<=ncomp; ++
i) {
410 this[
i].set_pointer( _ptr, _strd, _cap,
i-1,
false);
415 if ( _status == STATUS_ALLOCATED && old_ptr)
delete [] old_ptr;
417 _status = STATUS_ALLOCATED;
418 if ( _parent) _parent=NULL;
437 if ( _ncomp>1 && _id>=0)
try {
438 for (
int i=1;
i<=_ncomp; ++
i) {
439 this[
i].inherit( parent+
i, clone, withghost, 1);
447 _nitems = parent->size_of_items();
448 _ngitems = parent->size_of_ghost_items();
451 _nitems = parent->size_of_real_items();
454 if ( depth>0)
return;
458 if (parent->initialized()) allocate( _ncomp, _cap,
true);
463 if ( _ncomp>1 && _id>=0)
try {
464 for (
int i=1;
i<=_ncomp; ++
i) {
465 this[
i].inherit( parent+
i, clone, withghost, 1);
467 this[
i].set_pointer( _ptr, _strd, _cap,
i-1,
false);
497 case COM_SHORT:
return count*
sizeof(short);
505 case COM_LONG:
return count*
sizeof(
long int);
508 case COM_REAL:
return count*
sizeof(float);
523 case COM_VOID:
return sizeof(
void*)*count;
524 case COM_OBJECT:
return sizeof(COM_Object*)*count;
532 if (t1 == t2)
return true;
void inherit(Attribute *a, bool clone, bool withghost, int depth=0)
Inherit from parent. If depth>0, then the procedure is for the subcomponents.
Attribute * _parent
Parent attribute being used.
const Window * window() const
Obtain a constant pointer to its owner window object.
int COM_Type
Indices for derived data types.
int _ngitems
Size of ghost items.
A Pane object contains a mesh, pane attribute, and field variables.
bool size_set() const
Returns whether the size for the attribute has been set.
int _nbytes_strd
Number of bytes of the stride.
int maxsize_of_real_items() const
Obtain the maximum allowed number of real items in the attribute.
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
void set_pointer(void *p, int strd, int cap, int offset, bool is_const)
Set the physical address of the attribute values.
Contains the prototypes for the Pane object.
An Attribute object is a data member of a window.
static bool compatible_types(COM_Type t1, COM_Type t2)
Shorter_size _status
Indicating whether it has been initialized.
const void * get_addr(int i, int j=0) const
Obtain the address of the jth component of the ith item, where 0<=i<size_of_items.
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
A Window object contains multiple panes and multiple data attributes.
static const int _keysizes[COM_NUM_KEYWORDS]
Default sizes.
const std::string & name() const
Obtain the window's name.
real *8 function offset(vNorm, x2, y2, z2)
const Window * window() const
Obtain a constant pointer to the parent window of the attribute.
int maxsize_of_items() const
Obtain the maximum allowed number of items in the attribute.
Encapsulates the states of an exception.
int deallocate()
Deallocate memory if it was allocated by allocate().
Attribute * attribute(const std::string &a)
Obtain the attribute from given name.
#define CATCHBADALLOC_APPEND(frame)
Macro for catching an deallocation exception and append the information to the current frame...
static const COM_Type _keytypes[COM_NUM_KEYWORDS]
Default data types.
int capacity() const
Obtain the capacity of the array.
Attribute * root()
Root of use-inheritance.
Attribute()
Default constructor.
std::string _unit
Unit of the attribute.
int size_of_ghost_items() const
Obtain the number of ghost items in the attribute.
bool ignore_ghost() const
Pane * _pane
Pointer to its owner pane.
void * _ptr
Physical address of the attribute.
Shorter_size _loc
Location.
const std::string & name() const
Obtain the name of the attribute.
int _gap
Gap between the IDs of real and ghost items.
std::string _name
Name of the attribute.
Contains declarations of MPI subroutines used in Roccom.
This file contains a set of routines for error assertion.
static int get_sizeof(MPI_Datatype i)
Get the size of a given MPI data type.
int maxsize_of_ghost_items() const
Obtain the maximum allowed number of items in the attribute.
void set_size(int nitems, int ngitems=0)
Set the size of items and ghost items.
int size_of_real_items() const
Obtain the number of real items in the attribute.
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
#define append_frame(s, frame)
Macro for appending the information about the given frame to the string s.
COM_Type _type
Base data type of the attribute.
int _ncomp
Number of components.
void * allocate(int strd, int cap, bool force)
Allocate memory for the attribute.
int _nitems
Size of total items. Default value is -1.
void int int REAL REAL REAL *z blockDim dim * ni
void copy_array(void *buf, int strd, int nitem, int offset=0, int direction=COPY_IN)
#define CATCHEXP_APPEND(frame)
Macro for catching an exception and append the information to the current frame.
Contains the prototype of Attriubte.
static const char _keylocs[COM_NUM_KEYWORDS]
Default locations.
static const char * _keywords[COM_NUM_KEYWORDS]
List of keywords.
Contains the prototypes for the Window object.
int size_of_items() const
Obtain the number of items in the attribute.
std::string fullname() const
Obtain the full name of the attribute including window name suitable for printing out error messages...
static int get_sizeof(COM_Type type, int count=1)
void append_array(const void *from, int strd, int nitem)