PatternedMesh::PatternedMesh(const InputParameters & parameters) : MooseMesh(parameters), _files(getParam<std::vector<MeshFileName> >("files")), _pattern(getParam<std::vector<std::vector<unsigned int> > >("pattern")), _x_width(getParam<Real>("x_width")), _y_width(getParam<Real>("y_width")), _z_width(getParam<Real>("z_width")) { // The PatternedMesh class only works with ReplicatedMesh errorIfDistributedMesh("PatternedMesh"); _meshes.reserve(_files.size()); // Read in all of the meshes for (auto i = beginIndex(_files); i < _files.size(); ++i) { _meshes.emplace_back(libmesh_make_unique<ReplicatedMesh>(_communicator)); auto & mesh = _meshes.back(); mesh->read(_files[i]); } _original_mesh = dynamic_cast<ReplicatedMesh *>(&getMesh()); if (!_original_mesh) mooseError("PatternedMesh does not support DistributedMesh"); // Create a mesh for all n-1 rows, the first row is the original mesh _row_meshes.reserve(_pattern.size() - 1); for (auto i = beginIndex(_pattern); i < _pattern.size() - 1; ++i) _row_meshes.emplace_back(libmesh_make_unique<ReplicatedMesh>(_communicator)); }
void TimePeriod::execute() { // ENABLE for (auto i = beginIndex(_enable); i < _enable.size(); ++i) { // If the current time falls between the start and end time, ENABLE the object (_t >= // _start_time and _t < _end_time) if (MooseUtils::absoluteFuzzyGreaterEqual(_t, _start_time[i]) && MooseUtils::absoluteFuzzyLessThan(_t, _end_time[i])) setControllableValueByName<bool>(_enable[i], std::string("enable"), true); else if (_set_outside_of_range) setControllableValueByName<bool>(_enable[i], std::string("enable"), false); } // DISABLE for (auto i = beginIndex(_disable); i < _disable.size(); ++i) { // If the current time falls between the start and end time, DISABLE the object (_t >= // _start_time and _t < _end_time) if (MooseUtils::absoluteFuzzyGreaterEqual(_t, _start_time[i]) && MooseUtils::absoluteFuzzyLessThan(_t, _end_time[i])) setControllableValueByName<bool>(_disable[i], std::string("enable"), false); else if (_set_outside_of_range) setControllableValueByName<bool>(_disable[i], std::string("enable"), true); } }
void FeatureFloodCount::execute() { const auto end = _mesh.getMesh().active_local_elements_end(); for (auto el = _mesh.getMesh().active_local_elements_begin(); el != end; ++el) { const Elem * current_elem = *el; // Loop over elements or nodes if (_is_elemental) { for (auto var_num = beginIndex(_vars); var_num < _vars.size(); ++var_num) flood(current_elem, var_num, nullptr /* Designates inactive feature */); } else { auto n_nodes = current_elem->n_vertices(); for (auto i = decltype(n_nodes)(0); i < n_nodes; ++i) { const Node * current_node = current_elem->get_node(i); for (auto var_num = beginIndex(_vars); var_num < _vars.size(); ++var_num) flood(current_node, var_num, nullptr /* Designates inactive feature */); } } } }
void CExperimentSet::sort() { // First we make sure that all experiments are at the end of the group index_iterator it = beginIndex(); index_iterator end = endIndex(); index_iterator swapTarget = beginIndex(); mNonExperiments = 0; for (; it != end; ++it) if (dynamic_cast< CExperiment * >(*it) == NULL) { if (it != swapTarget) swap(it, swapTarget); swapTarget++; mNonExperiments++; } // Now sort the experiments std::vector< CExperiment * >::iterator startSort = mpExperiments->begin() + mNonExperiments; std::vector< CExperiment * >::iterator endSort = mpExperiments->end(); std::sort(startSort, endSort, &CExperiment::compare); return; }
bool CExperimentObjectMap::elevateChildren() { bool success = true; elements::iterator itColumn = beginIndex(); elements::iterator endColumn = endIndex(); if (itColumn != endColumn && dynamic_cast< CCopasiParameterGroup * >(*itColumn) == NULL) // We have an old data format. { CCopasiParameterGroup New(getObjectName()); for (; itColumn != endColumn; ++itColumn) { CCopasiParameterGroup * pGroup = New.assertGroup((*itColumn)->getObjectName()); pGroup->assertParameter("Object CN", CCopasiParameter::CN, (*itColumn)->getValue< CRegisteredObjectName >()); } clear(); operator=(New); } for (itColumn = beginIndex(); itColumn != endColumn; ++itColumn) if (((*itColumn) = elevate<CDataColumn, CCopasiParameterGroup>(*itColumn)) == NULL) success = false; return success; }
void StitchedMesh::buildMesh() { // Read the first mesh into the original mesh... then we'll stitch all of the others into that _original_mesh->read(_files[0]); _meshes.reserve(_files.size() - 1); // Read in all of the other meshes for (auto i = beginIndex(_files, 1); i < _files.size(); ++i) { _meshes.emplace_back(libmesh_make_unique<ReplicatedMesh>(_communicator)); auto & mesh = _meshes.back(); mesh->read(_files[i]); } // Stich 'em for (auto i = beginIndex(_meshes); i < _meshes.size(); i++) { auto & boundary_pair = _stitch_boundaries_pairs[i]; BoundaryID first = getBoundaryID(boundary_pair.first); BoundaryID second = getBoundaryID(boundary_pair.second); _original_mesh->stitch_meshes( *_meshes[i], first, second, TOLERANCE, _clear_stitched_boundary_ids); } }
SphericalAverage::SphericalAverage(const InputParameters & parameters) : ElementVectorPostprocessor(parameters), _nbins(getParam<unsigned int>("bin_number")), _radius(getParam<Real>("radius")), _deltaR(_radius / _nbins), _nvals(coupledComponents("variable")), _values(_nvals), _empty_bin_value(getParam<Real>("empty_bin_value")), _bin_center(declareVector("radius")), _counts(_nbins), _average(_nvals) { if (coupledComponents("variable") != 1) mooseError("SphericalAverage works on exactly one coupled variable"); // Note: We associate the local variable "i" with nbins and "j" with nvals throughout. // couple variables initialize vectors for (auto j = beginIndex(_average); j < _nvals; ++j) { _values[j] = &coupledValue("variable", j); _average[j] = &declareVector(getVar("variable", j)->name()); } // initialize the bin center value vector _bin_center.resize(_nbins); for (auto i = beginIndex(_counts); i < _nbins; ++i) _bin_center[i] = (i + 0.5) * _deltaR; }
void SamplerBase::finalize() { /** * We have several vectors that all need to be processed in the same way. * Rather than enumerate them all, let's just create a vector of pointers * and work on them that way. */ constexpr auto NUM_ID_VECTORS = 4; std::vector<VectorPostprocessorValue *> vec_ptrs; vec_ptrs.reserve(_values.size() + NUM_ID_VECTORS); // Initialize the pointer vector with the position and ID vectors vec_ptrs = {{&_x, &_y, &_z, &_id}}; // Now extend the vector by all the remaining values vector before processing vec_ptrs.insert(vec_ptrs.end(), _values.begin(), _values.end()); // Gather up each of the partial vectors for (auto vec_ptr : vec_ptrs) _comm.allgather(*vec_ptr, /* identical buffer lengths = */ false); // Now create an index vector by using an indirect sort std::vector<std::size_t> sorted_indices; Moose::indirectSort(vec_ptrs[_sort_by]->begin(), vec_ptrs[_sort_by]->end(), sorted_indices); /** * We now have one sorted vector. The remaining vectors need to be sorted according to that * vector. * We'll need a temporary vector to hold values as we map them according to the sorted indices. * After that, we'll swap the vector contents with the sorted vector to get the values * back into the original vector. */ // This vector is used as temp storage to sort each of the remaining vectors according to the // first auto vector_length = sorted_indices.size(); VectorPostprocessorValue tmp_vector(vector_length); #ifndef NDEBUG for (const auto vec_ptr : vec_ptrs) if (vec_ptr->size() != vector_length) mooseError("Vector length mismatch"); #endif // Sort each of the vectors using the same sorted indices for (auto i = beginIndex(vec_ptrs); i < vec_ptrs.size(); ++i) { for (auto j = beginIndex(sorted_indices); j < sorted_indices.size(); ++j) tmp_vector[j] = (*vec_ptrs[i])[sorted_indices[j]]; // Swap vector storage with sorted vector vec_ptrs[i]->swap(tmp_vector); } }
void SphericalAverage::finalize() { gatherSum(_counts); for (auto j = beginIndex(_average); j < _nvals; ++j) { gatherSum(*_average[j]); for (auto i = beginIndex(_counts); i < _nbins; ++i) (*_average[j])[i] = _counts[i] > 0 ? (*_average[j])[i] / static_cast<Real>(_counts[i]) : _empty_bin_value; } }
void SphericalAverage::threadJoin(const UserObject & y) { const SphericalAverage & uo = static_cast<const SphericalAverage &>(y); for (auto i = beginIndex(_counts); i < _nbins; ++i) { _counts[i] += uo._counts[i]; for (auto j = beginIndex(_average); j < _nvals; ++j) (*_average[j])[i] += (*uo._average[j])[i]; } }
void PatternedMesh::buildMesh() { // Local pointers to simplify algorithm std::vector<ReplicatedMesh *> row_meshes; row_meshes.reserve(_pattern.size()); // First row is the original mesh row_meshes.push_back(_original_mesh); // Copy the remaining raw pointers into the local vector for (const auto & row_mesh: _row_meshes) row_meshes.push_back(row_mesh.get()); BoundaryID left = getBoundaryID(getParam<BoundaryName>("left_boundary")); BoundaryID right = getBoundaryID(getParam<BoundaryName>("right_boundary")); BoundaryID top = getBoundaryID(getParam<BoundaryName>("top_boundary")); BoundaryID bottom = getBoundaryID(getParam<BoundaryName>("bottom_boundary")); // Build each row mesh for (auto i = beginIndex(_pattern); i < _pattern.size(); ++i) for (auto j = beginIndex(_pattern[i]); j < _pattern[i].size(); ++j) { Real deltax = j * _x_width, deltay = i * _y_width; // If this is the first cell of the row initialize the row mesh if (j == 0) { row_meshes[i]->read(_files[_pattern[i][j]]); MeshTools::Modification::translate(*row_meshes[i], deltax, -deltay, 0); continue; } ReplicatedMesh & cell_mesh = *_meshes[_pattern[i][j]]; // Move the mesh into the right spot. -i because we are starting at the top MeshTools::Modification::translate(cell_mesh, deltax, -deltay, 0); row_meshes[i]->stitch_meshes(dynamic_cast<ReplicatedMesh &>(cell_mesh), right, left, TOLERANCE, /*clear_stitched_boundary_ids=*/true); // Undo the translation MeshTools::Modification::translate(cell_mesh, -deltax, deltay, 0); } // Now stitch together the rows // We're going to stitch them all to row 0 (which is the real mesh) for (auto i = beginIndex(_pattern, 1); i < _pattern.size(); i++) row_meshes[0]->stitch_meshes(*row_meshes[i], bottom, top, TOLERANCE, /*clear_stitched_boundary_ids=*/true); }
void ParsedMaterialHelper::computeProperties() { Real a; for (_qp = 0; _qp < _qrule->n_points(); _qp++) { // fill the parameter vector, apply tolerances for (unsigned int i = 0; i < _nargs; ++i) { if (_tol[i] < 0.0) _func_params[i] = (*_args[i])[_qp]; else { a = (*_args[i])[_qp]; _func_params[i] = a < _tol[i] ? _tol[i] : (a > 1.0 - _tol[i] ? 1.0 - _tol[i] : a); } } // insert material property values auto nmat_props = _mat_prop_descriptors.size(); for (auto i = beginIndex(_mat_prop_descriptors); i < nmat_props; ++i) _func_params[i + _nargs] = _mat_prop_descriptors[i].value()[_qp]; // TODO: computeQpProperties() // set function value if (_prop_F) (*_prop_F)[_qp] = evaluate(_func_F); } }
StitchedMesh::StitchedMesh(const InputParameters & parameters) : MooseMesh(parameters), _files(getParam<std::vector<MeshFileName>>("files")), _clear_stitched_boundary_ids(getParam<bool>("clear_stitched_boundary_ids")), _stitch_boundaries(getParam<std::vector<BoundaryName>>("stitch_boundaries")) { if (_files.empty()) mooseError("Must specify at least one mesh file for StitchedMesh"); // The StitchedMesh class only works with ReplicatedMesh errorIfDistributedMesh("StitchedMesh"); // Get the original mesh _original_mesh = dynamic_cast<ReplicatedMesh *>(&getMesh()); if (!_original_mesh) mooseError("StitchedMesh does not support DistributedMesh"); if (_stitch_boundaries.size() % 2 != 0) mooseError("There must be an even amount of stitch_boundaries in ", name()); _stitch_boundaries_pairs.reserve(_stitch_boundaries.size() / 2); // Make pairs out of the boundary names for (auto i = beginIndex(_stitch_boundaries); i < _stitch_boundaries.size(); i += 2) _stitch_boundaries_pairs.emplace_back(_stitch_boundaries[i], _stitch_boundaries[i + 1]); }
void VolumeHistogram::threadJoin(const UserObject & y) { const VolumeHistogram & uo = static_cast<const VolumeHistogram &>(y); mooseAssert(uo._volume_tmp.size() == _volume_tmp.size(), "Inconsistent volume vector lengths across threads."); for (auto i = beginIndex(_volume_tmp); i < _volume_tmp.size(); ++i) _volume_tmp[i] += uo._volume_tmp[i]; }
void FeatureFloodCount::buildFeatureIdToLocalIndices(unsigned int max_id) { _feature_id_to_local_index.assign(max_id + 1, invalid_size_t); for (auto feature_index = beginIndex(_feature_sets); feature_index < _feature_sets.size(); ++feature_index) { mooseAssert(_feature_sets[feature_index]._id <= max_id, "Feature ID out of range"); _feature_id_to_local_index[_feature_sets[feature_index]._id] = feature_index; } }
Real CoupledBEKinetic::computeQpResidual() { Real assemble_conc = 0.0; for (auto i = beginIndex(_vals); i < _vals.size(); ++i) assemble_conc += _weight[i] * ((*_vals[i])[_qp] - (*_vals_old[i])[_qp]) / _dt; return _porosity[_qp] * _test[_i][_qp] * assemble_conc; }
void FeatureFloodCount::sortAndLabel() { mooseAssert(_is_master, "sortAndLabel can only be called on the master"); /** * Perform a sort to give a parallel unique sorting to the identified features. * We use the "min_entity_id" inside each feature to assign it's position in the * sorted vector. */ std::sort(_feature_sets.begin(), _feature_sets.end()); #ifndef NDEBUG /** * Sanity check. Now that we've sorted the flattened vector of features * we need to make sure that the counts vector still lines up appropriately * with each feature's _var_index. */ unsigned int feature_offset = 0; for (auto map_num = beginIndex(_feature_counts_per_map); map_num < _maps_size; ++map_num) { // Skip empty map checks if (_feature_counts_per_map[map_num] == 0) continue; // Check the begin and end of the current range auto range_front = feature_offset; auto range_back = feature_offset + _feature_counts_per_map[map_num] - 1; mooseAssert(range_front <= range_back && range_back < _feature_count, "Indexing error in feature sets"); if (!_single_map_mode && (_feature_sets[range_front]._var_index != map_num || _feature_sets[range_back]._var_index != map_num)) mooseError("Error in _feature_sets sorting, map index: " << map_num); feature_offset += _feature_counts_per_map[map_num]; } #endif // Label the features with an ID based on the sorting (processor number independent value) for (auto i = beginIndex(_feature_sets); i < _feature_sets.size(); ++i) _feature_sets[i]._id = i; }
void VolumeHistogram::finalize() { gatherSum(_volume_tmp); // copy into the MOOSE administered vector postprocessor vector _volume.resize(_nbins); mooseAssert(_volume_tmp.size() == _nbins, "Inconsistent volume vector lengths."); for (auto i = beginIndex(_volume_tmp); i < _volume_tmp.size(); ++i) _volume[i] = _volume_tmp[i]; }
void TaggingInterface::prepareMatrixTag(Assembly & assembly, unsigned int ivar, unsigned int jvar) { _ke_blocks.resize(_matrix_tags.size()); mooseAssert(_matrix_tags.size() >= 1, "we need at least one active tag"); auto mat_vector = _matrix_tags.begin(); for (auto i = beginIndex(_matrix_tags); i < _matrix_tags.size(); i++, ++mat_vector) _ke_blocks[i] = &assembly.jacobianBlock(ivar, jvar, *mat_vector); _local_ke.resize(_ke_blocks[0]->m(), _ke_blocks[0]->n()); _local_ke.zero(); }
void TaggingInterface::prepareVectorTagNeighbor(Assembly & assembly, unsigned int ivar) { _re_blocks.resize(_vector_tags.size()); mooseAssert(_vector_tags.size() >= 1, "we need at least one active tag"); auto vector_tag = _vector_tags.begin(); for (auto i = beginIndex(_vector_tags); i < _vector_tags.size(); i++, ++vector_tag) _re_blocks[i] = &assembly.residualBlockNeighbor(ivar, *vector_tag); _local_re.resize(_re_blocks[0]->size()); _local_re.zero(); }
Real FauxGrainTracker::getEntityValue(dof_id_type entity_id, FeatureFloodCount::FieldType field_type, std::size_t var_idx) const { if (var_idx == FeatureFloodCount::invalid_size_t) var_idx = 0; mooseAssert(var_idx < _n_vars, "Index out of range"); switch (field_type) { case FieldType::UNIQUE_REGION: case FieldType::VARIABLE_COLORING: { auto entity_it = _entity_id_to_var_num.find(entity_id); if (entity_it != _entity_id_to_var_num.end()) return entity_it->second; else return -1; break; } case FieldType::CENTROID: { if (_periodic_node_map.size()) mooseDoOnce(mooseWarning( "Centroids are not correct when using periodic boundaries, contact the MOOSE team")); // If this element contains the centroid of one of features, return it's index const auto * elem_ptr = _mesh.elemPtr(entity_id); for (auto var_num = beginIndex(_vars); var_num < _n_vars; ++var_num) { const auto centroid = _centroid.find(var_num); if (centroid != _centroid.end()) if (elem_ptr->contains_point(centroid->second)) return 1; } return 0; } // We don't want to error here because this should be a drop in replacement for the real grain // tracker. // Instead we'll just return zero and continue default: return 0; } return 0; }
void SamplerBase::addSample(const Point & p, const Real & id, const std::vector<Real> & values) { _x.push_back(p(0)); _y.push_back(p(1)); _z.push_back(p(2)); _id.push_back(id); mooseAssert(values.size() == _variable_names.size(), "Mismatch of variable names to vector size"); for (auto i = beginIndex(values); i < values.size(); ++i) _values[i]->emplace_back(values[i]); }
void MultiGrainRigidBodyMotion::getUserObjectJacobian(unsigned int jvar, dof_id_type dof_index) { _velocity_advection_jacobian = 0.0; for (auto i = beginIndex(_grain_ids); i < _grain_ids.size(); ++i) { auto grain_id = _grain_ids[i]; if (grain_id != FeatureFloodCount::invalid_id) { mooseAssert(grain_id < _grain_volumes.size(), "grain_id out of bounds"); const auto volume = _grain_volumes[grain_id]; const auto centroid = _grain_tracker.getGrainCentroid(grain_id); RealGradient force_jacobian; RealGradient torque_jacobian; if (jvar == _c_var) { force_jacobian(0) = _grain_force_c_jacobians[(6 * grain_id + 0) * _total_dofs + dof_index]; force_jacobian(1) = _grain_force_c_jacobians[(6 * grain_id + 1) * _total_dofs + dof_index]; force_jacobian(2) = _grain_force_c_jacobians[(6 * grain_id + 2) * _total_dofs + dof_index]; torque_jacobian(0) = _grain_force_c_jacobians[(6 * grain_id + 3) * _total_dofs + dof_index]; torque_jacobian(1) = _grain_force_c_jacobians[(6 * grain_id + 4) * _total_dofs + dof_index]; torque_jacobian(2) = _grain_force_c_jacobians[(6 * grain_id + 5) * _total_dofs + dof_index]; } for (unsigned int jvar_index = 0; jvar_index < _op_num; ++jvar_index) if (jvar == _vals_var[jvar_index]) { force_jacobian(0) = _grain_force_eta_jacobians[jvar_index][(6 * grain_id + 0) * _total_dofs + dof_index]; force_jacobian(1) = _grain_force_eta_jacobians[jvar_index][(6 * grain_id + 1) * _total_dofs + dof_index]; force_jacobian(2) = _grain_force_eta_jacobians[jvar_index][(6 * grain_id + 2) * _total_dofs + dof_index]; torque_jacobian(0) = _grain_force_eta_jacobians[jvar_index][(6 * grain_id + 3) * _total_dofs + dof_index]; torque_jacobian(1) = _grain_force_eta_jacobians[jvar_index][(6 * grain_id + 4) * _total_dofs + dof_index]; torque_jacobian(2) = _grain_force_eta_jacobians[jvar_index][(6 * grain_id + 5) * _total_dofs + dof_index]; } const auto force_jac = _mt / volume * force_jacobian; const auto torque_jac = _mr / volume * torque_jacobian.cross(_current_elem->centroid() - centroid); _velocity_advection_jacobian += (force_jac + torque_jac); } } }
FauxGrainTracker::FauxGrainTracker(const InputParameters & parameters) : FeatureFloodCount(parameters), GrainTrackerInterface(), _grain_count(0), _n_vars(_vars.size()), _tracking_step(getParam<int>("tracking_step")) { // initialize faux data with identity map _op_to_grains.resize(_n_vars); for (auto i = beginIndex(_op_to_grains); i < _op_to_grains.size(); ++i) _op_to_grains[i] = i; _empty_var_to_features.resize(_n_vars, FeatureFloodCount::invalid_id); }
void FeatureFloodCount::FeatureData::expandBBox(const FeatureData & rhs) { std::vector<bool> intersected_boxes(rhs._bboxes.size(), false); auto box_expanded = false; for (auto & bbox : _bboxes) for (auto j = beginIndex(rhs._bboxes); j < rhs._bboxes.size(); ++j) if (bbox.intersect(rhs._bboxes[j])) { updateBBoxExtremes(bbox, rhs._bboxes[j]); intersected_boxes[j] = true; box_expanded = true; } // Any bounding box in the rhs vector that doesn't intersect // needs to be appended to the lhs vector for (auto j = beginIndex(intersected_boxes); j < intersected_boxes.size(); ++j) if (!intersected_boxes[j]) _bboxes.push_back(rhs._bboxes[j]); // Error check if (!box_expanded) { std::ostringstream oss; oss << "LHS BBoxes:\n"; for (auto i = beginIndex(_bboxes); i < _bboxes.size(); ++i) oss << "Max: " << _bboxes[i].max() << " Min: " << _bboxes[i].min() << '\n'; oss << "RHS BBoxes:\n"; for (auto i = beginIndex(rhs._bboxes); i < rhs._bboxes.size(); ++i) oss << "Max: " << rhs._bboxes[i].max() << " Min: " << rhs._bboxes[i].min() << '\n'; mooseError("No Bounding Boxes Expanded - This is a catastrophic error!\n" << oss.str()); } }
void CExperimentObjectMap::fixBuild55() { CCopasiParameterGroup::index_iterator it = beginIndex(); CCopasiParameterGroup::index_iterator end = endIndex(); for (; it != end; ++it) { CDataColumn * pColumn = dynamic_cast< CDataColumn * >(*it); if (pColumn != NULL) { pColumn->fixBuild55(); } } }
void ChannelGradientVectorPostprocessor::execute() { if (_lv1_variable_values.size() != _lv2_variable_values.size()) mooseError("The two vector postprocessors that we're taking the difference of must be the same " "length."); _axis_values->resize(_lv1_axis_values.size()); _gradient_values->resize(_lv1_axis_values.size()); for (auto i = beginIndex(_lv1_axis_values); i < _lv1_axis_values.size(); ++i) { (*_axis_values)[i] = _lv1_axis_values[i]; (*_gradient_values)[i] = _lv1_variable_values[i] - _lv2_variable_values[i]; } }
size_t CExperimentObjectMap::getLastNotIgnoredColumn() const { elements::iterator itColumn = beginIndex(); elements::iterator endColumn = endIndex(); C_INT32 LastNotIgnored = -1; for (; itColumn != endColumn; ++itColumn) if (static_cast< CDataColumn * >(*itColumn)->getRole() != CExperiment::ignore) { C_INT32 index = strtol(static_cast< CDataColumn * >(*itColumn)->getObjectName().c_str(), NULL, 10); if (index > LastNotIgnored) LastNotIgnored = index; } return LastNotIgnored; }
bool CExperimentSet::elevateChildren() { index_iterator it = beginIndex(); index_iterator end = endIndex(); for (; it != end; ++it) { if (dynamic_cast< CCopasiParameterGroup * >(*it) == NULL) continue; if (!elevate<CExperiment, CCopasiParameterGroup>(*it)) return false; } mpExperiments = static_cast< std::vector< CExperiment * > * >(mpValue); sort(); return true; }
void FauxGrainTracker::finalize() { Moose::perf_log.push("finalize()", "FauxGrainTracker"); _communicator.set_union(_variables_used); _communicator.set_union(_entity_id_to_var_num); if (_is_elemental) for (auto var_num = beginIndex(_vars); var_num < _n_vars; ++var_num) { /** * Convert elements of the maps into simple values or vector of Real. * libMesh's _communicator.sum() does not work on std::maps */ unsigned int vol_count; std::vector<Real> grain_data(4); const auto count = _vol_count.find(var_num); if (count != _vol_count.end()) vol_count = count->second; const auto vol = _volume.find(var_num); if (vol != _volume.end()) grain_data[0] = vol->second; const auto centroid = _centroid.find(var_num); if (centroid != _centroid.end()) { grain_data[1] = centroid->second(0); grain_data[2] = centroid->second(1); grain_data[3] = centroid->second(2); } // combine centers & volumes from all MPI ranks gatherSum(vol_count); gatherSum(grain_data); _volume[var_num] = grain_data[0]; _centroid[var_num] = {grain_data[1], grain_data[2], grain_data[3]}; _centroid[var_num] /= vol_count; } Moose::perf_log.pop("finalize()", "FauxGrainTracker"); }