本文整理汇总了C++中StatisticsVector::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ StatisticsVector::push_back方法的具体用法?C++ StatisticsVector::push_back怎么用?C++ StatisticsVector::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StatisticsVector
的用法示例。
在下文中一共展示了StatisticsVector::push_back方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: median
Real ErrorVector::median()
{
const unsigned int n = this->size();
if (n == 0)
return 0.;
// Build a StatisticsVector<ErrorVectorReal> containing
// only our active entries and take its mean
StatisticsVector<ErrorVectorReal> sv;
sv.reserve (n);
for (unsigned int i=0; i<n; i++)
if(this->is_active_elem(i))
sv.push_back((*this)[i]);
return sv.median();
}
示例2: main
//.........这里部分代码省略.........
/**
* Maybe Triangulate
*/
// if (dim == 2 && triangulate)
if (triangulate)
{
if (verbose)
libMesh::out << "...Converting to all simplices...\n";
MeshTools::Modification::all_tri(mesh);
}
/**
* Compute Shape quality metrics
*/
if (do_quality)
{
StatisticsVector<Real> sv;
sv.reserve(mesh.n_elem());
libMesh::out << "Quality type is: " << Quality::name(quality_type) << std::endl;
// What are the quality bounds for this element?
std::pair<Real, Real> bounds = mesh.elem(0)->qual_bounds(quality_type);
libMesh::out << "Quality bounds for this element type are: (" << bounds.first
<< ", " << bounds.second << ") "
<< std::endl;
MeshBase::const_element_iterator it = mesh.active_elements_begin(),
end = mesh.active_elements_end();
for (; it != end; ++it)
{
Elem *e = *it;
sv.push_back(e->quality(quality_type));
}
const unsigned int n_bins = 10;
libMesh::out << "Avg. shape quality: " << sv.mean() << std::endl;
// Find element indices below the specified cutoff.
// These might be considered "bad" elements which need refinement.
std::vector<dof_id_type> bad_elts = sv.cut_below(0.8);
libMesh::out << "Found " << bad_elts.size()
<< " of " << mesh.n_elem()
<< " elements below the cutoff." << std::endl;
/*
for (unsigned int i=0; i<bad_elts.size(); i++)
libMesh::out << bad_elts[i] << " ";
libMesh::out << std::endl;
*/
// Compute the histogram for this distribution
std::vector<dof_id_type> histogram;
sv.histogram(histogram, n_bins);
/*
for (unsigned int i=0; i<n_bins; i++)
histogram[i] = histogram[i] / mesh.n_elem();
*/
const bool do_matlab = true;
if (do_matlab)
{
std::ofstream out ("histo.m");
示例3: main
int main (int argc, char ** argv)
{
LibMeshInit init(argc, argv);
unsigned int n_subdomains = 1;
unsigned int n_rsteps = 0;
double dist_fact = 0.;
bool verbose = false;
BoundaryMeshWriteMode write_bndry = BM_DISABLED;
bool convert_first_order = false;
unsigned int convert_second_order = 0;
bool triangulate = false;
bool do_quality = false;
ElemQuality quality_type = DIAGONAL;
#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
bool addinfelems = false;
InfElemBuilder::InfElemOriginValue origin_x(false, 0.);
InfElemBuilder::InfElemOriginValue origin_y(false, 0.);
InfElemBuilder::InfElemOriginValue origin_z(false, 0.);
bool x_sym=false;
bool y_sym=false;
bool z_sym=false;
#endif
std::vector<std::string> names;
std::vector<std::string> var_names;
std::vector<Number> soln;
// Check for minimum number of command line args
if (argc < 3)
usage(std::string(argv[0]));
// Create a GetPot object to parse the command line
GetPot command_line (argc, argv);
// Print usage and exit immediately if user asked for help.
if (command_line.search(2, "-h", "-?"))
usage(argv[0]);
// Input file name
if (command_line.search(1, "-i"))
{
std::string tmp;
tmp = command_line.next(tmp);
if (names.empty())
names.push_back(tmp);
else
libmesh_error_msg("ERROR: Input name must precede output name!");
}
// Output file name
if (command_line.search(1, "-o"))
{
std::string tmp;
tmp = command_line.next(tmp);
if (!names.empty())
names.push_back(tmp);
else
libmesh_error_msg("ERROR: Input name must precede output name!");
}
// Get the mesh distortion factor
if (command_line.search(1, "-D"))
dist_fact = command_line.next(dist_fact);
// Number of refinements
if (command_line.search(1, "-r"))
{
int tmp;
tmp = command_line.next(tmp);
n_rsteps = cast_int<unsigned int>(tmp);
}
// Number of subdomains for partitioning
if (command_line.search(1, "-p"))
{
int tmp;
tmp = command_line.next(tmp);
n_subdomains = cast_int<unsigned int>(tmp);
}
// Should we call all_tri()?
if (command_line.search(1, "-t"))
triangulate = true;
// Should we calculate element quality?
if (command_line.search(1, "-q"))
{
do_quality = true;
std::string tmp;
tmp = command_line.next(tmp);
if (tmp != "")
quality_type = Utility::string_to_enum<ElemQuality>(tmp);
}
// Should we be verbose?
if (command_line.search(1, "-v"))
verbose = true;
//.........这里部分代码省略.........