moab
RefinerTagManager.hpp
Go to the documentation of this file.
00001 /*
00002  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
00003  * storing and accessing finite element mesh data.
00004  * 
00005  * Copyright 2004 Sandia Corporation.  Under the terms of Contract
00006  * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government
00007  * retains certain rights in this software.
00008  * 
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  * 
00014  */
00015 
00016 #ifndef MOAB_REFINER_TAG_MANAGER_HPP
00017 #define MOAB_REFINER_TAG_MANAGER_HPP
00018 
00019 #include "moab/Types.hpp" // for MB_DLL_EXPORT
00020 
00021 #include "ProcessSet.hpp"
00022 
00023 #include <vector>
00024 
00025 namespace moab {
00026 
00027 class Interface;
00028 
00038 class MB_DLL_EXPORT RefinerTagManager
00039 {
00040 public:
00041   RefinerTagManager( Interface* in_mesh, Interface* out_mesh );
00042   virtual ~RefinerTagManager();
00043 
00044   void reset_vertex_tags();
00045   int add_vertex_tag( Tag tag_handle );
00046   int get_vertex_tag_size() const { return this->vertex_size; }
00047   int get_number_of_vertex_tags() const { return this->input_vertex_tags.size(); }
00048 
00049   void reset_element_tags();
00050   int add_element_tag( Tag tag_handle );
00051   int get_element_tag_size() const { return this->element_size; }
00052   int get_number_of_element_tags() const { return this->input_element_tags.size(); }
00053 
00054   void create_output_tags();
00055 
00056   void get_input_vertex_tag( int i, Tag& tag, int& byte_offset );
00057   void get_output_vertex_tag( int i, Tag& tag, int& byte_offset );
00058 
00059   void get_input_element_tag( int i, Tag& tag, int& byte_offset );
00060   void get_output_element_tag( int i, Tag& tag, int& byte_offset );
00061 
00062   Interface* get_input_mesh() { return this->input_mesh; }
00063   Interface* get_output_mesh() { return this->output_mesh; }
00064 
00065   Tag input_parallel_status() { return this->tag_ipstatus; }
00066   Tag input_shared_proc() { return this->tag_ipsproc; }
00067   Tag input_shared_procs() { return this->tag_ipsprocs; }
00068 
00069   int get_input_gids( int n, const EntityHandle* ents, std::vector<int>& gids );
00070   int get_output_gids( int n, const EntityHandle* ents, std::vector<int>& gids );
00071   int set_gid( EntityHandle ent, int gid );
00072   int copy_gid( EntityHandle ent_input, EntityHandle ent_output );
00073 
00074   void set_sharing( EntityHandle ent_handle, ProcessSet& procs );
00075   void get_common_processes( int num, const EntityHandle* src, ProcessSet& common_shared_procs, bool on_output_mesh = true );
00076 
00077   void set_element_tags_from_ent( EntityHandle ent_input );
00078   void assign_element_tags( EntityHandle ent_output );
00079 
00080   void set_element_procs_from_ent( EntityHandle ent_input )
00081     {
00082     this->get_common_processes( 1, &ent_input, this->current_element_procs, false );
00083     }
00084   ProcessSet& get_element_procs()
00085     {
00086     return this->current_element_procs;
00087     }
00088   void set_element_sharing( EntityHandle ent_output )
00089     {
00090     this->set_sharing( ent_output, this->current_element_procs );
00091     }
00092 
00093 protected:
00094   void create_tag_internal( Tag, int );
00095 
00096   std::vector< std::pair< Tag, int > > input_vertex_tags;
00097   std::vector< std::pair< Tag, int > > output_vertex_tags;
00098   std::vector< std::pair< Tag, int > > input_element_tags;
00099   std::vector< std::pair< Tag, int > > output_element_tags;
00100   int vertex_size;
00101   int element_size;
00102   Interface* input_mesh;
00103   Interface* output_mesh;
00104   Tag tag_ipstatus; // Handle for PARALLEL_STATUS on mesh_in
00105   Tag tag_ipsprocs; // Handle for PARALLEL_SHARED_PROCS on mesh_in
00106   Tag tag_ipsproc;  // Handle for PARALLEL_SHARED_PROC on mesh_in
00107   Tag tag_ipshands; // Handle for PARALLEL_SHARED_HANDLES on mesh_in
00108   Tag tag_ipshand;  // Handle for PARALLEL_SHARED_HANDLE on mesh_in
00109   Tag tag_igid;     // Handle for global IDs on mesh_in
00110   Tag tag_opstatus; // Handle for PARALLEL_STATUS on mesh_out
00111   Tag tag_opsprocs; // Handle for PARALLEL_SHARED_PROCS on mesh_out
00112   Tag tag_opsproc;  // Handle for PARALLEL_SHARED_PROC on mesh_out
00113   Tag tag_opshands; // Handle for PARALLEL_SHARED_HANDLES on mesh_out
00114   Tag tag_opshand;  // Handle for PARALLEL_SHARED_HANDLE on mesh_out
00115   Tag tag_ogid;     // Handle for global IDs on mesh_out
00116   int rank;
00117   std::vector<int> shared_procs_in; // Used to hold procs sharing an input vert.
00118   std::vector<int> shared_procs_out; // Used to hold procs sharing an output entity.
00119   ProcessSet current_shared_procs; // Holds process list as it is being accumulated
00120   ProcessSet current_element_procs; // The list of processes which should share an output element.
00121   std::vector<char> element_tag_data; // Holds tag data for per-element tags
00122 };
00123 
00124 } // namespace moab
00125 
00126 #endif // MOAB_REFINER_TAG_MANAGER_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines