本文整理汇总了C++中NumericVector::local_size方法的典型用法代码示例。如果您正苦于以下问题:C++ NumericVector::local_size方法的具体用法?C++ NumericVector::local_size怎么用?C++ NumericVector::local_size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NumericVector
的用法示例。
在下文中一共展示了NumericVector::local_size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: v
void
dataStore(std::ostream & stream, NumericVector<Real> & v, void * /*context*/)
{
v.close();
numeric_index_type size = v.local_size();
for (numeric_index_type i = v.first_local_index(); i < v.first_local_index() + size; i++)
{
Real r = v(i);
stream.write((char *) &r, sizeof(r));
}
}
示例2: sizeof
void
dataLoad(std::istream & stream, NumericVector<Real> & v, void * /*context*/)
{
numeric_index_type size = v.local_size();
for (numeric_index_type i = v.first_local_index(); i < v.first_local_index() + size; i++)
{
Real r = 0;
stream.read((char *) &r, sizeof(r));
v.set(i, r);
}
v.close();
}
示例3: TopResidualDebugOutputTopResidualData
void
TopResidualDebugOutput::printTopResiduals(const NumericVector<Number> & residual, unsigned int n)
{
// Need a reference to the libMesh mesh object
MeshBase & mesh = _problem_ptr->mesh().getMesh();
std::vector<TopResidualDebugOutputTopResidualData> vec;
vec.resize(residual.local_size());
unsigned int j = 0;
MeshBase::node_iterator it = mesh.local_nodes_begin();
const MeshBase::node_iterator end = mesh.local_nodes_end();
for (; it != end; ++it)
{
Node & node = *(*it);
dof_id_type nd = node.id();
for (unsigned int var = 0; var < node.n_vars(_sys.number()); ++var)
if (node.n_dofs(_sys.number(), var) > 0) // this check filters scalar variables (which are clearly not a dof on every node)
{
dof_id_type dof_idx = node.dof_number(_sys.number(), var, 0);
vec[j] = TopResidualDebugOutputTopResidualData(var, nd, residual(dof_idx));
j++;
}
}
// Loop over all scalar variables
std::vector<unsigned int> var_nums;
_sys.get_all_variable_numbers(var_nums);
const DofMap &dof_map(_sys.get_dof_map());
for (std::vector<unsigned int>::const_iterator it = var_nums.begin(); it != var_nums.end(); ++it)
{
if (_sys.variable_type(*it).family == SCALAR)
{
std::vector<dof_id_type> dof_indices;
dof_map.SCALAR_dof_indices(dof_indices, *it);
for (std::vector<dof_id_type>::const_iterator dof_it = dof_indices.begin(); dof_it != dof_indices.end(); ++dof_it)
if (*dof_it >= dof_map.first_dof() && *it < dof_map.end_dof())
{
vec[j] = TopResidualDebugOutputTopResidualData(*it, 0, residual(*dof_it), true);
j++;
}
}
}
// Sort vec by residuals
std::sort(vec.begin(), vec.end(), sortTopResidualData);
// Display the residuals
Moose::err << "[DBG][" << processor_id() << "] Max " << n << " residuals";
if (j < n)
{
n = j;
Moose::err << " (Only " << n << " available)";
}
Moose::err << std::endl;
for (unsigned int i = 0; i < n; ++i)
{
Moose::err << "[DBG][" << processor_id() << "] " << std::setprecision(15) << vec[i]._residual << " '"
<< _sys.variable_name(vec[i]._var).c_str() << "' ";
if (vec[i]._is_scalar)
Moose::err << "(SCALAR)\n";
else
Moose::err << "at node " << vec[i]._nd << '\n';
}
}