Пример #1
0
Value*
getRndMode_cf(Value** arg_list, int count)
{
	check_arg_count(getRndMode, 0, count);
	def_render_types();
	one_typed_value_local(Array* result);
	GraphicsWindow	*gw		= MAXScript_interface->GetActiveViewExp().getGW();
	
	if (MaxSDK::Graphics::IsRetainedModeEnabled() && gw->querySupport(GW_SPT_NUM_LIGHTS) == 0)
	{
		return &undefined;
	}

	DWORD			mode	= gw->getRndMode();

	vl.result = new Array(3);
	for (int i=0; i < elements(renderTypes); i++)
		if ((renderTypes[i].id) & mode) 
			vl.result->append(renderTypes[i].val);		
	return_value (vl.result); // LAM - 5/18/01 - was return vl.result
}
Пример #2
0
Value*
setRndLimits_cf(Value** arg_list, int count)
{
	check_arg_count(setRndLimits, 1, count);
	def_render_types();
	GraphicsWindow	*gw		= MAXScript_interface->GetActiveViewExp().getGW();
	
	if (MaxSDK::Graphics::IsRetainedModeEnabled() && gw->querySupport(GW_SPT_NUM_LIGHTS) == 0)
	{
		return &undefined;
	}

	Array			*arr	= (Array*)arg_list[0];
	DWORD			lim		=0;

	type_check(arr, Array, _T("setRndLimits"));
	for (int i=0; i < arr->size; i++)
		lim |= GetID(renderTypes, elements(renderTypes), arr->data[i]);
	gw->setRndLimits(lim);
	return &ok;
}
Пример #3
0
cell factor_vm::code_block_owner(code_block *compiled)
{
	tagged<object> owner(compiled->owner);

	/* Cold generic word call sites point to quotations that call the
	inline-cache-miss and inline-cache-miss-tail primitives. */
	if(owner.type_p(QUOTATION_TYPE))
	{
		tagged<quotation> quot(owner.as<quotation>());
		tagged<array> elements(quot->array);
#ifdef FACTOR_DEBUG
		assert(array_capacity(elements.untagged()) == 5);
		assert(array_nth(elements.untagged(),4) == special_objects[PIC_MISS_WORD]
			|| array_nth(elements.untagged(),4) == special_objects[PIC_MISS_TAIL_WORD]);
#endif
		tagged<wrapper> word_wrapper(array_nth(elements.untagged(),0));
		return word_wrapper->object;
	}
	else
		return compiled->owner;
}
Пример #4
0
void
ExporterVTK<MeshType,N>::saveMesh( mesh_ptrtype mesh, vtkSmartPointer<vtkout_type> out ) const
{
    /* get local elements */
    //auto r = markedelements(step->mesh(), markerid, EntityProcessType::LOCAL_ONLY );
    auto r = elements(mesh);
    auto elt_it = r.template get<1>();
    auto elt_en = r.template get<2>();

    /* Gather points and elements into vectors + info about data */
    Feel::detail::MeshPoints<float> mp( mesh.get(), this->worldComm(), elt_it, elt_en, false, true, true, 0 );

    /* Add points to data structure */
    vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
    points->SetDataTypeToFloat();
    points->SetNumberOfPoints(mp.ids.size());

    float * coords = mp.coords.data();
    for ( int i = 0; i < mp.ids.size() ; i++ )
    {
        points->SetPoint( (vtkIdType)(mp.ids[i]), coords + i * 3 );
    }

    out->SetPoints(points);

    /* Add cells to data structure */
    int nbElem = mp.elem.size() / mesh_type::element_type::numPoints;
    out->Allocate(nbElem, nbElem);

    vtkSmartPointer<vtkelement_type> cell = vtkSmartPointer<vtkelement_type>::New();

    for( int i = 0; i < mp.elem.size(); i+=mesh_type::element_type::numPoints )
    {
        for( int p=0; p < mesh_type::element_type::numPoints; ++p )
        {
            cell->GetPointIds()->SetId(p, mp.elem[i + p]);
        }
        out->InsertNextCell(cell->GetCellType(), cell->GetPointIds());
    }
}
Пример #5
0
/*******************************************************************
* Function Name: externalFunction
* Description: 
********************************************************************/
Model &cola::externalFunction( const ExternalMessage &msg )
{
	if( msg.port() == in )
	{
		elements().push_back( msg.value() ) ;
		this->holdIn( AtomicState::active, preparationTime );
	}

	if( msg.port() == done )
	{
		ocupado (0);
		this->holdIn( AtomicState::active, preparationTime );
	}

	if( msg.port() == stop )
	{ 
		ocupado (1);
		this->passivate();
	}

	return *this;
}
Пример #6
0
//template< typename Expr_convection, typename Expr_bc >
void
PreconditionerAS<space_type,coef_space_type>::update( sparse_matrix_ptrtype Pm,   // A + g M
                                                      sparse_matrix_ptrtype L,    // e_r * grad grad
                                                      sparse_matrix_ptrtype hatL, // 1/mu * grad grad
                                                      sparse_matrix_ptrtype Q     // e_r * id id
                                                      )
{
    tic();
    if(this->type() == AS)
    {
        // A = Pm
        backend()->diag(Pm,M_diagPm);
        M_diagPm->close();

        /*
         * hat(L) = 1/mu * grad grad = 1/(mu*e_r) * L
         * bar(L) = diag( hat(L), hat(L), hat(L) )
         * bar(Q) = diag( er*Q, er*Q, er*Q ) with Q = mass matrix on Qh3
         * blockms.11.1 <=> bar(L) + g*bar(Q) y = s = Pt*r
         * blockms.11.2 <=> L z = t = trans(C)*r
         */

        // Operator hat(L) + g Q
        sparse_matrix_ptrtype Lgq = hatL;
        Lgq->addMatrix(M_g,Q);
        M_lgqOp = op( Lgq, "blockms.11.1");
        // Operator L
        M_lOp = op(L,"blockms.11.2");
    }
    else if(this->type() == SIMPLE)
    {
        auto uu = M_Vh->element("uu");
        auto f22 = form2(M_Vh, M_Vh);
        f22 = integrate(_range=elements(M_Vh->mesh()),
                        _expr=inner(id(uu),idt(uu)));
        SimpleOp = op( f22.matrixPtr(),"blockms.11.1");
    }
    toc( "PreconditionerAS::update", FLAGS_v > 0 );
}
Пример #7
0
void PeriodogramDisplay::work(void)
{
    for (auto inPort : this->inputs())
    {
        if (not inPort->hasMessage()) continue;
        const auto msg = inPort->popMessage();

        //label-based messages have in-line commands
        if (msg.type() == typeid(Pothos::Label))
        {
            const auto &label = msg.convert<Pothos::Label>();
            if (label.id == _freqLabelId and label.data.canConvert(typeid(double)))
            {
                this->setCenterFrequency(label.data.convert<double>());
            }
            if (label.id == _rateLabelId and label.data.canConvert(typeid(double)))
            {
                this->setSampleRate(label.data.convert<double>());
            }
        }

        //packet-based messages have payloads to FFT
        if (msg.type() == typeid(Pothos::Packet))
        {
            const auto &buff = msg.convert<Pothos::Packet>().payload;
            auto floatBuff = buff.convert(Pothos::DType(typeid(std::complex<float>)), buff.elements());

            //safe guard against FFT size changes, old buffers could still be in-flight
            if (floatBuff.elements() != this->numFFTBins()) continue;

            //power bins to points on the curve
            CArray fftBins(floatBuff.as<const std::complex<float> *>(), this->numFFTBins());
            const auto powerBins = fftPowerSpectrum(fftBins, _window.call<std::vector<double>>("window"), _window.call<double>("power"));
            if (not _queueDepth[inPort->index()]) _queueDepth[inPort->index()].reset(new std::atomic<size_t>(0));
            _queueDepth[inPort->index()]->fetch_add(1);
            QMetaObject::invokeMethod(this, "handlePowerBins", Qt::QueuedConnection, Q_ARG(int, inPort->index()), Q_ARG(std::valarray<float>, powerBins));
        }
    }
}
Пример #8
0
std::vector<IIntroDescriptor::Pointer> IntroRegistry::GetIntros() const
{
  const IExtensionPoint* point =
      Platform::GetExtensionPointService()->GetExtensionPoint(
          PlatformUI::PLUGIN_ID + "." + WorkbenchRegistryConstants::PL_INTRO);
  if (!point)
  {
    return std::vector<IIntroDescriptor::Pointer>();
  }

  std::vector<const IExtension*> extensions(point->GetExtensions());
  extensions = RegistryReader::OrderExtensions(extensions);

  std::vector<IIntroDescriptor::Pointer> list;
  for (std::size_t i = 0; i < extensions.size(); i++)
  {
    std::vector<IConfigurationElement::Pointer> elements(
        extensions[i] ->GetConfigurationElements());
    for (std::size_t j = 0; j < elements.size(); j++)
    {
      if (elements[j]->GetName() == TAG_INTRO)
      {
        try
        {
          IIntroDescriptor::Pointer
              descriptor(new IntroDescriptor(elements[j]));
          list.push_back(descriptor);
        } catch (CoreException& e)
        {
          // log an error since its not safe to open a dialog here
          //TODO IStatus
          WorkbenchPlugin::Log("Unable to create intro descriptor", e); // e.getStatus());
        }
      }
    }
  }

  return list;
}
Пример #9
0
ProcessParameter::enumeration_element_list ProcessParameter::EnumerationElements() const
{
   if ( !IsEnumeration() )
      return enumeration_element_list();

   size_type count = (*API->Process->GetParameterElementCount)( m_data->handle );
   if ( count == 0 )
      throw APIFunctionError( "GetParameterElementCount" );

   enumeration_element_list elements( count );

   for ( size_type i = 0; i < count; ++i )
   {
      size_type len = 0;
      (*API->Process->GetParameterElementIdentifier)( m_data->handle, i, 0, &len );
      if ( len == 0 )
         throw APIFunctionError( "GetParameterElementIdentifier" );
      elements[i].id.SetLength( len );
      if ( (*API->Process->GetParameterElementIdentifier)( m_data->handle, i, elements[i].id.c_str(), &len ) == api_false )
         throw APIFunctionError( "GetParameterElementIdentifier" );
      elements[i].id.ResizeToNullTerminated();

      len = 0;
      (*API->Process->GetParameterElementAliasIdentifiers)( m_data->handle, i, 0, &len );
      if ( len > 0 )
      {
         IsoString aliases;
         aliases.SetLength( len );
         if ( (*API->Process->GetParameterElementAliasIdentifiers)( m_data->handle, i, aliases.c_str(), &len ) == api_false )
            throw APIFunctionError( "GetParameterElementAliasIdentifiers" );
         aliases.ResizeToNullTerminated();
         aliases.Break( elements[i].aliases, ',' );
      }

      elements[i].value = (*API->Process->GetParameterElementValue)( m_data->handle, i );
   }

   return elements;
}
      void operator()( viennagrid::detail::tag<ElementT> )
      {
        typedef typename viennagrid::result_of::element_range<MeshViewT, ElementT>::type ToEraseElementRangeType;
        typedef typename viennagrid::result_of::iterator<ToEraseElementRangeType>::type ToEraseElementRangeIterator;

        typedef typename viennagrid::result_of::handle<MeshT, ElementT>::type ElementHandle;
        typedef typename viennagrid::result_of::element_range<MeshT, ElementT>::type ElementRangeType;
        typedef typename viennagrid::result_of::iterator<ElementRangeType>::type ElementRangeIterator;

        typedef typename viennagrid::result_of::id<ElementT>::type id_type;

  //             std::vector< std::pair<element_range_iterator, element_range_iterator> > swtiching_map;

        std::deque<id_type> ids_to_erase;

        ToEraseElementRangeType elements_to_erase(view_to_erase_);
        for (ToEraseElementRangeIterator it = elements_to_erase.begin(); it != elements_to_erase.end(); ++it)
          ids_to_erase.push_back( it->id() );

        ElementRangeType elements(mesh_obj_);

        for (typename std::deque<id_type>::iterator it = ids_to_erase.begin(); it != ids_to_erase.end(); ++it)
        {
          ElementRangeIterator to_erase_it = find( mesh_obj_, *it );
          ElementRangeIterator back_it = --elements.end();

          if (back_it != to_erase_it)
          {
            ElementHandle old_handle = back_it.handle();
            std::swap( *back_it, *to_erase_it );
            ElementHandle new_handle = to_erase_it.handle();

            switch_handle( mesh_obj_, old_handle, new_handle );
          }

          elements.erase( back_it );
        }
      }
      void copy(viennashe::math::sparse_matrix<NumericT> const & assembled_matrix,
                viennacl::compressed_matrix<NumericT>          &       vcl_matrix)
      {
        std::size_t nonzeros = assembled_matrix.nnz();
        viennacl::backend::typesafe_host_array<unsigned int> row_buffer(vcl_matrix.handle1(), assembled_matrix.size1() + 1);
        viennacl::backend::typesafe_host_array<unsigned int> col_buffer(vcl_matrix.handle2(), nonzeros);
        std::vector<NumericT> elements(nonzeros);

        std::size_t data_index = 0;

        for (std::size_t i  = 0;
                         i != assembled_matrix.size1();
                       ++i)
        {
          typedef typename viennashe::math::sparse_matrix<NumericT>::const_iterator2   AlongRowIterator;
          typedef typename viennashe::math::sparse_matrix<NumericT>::row_type          RowType;

          row_buffer.set(i, data_index);
          RowType const & row_i = assembled_matrix.row(i);

          for (AlongRowIterator col_it  = row_i.begin();
                                col_it != row_i.end();
                              ++col_it)
          {
            col_buffer.set(data_index, col_it->first);
            elements[data_index] = col_it->second;
            ++data_index;
          }
        }
        row_buffer.set(assembled_matrix.size1(), data_index);

        vcl_matrix.set(row_buffer.get(),
                       col_buffer.get(),
                       &elements[0],
                       assembled_matrix.size1(),
                       assembled_matrix.size2(),
                       nonzeros);
      }
Пример #12
0
void FaceCellConnectivity::build_connectivity()
{

  if (used().size() == 0 )
  {
    CFwarn << "No elements are given to build faces of" << CFendl;
    return;
  }

  // sanity check
//  CFinfo << "building face_cell connectivity using " << CFendl;
//  boost_foreach(Handle< Component > cells, used() )
//  {
//    CFinfo << "  " << cells->uri().path() << CFendl;
//  }

  // declartions
  m_connectivity->resize(0);
  common::Table<Entity>::Buffer f2c = m_connectivity->create_buffer();
  common::Table<Uint>::Buffer face_number = m_face_nb_in_elem->create_buffer();
  common::List<bool>::Buffer is_bdry_face = m_is_bdry_face->create_buffer();
  Dictionary& geometry_fields = find_parent_component<Mesh>(*used()[0]).geometry_fields();
  Uint tot_nb_nodes = geometry_fields.size();
  std::vector < std::vector<Uint> > mapNodeFace(tot_nb_nodes);
  std::vector<Uint> face_nodes;  face_nodes.reserve(100);
  std::vector<Entity> dummy_element_row(2);
  std::vector<Uint> dummy_idx_row(2);
  Uint max_nb_faces(0);

  // calculate max_nb_faces
  boost_foreach ( Handle< Component > elements_comp, used() )
  {
    Handle<Elements> elements(elements_comp);
    if (elements->element_type().dimensionality() != elements->element_type().dimension() )
      continue;
    const Uint nb_faces = elements->element_type().nb_faces();
    max_nb_faces += nb_faces * elements->size() ;
  }
Пример #13
0
    void work(void)
    {
        auto inputPort = this->input(0);
        auto outputPort = this->output(0);

        while (inputPort->hasMessage() and _elementsLeft != 0)
        {
            auto m = inputPort->popMessage();
            outputPort->postMessage(m);
            _elementsLeft -= 1;
        }

        auto buffer = inputPort->buffer();
        //input port type unspecified, inspect buffer for actual element count
        const size_t elems = std::min(_elementsLeft, buffer.elements());
        if (elems != 0)
        {
            buffer.length = elems*buffer.dtype.size();
            outputPort->postBuffer(buffer);
            inputPort->consume(buffer.length);
            _elementsLeft -= elems;
        }
    }
Пример #14
0
void Array<T>::eval()
{
    if (isReady()) return;

    this->setId(getActiveDeviceId());
    data = std::shared_ptr<T>(memAlloc<T>(elements()), memFree<T>);
    T *ptr = data.get();

    dim4 ostrs = strides();
    dim4 odims = dims();

    for (int w = 0; w < (int)odims[3]; w++) {
        dim_t offw = w * ostrs[3];

        for (int z = 0; z < (int)odims[2]; z++) {
            dim_t offz = z * ostrs[2] + offw;

            for (int y = 0; y < (int)odims[1]; y++) {
                dim_t offy = y * ostrs[1] + offz;

                for (int x = 0; x < (int)odims[0]; x++) {
                    dim_t id = x + offy;

                    ptr[id] = *(T *)node->calc(x, y, z, w);
                }
            }
        }
    }


    ready = true;

    Node_ptr prev = node;
    prev->reset();
    // FIXME: Replace the current node in any JIT possible trees with the new BufferNode
    node.reset();
}
Пример #15
0
void LogicAnalyzerDisplay::populateChannel(const int channel, const Pothos::Packet &packet)
{
    //convert buffer (does not convert when type matches)
    const auto numericBuff = packet.payload.convert(typeid(T));
    assert(_chData.size() > channel);
    _chData[channel] = packet;
    _chData[channel].payload = numericBuff;

    //load element data into table
    for (size_t i = 0; i < numericBuff.elements(); i++)
    {
        const auto num = numericBuff.as<const T *>()[i];
        const auto s = toStr(num, _chBase.at(channel));
        auto item = new QTableWidgetItem(s);
        auto flags = item->flags();
        flags &= ~Qt::ItemIsEditable;
        item->setFlags(flags);
        item->setTextAlignment(Qt::AlignRight);
        _tableView->setItem(channel, i, item);
    }

    //inspect labels to decorate table
    for (const auto &label : packet.labels)
    {
        const int column = label.index;
        assert(column < _tableView->columnCount());
        auto item = _tableView->item(channel, column);

        //highlight and display label id
        item->setBackground(Qt::yellow);
        item->setText(QString("%1\n%2")
            .arg(item->text())
            .arg(QString::fromStdString(label.id)));
        _tableView->resizeColumnToContents(column);
    }
}
Пример #16
0
int permute_sign(int n, ...){
	int sign=1;
	va_list ap;
	va_start(ap,n);
	vector<int> elements(n,0);
	
	for(int j=0; j<n; j++){
		elements[j]=va_arg(ap,int);
	}
	va_end(ap);
	
	int temp;
	for(int j=n;j>0;j--){
		for(int i=0;i<j-1;i++){
			if(elements[i]>elements[i+1]){
				 temp=elements[i];
				 elements[i]=elements[i+1];
				 elements[i+1]=temp;
				 sign*=-1;
			}
		}
	}
	return sign;
}		
Пример #17
0
//------------------------------add_liveout------------------------------------
// Add a vector of live-out values to a given blocks live-out set.
void PhaseLive::add_liveout( Block *p, IndexSet *lo, VectorSet &first_pass ) {
  IndexSet *live = &_live[p->_pre_order-1];
  IndexSet *defs = &_defs[p->_pre_order-1];
  IndexSet *on_worklist = _deltas[p->_pre_order-1];
  IndexSet *delta = on_worklist ? on_worklist : getfreeset();

  IndexSetIterator elements(lo);
  uint r;
  while ((r = elements.next()) != 0) {
    if( live->insert(r) &&      // If actually inserted...
        !defs->member( r ) )    // and not defined locally
      delta->insert(r);         // Then add to live-in set
  }

  if( delta->count() ) {                // If actually added things
    _deltas[p->_pre_order-1] = delta; // Flag as on worklist now
    if( !on_worklist &&         // Not on worklist?
        first_pass.test(p->_pre_order) )
      _worklist->push(p);       // Actually go on worklist if already 1st pass
  } else {                      // Nothing there; just free it
    delta->set_next(_free_IndexSet);
    _free_IndexSet = delta;     // Drop onto free list
  }
}
Пример #18
0
inline typename boost::enable_if<boost::mpl::and_<
    is_vector<T>, boost::is_fundamental<typename T::value_type>
>, void>::type
write_attribute(H5::H5Object const& object, std::string const& name, T const& value)
{
    typedef typename T::value_type value_type;

    H5::Attribute attr;
    try {
        H5XX_NO_AUTO_PRINT(H5::AttributeIException);
        attr = object.openAttribute(name);
        if (!has_type<T>(attr) || elements(attr) != value.size()) {
            // recreate attribute with proper type
            object.removeAttr(name);
            throw H5::AttributeIException();
        }
    }
    catch (H5::AttributeIException const&) {
        hsize_t dim[1] = { value.size() };
        H5::DataSpace ds(1, dim);
        attr = object.createAttribute(name, ctype<value_type>::hid(), ds);
    }
    attr.write(ctype<value_type>::hid(), &*value.begin());
}
Пример #19
0
void
PreconditionerBlockMS<space_type>::initAMS( void )
    {
        M_grad  = Grad( _domainSpace=M_Qh, _imageSpace=M_Vh);

        // This preconditioner is linked to that backend : the backend will
        // automatically use the preconditioner.
        auto prec = preconditioner(_pc=pcTypeConvertStrToEnum(soption(M_prefix_11+".pc-type")),
                                   _backend=backend(_name=M_prefix_11),
                                   _prefix=M_prefix_11,
                                   _matrix=M_11
                                  );
        prec->setMatrix(M_11);
        prec->attachAuxiliarySparseMatrix("G",M_grad.matPtr());
        if(boption(M_prefix_11+".useEdge"))
        {
            LOG(INFO) << "[ AMS ] : using SetConstantEdgeVector \n";
            ozz.on(_range=elements(M_Vh->mesh()),_expr=vec(cst(1),cst(0),cst(0)));
            zoz.on(_range=elements(M_Vh->mesh()),_expr=vec(cst(0),cst(1),cst(0)));
            zzo.on(_range=elements(M_Vh->mesh()),_expr=vec(cst(0),cst(0),cst(1)));
            *M_ozz = ozz; M_ozz->close();
            *M_zoz = zoz; M_zoz->close();
            *M_zzo = zzo; M_zzo->close();

            prec->attachAuxiliaryVector("Px",M_ozz);
            prec->attachAuxiliaryVector("Py",M_zoz);
            prec->attachAuxiliaryVector("Pz",M_zzo);
        }
        else
        {
            LOG(INFO) << "[ AMS ] : using SetCoordinates \n";
            X.on(_range=elements(M_Vh->mesh()),_expr=Px());
            Y.on(_range=elements(M_Vh->mesh()),_expr=Py());
            Z.on(_range=elements(M_Vh->mesh()),_expr=Pz());
            *M_X = X; M_X->close();
            *M_Y = Y; M_Y->close();
            *M_Z = Z; M_Z->close();
            prec->attachAuxiliaryVector("X",M_X);
            prec->attachAuxiliaryVector("Y",M_Y);
            prec->attachAuxiliaryVector("Z",M_Z);
        }
    }
Пример #20
0
//! Create an element sequence
ErrorCode ReadGmsh::create_elements(const GmshElemType& type,
                                    const std::vector<int>& elem_ids,
                                    const std::vector<int>& matl_ids,
                                    const std::vector<int>& geom_ids,
                                    const std::vector<int>& prtn_ids,
                                    const std::vector<EntityHandle>& connectivity,
                                    const Tag* file_id_tag)
{
  ErrorCode result;

  // Make sure input is consistent
  const unsigned long num_elem = elem_ids.size();
  const int node_per_elem = type.num_nodes;
  if (matl_ids.size() != num_elem ||
      geom_ids.size() != num_elem ||
      prtn_ids.size() != num_elem ||
      connectivity.size() != num_elem*node_per_elem)
    return MB_FAILURE;

  // Create the element sequence
  // do not do anything for point type
  if (type.mb_type==MBVERTEX)
    return MB_SUCCESS; // do not create anything
  EntityHandle handle = 0;
  EntityHandle* conn_array;
  result = readMeshIface->get_element_connect(num_elem, node_per_elem, type.mb_type,
                                              MB_START_ID,
                                              handle, conn_array);
  if (MB_SUCCESS != result)
    return result;

  // Copy passed element connectivity into entity sequence data.
  if (type.node_order) {
    for (unsigned long i = 0; i < num_elem; ++i)
      for (int j = 0; j < node_per_elem; ++j)
        conn_array[i*node_per_elem + type.node_order[j]] = connectivity[i*node_per_elem + j];
  }
  else {
    memcpy(conn_array, &connectivity[0], connectivity.size() * sizeof(EntityHandle));
  }

  // Notify MOAB of the new elements
  result = readMeshIface->update_adjacencies(handle, num_elem, node_per_elem, conn_array);
  if (MB_SUCCESS != result)
    return result;

  // Store element IDs
  Range elements(handle, handle + num_elem - 1);
  result = mdbImpl->tag_set_data(globalId, elements, &elem_ids[0]);
  if (MB_SUCCESS != result)
    return result;
  if (file_id_tag) {
    result = mdbImpl->tag_set_data(*file_id_tag, elements, &elem_ids[0]);
    if (MB_SUCCESS != result) 
      return result;
  }

  // Add elements to material sets
  result = create_sets(type.mb_type, elements, matl_ids, 0);
  if (MB_SUCCESS != result)
    return result;
  // Add elements to geometric sets
  result = create_sets(type.mb_type, elements, geom_ids, 1);
  if (MB_SUCCESS != result)
    return result;
  // Add elements to parallel partitions
  result = create_sets(type.mb_type, elements, prtn_ids, 2);
  if (MB_SUCCESS != result)
    return result;

  return MB_SUCCESS;
}
void LogStatistics::format(char **buf, uid_t uid, unsigned int logMask) {
    static const unsigned short spaces_total = 19;

    if (*buf) {
        free(*buf);
        *buf = NULL;
    }

    // Report on total logging, current and for all time

    android::String8 output("size/num");
    size_t oldLength;
    short spaces = 1;

    log_id_for_each(id) {
        if (!(logMask & (1 << id))) {
            continue;
        }
        oldLength = output.length();
        if (spaces < 0) {
            spaces = 0;
        }
        output.appendFormat("%*s%s", spaces, "", android_log_id_to_name(id));
        spaces += spaces_total + oldLength - output.length();
    }

    spaces = 4;
    output.appendFormat("\nTotal");

    log_id_for_each(id) {
        if (!(logMask & (1 << id))) {
            continue;
        }
        oldLength = output.length();
        if (spaces < 0) {
            spaces = 0;
        }
        output.appendFormat("%*s%zu/%zu", spaces, "",
                            sizesTotal(id), elementsTotal(id));
        spaces += spaces_total + oldLength - output.length();
    }

    spaces = 6;
    output.appendFormat("\nNow");

    log_id_for_each(id) {
        if (!(logMask & (1 << id))) {
            continue;
        }

        size_t els = elements(id);
        if (els) {
            oldLength = output.length();
            if (spaces < 0) {
                spaces = 0;
            }
            output.appendFormat("%*s%zu/%zu", spaces, "", sizes(id), els);
            spaces -= output.length() - oldLength;
        }
        spaces += spaces_total;
    }

    // Report on Chattiest

    // Chattiest by application (UID)
    static const size_t maximum_sorted_entries = 32;
    log_id_for_each(id) {
        if (!(logMask & (1 << id))) {
            continue;
        }

        bool headerPrinted = false;
        std::unique_ptr<const UidEntry *[]> sorted = sort(maximum_sorted_entries, id);
        ssize_t index = -1;
        while ((index = uidTable_t::next(index, sorted, maximum_sorted_entries)) >= 0) {
            const UidEntry *entry = sorted[index];
            uid_t u = entry->getKey();
            if ((uid != AID_ROOT) && (u != uid)) {
                continue;
            }

            if (!headerPrinted) {
                if (uid == AID_ROOT) {
                    output.appendFormat(
                        "\n\nChattiest UIDs in %s:\n",
                        android_log_id_to_name(id));
                } else {
                    output.appendFormat(
                        "\n\nLogging for your UID in %s:\n",
                        android_log_id_to_name(id));
                }
                android::String8 name("UID");
                android::String8 size("Size");
                android::String8 pruned("Pruned");
                if (!worstUidEnabledForLogid(id)) {
                    pruned.setTo("");
                }
                format_line(output, name, size, pruned);
                headerPrinted = true;
            }

            android::String8 name("");
            name.appendFormat("%u", u);
            char *n = uidToName(u);
            if (n) {
                name.appendFormat("%*s%s", (int)std::max(6 - name.length(), (size_t)1), "", n);
                free(n);
            }

            android::String8 size("");
            size.appendFormat("%zu", entry->getSizes());

            android::String8 pruned("");
            size_t dropped = entry->getDropped();
            if (dropped) {
                pruned.appendFormat("%zu", dropped);
            }

            format_line(output, name, size, pruned);
        }
    }

    if (enable) {
        bool headerPrinted = false;
        std::unique_ptr<const PidEntry *[]> sorted = pidTable.sort(maximum_sorted_entries);
        ssize_t index = -1;
        while ((index = pidTable.next(index, sorted, maximum_sorted_entries)) >= 0) {
            const PidEntry *entry = sorted[index];
            uid_t u = entry->getUid();
            if ((uid != AID_ROOT) && (u != uid)) {
                continue;
            }

            if (!headerPrinted) {
                if (uid == AID_ROOT) {
                    output.appendFormat("\n\nChattiest PIDs:\n");
                } else {
                    output.appendFormat("\n\nLogging for this PID:\n");
                }
                android::String8 name("  PID/UID");
                android::String8 size("Size");
                android::String8 pruned("Pruned");
                format_line(output, name, size, pruned);
                headerPrinted = true;
            }

            android::String8 name("");
            name.appendFormat("%5u/%u", entry->getKey(), u);
            const char *n = entry->getName();
            if (n) {
                name.appendFormat("%*s%s", (int)std::max(12 - name.length(), (size_t)1), "", n);
            } else {
                char *un = uidToName(u);
                if (un) {
                    name.appendFormat("%*s%s", (int)std::max(12 - name.length(), (size_t)1), "", un);
                    free(un);
                }
            }

            android::String8 size("");
            size.appendFormat("%zu", entry->getSizes());

            android::String8 pruned("");
            size_t dropped = entry->getDropped();
            if (dropped) {
                pruned.appendFormat("%zu", dropped);
            }

            format_line(output, name, size, pruned);
        }
    }

    *buf = strdup(output.string());
}
Пример #22
0
void print_sorted_addresses(FooIterator beginFoos, FooIterator endFoos) {
    std::vector<const Foo*> elements(make_address_iterator(beginFoos), make_address_iterator(endFoos));
    std::sort(elements.begin(), elements.end());
    for(const Foo* e : elements)
        std::cout << e << std::endl;
}
Пример #23
0
 void updateFieldVelocityConvection( vf::Expr<ExprT> const& expr )
 {
     if ( M_fieldVelocityConvection )
         this->updateForUseFunctionSpacesVelocityConvection();
     M_fieldVelocityConvection->on(_range=elements(this->mesh()), _expr=expr );
 }
Пример #24
0
void KlassInfoHisto::sort() {
  elements()->sort(KlassInfoHisto::sort_helper);
}
Пример #25
0
void KlassInfoHisto::print_class_stats(outputStream* st,
                                      bool csv_format, const char *columns) {
  ResourceMark rm;
  KlassSizeStats sz, sz_sum;
  int i;
  julong *col_table = (julong*)(&sz);
  julong *colsum_table = (julong*)(&sz_sum);
  int width_table[KlassSizeStats::_num_columns];
  bool selected[KlassSizeStats::_num_columns];

  _selected_columns = columns;

  memset(&sz_sum, 0, sizeof(sz_sum));
  for (int c=0; c<KlassSizeStats::_num_columns; c++) {
    selected[c] = is_selected(name_table[c]);
  }

  for(i=0; i < elements()->length(); i++) {
    elements()->at(i)->set_index(i+1);
  }

  for (int pass=1; pass<=2; pass++) {
    if (pass == 2) {
      print_title(st, csv_format, selected, width_table, name_table);
    }
    for(i=0; i < elements()->length(); i++) {
      KlassInfoEntry* e = (KlassInfoEntry*)elements()->at(i);
      const Klass* k = e->klass();

      memset(&sz, 0, sizeof(sz));
      sz._inst_count = e->count();
      sz._inst_bytes = HeapWordSize * e->words();
      k->collect_statistics(&sz);
      sz._total_bytes = sz._ro_bytes + sz._rw_bytes;

      if (pass == 1) {
        for (int c=0; c<KlassSizeStats::_num_columns; c++) {
          colsum_table[c] += col_table[c];
        }
      } else {
        int super_index = -1;
        if (k->oop_is_instance()) {
          Klass* super = ((InstanceKlass*)k)->java_super();
          if (super) {
            KlassInfoEntry* super_e = _cit->lookup(super);
            if (super_e) {
              super_index = super_e->index();
            }
          }
        }

        if (csv_format) {
          st->print("%d,%d", e->index(), super_index);
          for (int c=0; c<KlassSizeStats::_num_columns; c++) {
            if (selected[c]) {st->print("," JULONG_FORMAT, col_table[c]);}
          }
          st->print(",%s",e->name());
        } else {
          st->print("%5d %5d", e->index(), super_index);
          for (int c=0; c<KlassSizeStats::_num_columns; c++) {
            if (selected[c]) {print_julong(st, width_table[c], col_table[c]);}
          }
          st->print(" %s", e->name());
        }
        if (is_selected("ClassLoader")) {
          ClassLoaderData* loader_data = k->class_loader_data();
          st->print(",");
          loader_data->print_value_on(st);
        }
        st->cr();
      }
    }

    if (pass == 1) {
      for (int c=0; c<KlassSizeStats::_num_columns; c++) {
        width_table[c] = col_width(colsum_table[c], name_table[c]);
      }
    }
  }

  sz_sum._inst_size = 0;

  if (csv_format) {
    st->print(",");
    for (int c=0; c<KlassSizeStats::_num_columns; c++) {
      if (selected[c]) {st->print("," JULONG_FORMAT, colsum_table[c]);}
    }
  } else {
    st->print("           ");
    for (int c=0; c<KlassSizeStats::_num_columns; c++) {
      if (selected[c]) {print_julong(st, width_table[c], colsum_table[c]);}
    }
    st->print(" Total");
    if (sz_sum._total_bytes > 0) {
      st->cr();
      st->print("           ");
      for (int c=0; c<KlassSizeStats::_num_columns; c++) {
        if (selected[c]) {
          switch (c) {
          case KlassSizeStats::_index_inst_size:
          case KlassSizeStats::_index_inst_count:
          case KlassSizeStats::_index_method_count:
PRAGMA_DIAG_PUSH
PRAGMA_FORMAT_NONLITERAL_IGNORED_INTERNAL
            st->print(str_fmt(width_table[c]), "-");
PRAGMA_DIAG_POP
            break;
          default:
            {
              double perc = (double)(100) * (double)(colsum_table[c]) / (double)sz_sum._total_bytes;
PRAGMA_DIAG_PUSH
PRAGMA_FORMAT_NONLITERAL_IGNORED_INTERNAL
              st->print(perc_fmt(width_table[c]), perc);
PRAGMA_DIAG_POP
            }
          }
        }
      }
    }
  }
Пример #26
0
void KlassInfoHisto::add(KlassInfoEntry* cie) {
  elements()->append(cie);
}
Пример #27
0
			template<class Compare> void sort(Compare comp) {
				pimpl.elements.swap(std::map<TKey, TElement*>(pimpl.elements.begin(), pimpl.elements().end(), comp));
			}
Пример #28
0
inline Operand OperandOperandList::elements(int index) { return elements()[index]; }
Пример #29
0
inline unsigned OperandOperandList::elementCount() { return elements().size(); }
Пример #30
0
inline Code OperandCodeList::elements(int index) { return elements()[index]; }