diff --git a/src/io/dumper/dumper_element_partition.hh b/src/io/dumper/dumper_element_partition.hh index 59e46332e..3c4ed6f3d 100644 --- a/src/io/dumper/dumper_element_partition.hh +++ b/src/io/dumper/dumper_element_partition.hh @@ -1,121 +1,123 @@ /** * @file dumper_element_partition.hh * * @author Guillaume Anciaux * * @date creation: Tue Sep 02 2014 * @date last modification: Tue Sep 02 2014 * * @brief ElementPartition field * * @section LICENSE * * Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * * Akantu is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. * * Akantu is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with Akantu. If not, see . * */ /* -------------------------------------------------------------------------- */ __BEGIN_AKANTU__ __BEGIN_AKANTU_DUMPER__ - +#ifdef AKANTU_IGFEM +# include "dumper_igfem_element_partition.hh" +#endif /* -------------------------------------------------------------------------- */ template class element_partition_field_iterator : public element_iterator { /* ------------------------------------------------------------------------ */ /* Typedefs */ /* ------------------------------------------------------------------------ */ public: typedef element_iterator parent; typedef typename types::return_type return_type; typedef typename types::array_iterator array_iterator; typedef typename types::field_type field_type; /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: element_partition_field_iterator(const field_type & field, const typename field_type::type_iterator & t_it, const typename field_type::type_iterator & t_it_end, const array_iterator & array_it, const array_iterator & array_it_end, const GhostType ghost_type = _not_ghost) : parent(field, t_it, t_it_end, array_it, array_it_end, ghost_type) { prank = StaticCommunicator::getStaticCommunicator().whoAmI(); } /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: return_type operator*() { return return_type(1, prank); } /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ protected: UInt prank; }; /* -------------------------------------------------------------------------- */ template class ElementPartitionField : public GenericElementalField, element_partition_field_iterator> { public: /* ------------------------------------------------------------------------ */ /* Typedefs */ /* ------------------------------------------------------------------------ */ typedef SingleType types; typedef element_partition_field_iterator iterator; typedef GenericElementalField parent; typedef typename types::field_type field_type; public: /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ ElementPartitionField(const field_type & field, UInt spatial_dimension = _all_dimensions, GhostType ghost_type = _not_ghost, ElementKind element_kind = _ek_not_defined) : parent(field, spatial_dimension, ghost_type, element_kind) { this->homogeneous = true; } /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ UInt getDim() { return 1; } }; /* -------------------------------------------------------------------------- */ __END_AKANTU_DUMPER__ __END_AKANTU__ diff --git a/src/io/dumper/dumper_elemental_field.hh b/src/io/dumper/dumper_elemental_field.hh index f71d0b508..486241411 100644 --- a/src/io/dumper/dumper_elemental_field.hh +++ b/src/io/dumper/dumper_elemental_field.hh @@ -1,79 +1,82 @@ /** * @file dumper_elemental_field.hh * * @author Guillaume Anciaux * @author Nicolas Richart * * @date creation: Tue Sep 02 2014 * @date last modification: Tue Sep 02 2014 * * @brief description of elemental fields * * @section LICENSE * * Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * * Akantu is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. * * Akantu is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with Akantu. If not, see . * */ #ifndef __AKANTU_DUMPER_ELEMENTAL_FIELD_HH__ #define __AKANTU_DUMPER_ELEMENTAL_FIELD_HH__ /* -------------------------------------------------------------------------- */ #include "static_communicator.hh" #include "dumper_field.hh" #include "dumper_generic_elemental_field.hh" +#ifdef AKANTU_IGFEM +# include "dumper_igfem_elemental_field.hh" +#endif /* -------------------------------------------------------------------------- */ __BEGIN_AKANTU__ __BEGIN_AKANTU_DUMPER__ /* -------------------------------------------------------------------------- */ template class ret = Vector,bool filtered = false> class ElementalField : public GenericElementalField, elemental_field_iterator> { public: /* ------------------------------------------------------------------------ */ /* Typedefs */ /* ------------------------------------------------------------------------ */ typedef SingleType types; typedef typename types::field_type field_type; typedef elemental_field_iterator iterator; /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ ElementalField(const field_type & field, UInt spatial_dimension = _all_dimensions, GhostType ghost_type = _not_ghost, ElementKind element_kind = _ek_not_defined) : GenericElementalField(field, spatial_dimension, ghost_type, element_kind) { } }; /* -------------------------------------------------------------------------- */ __END_AKANTU_DUMPER__ __END_AKANTU__ #endif /* __AKANTU_DUMPER_ELEMENTAL_FIELD_HH__ */ diff --git a/src/io/dumper/dumper_homogenizing_field.hh b/src/io/dumper/dumper_homogenizing_field.hh index cfd6cdc6f..9317030f0 100644 --- a/src/io/dumper/dumper_homogenizing_field.hh +++ b/src/io/dumper/dumper_homogenizing_field.hh @@ -1,226 +1,227 @@ /** * @file dumper_homogenizing_field.hh * * @author Guillaume Anciaux * @author Nicolas Richart * * @date creation: Tue Sep 02 2014 * @date last modification: Tue Sep 02 2014 * * @brief description of field homogenizing field * * @section LICENSE * * Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * * Akantu is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. * * Akantu is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with Akantu. If not, see . * */ #ifndef __AKANTU_DUMPER_HOMOGENIZING_FIELD_HH__ #define __AKANTU_DUMPER_HOMOGENIZING_FIELD_HH__ /* -------------------------------------------------------------------------- */ #include "dumper_compute.hh" /* -------------------------------------------------------------------------- */ __BEGIN_AKANTU__ __BEGIN_AKANTU_DUMPER__ /* -------------------------------------------------------------------------- */ template inline type typeConverter(const type & input, Vector & res,UInt nb_data){ throw; return input; } /* -------------------------------------------------------------------------- */ template inline Matrix typeConverter(const Matrix & input, Vector & res,UInt nb_data){ Matrix tmp(res.storage(),input.rows(),nb_data/input.rows()); Matrix tmp2(tmp,true); return tmp2; } /* -------------------------------------------------------------------------- */ template inline Vector typeConverter(const Vector & input, Vector & res,UInt nb_data){ return res; } /* -------------------------------------------------------------------------- */ template class AvgHomogenizingFunctor : public ComputeFunctor { /* ------------------------------------------------------------------------ */ /* Typedefs */ /* ------------------------------------------------------------------------ */ typedef typename type::value_type value_type; /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: AvgHomogenizingFunctor(ElementTypeMap & nb_datas){ ElementTypeMap::type_iterator tit = nb_datas.firstType(); ElementTypeMap::type_iterator end = nb_datas.lastType(); nb_data = nb_datas(*tit); for (;tit != end; ++tit) if (nb_data != nb_datas(*tit)) throw; } /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ virtual type func(const type & d, Element global_index){ Vector res(this->nb_data); if (d.size() % this->nb_data) throw; UInt nb_to_average = d.size()/this->nb_data; value_type * ptr = d.storage(); for (UInt i = 0; i < nb_to_average; ++i) { Vector tmp(ptr,this->nb_data); res += tmp; + ptr += this->nb_data; } res /= nb_to_average; return typeConverter(d,res,this->nb_data); }; UInt getDim(){return nb_data;}; UInt getNbComponent(UInt old_nb_comp){ throw; }; /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ /// The size of data: i.e. the size of the vector to be returned UInt nb_data; }; /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ class HomogenizerProxy { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: HomogenizerProxy(){}; public: inline static ComputeFunctorInterface * createHomogenizer(Field & field); template inline ComputeFunctorInterface * connectToField(T * field){ ElementTypeMap nb_components = field->getNbComponents(); typedef typename T::types::return_type ret_type; return this->instantiateHomogenizer(nb_components); } template inline ComputeFunctorInterface * instantiateHomogenizer(ElementTypeMap & nb_components); }; /* -------------------------------------------------------------------------- */ template inline ComputeFunctorInterface * HomogenizerProxy ::instantiateHomogenizer(ElementTypeMap & nb_components){ typedef dumper::AvgHomogenizingFunctor Homogenizer; Homogenizer * foo = new Homogenizer(nb_components); return foo; } template <> inline ComputeFunctorInterface * HomogenizerProxy ::instantiateHomogenizer > (ElementTypeMap & nb_components){ throw; return NULL; } /* -------------------------------------------------------------------------- */ /// for connection to a FieldCompute template inline ComputeFunctorInterface * FieldCompute ::connect(HomogenizerProxy & proxy){ return proxy.connectToField(this); } /* -------------------------------------------------------------------------- */ inline ComputeFunctorInterface * HomogenizerProxy::createHomogenizer(Field & field){ HomogenizerProxy homogenizer_proxy; return field.connect(homogenizer_proxy); } /* -------------------------------------------------------------------------- */ // inline ComputeFunctorInterface & createHomogenizer(Field & field){ // HomogenizerProxy::createHomogenizer(field); // throw; // ComputeFunctorInterface * ptr = NULL; // return *ptr; // } // /* -------------------------------------------------------------------------- */ __END_AKANTU_DUMPER__ __END_AKANTU__ #endif /* __AKANTU_DUMPER_HOMOGENIZING_FIELD_HH__ */