Commit 241d9230 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#1405 A modification GetIndex() -> GetPositionInCoordsList() was not right.

parent 5a0f7cde
Pipeline #73945 passed with stages
in 11 minutes and 46 seconds
......@@ -16,126 +16,108 @@
# define MOREFEM_x_PARAMETER_INSTANCES_x_FIBER_x_INTERNAL_x_FILL_GLOBAL_VECTOR_HXX_
namespace MoReFEM
namespace MoReFEM::Internal::FiberNS
{
namespace Internal
template<ParameterNS::Type TypeT>
void FillGlobalVector(const typename Traits<TypeT>::value_list_per_coord_index_type& value_list_per_coord_index,
const NodeBearer::vector_shared_ptr& node_bearer_list,
const Unknown& unknown,
const NumberingSubset& numbering_subset,
GlobalVector& vector)
{
# ifndef NDEBUG
if (TypeT == ParameterNS::Type::scalar)
assert(unknown.GetNature() == UnknownNS::Nature::scalar);
if (TypeT == ParameterNS::Type::vector)
assert(unknown.GetNature() == UnknownNS::Nature::vectorial);
# endif // NDEBUG
namespace FiberNS
{
::MoReFEM::Wrappers::Petsc
::AccessVectorContent<Utilities::Access::read_and_write> vector_content(vector,
__FILE__, __LINE__);
# ifndef NDEBUG
unsigned int vector_proc_size = static_cast<unsigned int>(vector.GetProcessorWiseSize(__FILE__, __LINE__));
# endif // NDEBUG
template<ParameterNS::Type TypeT>
void FillGlobalVector(const typename Traits<TypeT>::value_list_per_coord_index_type& value_list_per_coord_index,
const NodeBearer::vector_shared_ptr& node_bearer_list,
const Unknown& unknown,
const NumberingSubset& numbering_subset,
GlobalVector& vector)
{
# ifndef NDEBUG
if (TypeT == ParameterNS::Type::scalar)
assert(unknown.GetNature() == UnknownNS::Nature::scalar);
if (TypeT == ParameterNS::Type::vector)
assert(unknown.GetNature() == UnknownNS::Nature::vectorial);
# endif // NDEBUG
{
::MoReFEM::Wrappers::Petsc
::AccessVectorContent<Utilities::Access::read_and_write> vector_content(vector,
__FILE__, __LINE__);
# ifndef NDEBUG
unsigned int vector_proc_size = static_cast<unsigned int>(vector.GetProcessorWiseSize(__FILE__, __LINE__));
# endif // NDEBUG
unsigned int number_of_dofs_filled = 0;
unsigned int number_of_dofs_filled = 0;
for (const auto& node_bearer_ptr : node_bearer_list)
{
assert(!(!node_bearer_ptr));
const auto& node_bearer = *node_bearer_ptr;
for (const auto& node_bearer_ptr : node_bearer_list)
{
assert(!(!node_bearer_ptr));
const auto& node_bearer = *node_bearer_ptr;
if (node_bearer.GetNature() != ::MoReFEM::InterfaceNS::Nature::vertex)
continue;
if (node_bearer.GetNature() != ::MoReFEM::InterfaceNS::Nature::vertex)
continue;
const auto& vertex_coords_list = node_bearer.GetInterface().GetVertexCoordsList();
assert(vertex_coords_list.size() == 1ul && "Interface is a vertex...");
const auto& vertex_coords_ptr = vertex_coords_list.back();
assert(!(!vertex_coords_ptr));
const auto& vertex_coords_list = node_bearer.GetInterface().GetVertexCoordsList();
assert(vertex_coords_list.size() == 1ul && "Interface is a vertex...");
const auto& vertex_coords_ptr = vertex_coords_list.back();
assert(!(!vertex_coords_ptr));
const auto geometric_vertex_index =
vertex_coords_ptr->GetPositionInCoordsListInMesh<MpiScale::processor_wise>();
const auto geometric_vertex_index = vertex_coords_ptr->GetIndex();
auto it = value_list_per_coord_index.find(geometric_vertex_index);
auto it = value_list_per_coord_index.find(geometric_vertex_index);
if (it != value_list_per_coord_index.cend())
{
const auto& value_list_for_current_coord = it->second;
if (it != value_list_per_coord_index.cend())
{
const auto& value_list_for_current_coord = it->second;
const auto& node_list = node_bearer.GetNodeList();
const auto& node_list = node_bearer.GetNodeList();
// Find the only node related to \a Unknown. There is no more direct accessor in
// \a NodeBearer s it would be error-prone: one should not be encouraged to select
// solely on \a Unknown regardless of shape function.
const auto& find_node_with_unknown = [&unknown](const auto& node_ptr)
{
assert(!(!node_ptr));
return node_ptr->GetUnknown() == unknown;
};
// Find the only node related to \a Unknown. There is no more direct accessor in
// \a NodeBearer s it would be error-prone: one should not be encouraged to select
// solely on \a Unknown regardless of shape function.
const auto& find_node_with_unknown = [&unknown](const auto& node_ptr)
{
assert(!(!node_ptr));
return node_ptr->GetUnknown() == unknown;
};
assert(std::count_if(node_list.cbegin(),
node_list.cend(),
find_node_with_unknown) == 1ul);
assert(std::count_if(node_list.cbegin(),
node_list.cend(),
find_node_with_unknown) == 1ul);
const auto it_node = std::find_if(node_list.cbegin(),
node_list.cend(),
find_node_with_unknown);
const auto it_node = std::find_if(node_list.cbegin(),
node_list.cend(),
find_node_with_unknown);
decltype(auto) node_ptr = *it_node;
assert(!(!node_ptr));
decltype(auto) node_ptr = *it_node;
assert(!(!node_ptr));
const auto& node = *node_ptr;
const auto& node = *node_ptr;
assert(node.DoBelongToNumberingSubset(numbering_subset));
assert(node.DoBelongToNumberingSubset(numbering_subset));
const auto& dof_list = node.GetDofList();
const auto& dof_list = node.GetDofList();
const std::size_t Ndof_in_node = dof_list.size();
assert(Ndof_in_node <= value_list_for_current_coord.size());
const std::size_t Ndof_in_node = dof_list.size();
assert(Ndof_in_node <= value_list_for_current_coord.size());
for (std::size_t i = 0ul; i < Ndof_in_node; ++i)
{
const auto& dof_ptr = dof_list[i];
assert(!(!dof_ptr));
vector_content[dof_ptr->GetProcessorWiseOrGhostIndex(numbering_subset)] =
value_list_for_current_coord[i];
for (std::size_t i = 0ul; i < Ndof_in_node; ++i)
{
const auto& dof_ptr = dof_list[i];
assert(!(!dof_ptr));
++number_of_dofs_filled;
}
}
vector_content[dof_ptr->GetProcessorWiseOrGhostIndex(numbering_subset)] =
value_list_for_current_coord[i];
++number_of_dofs_filled;
}
assert(vector_proc_size == number_of_dofs_filled && "All the dofs have not been filled.");
}
vector.UpdateGhosts(__FILE__, __LINE__);
}
assert(vector_proc_size == number_of_dofs_filled && "All the dofs have not been filled.");
}
vector.UpdateGhosts(__FILE__, __LINE__);
} // namespace FiberNS
} // namespace Internal
}
} // namespace MoReFEM
} // namespace MoReFEM::Internal::FiberNS
/// @} // addtogroup ParameterInstancesGroup
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment