本文整理汇总了C++中GenericMatrix::ident方法的典型用法代码示例。如果您正苦于以下问题:C++ GenericMatrix::ident方法的具体用法?C++ GenericMatrix::ident怎么用?C++ GenericMatrix::ident使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GenericMatrix
的用法示例。
在下文中一共展示了GenericMatrix::ident方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apply
//-----------------------------------------------------------------------------
void NewDirichletBC::apply(GenericMatrix& A, GenericVector& b,
const GenericVector* x, const DofMap& dof_map, const ufc::form& form)
{
bool reassemble = dolfin_get("PDE reassemble matrix");
std::cout << "newdirichlet: " << reassemble << std::endl;
// FIXME: How do we reuse the dof map for u?
if (method == topological)
message("Applying Dirichlet boundary conditions to linear system.");
/*
else if (method == geometrical)
message("Applying Dirichlet boundary conditions to linear system (geometrical approach).");
else
message("Applying Dirichlet boundary conditions to linear system (pointwise approach).");
*/
// Make sure we have the facet - cell connectivity
const uint D = _mesh.topology().dim();
if (method == topological)
_mesh.init(D - 1, D);
// Create local data for application of boundary conditions
BoundaryCondition::LocalData data(form, _mesh, dof_map, sub_system);
// A map to hold the mapping from boundary dofs to boundary values
std::map<uint, real> boundary_values;
if (method == pointwise)
{
Progress p("Applying Dirichlet boundary conditions", _mesh.size(D));
for (CellIterator cell(_mesh); !cell.end(); ++cell)
{
computeBCPointwise(boundary_values, *cell, data);
p++;
}
}
else
{
// Iterate over the facets of the mesh
Progress p("Applying Dirichlet boundary conditions", _mesh.size(D - 1));
for (FacetIterator facet(_mesh); !facet.end(); ++facet)
{
// Skip facets not inside the sub domain
if ((*sub_domains)(*facet) != sub_domain)
{
p++;
continue;
}
// Chose strategy
if (method == topological)
computeBCTopological(boundary_values, *facet, data);
else
computeBCGeometrical(boundary_values, *facet, data);
// Update process
p++;
}
}
// Copy boundary value data to arrays
uint* dofs = new uint[boundary_values.size()];
real* values = new real[boundary_values.size()];
std::map<uint, real>::const_iterator boundary_value;
uint i = 0;
for (boundary_value = boundary_values.begin(); boundary_value != boundary_values.end(); ++boundary_value)
{
dofs[i] = boundary_value->first;
values[i++] = boundary_value->second;
}
// Modify boundary values for nonlinear problems
if (x)
{
real* x_values = new real[boundary_values.size()];
x->get(x_values, boundary_values.size(), dofs);
for (uint i = 0; i < boundary_values.size(); i++)
values[i] -= x_values[i];
delete[] x_values;
}
// Modify RHS vector (b[i] = value)
b.set(values, boundary_values.size(), dofs);
if(reassemble)
{
// Modify linear system (A_ii = 1)
A.ident(boundary_values.size(), dofs);
}
// Clear temporary arrays
delete [] dofs;
delete [] values;
// Finalise changes to b
b.apply();
}