本文整理汇总了C++中NumericVector::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ NumericVector::clear方法的具体用法?C++ NumericVector::clear怎么用?C++ NumericVector::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NumericVector
的用法示例。
在下文中一共展示了NumericVector::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: estimate_error
void AdjointRefinementEstimator::estimate_error (const System& _system,
ErrorVector& error_per_cell,
const NumericVector<Number>* solution_vector,
bool /*estimate_parent_error*/)
{
// We have to break the rules here, because we can't refine a const System
System& system = const_cast<System&>(_system);
// An EquationSystems reference will be convenient.
EquationSystems& es = system.get_equation_systems();
// The current mesh
MeshBase& mesh = es.get_mesh();
// Resize the error_per_cell vector to be
// the number of elements, initialized to 0.
error_per_cell.clear();
error_per_cell.resize (mesh.max_elem_id(), 0.);
// We'll want to back up all coarse grid vectors
std::map<std::string, NumericVector<Number> *> coarse_vectors;
for (System::vectors_iterator vec = system.vectors_begin(); vec !=
system.vectors_end(); ++vec)
{
// The (string) name of this vector
const std::string& var_name = vec->first;
coarse_vectors[var_name] = vec->second->clone().release();
}
// Back up the coarse solution and coarse local solution
NumericVector<Number> * coarse_solution =
system.solution->clone().release();
NumericVector<Number> * coarse_local_solution =
system.current_local_solution->clone().release();
// And make copies of the projected solution
NumericVector<Number> * projected_solution;
// And we'll need to temporarily change solution projection settings
bool old_projection_setting;
old_projection_setting = system.project_solution_on_reinit();
// Make sure the solution is projected when we refine the mesh
system.project_solution_on_reinit() = true;
// And it'll be best to avoid any repartitioning
AutoPtr<Partitioner> old_partitioner = mesh.partitioner();
mesh.partitioner().reset(NULL);
// And we can't allow any renumbering
const bool old_renumbering_setting = mesh.allow_renumbering();
mesh.allow_renumbering(false);
// Use a non-standard solution vector if necessary
if (solution_vector && solution_vector != system.solution.get())
{
NumericVector<Number> *newsol =
const_cast<NumericVector<Number>*> (solution_vector);
newsol->swap(*system.solution);
system.update();
}
#ifndef NDEBUG
// n_coarse_elem is only used in an assertion later so
// avoid declaring it unless asserts are active.
const dof_id_type n_coarse_elem = mesh.n_elem();
#endif
// Uniformly refine the mesh
MeshRefinement mesh_refinement(mesh);
libmesh_assert (number_h_refinements > 0 || number_p_refinements > 0);
// FIXME: this may break if there is more than one System
// on this mesh but estimate_error was still called instead of
// estimate_errors
for (unsigned int i = 0; i != number_h_refinements; ++i)
{
mesh_refinement.uniformly_refine(1);
es.reinit();
}
for (unsigned int i = 0; i != number_p_refinements; ++i)
{
mesh_refinement.uniformly_p_refine(1);
es.reinit();
}
// Copy the projected coarse grid solutions, which will be
// overwritten by solve()
projected_solution = NumericVector<Number>::build(mesh.comm()).release();
projected_solution->init(system.solution->size(), true, SERIAL);
system.solution->localize(*projected_solution,
system.get_dof_map().get_send_list());
// Rebuild the rhs with the projected primal solution
(dynamic_cast<ImplicitSystem&>(system)).assembly(true, false);
NumericVector<Number> & projected_residual = (dynamic_cast<ExplicitSystem&>(system)).get_vector("RHS Vector");
projected_residual.close();
// Solve the adjoint problem on the refined FE space
//.........这里部分代码省略.........