⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mesh_base.h

📁 一个用来实现偏微分方程中网格的计算库
💻 H
📖 第 1 页 / 共 2 页
字号:
// $Id: mesh_base.h 2803 2008-04-23 21:14:29Z roystgnr $// The libMesh Finite Element Library.// Copyright (C) 2002-2007  Benjamin S. Kirk, John W. Peterson  // This library 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 2.1 of the License, or (at your option) any later version.  // This library 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 this library; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA#ifndef __mesh_base_h__#define __mesh_base_h__// C++ Includes   -----------------------------------#include <string>// forward declarationsclass Elem;class Node;class Point;class Partitioner;class BoundaryInfo;class PointLocatorBase;class MeshData;// Local Includes -----------------------------------#include "auto_ptr.h"#include "dof_object.h" // for invalid_processor_id#include "enum_elem_type.h"#include "libmesh_common.h"#include "multi_predicates.h"#include "variant_filter_iterator.h"/** * This is the \p MeshBase class. This class provides all the data necessary * to describe a geometric entity.  It allows for the description of a * \p dim dimensional object that lives in \p DIM-dimensional space. * \par * A mesh is made of nodes and elements, and this class provides data * structures to store and access both.  A mesh may be partitioned into a * number of subdomains, and this class provides that functionality. * Furthermore, this class provides functions for reading and writing a * mesh to disk in various formats. * * \author  Benjamin S. Kirk * \date    $Date: 2008-04-23 16:14:29 -0500 (Wed, 23 Apr 2008) $ * \version $Revision: 2803 $ */// ------------------------------------------------------------// MeshBase class definitionclass MeshBase{public:  /**   * Constructor.  Requires \p d, the dimension of the mesh.   */  MeshBase (unsigned int d);    /**   * Copy-constructor.   */  MeshBase (const MeshBase& other_mesh);  /**   * Virtual "copy constructor"   */  virtual AutoPtr<MeshBase> clone() const = 0;  /**   * Destructor.   */  virtual ~MeshBase ();  /**   * This class holds the boundary information.  It can store nodes, edges,   * and faces with a corresponding id that facilitates setting boundary   * conditions.   */  AutoPtr<BoundaryInfo> boundary_info;    /**   * Deletes all the data that are currently stored.   */  virtual void clear ();    /**   * @returns \p true if the mesh has been prepared via a call   * to \p prepare_for_use, \p false otherwise.   */  bool is_prepared () const  { return _is_prepared; }    /**   * @returns \p true if all elements and nodes of the mesh   * exist on the current processor, \p false otherwise   */  virtual bool is_serial () const   { return true; }    /**   * @gathers all elements and nodes of the mesh onto   * every processor   */  virtual void allgather () {}    /**   * @when supported, deletes all nonlocal elements of the mesh   * except for "ghosts" which touch a local element, and deletes   * all nodes which are not part of a local or ghost element   */  virtual void delete_remote_elements () {}    /**   * Returns the logical dimension of the mesh.   */  unsigned int mesh_dimension () const  { return static_cast<unsigned int>(_dim); }    /**   * Returns the spatial dimension of the mesh.  Note that this is   * defined at compile time in the header \p libmesh_common.h.   */  unsigned int spatial_dimension () const  { return static_cast<unsigned int>(DIM); }    /**   * Returns the number of nodes in the mesh. This function and others must   * be defined in derived classes since the MeshBase class has no specific   * storage for nodes or elements.   */  virtual unsigned int n_nodes () const = 0;   /**   * Returns the number of nodes on processor \p proc.   */  unsigned int n_nodes_on_proc (const unsigned int proc) const;  /**   * Returns the number of nodes on the local processor.   */  unsigned int n_local_nodes () const  { return this->n_nodes_on_proc (libMesh::processor_id()); }  /**   * Returns the number of nodes owned by no processor.   */  unsigned int n_unpartitioned_nodes () const  { return this->n_nodes_on_proc (DofObject::invalid_processor_id); }  /**   * Returns a number greater than or equal to the maximum node id in the   * mesh.   */  virtual unsigned int max_node_id () const = 0;  /**   * Reserves space for a known number of nodes.   * Note that this method may or may not do anything, depending   * on the actual \p Mesh implementation.  If you know the number   * of nodes you will add and call this method before repeatedly   * calling \p add_point() the implementation will be more efficient.   */  virtual void reserve_nodes (const unsigned int nn) = 0;     /**   * Returns the number of elements in the mesh.   */  virtual unsigned int n_elem () const = 0;   /**   * Returns a number greater than or equal to the maximum element id in the   * mesh.   */  virtual unsigned int max_elem_id () const = 0;  /**   * Reserves space for a known number of elements.   * Note that this method may or may not do anything, depending   * on the actual \p Mesh implementation.  If you know the number   * of elements you will add and call this method before repeatedly   * calling \p add_point() the implementation will be more efficient.   */  virtual void reserve_elem (const unsigned int ne) = 0;   /**   * Updates parallel caches so that methods like n_elem()    * accurately reflect changes on other processors   */  virtual void update_parallel_id_counts () = 0;  /**   * Returns the number of active elements in the mesh.  Implemented   * in terms of active_element_iterators.   */  unsigned int n_active_elem () const;  /**   * Returns the number of elements on processor \p proc.   */  unsigned int n_elem_on_proc (const unsigned int proc) const;  /**   * Returns the number of elements on the local processor.   */  unsigned int n_local_elem () const  { return this->n_elem_on_proc (libMesh::processor_id()); }  /**   * Returns the number of elements owned by no processor.   */  unsigned int n_unpartitioned_elem () const  { return this->n_elem_on_proc (DofObject::invalid_processor_id); }  /**   * Returns the number of active elements on processor \p proc.   */  unsigned int n_active_elem_on_proc (const unsigned int proc) const;  /**   * Returns the number of active elements on the local processor.   */  unsigned int n_active_local_elem () const  { return this->n_active_elem_on_proc (libMesh::processor_id()); }    /**   * This function returns the number of elements that will be written   * out in the Tecplot format.  For example, a 9-noded quadrilateral will   * be broken into 4 linear sub-elements for plotting purposes.  Thus, for   * a mesh of 2 \p QUAD9 elements  \p n_tecplot_elem() will return 8.   * Implemented in terms of element_iterators.   */  unsigned int n_sub_elem () const;  /**   * Same, but only counts active elements.   */  unsigned int n_active_sub_elem () const;    /**   * Return a constant reference (for reading only) to the   * \f$ i^{th} \f$ point.   */    virtual const Point& point (const unsigned int i) const = 0;  /**   * Return a constant reference (for reading only) to the   * \f$ i^{th} \f$ node.   */    virtual const Node& node (const unsigned int i) const = 0;    /**   * Return a reference to the \f$ i^{th} \f$ node.   */    virtual Node& node (const unsigned int i) = 0;    /**   * Return a pointer to the \f$ i^{th} \f$ node.   */    virtual const Node* node_ptr (const unsigned int i) const = 0;  /**   * Return a pointer to the \f$ i^{th} \f$ node.   */    virtual Node* & node_ptr (const unsigned int i) = 0;  /**   * Return a pointer to the \f$ i^{th} \f$ element.   */  virtual Elem* elem (const unsigned int i) const = 0;  /**   * Add a new \p Node at \p Point \p p to the end of the vertex array,   * with processor_id \p procid.   * Use DofObject::invalid_processor_id (default) to add a node to all   * processors, or libMesh::processor_id() to add a node to the local   * processor only.   * If adding a node locally, passing an \p id other than   * DofObject::invalid_id will set that specific node id.  Only   * do this in parallel if you are manually keeping ids consistent.   */  virtual Node* add_point (const Point& p,			   const unsigned int id = DofObject::invalid_id,			   const unsigned int proc_id =			     DofObject::invalid_processor_id) = 0;  /**   * Add \p Node \p n to the end of the vertex array.   */  virtual Node* add_node (Node* n) = 0;  /**   * Removes the Node n from the mesh.   */  virtual void delete_node (Node* n) = 0;    /**   * Changes the id of node \p old_id, both by changing node(old_id)->id() and   * by moving node(old_id) in the mesh's internal container.  No element with   * the id \p new_id should already exist.   */  virtual void renumber_node (unsigned int old_id, unsigned int new_id) = 0;		        /**   * Add elem \p e to the end of the element array.   * To add an element locally, set e->processor_id() before adding it.   * To ensure a specific element id, call e->set_id() before adding it;   * only do this in parallel if you are manually keeping ids consistent.   */  virtual Elem* add_elem (Elem* e) = 0;  /**   * Insert elem \p e to the element array, preserving its id   * and replacing/deleting any existing element with the same id.   */  virtual Elem* insert_elem (Elem* e) = 0;  /**   * Removes element \p e from the mesh. Note that calling this   * method may produce isolated nodes, i.e. nodes not connected   * to any element.  This method must be implemented in derived classes   * in such a way that it does not invalidate element iterators.   */  virtual void delete_elem (Elem* e) = 0;  /**   * Changes the id of element \p old_id, both by changing elem(old_id)->id()   * and by moving elem(old_id) in the mesh's internal container.  No element   * with the id \p new_id should already exist.   */  virtual void renumber_elem (unsigned int old_id, unsigned int new_id) = 0;  /**   * Locate element face (edge in 2D) neighbors.  This is done with the help   * of a \p std::map that functions like a hash table.     * After this routine is called all the elements with a \p NULL neighbor   * pointer are guaranteed to be on the boundary.  Thus this routine is   * useful for automatically determining the boundaries of the domain.   * If reset_remote_elements is left to false, remote neighbor links are not   * reset and searched for in the local mesh.   */  virtual void find_neighbors (bool reset_remote_elements = false) = 0;    /**   * After partitoning a mesh it is useful to renumber the nodes and elements   * so that they lie in contiguous blocks on the processors.  This method   * does just that.   */  virtual void renumber_nodes_and_elements () = 0;    #ifdef ENABLE_AMR  /**   * Delete subactive (i.e. children of coarsened) elements.   * This removes all elements descended from currently active   * elements in the mesh.   */  virtual bool contract () = 0;#endif  /**   * Prepare a newly created (or read) mesh for use.   * This involves 3 steps:   *  1.) call \p find_neighbors()   *  2.) call \p partition()   *  3.) call \p renumber_nodes_and_elements()    *   * The read_xda_file boolean flag is true when prepare_for_use   * is called from Mesh::read after reading an xda file.  It prevents   * the renumbering of nodes and elements.  In general, leave this at   * the default value of false.   */  void prepare_for_use (const bool skip_renumber_nodes_and_elements=false);    /**   * Call the default partitioner (currently \p metis_partition()).   */  void partition (const unsigned int n_parts=libMesh::n_processors());    /**   * Returns the number of subdomains in the global mesh. Note that it is   * convenient to have one subdomain on each processor on parallel machines,   * however this is not required. Multiple subdomains can exist on the same   * processor.   */  unsigned int n_subdomains () const  { return _n_sbd; }  /**   * Returns the number of partitions which have been defined via   * a call to either mesh.partition() or by building a Partitioner   * object and calling partition.  Note that the partitioner objects   * are responsible for setting this value.   */  unsigned int n_partitions () const  { return _n_parts; }    /**   * @returns the number of processors used in the   * current simulation.   */  unsigned int n_processors () const  { return libMesh::n_processors(); }  /**   * @returns the subdomain id for this processor.   */  unsigned int processor_id () const

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -