Loading...
Searching...
No Matches
geo_mpi_put.cc
Go to the documentation of this file.
#include "rheolef/config.h"
#ifdef _RHEOLEF_HAVE_MPI
#include "rheolef/geo.h"
#include "rheolef/geo_domain.h"
#include "rheolef/dis_macros.h"
#include "rheolef/rheostream.h"
#include "rheolef/iorheo.h"
#include "rheolef/index_set.h"
namespace rheolef {
// ----------------------------------------------------------------------------
// output
// ----------------------------------------------------------------------------
struct permutation_proxy {
typedef geo_element::size_type size_type;
permutation_proxy (const hack_array<geo_element_hack>& elts, size_type first_dis_v = 0)
: _elts(elts), _first_dis_v(first_dis_v) {}
size_type size() const { return _elts.size(); }
size_type operator[] (size_type ie) const {
const geo_element& K = _elts [ie];
return K.ios_dis_ie() - _first_dis_v;
}
const permutation_proxy& data() const { return *this; }
// data:
const hack_array<geo_element_hack>& _elts;
size_type _first_dis_v;
};
template <class T>
odiststream&
geo_rep<T,distributed>::put (odiststream& ops) const
{
using namespace std;
iorheo::flag_type format = iorheo::flags(ops.os()) & iorheo::format_field;
check_macro (format[iorheo::rheo], "geo distributed: unsupported geo output file format=" << format);
communicator comm = base::_geo_element[reference_element::p].ownership().comm();
size_type io_proc = odiststream::io_proc();
size_type my_proc = comm.rank();
size_type nproc = comm.size();
size_type dis_nnod = base::_node.dis_size ();
size_type dis_nv = base::_geo_element[reference_element::p].dis_size ();
//
// 1) put header
//
ops << setprecision(numeric_limits<Float>::digits10)
<< "#!geo" << endl
<< endl
<< "mesh" << endl
<< base::_version;
geo_header h;
h.dimension = base::_dimension;
h.sys_coord = base::_sys_coord;
h.order = base::order();
h.dis_size_by_variant [0] = base::_node.dis_size();
for (size_type variant = 1; variant < reference_element::max_variant; variant++) {
h.dis_size_by_variant [variant] = base::_geo_element [variant].dis_size();
}
ops << endl << h << endl;
//
// 2) put nodes
//
if (base::_dimension > 0) {
T rounding_prec = iorheo::getrounding_precision(ops.os());
if (rounding_prec == 0) {
base::_node.permuted_put_values (ops,
_inod2ios_dis_inod,
_point_put<T>(base::_dimension));
} else {
base::_node.permuted_put_values (ops,
_inod2ios_dis_inod,
_round_point_put<T>(base::_dimension, rounding_prec));
}
ops << endl;
}
//
// 3) build a node permutation disarray on io_proc
//
// elements are permuted back to original order and may
// refer to original node numbering
// TODO: disarray node_perm = merge_array_on_proc (_inod2ios_dis_inod , io_proc);
std::vector<size_type> node_perm ((my_proc == io_proc) ? dis_nnod : 0);
size_type tag_gather = distributor::get_new_tag();
if (my_proc == io_proc) {
size_type i_start = _inod2ios_dis_inod.ownership().first_index(my_proc);
size_type i_size = _inod2ios_dis_inod.ownership().size (my_proc);
for (size_type i = 0; i < i_size; i++) {
node_perm [i_start + i] = _inod2ios_dis_inod [i];
}
for (size_type iproc = 0; iproc < nproc; iproc++) {
if (iproc == my_proc) continue;
size_type i_start = _inod2ios_dis_inod.ownership().first_index(iproc);
size_type i_size = _inod2ios_dis_inod.ownership().size (iproc);
comm.recv (iproc, tag_gather, node_perm.begin().operator->() + i_start, i_size);
}
} else {
comm.send (0, tag_gather, _inod2ios_dis_inod.begin().operator->(), _inod2ios_dis_inod.size());
}
//
// 4) put elements, faces & edges
//
geo_element_permuted_put put_element (node_perm);
for (size_type dim = base::_gs._map_dimension; dim > 0; dim--) {
size_type first_dis_v = 0;
for (size_type variant = reference_element::first_variant_by_dimension(dim);
variant < reference_element:: last_variant_by_dimension(dim); variant++) {
if (base::_gs.ownership_by_variant[variant].dis_size() == 0) continue;
permutation_proxy perm (base::_geo_element [variant], first_dis_v);
base::_geo_element [variant].permuted_put_values (ops, perm, put_element);
first_dis_v += base::_gs.ownership_by_variant[variant].dis_size();
}
ops << endl;
}
//
// 6) put domains
//
for (typename std::vector<domain_indirect_basic<distributed> >::const_iterator
iter = base::_domains.begin(),
last = base::_domains.end();
iter != last; ++iter) {
ops << endl;
(*iter).put (ops, *this);
}
return ops;
}
template <class T>
void
geo_rep<T,distributed>::dump (std::string name) const
{
fatal_macro ("dump: not yet");
#ifdef TODO
base::_node.dump (name + "-node");
base::_geo_element[variant].dump(name + "-elem-"+ref::name(variant));
#endif // TODO
}
// ----------------------------------------------------------------------------
// instanciation in library
// ----------------------------------------------------------------------------
template class geo_rep<Float,distributed>;
} // namespace rheolef
#endif // _RHEOLEF_HAVE_MPI
communicator
see the communicator page for the full documentation
rheolef::distributor::get_new_tag
static tag_type get_new_tag()
returns a new tag
Definition distributor.cc:133
rheolef::domain_indirect_basic
the finite element boundary domain
Definition domain_indirect.h:335
rheolef::geo_base_rep< T, distributed >::name
std::string name() const
rheolef::geo_base_rep< T, distributed >::_dimension
size_type _dimension
Definition geo.h:685
rheolef::geo_base_rep< T, distributed >::_domains
std::vector< domain_indirect_basic< distributed > > _domains
Definition geo.h:680
rheolef::geo_base_rep< T, distributed >::_sys_coord
coordinate_type _sys_coord
Definition geo.h:686
rheolef::geo_base_rep< T, distributed >::_version
size_type _version
Definition geo.h:675
rheolef::geo_base_rep< T, distributed >::_node
disarray< node_type, distributed > _node
Definition geo.h:684
rheolef::geo_base_rep< T, distributed >::variant
size_type variant() const
Definition geo.h:559
rheolef::geo_base_rep< T, distributed >::_gs
geo_size _gs
Definition geo.h:679
rheolef::geo_base_rep< T, distributed >::_geo_element
std::array< hack_array< geo_element_hack, distributed >, reference_element::max_variant > _geo_element
Definition geo.h:678
rheolef::geo_base_rep< T, distributed >::order
size_type order() const
Definition geo.h:638
rheolef::geo_base_rep< T, distributed >::comm
const communicator & comm() const
Definition geo.h:637
rheolef::geo_base_rep< T, distributed >::dis_size
size_type dis_size(size_type dim) const
rheolef::geo_element::size_type
reference_element::size_type size_type
Definition geo_element.h:125
rheolef::geo_rep< T, distributed >::end
const_iterator end(size_type dim) const
Definition geo.h:1004
rheolef::geo_rep< T, distributed >::geo_rep
geo_rep()
Definition geo.cc:112
rheolef::geo_rep< T, distributed >::size_type
base::size_type size_type
Definition geo.h:934
rheolef::geo_rep< T, distributed >::_inod2ios_dis_inod
disarray< size_type > _inod2ios_dis_inod
Definition geo.h:1064
rheolef::geo_rep< T, distributed >::const_iterator
base::const_iterator const_iterator
Definition geo.h:941
rheolef::geo_rep< T, distributed >::begin
const_iterator begin(size_type dim) const
Definition geo.h:1003
rheolef::geo_rep
sequential mesh representation
Definition geo.h:778
rheolef::iorheo::flag_type
std::bitset< last > flag_type
Definition iorheo.h:440
rheolef::iorheo::flags
static flag_type flags(std::ios &s)
Definition iorheo.cc:244
rheolef::iorheo::format_field
static flag_type format_field
Definition iorheo.h:445
rheolef::iorheo::rheo
@ rheo
Definition iorheo.h:382
rheolef::odiststream
odiststream: see the diststream page for the full documentation
Definition diststream.h:137
rheolef::odiststream::os
std::ostream & os()
Definition diststream.h:247
rheolef::odiststream::io_proc
static size_type io_proc()
Definition diststream.cc:79
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::first_variant_by_dimension
static variant_type first_variant_by_dimension(size_type dim)
Definition reference_element.h:148
rheolef::reference_element::p
static const variant_type p
Definition reference_element.h:75
fatal_macro
#define fatal_macro(message)
Definition dis_macros.h:33
T
Expr1::float_type T
Definition field_expr.h:230
check_macro
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
rheolef
This file is part of Rheolef.
Definition compiler_eigen.h:39
std
STL namespace.
rheolef::_point_put
point output helper
Definition geo.h:163
rheolef::_round_point_put
point output helper, with rounding feature
Definition geo.h:171
rheolef::geo_element_permuted_put
Definition geo_element.h:526
rheolef::geo_header
Definition geo_header.h:32