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; }
FeatureVolumeVectorPostprocessor::FeatureVolumeVectorPostprocessor( const InputParameters & parameters) : GeneralVectorPostprocessor(parameters), MooseVariableDependencyInterface(), BoundaryRestrictable(this, false), _single_feature_per_elem(getParam<bool>("single_feature_per_element")), _output_centroids(getParam<bool>("output_centroids")), _feature_counter(getUserObject<FeatureFloodCount>("flood_counter")), _var_num(declareVector("var_num")), _feature_volumes(declareVector("feature_volumes")), _intersects_bounds(declareVector("intersects_bounds")), _percolated(declareVector("percolated")), _vars(_feature_counter.getFECoupledVars()), _mesh(_subproblem.mesh()), _assembly(_subproblem.assembly(_tid)), _q_point(_assembly.qPoints()), _qrule(_assembly.qRule()), _JxW(_assembly.JxW()), _coord(_assembly.coordTransformation()), _qrule_face(_assembly.qRuleFace()), _JxW_face(_assembly.JxWFace()) { addMooseVariableDependency(_vars); _is_boundary_restricted = boundaryRestricted(); _coupled_sln.reserve(_vars.size()); for (auto & var : _feature_counter.getCoupledVars()) _coupled_sln.push_back(&var->sln()); }
Eigenvalues::Eigenvalues(const InputParameters & parameters) : GeneralVectorPostprocessor(parameters), _eigen_values_real(declareVector("eigen_values_real")), _eigen_values_imag(declareVector("eigen_values_imag")), _nl_eigen(dynamic_cast<NonlinearEigenSystem *>(&_fe_problem.getNonlinearSystemBase())) { if (!_nl_eigen) mooseError("Given system is not a NonlinearEigenSystem \n"); }
ChannelGradientVectorPostprocessor::ChannelGradientVectorPostprocessor( const InputParameters & parameters) : GeneralVectorPostprocessor(parameters), _lv1_name(getParam<VectorPostprocessorName>("lv1")), _lv2_name(getParam<VectorPostprocessorName>("lv2")), _axis(getParam<MooseEnum>("axis")), _lv1_variable_values(getVectorPostprocessorValue("lv1", getParam<std::string>("var1"))), _lv2_variable_values(getVectorPostprocessorValue("lv2", getParam<std::string>("var2"))), _lv1_axis_values(getVectorPostprocessorValue("lv1", _axis)), _axis_values(&declareVector(_axis)), _gradient_values(&declareVector("gradient")) { }
ElementsAlongLine::ElementsAlongLine(const InputParameters & parameters) : GeneralVectorPostprocessor(parameters), _start(getParam<Point>("start")), _end(getParam<Point>("end")), _elem_ids(declareVector("elem_ids")) { }
MaterialVectorPostprocessor::MaterialVectorPostprocessor(const InputParameters & parameters) : ElementVectorPostprocessor(parameters), _elem_filter(getParam<std::vector<unsigned int>>("elem_ids").begin(), getParam<std::vector<unsigned int>>("elem_ids").end()), _elem_ids(declareVector("elem_id")), _qp_ids(declareVector("qp_id")) { auto & mat = getMaterialByName(getParam<MaterialName>("material"), true); auto & prop_names = mat.getSuppliedItems(); if (mat.isBoundaryMaterial()) mooseError(name(), ": boundary materials (i.e. ", mat.name(), ") cannot be used"); for (auto & id : _elem_filter) { auto el = _mesh.getMesh().query_elem_ptr(id); // We'd better have found the requested element on *some* // processor. bool found_elem = (el != nullptr); this->comm().max(found_elem); // We might not have el on this processor in a distributed mesh, // but it should be somewhere and it ought to have a material // defined for its subdomain if (!found_elem || (el && !mat.hasBlocks(el->subdomain_id()))) mooseError(name(), ": material ", mat.name(), " is not defined on element ", id); } for (auto & prop : prop_names) { if (hasMaterialProperty<Real>(prop)) _prop_refs.push_back(&getMaterialProperty<Real>(prop)); else if (hasMaterialProperty<unsigned int>(prop)) _prop_refs.push_back(&getMaterialProperty<unsigned int>(prop)); else if (hasMaterialProperty<int>(prop)) _prop_refs.push_back(&getMaterialProperty<int>(prop)); else { mooseWarning("property " + prop + " is of unsupported type and skipped by MaterialVectorPostprocessor"); continue; } _prop_vecs.push_back(&declareVector(prop)); _prop_names.push_back(prop); } }
LeastSquaresFit::LeastSquaresFit(const InputParameters & parameters) : GeneralVectorPostprocessor(parameters), _vpp_name(getParam<VectorPostprocessorName>("vectorpostprocessor")), _order(parameters.get<unsigned int>("order")), _x_name(getParam<std::string>("x_name")), _y_name(getParam<std::string>("y_name")), _x_values(getVectorPostprocessorValue("vectorpostprocessor", _x_name)), _y_values(getVectorPostprocessorValue("vectorpostprocessor", _y_name)), _output_type(getParam<MooseEnum>("output")), _num_samples(0), _have_sample_x_min(isParamValid("sample_x_min")), _have_sample_x_max(isParamValid("sample_x_max")), _sample_x(NULL), _sample_y(NULL), _coeffs(NULL) { if (_output_type == "Samples") { if (isParamValid("num_samples")) _num_samples = getParam<unsigned int>("num_samples"); else mooseError("In LeastSquaresFit num_samples parameter must be provided with output=Samples"); if (_have_sample_x_min) _sample_x_min = getParam<Real>("sample_x_min"); if (_have_sample_x_max) _sample_x_max = getParam<Real>("sample_x_max"); _sample_x = &declareVector(_x_name); _sample_y = &declareVector(_y_name); } else { if (isParamValid("num_samples")) mooseWarning("In LeastSquaresFit num_samples parameter is unused with output=Coefficients"); _coeffs = &declareVector("coefficients"); } if (_output_type == "Samples") { _sample_x->resize(_num_samples); _sample_y->resize(_num_samples); } else _coeffs->resize(_order+1); }
void StochasticResults::init(Sampler & sampler) { _sampler = &sampler; const std::vector<std::string> & names = _sampler->getSampleNames(); _sample_vectors.resize(names.size()); for (MooseIndex(names) i = 0; i < names.size(); ++i) _sample_vectors[i] = &declareVector(names[i]); }
LeastSquaresFitHistory::LeastSquaresFitHistory(const InputParameters & parameters) : GeneralVectorPostprocessor(parameters), _vpp_name(getParam<VectorPostprocessorName>("vectorpostprocessor")), _order(parameters.get<unsigned int>("order")), _x_name(getParam<std::string>("x_name")), _y_name(getParam<std::string>("y_name")), _x_values(getVectorPostprocessorValue("vectorpostprocessor", _x_name)), _y_values(getVectorPostprocessorValue("vectorpostprocessor", _y_name)), _x_scale(parameters.get<Real>("x_scale")), _x_shift(parameters.get<Real>("x_shift")), _y_scale(parameters.get<Real>("y_scale")), _y_shift(parameters.get<Real>("y_shift")) { _coeffs.resize(_order + 1); for (unsigned int i = 0; i < _coeffs.size(); ++i) _coeffs[i] = &declareVector("coef_" + Moose::stringify(i)); _times = &declareVector("time"); }
VolumeHistogram::VolumeHistogram(const InputParameters & parameters) : ElementVectorPostprocessor(parameters), _nbins(getParam<unsigned int>("bin_number")), _min_value(getParam<Real>("min_value")), _max_value(getParam<Real>("max_value")), _deltaV((_max_value - _min_value) / _nbins), _value(coupledValue("variable")), _bin_center(declareVector(getVar("variable", 0)->name())), _volume(declareVector("n")) { if (coupledComponents("variable") != 1) mooseError("VolumeHistogram works on exactly one coupled variable"); // initialize the bin center value vector _bin_center.resize(_nbins); for (unsigned i = 0; i < _nbins; ++i) _bin_center[i] = (i + 0.5) * _deltaV + _min_value; }
GrainForcesPostprocessor::GrainForcesPostprocessor(const InputParameters & parameters) : GeneralVectorPostprocessor(parameters), _grain_force_torque_vector(declareVector("grain_force_torque_vector")), _grain_force_torque(getUserObject<GrainForceAndTorqueInterface>("grain_force")), _grain_forces(_grain_force_torque.getForceValues()), _grain_torques(_grain_force_torque.getTorqueValues()), _grain_num(0) { }
GrainCentersPostprocessor::GrainCentersPostprocessor(const InputParameters & parameters) : GeneralVectorPostprocessor(parameters), _grain_volume_center_vector(declareVector("grain_volume_center_vector")), _grain_data(getUserObject<ComputeGrainCenterUserObject>("grain_data")), _grain_volumes(_grain_data.getGrainVolumes()), _grain_centers(_grain_data.getGrainCenters()), _total_grains(_grain_volumes.size()) { _grain_volume_center_vector.resize(_total_grains * 4); }
EulerAngleUpdaterCheck::EulerAngleUpdaterCheck(const InputParameters & params) : GeneralVectorPostprocessor(params), _diff(declareVector("vec_diff")), _grain_tracker(getUserObject<GrainTrackerInterface>("grain_tracker_object")), _euler(getUserObject<EulerAngleUpdater>("euler_angle_updater")), _grain_torque(getUserObject<GrainForceAndTorqueInterface>("grain_torques_object")), _grain_volumes(getVectorPostprocessorValue("grain_volumes", "feature_volumes")), _mr(getParam<Real>("rotation_constant")) { }
VectorMemoryUsage::VectorMemoryUsage(const InputParameters & parameters) : GeneralVectorPostprocessor(parameters), MemoryUsageReporter(this), _mem_units(getParam<MooseEnum>("mem_units").getEnum<MemoryUtils::MemUnits>()), _col_hardware_id(declareVector("hardware_id")), _col_total_ram(declareVector("total_ram")), _col_physical_mem(declareVector("physical_mem")), _col_virtual_mem(declareVector("virtual_mem")), _col_page_faults(declareVector("page_faults")), _col_node_utilization(declareVector("node_utilization")), _report_peak_value(getParam<bool>("report_peak_value")), _peak_physical_mem(0.0), _peak_virtual_mem(0.0) { _col_hardware_id.resize(_nrank); _col_total_ram.resize(_nrank); _col_physical_mem.resize(_nrank); _col_virtual_mem.resize(_nrank); _col_page_faults.resize(_nrank); _col_node_utilization.resize(_nrank); if (_my_rank == 0) { std::copy(_hardware_id.begin(), _hardware_id.end(), _col_hardware_id.begin()); for (std::size_t i = 0; i < _nrank; ++i) _col_total_ram[i] = MemoryUtils::convertBytes(_hardware_memory_total[_hardware_id[i]], _mem_units); } }
IntersectionPointsAlongLine::IntersectionPointsAlongLine(const InputParameters & parameters) : GeneralVectorPostprocessor(parameters), _start(getParam<Point>("start")), _end(getParam<Point>("end")), _x_intersections(declareVector("x")) #if LIBMESH_DIM > 1 , _y_intersections(declareVector("y")) #if LIBMESH_DIM > 2 , _z_intersections(declareVector("z")) #endif #endif { _intersections.push_back(&_x_intersections); #if LIBMESH_DIM > 1 _intersections.push_back(&_y_intersections); #if LIBMESH_DIM > 2 _intersections.push_back(&_z_intersections); #endif #endif }
// DEPRECATED CONSTRUCTOR VectorOfPostprocessors::VectorOfPostprocessors(const std::string & deprecated_name, InputParameters parameters) : GeneralVectorPostprocessor(deprecated_name, parameters), _pp_vec(declareVector(MooseUtils::shortName(parameters.get<std::string>("name")))) { std::vector<PostprocessorName> pps_names(getParam<std::vector<PostprocessorName> >("postprocessors")); _pp_vec.resize(pps_names.size()); for (unsigned int i=0; i<pps_names.size(); ++i) { if (!hasPostprocessorByName(pps_names[i])) mooseError("In VectorOfPostprocessors, postprocessor with name: "<<pps_names[i]<<" does not exist"); _postprocessor_values.push_back(&getPostprocessorValueByName(pps_names[i])); } }
VectorOfPostprocessors::VectorOfPostprocessors(const InputParameters & parameters) : GeneralVectorPostprocessor(parameters), _pp_vec(declareVector(MooseUtils::shortName(parameters.get<std::string>("_object_name")))) { std::vector<PostprocessorName> pps_names( getParam<std::vector<PostprocessorName>>("postprocessors")); _pp_vec.resize(pps_names.size()); for (const auto & pps_name : pps_names) { if (!hasPostprocessorByName(pps_name)) mooseError( "In VectorOfPostprocessors, postprocessor with name: ", pps_name, " does not exist"); _postprocessor_values.push_back(&getPostprocessorValueByName(pps_name)); } }
void LateDeclarationVectorPostprocessor::initialize() { if (_t_step == 1) _value = &declareVector("value"); }
ConstantVectorPostprocessor::ConstantVectorPostprocessor(const InputParameters & parameters) : GeneralVectorPostprocessor(parameters), _value(declareVector("value")) { _value = getParam<VectorPostprocessorValue>("value"); }
void FeatureVolumeVectorPostprocessor::execute() { const auto num_features = _feature_counter.getTotalFeatureCount(); // Reset the variable index and intersect bounds vectors _var_num.assign(num_features, -1); // Invalid _intersects_bounds.assign(num_features, -1); // Invalid _percolated.assign(num_features, -1); // Invalid for (MooseIndex(num_features) feature_num = 0; feature_num < num_features; ++feature_num) { auto var_num = _feature_counter.getFeatureVar(feature_num); if (var_num != FeatureFloodCount::invalid_id) _var_num[feature_num] = var_num; _intersects_bounds[feature_num] = static_cast<unsigned int>(_feature_counter.doesFeatureIntersectBoundary(feature_num)); _percolated[feature_num] = static_cast<unsigned int>(_feature_counter.isFeaturePercolated(feature_num)); } if (_output_centroids) { VectorPostprocessorValue & center_x = declareVector("centroid_x"); center_x.resize(num_features); VectorPostprocessorValue & center_y = declareVector("centroid_y"); center_y.resize(num_features); VectorPostprocessorValue & center_z = declareVector("centroid_z"); center_z.resize(num_features); for (MooseIndex(_var_num) feature_num = 0; feature_num < num_features; ++feature_num) { auto p = _feature_counter.featureCentroid(feature_num); center_x[feature_num] = p(0); center_y[feature_num] = p(1); center_z[feature_num] = p(2); } } // Reset the volume vector _feature_volumes.assign(num_features, 0); // Calculate coverage of a boundary if one has been supplied in the input file if (_is_boundary_restricted) { const std::set<BoundaryID> supplied_bnd_ids = BoundaryRestrictable::boundaryIDs(); for (auto elem_it = _mesh.bndElemsBegin(), elem_end = _mesh.bndElemsEnd(); elem_it != elem_end; ++elem_it) // loop over only boundaries supplied by user in boundary param for (auto & supplied_bnd_id : supplied_bnd_ids) if (((*elem_it)->_bnd_id) == supplied_bnd_id) { const auto & elem = (*elem_it)->_elem; auto rank = processor_id(); if (elem->processor_id() == rank) { _fe_problem.setCurrentSubdomainID(elem, 0); _fe_problem.prepare(elem, 0); _fe_problem.reinitElem(elem, 0); _fe_problem.reinitElemFace(elem, (*elem_it)->_side, (*elem_it)->_bnd_id, 0); const auto & var_to_features = _feature_counter.getVarToFeatureVector(elem->id()); accumulateBoundaryFaces(elem, var_to_features, num_features, (*elem_it)->_side); } } } else // If no boundary is supplied, calculate volumes of features as normal for (const auto & elem : _mesh.getMesh().active_local_element_ptr_range()) { _fe_problem.setCurrentSubdomainID(elem, 0); _fe_problem.prepare(elem, 0); _fe_problem.reinitElem(elem, 0); /** * Here we retrieve the var to features vector on the current element. * We'll use that information to figure out which variables are non-zero * (from a threshold perspective) then we can sum those values into * appropriate grain index locations. */ const auto & var_to_features = _feature_counter.getVarToFeatureVector(elem->id()); accumulateVolumes(elem, var_to_features, num_features); } }
ConstantVectorPostprocessor::ConstantVectorPostprocessor(const std::string & name, InputParameters parameters) : GeneralVectorPostprocessor(name, parameters), _value(declareVector("value")) { _value = getParam<VectorPostprocessorValue>("value"); }