本文整理汇总了C++中MeshBase::local_nodes_end方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshBase::local_nodes_end方法的具体用法?C++ MeshBase::local_nodes_end怎么用?C++ MeshBase::local_nodes_end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshBase
的用法示例。
在下文中一共展示了MeshBase::local_nodes_end方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mooseAssert
void
MoosePreconditioner::copyVarValues(MeshBase & mesh,
const unsigned int from_system,
const unsigned int from_var,
const NumericVector<Number> & from_vector,
const unsigned int to_system,
const unsigned int to_var,
NumericVector<Number> & to_vector)
{
{
MeshBase::node_iterator it = mesh.local_nodes_begin();
MeshBase::node_iterator it_end = mesh.local_nodes_end();
for (; it != it_end; ++it)
{
Node * node = *it;
unsigned int n_comp = node->n_comp(from_system, from_var);
mooseAssert(node->n_comp(from_system, from_var) == node->n_comp(to_system, to_var),
"Number of components does not match in each system");
for (unsigned int i = 0; i < n_comp; i++)
{
dof_id_type from_dof = node->dof_number(from_system, from_var, i);
dof_id_type to_dof = node->dof_number(to_system, to_var, i);
to_vector.set(to_dof, from_vector(from_dof));
}
}
}
{
MeshBase::element_iterator it = mesh.local_elements_begin();
MeshBase::element_iterator it_end = mesh.local_elements_end();
for (; it != it_end; ++it)
{
Elem * elem = *it;
unsigned int n_comp = elem->n_comp(from_system, from_var);
mooseAssert(elem->n_comp(from_system, from_var) == elem->n_comp(to_system, to_var),
"Number of components does not match in each system");
for (unsigned int i = 0; i < n_comp; i++)
{
dof_id_type from_dof = elem->dof_number(from_system, from_var, i);
dof_id_type to_dof = elem->dof_number(to_system, to_var, i);
to_vector.set(to_dof, from_vector(from_dof));
}
}
}
}
示例2: name
void
MultiAppUserObjectTransfer::execute()
{
_console << "Beginning MultiAppUserObjectTransfer " << name() << std::endl;
switch (_direction)
{
case TO_MULTIAPP:
{
for (unsigned int i=0; i<_multi_app->numGlobalApps(); i++)
{
if (_multi_app->hasLocalApp(i))
{
MPI_Comm swapped = Moose::swapLibMeshComm(_multi_app->comm());
// Loop over the master nodes and set the value of the variable
System * to_sys = find_sys(_multi_app->appProblem(i).es(), _to_var_name);
unsigned int sys_num = to_sys->number();
unsigned int var_num = to_sys->variable_number(_to_var_name);
NumericVector<Real> & solution = _multi_app->appTransferVector(i, _to_var_name);
MeshBase * mesh = NULL;
if (_displaced_target_mesh && _multi_app->appProblem(i).getDisplacedProblem())
{
mesh = &_multi_app->appProblem(i).getDisplacedProblem()->mesh().getMesh();
}
else
mesh = &_multi_app->appProblem(i).mesh().getMesh();
bool is_nodal = to_sys->variable_type(var_num).family == LAGRANGE;
const UserObject & user_object = _multi_app->problem().getUserObjectBase(_user_object_name);
if (is_nodal)
{
MeshBase::const_node_iterator node_it = mesh->local_nodes_begin();
MeshBase::const_node_iterator node_end = mesh->local_nodes_end();
for (; node_it != node_end; ++node_it)
{
Node * node = *node_it;
if (node->n_dofs(sys_num, var_num) > 0) // If this variable has dofs at this node
{
// The zero only works for LAGRANGE!
dof_id_type dof = node->dof_number(sys_num, var_num, 0);
// Swap back
Moose::swapLibMeshComm(swapped);
Real from_value = user_object.spatialValue(*node+_multi_app->position(i));
// Swap again
swapped = Moose::swapLibMeshComm(_multi_app->comm());
solution.set(dof, from_value);
}
}
}
else // Elemental
{
MeshBase::const_element_iterator elem_it = mesh->local_elements_begin();
MeshBase::const_element_iterator elem_end = mesh->local_elements_end();
for (; elem_it != elem_end; ++elem_it)
{
Elem * elem = *elem_it;
Point centroid = elem->centroid();
if (elem->n_dofs(sys_num, var_num) > 0) // If this variable has dofs at this elem
{
// The zero only works for LAGRANGE!
dof_id_type dof = elem->dof_number(sys_num, var_num, 0);
// Swap back
Moose::swapLibMeshComm(swapped);
Real from_value = user_object.spatialValue(centroid+_multi_app->position(i));
// Swap again
swapped = Moose::swapLibMeshComm(_multi_app->comm());
solution.set(dof, from_value);
}
}
}
solution.close();
to_sys->update();
// Swap back
Moose::swapLibMeshComm(swapped);
}
}
break;
}
case FROM_MULTIAPP:
{
FEProblem & to_problem = _multi_app->problem();
//.........这里部分代码省略.........
示例3: switch
void
MultiAppInterpolationTransfer::execute()
{
_console << "Beginning InterpolationTransfer " << _name << std::endl;
switch (_direction)
{
case TO_MULTIAPP:
{
FEProblem & from_problem = *_multi_app->problem();
MooseVariable & from_var = from_problem.getVariable(0, _from_var_name);
MeshBase * from_mesh = NULL;
if (_displaced_source_mesh && from_problem.getDisplacedProblem())
from_mesh = &from_problem.getDisplacedProblem()->mesh().getMesh();
else
from_mesh = &from_problem.mesh().getMesh();
SystemBase & from_system_base = from_var.sys();
System & from_sys = from_system_base.system();
unsigned int from_sys_num = from_sys.number();
unsigned int from_var_num = from_sys.variable_number(from_var.name());
bool from_is_nodal = from_sys.variable_type(from_var_num).family == LAGRANGE;
// EquationSystems & from_es = from_sys.get_equation_systems();
NumericVector<Number> & from_solution = *from_sys.solution;
InverseDistanceInterpolation<LIBMESH_DIM> * idi;
switch (_interp_type)
{
case 0:
idi = new InverseDistanceInterpolation<LIBMESH_DIM>(from_sys.comm(), _num_points, _power);
break;
case 1:
idi = new RadialBasisInterpolation<LIBMESH_DIM>(from_sys.comm(), _radius);
break;
default:
mooseError("Unknown interpolation type!");
}
std::vector<Point> &src_pts (idi->get_source_points());
std::vector<Number> &src_vals (idi->get_source_vals());
std::vector<std::string> field_vars;
field_vars.push_back(_to_var_name);
idi->set_field_variables(field_vars);
std::vector<std::string> vars;
vars.push_back(_to_var_name);
if (from_is_nodal)
{
MeshBase::const_node_iterator from_nodes_it = from_mesh->local_nodes_begin();
MeshBase::const_node_iterator from_nodes_end = from_mesh->local_nodes_end();
for (; from_nodes_it != from_nodes_end; ++from_nodes_it)
{
Node * from_node = *from_nodes_it;
// Assuming LAGRANGE!
dof_id_type from_dof = from_node->dof_number(from_sys_num, from_var_num, 0);
src_pts.push_back(*from_node);
src_vals.push_back(from_solution(from_dof));
}
}
else
{
MeshBase::const_element_iterator from_elements_it = from_mesh->local_elements_begin();
MeshBase::const_element_iterator from_elements_end = from_mesh->local_elements_end();
for (; from_elements_it != from_elements_end; ++from_elements_it)
{
Elem * from_elem = *from_elements_it;
// Assuming CONSTANT MONOMIAL
dof_id_type from_dof = from_elem->dof_number(from_sys_num, from_var_num, 0);
src_pts.push_back(from_elem->centroid());
src_vals.push_back(from_solution(from_dof));
}
}
// We have only set local values - prepare for use by gathering remote gata
idi->prepare_for_use();
for (unsigned int i=0; i<_multi_app->numGlobalApps(); i++)
{
if (_multi_app->hasLocalApp(i))
{
MPI_Comm swapped = Moose::swapLibMeshComm(_multi_app->comm());
// Loop over the master nodes and set the value of the variable
System * to_sys = find_sys(_multi_app->appProblem(i)->es(), _to_var_name);
//.........这里部分代码省略.........
示例4: name
void
MultiAppCopyTransfer::execute()
{
_console << "Beginning CopyTransfer " << name() << std::endl;
switch (_direction)
{
case TO_MULTIAPP:
{
FEProblem & from_problem = _multi_app->problem();
MooseVariable & from_var = from_problem.getVariable(0, _from_var_name);
MeshBase * from_mesh = NULL;
from_mesh = &from_problem.mesh().getMesh();
SystemBase & from_system_base = from_var.sys();
System & from_sys = from_system_base.system();
unsigned int from_sys_num = from_sys.number();
// Only works with a serialized mesh to transfer from!
mooseAssert(from_sys.get_mesh().is_serial(), "MultiAppCopyTransfer only works with ReplicatedMesh!");
unsigned int from_var_num = from_sys.variable_number(from_var.name());
//Create a serialized version of the solution vector
// NumericVector<Number> * serialized_solution = NumericVector<Number>::build(from_sys.comm()).release();
// serialized_solution->init(from_sys.n_dofs(), false, SERIAL);
// Need to pull down a full copy of this vector on every processor so we can get values in parallel
// from_sys.solution->localize(*serialized_solution);
for (unsigned int i=0; i<_multi_app->numGlobalApps(); i++)
{
if (_multi_app->hasLocalApp(i))
{
MPI_Comm swapped = Moose::swapLibMeshComm(_multi_app->comm());
// Loop over the master nodes and set the value of the variable
System * to_sys = find_sys(_multi_app->appProblem(i).es(), _to_var_name);
unsigned int sys_num = to_sys->number();
unsigned int var_num = to_sys->variable_number(_to_var_name);
NumericVector<Real> & solution = _multi_app->appTransferVector(i, _to_var_name);
MeshBase * mesh = NULL;
mesh = &_multi_app->appProblem(i).mesh().getMesh();
bool is_nodal = to_sys->variable_type(var_num).family == LAGRANGE;
if (is_nodal)
{
MeshBase::const_node_iterator node_it = mesh->local_nodes_begin();
MeshBase::const_node_iterator node_end = mesh->local_nodes_end();
for (; node_it != node_end; ++node_it)
{
Node * node = *node_it;
unsigned int node_id = node->id();
if (node->n_dofs(sys_num, var_num) > 0) // If this variable has dofs at this node
{
// The zero only works for LAGRANGE!
dof_id_type dof = node->dof_number(sys_num, var_num, 0);
// Swap back
Moose::swapLibMeshComm(swapped);
Node * from_node = from_mesh->node_ptr(node_id);
// Assuming LAGRANGE!
dof_id_type from_dof = from_node->dof_number(from_sys_num, from_var_num, 0);
//Real from_value = (*serialized_solution)(from_dof);
Real from_value = (*from_sys.solution)(from_dof);
// Swap again
swapped = Moose::swapLibMeshComm(_multi_app->comm());
solution.set(dof, from_value);
}
}
}
else // Elemental
{
mooseError("MultiAppCopyTransfer can only be used on nodal variables");
}
solution.close();
to_sys->update();
// Swap back
Moose::swapLibMeshComm(swapped);
}
}
// delete serialized_solution;
//.........这里部分代码省略.........
示例5: switch
void
MultiAppNearestNodeTransfer::execute()
{
Moose::out << "Beginning NearestNodeTransfer " << _name << std::endl;
switch(_direction)
{
case TO_MULTIAPP:
{
FEProblem & from_problem = *_multi_app->problem();
MooseVariable & from_var = from_problem.getVariable(0, _from_var_name);
MeshBase * from_mesh = NULL;
if (_displaced_source_mesh && from_problem.getDisplacedProblem())
{
mooseError("Cannot use a NearestNode transfer from a displaced mesh to a MultiApp!");
from_mesh = &from_problem.getDisplacedProblem()->mesh().getMesh();
}
else
from_mesh = &from_problem.mesh().getMesh();
SystemBase & from_system_base = from_var.sys();
System & from_sys = from_system_base.system();
unsigned int from_sys_num = from_sys.number();
// Only works with a serialized mesh to transfer from!
mooseAssert(from_sys.get_mesh().is_serial(), "MultiAppNearestNodeTransfer only works with SerialMesh!");
unsigned int from_var_num = from_sys.variable_number(from_var.name());
// EquationSystems & from_es = from_sys.get_equation_systems();
//Create a serialized version of the solution vector
NumericVector<Number> * serialized_solution = NumericVector<Number>::build().release();
serialized_solution->init(from_sys.n_dofs(), false, SERIAL);
// Need to pull down a full copy of this vector on every processor so we can get values in parallel
from_sys.solution->localize(*serialized_solution);
for(unsigned int i=0; i<_multi_app->numGlobalApps(); i++)
{
if (_multi_app->hasLocalApp(i))
{
MPI_Comm swapped = Moose::swapLibMeshComm(_multi_app->comm());
// Loop over the master nodes and set the value of the variable
System * to_sys = find_sys(_multi_app->appProblem(i)->es(), _to_var_name);
if (!to_sys)
mooseError("Cannot find variable "<<_to_var_name<<" for "<<_name<<" Transfer");
unsigned int sys_num = to_sys->number();
unsigned int var_num = to_sys->variable_number(_to_var_name);
NumericVector<Real> & solution = _multi_app->appTransferVector(i, _to_var_name);
MeshBase * mesh = NULL;
if (_displaced_target_mesh && _multi_app->appProblem(i)->getDisplacedProblem())
mesh = &_multi_app->appProblem(i)->getDisplacedProblem()->mesh().getMesh();
else
mesh = &_multi_app->appProblem(i)->mesh().getMesh();
bool is_nodal = to_sys->variable_type(var_num).family == LAGRANGE;
if (is_nodal)
{
MeshBase::const_node_iterator node_it = mesh->local_nodes_begin();
MeshBase::const_node_iterator node_end = mesh->local_nodes_end();
for(; node_it != node_end; ++node_it)
{
Node * node = *node_it;
Point actual_position = *node+_multi_app->position(i);
if (node->n_dofs(sys_num, var_num) > 0) // If this variable has dofs at this node
{
// The zero only works for LAGRANGE!
dof_id_type dof = node->dof_number(sys_num, var_num, 0);
// Swap back
Moose::swapLibMeshComm(swapped);
Real distance = 0; // Just to satisfy the last argument
MeshBase::const_node_iterator from_nodes_begin = from_mesh->nodes_begin();
MeshBase::const_node_iterator from_nodes_end = from_mesh->nodes_end();
Node * nearest_node = NULL;
if (_fixed_meshes)
{
if (_node_map.find(node->id()) == _node_map.end()) // Haven't cached it yet
{
nearest_node = getNearestNode(actual_position, distance, from_nodes_begin, from_nodes_end);
_node_map[node->id()] = nearest_node;
_distance_map[node->id()] = distance;
//.........这里部分代码省略.........