geo_domain.cc
Go to the documentation of this file.
#include "rheolef/geo_domain.h"
namespace rheolef {
// ------------------------------------------------------------------------
// cstors
// ------------------------------------------------------------------------
template <class T, class M>
geo_domain_rep<T,M>::geo_domain_rep (const geo_domain_rep<T,M>& x)
: base(x),
_dom (x._dom),
_bgd_ie2dom_ie(x._bgd_ie2dom_ie),
_dis_bgd_ie2dis_dom_ie(x._dis_bgd_ie2dis_dom_ie)
{
trace_macro ("*** PHYSICAL COPY OF GEO_DOMAIN ***");
}
template <class T, class M>
geo_abstract_rep<T,M>*
geo_domain_rep<T,M>::clone() const
{
trace_macro ("*** CLONE GEO_DOMAIN ***");
typedef geo_domain_rep<T,M> rep;
return new_macro(rep(*this));
}
template <class T, class M>
geo_domain_rep<T,M>::geo_domain_rep (const geo_domain_indirect_rep<T,M>& dom)
: base(),
_dom (dom),
_bgd_ie2dom_ie(),
_dis_bgd_ie2dis_dom_ie()
{
geo_rep<T,M>::build_from_domain (
_dom.get_indirect().data(),
_dom.get_background_geo().data(),
_bgd_ie2dom_ie,
_dis_bgd_ie2dis_dom_ie);
}
// ----------------------------------------------------------------------------
// geo_element: goes from bgd to domain element
// ----------------------------------------------------------------------------
template <class T, class M>
typename geo_domain_rep<T,M>::size_type
geo_domain_rep<T,M>::bgd_ie2dom_ie (size_type bgd_ie) const
{
typename std::map<size_type,size_type>::const_iterator iter = _bgd_ie2dom_ie.find (bgd_ie);
if (iter != _bgd_ie2dom_ie.end()) {
return (*iter).second;
} else {
return std::numeric_limits<size_type>::max();
}
}
template <class T, class M>
typename geo_domain_rep<T,M>::size_type
geo_domain_rep<T,M>::dis_bgd_ie2dis_dom_ie (size_type dis_bgd_ie) const
{
size_type map_d = base::map_dimension();
size_type first_dis_bgd_ie = get_background_geo().sizes().ownership_by_dimension[map_d].first_index();
size_type last_dis_bgd_ie = get_background_geo().sizes().ownership_by_dimension[map_d]. last_index();
if (dis_bgd_ie >= first_dis_bgd_ie && dis_bgd_ie < last_dis_bgd_ie) {
size_type bgd_ie = dis_bgd_ie - first_dis_bgd_ie;
return bgd_ie2dom_ie (bgd_ie);
}
typename std::map<size_type,size_type>::const_iterator iter = _dis_bgd_ie2dis_dom_ie.find (dis_bgd_ie);
if (iter != _dis_bgd_ie2dis_dom_ie.end()) {
return (*iter).second;
} else {
return std::numeric_limits<size_type>::max();
}
}
template <class T, class M>
const geo_element&
geo_domain_rep<T,M>::bgd2dom_geo_element (const geo_element& bgd_K) const
{
size_type map_d = bgd_K.dimension();
size_type dis_bgd_ie = bgd_K.dis_ie();
size_type first_dis_bgd_ie = get_background_geo().sizes().ownership_by_dimension[map_d].first_index();
size_type last_dis_bgd_ie = get_background_geo().sizes().ownership_by_dimension[map_d]. last_index();
if (dis_bgd_ie >= first_dis_bgd_ie && dis_bgd_ie < last_dis_bgd_ie) {
size_type bgd_ie = dis_bgd_ie - first_dis_bgd_ie;
size_type dom_ie = bgd_ie2dom_ie (bgd_ie);
const geo_element& dom_K = base::get_geo_element (map_d, dom_ie);
return dom_K;
} else {
size_type dis_dom_ie = dis_bgd_ie2dis_dom_ie (dis_bgd_ie);
const geo_element& dom_K = base::dis_get_geo_element (map_d, dis_dom_ie);
return dom_K;
}
}
template <class T, class M>
const geo_element&
geo_domain_rep<T,M>::dom2bgd_geo_element (const geo_element& dom_K) const
{
size_type map_d = dom_K.dimension();
size_type dom_dis_ie = dom_K.dis_ie();
size_type first_dom_dis_ie = base::sizes().ownership_by_dimension[map_d].first_index();
check_macro (dom_dis_ie >= first_dom_dis_ie, "unexpected dis_index "<<dom_dis_ie<<": out of local range");
size_type dom_ie = dom_dis_ie - first_dom_dis_ie;
const geo_basic<T,M>& dom = get_background_domain();
const geo_element& bgd_K = dom[dom_ie];
return bgd_K;
}
// ----------------------------------------------------------------------------
// instanciation in library
// ----------------------------------------------------------------------------
#define _RHEOLEF_instanciation(T,M) \
template class geo_domain_rep<T,M>;
_RHEOLEF_instanciation(Float,sequential)
#ifdef _RHEOLEF_HAVE_MPI
_RHEOLEF_instanciation(Float,distributed)
#endif // _RHEOLEF_HAVE_MPI
} // namespace rheolef
rheolef::geo_domain_indirect_rep
Definition: geo.h:187
rheolef::geo_domain_rep::_bgd_ie2dom_ie
std::map< size_type, size_type > _bgd_ie2dom_ie
Definition: geo_domain.h:87
rheolef::geo_domain_rep::size_type
base::size_type size_type
Definition: geo_domain.h:57
rheolef::geo_basic< T, M >
rheolef::geo_domain_rep
Definition: geo_domain.h:53
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::_RHEOLEF_instanciation
_RHEOLEF_instanciation(Float, sequential, std::allocator< Float >) _RHEOLEF_instanciation(Float
rheolef::geo_element
see the geo_element page for the full documentation
Definition: geo_element.h:102
rheolef::geo_rep
sequential mesh representation
Definition: domain_indirect.h:63
rheolef::geo_element::dis_ie
size_type dis_ie() const
Definition: geo_element.h:163
rheolef::geo_domain_rep::_dis_bgd_ie2dis_dom_ie
std::map< size_type, size_type > _dis_bgd_ie2dis_dom_ie
Definition: geo_domain.h:88
rheolef::geo_element::dimension
size_type dimension() const
Definition: geo_element.h:167
rheolef::geo_domain_rep::geo_domain_rep
geo_domain_rep(const geo_domain_rep< T, M > &)
Definition: geo_domain.cc:30
rheolef::geo_abstract_rep
abstract interface class
Definition: domain_indirect.h:62
rheolef::geo_domain_rep::bgd2dom_geo_element
const geo_element & bgd2dom_geo_element(const geo_element &bgd_K) const
Definition: geo_domain.cc:93
rheolef::geo_domain_rep::bgd_ie2dom_ie
size_type bgd_ie2dom_ie(size_type bgd_ie) const
Definition: geo_domain.cc:64
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
Float
see the Float page for the full documentation
rheolef::geo_domain_rep::_dom
geo_domain_indirect_rep< T, M > _dom
Definition: geo_domain.h:86
rheolef::distributed
distributed
Definition: asr.cc:228
rheolef::geo_domain_rep::dom2bgd_geo_element
const geo_element & dom2bgd_geo_element(const geo_element &dom_K) const
Definition: geo_domain.cc:112
trace_macro
#define trace_macro(message)
Definition: dis_macros.h:111
rheolef::geo_domain_rep::clone
geo_abstract_rep< T, M > * clone() const
Definition: geo_domain.cc:40
rheolef::geo_domain_rep::dis_bgd_ie2dis_dom_ie
size_type dis_bgd_ie2dis_dom_ie(size_type dis_bgd_ie) const
Definition: geo_domain.cc:75