LCOV - code coverage report
Current view: top level - ugbase/lib_grid - lib_grid_messages.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 18 0
Test Date: 2025-09-21 23:31:46 Functions: - 0 0

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2011-2015:  G-CSC, Goethe University Frankfurt
       3              :  * Author: Sebastian Reiter
       4              :  * 
       5              :  * This file is part of UG4.
       6              :  * 
       7              :  * UG4 is free software: you can redistribute it and/or modify it under the
       8              :  * terms of the GNU Lesser General Public License version 3 (as published by the
       9              :  * Free Software Foundation) with the following additional attribution
      10              :  * requirements (according to LGPL/GPL v3 §7):
      11              :  * 
      12              :  * (1) The following notice must be displayed in the Appropriate Legal Notices
      13              :  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
      14              :  * 
      15              :  * (2) The following notice must be displayed at a prominent place in the
      16              :  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
      17              :  * 
      18              :  * (3) The following bibliography is recommended for citation and must be
      19              :  * preserved in all covered files:
      20              :  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
      21              :  *   parallel geometric multigrid solver on hierarchically distributed grids.
      22              :  *   Computing and visualization in science 16, 4 (2013), 151-164"
      23              :  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
      24              :  *   flexible software system for simulating pde based models on high performance
      25              :  *   computers. Computing and visualization in science 16, 4 (2013), 165-179"
      26              :  * 
      27              :  * This program is distributed in the hope that it will be useful,
      28              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      29              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      30              :  * GNU Lesser General Public License for more details.
      31              :  */
      32              : 
      33              : #ifndef __H__UG__lib_grid_messages__
      34              : #define __H__UG__lib_grid_messages__
      35              : 
      36              : #include "common/util/message_hub.h"
      37              : #include "lib_grid/grid/grid_object_collection.h"
      38              : #include "lib_grid/algorithms/serialization.h"
      39              : 
      40              : namespace ug
      41              : {
      42              : 
      43              : ////////////////////////////////////////////////////////////////////////////////
      44              : enum GridMessageMultiGridChangedType{
      45              :         GMMGCT_LEVEL_ADDED = 1,
      46              :         GMMGCT_REMOVED = 2
      47              : };
      48              : 
      49              : ///     A message sent by the MultiGrid, if something special happened.
      50            0 : class GridMessage_MultiGridChanged : public MessageHub::IMessage
      51              : {
      52              :         public:
      53              :                 GridMessage_MultiGridChanged(GridMessageMultiGridChangedType msgType,
      54            0 :                                                                          int numLevels) :
      55            0 :                         m_msgType(msgType),
      56            0 :                         m_numLevels(numLevels)
      57              :                 {}
      58              : 
      59              :         ///     returns the type of the message
      60            0 :                 GridMessageMultiGridChangedType message_type() const    {return m_msgType;}
      61              : 
      62              :         ///     returns the current number of levels in the multigrid, which did send the message.
      63            0 :                 int num_levels_in_grid() const          {return m_numLevels;}
      64              : 
      65              :         private:
      66              :                 GridMessageMultiGridChangedType m_msgType;
      67              :                 int             m_numLevels;
      68              : };
      69              : 
      70              : 
      71              : ////////////////////////////////////////////////////////////////////////////////
      72              : ///     constants which indicate the adaption type in a grid refinement message.
      73              : enum GridMessageAdaptionType{
      74              :         GMAT_UNKNOWN = 0,
      75              :         GMAT_GLOBAL_ADAPTION_BEGINS,
      76              :         GMAT_HNODE_ADAPTION_BEGINS,
      77              :         GMAT_GLOBAL_ADAPTION_ENDS,
      78              :         GMAT_HNODE_ADAPTION_ENDS,
      79              :         GMAT_GLOBAL_REFINEMENT_BEGINS,
      80              :         GMAT_HNODE_REFINEMENT_BEGINS,
      81              :         GMAT_GLOBAL_REFINEMENT_ENDS,
      82              :         GMAT_HNODE_REFINEMENT_ENDS,
      83              :         GMAT_GLOBAL_COARSENING_BEGINS,
      84              :         GMAT_HNODE_COARSENING_BEGINS,
      85              :         GMAT_GLOBAL_COARSENING_ENDS,
      86              :         GMAT_HNODE_COARSENING_ENDS
      87              : };
      88              : 
      89              : ///     A message sent along with "GridRefinement" messages.
      90            0 : class GridMessage_Adaption : public MessageHub::IMessage
      91              : {
      92              :         public:
      93            0 :                 GridMessage_Adaption(GridMessageAdaptionType adaptionType) :
      94            0 :                         m_adaptionType(adaptionType)    {}
      95              : 
      96              :                 GridMessage_Adaption(GridMessageAdaptionType adaptionType,
      97            0 :                                                          const GridObjectCollection& affectedElements) :
      98            0 :                         m_adaptionType(adaptionType),
      99            0 :                         m_affectedElements(affectedElements){}
     100              : 
     101              :                 GridMessageAdaptionType adaption_type() const   {return m_adaptionType;}
     102              : 
     103              :         ///     tells whether grid adaption has just been started or has been finished.
     104              :         /**     Note that begins and ends may both be false. An adaption consists of
     105              :          * multiple steps.
     106              :          * \{ */
     107              :                 bool adaption_begins() const;
     108              :                 bool adaption_ends() const;
     109              :         /** \} */
     110              : 
     111              :         ///     tells whether an adaption step has just been started or has been finished.
     112              :         /**     Note that both may be false. An adaption consists of multiple adaption steps.
     113              :          * \{ */
     114              :                 bool step_begins() const;
     115              :                 bool step_ends() const;
     116              :         /** \} */
     117              : 
     118              :         ///     tells whether refinement / coarsening is adaptive (adaptive() == !global())
     119              :                 bool adaptive() const;
     120              : 
     121              :         ///     tells whether refinement / coarsening is global (global() == !adaptive())
     122              :                 bool global() const;
     123              : 
     124              :         ///     tells whether a step is a refinement step.
     125              :         /**     This is always false if adaption_begins() or adaption_ends() returns true*/
     126              :                 bool refinement() const;
     127              : 
     128              :         ///     tells whether a step is a coarsen step
     129              :         /**     This is always false if adaption_begins() or adaption_ends() returns true*/
     130              :                 bool coarsening() const;
     131              : 
     132              :         ///     returns the geometric-object-collection, which holds lists with affected elements.
     133              :         /**     - REFINEMENT_BEGINS: Elements on which new elements will occur or which are
     134              :          *                                               transformed to a new element type (e.g. constrained/constraining)
     135              :          *      - REFINEMENT_ENDS: Elements which were refined.
     136              :          *      - COARSENING_BEGINS: Elements which will be removed or replaced during coarsening
     137              :          *
     138              :          *      For all other adaption types, the geometric-object-collection should be empty and
     139              :          *      should be ignored.
     140              :          *
     141              :          *      \note   during refinement only elements on which a new child was actually created
     142              :          *                      are considered to be affected. Elements which were replaced by elements
     143              :          *                      of a different type are not considered in the list of affected elements.
     144              :          *
     145              :          *      \note   (THIS MAY CHANGE SOON!) Some of the elements marked for coarsening may
     146              :          *                      actually only be replaced by a normal/constraining/constrained element.
     147              :          *                      Note that elements may be marked during coarsening which actually have children
     148              :          *                      themselves, even if not all of those children are removed during coarsening
     149              :          *                      (e.g. edges which are replaced by constraining edges).*/
     150              :                 const GridObjectCollection& affected_elements() const {return m_affectedElements;}
     151              : 
     152              :         protected:
     153              :                 GridMessageAdaptionType         m_adaptionType;
     154              :                 GridObjectCollection    m_affectedElements;
     155              : };
     156              : 
     157              : 
     158              : ///     Instances of this class inform about distribution
     159              : enum GridMessageDistributionType{
     160              :         GMDT_NONE,
     161              :         GMDT_DISTRIBUTION_STARTS,
     162              :         GMDT_DISTRIBUTION_STOPS
     163              : };
     164              : 
     165              : class GridMessage_Distribution : public MessageHub::IMessage
     166              : {
     167              :         public:
     168              :                 GridMessage_Distribution(GridMessageDistributionType msg,
     169              :                                                                  GridDataSerializationHandler& gdsh) :
     170              :                         m_msg(msg),
     171              :                         m_serializationHandler(gdsh)
     172              :                 {}
     173              : 
     174            0 :                 GridMessageDistributionType msg() const {return m_msg;}
     175              : 
     176              :                 GridDataSerializationHandler& serialization_handler() const
     177              :                 {
     178              :                         return m_serializationHandler;
     179              :                 }
     180              : 
     181              :         private:
     182              :                 GridMessageDistributionType             m_msg;
     183              :                 GridDataSerializationHandler&       m_serializationHandler;
     184              : };
     185              : 
     186              : 
     187              : ///     Instances of this class inform about grid creation (e.g. during load or distribution)
     188              : enum GridMessageCreationType{
     189              :         GMCT_NONE,
     190              :         GMCT_CREATION_STARTS,
     191              :         GMCT_CREATION_STOPS
     192              : };
     193              : 
     194            0 : class GridMessage_Creation : public MessageHub::IMessage
     195              : {
     196              :         public:
     197            0 :                 GridMessage_Creation(GridMessageCreationType msg = GMCT_NONE, int procId = -1) :
     198            0 :                         m_msg(msg), m_procId(procId)    {}
     199              : 
     200            0 :                 GridMessageCreationType msg() const     {return m_msg;}
     201            0 :                 int proc_id() const                                     {return m_procId;}
     202              : 
     203              :         private:
     204              :                 GridMessageCreationType m_msg;
     205              :                 int m_procId;
     206              : };
     207              : 
     208              : }//     end of namespace
     209              : 
     210              : #endif
        

Generated by: LCOV version 2.0-1