Branch data Line data Source code
1 : : /* *****************************************************************
2 : : MESQUITE -- The Mesh Quality Improvement Toolkit
3 : :
4 : : Copyright 2007 Sandia National Laboratories. Developed at the
5 : : University of Wisconsin--Madison under SNL contract number
6 : : 624796. The U.S. Government and the University of Wisconsin
7 : : retain certain rights to this software.
8 : :
9 : : This library is free software; you can redistribute it and/or
10 : : modify it under the terms of the GNU Lesser General Public
11 : : License as published by the Free Software Foundation; either
12 : : version 2.1 of the License, or (at your option) any later version.
13 : :
14 : : This library is distributed in the hope that it will be useful,
15 : : but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 : : Lesser General Public License for more details.
18 : :
19 : : You should have received a copy of the GNU Lesser General Public License
20 : : (lgpl.txt) along with this library; if not, write to the Free Software
21 : : Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 : :
23 : : (2009) [email protected]
24 : :
25 : : ***************************************************************** */
26 : :
27 : : /** \file Settings.cpp
28 : : * \brief
29 : : * \author Jason Kraftcheck
30 : : */
31 : :
32 : : #include "Mesquite.hpp"
33 : : #include "Settings.hpp"
34 : : #include "TriLagrangeShape.hpp"
35 : : #include "QuadLagrangeShape.hpp"
36 : : #include "TetLagrangeShape.hpp"
37 : : #include "LinearPyramid.hpp"
38 : : #include "LinearPrism.hpp"
39 : : #include "LinearHexahedron.hpp"
40 : :
41 : : namespace MBMesquite
42 : : {
43 : :
44 : : #ifdef MSQ_TRAP_FPE
45 : : const bool IQ_TRAP_FPE_DEFAULT = true;
46 : : #else
47 : : const bool IQ_TRAP_FPE_DEFAULT = false;
48 : : #endif
49 : :
50 : 392 : struct SettingData
51 : : {
52 : : SettingData(); //!< Initialize to default settings.
53 : : SettingData( const SettingData& other );
54 : : SettingData& operator=( const SettingData& other );
55 : : bool trapFPE;
56 : : Settings::FixedVertexMode fixedMode;
57 : : Settings::HigherOrderSlaveMode slaveMode;
58 : : std::vector< const MappingFunction* > mapArray;
59 : : std::vector< const MappingFunction2D* > mapArray2D;
60 : : std::vector< const MappingFunction3D* > mapArray3D;
61 : :
62 : : TriLagrangeShape defTriFunc;
63 : : QuadLagrangeShape defQuadFunc;
64 : : TetLagrangeShape defTetFunc;
65 : : LinearPyramid defPyrFunc;
66 : : LinearPrism defPriFunc;
67 : : LinearHexahedron defHexFunc;
68 : :
69 : : private:
70 : : void fix_copy( const SettingData& other );
71 : : };
72 : :
73 : 196 : SettingData::SettingData()
74 : : : trapFPE( IQ_TRAP_FPE_DEFAULT ), fixedMode( Settings::FIXED_FLAG ), slaveMode( Settings::SLAVE_ALL ),
75 [ + - ][ + - ]: 196 : mapArray( MIXED, 0 ), mapArray2D( MIXED, 0 ), mapArray3D( MIXED, 0 )
[ + - ]
76 : : {
77 [ + - ]: 196 : mapArray[TRIANGLE] = &defTriFunc;
78 [ + - ]: 196 : mapArray[QUADRILATERAL] = &defQuadFunc;
79 [ + - ]: 196 : mapArray[TETRAHEDRON] = &defTetFunc;
80 [ + - ]: 196 : mapArray[PYRAMID] = &defPyrFunc;
81 [ + - ]: 196 : mapArray[PRISM] = &defPriFunc;
82 [ + - ]: 196 : mapArray[HEXAHEDRON] = &defHexFunc;
83 [ + - ]: 196 : mapArray2D[TRIANGLE] = &defTriFunc;
84 [ + - ]: 196 : mapArray2D[QUADRILATERAL] = &defQuadFunc;
85 [ + - ]: 196 : mapArray3D[TETRAHEDRON] = &defTetFunc;
86 [ + - ]: 196 : mapArray3D[PYRAMID] = &defPyrFunc;
87 [ + - ]: 196 : mapArray3D[PRISM] = &defPriFunc;
88 [ + - ]: 196 : mapArray3D[HEXAHEDRON] = &defHexFunc;
89 : 196 : }
90 : :
91 : 0 : SettingData::SettingData( const SettingData& other )
92 : : : trapFPE( other.trapFPE ), fixedMode( other.fixedMode ), slaveMode( other.slaveMode ), mapArray( other.mapArray ),
93 [ # # ][ # # ]: 0 : mapArray2D( other.mapArray2D ), mapArray3D( other.mapArray3D )
94 : : {
95 [ # # ]: 0 : fix_copy( other );
96 : 0 : }
97 : :
98 : 0 : SettingData& SettingData::operator=( const SettingData& other )
99 : : {
100 : 0 : trapFPE = other.trapFPE;
101 : 0 : fixedMode = other.fixedMode;
102 : 0 : slaveMode = other.slaveMode;
103 : 0 : mapArray = other.mapArray;
104 : 0 : mapArray2D = other.mapArray2D;
105 : 0 : mapArray3D = other.mapArray3D;
106 : 0 : fix_copy( other );
107 : 0 : return *this;
108 : : }
109 : :
110 : 0 : void SettingData::fix_copy( const SettingData& other )
111 : : {
112 [ # # ]: 0 : if( mapArray[TRIANGLE] == &other.defTriFunc ) mapArray[TRIANGLE] = &defTriFunc;
113 [ # # ]: 0 : if( mapArray[QUADRILATERAL] == &other.defQuadFunc ) mapArray[QUADRILATERAL] = &defQuadFunc;
114 [ # # ]: 0 : if( mapArray[TETRAHEDRON] == &other.defTetFunc ) mapArray[TETRAHEDRON] = &defTetFunc;
115 [ # # ]: 0 : if( mapArray[PYRAMID] == &other.defPyrFunc ) mapArray[PYRAMID] = &defPyrFunc;
116 [ # # ]: 0 : if( mapArray[PRISM] == &other.defPriFunc ) mapArray[PRISM] = &defPriFunc;
117 [ # # ]: 0 : if( mapArray[HEXAHEDRON] == &other.defHexFunc ) mapArray[HEXAHEDRON] = &defHexFunc;
118 [ # # ]: 0 : if( mapArray2D[TRIANGLE] == &other.defTriFunc ) mapArray2D[TRIANGLE] = &defTriFunc;
119 [ # # ]: 0 : if( mapArray2D[QUADRILATERAL] == &other.defQuadFunc ) mapArray2D[QUADRILATERAL] = &defQuadFunc;
120 [ # # ]: 0 : if( mapArray3D[TETRAHEDRON] == &other.defTetFunc ) mapArray3D[TETRAHEDRON] = &defTetFunc;
121 [ # # ]: 0 : if( mapArray3D[PYRAMID] == &other.defPyrFunc ) mapArray3D[PYRAMID] = &defPyrFunc;
122 [ # # ]: 0 : if( mapArray3D[PRISM] == &other.defPriFunc ) mapArray3D[PRISM] = &defPriFunc;
123 [ # # ]: 0 : if( mapArray3D[HEXAHEDRON] == &other.defHexFunc ) mapArray3D[HEXAHEDRON] = &defHexFunc;
124 : 0 : }
125 : :
126 [ + - ]: 196 : Settings::Settings() : mData( new SettingData ) {}
127 [ # # ]: 0 : Settings::Settings( const Settings& other ) : mData( new SettingData( *other.mData ) ) {}
128 : 196 : Settings::~Settings()
129 : : {
130 [ + - ]: 196 : delete mData;
131 : 196 : }
132 : 0 : Settings& Settings::operator=( const Settings& other )
133 : : {
134 : 0 : *mData = *( other.mData );
135 : 0 : return *this;
136 : : }
137 : :
138 : 0 : void Settings::set_mapping_function( const MappingFunction* func )
139 : : {
140 : 0 : EntityTopology type = func->element_topology();
141 [ # # ][ # # ]: 0 : if( mData->mapArray.size() <= (size_t)type ) mData->mapArray.resize( type + 1, 0 );
142 : 0 : mData->mapArray[type] = func;
143 [ # # ][ # # ]: 0 : if( TopologyInfo::dimension( type ) == 2 && mData->mapArray2D.size() > (size_t)type )
[ # # ]
144 : 0 : mData->mapArray2D[type] = 0;
145 [ # # ][ # # ]: 0 : else if( TopologyInfo::dimension( type ) == 3 && mData->mapArray3D.size() > (size_t)type )
[ # # ]
146 : 0 : mData->mapArray3D[type] = 0;
147 : 0 : }
148 : :
149 : 2 : void Settings::set_mapping_function( const MappingFunction2D* func )
150 : : {
151 : 2 : unsigned type = func->element_topology();
152 [ - + ][ # # ]: 2 : if( mData->mapArray.size() <= type ) mData->mapArray.resize( type + 1, 0 );
153 : 2 : mData->mapArray[type] = func;
154 [ - + ][ # # ]: 2 : if( mData->mapArray2D.size() <= type ) mData->mapArray2D.resize( type + 1, 0 );
155 : 2 : mData->mapArray2D[type] = func;
156 : 2 : }
157 : :
158 : 0 : void Settings::set_mapping_function( const MappingFunction3D* func )
159 : : {
160 : 0 : unsigned type = func->element_topology();
161 [ # # ][ # # ]: 0 : if( mData->mapArray.size() <= type ) mData->mapArray.resize( type + 1, 0 );
162 : 0 : mData->mapArray[type] = func;
163 [ # # ][ # # ]: 0 : if( mData->mapArray3D.size() <= type ) mData->mapArray3D.resize( type + 1, 0 );
164 : 0 : mData->mapArray3D[type] = func;
165 : 0 : }
166 : :
167 : 0 : void Settings::set_mapping_functions( const MappingFunction* const* array, size_t array_len )
168 : : {
169 [ # # ]: 0 : for( size_t i = 0; i < array_len; ++i )
170 : 0 : set_mapping_function( array[i] );
171 : 0 : }
172 : 0 : void Settings::set_mapping_functions( const MappingFunction2D* const* array, size_t array_len )
173 : : {
174 [ # # ]: 0 : for( size_t i = 0; i < array_len; ++i )
175 : 0 : set_mapping_function( array[i] );
176 : 0 : }
177 : 0 : void Settings::set_mapping_functions( const MappingFunction3D* const* array, size_t array_len )
178 : : {
179 [ # # ]: 0 : for( size_t i = 0; i < array_len; ++i )
180 : 0 : set_mapping_function( array[i] );
181 : 0 : }
182 : :
183 : 8125345 : const MappingFunction* Settings::get_mapping_function( EntityTopology type ) const
184 : : {
185 [ + - ]: 8125345 : return (size_t)type < mData->mapArray.size() ? mData->mapArray[type] : 0;
186 : : }
187 : :
188 : 20205940 : const MappingFunction2D* Settings::get_mapping_function_2D( EntityTopology type ) const
189 : : {
190 [ + - ]: 20205940 : return (size_t)type < mData->mapArray2D.size() ? mData->mapArray2D[type] : 0;
191 : : }
192 : :
193 : 7808570 : const MappingFunction3D* Settings::get_mapping_function_3D( EntityTopology type ) const
194 : : {
195 [ + - ]: 7808570 : return (size_t)type < mData->mapArray3D.size() ? mData->mapArray3D[type] : 0;
196 : : }
197 : :
198 : 0 : void Settings::set_fixed_vertex_mode( Settings::FixedVertexMode mode )
199 : : {
200 : 0 : mData->fixedMode = mode;
201 : 0 : }
202 : :
203 : 273 : Settings::FixedVertexMode Settings::get_fixed_vertex_mode() const
204 : : {
205 : 273 : return mData->fixedMode;
206 : : }
207 : :
208 : 9 : void Settings::set_slaved_ho_node_mode( Settings::HigherOrderSlaveMode mode )
209 : : {
210 : 9 : mData->slaveMode = mode;
211 : 9 : }
212 : :
213 : 549 : Settings::HigherOrderSlaveMode Settings::get_slaved_ho_node_mode() const
214 : : {
215 : 549 : return mData->slaveMode;
216 : : }
217 : :
218 : 0 : void Settings::trap_floating_point_exception( bool enable )
219 : : {
220 : 0 : mData->trapFPE = enable;
221 : 0 : }
222 : 138 : bool Settings::trap_floating_point_exception() const
223 : : {
224 : 138 : return mData->trapFPE;
225 : : }
226 : :
227 : : } // namespace MBMesquite
|