20 using namespace common;
26 boost::shared_ptr< List< Uint > >
used_nodes = allocate_component< List< Uint > >(mesh::Tags::nodes_used());
28 if(entities_vector.empty())
31 const Uint all_nb_nodes = dictionary.
size();
33 std::vector<bool> node_is_used(all_nb_nodes,
false);
42 if( &space->support() == entities.
get() )
44 const Uint nb_elems = space->size();
49 if(include_ghost_elems || entities->is_ghost(
idx) ==
false)
54 if(!node_is_used[node])
56 node_is_used[node] =
true;
65 if(follow_periodic_links && periodic_links_active)
67 const List<Uint>& per_links = *periodic_links_nodes;
70 for(
Uint i = 0; i != all_nb_nodes; ++i)
72 if(per_active[i] && (node_is_used[per_links[i]] || node_is_used[i]))
74 node_is_used[i] =
true;
75 node_is_used[per_links[i]] =
true;
81 const Uint nb_used_nodes =
std::count(node_is_used.begin(), node_is_used.end(),
true);
82 used_nodes->resize(nb_used_nodes);
88 for(
Uint i = 0; i != all_nb_nodes; ++i)
93 nodes_array[back++] = i;
97 std::sort(used_nodes->array().begin(), used_nodes->array().end());
105 std::vector< Handle<Entities const> > entities_vector;
107 entities_vector.push_back(entities_h);
118 const Real
eps = 1
e-8;
119 const Real
min = support_local_coords.minCoeff();
120 const Real
max = support_local_coords.maxCoeff();
121 const Real max_sum = min == -1. ? -2. : 1.-
eps;
123 const Eigen::Array<bool, Eigen::Dynamic, 1> is_interior_arr = ((source_local_coords.array() >
min).rowwise().all() && (source_local_coords.array() <
max).rowwise().all() && source_local_coords.array().rowwise().sum() < max_sum);
125 const Uint nb_target_nodes = source_local_coords.rows();
127 node_mapping.resize(nb_target_nodes);
128 is_interior.resize(nb_target_nodes);
130 Eigen::Array<int, Eigen::Dynamic, 1> counts(support_local_coords.rows());
133 for(
Uint row_idx = 0; row_idx != nb_target_nodes; ++row_idx)
135 is_interior[row_idx] = is_interior_arr[row_idx];
138 const Eigen::Array<Real, Eigen::Dynamic, 1> distances = (support_local_coords.rowwise() - source_local_coords.row(row_idx)).rowwise().squaredNorm();
141 const Real min_dist = distances.minCoeff();
145 (distances.array() == min_dist).select(counts, nb_target_nodes).minCoeff(&min_idx);
147 node_mapping[row_idx] = min_idx;
boost::multi_array< ValueT, 1 > ListT
the type of the internal structure of the list
void nearest_node_mapping(const RealMatrix &support_local_coords, const RealMatrix &source_local_coords, std::vector< Uint > &node_mapping, std::vector< bool > &is_interior)
std::vector< Uint > used_nodes(const mesh::Region ®ion, const mesh::Dictionary &dict)
#define boost_foreach
lowercase version of BOOST_FOREACH
Real max(const Real a, const Real b)
Maximum between two scalars.
Real e()
Definition of the Unit charge [C].
const std::vector< Handle< Space > > & spaces() const
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic > RealMatrix
Dynamic sized matrix of Real scalars.
Real min(const Real a, const Real b)
Minimum between two scalars.
Handle< Component > get_child(const std::string &name)
Top-level namespace for coolfluid.
std::vector< Handle< const T > > range_to_const_vector(boost::iterator_range< ComponentIterator< T > > range)
unsigned int Uint
typedef for unsigned int
boost::shared_ptr< List< Uint > > build_used_nodes_list(const std::vector< Handle< Entities const > > &entities_vector, const Dictionary &dictionary, const bool include_ghost_elems, const bool follow_periodic_links)
Create a List containing unique entries of all the nodes used by a vector of entities...
Handle< Component > handle()
Get a handle to the component.
Base class for defining CF components.
Uint size() const
Number of rows of contained fields.
Uint count(const RangeT &range)
Count the elements in a range.
T * get() const
Raw pointer to the stored value, or null if there is none.