PECommPattern& CField::parallelize() { if ( is_not_null( m_comm_pattern ) ) // return if already parallel return *m_comm_pattern; // Extract gid from the nodes.glb_idx() for only the nodes in the region the fields will use. const CList<Uint>& nodes = used_nodes(); std::vector<Uint> gid; std::vector<Uint> rank; gid.reserve(nodes.size()); rank.reserve(nodes.size()); CMesh& mesh = find_parent_component<CMesh>(*this); boost_foreach (const Uint node, nodes.array()) { cf_assert_desc(to_str(node)+">="+to_str(mesh.nodes().glb_idx().size()), node < mesh.nodes().glb_idx().size()); cf_assert_desc(to_str(node)+">="+to_str(mesh.nodes().rank().size()), node < mesh.nodes().rank().size()); gid.push_back(mesh.nodes().glb_idx()[node]); rank.push_back(mesh.nodes().rank()[node]); } // create the comm pattern and setup the pattern m_comm_pattern = mesh.create_component_ptr<PECommPattern>("comm_pattern_node_based"); m_comm_pattern->insert("gid",gid,1,false); m_comm_pattern->setup(m_comm_pattern->get_child("gid").as_ptr<PEObjectWrapper>(),rank); return parallelize_with(*m_comm_pattern); }
PECommPattern& CField::parallelize_with(PECommPattern& comm_pattern) { cf_assert_desc("Only point-based fields supported now", m_basis == Basis::POINT_BASED); m_comm_pattern = comm_pattern.as_ptr<Common::PECommPattern>(); comm_pattern.insert(name(),data().array(),true); return comm_pattern; }
Option::Ptr add_option (boost::shared_ptr<OPTION_TYPE> option) { cf_assert_desc ( "Class has already property with name " + option->name(), this->store.find(option->name()) == store.end() ); Option::Ptr opt = boost::dynamic_pointer_cast<Option>(option); store.insert( std::make_pair(option->name(), opt ) ); return opt; }
Option::Ptr add_option (const std::string& name, const typename OPTION_TYPE::value_type& def=typename OPTION_TYPE::value_type() ) { cf_assert_desc ( "Class has already property with same name", this->store.find(name) == store.end() ); Option::Ptr opt ( new OPTION_TYPE(name, def) ); store.insert( std::make_pair(name, opt ) ); return opt; }
std::string class_name_from_typeinfo (const std::type_info & info) { TypeInfo& ti = TypeInfo::instance(); std::map<std::string, std::string>::const_iterator it = ti.portable_types.find(info.name()); cf_assert_desc(Common::demangle(info.name()).c_str(), it != ti.portable_types.end() ); return it->second; }