Exemplo n.º 1
0
void FieldManagerDlg::OnBnClickedAddBtn()
{
    InputDlg dlg;
    if( dlg.DoModal() != IDOK ) return;

    // 注意m_lastSel的更新问题
    if( m_fieldListBox.GetCount() == 0 ) setLastSelIndex( 0 );

    if( !isValidField( dlg.m_str ) )
    {
        CString msg;
        msg.Format( _T( "非法的字段\n[%s]" ), dlg.m_str );
        MessageBox( msg );
        return;
    }
    if( isFieldExistInListBox( dlg.m_str ) )
    {
        CString msg;
        msg.Format( _T( "字段[%s]已存在!" ), dlg.m_str );
        MessageBox( msg );
        return;
    }

    // 添加字段到listbox中
    int index = m_fieldListBox.AddString( dlg.m_str );
    if( index != LB_ERR )
    {
        m_fieldListBox.SetCurSel( index );
        // ***创建新的字段信息,并记录***
        m_infoes.append( new FieldInfo() );

        // 切换selection, 保存上次selection所在位置的字段信息
        updateFieldInfo();
    }
}
Exemplo n.º 2
0
void
FeatureFloodCount::finalize()
{
  communicateAndMerge();

  // Populate _feature_maps and _var_index_maps
  updateFieldInfo();

  // Calculate and out output bubble volume data
  if (_pars.isParamValid("bubble_volume_file"))
  {
    calculateBubbleVolumes();
    std::vector<Real> data;
    data.reserve(_all_feature_volumes.size() + _total_volume_intersecting_boundary.size() + 2);

    // Insert the current timestep and the simulation time into the data vector
    data.push_back(_fe_problem.timeStep());
    data.push_back(_fe_problem.time());

    // Insert the (sorted) bubble volumes into the data vector
    data.insert(data.end(), _all_feature_volumes.begin(), _all_feature_volumes.end());

    // If we are computing the boundary-intersecting volumes, insert
    // those numbers into the normalized boundary-intersecting bubble
    // volumes into the data vector.
    if (_compute_boundary_intersecting_volume)
      data.insert(data.end(), _total_volume_intersecting_boundary.begin(), _total_volume_intersecting_boundary.end());

    // Finally, write the file
    writeCSVFile(getParam<FileName>("bubble_volume_file"), data);
  }
}
Exemplo n.º 3
0
void
GrainTracker::finalize()
{
  Moose::perf_log.push("finalize()", "GrainTracker");

  // Don't track grains if the current simulation step is before the specified tracking step
  if (_t_step < _tracking_step)
    return;

  expandHalos();

  FeatureFloodCount::communicateAndMerge();

  _console << "Finished inside of FeatureFloodCount" << std::endl;

  Moose::perf_log.push("trackGrains()","GrainTracker");
  trackGrains();
  Moose::perf_log.pop("trackGrains()","GrainTracker");

  _console << "Finished inside of trackGrains" << std::endl;

  Moose::perf_log.push("remapGrains()","GrainTracker");
  if (_remap)
    remapGrains();
  Moose::perf_log.pop("remapGrains()","GrainTracker");

  updateFieldInfo();

  _console << "Finished inside of updateFieldInfo" << std::endl;

  // Calculate and out output bubble volume data
  if (_pars.isParamValid("bubble_volume_file"))
  {
    calculateBubbleVolumes();
    std::vector<Real> data; data.reserve(_all_feature_volumes.size() + 2);
    data.push_back(_fe_problem.timeStep());
    data.push_back(_fe_problem.time());
    data.insert(data.end(), _all_feature_volumes.begin(), _all_feature_volumes.end());
    writeCSVFile(getParam<FileName>("bubble_volume_file"), data);
  }

  if (_compute_op_maps)
  {
    for (std::map<unsigned int, MooseSharedPointer<FeatureData> >::const_iterator grain_it = _unique_grains.begin();
         grain_it != _unique_grains.end(); ++grain_it)
    {
      if (grain_it->second->_status != INACTIVE)
      {
        std::set<dof_id_type>::const_iterator elem_it_end = grain_it->second->_local_ids.end();
        for (std::set<dof_id_type>::const_iterator elem_it = grain_it->second->_local_ids.begin(); elem_it != elem_it_end; ++elem_it)
        {
          mooseAssert(!_ebsd_reader || _unique_grain_to_ebsd_num.find(grain_it->first) != _unique_grain_to_ebsd_num.end(), "Bad mapping in unique_grain_to_ebsd_num");
          _elemental_data[*elem_it].push_back(std::make_pair(_ebsd_reader ? _unique_grain_to_ebsd_num[grain_it->first] : grain_it->first, grain_it->second->_var_idx));
        }
      }
    }
  }

  Moose::perf_log.pop("finalize()", "GrainTracker");
}
Exemplo n.º 4
0
void
NodalFloodCount::finalize()
{
  // Exchange data in parallel
  pack(_packed_data);
  _communicator.allgather(_packed_data, false);
  unpack(_packed_data);

  mergeSets();

  // Populate _bubble_maps and _var_index_maps
  updateFieldInfo();

  // Update the region offsets so we can get unique bubble numbers in multimap mode
  updateRegionOffsets();

  // Calculate and out output bubble volume data
  if (_pars.isParamValid("bubble_volume_file"))
  {
    calculateBubbleVolumes();
    std::vector<Real> data; data.reserve(_all_bubble_volumes.size() + 2);
    data.push_back(_fe_problem.timeStep());
    data.push_back(_fe_problem.time());
    data.insert(data.end(), _all_bubble_volumes.begin(), _all_bubble_volumes.end());
    writeCSVFile(getParam<FileName>("bubble_volume_file"), data);
  }

  // Calculate memory usage
  if (_track_memory)
  {
    _bytes_used += calculateUsage();
    _communicator.sum(_bytes_used);
    formatBytesUsed();
  }
}
Exemplo n.º 5
0
const HitList &
PhraseQueryNode::evaluateHits(HitList & hl) const
{
    hl.clear();
    _fieldInfo.clear();
    if ( ! AndQueryNode::evaluate()) return hl;

    HitList tmpHL;
    unsigned int fullPhraseLen = size();
    unsigned int currPhraseLen = 0;
    std::vector<unsigned int> indexVector(fullPhraseLen, 0);
    auto curr = static_cast<const QueryTerm *> ((*this)[currPhraseLen].get());
    bool exhausted( curr->evaluateHits(tmpHL).empty());
    for (; !exhausted; ) {
        auto next = static_cast<const QueryTerm *>((*this)[currPhraseLen+1].get());
        unsigned int & currIndex = indexVector[currPhraseLen];
        unsigned int & nextIndex = indexVector[currPhraseLen+1];

        const auto & currHit = curr->evaluateHits(tmpHL)[currIndex];
        size_t firstPosition = currHit.pos();
        uint32_t currElemId = currHit.elemId();
        uint32_t currContext = currHit.context();

        const HitList & nextHL = next->evaluateHits(tmpHL);

        int diff(0);
        size_t nextIndexMax = nextHL.size();
        while ((nextIndex < nextIndexMax) &&
              ((nextHL[nextIndex].context() < currContext) ||
               ((nextHL[nextIndex].context() == currContext) && (nextHL[nextIndex].elemId() <= currElemId))) &&
             ((diff = nextHL[nextIndex].pos()-firstPosition) < 1))
        {
            nextIndex++;
        }
        if ((diff == 1) && (nextHL[nextIndex].context() == currContext) && (nextHL[nextIndex].elemId() == currElemId)) {
            currPhraseLen++;
            if ((currPhraseLen+1) == fullPhraseLen) {
                Hit h = nextHL[indexVector[currPhraseLen]];
                hl.push_back(h);
                const QueryTerm::FieldInfo & fi = next->getFieldInfo(h.context());
                updateFieldInfo(h.context(), hl.size() - 1, fi.getFieldLength());
                currPhraseLen = 0;
                indexVector[0]++;
            }
        } else {
            currPhraseLen = 0;
            indexVector[currPhraseLen]++;
        }
        curr = static_cast<const QueryTerm *>((*this)[currPhraseLen].get());
        exhausted = (nextIndex >= nextIndexMax) || (indexVector[currPhraseLen] >= curr->evaluateHits(tmpHL).size());
    }
    return hl;
}
Exemplo n.º 6
0
void
FeatureFloodCount::finalize()
{
  // Exchange data in parallel
  pack(_packed_data);
  _communicator.allgather(_packed_data, false);
  unpack(_packed_data);

  mergeSets(true);

  // Populate _bubble_maps and _var_index_maps
  updateFieldInfo();

  // Update the region offsets so we can get unique bubble numbers in multimap mode
  updateRegionOffsets();

  // Calculate and out output bubble volume data
  if (_pars.isParamValid("bubble_volume_file"))
  {
    calculateBubbleVolumes();
    std::vector<Real> data;
    data.reserve(_all_bubble_volumes.size() + _total_volume_intersecting_boundary.size() + 2);

    // Insert the current timestep and the simulation time into the data vector
    data.push_back(_fe_problem.timeStep());
    data.push_back(_fe_problem.time());

    // Insert the (sorted) bubble volumes into the data vector
    data.insert(data.end(), _all_bubble_volumes.begin(), _all_bubble_volumes.end());

    // If we are computing the boundary-intersecting volumes, insert
    // those numbers into the normalized boundary-intersecting bubble
    // volumes into the data vector.
    if (_compute_boundary_intersecting_volume)
      data.insert(data.end(), _total_volume_intersecting_boundary.begin(), _total_volume_intersecting_boundary.end());

    // Finally, write the file
    writeCSVFile(getParam<FileName>("bubble_volume_file"), data);
  }

  // Calculate memory usage
  if (_track_memory)
  {
    _bytes_used += calculateUsage();
    _communicator.sum(_bytes_used);
    formatBytesUsed();
  }
}
Exemplo n.º 7
0
void
FeatureFloodCount::finalize()
{
  // Gather all information on processor zero and merge
  communicateAndMerge();

  // Sort and label the features
  if (_is_master)
    sortAndLabel();

  // Send out the local to global mappings
  scatterAndUpdateRanks();

  // Populate _feature_maps and _var_index_maps
  updateFieldInfo();
}
Exemplo n.º 8
0
/*
 * 方法:
 *	  1) 得到原始的字段链表L1和字段列表框中的字段链表L2
 *    2) 遍历链表L2,判断字段是否存在于L1中
 *       a) 如果存在,则该字段保持不变,并从L1中移除该字段;
 *       b) 如果不存在,则转第(3)步
 *    3) 该字段是新添加的字段,则执行"增加字段"操作Add
 *    4) 完成遍历L2,最后剩下的L1的元素就是需要删除的字段
 *    5) 执行"删除字段"操作Remove
 */
void FieldManagerDlg::OnBnClickedApplyBtn()
{
    if( m_fieldListBox.GetCount() > 0 )
    {
        // 切换之前更新上次选择的字段信息
        // 并检查字段信息的有效性
        if( !updateFieldInfo() ) return;
    }

    // 选择的图元类型
    CString selType = getSelType();
    if( selType.GetLength() == 0 ) return;

    AcStringArray fields;
    FieldHelper::GetAllFields( selType, fields );
    if( fields.isEmpty() && m_fieldListBox.GetCount() == 0 )
    {
        MessageBox( _T( "没有字段可更新" ) );
        return;
    }

    // "剩余"字段
    // 与m_infoes应该是一一对应的
    AcStringArray leftFields;
    for( int i = 0; i < m_fieldListBox.GetCount(); i++ )
    {
        CString text;
        m_fieldListBox.GetText( i, text );
        leftFields.append( text );
    }

    int len = leftFields.length();
    for( int i = 0; i < len; i++ )
    {
        CString field = leftFields[i].kACharPtr();
        int index = fields.find( field );
        if( index >= 0 ) // 已存在,不变
        {
            fields.removeAt( index );
        }
        else
        {
            // 增加字段
            FieldHelper::AddField( selType, field );
        }
        // 默认属性设置不需要添加到词典中
        if( m_infoes[i]->isDefault() )
        {
            FieldInfoHelper::RemoveFieldInfo( selType, field );
        }
        else
        {
            // 新增的字段
            if( index < 0 || !FieldInfoHelper::FindFieldInfo( selType, field ) )
            {
                FieldInfoHelper::AddFieldInfo( selType, field, *m_infoes[i] );
            }
            else
            {
                // 更新已有的字段信息
                FieldInfoHelper::WriteFieldInfo( selType, field, *m_infoes[i] );
            }
        }
    }

    // 删除字段
    len = fields.length();
    for( int i = 0; i < len; i++ )
    {
        FieldHelper::RemoveField( selType, fields[i].kACharPtr() );
    }

    MessageBox( _T( "字段信息更新成功!" ) );
}
Exemplo n.º 9
0
void FieldManagerDlg::OnLbnSelchangeFieldList()
{
    // 切换之前更新上次选择的字段信息
    // 并检查字段信息的有效性
    updateFieldInfo();
}
Exemplo n.º 10
0
void
GrainTracker::finalize()
{
 // Don't track grains if the current simulation step is before the specified tracking step
  if (_t_step < _tracking_step)
    return;
  Moose::perf_log.push("finalize()","GrainTracker");

  // Exchange data in parallel
  pack(_packed_data);
  _communicator.allgather(_packed_data, false);
  unpack(_packed_data);
  mergeSets(false);

  Moose::perf_log.push("buildspheres()","GrainTracker");
  buildBoundingSpheres();                    // Build bounding sphere information
  Moose::perf_log.pop("buildspheres()","GrainTracker");

  // Now merge sets again but this time we'll add periodic neighbor information
  mergeSets(true);

  Moose::perf_log.push("trackGrains()","GrainTracker");
  trackGrains();
  Moose::perf_log.pop("trackGrains()","GrainTracker");

  Moose::perf_log.push("remapGrains()","GrainTracker");
  if (_remap)
    remapGrains();
  Moose::perf_log.pop("remapGrains()","GrainTracker");

  updateFieldInfo();
  Moose::perf_log.pop("finalize()","GrainTracker");

  // Calculate and out output bubble volume data
  if (_pars.isParamValid("bubble_volume_file"))
  {
    calculateBubbleVolumes();
    std::vector<Real> data; data.reserve(_all_bubble_volumes.size() + 2);
    data.push_back(_fe_problem.timeStep());
    data.push_back(_fe_problem.time());
    data.insert(data.end(), _all_bubble_volumes.begin(), _all_bubble_volumes.end());
    writeCSVFile(getParam<FileName>("bubble_volume_file"), data);
  }

  if (_compute_op_maps)
  {
    for (std::map<unsigned int, UniqueGrain *>::const_iterator grain_it = _unique_grains.begin();
         grain_it != _unique_grains.end(); ++grain_it)
    {
      if (grain_it->second->status != INACTIVE)
      {
        std::set<dof_id_type>::const_iterator elem_it_end = grain_it->second->entities_ptr->end();
        for (std::set<dof_id_type>::const_iterator elem_it = grain_it->second->entities_ptr->begin(); elem_it != elem_it_end; ++elem_it)
          _elemental_data[*elem_it].push_back(std::make_pair(grain_it->first, grain_it->second->variable_idx));
      }
    }
  }

  // Calculate memory usage
  if (_track_memory)
  {
    _bytes_used += calculateUsage();
    _communicator.sum(_bytes_used);
    formatBytesUsed();
  }
}