FlattenedHierarchy::FlattenedHierarchy( const PatchHierarchy& hierarchy, int coarsest_level, int finest_level) : d_coarsest_level(coarsest_level), d_finest_level(finest_level), d_patch_hierarchy(&hierarchy) { int num_levels = hierarchy.getNumberOfLevels(); TBOX_ASSERT(coarsest_level >= 0); TBOX_ASSERT(coarsest_level <= finest_level); TBOX_ASSERT(finest_level < num_levels); d_visible_boxes.resize(num_levels); LocalId local_id(0); for (int ln = finest_level; ln >= coarsest_level; --ln) { const std::shared_ptr<PatchLevel>& current_level = hierarchy.getPatchLevel(ln); if (ln != finest_level) { const Connector& coarse_to_fine = current_level->findConnector( *(hierarchy.getPatchLevel(ln+1)), IntVector::getOne(hierarchy.getDim()), CONNECTOR_IMPLICIT_CREATION_RULE, true); const IntVector& connector_ratio = coarse_to_fine.getRatio(); for (PatchLevel::iterator ip(current_level->begin()); ip != current_level->end(); ++ip) { const std::shared_ptr<Patch>& patch = *ip; const Box& box = patch->getBox(); const BlockId& block_id = box.getBlockId(); const BoxId& box_id = box.getBoxId(); BoxContainer& visible_boxes = d_visible_boxes[ln][box_id]; BoxContainer coarse_boxes(box); BoxContainer fine_nbr_boxes; if (coarse_to_fine.hasNeighborSet(box_id)) { coarse_to_fine.getNeighborBoxes(box_id, fine_nbr_boxes); } if (!fine_nbr_boxes.empty()) { BoxContainer fine_boxes; for (SAMRAI::hier::RealBoxConstIterator nbr_itr = fine_nbr_boxes.realBegin(); nbr_itr != fine_nbr_boxes.realEnd(); ++nbr_itr) { if (nbr_itr->getBlockId() == block_id) { fine_boxes.pushBack(*nbr_itr); } } fine_boxes.coarsen(connector_ratio); coarse_boxes.removeIntersections(fine_boxes); coarse_boxes.coalesce(); } for (BoxContainer::iterator itr = coarse_boxes.begin(); itr != coarse_boxes.end(); ++itr) { Box new_box(*itr, local_id, box_id.getOwnerRank()); ++local_id; visible_boxes.insert(visible_boxes.end(), new_box); } } } else { for (PatchLevel::iterator ip(current_level->begin()); ip != current_level->end(); ++ip) { const std::shared_ptr<Patch>& patch = *ip; const Box& box = patch->getBox(); const BoxId& box_id = box.getBoxId(); BoxContainer& visible_boxes = d_visible_boxes[ln][box_id]; Box new_box(box, local_id, box.getOwnerRank()); ++local_id; visible_boxes.insert(visible_boxes.end(), new_box); } } } }
void FE_Utils::create_uses_multiple_stuff (AST_Component *c, AST_Uses *u, const char *prefix) { ACE_CString struct_name (prefix); if (!struct_name.empty ()) { struct_name += '_'; } struct_name += u->local_name ()->get_string (); struct_name += "Connection"; Identifier struct_id (struct_name.c_str ()); UTL_ScopedName sn (&struct_id, 0); // In case this call comes from the backend. We // will pop the scope before returning. idl_global->scopes ().push (c); AST_Structure *connection = idl_global->gen ()->create_structure (&sn, 0, 0); struct_id.destroy (); /// If the field type is a param holder, we want /// to use the lookup to create a fresh one, /// since the field will own it and destroy it. UTL_ScopedName *fn = u->uses_type ()->name (); AST_Decl *d = idl_global->root ()->lookup_by_name (fn, true, false); AST_Type *ft = AST_Type::narrow_from_decl (d); Identifier object_id ("objref"); UTL_ScopedName object_name (&object_id, 0); AST_Field *object_field = idl_global->gen ()->create_field (ft, &object_name, AST_Field::vis_NA); (void) DeclAsScope (connection)->fe_add_field (object_field); object_id.destroy (); Identifier local_id ("Cookie"); UTL_ScopedName local_name (&local_id, 0); Identifier module_id ("Components"); UTL_ScopedName scoped_name (&module_id, &local_name); d = c->lookup_by_name (&scoped_name, true); local_id.destroy (); module_id.destroy (); if (d == 0) { // This would happen if we haven't included Components.idl. idl_global->err ()->lookup_error (&scoped_name); return; } AST_ValueType *cookie = AST_ValueType::narrow_from_decl (d); Identifier cookie_id ("ck"); UTL_ScopedName cookie_name (&cookie_id, 0); AST_Field *cookie_field = idl_global->gen ()->create_field (cookie, &cookie_name, AST_Field::vis_NA); (void) DeclAsScope (connection)->fe_add_field (cookie_field); cookie_id.destroy (); (void) c->fe_add_structure (connection); ACE_CDR::ULong bound = 0; AST_Expression *bound_expr = idl_global->gen ()->create_expr (bound, AST_Expression::EV_ulong); AST_Sequence *sequence = idl_global->gen ()->create_sequence (bound_expr, connection, 0, 0, 0); ACE_CString seq_string (struct_name); seq_string += 's'; Identifier seq_id (seq_string.c_str ()); UTL_ScopedName seq_name (&seq_id, 0); AST_Typedef *connections = idl_global->gen ()->create_typedef (sequence, &seq_name, 0, 0); seq_id.destroy (); (void) c->fe_add_typedef (connections); // In case this call comes from the backend. idl_global->scopes ().pop (); }
int be_visitor_ami_pre_proc::visit_interface (be_interface *node) { // We check for an imported node after generating the reply handler. if (node->is_local () || node->is_abstract ()) { return 0; } // The following 3 IF blocks are checks for CCM-related nodes, which // we want to skip until we get AMI integrated with CIAO. // Skip the *EventConsumer added for each eventtype. if (node->is_event_consumer ()) { return 0; } // Check for home equivalent interface. The lookup will find the // home itself, which was declared first. Identifier *node_lname = node->AST_Decl::local_name (); AST_Decl *first_stored = node->defined_in ()->lookup_by_name_local (node_lname, false); if (0 != first_stored && first_stored->node_type () == AST_Decl::NT_home) { return 0; } ACE_CString lname (node_lname->get_string ()); // Skip the *Explict and *Implicit interfaces added for a home. if (lname.substr (lname.length () - 6) == "plicit") { UTL_Scope *s = node->defined_in (); Identifier local_id (lname.substr (0, lname.length () - 8).c_str ()); AST_Decl *d = s->lookup_by_name_local (&local_id, false); local_id.destroy (); if (0 != d) { return 0; } } AST_Module *module = AST_Module::narrow_from_scope (node->defined_in ()); if (!module) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_ami_pre_proc::" "visit_interface - " "module is null\n"), -1); } be_interface *reply_handler = this->create_reply_handler (node); if (reply_handler) { reply_handler->set_defined_in (node->defined_in ()); // Insert the ami handler after the node, the // exception holder will be placed between these two later. module->be_add_interface (reply_handler, node); // Remember from whom we were cloned reply_handler->original_interface (node); // If this was created for an imported node, it will be wrong // unless we set it. reply_handler->set_imported (node->imported ()); } else { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_ami_pre_proc::" "visit_interface - " "creating the reply handler failed\n"), -1); } if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_ami_pre_proc::" "visit_interface - " "visit scope failed\n"), -1); } return 0; }