Loading...
Searching...
No Matches
geo_size.cc
Go to the documentation of this file.
// Manage distributed indexes for the geo class
//
// Author: Pierre Saramito
//
#include "rheolef/geo_size.h"
namespace rheolef {
// =========================================================================
// utility: convect geo_element numbering by dimension and by variant
// =========================================================================
geo_size::size_type
geo_size::dis_ige2variant (
size_type map_dim,
size_type dis_ige) const
{
const distributor& ownership = ownership_by_dimension [map_dim];
size_type iproc = ownership.find_owner (dis_ige);
size_type first_dis_ige = ownership.first_index(iproc);
size_type ige = dis_ige - first_dis_ige;
size_type first_v = 0;
for (size_type variant = reference_element::first_variant_by_dimension(map_dim);
variant < reference_element:: last_variant_by_dimension(map_dim);
variant++) {
size_type size_v = ownership_by_variant [variant].size(iproc);
size_type last_v = first_v + size_v;
if (ige < last_v) return variant;
first_v = last_v;
}
error_macro ("dis_ie2variant: invalid dis_ige="<<dis_ige<<", ige="<<ige);
return reference_element::max_variant; // not reached
}
// compute dis_igev from dis_ige & variant:
geo_size::size_type
geo_size::_dis_ige2dis_igev (
size_type map_dim,
size_type variant,
size_type dis_ige) const
{
trace_macro("dis_ige2dis_igev (map_dim="<<map_dim<<", hat_K="<<reference_element(variant).name()<<", dis_ige="<<dis_ige<<")...");
size_type iproc = ownership_by_dimension [map_dim].find_owner (dis_ige);
size_type first_dis_v = 0;
for (size_type prev_variant = reference_element::first_variant_by_dimension(map_dim);
prev_variant < variant;
prev_variant++) {
size_type shift = ownership_by_variant [prev_variant].last_index(iproc);
first_dis_v += shift;
}
for (size_type next_variant = variant+1;
next_variant < reference_element::last_variant_by_dimension(map_dim);
next_variant++) {
size_type shift = ownership_by_variant [next_variant].first_index(iproc);
first_dis_v += shift;
}
assert_macro (dis_ige >= first_dis_v, "invalid index");
size_type dis_igev = dis_ige - first_dis_v;
trace_macro("dis_ige2dis_igev (map_dim="<<map_dim<<", hat_K="<<reference_element(variant).name()<<", dis_ige="<<dis_ige<<"): dis_igev="<<dis_igev<<"...");
return dis_igev;
}
geo_size::size_type
geo_size::dis_ige2dis_igev_by_dimension (
size_type map_dim,
size_type dis_ige,
size_type& variant) const
{
variant = dis_ige2variant (map_dim, dis_ige);
return _dis_ige2dis_igev (map_dim, variant, dis_ige);
}
geo_size::size_type
geo_size::dis_ige2dis_igev_by_dimension (
size_type map_dim,
size_type dis_ige) const
{
size_type variant;
return dis_ige2dis_igev_by_dimension (map_dim, dis_ige, variant);
}
geo_size::size_type
geo_size::dis_ige2dis_igev_by_variant (
size_type variant,
size_type dis_ige) const
{
size_type map_dim = reference_element::dimension (variant);
return _dis_ige2dis_igev (map_dim, variant, dis_ige);
}
// =========================================================================
// utility: vertex ownership follows node ownership, but dis_numbering differ
// for high order > 1 meshes. This function converts numbering.
// =========================================================================
geo_size::size_type
geo_size::dis_inod2dis_iv (size_type dis_inod) const
{
const distributor& vertex_ownership = ownership_by_dimension[0];
size_type iproc = node_ownership.find_owner(dis_inod);
size_type first_dis_inod = node_ownership.first_index(iproc);
size_type first_dis_iv = vertex_ownership.first_index(iproc);
size_type inod = dis_inod - first_dis_inod;
size_type iv = inod;
size_type dis_iv = first_dis_iv + iv;
return dis_iv;
}
geo_size::size_type
geo_size::dis_iv2dis_inod (size_type dis_iv) const
{
const distributor& vertex_ownership = ownership_by_dimension[0];
size_type iproc = vertex_ownership.find_owner(dis_iv);
size_type first_dis_iv = vertex_ownership.first_index(iproc);
size_type first_dis_inod = node_ownership.first_index(iproc);
size_type iv = dis_iv - first_dis_iv;
size_type inod = iv;
size_type dis_inod = first_dis_inod + inod;
return dis_inod;
}
} // namespace
rheolef::distributor
see the distributor page for the full documentation
Definition distributor.h:69
rheolef::distributor::find_owner
size_type find_owner(size_type dis_i) const
find iproc associated to a global index dis_i: CPU=log(nproc)
Definition distributor.cc:106
rheolef::distributor::first_index
size_type first_index(size_type iproc) const
global index range and local size owned by ip-th process
Definition distributor.h:158
rheolef::reference_element
see the reference_element page for the full documentation
Definition reference_element.h:66
rheolef::reference_element::max_variant
static const variant_type max_variant
Definition reference_element.h:82
rheolef::reference_element::last_variant_by_dimension
static variant_type last_variant_by_dimension(size_type dim)
Definition reference_element.h:150
rheolef::reference_element::dimension
size_type dimension() const
Definition reference_element.h:101
rheolef::reference_element::first_variant_by_dimension
static variant_type first_variant_by_dimension(size_type dim)
Definition reference_element.h:148
trace_macro
#define trace_macro(message)
Definition dis_macros.h:111
assert_macro
#define assert_macro(ok_condition, message)
Definition dis_macros.h:113
error_macro
#define error_macro(message)
Definition dis_macros.h:49
rheolef
This file is part of Rheolef.
Definition compiler_eigen.h:39
rheolef::geo_size::dis_ige2dis_igev_by_variant
size_type dis_ige2dis_igev_by_variant(size_type variant, size_type dis_ige) const
Definition geo_size.cc:98
rheolef::geo_size::ownership_by_variant
distributor ownership_by_variant[reference_element::max_variant]
Definition geo_size.h:64
rheolef::geo_size::dis_iv2dis_inod
size_type dis_iv2dis_inod(size_type dis_iv) const
Definition geo_size.cc:122
rheolef::geo_size::dis_ige2variant
size_type dis_ige2variant(size_type map_dim, size_type dis_ige) const
Definition geo_size.cc:33
rheolef::geo_size::dis_ige2dis_igev_by_dimension
size_type dis_ige2dis_igev_by_dimension(size_type map_dim, size_type dis_ige) const
Definition geo_size.cc:90
rheolef::geo_size::node_ownership
distributor node_ownership
Definition geo_size.h:65
rheolef::geo_size::dis_inod2dis_iv
size_type dis_inod2dis_iv(size_type dis_inod) const
Definition geo_size.cc:110
rheolef::geo_size::size_type
distributor::size_type size_type
Definition geo_size.h:33
rheolef::geo_size::ownership_by_dimension
distributor ownership_by_dimension[4]
Definition geo_size.h:63
rheolef::geo_size::_dis_ige2dis_igev
size_type _dis_ige2dis_igev(size_type map_dim, size_type variant, size_type dis_ige) const
Definition geo_size.cc:55