Branch data Line data Source code
1 : : #ifndef MESHKIT_MESQUITE_OPT_HPP
2 : : #define MESHKIT_MESQUITE_OPT_HPP
3 : :
4 : : #include "MKVersion.h"
5 : : #include "moab/mesquite/IQInterface.hpp"
6 : : #include "meshkit/MeshOp.hpp"
7 : : #include "iBase.h"
8 : :
9 : : namespace MeshKit {
10 : :
11 : : /**\brief Base class for creating MeshOps that call Mesquite smoother
12 : : *
13 : : * This class can be used to either create a MeshOp
14 : : * from any custom Mesquite algorithm or Mesquite wrapper,
15 : : * or as a base class for MeshOp classes that implement
16 : : * a specific Mesquite algorithm.
17 : : */
18 [ - + ]: 4 : class MesquiteOpt : public MeshOp
19 : : {
20 : : public:
21 : :
22 : : MesquiteOpt( MKCore* core, const MEntVector &me_vec = MEntVector());
23 : :
24 : : /**\brief Get class name */
25 : : static const char* name();
26 : :
27 : : /**\brief specify mesquite optimization algorithm to execute */
28 : : void set_mesquite_op( MESQUITE_NS::IQInterface* msq_algo ) { msqAlgo = msq_algo; }
29 : :
30 : : /**\brief Get handle of tag used to designate vertices as fixed */
31 : : iBase_TagHandle get_fixed_tag();
32 : :
33 : : /**\brief Set handle of tag used to designate vertices as fixed */
34 : : void set_fixed_tag( iBase_TagHandle tag );
35 : :
36 : : /**\brief Set handle of tag used to designate vertices as fixed
37 : : *
38 : : * Tag will be created if it does not already exists. If
39 : : * tag already exists then it must be a single integer value.
40 : : */
41 : : void set_fixed_tag( const char* name );
42 : :
43 : : /**\brief smooth only interior of mesh
44 : : *
45 : : * This is the default behavior
46 : : */
47 : : void smooth_with_fixed_boundary();
48 : :
49 : : /**\brief smooth interior and exiterior of mesh
50 : : *
51 : : * This method will throw an exception if Mesquite is
52 : : * configured w/out iRel support or the boundary of the
53 : : * mesh is not constrained to geometric entities.
54 : : */
55 : : void smooth_with_free_boundary();
56 : :
57 : : /* virtual functions from MeshOp */
58 : : virtual void setup_this();
59 : : virtual void execute_this();
60 : 0 : virtual const moab::EntityType* mesh_types_arr() const
61 : 0 : { return output_types(); }
62 : :
63 : : /* pseudo-virtual functions from MeshOpProxy */
64 : : static const moab::EntityType* output_types();
65 : : static bool can_mesh( iBase_EntityType dimension );
66 : : static bool can_mesh( ModelEnt* entity );
67 : :
68 : 2 : void print_quality( bool yesno )
69 : 2 : { verboseOutput = yesno; }
70 : :
71 : : protected:
72 : :
73 : : /** Create Mesquite's internal-use tag for it so that we can
74 : : * create it as a dense tag.
75 : : */
76 : : void create_byte_tag();
77 : :
78 : : /**\brief Set fixed tag on vertices of ModelEnt's mesh entities
79 : : *\param ent Entity for which to set 'fixed' tag on vertices of
80 : : * all owned elements.
81 : : *\param value Value to set 'fixed' tag to. Should be either zero
82 : : * or one, corresponding to free or fixed, respectively.
83 : : */
84 : : void set_fixed_tag( ModelEnt* ent, int value );
85 : :
86 : : /**\brief Set fixed tag on boundary of ModelEnt's mesh
87 : : *\param ent Entity for which to set 'fixed' tag on vertices of boundary
88 : : *\param value Value to set 'fixed' tag to. Should be either zero
89 : : * or one, corresponding to free or fixed, respectively.
90 : : */
91 : : void set_fixed_tag_on_skin( ModelEnt* ent, int value );
92 : :
93 : : /**\brief Verify that all model entities have associated geometry
94 : : */
95 : : bool all_model_ents_have_geom() const;
96 : :
97 : : /**\brief Helper function for free smooth of multiple entities
98 : : *
99 : : * For proper results when doing a free smooth of multiple model
100 : : * entities, the mesh for all model entities connected by a curve
101 : : * or surface should be smoothed together. This finds a single
102 : : * connected group of ModelEnts in \c from_this, removes them from
103 : : * \c from_this, and creates a single \c iBase_EntitySetHandle
104 : : * containing the mesh of all of the ModelEnts in the connected set.
105 : : *
106 : : *\param from_this Set of ModelEnts in which to search for a group
107 : : * of connected ModelEnts. Connected ModelEnts are
108 : : * _removed_ from the passed MEntSet.
109 : : *\param smooth_ents List of connected entities that are to be
110 : : * smoothed together.
111 : : *\param result An iBase_EntitySetHandle corresponding to a set
112 : : * that contains all of the mesh entities of all
113 : : * of the connected ModelEnts removed from \c from_this
114 : : *\param dimension If all connected ModelEnts have the same dimension,
115 : : * that dimension. Otherwise iBase_ALL_TYPES.
116 : : *\param created_result_set True if the function created a new
117 : : * iBase_EntitySetHandle. Will be false if the
118 : : * set corresponds to a single ModelEnt that was
119 : : * connected to no others, in which case the returned
120 : : * set is just that of the ModelEnt.
121 : : */
122 : : void get_adjacent_entity_set( MEntSet& from_this,
123 : : MEntVector& smooth_ents,
124 : : iBase_EntitySetHandle& result,
125 : : iBase_EntityType& dimension,
126 : : bool& created_result_set );
127 : :
128 : : /**\brief Change relation on iMesh side to BOTH-type.
129 : : *
130 : : * Doing a free smooth of geometry with Mesquite requires
131 : : * that Mesquite be able to query iRel for a iGeom handle
132 : : * corresponding to vertex and elemet handles. This requires
133 : : * a 'BOTH' relation on the iMesh side.
134 : : */
135 : : void set_irel_both_relation();
136 : :
137 : : private:
138 : :
139 : : MESQUITE_NS::IQInterface* msqAlgo;
140 : : bool fixedBoundary;
141 : : bool haveFixedTag;
142 : : bool createdByteTag;
143 : : bool verboseOutput;
144 : : iBase_TagHandle fixedTag;
145 : : };
146 : :
147 : 40 : inline const char* MesquiteOpt::name()
148 : : {
149 : 40 : return "MesquiteOpt";
150 : : }
151 : :
152 : :
153 : :
154 : : }
155 : :
156 : :
157 : : #endif // MESHKIT_MESQUITE_OPT_HPP
|