34 _window(w), _id(i), _ignore_ghost(false)
46 _window(p->_window), _id(id), _ignore_ghost(false)
57 for (
int i=COM_NUM_KEYWORDS;
i<
n; ) {
59 if ( ap==NULL || ap->
pane()==NULL) { ++
i;
continue; }
66 for (
int k=0,
nk=(ncomp==1)?0:ncomp;
k<=
nk; ++
k,++
i)
71 reinterpret_cast<Attribute_friend*>(as)->inherit( ap,
INHERIT_USE,
true);
91 if ( a==NULL || a->
pane()==NULL)
continue;
101 if (
i>size_of_elements()) {
110 Cnct_set::iterator it=_cnct_set.begin();
111 for ( ; it != _cnct_set.end(); ++it) {
127 Cnct_set::iterator it=_cnct_set.begin();
128 for ( ; it != _cnct_set.end(); ++it) {
129 if ( a==(*it)->name())
return *it;
136 _cnct_set.push_back( c);
137 return _cnct_set.back();
150 if ( w_attr==NULL)
return NULL;
160 if ( p_attr==NULL || p_attr->
id () !=
i)
return NULL;
169 if ( a==NULL || a->
pane()==NULL)
continue;
173 if ( ncomp>1)
i+=ncomp;
179 const int type,
int ncomp,
const std::string &unit)
183 if ( loc ==
'c' &&
id() != 0) {
185 std::string::size_type pos = aname.find(
":");
186 std::string conn = aname.substr(pos, aname.size());
195 if ( aid>=
int(_attr_set.size()))
207 if ( ncomp>1)
for (
int i=1;
i<=ncomp; ++
i) {
209 std::sprintf( buf,
"%d-",
i);
210 std::string newname = std::string( buf)+a->
name();
217 if ( _id && loc ==
'w') {
219 inherit( _window->attribute( aid), INHERIT_USE,
true);
231 if (
int(_attr_set.size())<=
id) {
232 int s = attr->size_of_components();
233 _attr_set.resize(
id+s+(s>1), NULL);
236 if ( _attr_set[
id]==NULL) _attr_set[
id] = attr;
244 if ( a==NULL || a->
pane()==NULL)
continue;
247 if (ncomp>1)
i+=ncomp;
257 for (
int i=
id+((ncomp>1)?ncomp:0);
i>=
id; --
i) _attr_set[
i] = NULL;
259 if (
id+ncomp+(ncomp>1) ==
int(_attr_set.size()))
260 _attr_set.resize(
id);
272 for (
int i=0,
n=_cnct_set.size();
i<
n; ++
i) {
273 if ( !_cnct_set[
i]->is_structured())
274 reinit_conn( _cnct_set[
i], op, NULL, strd, cap);
277 if ( addr) *addr = NULL;
282 reinit_attr(
COM_NC, op, NULL, strd, cap);
283 reinit_attr(
COM_CONN, op, NULL, strd, cap);
284 reinit_attr(
COM_RIDGES, op, NULL, strd, cap);
285 if ( addr) *addr = NULL;
290 reinit_attr(
COM_NC, op, NULL, strd, cap);
291 reinit_attr(
COM_CONN, op, NULL, strd, cap);
292 reinit_attr(
COM_RIDGES, op, NULL, strd, cap);
293 reinit_attr(
COM_PCONN, op, NULL, strd, cap);
294 if ( addr) *addr = NULL;
302 if ( a==NULL || a->
pane()==NULL)
continue;
304 reinit_attr(
i, op, NULL, strd, cap);
306 if ( ncomp>1)
i+= ncomp;
312 reinit_attr(
COM_PMESH, op, NULL, strd, cap);
313 reinit_attr(
COM_ATTS, op, NULL, strd, cap);
326 if (op == OP_SET || op == OP_SET_CONST)
337 if ( op==OP_DEALLOC) {
343 COM_assertion( op==OP_SET_CONST||op==OP_SET||op==OP_ALLOC||op==OP_RESIZE);
358 if ( op==OP_SET || op==OP_SET_CONST) cap = a->
size_of_items();
369 if ( (op == OP_SET || op == OP_SET_CONST) && *addr && cap==0)
374 int icomp=std::atoi( a->
name().c_str());
375 if ( attribute(aid-icomp)->initialized())
380 if ( strd==0 || strd<0 && a->stride()==0)
386 if ( op == OP_SET || op == OP_SET_CONST) {
388 0, op==OP_SET_CONST);
392 p = a->
allocate( strd, cap, op == OP_ALLOC);
393 if ( addr) *addr = p;
404 if ( op!=OP_DEALLOC) {
408 if ( op==OP_SET || op==OP_SET_CONST) cap = con->size_of_items();
410 if ( con->capacity()==0)
411 cap = con->size_of_items();
412 else if ( con->size_of_items()<=con->capacity())
413 cap = con->capacity();
415 cap = con->size_of_items()+con->size_of_items()/5;
419 if ( strd==0 || strd<0 && con->stride()==0)
421 strd = con->size_of_components();
423 strd = con->stride();
426 if ( op == OP_SET || op == OP_SET_CONST) {
431 if ( *addr && cap==0 && !con->is_structured())
438 if ( con->is_structured())
443 { con->deallocate(); p=NULL; }
445 p = con->allocate( strd, cap, op==OP_ALLOC);
447 if ( addr) *addr = (
int*)p;
458 switch (from->id()) {
460 inherit( from->pane()->attribute(
COM_PMESH),
"", mode, withghost);
461 inherit( from->pane()->attribute(
COM_ATTS),
"", mode, withghost);
464 inherit( from->pane()->attribute(
COM_NC),
"", mode, withghost);
465 inherit( from->pane()->attribute(
COM_CONN),
"", mode, withghost);
466 inherit( from->pane()->attribute(
COM_RIDGES),
"", mode, withghost);
469 inherit( from->pane()->attribute(
COM_NC),
"", mode, withghost);
470 inherit( from->pane()->attribute(
COM_CONN),
"", mode, withghost);
471 inherit( from->pane()->attribute(
COM_RIDGES),
"", mode, withghost);
472 inherit( from->pane()->attribute(
COM_PCONN),
"", mode, withghost);
476 std::vector<Attribute*> &atts=from->pane()->_attr_set;
480 if ( a==NULL || a->
pane()==NULL)
continue;
482 inherit( a,
"", mode, withghost);
484 if ( ncomp>1)
i+= ncomp;
489 if ( _id==0)
return attribute(
COM_CONN);
491 if (mode != INHERIT_COPY) {
493 for (
Size i=0;
i<_cnct_set.size(); ++
i)
delete _cnct_set[
i];
496 if ( mode==INHERIT_USE) {
501 _attr_set[
COM_NC]->parent()->pane() == from->pane());
505 std::vector<Connectivity*>::iterator it=from->pane()->_cnct_set.begin();
506 std::vector<Connectivity*>::iterator
iend=from->pane()->_cnct_set.end();
507 for ( ; it !=
iend; ++it) {
508 _cnct_set.push_back(
new Connectivity(
this, *it, (*it)->name(),
509 -_cnct_set.size()-1));
514 _ignore_ghost = !withghost;
515 if ( _ignore_ghost && is_structured() && size_of_ghost_layers())
519 if ( mode == INHERIT_USE)
return attribute(
COM_ATTS);
524 const std::vector<Connectivity*> &es = from->pane()->_cnct_set;
526 "Number of connectivity tables do not match");
529 for (
int i=0,
ni=_cnct_set.size();
i<
ni; ++
i) {
532 _cnct_set[
i]->copy_array( const_cast<int*>(conn->
pointer()),
536 refresh_connectivity();
542 std::string str = aname.size()?aname:from->name();
547 attribute(from->id()) : _window->attribute(str);
549 if ( mode != INHERIT_COPY) {
554 a=_window->new_attribute( str, from->location(), from->data_type(),
555 from->size_of_components(), from->unit());
557 if ( from->is_windowed())
566 if ( mode == INHERIT_USE || !from->is_windowed())
return a;
570 a = _attr_set[a->
id()];
575 if ( mode == INHERIT_USE)
return a;
580 if ( a) a = _attr_set[a->
id()];
585 (from->fullname()+
" and "+a->
fullname(),
589 if ( (_id==0) != (from->is_windowed()))
return a;
592 if ( !withghost && is_structured() && size_of_ghost_layers())
597 int count = withghost?from->size_of_items():from->size_of_real_items();
598 int s_nc = from->size_of_components();
599 const Pane *src_pane = from->pane();
602 (std::string(
"Location of attributes ")+
603 from->fullname()+
" and " +a->
fullname()+
604 " do not match during copying.").c_str());
607 if ( count)
for (
int j=(s_nc>1),
nj=s_nc-(s_nc==1);
j<=
nj; ++
j) {
617 (std::string(
"Number of items of attributes ")+
618 from->fullname()+
" and " +a->
fullname()+
619 " do not match during copying.").c_str());
622 src_data->
stride(), count);
636 if ( !a->is_windowed() && !_id)
640 if ( a->is_nodal()) {
642 (std::string(
"Cannot set size for nodal attribute ")+
643 a->fullname()+
". Must use the nc attribute").c_str());
645 _attr_set[
COM_NC]->set_size( nitems, ng);
647 else if ( a->is_elemental()) {
649 (std::string(
"Cannot set size for elemental attribute ")+
650 a->fullname()+
". Must use the conn attribute").c_str());
652 _attr_set[
COM_CONN]->set_size( nitems, ng);
655 attribute(a->id())->set_size( nitems, ng);
661 if ( !con->is_structured() && nitems<ng)
664 con->set_size( nitems, ng);
668 int nelems = 0, ngelems = 0;
681 if ( nelems<0 || ngelems<0)
void inherit(Attribute *a, bool clone, bool withghost, int depth=0)
Inherit from parent. If depth>0, then the procedure is for the subcomponents.
Size size_of_ghost_elements() const
Get the number of ghost elements.
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.
bool initialized() const
Returns whether the array for the attribute has been set or allocated.
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
const int * pointer() const
Get a constant pointer to the connectivity array.
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)
static bool is_digit(char c)
#define COM_assertion_msg(EX, msg)
bool is_windowed() const
Checks whether the attribute is associated with the window.
void reinit_conn(Connectivity *con, OP_Init op, int **addr, int strd, int cap)
A Window object contains multiple panes and multiple data attributes.
void set_size(Attribute *a, int nitems, int ng)
Set the size of an attribute.
bool is_structured() const
Is mesh of the pane structured?
Pane(Window *w, int i)
Create a pane in window w with ID i.
Size size_of_ghost_nodes() const
Get the number of ghost nodes.
void delete_attribute(int id)
Delete an existing attribute with given id.
const std::string & name() const
Obtain the window's name.
Shorter_size location() const
Obtain the location of the attribute.
static const int * get_size_info(const std::string &aname)
Obtain the size info of pre-defined connectivity.
Encapsulates the states of an exception.
int deallocate()
Deallocate memory if it was allocated by allocate().
void init_done()
Finalize the initialization of a pane.
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...
int capacity() const
Obtain the capacity of the array.
Window * _window
Point to the parent window.
const void * pointer() const
Obtain a constant pointer to the physical address.
Size index_offset() const
Get the index of the first element.
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE knode iend
const std::string & name() const
Obtain the name of the attribute.
void reinit_attr(int aid, OP_Init op, void **addr, int strd, int cap)
virtual ~Pane()
Default destructor.
This file contains a set of routines for error assertion.
void set_offset(Size offset)
Set the index of the first element.
int stride() const
Obtain the stride of the attribute in base datatype.
unsigned int Size
Unsighed int.
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.
const Pane * pane() const
Obtain a constant pointer to the owner pane of the attribute.
Attribute * attribute(const std::string &a)
Obtain a pointer to the attribute metadata from its name.
Cnct_set _cnct_set
Set of element connectivity.
#define append_frame(s, frame)
Macro for appending the information about the given frame to the string s.
int last_attribute_id() const
Return the last attribute id.
Size size_of_nodes() const
Get the total number of nodes in the pane (including ghost nodes).
unsigned long id(const Leda_like_handle &x)
Connectivity * connectivity(Size i)
Obtain the connectivity table containing the element with the given ID.
void * allocate(int strd, int cap, bool force)
Allocate memory for the attribute.
void refresh_connectivity()
Update offsets and sizes of connectivity of an unstructured mesh.
Size size_of_elements() const
Get the total number of elements (including ghost elements) in the table.
void int int REAL REAL REAL *z blockDim dim * ni
Attribute * new_attribute(const std::string &aname, int aid, const char loc, const int type, int ncomp, const std::string &unit)
Attribute * inherit(Attribute *from, const std::string &aname, int mode, bool withghost)
Inherit an attribute from another pane onto the current pane:
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.
COM_Type data_type() const
Obtain the data type of each component of the attribute.
int id() const
Obtain the id (or index) of the attribute.
Attr_set _attr_set
Set of attributes.
void attributes(std::vector< Attribute * > &as)
Obtain all the attributes of the pane.
void insert(Attribute *attr)
Insert an attribute onto the pane.
Contains the prototypes for the Window object.
Encapsulates an element-connectivity of a mesh.
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...
int size_of_components() const
Obtain the number of components in the attribute.