36 #include "Vector3D.hpp"
38 #include "QualityMetric.hpp"
39 #include "MsqTimer.hpp"
40 #include "MsqDebug.hpp"
43 #ifdef MSQ_USE_OLD_STD_HEADERS
50 using namespace Mesquite;
65 static const int locs_hex[8][4] = {{0, 1, 3, 4},
79 bool metric_valid =
false;
88 if (!metric_valid)
return false;
93 for (i = 0; i < 4; ++
i) {
95 mCoords[0] = vertices[v_i[locs_hex[
i][0]]];
96 mCoords[1] = vertices[v_i[locs_hex[
i][1]]];
97 mCoords[2] = vertices[v_i[locs_hex[
i][2]]];
100 if (!metric_valid)
return false;
111 if (!metric_valid)
return false;
115 for (i = 0; i < 8; ++
i) {
116 mCoords[0] = vertices[v_i[locs_hex[
i][0]]];
117 mCoords[1] = vertices[v_i[locs_hex[
i][1]]];
118 mCoords[2] = vertices[v_i[locs_hex[
i][2]]];
119 mCoords[3] = vertices[v_i[locs_hex[
i][3]]];
122 if (!metric_valid)
return false;
147 "Minimum and maximum not continuously differentiable.\n"
148 "Element of subdifferential will be returned.\n");
159 static const int locs_hex[8][4] = {{0, 1, 3, 4},
168 const Vector3D d_con(1.0, 1.0, 1.0);
172 bool metric_valid =
false;
173 int vert_per_elem = 0;
192 for (i = 0; i < 4; ++
i) {
195 mCoords[0] = vertices[v_i[locs_hex[
i][0]]];
196 mCoords[1] = vertices[v_i[locs_hex[
i][1]]];
197 mCoords[2] = vertices[v_i[locs_hex[
i][2]]];
203 for (i = 0; i < 4; ++
i)
219 if (!metric_valid)
return false;
225 for (i = 0; i < 8; ++
i) {
228 mCoords[0] = vertices[v_i[locs_hex[
i][0]]];
229 mCoords[1] = vertices[v_i[locs_hex[
i][1]]];
230 mCoords[2] = vertices[v_i[locs_hex[
i][2]]];
231 mCoords[3] = vertices[v_i[locs_hex[
i][3]]];
237 for (i = 0; i < 8; ++
i)
252 for (i = 0; i < vert_per_elem; ++
i) {
253 for (j = 0; j < nv; ++
j) {
254 if (vertices + v_i[i] == v[j]) {
280 "Minimum and maximum not continuously differentiable.\n"
281 "Element of subdifferential will be returned.\n"
282 "Who knows what the Hessian is?\n" );
292 static const int locs_hex[8][4] = {{0, 1, 3, 4},
301 const Vector3D d_con(1.0, 1.0, 1.0);
306 bool metric_valid =
false;
321 for (i = 0; i < 3; ++
i) {
323 if (vertices + v_i[i] == fv[j] )
346 for (i=0; i < 10; ++
i) {
351 for (i = 0; i < 4; ++
i) {
355 mCoords[0] = vertices[v_i[locs_hex[
i][0]]];
356 mCoords[1] = vertices[v_i[locs_hex[
i][1]]];
357 mCoords[2] = vertices[v_i[locs_hex[
i][2]]];
373 for (i = 0; i < 4; ++
i) {
378 for (i = 0; i < 4; ++
i) {
383 for (j = 0; j < 3; ++
j) {
384 for (k = j; k < 3; ++
k) {
389 loc = 4*r - (r*(r+1)/2) + c;
393 loc = 4*c - (c*(c+1)/2) + r;
404 for (i = 0; i < 4; ++
i) {
410 for (i = 0; i < 4; ++
i) {
415 for (j = 0; j < 3; ++
j) {
416 for (k = j; k < 3; ++
k) {
421 loc = 4*r - (r*(r+1)/2) + c;
425 loc = 4*c - (c*(c+1)/2) + r;
447 for (i=0; i<4; ++
i) {
449 if ( vertices+v_i[i] == fv[ind] )
481 if (!metric_valid)
return false;
485 for (i = 0; i < 4; ++
i) {
487 if (vertices + v_i[i] == fv[j] )
518 for (i = 0; i < 8; ++
i) {
521 mCoords[0] = vertices[v_i[locs_hex[
i][0]]];
522 mCoords[1] = vertices[v_i[locs_hex[
i][1]]];
523 mCoords[2] = vertices[v_i[locs_hex[
i][2]]];
524 mCoords[3] = vertices[v_i[locs_hex[
i][3]]];
540 for (i = 0; i < 8; ++
i) {
545 for (i = 0; i < 8; ++
i) {
551 for (j = 0; j < 4; ++
j) {
552 for (k = j; k < 4; ++
k) {
557 loc = 8*r - (r*(r+1)/2) + c;
561 loc = 8*c - (c*(c+1)/2) + r;
572 for (i = 0; i < 8; ++
i) {
578 for (i = 0; i < 8; ++
i) {
584 for (j = 0; j < 4; ++
j) {
585 for (k = j; k < 4; ++
k) {
590 loc = 8*r - (r*(r+1)/2) + c;
594 loc = 8*c - (c*(c+1)/2) + r;
616 for (i=0; i<8; ++
i) {
618 if ( vertices+v_i[i] == fv[ind] )
int h_fcn_3i(double &obj, Vector3D g_obj[4], Matrix3D h_obj[10], const Vector3D x[4], const double a, const Exponent &b, const Exponent &c, const Vector3D &d)
bool g_fcn_2i(double &obj, Vector3D g_obj[3], const Vector3D x[3], const Vector3D &n, const double a, const Exponent &b, const Exponent &c, const Vector3D &d)
bool m_fcn_3e(double &obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
bool g_fcn_2e(double &obj, Vector3D g_obj[3], const Vector3D x[3], const Vector3D &n, const double a, const Exponent &b, const Exponent &c)
void zero()
Sets all entries to zero (more efficient than assignement).
bool g_fcn_3e(double &obj, Vector3D g_obj[4], const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
Used to hold the error state and return it to the application.
bool m_fcn_3i(double &obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c, const Vector3D &d)
Matrix3D transpose(const Matrix3D &A)
MsqMeshEntity is the Mesquite object that stores information about the elements in the mesh...
Vector3D is the object that effeciently stores information about about three-deminsional vectors...
bool m_fcn_2i(double &obj, const Vector3D x[3], const Vector3D &n, const double a, const Exponent &b, const Exponent &c, const Vector3D &d)
bool g_fcn_3i(double &obj, Vector3D g_obj[4], const Vector3D x[4], const double a, const Exponent &b, const Exponent &c, const Vector3D &d)
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
double average_metric_and_weights(double metric_values[], int num_metric_values, MsqError &err)
Given a list of metric values, calculate the average metric valude according to the current avgMethod...
void get_domain_normal_at_element(size_t elem_index, Vector3D &surf_norm, MsqError &err) const
bool h_fcn_3e(double &obj, Vector3D g_obj[4], Matrix3D h_obj[10], const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool compute_element_analytical_gradient(PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], int num_vtx, double &metric_value, MsqError &err)
Virtual function that computes the gradient of the QualityMetric analytically. The base class impleme...
3*3 Matric class, row-oriented, 0-based [i][j] indexing.
bool m_fcn_2e(double &obj, const Vector3D x[3], const Vector3D &n, const double a, const Exponent &b, const Exponent &c)
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
bool evaluate_element(PatchData &pd, MsqMeshEntity *element, double &fval, MsqError &err)
evaluate using mesquite objects
bool compute_element_analytical_hessian(PatchData &pd, MsqMeshEntity *e, MsqVertex *v[], Vector3D g[], Matrix3D h[], int nv, double &m, MsqError &err)
bool h_fcn_2e(double &obj, Vector3D g_obj[3], Matrix3D h_obj[6], const Vector3D x[3], const Vector3D &n, const double a, const Exponent &b, const Exponent &c)
const MsqVertex * get_vertex_array(MsqError &err) const
Returns a pointer to the start of the vertex array.
#define MSQ_PRINT(flag)
Check debug flag and print printf-style formatted output.
EntityTopology get_element_type() const
Returns element type.
object is in an invalid state
const msq_stdc::size_t * get_vertex_index_array() const
Very efficient retrieval of vertices indexes (corresponding to the PatchData vertex array)...
double average_metrics(const double metric_values[], const int &num_values, MsqError &err)
average_metrics takes an array of length num_values and averages the contents using averaging method ...
AveragingMethod avgMethod
MsqVertex is the Mesquite object that stores information about the vertices in the mesh...
bool h_fcn_2i(double &obj, Vector3D g_obj[3], Matrix3D h_obj[6], const Vector3D x[3], const Vector3D &n, const double a, const Exponent &b, const Exponent &c, const Vector3D &d)