MOAB: Mesh Oriented datABase  (version 5.2.1)
MBMesquite Namespace Reference

Implements the NonSmoothDescent class member functions. More...

Namespaces

namespace  DomainUtil
namespace  MeshWriter

Classes

class  Instruction
 Base class for all objects inserted into InstructionQueue. More...
class  InstructionQueue
 An InstructionQueue object gathers Mesquite Instructions and ensures that the instruction queue is coherent for mesh improvement and/or mesh quality assessment purposes. More...
class  IQInterface
struct  SettingData
class  Settings
class  SlaveBoundaryVertices
 Utility to set slaved vs. non-slaved vertices. More...
class  TerminationCriterion
 The TerminationCriterion class contains functionality to terminate the VertexMover's optimization. More...
class  VertexSlaver
class  CurveDomain
 Domain used for optional curve smoother. More...
class  Mesh
 A MBMesquite::Mesh is a collection of mesh elements which are composed of mesh vertices. Intermediate objects are not accessible through this interface (where intermediate objects include things like the faces of a hex, or an element's edges). More...
class  EntityIterator
 Iterates through a set of entities. An EntityIterator is typically obtained via Mesh::vertex_iterator() or Mesh::element_iterator(). An iterator obtained in this way iterates over the set of all vertices/elements in the Mesh from which the iterator was obtained. More...
class  MeshDomain
class  MeshDomainAssoc
class  ParallelHelper
class  ParallelMesh
class  HexLagrangeShape
 Lagrange shape function for 27-node hexahedral elements. More...
class  QuadLagrangeShape
 Lagrange shape function for 9-node quadrilateral elements. More...
class  TetLagrangeShape
 Lagrange shape function for tetrahedral elements. More...
class  TriLagrangeShape
 Lagrange shape function for triangle elements. More...
class  LinearHexahedron
 Linear mapping function for a hexahedral element. More...
class  LinearPrism
 Linear mapping function for a prism element. More...
class  LinearPyramid
 Linear mapping function for a pyramid element. More...
class  LinearQuadrilateral
 Linear shape function for quadrilateral elements. More...
class  LinearTetrahedron
 Linear mapping function for a tetrahedral element. More...
class  LinearTriangle
 Linear mapping function for a triangular element. More...
class  MappingFunction
 An interface for a mapping function of the form \(\vec{x}(\vec{\xi})=\sum_{i=1}^n N_i(\vec{\xi})\vec{x_i}\), where \(\vec{x_i}\) is a point in \(\mathbf{R}^3\) (i.e. \(x_i,y_i,z_i\)), \(\vec{\xi_i} = \left\{\begin{array}{c}\xi_i\\ \eta_i\\ \end{array}\right\}\) for surface elements and \(\vec{\xi_i} = \left\{\begin{array}{c}\xi_i\\ \eta_i\\ \zeta_i\\ \end{array}\right\}\) for volume elements. More...
class  MappingFunction2D
 MappingFunction for topologically 2D (surface) elements. More...
class  MappingFunction3D
 MappingFunction for topologically 3D (volume) elements. More...
class  NodeSet
struct  Sample
class  IndexIterator
class  ArrayMesh
class  ElementPatches
 A PatchSet representing a decomposition of the mesh into patches containing a single element. More...
class  ExtraData
 Object used to attach auxiliary data to PatchData. More...
class  ExtraDataUser
 Manage extra data attached to PatchData instances. More...
class  ExtraUserData
class  GlobalPatch
 A PatchSet representing a single global patch. More...
class  MeshDecorator
 Utility class for implementing decorators for the MBMesquite::Mesh interface. More...
struct  cast_handle
class  MeshImpl
 MeshImpl is a Mesquite implementation of the Mesh interface. Applications can also provide their own implementation of the interface. More...
class  MeshImplData
class  MeshImplVertIter
 VertexIterator for MeshImpl. More...
class  MeshImplElemIter
 ElementIterator for MeshImpl. More...
struct  TagDescription
class  MeshImplTags
class  MeshUtil
 Miscelanions operations performed on an entire Mesh without the conveinience of a PatchData. More...
class  MsqFreeVertexIndexIterator
 iterates over indexes of free vetices in a PatchData. More...
class  MsqMeshEntity
 MsqMeshEntity is the Mesquite object that stores information about the elements in the mesh. More...
class  MsqVertex
 MsqVertex is the Mesquite object that stores information about the vertices in the mesh. More...
struct  VertexPack
struct  VertexIdMapKey
struct  VertexIdLessFunc
class  ParallelHelperImpl
class  ParallelMeshImpl
 ParallelMeshImpl is a Mesquite implementation of the ParallelMesh interface. It inherits all of the implementation from MeshImpl and only implements any additional functionality. More...
class  PatchData
class  PatchDataVerticesMemento
 Contains a copy of the coordinates of a PatchData. More...
class  PatchIterator
class  PatchSet
 Specify a division of the Mesh into working patches. More...
class  TagVertexMesh
 Store alternate vertex coordinates in tags. More...
class  VertexPatches
 A PatchSet representing a decomposition of the mesh into patches containing a single free vertex and the adjacent elements. More...
class  BoundedCylinderDomain
class  ConicDomain
class  CylinderDomain
class  DomainClassifier
 Assign subsets of a mesh do different domains. More...
class  EdgeIterator
 Iterate over all edges in a patch. More...
class  Exponent
class  FileTokenizer
 Parse a file as space-separated tokens. More...
class  Matrix3D
 3*3 Matric class, row-oriented, 0-based [i][j] indexing. More...
class  PointDomain
class  LineDomain
class  CircleDomain
class  MeshTransform
class  MsqDebug
 Run-time activation/deactivation of debug flags. More...
class  MsqError
 Used to hold the error state and return it to the application. More...
class  MsqPrintError
 Utility class for printing error data - used in Mesquite tests. More...
class  MsqFPE
 Utility class used by InstructionQueue SIGFPE option. More...
class  MsqLine
 Line in R^3. More...
class  MsqCircle
 Circle in R^3. More...
class  MsqPlane
 Plane. More...
class  MsqSphere
 Sphere. More...
class  MsqHessian
 Vector3D is the object that effeciently stores the objective function Hessian each entry is a Matrix3D object (i.e. a vertex Hessian). More...
class  MsqInterrupt
 Class to watch for user-interrupt (SIGINT, ctrl-C) More...
class  MsqMatrix
 Fixed-size matrix class. More...
class  MsqMatrix< 1, 1 >
class  MsqVector
 Vector is a 1xL Matrix. More...
class  MsqMatrixA
 A subclass of MsqMatrix that behaves more like the old Matrix3D class. More...
class  Timer
class  StopWatch
class  StopWatchCollection
class  FunctionTimer
class  PlanarDomain
class  SimpleStats
 Accumulate various statistics for a list of discrete values. More...
class  SphericalDomain
class  SymMatrix3D
class  Vector3D
 Vector3D is the object that effeciently stores information about about three-deminsional vectors. It is also the parent class of MsqVertex. More...
struct  VtkTypeInfo
class  XYPlanarDomain
class  XYRectangle
 Simple 2D Domain for free-smooth testing. More...
class  CompositeOFAdd
 Adds two ObjectiveFunction values together. More...
class  CompositeOFMultiply
 Multiplies two ObjectiveFunction values together. More...
class  CompositeOFScalarAdd
 Adds a scalar to a given ObjectiveFunction. More...
class  CompositeOFScalarMultiply
 Scales a given an ObjectiveFunction. More...
class  LInfTemplate
 Computes the L_infinity objective function for a given patch, i.e., LInfTemplate::concrete_evaluate returns the maximum absolute value of the quality metric values on 'patch'. More...
class  LPtoPTemplate
 Calculates the L_p objective function raised to the pth power. That is, sums the p_th powers of (the absolute value of) the quality metric values. More...
class  MaxTemplate
 Computes the maximum quality metric value. More...
class  ObjectiveFunction
 Base class for concrete Objective Functions ObjectiveFunction contains a pointer to a QualityMetric. If the ObjectiveFunction is associated with more than one QualityMetric (i.e., the Objective is a composite, and the composed ObjectiveFunctions are associated with different QualityMetrics), then the QualityMetric pointer is set to NULL.. More...
class  ObjectiveFunctionTemplate
 Base for most concrete objective functions. More...
class  OFEvaluator
 Evaluate objective function. More...
class  PatchPowerMeanP
 Objective function: p-mean^p of p-mean^p of patch metric values. More...
class  PMeanPTemplate
 \(\frac{1}{n}\sum_{i=1}^n\mu(s_i)^p\) More...
class  StdDevTemplate
 standard deviation template More...
class  VarianceTemplate
 (variance)^2 template More...
class  QualityAssessor
 A QualityAssessor instance can be inserted into an InstructionQueue to calculate and summarize registered QualityMetric or QualityMetrics for the mesh. More...
class  NullImprover
class  ConjugateGradient
 Optimizes the objective function using the Polack-Ribiere scheme. More...
class  FeasibleNewton
 High Performance implementation of the Feasible Newton algorythm. More...
class  NonGradient
class  NonSmoothDescent
class  QuasiNewton
class  SteepestDescent
class  TrustRegion
class  PatchSetUser
 Utility class for handling variable patch types. More...
class  QualityImprover
 Base class for all quality improvers. Mote that the PatchData settings are inherited from the PathDataUser class. More...
class  LaplacianSmoother
class  Randomize
 Randomly perftubs the (un-culled) vertices. More...
class  RelaxationSmoother
 Base class for LaPlacian and other relaxation smoothers. More...
class  SmartLaplacianSmoother
class  VertexMover
class  AddQualityMetric
class  CornerHessDiagIterator
 Iterate over only diagonal blocks of element corner Hessian data. More...
class  AveragingQM
 Averaging functionality for use in quality metrics. More...
class  CompareQM
 Compare values for two supposedly equivalent quality metrics. More...
class  NumericalQM
 Use finite difference rather than analytical derivative calculations. More...
struct  EdgeData
class  EdgeQM
 Base type for quality metrics evaluated for each edge. More...
class  ElementAvgQM
class  ElementMaxQM
class  ElementPMeanP
class  ElementQM
 Base type for per-element quality metrics. More...
class  ElemSampleQM
 Base type for metrics evaluated at several sample points within each element. More...
class  MultiplyQualityMetric
 Combines two quality metrics (qMetric1 and qMetric2 defined in the parent class CompositeQualityMetric) by multiplication for two- and three-diminsional elements. Note: This function should not be used to combine a node-based metric with an element-based metric. More...
class  PMeanPMetric
class  PowerQualityMetric
 Raises a single quality metrics (qMetric1) to an arbitrary power (a double value, scaleAlpha) for two- and three-diminsional elements. More...
class  QualityMetric
 Base class for concrete quality metrics. More...
class  ScalarAddQualityMetric
 Offset a quality metric by a scalar value. More...
class  ScalarMultiplyQualityMetric
 Multiplies quality metric value by a number (a double). More...
class  AspectRatioGammaQualityMetric
 Object for computing the aspect ratio gamma of simplicial elements. More...
class  ConditionNumberQualityMetric
 Computes the condition number of given element. More...
class  IdealWeightInverseMeanRatio
 Computes the inverse mean ratio of given element. More...
class  IdealWeightMeanRatio
 Computes the mean ratio quality metric of given element. More...
class  VertexConditionNumberQualityMetric
 Computes the condition numbers of the corner's of elements connected to the given vertex and then averages those values. More...
class  EdgeLengthQualityMetric
 Computes the lengths of the edges connected to given a vertex.. More...
class  EdgeLengthRangeQualityMetric
 Computes the edge length range metric for a given vertex. More...
class  AffineMapMetric
 Compare targets to affine map to ideal element. More...
class  AWQualityMetric
 Compare targets to mapping function Jacobian matrices. More...
class  TMPQualityMetric
 Compare targets to mapping function Jacobian matrices. More...
class  TQualityMetric
 Compare targets to mapping function Jacobian matrices. More...
class  UntangleBetaQualityMetric
 The untangle beta quality metric. More...
class  VertexMaxQM
class  VertexPMeanP
class  VertexQM
 Base type for per-vertex quality metrics. More...
class  EdgeLengthMetric
class  LocalSizeQualityMetric
 Computes the local size metric for a given vertex. More...
class  SizeMetric
 Element size (area or volume) More...
struct  CachedTargetData
class  CachingTargetCalculator
 Cache target matrices on PatchData. More...
class  IdealShapeTarget
class  InverseMetricWeight
 Use inverse of metric value as target weight. More...
class  JacobianCalculator
 Calculate Jacobian matrices given vertex coordinates and MappingFunction. More...
class  LambdaConstant
 Scale a target matrix. More...
class  LambdaTarget
 Scale a target matrix by the size of another. More...
class  LVQDTargetCalculator
 Construct target matrices from factors of guide matrices. More...
class  MetricWeight
 Use metric value as target weight. More...
class  ReferenceMeshInterface
 Class for accessing reference element topology. More...
class  ReferenceMesh
class  RefMeshTargetCalculator
class  RefSizeTargetCalculator
class  RemainingWeight
 c2_k = 1 - c1_k More...
class  TargetCalculator
struct  TargetReaderData
 Internal structure used by TargetReader. More...
class  TargetReader
 Read targets from tag data. More...
class  TargetWriter
class  WeightCalculator
struct  WeightReaderData
 Internal structure used by WeightReader. More...
class  WeightReader
 Read targets from tag data. More...
class  AWMetric
 A metric for comparing a matrix A with a target matrix W. More...
class  AWMetric2D
class  AWMetric3D
class  AWMetricBarrier
 A metric for comparing a matrix A with a target matrix W. More...
class  AWMetricBarrier2D
class  AWMetricBarrier3D
class  AWMetricNonBarrier
 The parent class for all AWMetricNonBarrier sub-classes. More...
class  AWMetricNonBarrier2D
class  AWMetricNonBarrier3D
class  InvTransBarrier
class  TMixed
 Use different target metrics for surface and volume elements. More...
class  TOffset
class  TPower2
class  TScale
class  TSquared
class  TSum
class  AWShape2DB1
class  AWShape2DNB1
class  AWShape2DNB2
class  TInverseMeanRatio
class  TShape2DNB2
class  TShape3DB2
 3.3.8: 1/9 ^2(T) - 1, Kappa(T) = |T||T|^-1 = |T||adj(T)/ More...
class  TShapeB1
 Metric sensitive to shape. More...
class  TShapeNB1
 Metric sensitive to shape. More...
class  AWShapeOrientNB1
class  TShapeOrientB1
class  TShapeOrientB2
class  TShapeOrientNB1
class  TShapeOrientNB2
class  AWShapeSizeB1
class  TShapeSize2DB2
class  TShapeSize2DNB1
class  TShapeSize2DNB2
class  TShapeSize3DB2
class  TShapeSize3DB4
class  TShapeSize3DNB1
 \( |T|^3 - 3 \sqrt{3} \tau + \gamma (\tau - 1)^2 \) More...
class  TShapeSizeB1
class  TShapeSizeB3
class  TShapeSizeNB3
class  AWShapeSizeOrientNB1
class  TShapeSizeOrientB1
class  TShapeSizeOrientB2
class  TShapeSizeOrientNB1
class  AWSizeB1
class  AWSizeNB1
class  TSizeB1
class  TSizeNB1
class  TTau
 det(T) More...
class  TMetric
class  TMetric2D
class  TMetric3D
class  TMetricBarrier
class  TMetricBarrier2D
class  TMetricBarrier3D
class  TMetricNonBarrier
class  TMetricNonBarrier2D
class  TMetricNonBarrier3D
struct  DimConst
 Dimension-specific constants. More...
struct  DimConst< 2 >
struct  DimConst< 3 >
class  AWUntangleBeta
class  TUntangle1
 Untangle metric. More...
class  TUntangleBeta
 Untangle metric. More...
class  TUntangleMu
 Composite untangle metric. More...
class  DeformingDomainWrapper
 Smooth mesh with deforming domain (deforming geometry) More...
class  DeformingCurveSmoother
 Utility to do curve smoothing. More...
class  LaplaceWrapper
class  PaverMinEdgeLengthWrapper
class  ShapeImprovementWrapper
 Wrapper which performs a Feasible Newton solve using an \(\ell_2^2 \) objective function template with inverse mean ratio. More...
class  ShapeImprover
 Wrapper that implements TMP-based shape improvement. More...
class  SizeAdaptShapeWrapper
class  UntangleWrapper
 Wrapper that implements several TMP-based untanglers. More...
class  ViscousCFDTetShapeWrapper
class  Wrapper
 Interface for wrappers. More...
class  MsqCommonIGeom
 Common code for specific implementations of MeshDomain on ITAPS interfaces. More...
class  MsqIGeom
 A MBMesquite::MeshDomain implemented on top of the ITAPS iGeom API. More...
class  MsqIMesh
 Mesquite iMesh Adapter. More...
class  MsqIMeshP
 Mesquite iMesh Adapter. More...
class  MsqIRel
class  MsqMOAB
class  CircleDomainTest
class  LineDomainTest
class  TestRunner
 A class the runs cppunit tests, outputs results in an organized manner. More...

Typedefs

typedef EntityIterator VertexIterator
typedef EntityIterator ElementIterator
typedef void * TagHandle
typedef int StatusCode
typedef double real
typedef struct
MBMesquite::VertexPack 
VertexPack
typedef struct
MBMesquite::VertexIdMapKey 
VertexIdMapKey
typedef std::map
< VertexIdMapKey, int,
VertexIdLessFunc
VertexIdMap
typedef void(* msq_sig_handler_t )(int)

Enumerations

enum  TCType {
  NONE = 0, GRADIENT_L2_NORM_ABSOLUTE = 1 << 0, GRADIENT_INF_NORM_ABSOLUTE = 1 << 1, GRADIENT_L2_NORM_RELATIVE = 1 << 2,
  GRADIENT_INF_NORM_RELATIVE = 1 << 3, KKT = 1 << 4, QUALITY_IMPROVEMENT_ABSOLUTE = 1 << 5, QUALITY_IMPROVEMENT_RELATIVE = 1 << 6,
  NUMBER_OF_ITERATES = 1 << 7, CPU_TIME = 1 << 8, VERTEX_MOVEMENT_ABSOLUTE = 1 << 9, VERTEX_MOVEMENT_ABS_EDGE_LENGTH = 1 << 10,
  VERTEX_MOVEMENT_RELATIVE = 1 << 11, SUCCESSIVE_IMPROVEMENTS_ABSOLUTE = 1 << 12, SUCCESSIVE_IMPROVEMENTS_RELATIVE = 1 << 13, BOUNDED_VERTEX_MOVEMENT = 1 << 14,
  UNTANGLED_MESH = 1 << 15
}
enum  StatusCodeValues { MSQ_FAILURE = 0, MSQ_SUCCESS }
enum  EntityTopology {
  POLYGON = 7, TRIANGLE = 8, QUADRILATERAL = 9, POLYHEDRON = 10,
  TETRAHEDRON = 11, HEXAHEDRON = 12, PRISM = 13, PYRAMID = 14,
  SEPTAHEDRON = 15, MIXED
}
enum  AssessSchemes {
  NO_SCHEME = 0, ELEMENT_AVG_QM = 1, ELEMENT_MAX_QM = 2, TMP_QUALITY_METRIC = 3,
  QUALITY_METRIC = 4
}
enum  ReleaseType { RELEASE, BETA, ALPHA }
enum  Rotate { COUNTERCLOCKWISE = 1, CLOCKWISE = 0 }

Functions

int get_parallel_rank ()
int get_parallel_size ()
double reduce_parallel_max (double value)
size_t vertices_in_topology (EntityTopology)
MESQUITE_EXPORT const char * version_string (bool)
MESQUITE_EXPORT unsigned int major_version_number ()
MESQUITE_EXPORT unsigned int minor_version_number ()
MESQUITE_EXPORT unsigned int patch_version_number ()
MESQUITE_EXPORT
MBMesquite::ReleaseType 
release_type ()
template<class T >
T MSQ_MIN_2 (T a, T b)
template<class T >
T MSQ_MAX_2 (T a, T b)
double cbrt (double d)
double cbrt_sqr (double d)
bool divide (double num, double den, double &result)
 Perform safe division (no overflow or div by zero).
template<typename T >
Tarrptr (std::vector< T > &v, bool check_zero_size=false)
 get array pointer from std::vector
template<typename T >
const Tarrptr (const std::vector< T > &v, bool check_zero_size=false)
static void derivatives_at_corner (unsigned corner, NodeSet nodeset, size_t *vertices, MsqVector< 2 > *derivs, size_t &num_vtx)
static void derivatives_at_mid_edge (unsigned edge, NodeSet nodeset, size_t *vertices, MsqVector< 2 > *derivs, size_t &num_vtx)
static void derivatives_at_mid_elem (NodeSet nodeset, size_t *vertices, MsqVector< 2 > *derivs, size_t &num_vtx)
static void coefficients_at_corner (unsigned corner, double *coeff_out, size_t *indices_out, size_t &num_coeff)
static void coefficients_at_mid_edge (unsigned edge, NodeSet nodeset, double *coeff_out, size_t *indices_out, size_t &num_coeff)
static void coefficients_at_mid_face (unsigned face, NodeSet nodeset, double *coeff_out, size_t *indices_out, size_t &num_coeff)
static void coefficients_at_mid_elem (NodeSet nodeset, double *coeff_out, size_t *indices_out, size_t &num_coeff)
static void get_linear_derivatives (size_t *vertices, MsqVector< 3 > *derivs)
static void derivatives_at_corner (unsigned corner, NodeSet nodeset, size_t *vertices, MsqVector< 3 > *derivs, size_t &num_vtx)
static void derivatives_at_mid_edge (unsigned edge, NodeSet nodeset, size_t *vertices, MsqVector< 3 > *derivs, size_t &num_vtx)
static void derivatives_at_mid_face (unsigned face, NodeSet nodeset, size_t *vertices, MsqVector< 3 > *derivs, size_t &num_vtx)
static void derivatives_at_mid_elem (NodeSet nodeset, size_t *vertices, MsqVector< 3 > *derivs, size_t &num_vtx)
static void get_linear_derivatives (size_t *vertices, MsqVector< 2 > *derivs)
static int coeff_xi_sign (unsigned coeff)
static int coeff_eta_sign (unsigned coeff)
static int coeff_zeta_sign (unsigned coeff)
static void coefficients_at_mid_edge (unsigned edge, double *coeff_out, size_t *indices_out, size_t &num_coeff)
static void coefficients_at_mid_face (unsigned face, double *coeff_out, size_t *indices_out, size_t &num_coeff)
static void coefficients_at_mid_elem (double *coeff_out, size_t *indices_out, size_t &num_coeff)
static void derivatives_at_corner (unsigned corner, size_t *vertex_indices_out, MsqVector< 3 > *d_coeff_d_xi_out, size_t &num_vtx)
static void derivatives_at_mid_edge (unsigned edge, size_t *vertex_indices_out, MsqVector< 3 > *d_coeff_d_xi_out, size_t &num_vtx)
static void derivatives_at_mid_face (unsigned face, size_t *vertex_indices_out, MsqVector< 3 > *d_coeff_d_xi_out, size_t &num_vtx)
static void derivatives_at_mid_elem (size_t *vertex_indices_out, MsqVector< 3 > *d_coeff_d_xi_out, size_t &num_vtx)
static void set_equal_derivatives (double value, size_t *indices, MsqVector< 3 > *derivs, size_t &num_vtx)
static void set_edge_derivatives (unsigned base_corner, double value, size_t *indices, MsqVector< 3 > *derivs, size_t &num_vtx)
static void set_corner_derivatives (unsigned corner, double value, size_t *indices, MsqVector< 3 > *derivs, size_t &num_vtx)
static void derivatives_at_corner (unsigned corner, size_t *vertex_indices, MsqVector< 2 > *derivs, size_t &num_vtx)
static void derivatives_at_mid_edge (unsigned edge, size_t *vertices, MsqVector< 2 > *derivs, size_t &num_vtx)
static void derivatives_at_mid_elem (size_t *vertices, MsqVector< 2 > *derivs, size_t &num_vtx)
std::ostream & operator<< (std::ostream &s, NodeSet set)
std::ostream & operator<< (std::ostream &str, Sample s)
static void init_tri (Vector3D *coords, double side)
static void init_tet (Vector3D *coords, double side)
static void init_pyr (Vector3D *coords, double side)
static void init_wdg (Vector3D *coords, double side)
static void init_hex_pyr (Vector3D *coords, double height)
static const Vector3D *const * init_unit_edge (Vector3D **)
static const Vector3D *const * init_unit_elem (Vector3D **)
const Vector3Dunit_edge_element (EntityTopology type, bool unit_height_pyramid=false)
 Get ideal element with unit edge length.
const Vector3Dunit_element (EntityTopology type, bool unit_height_pyramid=false)
 Get ideal element with unit area or volume.
static bool is_side_boundary (MeshImplData *myMesh, size_t elem, unsigned side_dim, unsigned side_num, MsqError &err)
 Helper function for MeshImpl::mark_skin_fixed.
static void get_field_names (const TagDescription &tag, std::string &field_out, std::string &member_out, MsqError &err)
static double corner_volume (const Vector3D &v0, const Vector3D &v1, const Vector3D &v2, const Vector3D &v3)
ostream & operator<< (ostream &stream, const MsqMeshEntity &entity)
void parallel_barrier ()
static const char * mpi_err_string (int error_code)
static bool vertex_map_insert (VertexIdMap &map, size_t glob_id, int proc_id, int value)
static int vertex_map_find (const VertexIdMap &map, size_t glob_id, int proc_id)
static void my_quicksort (int *a, size_t *b, MBMesquite::Mesh::VertexHandle *c, int i, int j)
static int hash6432shift (unsigned long long key)
static unsigned long long hash64shift (unsigned long long key)
static double generate_random_number (int generate_random_numbers, int proc_id, size_t glob_id)
static void project_to_plane (Vector3D &vect, const Vector3D &norm)
static int width (double d)
static int width (size_t t)
static int width (const void *ptr)
ostream & operator<< (ostream &stream, const PatchData &pd)
void print_patch_data (const PatchData &pd)
int popcount (unsigned int x)
 Count number of 1-bits in an unsigned integer.
static bool compare_sides (unsigned num_vtx, const unsigned *idx_set_1, const Mesh::VertexHandle *vtx_set_1, const unsigned *idx_set_2, const Mesh::VertexHandle *vtx_set_2)
 Helper function for 'find_skin'.
static void find_skin (Mesh *mesh, std::vector< Mesh::VertexHandle > &skin_verts, std::vector< Mesh::ElementHandle > &skin_elems, MsqError &err)
 Skin mesh.
static void dimension_sort_domains (MeshDomain **domains, const int *dims, unsigned count, std::vector< DomainClassifier::DomainSet > &results, int dim_indices[4], MsqError &err)
 Group MeshDomain objectects by topological dimension.
static void geom_classify_vertices (Mesh *mesh, DomainClassifier::DomainSet *dim_sorted_domains, unsigned num_domain, const std::vector< Mesh::VertexHandle > &vertices, double epsilon, MsqError &err)
 Classify mesh vertices using vertex position.
static void vert_classify_elements (Mesh *mesh, DomainClassifier::DomainSet *dim_sorted_domains, unsigned num_domain, int dim_indices[4], const std::vector< Mesh::ElementHandle > &elems, std::vector< Mesh::ElementHandle > &unknown_elems, MsqError &err)
 Classify mesh elements using vertex classification.
static void geom_classify_elements (Mesh *mesh, DomainClassifier::DomainSet *dim_sorted_domains, unsigned num_domain, int dim_indices[4], const std::vector< Mesh::ElementHandle > &elems, std::vector< Mesh::ElementHandle > &unknown_elems, double epsilon, MsqError &err)
 Classify mesh elements geometrically.
static bool next_vertex (Mesh *mesh, Mesh::VertexHandle &vtx, std::set< Mesh::VertexHandle > &unseen, MsqError &err)
static bool operator< (const Mesh::EntityHandle h, const DomainClassifier::DomainBlock &b)
static bool operator< (const DomainClassifier::DomainBlock &b, const Mesh::EntityHandle h)
static bool operator< (const DomainClassifier::DomainBlock &b, const DomainClassifier::DomainBlock &c)
bool operator< (const EdgeIterator::Edge &e1, const EdgeIterator::Edge &e2)
bool operator== (const EdgeIterator::Edge &e1, const EdgeIterator::Edge &e2)
std::ostream & operator<< (std::ostream &s, const Matrix3D &A)
std::istream & operator>> (std::istream &s, Matrix3D &A)
bool operator== (const Matrix3D &lhs, const Matrix3D &rhs)
bool operator!= (const Matrix3D &lhs, const Matrix3D &rhs)
Matrix3D operator- (const Matrix3D &A)
const Matrix3D operator+ (const Matrix3D &A, const Matrix3D &B)
Matrix3D operator+ (const Matrix3D &A, const SymMatrix3D &B)
Matrix3D operator+ (const SymMatrix3D &B, const Matrix3D &A)
const Matrix3D operator- (const Matrix3D &A, const Matrix3D &B)
Matrix3D operator- (const Matrix3D &A, const SymMatrix3D &B)
Matrix3D operator- (const SymMatrix3D &B, const Matrix3D &A)
const Matrix3D mult_element (const Matrix3D &A, const Matrix3D &B)
 Multiplies entry by entry. This is NOT a matrix multiplication.
double Frobenius_2 (const Matrix3D &A)
 Return the square of the Frobenius norm of A, i.e. sum (diag (A' * A))
Matrix3D transpose (const Matrix3D &A)
Matrix3D plus_transpose (const Matrix3D &A, const Matrix3D &B)
 \( + B^T \)
const Matrix3D operator* (const Matrix3D &A, const Matrix3D &B)
const Matrix3D operator* (const Matrix3D &A, const SymMatrix3D &B)
const Matrix3D operator* (const SymMatrix3D &B, const Matrix3D &A)
const Matrix3D operator* (const SymMatrix3D &a, const SymMatrix3D &b)
const Matrix3D operator* (double s, const Matrix3D &A)
void matmult (Matrix3D &C, const Matrix3D &A, const Matrix3D &B)
 \( C = A \times B \)
const Vector3D operator* (const Matrix3D &A, const Vector3D &x)
 Computes \( A v \) .
const Vector3D operator* (const Vector3D &x, const Matrix3D &A)
 Computes \( v^T A \) .
void eqAx (Vector3D &v, const Matrix3D &A, const Vector3D &x)
void plusEqAx (Vector3D &v, const Matrix3D &A, const Vector3D &x)
void eqTransAx (Vector3D &v, const Matrix3D &A, const Vector3D &x)
void plusEqTransAx (Vector3D &v, const Matrix3D &A, const Vector3D &x)
void plusEqaA (Matrix3D &B, const double a, const Matrix3D &A)
double det (const Matrix3D &A)
void inv (Matrix3D &Ainv, const Matrix3D &A)
void timesInvA (Matrix3D &B, const Matrix3D &A)
void QR (Matrix3D &Q, Matrix3D &R, const Matrix3D &A)
std::ostream & operator<< (std::ostream &, const MsqError::Trace &)
 Print MsqError::Trace.
std::ostream & operator<< (std::ostream &, const MsqError &)
 Print message and stack trace.
std::ostream & operator<< (std::ostream &s, const MsqHessian &h)
 Prints out the MsqHessian blocks.
void axpy (Vector3D res[], size_t size_r, const MsqHessian &H, const Vector3D x[], size_t size_x, const Vector3D y[], size_t size_y, MsqError &)
std::string process_itaps_error (int ierr)
void msq_sigint_handler (int)
template<unsigned R1, unsigned C1, unsigned R2, unsigned C2>
void set_region (MsqMatrix< R1, C1 > &d, unsigned r, unsigned c, MsqMatrix< R2, C2 > &s)
 Set a subset of this matrix to some other matrix.
template<unsigned R, unsigned C>
MsqMatrix< R, Coperator- (const MsqMatrix< R, C > &m)
template<unsigned R, unsigned C>
MsqMatrix< R, Coperator+ (const MsqMatrix< R, C > &m, double s)
template<unsigned R, unsigned C>
MsqMatrix< R, Coperator+ (double s, const MsqMatrix< R, C > &m)
template<unsigned R, unsigned C>
MsqMatrix< R, Coperator+ (const MsqMatrix< R, C > &A, const MsqMatrix< R, C > &B)
template<unsigned R, unsigned C>
MsqMatrix< R, Coperator- (const MsqMatrix< R, C > &m, double s)
template<unsigned R, unsigned C>
MsqMatrix< R, Coperator- (double s, const MsqMatrix< R, C > &m)
template<unsigned R, unsigned C>
MsqMatrix< R, Coperator- (const MsqMatrix< R, C > &A, const MsqMatrix< R, C > &B)
template<unsigned R, unsigned C>
MsqMatrix< R, Coperator* (const MsqMatrix< R, C > &m, double s)
template<unsigned R, unsigned C>
MsqMatrix< R, Coperator* (double s, const MsqMatrix< R, C > &m)
template<unsigned R, unsigned RC, unsigned C>
double multiply_helper_result_val (unsigned r, unsigned c, const MsqMatrix< R, RC > &A, const MsqMatrix< RC, C > &B)
template<unsigned R, unsigned RC, unsigned C>
MsqMatrix< R, Coperator* (const MsqMatrix< R, RC > &A, const MsqMatrix< RC, C > &B)
template<unsigned R, unsigned C>
MsqMatrix< R, Coperator/ (const MsqMatrix< R, C > &m, double s)
template<unsigned RC>
double cofactor (const MsqMatrix< RC, RC > &m, unsigned r, unsigned c)
template<unsigned RC>
double det (const MsqMatrix< RC, RC > &m)
double det (const MsqMatrix< 2, 2 > &m)
double det (const MsqMatrix< 3, 3 > &m)
MsqMatrix< 2, 2 > adj (const MsqMatrix< 2, 2 > &m)
MsqMatrix< 2, 2 > transpose_adj (const MsqMatrix< 2, 2 > &m)
MsqMatrix< 3, 3 > adj (const MsqMatrix< 3, 3 > &m)
MsqMatrix< 3, 3 > transpose_adj (const MsqMatrix< 3, 3 > &m)
template<unsigned R, unsigned C>
MsqMatrix< R, Cinverse (const MsqMatrix< R, C > &m)
template<unsigned R, unsigned C>
MsqMatrix< R, Ctranspose (const MsqMatrix< C, R > &m)
template<unsigned RC>
double trace (const MsqMatrix< RC, RC > &m)
template<unsigned R, unsigned C>
double sqr_Frobenius (const MsqMatrix< R, C > &m)
template<unsigned R, unsigned C>
double Frobenius (const MsqMatrix< R, C > &m)
template<unsigned R, unsigned C>
bool operator== (const MsqMatrix< R, C > &A, const MsqMatrix< R, C > &B)
template<unsigned R, unsigned C>
bool operator!= (const MsqMatrix< R, C > &A, const MsqMatrix< R, C > &B)
template<unsigned R, unsigned C>
std::ostream & operator<< (std::ostream &str, const MsqMatrix< R, C > &m)
template<unsigned R, unsigned C>
std::istream & operator>> (std::istream &str, MsqMatrix< R, C > &m)
template<unsigned R>
double sqr_length (const MsqMatrix< R, 1 > &v)
template<unsigned C>
double sqr_length (const MsqMatrix< 1, C > &v)
template<unsigned R>
double length (const MsqMatrix< R, 1 > &v)
template<unsigned C>
double length (const MsqMatrix< 1, C > &v)
template<unsigned R, unsigned C>
double inner_product (const MsqMatrix< R, C > &m1, const MsqMatrix< R, C > &m2)
template<unsigned R, unsigned C>
MsqMatrix< R, Couter (const MsqMatrix< R, 1 > &v1, const MsqMatrix< C, 1 > &v2)
template<unsigned R, unsigned C>
MsqMatrix< R, Couter (const MsqMatrix< 1, R > &v1, const MsqMatrix< 1, C > &v2)
double vector_product (const MsqMatrix< 2, 1 > &v1, const MsqMatrix< 2, 1 > &v2)
double vector_product (const MsqMatrix< 1, 2 > &v1, const MsqMatrix< 1, 2 > &v2)
MsqMatrix< 3, 1 > vector_product (const MsqMatrix< 3, 1 > &a, const MsqMatrix< 3, 1 > &b)
MsqMatrix< 1, 3 > vector_product (const MsqMatrix< 1, 3 > &a, const MsqMatrix< 1, 3 > &b)
template<unsigned R, unsigned C>
double operator% (const MsqMatrix< R, C > &v1, const MsqMatrix< R, C > &v2)
double operator* (const MsqMatrix< 2, 1 > &v1, const MsqMatrix< 2, 1 > &v2)
double operator* (const MsqMatrix< 1, 2 > &v1, const MsqMatrix< 1, 2 > &v2)
MsqMatrix< 3, 1 > operator* (const MsqMatrix< 3, 1 > &v1, const MsqMatrix< 3, 1 > &v2)
MsqMatrix< 1, 3 > operator* (const MsqMatrix< 1, 3 > &v1, const MsqMatrix< 1, 3 > &v2)
void QR (const MsqMatrix< 3, 3 > &A, MsqMatrix< 3, 3 > &Q, MsqMatrix< 3, 3 > &R)
void QR (const MsqMatrix< 2, 2 > &A, MsqMatrix< 2, 2 > &Q, MsqMatrix< 2, 2 > &R)
MESQUITE_EXPORT std::ostream & operator<< (std::ostream &, StopWatchCollection &coll)
MESQUITE_EXPORT void print_timing_diagnostics (int debugflag)
MESQUITE_EXPORT void print_timing_diagnostics (std::ostream &stream)
SymMatrix3D operator- (const SymMatrix3D &m)
SymMatrix3D operator+ (const SymMatrix3D &a, const SymMatrix3D &b)
SymMatrix3D operator- (const SymMatrix3D &a, const SymMatrix3D &b)
SymMatrix3D operator* (const SymMatrix3D &a, double s)
SymMatrix3D operator* (double s, const SymMatrix3D &a)
SymMatrix3D operator/ (const SymMatrix3D &a, double s)
SymMatrix3D operator/ (double s, const SymMatrix3D &a)
Vector3D operator* (const Vector3D &v, const SymMatrix3D &m)
Vector3D operator* (const SymMatrix3D &m, const Vector3D &v)
SymMatrix3D outer (const Vector3D &v)
SymMatrix3D outer_plus_transpose (const Vector3D &u, const Vector3D &v)
const SymMatrix3Dtranspose (const SymMatrix3D &a)
double det (const SymMatrix3D &a)
SymMatrix3D inverse (const SymMatrix3D &a)
double Frobenius_2 (const SymMatrix3D &a)
double Frobenius (const SymMatrix3D &a)
std::ostream & operator<< (std::ostream &s, const MBMesquite::Vector3D &v)
const Vector3D operator+ (const Vector3D &lhs, const Vector3D &rhs)
const Vector3D operator- (const Vector3D &lhs, const Vector3D &rhs)
const Vector3D operator* (const Vector3D &lhs, const double scalar)
const Vector3D operator* (const double scalar, const Vector3D &rhs)
const Vector3D operator/ (const Vector3D &lhs, const double scalar)
double operator% (const Vector3D &lhs, const Vector3D &rhs)
double inner (const Vector3D lhs[], const Vector3D rhs[], int n)
double inner (const std::vector< Vector3D > &lhs, const std::vector< Vector3D > &rhs)
double operator% (const double scalar, const Vector3D &rhs)
double operator% (const Vector3D &lhs, const double scalar)
const Vector3D operator* (const Vector3D &lhs, const Vector3D &rhs)
double inner_product (const Vector3D *v1, const Vector3D *v2, size_t n)
double length_squared (const Vector3D *v, int n)
double length_squared (const std::vector< Vector3D > &v)
double length (const Vector3D *v, int n)
double length (const std::vector< Vector3D > &v)
double Linf (const Vector3D *v, int n)
double Linf (const std::vector< Vector3D > &v)
bool operator== (const Vector3D &v1, const Vector3D &v2)
bool operator!= (const Vector3D &v1, const Vector3D &v2)
const char * default_name (bool free_only)
static double condition3x3 (const double A[9])
template<typename T >
static void free_vector (std::vector< T > &v)
static void plus_eq_scaled (Vector3D *v, double s, const Vector3D *x, size_t n)
static void negate (Vector3D *out, const Vector3D *in, size_t nn)
static void times_eq_minus (Vector3D *v, double s, const Vector3D *x, size_t n)
static void checkpoint_bytes (Mesh *mesh, std::vector< unsigned char > &saved_bytes, MsqError &err)
static void restore_bytes (Mesh *mesh, std::vector< unsigned char > &saved_bytes, MsqError &err)
static void save_or_restore_debug_state (bool save)
template<typename HessIter >
static double sum_corner_diagonals (EntityTopology type, unsigned num_corner, const double corner_values[], const Vector3D corner_grads[], HessIter corner_diag_blocks, Vector3D vertex_grads[], SymMatrix3D vertex_hessians[])
template<typename HessIter >
static double sum_sqr_corner_diagonals (EntityTopology type, unsigned num_corner, const double corner_values[], const Vector3D corner_grads[], HessIter corner_diag_blocks, Vector3D vertex_grads[], SymMatrix3D vertex_hessians[])
template<typename HessIter >
static double pmean_corner_diagonals (EntityTopology type, unsigned num_corner, const double corner_values[], const Vector3D corner_grads[], HessIter corner_diag_blocks, Vector3D vertex_grads[], SymMatrix3D vertex_hessians[], double p)
template<typename HessIter >
static double average_corner_diagonals (EntityTopology type, QualityMetric::AveragingMethod method, unsigned num_corner, const double corner_values[], const Vector3D corner_grads[], HessIter corner_diag_blocks, Vector3D vertex_grads[], SymMatrix3D vertex_hessians[], MsqError &err)
static double sum_corner_hessians (EntityTopology type, unsigned num_corner, const double corner_values[], const Vector3D corner_grads[], const Matrix3D corner_hessians[], Vector3D vertex_grads[], Matrix3D vertex_hessians[])
static double sum_sqr_corner_hessians (EntityTopology type, unsigned num_corner, const double corner_values[], const Vector3D corner_grads[], const Matrix3D corner_hessians[], Vector3D vertex_grads[], Matrix3D vertex_hessians[])
static double pmean_corner_hessians (EntityTopology type, unsigned num_corner, const double corner_values[], const Vector3D corner_grads[], const Matrix3D corner_hessians[], Vector3D vertex_grads[], Matrix3D vertex_hessians[], double p)
static void print (const char *title, const char *name1, const char *name2, const SimpleStats &s1, const SimpleStats &s2, const SimpleStats &sd)
bool operator< (const EdgeData &e1, const EdgeData &e2)
bool operator== (const EdgeData &e1, const EdgeData &e2)
static double get_delta_C (const PatchData &pd, const std::vector< size_t > &indices, MsqError &err)
static bool condition_number_2d (const Vector3D temp_vec[], size_t e_ind, PatchData &pd, double &fval, MsqError &err)
static bool condition_number_3d (const Vector3D temp_vec[], PatchData &, double &fval, MsqError &)
bool m_fcn_2e (double &obj, const Vector3D x[3], const Vector3D &n, const double a, const Exponent &b, const Exponent &c)
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)
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)
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_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 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)
bool m_fcn_3e (double &obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool g_fcn_3e (double &obj, Vector3D g_obj[4], const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
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 g_fcn_3e_v3 (double &obj, Vector3D &g_obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool g_fcn_3e_v0 (double &obj, Vector3D &g_obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool g_fcn_3e_v1 (double &obj, Vector3D &g_obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool g_fcn_3e_v2 (double &obj, Vector3D &g_obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool h_fcn_3e_v3 (double &obj, Vector3D &g_obj, Matrix3D &h_obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool h_fcn_3e_v0 (double &obj, Vector3D &g_obj, Matrix3D &h_obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool h_fcn_3e_v1 (double &obj, Vector3D &g_obj, Matrix3D &h_obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool h_fcn_3e_v2 (double &obj, Vector3D &g_obj, Matrix3D &h_obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool m_fcn_3i (double &obj, const Vector3D x[4], 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)
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 m_fcn_3p (double &obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool g_fcn_3p (double &obj, Vector3D g_obj[4], const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool h_fcn_3p (double &obj, Vector3D g_obj[4], Matrix3D h_obj[10], const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool m_fcn_3w (double &obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool g_fcn_3w (double &obj, Vector3D g_obj[4], const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool h_fcn_3w (double &obj, Vector3D g_obj[4], Matrix3D h_obj[10], const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
void surface_to_2d (const MsqMatrix< 3, 2 > &A, const MsqMatrix< 3, 2 > &W_32, MsqMatrix< 2, 2 > &W_22, MsqMatrix< 3, 2 > &RZ)
 Calculate R and Z such that \(W\prime = Z^{-1} W\) and \(A\prime = (RZ)^{-1} A\).
static void append_elem_samples (PatchData &pd, size_t e, std::vector< size_t > &handles)
void get_sample_pt_evaluations (PatchData &pd, std::vector< size_t > &handles, bool free, MsqError &err)
void get_elem_sample_points (PatchData &pd, size_t elem, std::vector< size_t > &handles, MsqError &)
template<int DIM>
void gradient (size_t num_free_verts, const MsqVector< DIM > *dNdxi, const MsqMatrix< 3, DIM > &dmdA, std::vector< Vector3D > &grad)
 Calculate gradient from derivatives of mapping function terms and derivatives of target metric.
template<int DIM, typename MAT >
void hessian (size_t num_free_verts, const MsqVector< DIM > *dNdxi, const MsqMatrix< DIM, DIM > *d2mdA2, MAT *hess)
 Calculate Hessian from derivatives of mapping function terms and derivatives of target metric.
template<int DIM>
void hessian_diagonal (size_t num_free_verts, const MsqVector< DIM > *dNdxi, const MsqMatrix< DIM, DIM > *d2mdA2, SymMatrix3D *diagonal)
 Calculate Hessian from derivatives of mapping function terms and derivatives of target metric.
static void get_u_perp (const MsqVector< 3 > &u, MsqVector< 3 > &u_perp)
static bool project_to_perp_plane (MsqMatrix< 3, 2 > J, const MsqVector< 3 > &u, const MsqVector< 3 > &u_perp, MsqMatrix< 2, 2 > &A, MsqMatrix< 3, 2 > &S_a_transpose_Theta)
static void project_to_matrix_plane (const MsqMatrix< 3, 2 > &M_in, MsqMatrix< 2, 2 > &M_out, MsqVector< 3 > &u, MsqVector< 3 > &u_perp)
static void populate_data (PatchData &pd, CachedTargetData *data, TargetCalculator *calc, MsqError &err)
static bool ideal_constant_skew_I_3D (EntityTopology element_type, MsqMatrix< 3, 3 > &q)
static bool ideal_constant_skew_I_2D (EntityTopology element_type, MsqMatrix< 2, 2 > &q)
static NodeSet get_nodeset (EntityTopology type, int num_nodes, MsqError &err)
static TagHandle get_tag (Mesh *mesh, unsigned num_matrices, unsigned dimension, const char *base_name, bool orient_surface, MsqError &err)
static double da (double dot)
static TagHandle get_tag (Mesh *mesh, unsigned num_doubles, const std::string &base_name, MsqError &err)
template<unsigned Dim>
static double do_finite_difference (int r, int c, AWMetric *metric, MsqMatrix< Dim, Dim > A, const MsqMatrix< Dim, Dim > &W, double value, MsqError &err)
template<unsigned Dim>
static bool do_numerical_gradient (AWMetric *mu, MsqMatrix< Dim, Dim > A, const MsqMatrix< Dim, Dim > &W, double &result, MsqMatrix< Dim, Dim > &wrt_A, MsqError &err)
template<unsigned Dim>
static bool do_numerical_hessian (AWMetric *metric, MsqMatrix< Dim, Dim > A, const MsqMatrix< Dim, Dim > &W, double &value, MsqMatrix< Dim, Dim > &grad, MsqMatrix< Dim, Dim > *Hess, MsqError &err)
template<unsigned DIM>
static bool eval (const MsqMatrix< DIM, DIM > &T, double &result)
template<unsigned DIM>
static bool grad (const MsqMatrix< DIM, DIM > &T, double &result, MsqMatrix< DIM, DIM > &wrt_T)
template<unsigned DIM>
static bool hess (const MsqMatrix< DIM, DIM > &T, double &result, MsqMatrix< DIM, DIM > &deriv_wrt_T, MsqMatrix< DIM, DIM > *second_wrt_T)
template<unsigned DIM>
static bool eval (const MsqMatrix< DIM, DIM > &A, const MsqMatrix< DIM, DIM > &W, double &result)
template<unsigned DIM>
static bool grad (const MsqMatrix< DIM, DIM > &A, const MsqMatrix< DIM, DIM > &W, double &result, MsqMatrix< DIM, DIM > &deriv)
template<unsigned DIM>
static bool hess (const MsqMatrix< DIM, DIM > &A, const MsqMatrix< DIM, DIM > &W, double &result, MsqMatrix< DIM, DIM > &deriv, MsqMatrix< DIM, DIM > *second)
template<unsigned Dim>
static double do_finite_difference (int r, int c, TMetric *metric, MsqMatrix< Dim, Dim > A, double value, MsqError &err)
template<unsigned Dim>
static bool do_numerical_gradient (TMetric *mu, MsqMatrix< Dim, Dim > A, double &result, MsqMatrix< Dim, Dim > &wrt_A, MsqError &err)
template<unsigned Dim>
static bool do_numerical_hessian (TMetric *metric, MsqMatrix< Dim, Dim > A, double &value, MsqMatrix< Dim, Dim > &grad, MsqMatrix< Dim, Dim > *Hess, MsqError &err)
template<unsigned D>
void hess_scale_t (MsqMatrix< D, D > R[D *(D+1)/2], double alpha)
 \( R *= s \)
void hess_scale (MsqMatrix< 3, 3 > R[6], double alpha)
void hess_scale (MsqMatrix< 2, 2 > R[3], double alpha)
void set_scaled_I (MsqMatrix< 3, 3 > R[6], double alpha)
 \( R = \alpha I_9 \)
void pluseq_scaled_I (MsqMatrix< 3, 3 > R[6], double alpha)
 \( R += \alpha I_9 \)
void pluseq_scaled_I (MsqMatrix< 3, 3 > &R, double alpha)
 \( R += \alpha I_9 \)
void set_scaled_I (MsqMatrix< 2, 2 > R[3], double alpha)
 \( R = \alpha I_4 \)
void pluseq_scaled_I (MsqMatrix< 2, 2 > R[3], double alpha)
 \( R += \alpha I_4 \)
void pluseq_scaled_I (MsqMatrix< 2, 2 > &R, double alpha)
 \( R += \alpha I_4 \)
void pluseq_scaled_2nd_deriv_of_det (MsqMatrix< 3, 3 > R[6], double alpha, const MsqMatrix< 3, 3 > &T)
 \( R += \alpha \frac{\partial}{\partial T}det(T) \)
void pluseq_scaled_2nd_deriv_of_det (MsqMatrix< 2, 2 > R[3], double alpha)
 \( R += \alpha \frac{\partial}{\partial T}det(T) \)
void pluseq_scaled_2nd_deriv_of_det (MsqMatrix< 2, 2 > R[3], double alpha, const MsqMatrix< 2, 2 > &)
void set_scaled_2nd_deriv_of_det (MsqMatrix< 3, 3 > R[6], double alpha, const MsqMatrix< 3, 3 > &T)
 \( R = \alpha \frac{\partial}{\partial T}det(T) \)
void set_scaled_2nd_deriv_of_det (MsqMatrix< 2, 2 > R[3], double alpha)
 \( R = \alpha \frac{\partial}{\partial T}det(T) \)
void set_scaled_2nd_deriv_of_det (MsqMatrix< 2, 2 > R[3], double alpha, const MsqMatrix< 2, 2 > &)
void pluseq_scaled_2nd_deriv_tr_adj (MsqMatrix< 2, 2 > R[3], double alpha)
 \( R += \alpha \frac{\partial^2}{\partial T^2}tr(adj T) \)
void pluseq_scaled_2nd_deriv_tr_adj (MsqMatrix< 3, 3 > R[6], double alpha)
 \( R += \alpha \frac{\partial^2}{\partial T^2}tr(adj T) \)
void set_scaled_2nd_deriv_norm_sqr_adj (MsqMatrix< 2, 2 > R[3], double alpha, const MsqMatrix< 2, 2 > &T)
 \( R += \alpha \frac{\partial^2}{\partial T^2}|adj T|^2 \)
void set_scaled_2nd_deriv_norm_sqr_adj (MsqMatrix< 3, 3 > R[6], double alpha, const MsqMatrix< 3, 3 > &T)
 \( R += \alpha \frac{\partial^2}{\partial T^2}|adj T|^2 \)
template<unsigned D>
void pluseq_scaled_outer_product_t (MsqMatrix< D, D > R[D *(D+1)/2], double alpha, const MsqMatrix< D, D > &M)
 \( R += \alpha \left( M \otimes M \right) \)
void pluseq_scaled_outer_product (MsqMatrix< 3, 3 > R[6], double alpha, const MsqMatrix< 3, 3 > &M)
void pluseq_scaled_outer_product (MsqMatrix< 2, 2 > R[3], double alpha, const MsqMatrix< 2, 2 > &M)
template<unsigned D>
void set_scaled_outer_product_t (MsqMatrix< D, D > R[D *(D+1)/2], double alpha, const MsqMatrix< D, D > &M)
 \( R = \alpha \left( M \otimes M \right) \)
void set_scaled_outer_product (MsqMatrix< 3, 3 > R[6], double alpha, const MsqMatrix< 3, 3 > &M)
void set_scaled_outer_product (MsqMatrix< 2, 2 > R[3], double alpha, const MsqMatrix< 2, 2 > &M)
void pluseq_scaled_sum_outer_product (MsqMatrix< 3, 3 > R[6], double alpha, const MsqMatrix< 3, 3 > &A, const MsqMatrix< 3, 3 > &B)
 \( R += \alpha \left( A \otimes B + B \otimes A \right) \)
void pluseq_scaled_sum_outer_product (MsqMatrix< 2, 2 > R[3], double alpha, const MsqMatrix< 2, 2 > &A, const MsqMatrix< 2, 2 > &B)
 \( R += \alpha \left( A \otimes B + B \otimes A \right) \)
void set_scaled_sum_outer_product (MsqMatrix< 3, 3 > R[6], double alpha, const MsqMatrix< 3, 3 > &A, const MsqMatrix< 3, 3 > &B)
 \( R = \alpha \left( A \otimes B + B \otimes A \right) \)
void set_scaled_sum_outer_product (MsqMatrix< 2, 2 > R[3], double alpha, const MsqMatrix< 2, 2 > &A, const MsqMatrix< 2, 2 > &B)
 \( R = \alpha \left( A \otimes B + B \otimes A \right) \)
void pluseq_scaled_outer_product_I_I (MsqMatrix< 3, 3 > R[6], double alpha)
 \( R += \alpha (I \otimes I) \)
void pluseq_scaled_outer_product_I_I (MsqMatrix< 2, 2 > R[3], double alpha)
 \( R += \alpha (I \otimes I) \)
void pluseq_I_outer_product (MsqMatrix< 3, 3 > R[6], const MsqMatrix< 3, 3 > &A)
 \( R += I \otimes A \)
void pluseq_outer_product_I (MsqMatrix< 3, 3 > R[6], const MsqMatrix< 3, 3 > &A)
 \( R += A \otimes I \)
template<unsigned D>
void pluseq_scaled_sum_outer_product_I_t (MsqMatrix< D, D > R[D *(D+1)/2], double alpha, const MsqMatrix< D, D > &A)
 \( R += \alpha \left( I \otimes A + A \otimes I \right) \)
void pluseq_scaled_sum_outer_product_I (MsqMatrix< 3, 3 > R[6], double alpha, const MsqMatrix< 3, 3 > &A_in)
void pluseq_scaled_sum_outer_product_I (MsqMatrix< 2, 2 > R[2], double alpha, const MsqMatrix< 2, 2 > &A_in)
template<unsigned D>
void second_deriv_wrt_product_factor_t (MsqMatrix< D, D > R[D *(D+1)/2], const MsqMatrix< D, D > &Z)
 \( \frac{\partial^2 f}{\partial (AZ)^2} \Rightarrow \frac{\partial^2 f}{\partial A^2} \)
void second_deriv_wrt_product_factor (MsqMatrix< 3, 3 > R[6], const MsqMatrix< 3, 3 > &Z)
void second_deriv_wrt_product_factor (MsqMatrix< 2, 2 > R[3], const MsqMatrix< 2, 2 > &Z)
void set_scaled_2nd_deriv_wrt_psi (MsqMatrix< 2, 2 > R[3], const double alpha, const double psi, const MsqMatrix< 2, 2 > &T)
 \( R = \alpha * \frac{\partial^2 \psi(T)}{\partial T^2} \)
template<unsigned D>
void pluseq_scaled_t (MsqMatrix< D, D > R[D *(D+1)/2], double alpha, const MsqMatrix< D, D > Z[D *(D+1)/2])
 \( R = R + \alpha * Z \)
void pluseq_scaled_2nd_deriv_tr_adj (MsqMatrix< 2, 2 > *, double)
void pluseq_I_outer_product (MsqMatrix< 2, 2 > R[3], const MsqMatrix< 2, 2 > &A)
void pluseq_outer_product_I (MsqMatrix< 2, 2 > R[3], const MsqMatrix< 2, 2 > &A)
template<unsigned D>
void pluseq_scaled (MsqMatrix< D, D > R[D *(D+1)/2], double alpha, const MsqMatrix< D, D > Z[D *(D+1)/2])
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION (CircleDomainTest,"CircleDomainTest")
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION (CircleDomainTest,"Unit")
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION (LineDomainTest,"LineDomainTest")
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION (LineDomainTest,"Unit")
void destroy_patch_with_domain (PatchData &pd)
 must be called in sync with create_...._patch_with_domain
void move_vertex (PatchData &pd, const Vector3D &position, const Vector3D &delta, MsqError &err)
void create_one_hex_patch (PatchData &one_hex_patch, MsqError &err)
void create_one_tet_patch (PatchData &one_tet_patch, MsqError &err)
 creates a Patch containing an ideal tetrahedra
void create_one_pyr_patch (PatchData &one_pyr_patch, MsqError &err)
 create patch containing one ideal pyramid
void create_one_wdg_patch (PatchData &one_wdg_patch, MsqError &err)
 create patch containing one ideal wedge
void create_one_inverted_tet_patch (PatchData &one_tet_patch, MsqError &err)
 creates a Patch containing an ideal tetrahedra, inverted
void create_one_quad_patch (PatchData &one_qua_patch, MsqError &err)
 creates a Patch containing an ideal quadrilateral
void create_one_tri_patch (PatchData &one_tri_patch, MsqError &err)
void create_two_tri_patch (PatchData &pd, MsqError &err)
void create_four_quads_patch (PatchData &four_quads, MsqError &err)
void create_six_quads_patch_with_domain (PatchData &pd, MsqError &err)
void create_six_quads_patch_inverted_with_domain (PatchData &pd, MsqError &err)
void create_twelve_hex_patch (PatchData &pd, MsqError &err)
void create_twelve_hex_patch_inverted (PatchData &pd, MsqError &err)
void create_qm_two_tri_patch_with_domain (PatchData &triPatch, MsqError &err)
void create_qm_two_quad_patch_with_domain (PatchData &quadPatch, MsqError &err)
void create_qm_two_tet_patch (PatchData &tetPatch, MsqError &err)
void create_qm_two_pyr_patch (PatchData &pyrPatch, MsqError &err)
void create_qm_two_wdg_patch (PatchData &wdgPatch, MsqError &err)
void create_qm_two_hex_patch (PatchData &hexPatch, MsqError &err)
void create_ideal_element_patch (PatchData &pd, EntityTopology type, size_t num_nodes, MsqError &err)

Variables

const bool IQ_TRAP_FPE_DEFAULT = false
const unsigned long GRAD_FLAGS
const unsigned long OF_FLAGS
const unsigned long MOVEMENT_FLAGS
const bool OF_FREE_EVALS_ONLY = true
const int MSQ_MAX_NUM_VERT_PER_ENT = 8
const int MSQ_HIST_SIZE = 7
static const double MSQ_SQRT_TWO = std::sqrt( 2.0 )
static const double MSQ_SQRT_THREE = std::sqrt( 3.0 )
static const double MSQ_SQRT_THREE_DIV_TWO = MSQ_SQRT_THREE / 2.0
static const double MSQ_SQRT_THREE_INV = 1.0 / MSQ_SQRT_THREE
static const double MSQ_SQRT_TWO_INV = 1.0 / MSQ_SQRT_TWO
static const double MSQ_SQRT_TWO_DIV_SQRT_THREE = MSQ_SQRT_TWO / MSQ_SQRT_THREE
static const double MSQ_ONE_THIRD = 1.0 / 3.0
static const double MSQ_TWO_THIRDS = 2.0 / 3.0
static const double MSQ_3RT_2_OVER_6RT_3 = std::pow( 2 / MSQ_SQRT_THREE, MSQ_ONE_THIRD )
const unsigned MSQ_UINT_MAX = ~(unsigned)0
const int MSQ_INT_MAX = MSQ_UINT_MAX >> 1
const int MSQ_INT_MIN = ~MSQ_INT_MAX
const double MSQ_DBL_MIN = 1.0E-30
const double MSQ_MIN = MSQ_DBL_MIN
const double MSQ_DBL_MAX = 1.0E30
const double MSQ_MAX = MSQ_DBL_MAX
const double MSQ_MAX_CAP = 1.e6
static const unsigned edges [][2] = { { 0, 1 }, { 1, 2 }, { 2, 0 }, { 0, 3 }, { 1, 3 }, { 2, 3 } }
const double ft = 4.0 / 3.0
const double ho_dr [6][4]
const double ho_ds [6][4]
const double ho_dt [6][4]
static const int zeros [6] = { 0, 2, 1, 2, 1, 0 }
static const int signs [6] = { -1, 1, -1, -1, 1, 1 }
static const double edr [3][3] = { { 0.0, -2.0, 2.0 }, { 0.0, 2.0, 2.0 }, { 0.0, -2.0, -2.0 } }
static const double eds [3][3] = { { -2.0, -2.0, 0.0 }, { 2.0, 2.0, 0.0 }, { 2.0, -2.0, 0.0 } }
static const double fdr [] = { 0.0, 4.0 / 3.0, -4.0 / 3.0 }
static const double fds [] = { -4.0 / 3.0, 4.0 / 3.0, 0.0 }
static const char * nonlinear_error = "Attempt to use LinearHexahedron mapping function for a nonlinear element\n"
const unsigned xi = 0
const unsigned eta = 1
const unsigned zeta = 2
const int edge_dir [] = { xi, eta, xi, eta, zeta, zeta, zeta, zeta, xi, eta, xi, eta }
const int edge_beg [] = { 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7 }
const int edge_end [] = { 1, 2, 3, 0, 4, 5, 6, 7, 5, 6, 7, 4 }
const int edge_opposite [] = { 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1 }
const int edge_beg_orth1 []
const int edge_beg_orth2 []
const int edge_end_orth1 []
const int edge_end_orth2 []
const int face_vtx [6][4]
const int face_opp [6] = { 2, 3, 0, 1, 5, 4 }
const int face_dir [6] = { eta, xi, eta, xi, zeta, zeta }
static const int faces [5][5]
const int sign [2][4]
const PatchSet::PatchHandle GLOBAL_PATCH_HANDLE = 0
static Vector3D unit_quad [4]
static Vector3D unit_hex [8]
static Vector3D unit_edge_tri [3]
static Vector3D unit_edge_tet [4]
static Vector3D unit_edge_pyr [5]
static Vector3D unit_edge_wdg [6]
static Vector3D unit_height_pyr [5]
static Vector3D unit_tri [3]
static Vector3D unit_tet [4]
static Vector3D unit_pyr [5]
static Vector3D unit_wdg [6]
static Vector3D unit_hex_pyr [5]
const char * MESQUITE_FIELD_TAG = "MesquiteTags"
const char *const vtk_type_names []
const std::vector< size_t > dummy_list
const Vector3D dummy_vtx
const char long_polygon_name [] = "Polygon"
const char long_triangle_name [] = "Triangle"
const char long_quadrilateral_name [] = "Quadrilateral"
const char long_polyhedron_name [] = "Polyhedron"
const char long_tetrahedron_name [] = "Tetrahedron"
const char long_hexahedron_name [] = "Hexahedron"
const char long_prism_name [] = "Prism"
const char long_pyramid_name [] = "Pyramd"
const char long_septahedron_name [] = "Septahedron"
const char short_polygon_name [] = "Polygon"
const char short_triangle_name [] = "Tri"
const char short_quadrilateral_name [] = "Quad"
const char short_polyhedron_name [] = "Polyhedron"
const char short_tetrahedron_name [] = "Tet"
const char short_hexahedron_name [] = "Hex"
const char short_prism_name [] = "Pri"
const char short_pyramid_name [] = "Pyr"
const char short_septahedron_name [] = "Sept"
msq_sig_handler_t oldHandler = SIG_ERR
MBMesquite::StopWatchCollection GlobalStopWatches
const unsigned vtk_pixel_order [] = { 0, 1, 3, 2 }
const unsigned vtk_voxel_order [] = { 0, 1, 3, 2, 4, 5, 7, 6 }
const unsigned vtk_wedge_order []
const unsigned vtk_hex_order []
static const VtkTypeInfo typeInfoList []
const unsigned typeInfoListLen = sizeof( typeInfoList ) / sizeof( typeInfoList[0] )
const unsigned reverseIndexList [][3]
const double EPSILON = 1e-16
const int MSQ_MAX_OPT_ITER = 20
const double TRI_XFORM_VALS [] = { 1.0, -1.0 / sqrt( 3.0 ), 0.0, 2.0 / sqrt( 3.0 ) }
MsqMatrix< 2, 2 > TRI_XFORM (TRI_XFORM_VALS)
const double TET_XFORM_VALS []
MsqMatrix< 3, 3 > TET_XFORM (TET_XFORM_VALS)
static const std::string & barrier_violated_msg_aw
static const std::string & barrier_violated_msg
const int P = 3
const
DeformingDomainWrapper::MeshCharacteristic 
DEFAULT_METRIC_TYPE = DeformingDomainWrapper::SHAPE
const bool DEFAULT_CULLING = true
const double DEFAULT_CPU_TIME = 0.0
const double DEFAULT_MOVEMENT_FACTOR = 0.01
const int DEFAULT_INNER_ITERATIONS = 2
const char DEFAULT_CURVE_TAG [] = "MesquiteCurveFraction"
const
DeformingCurveSmoother::Scheme 
DEFAULT_CURVE_TYPE = DeformingCurveSmoother::PROPORTIONAL
const bool CULLING_DEFAULT = true
const int DEFAULT_ITERATION_LIMIT = 100
const double DEF_UNT_BETA = 1e-8
const double DEF_SUC_EPS = 1e-4
const double DEFAULT_BETA = 0.0
const int DEFUALT_PARALLEL_ITERATIONS = 10
const char *const VERTEX_BYTE_TAG_NAME = "MesquiteVertexByte"

Detailed Description

Implements the NonSmoothDescent class member functions.

NonSmoothDescent.cpp

Author:
Lori Freitag
Date:
2002-07-20

Typedef Documentation

Definition at line 63 of file MeshInterface.hpp.

typedef void( * MBMesquite::msq_sig_handler_t)(int)

Definition at line 36 of file MsqInterrupt.cpp.

typedef double MBMesquite::real

Definition at line 82 of file Mesquite.hpp.

Definition at line 80 of file Mesquite.hpp.

typedef void* MBMesquite::TagHandle

Type used to refer to a tag defintion

Definition at line 66 of file MeshInterface.hpp.

Definition at line 62 of file ParallelHelper.hpp.

Definition at line 61 of file MeshInterface.hpp.


Enumeration Type Documentation

Enumerator:
NO_SCHEME 
ELEMENT_AVG_QM 
ELEMENT_MAX_QM 
TMP_QUALITY_METRIC 
QUALITY_METRIC 

Definition at line 104 of file Mesquite.hpp.

Enumerator:
POLYGON 
TRIANGLE 
QUADRILATERAL 
POLYHEDRON 
TETRAHEDRON 
HEXAHEDRON 
PRISM 
PYRAMID 
SEPTAHEDRON 
MIXED 

Definition at line 90 of file Mesquite.hpp.

{
    POLYGON       = 7,
    TRIANGLE      = 8,
    QUADRILATERAL = 9,
    POLYHEDRON    = 10,
    TETRAHEDRON   = 11,
    HEXAHEDRON    = 12,
    PRISM         = 13,
    PYRAMID       = 14,
    SEPTAHEDRON   = 15,
    MIXED
};
Enumerator:
RELEASE 
BETA 
ALPHA 

Definition at line 118 of file Mesquite.hpp.

Enumerator:
COUNTERCLOCKWISE 
CLOCKWISE 

Definition at line 50 of file NonSmoothDescent.cpp.

Enumerator:
MSQ_FAILURE 
MSQ_SUCCESS 

Definition at line 84 of file Mesquite.hpp.

defines the termination criterion

Enumerator:
NONE 
GRADIENT_L2_NORM_ABSOLUTE 

checks the gradient \(\nabla f \) of objective function \(f : I\!\!R^{3N} \rightarrow I\!\!R \) against a double \(d\) and stops when \(\sqrt{\sum_{i=1}^{3N}\nabla f_i^2}<d\)

GRADIENT_INF_NORM_ABSOLUTE 

checks the gradient \(\nabla f \) of objective function \(f : I\!\!R^{3N} \rightarrow I\!\!R \) against a double \(d\) and stops when \( \max_{i=1}^{3N} \nabla f_i < d \)

GRADIENT_L2_NORM_RELATIVE 

terminates on the j_th iteration when \(\sqrt{\sum_{i=1}^{3N}\nabla f_{i,j}^2}<d\sqrt{\sum_{i=1}^{3N}\nabla f_{i,0}^2}\) That is, terminates when the norm of the gradient is small than some scaling factor times the norm of the original gradient.

GRADIENT_INF_NORM_RELATIVE 

terminates on the j_th iteration when \(\max_{i=1 \cdots 3N}\nabla f_{i,j}<d \max_{i=1 \cdots 3N}\nabla f_{i,0}\) That is, terminates when the norm of the gradient is small than some scaling factor times the norm of the original gradient. (Using the infinity norm.)

KKT 

Not yet implemented.

QUALITY_IMPROVEMENT_ABSOLUTE 

Terminates when the objective function value is smaller than the given scalar value.

QUALITY_IMPROVEMENT_RELATIVE 

Terminates when the objective function value is smaller than the given scalar value times the original objective function value.

NUMBER_OF_ITERATES 

Terminates when the number of iterations exceeds a given integer.

CPU_TIME 

Terminates when the algorithm exceeds an allotted time limit (given in seconds).

VERTEX_MOVEMENT_ABSOLUTE 

Terminates when a the maximum distance moved by any vertex during the previous iteration is below the given value.

VERTEX_MOVEMENT_ABS_EDGE_LENGTH 

Terminates when a the maximum distance moved by any vertex during the previous iteration is below a value calculated from the edge lengths of the initial mesh.

VERTEX_MOVEMENT_RELATIVE 

Terminates when a the maximum distance moved by any vertex during the previous iteration is below the given value times the maximum distance moved by any vertex over the entire course of the optimization.

SUCCESSIVE_IMPROVEMENTS_ABSOLUTE 

Terminates when the decrease in the objective function value since the previous iteration is below the given value.

SUCCESSIVE_IMPROVEMENTS_RELATIVE 

Terminates when the decrease in the objective function value since the previous iteration is below the given value times the decrease in the objective function value since the beginning of this optimization process.

BOUNDED_VERTEX_MOVEMENT 

Terminates when any vertex leaves the bounding box, defined by the given value, d. That is, when the absolute value of a single coordinate of vertex's position exceeds d.

UNTANGLED_MESH 

Terminate when no elements are inverted.

Definition at line 71 of file TerminationCriterion.cpp.

{
    NONE = 0,
    //! checks the gradient \f$\nabla f \f$ of objective function
    //! \f$f : I\!\!R^{3N} \rightarrow I\!\!R \f$ against a double \f$d\f$
    //! and stops when \f$\sqrt{\sum_{i=1}^{3N}\nabla f_i^2}<d\f$
    GRADIENT_L2_NORM_ABSOLUTE = 1 << 0,
    //! checks the gradient \f$\nabla f \f$ of objective function
    //! \f$f : I\!\!R^{3N} \rightarrow I\!\!R \f$ against a double \f$d\f$
    //! and stops when \f$ \max_{i=1}^{3N} \nabla f_i < d \f$
    GRADIENT_INF_NORM_ABSOLUTE = 1 << 1,
    //! terminates on the j_th iteration when
    //! \f$\sqrt{\sum_{i=1}^{3N}\nabla f_{i,j}^2}<d\sqrt{\sum_{i=1}^{3N}\nabla f_{i,0}^2}\f$
    //!  That is, terminates when the norm of the gradient is small
    //! than some scaling factor times the norm of the original gradient.
    GRADIENT_L2_NORM_RELATIVE = 1 << 2,
    //! terminates on the j_th iteration when
    //! \f$\max_{i=1 \cdots 3N}\nabla f_{i,j}<d \max_{i=1 \cdots 3N}\nabla f_{i,0}\f$
    //!  That is, terminates when the norm of the gradient is small
    //! than some scaling factor times the norm of the original gradient.
    //! (Using the infinity norm.)
    GRADIENT_INF_NORM_RELATIVE = 1 << 3,
    //! Not yet implemented.
    KKT = 1 << 4,
    //! Terminates when the objective function value is smaller than
    //! the given scalar value.
    QUALITY_IMPROVEMENT_ABSOLUTE = 1 << 5,
    //! Terminates when the objective function value is smaller than
    //! the given scalar value times the original objective function
    //! value.
    QUALITY_IMPROVEMENT_RELATIVE = 1 << 6,
    //! Terminates when the number of iterations exceeds a given integer.
    NUMBER_OF_ITERATES = 1 << 7,
    //! Terminates when the algorithm exceeds an allotted time limit
    //! (given in seconds).
    CPU_TIME = 1 << 8,
    //! Terminates when a the maximum distance moved by any vertex
    //! during the previous iteration is below the given value.
    VERTEX_MOVEMENT_ABSOLUTE = 1 << 9,
    //! Terminates when a the maximum distance moved by any vertex
    //! during the previous iteration is below a value calculated
    //! from the edge lengths of the initial mesh.
    VERTEX_MOVEMENT_ABS_EDGE_LENGTH = 1 << 10,
    //! Terminates when a the maximum distance moved by any vertex
    //! during the previous iteration is below the given value
    //! times the maximum distance moved by any vertex over the
    //! entire course of the optimization.
    VERTEX_MOVEMENT_RELATIVE = 1 << 11,
    //! Terminates when the decrease in the objective function value since
    //! the previous iteration is below the given value.
    SUCCESSIVE_IMPROVEMENTS_ABSOLUTE = 1 << 12,
    //! Terminates when the decrease in the objective function value since
    //! the previous iteration is below the given value times the
    //! decrease in the objective function value since the beginning
    //! of this optimization process.
    SUCCESSIVE_IMPROVEMENTS_RELATIVE = 1 << 13,
    //! Terminates when any vertex leaves the bounding box, defined
    //! by the given value, d.  That is, when the absolute value of
    //! a single coordinate of vertex's position exceeds d.
    BOUNDED_VERTEX_MOVEMENT = 1 << 14,
    //! Terminate when no elements are inverted
    UNTANGLED_MESH = 1 << 15
};

Function Documentation

MsqMatrix< 2, 2 > MBMesquite::adj ( const MsqMatrix< 2, 2 > &  m) [inline]

Definition at line 995 of file MsqMatrix.hpp.

Referenced by moab::Skinner::add_adjacency(), all_adjacency_regression(), check_meshset_common(), check_order_by_sets_and_adj(), check_set_contents(), MBMesquite::MeshImplData::clear_element(), moab::ReadHDF5::delete_non_side_elements(), MBMesquite::TShapeSize3DB2::evaluate(), MBMesquite::AWShape2DNB2::evaluate(), MBMesquite::AWShape2DB1::evaluate(), MBMesquite::TShapeSizeOrientB2::evaluate(), MBMesquite::TShape3DB2::evaluate(), MBMesquite::AffineMapMetric::evaluate(), MBMesquite::TShapeSize3DB2::evaluate_with_grad(), MBMesquite::AWShape2DNB2::evaluate_with_grad(), MBMesquite::TShape3DB2::evaluate_with_grad(), MBMesquite::TShapeSizeOrientB2::evaluate_with_grad(), MBMesquite::TShapeSize3DB2::evaluate_with_hess(), MBMesquite::TShape3DB2::evaluate_with_hess(), MBMesquite::TShapeSizeOrientB2::evaluate_with_hess(), MBMesquite::AffineMapMetric::evaluate_with_indices(), moab::Skinner::find_match(), find_side(), moab::Skinner::find_skin_vertices_1D(), moab::Skinner::find_skin_vertices_2D(), moab::Skinner::find_skin_vertices_3D(), MBMesquite::PatchData::get_adjacent_vertex_indices(), moab::ReorderTool::int_order_from_sets_and_adj(), moab::MeshSet::intersect(), inverse(), main(), mb_skin_verts_common(), mb_upward_adjacencies_test(), moab::MergeMesh::merge_higher_dimensions(), moab::Core::print_database(), print_elem_desc(), moab::Skinner::remove_adjacency(), MBMesquite::MeshImplData::set_element(), MBMesquite::MeshImplData::skin(), QualityMetricTest::test_diagonal_tau(), test_getEntArrAdj_conn(), test_getEntArrAdj_down(), test_getEntArrAdj_none(), test_getEntArrAdj_up(), test_getEntArrAdj_vertex(), QualityMetricTest::test_gradient_tau(), QualityMetricTest::test_Hessian_tau(), test_read_handle_tag_common(), test_read_side(), SlaveBoundaryVerticesTest::test_slaved_common(), MBMesquite::MeshImpl::vertices_get_attached_elements(), and moab::FBEngine::weave_lateral_face_from_edges().

{
    MsqMatrix< 2, 2 > result;
    result( 0, 0 ) = m( 1, 1 );
    result( 0, 1 ) = -m( 0, 1 );
    result( 1, 0 ) = -m( 1, 0 );
    result( 1, 1 ) = m( 0, 0 );
    return result;
}
MsqMatrix< 3, 3 > MBMesquite::adj ( const MsqMatrix< 3, 3 > &  m) [inline]

Definition at line 1015 of file MsqMatrix.hpp.

{
    MsqMatrix< 3, 3 > result;

    result( 0, 0 ) = m( 1, 1 ) * m( 2, 2 ) - m( 1, 2 ) * m( 2, 1 );
    result( 0, 1 ) = m( 0, 2 ) * m( 2, 1 ) - m( 0, 1 ) * m( 2, 2 );
    result( 0, 2 ) = m( 0, 1 ) * m( 1, 2 ) - m( 0, 2 ) * m( 1, 1 );

    result( 1, 0 ) = m( 1, 2 ) * m( 2, 0 ) - m( 1, 0 ) * m( 2, 2 );
    result( 1, 1 ) = m( 0, 0 ) * m( 2, 2 ) - m( 0, 2 ) * m( 2, 0 );
    result( 1, 2 ) = m( 0, 2 ) * m( 1, 0 ) - m( 0, 0 ) * m( 1, 2 );

    result( 2, 0 ) = m( 1, 0 ) * m( 2, 1 ) - m( 1, 1 ) * m( 2, 0 );
    result( 2, 1 ) = m( 0, 1 ) * m( 2, 0 ) - m( 0, 0 ) * m( 2, 1 );
    result( 2, 2 ) = m( 0, 0 ) * m( 1, 1 ) - m( 0, 1 ) * m( 1, 0 );

    return result;
}
static void MBMesquite::append_elem_samples ( PatchData &  pd,
size_t  e,
std::vector< size_t > &  handles 
) [inline, static]

Definition at line 113 of file TargetMetricUtil.cpp.

References MBMesquite::NodeSet::corner_node(), corners, edges, MBMesquite::PatchData::element_by_index(), faces, MBMesquite::MsqMeshEntity::get_element_type(), MBMesquite::PatchData::get_samples(), MBMesquite::ElemSampleQM::handle(), MBMesquite::NodeSet::mid_edge_node(), MBMesquite::NodeSet::mid_face_node(), MBMesquite::NodeSet::mid_region_node(), and MBMesquite::NodeSet::num_nodes().

Referenced by get_elem_sample_points(), and get_sample_pt_evaluations().

{
    NodeSet samples     = pd.get_samples( e );
    EntityTopology type = pd.element_by_index( e ).get_element_type();
    size_t curr_size    = handles.size();
    handles.resize( curr_size + samples.num_nodes() );
    std::vector< size_t >::iterator i = handles.begin() + curr_size;
    for( unsigned j = 0; j < TopologyInfo::corners( type ); ++j )
        if( samples.corner_node( j ) ) *( i++ ) = ElemSampleQM::handle( Sample( 0, j ), e );
    for( unsigned j = 0; j < TopologyInfo::edges( type ); ++j )
        if( samples.mid_edge_node( j ) ) *( i++ ) = ElemSampleQM::handle( Sample( 1, j ), e );
    for( unsigned j = 0; j < TopologyInfo::faces( type ); ++j )
        if( samples.mid_face_node( j ) ) *( i++ ) = ElemSampleQM::handle( Sample( 2, j ), e );
    if( TopologyInfo::dimension( type ) == 3 && samples.mid_region_node() )
        *( i++ ) = ElemSampleQM::handle( Sample( 3, 0 ), e );
}
template<typename T >
T* MBMesquite::arrptr ( std::vector< T > &  v,
bool  check_zero_size = false 
) [inline]

get array pointer from std::vector

Definition at line 245 of file Mesquite.hpp.

Referenced by MBMesquite::TerminationCriterion::accumulate_inner(), VtkTest::check_4quad_structured(), VtkTest::check_8hex_structured(), AveragingQMTest::check_average_and_weights(), VtkTest::check_field_attrib(), ExodusTest::check_mesh(), check_no_slaved_corners(), check_results(), check_slaved_coords(), MBMesquite::DomainClassifier::classify_by_tag(), MBMesquite::DomainClassifier::classify_geometrically(), MBMesquite::DomainClassifier::classify_skin_geometrically(), BCDTest::compare_bcd(), compare_node_coords(), compare_nodes(), MBMesquite::TagVertexMesh::copy_all_coordinates(), MBMesquite::BoundedCylinderDomain::create_curve(), MBMesquite::MsqIRel::domain_DoF(), elem_areas(), MBMesquite::MsqMOAB::elements_get_attached_vertices(), MBMesquite::MsqIMesh::elements_get_topologies(), MBMesquite::VertexConditionNumberQualityMetric::evaluate(), MBMesquite::TQualityMetric::evaluate_with_gradient(), MBMesquite::IdealWeightMeanRatio::evaluate_with_gradient(), MBMesquite::AWQualityMetric::evaluate_with_gradient(), MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_gradient(), MBMesquite::IdealWeightMeanRatio::evaluate_with_Hessian(), MBMesquite::TQualityMetric::evaluate_with_Hessian(), MBMesquite::AWQualityMetric::evaluate_with_Hessian(), MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_Hessian(), MBMesquite::IdealWeightMeanRatio::evaluate_with_Hessian_diagonal(), MBMesquite::TQualityMetric::evaluate_with_Hessian_diagonal(), MBMesquite::AWQualityMetric::evaluate_with_Hessian_diagonal(), MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_Hessian_diagonal(), MBMesquite::TMPQualityMetric::evaluate_with_indices(), MBMesquite::PatchData::fill(), find_skin(), find_z10_extreme_elements(), MBMesquite::SphericalDomain::fit_vertices(), MBMesquite::PlanarDomain::fit_vertices(), geom_classify_elements(), MBMesquite::MsqIMesh::get_adjacent_entities(), MBMesquite::MsqMOAB::get_adjacent_entities(), MBMesquite::MeshImpl::get_all_elements(), MBMesquite::MsqIMesh::get_all_elements(), MBMesquite::MsqMOAB::get_all_elements(), MBMesquite::MeshImpl::get_all_vertices(), MBMesquite::MsqIMesh::get_all_vertices(), MBMesquite::MsqMOAB::get_all_vertices(), IdealTargetTest::get_calc_target(), MBMesquite::PatchData::get_connectivity_array(), MBMesquite::MsqCommonIGeom::get_dimension(), MBMesquite::PatchData::get_element_array(), MBMesquite::PatchData::get_element_handles_array(), MBMesquite::PatchData::get_element_index(), MBMesquite::MsqMOAB::get_flag_data(), MBMesquite::MsqIMesh::get_flag_data(), PatchDataTest::get_higher_order_vertices(), QualityMetricTester::get_ideal_element(), MBMesquite::VertexPatches::get_patch(), MBMesquite::VertexPatches::get_patch_handles(), PatchDataTest::get_quad8_mesh(), MBMesquite::ReferenceMesh::get_reference_vertex_coordinates(), get_slaved_coords(), MBMesquite::ConjugateGradient::get_step(), MBMesquite::PatchData::get_subpatch(), MBMesquite::PatchData::get_vertex_array(), MBMesquite::PatchData::get_vertex_handles_array(), MBMesquite::PatchData::get_vertex_index(), MBMesquite::PatchData::initialize_data(), MBMesquite::Instruction::initialize_vertex_byte(), is_side_boundary(), MBMesquite::TargetWriter::loop_over_mesh(), MBMesquite::SlaveBoundaryVertices::loop_over_mesh(), main(), make_domain(), iMeshTest::matchElementConnectivity(), iMeshTest::matchVertexCoordinates(), MBMesquite::MeshUtil::meshes_are_different(), next_vertex(), MBMesquite::MsqCommonIGeom::normal(), UnOptimizer::optimize_vertex_positions(), MBMesquite::QuasiNewton::optimize_vertex_positions(), MBMesquite::TrustRegion::optimize_vertex_positions(), MBMesquite::ConjugateGradient::optimize_vertex_positions(), MBMesquite::SteepestDescent::optimize_vertex_positions(), MBMesquite::FeasibleNewton::optimize_vertex_positions(), MBMesquite::QualityAssessor::Assessor::print_histogram(), process_domain_args(), MBMesquite::MeshImpl::read_exodus(), MBMesquite::TerminationCriterion::reset_inner(), run(), MBMesquite::QualityAssessor::scale_histograms(), MBMesquite::MsqIMesh::set_active_set(), MBMesquite::MsqMOAB::set_active_set(), MBMesquite::PatchData::set_mesh_entities(), XYRectangleTest::setUp(), MBMesquite::XYRectangle::setup(), MeshInterfaceTest::setUp(), MeshImplTest::skin_mesh_higher_order(), MeshImplTest::skin_mesh_mixed(), tag_patch_slaved(), AveragingQMTest::test_average_and_weights_geometric(), AveragingQMTest::test_average_and_weights_harmonic(), AveragingQMTest::test_average_and_weights_hms(), AveragingQMTest::test_average_and_weights_linear(), AveragingQMTest::test_average_and_weights_maximum(), AveragingQMTest::test_average_and_weights_minimum(), AveragingQMTest::test_average_and_weights_rms(), AveragingQMTest::test_average_and_weights_sum(), AveragingQMTest::test_average_and_weights_sum_squared(), DomainClassifierTest::test_classify_by_geometry(), DomainClassifierTest::test_classify_by_handle(), DomainClassifierTest::test_classify_by_tag(), DomainClassifierTest::test_classify_skin(), XYRectangleTest::test_closest_point(), BoundedCylinderDomainTest::test_create_curve_from_mesh(), PMeanPTemplateTest::test_diagonal(), ConicDomainTest::test_domain_DoF(), SphericalDomainTest::test_domain_DoF(), XYRectangleTest::test_domain_DoF(), MeshInterfaceTest::test_element_get_attached_vertex_indices(), MeshInterfaceTest::test_elements_get_topology(), SphericalDomainTest::test_fit_vertices(), PatchDataTest::test_fixed_by_geom_dim(), PMeanPTemplateTest::test_gradient(), TerminationCriterionTest::test_gradient_common(), PMeanPTemplateTest::test_Hessian(), ObjectiveFunctionTest::test_LInf_value(), ObjectiveFunctionTest::test_LPtoP_value(), ObjectiveFunctionTest::test_max_value(), XYRectangleTest::test_normal_at(), PatchDataTest::test_patch_data_mesh_calcualted_ho_nodes(), PatchDataTest::test_quad8_patch(), VtkTest::test_read_fixed_attrib(), VtkTest::test_read_quadratic(), VtkTest::test_read_simple_scalar_attrib(), VtkTest::test_read_unstructured(), VtkTest::test_read_vector_attrib(), SlaveBoundaryVerticesTest::test_slaved_common(), XYRectangleTest::test_snap_to(), ArrayMeshTest::test_tag_data(), QualityAssessorTest::test_tag_element(), QualityAssessorTest::test_tag_inverted(), QualityAssessorTest::test_tag_vertex(), MBMesquite::DomainClassifier::test_valid_classification(), DomainClassifierTest::test_valid_classification(), MeshInterfaceTest::test_vertex_byte(), MeshInterfaceTest::test_vertex_get_attached_elements(), MeshInterfaceTest::test_vertex_is_fixed(), PatchSetTest::test_vertex_patches(), MeshInterfaceTest::test_vertices(), iMeshTest::testDoubleTag(), iMeshTest::testIntTag(), iMeshTest::testVertexFlag(), iMeshTest::testVertexFlagNone(), tet_dihedral_angle_ratios(), MBMesquite::PatchData::update_cached_normals(), uwt(), MBMesquite::MsqMOAB::vertices_get_attached_elements(), MBMesquite::MsqIMesh::vertices_get_byte(), MBMesquite::MsqMOAB::vertices_get_byte(), MBMesquite::TagVertexMesh::vertices_get_coordinates(), MBMesquite::MsqMOAB::vertices_get_coordinates(), MBMesquite::MsqIMesh::vertices_get_coordinates(), MBMesquite::MsqMOAB::vertices_set_byte(), MBMesquite::MsqIMesh::vertices_set_byte(), MBMesquite::MeshImpl::vtk_read_polygons(), MBMesquite::MeshImpl::vtk_read_scalar_attrib(), MBMesquite::MeshImpl::vtk_read_unstructured_grid(), MBMesquite::MeshImpl::vtk_store_cell_data(), MBMesquite::MeshImpl::vtk_store_point_data(), MBMesquite::MeshWriter::write_eps_triangle(), MBMesquite::MeshImpl::write_exodus(), MBMesquite::MeshWriter::write_stl(), and MBMesquite::MeshImpl::write_vtk().

{
    if( check_zero_size && !v.size() ) return 0;
    assert( !v.empty() );
    return &v[0];
}
template<typename T >
const T* MBMesquite::arrptr ( const std::vector< T > &  v,
bool  check_zero_size = false 
) [inline]

Definition at line 252 of file Mesquite.hpp.

{
    if( check_zero_size && !v.size() ) return 0;
    assert( !v.empty() );
    return &v[0];
}
template<typename HessIter >
static double MBMesquite::average_corner_diagonals ( EntityTopology  type,
QualityMetric::AveragingMethod  method,
unsigned  num_corner,
const double  corner_values[],
const Vector3D  corner_grads[],
HessIter  corner_diag_blocks,
Vector3D  vertex_grads[],
SymMatrix3D  vertex_hessians[],
MsqError &  err 
) [inline, static]

Definition at line 269 of file AveragingQM.cpp.

References corners, MBMesquite::QualityMetric::HARMONIC, MBMesquite::QualityMetric::HMS, inv(), MBMesquite::MsqError::INVALID_STATE, MBMesquite::QualityMetric::LINEAR, MSQ_SETERR, pmean_corner_diagonals(), MBMesquite::QualityMetric::RMS, MBMesquite::Vector3D::set(), MBMesquite::QualityMetric::SUM, sum_corner_diagonals(), sum_sqr_corner_diagonals(), and MBMesquite::QualityMetric::SUM_SQUARED.

Referenced by MBMesquite::AveragingQM::average_corner_hessian_diagonals().

{
    unsigned i;
    double avg, inv;

    // Zero gradients and Hessians
    const unsigned num_vertex = TopologyInfo::corners( type );
    for( i = 0; i < num_vertex; ++i )
    {
        vertex_grads[i].set( 0.0 );
        vertex_hessians[i] = SymMatrix3D( 0.0 );
    }

    switch( method )
    {
        case QualityMetric::SUM:
            avg = sum_corner_diagonals( type, num_corner, corner_values, corner_grads, corner_diag_blocks, vertex_grads,
                                        vertex_hessians );
            break;

        case QualityMetric::LINEAR:
            avg = sum_corner_diagonals( type, num_corner, corner_values, corner_grads, corner_diag_blocks, vertex_grads,
                                        vertex_hessians );
            inv = 1.0 / num_corner;
            avg *= inv;
            for( i = 0; i < num_vertex; ++i )
            {
                vertex_grads[i] *= inv;
                vertex_hessians[i] *= inv;
            }
            break;

        case QualityMetric::SUM_SQUARED:
            avg = sum_sqr_corner_diagonals( type, num_corner, corner_values, corner_grads, corner_diag_blocks,
                                            vertex_grads, vertex_hessians );
            break;

        case QualityMetric::RMS:
            avg = pmean_corner_diagonals( type, num_corner, corner_values, corner_grads, corner_diag_blocks,
                                          vertex_grads, vertex_hessians, 2.0 );
            break;

        case QualityMetric::HARMONIC:
            avg = pmean_corner_diagonals( type, num_corner, corner_values, corner_grads, corner_diag_blocks,
                                          vertex_grads, vertex_hessians, -1.0 );
            break;

        case QualityMetric::HMS:
            avg = pmean_corner_diagonals( type, num_corner, corner_values, corner_grads, corner_diag_blocks,
                                          vertex_grads, vertex_hessians, -2.0 );
            break;

        default:
            MSQ_SETERR( err )( "averaging method not available.", MsqError::INVALID_STATE );
            return 0.0;
    }

    return avg;
}
void MBMesquite::axpy ( Vector3D  res[],
size_t  size_r,
const MsqHessian &  H,
const Vector3D  x[],
size_t  size_x,
const Vector3D  y[],
size_t  size_y,
MsqError &   
) [inline]
Parameters:
res,:array of Vector3D in which the result is stored.
size_r,:size of the res array.
x,:vector multiplied by the Hessian.
size_x,:size of the x array.
y,:vector added to the Hessian vector product. Set to 0 (NULL) if not needed.
size_y,:size of the y array. Set to 0 if not needed.

Definition at line 246 of file MsqHessian.hpp.

References eqAx(), MBMesquite::MsqHessian::mColIndex, MBMesquite::MsqHessian::mEntries, MBMesquite::MsqHessian::mRowStart, MBMesquite::MsqHessian::mSize, plusEqAx(), and plusEqTransAx().

Referenced by MsqHessianTest::test_axpy().

{
    if( ( size_r != H.mSize ) || ( size_x != H.mSize ) || ( size_y != H.mSize && size_y != 0 ) )
    {
        // throw an error
    }

    Vector3D tmpx, tmpm;  // for cache opt.
    size_t* col     = H.mColIndex;
    const size_t nn = H.mSize;
    size_t rl;  // row length
    size_t el;  // entries index
    size_t lo;
    size_t c;  // column index
    size_t i, j;

    if( y != 0 )
    {
        for( i = 0; i < nn; ++i )
        {
            res[i] = y[i];
        }
    }
    else
    {  // y == 0
        for( i = 0; i < nn; ++i )
        {
            res[i] = 0.;
        }
    }

    el = 0;
    for( i = 0; i < nn; ++i )
    {
        rl = H.mRowStart[i + 1] - H.mRowStart[i];
        lo = *col++;

        // Diagonal entry
        tmpx = x[i];
        eqAx( tmpm, H.mEntries[el], tmpx );
        ++el;

        // Non-diagonal entries
        for( j = 1; j < rl; ++j )
        {
            c = *col++;
            //          res[i] += H.mEntries[e] * x[c];
            plusEqAx( tmpm, H.mEntries[el], x[c] );
            //          res[c] += transpose(H.mEntries[e]) * tmpxi;
            plusEqTransAx( res[c], H.mEntries[el], tmpx );
            ++el;
        }
        res[lo] += tmpm;
    }
}
double MBMesquite::cbrt_sqr ( double  d) [inline]

Definition at line 207 of file Mesquite.hpp.

References cbrt(), and MSQ_TWO_THIRDS.

Referenced by MBMesquite::Exponent::invTwoThirds(), and MBMesquite::Exponent::powTwoThirds().

{
#ifdef MOAB_HAVE_CBRT
    return ::cbrt( d * d );
#else
    return std::pow( d, MSQ_TWO_THIRDS );
#endif
}
static void MBMesquite::checkpoint_bytes ( Mesh *  mesh,
std::vector< unsigned char > &  saved_bytes,
MsqError &  err 
) [static]

Definition at line 441 of file VertexMover.cpp.

References MBMesquite::Mesh::get_all_vertices(), MSQ_ERRRTN, and MBMesquite::Mesh::vertices_get_byte().

Referenced by MBMesquite::VertexMover::loop_over_mesh().

{
    std::vector< Mesh::VertexHandle > vertexHandlesArray;
    mesh->get_all_vertices( vertexHandlesArray, err );MSQ_ERRRTN( err );
    saved_bytes.resize( vertexHandlesArray.size() );
    mesh->vertices_get_byte( &vertexHandlesArray[0], &saved_bytes[0], vertexHandlesArray.size(), err );MSQ_ERRRTN( err );
}
static int MBMesquite::coeff_eta_sign ( unsigned  coeff) [inline, static]

Definition at line 55 of file LinearHexahedron.cpp.

Referenced by derivatives_at_corner(), derivatives_at_mid_edge(), and derivatives_at_mid_face().

{
    return 2 * ( ( coeff / 2 ) % 2 ) - 1;
}
static int MBMesquite::coeff_xi_sign ( unsigned  coeff) [inline, static]

Definition at line 51 of file LinearHexahedron.cpp.

Referenced by derivatives_at_corner(), derivatives_at_mid_edge(), and derivatives_at_mid_face().

{
    return 2 * ( ( ( coeff + 1 ) / 2 ) % 2 ) - 1;
}
static int MBMesquite::coeff_zeta_sign ( unsigned  coeff) [inline, static]

Definition at line 59 of file LinearHexahedron.cpp.

Referenced by derivatives_at_corner(), derivatives_at_mid_edge(), and derivatives_at_mid_face().

{
    return 2 * ( coeff / 4 ) - 1;
}
static void MBMesquite::coefficients_at_corner ( unsigned  corner,
double *  coeff_out,
size_t *  indices_out,
size_t &  num_coeff 
) [static]
static void MBMesquite::coefficients_at_mid_edge ( unsigned  edge,
NodeSet  nodeset,
double *  coeff_out,
size_t *  indices_out,
size_t &  num_coeff 
) [static]

Definition at line 68 of file TetLagrangeShape.cpp.

References MBMesquite::NodeSet::mid_edge_node().

Referenced by MBMesquite::LinearPrism::coefficients(), MBMesquite::LinearHexahedron::coefficients(), MBMesquite::LinearPyramid::coefficients(), and MBMesquite::TetLagrangeShape::coefficients().

{
    if( nodeset.mid_edge_node( edge ) )
    {  // if mid-edge node is present
        num_coeff      = 1;
        indices_out[0] = 4 + edge;
        coeff_out[0]   = 1.0;
    }
    else
    {  // no mid node on edge
        num_coeff    = 2;
        coeff_out[0] = coeff_out[1] = 0.5;
        if( edge < 3 )
        {
            indices_out[0] = edge;
            indices_out[1] = ( edge + 1 ) % 3;
        }
        else
        {
            indices_out[0] = edge - 3;
            indices_out[1] = 3;
        }
    }
}
static void MBMesquite::coefficients_at_mid_edge ( unsigned  edge,
double *  coeff_out,
size_t *  indices_out,
size_t &  num_coeff 
) [static]

Definition at line 89 of file LinearHexahedron.cpp.

References edge_beg, and edge_end.

{
    num_coeff      = 2;
    coeff_out[0]   = 0.5;
    coeff_out[1]   = 0.5;
    indices_out[0] = edge_beg[edge];
    indices_out[1] = edge_end[edge];
}
static void MBMesquite::coefficients_at_mid_elem ( double *  coeff_out,
size_t *  indices_out,
size_t &  num_coeff 
) [static]

Definition at line 120 of file LinearHexahedron.cpp.

{
    num_coeff      = 8;
    coeff_out[0]   = 0.125;
    coeff_out[1]   = 0.125;
    coeff_out[2]   = 0.125;
    coeff_out[3]   = 0.125;
    coeff_out[4]   = 0.125;
    coeff_out[5]   = 0.125;
    coeff_out[6]   = 0.125;
    coeff_out[7]   = 0.125;
    indices_out[0] = 0;
    indices_out[1] = 1;
    indices_out[2] = 2;
    indices_out[3] = 3;
    indices_out[4] = 4;
    indices_out[5] = 5;
    indices_out[6] = 6;
    indices_out[7] = 7;
}
static void MBMesquite::coefficients_at_mid_elem ( NodeSet  nodeset,
double *  coeff_out,
size_t *  indices_out,
size_t &  num_coeff 
) [static]

Definition at line 191 of file TetLagrangeShape.cpp.

References MBMesquite::NodeSet::mid_edge_node().

Referenced by MBMesquite::LinearPrism::coefficients(), MBMesquite::LinearHexahedron::coefficients(), MBMesquite::LinearPyramid::coefficients(), and MBMesquite::TetLagrangeShape::coefficients().

{
    num_coeff      = 4;
    indices_out[0] = 0;
    indices_out[1] = 1;
    indices_out[2] = 2;
    indices_out[3] = 3;
    coeff_out[0]   = -0.125;
    coeff_out[1]   = -0.125;
    coeff_out[2]   = -0.125;
    coeff_out[3]   = -0.125;
    if( nodeset.mid_edge_node( 0 ) )
    {
        indices_out[num_coeff] = 4;
        coeff_out[num_coeff]   = 0.25;
        ++num_coeff;
    }
    else
    {
        coeff_out[0] += 0.125;
        coeff_out[1] += 0.125;
    }
    if( nodeset.mid_edge_node( 1 ) )
    {
        indices_out[num_coeff] = 5;
        coeff_out[num_coeff]   = 0.25;
        ++num_coeff;
    }
    else
    {
        coeff_out[1] += 0.125;
        coeff_out[2] += 0.125;
    }
    if( nodeset.mid_edge_node( 2 ) )
    {
        indices_out[num_coeff] = 6;
        coeff_out[num_coeff]   = 0.25;
        ++num_coeff;
    }
    else
    {
        coeff_out[2] += 0.125;
        coeff_out[0] += 0.125;
    }
    if( nodeset.mid_edge_node( 3 ) )
    {
        indices_out[num_coeff] = 7;
        coeff_out[num_coeff]   = 0.25;
        ++num_coeff;
    }
    else
    {
        coeff_out[0] += 0.125;
        coeff_out[3] += 0.125;
    }
    if( nodeset.mid_edge_node( 4 ) )
    {
        indices_out[num_coeff] = 8;
        coeff_out[num_coeff]   = 0.25;
        ++num_coeff;
    }
    else
    {
        coeff_out[1] += 0.125;
        coeff_out[3] += 0.125;
    }
    if( nodeset.mid_edge_node( 5 ) )
    {
        indices_out[num_coeff] = 9;
        coeff_out[num_coeff]   = 0.25;
        ++num_coeff;
    }
    else
    {
        coeff_out[2] += 0.125;
        coeff_out[3] += 0.125;
    }
}
static void MBMesquite::coefficients_at_mid_face ( unsigned  face,
NodeSet  nodeset,
double *  coeff_out,
size_t *  indices_out,
size_t &  num_coeff 
) [static]

Definition at line 94 of file TetLagrangeShape.cpp.

References MBMesquite::NodeSet::mid_edge_node().

Referenced by MBMesquite::LinearPrism::coefficients(), MBMesquite::LinearHexahedron::coefficients(), MBMesquite::LinearPyramid::coefficients(), and MBMesquite::TetLagrangeShape::coefficients().

{
    const double one_ninth  = 1.0 / 9.0;
    const double two_ninth  = 2.0 / 9.0;
    const double four_ninth = 4.0 / 9.0;

    if( face < 3 )
    {
        const int next = ( face + 1 ) % 3;
        indices_out[0] = face;
        indices_out[1] = next;
        indices_out[2] = 3;
        coeff_out[0]   = -one_ninth;
        coeff_out[1]   = -one_ninth;
        coeff_out[2]   = -one_ninth;
        num_coeff      = 3;
        if( nodeset.mid_edge_node( face ) )
        {
            indices_out[num_coeff] = 4 + face;
            coeff_out[num_coeff]   = four_ninth;
            ++num_coeff;
        }
        else
        {
            coeff_out[0] += two_ninth;
            coeff_out[1] += two_ninth;
        }
        if( nodeset.mid_edge_node( 3 + next ) )
        {
            indices_out[num_coeff] = 7 + next;
            coeff_out[num_coeff]   = four_ninth;
            ++num_coeff;
        }
        else
        {
            coeff_out[1] += two_ninth;
            coeff_out[2] += two_ninth;
        }
        if( nodeset.mid_edge_node( 3 + face ) )
        {
            indices_out[num_coeff] = 7 + face;
            coeff_out[num_coeff]   = four_ninth;
            ++num_coeff;
        }
        else
        {
            coeff_out[0] += two_ninth;
            coeff_out[2] += two_ninth;
        }
    }
    else
    {
        assert( face == 3 );
        indices_out[0] = 0;
        indices_out[1] = 1;
        indices_out[2] = 2;
        coeff_out[0]   = -one_ninth;
        coeff_out[1]   = -one_ninth;
        coeff_out[2]   = -one_ninth;
        num_coeff      = 3;
        if( nodeset.mid_edge_node( 0 ) )
        {
            indices_out[num_coeff] = 4;
            coeff_out[num_coeff]   = four_ninth;
            ++num_coeff;
        }
        else
        {
            coeff_out[0] += two_ninth;
            coeff_out[1] += two_ninth;
        }
        if( nodeset.mid_edge_node( 1 ) )
        {
            indices_out[num_coeff] = 5;
            coeff_out[num_coeff]   = four_ninth;
            ++num_coeff;
        }
        else
        {
            coeff_out[1] += two_ninth;
            coeff_out[2] += two_ninth;
        }
        if( nodeset.mid_edge_node( 2 ) )
        {
            indices_out[num_coeff] = 6;
            coeff_out[num_coeff]   = four_ninth;
            ++num_coeff;
        }
        else
        {
            coeff_out[2] += two_ninth;
            coeff_out[0] += two_ninth;
        }
    }
}
static void MBMesquite::coefficients_at_mid_face ( unsigned  face,
double *  coeff_out,
size_t *  indices_out,
size_t &  num_coeff 
) [static]

Definition at line 107 of file LinearHexahedron.cpp.

References face_vtx.

{
    num_coeff      = 4;
    coeff_out[0]   = 0.25;
    coeff_out[1]   = 0.25;
    coeff_out[2]   = 0.25;
    coeff_out[3]   = 0.25;
    indices_out[0] = face_vtx[face][0];
    indices_out[1] = face_vtx[face][1];
    indices_out[2] = face_vtx[face][2];
    indices_out[3] = face_vtx[face][3];
}
template<unsigned RC>
double MBMesquite::cofactor ( const MsqMatrix< RC, RC > &  m,
unsigned  r,
unsigned  c 
) [inline]

Definition at line 964 of file MsqMatrix.hpp.

References det(), and sign.

{
    const double sign[] = { 1.0, -1.0 };
    return sign[( r + c ) % 2] * det( MsqMatrix< RC - 1, RC - 1 >( m, r, c ) );
}
static bool MBMesquite::compare_sides ( unsigned  num_vtx,
const unsigned *  idx_set_1,
const Mesh::VertexHandle *  vtx_set_1,
const unsigned *  idx_set_2,
const Mesh::VertexHandle *  vtx_set_2 
) [static]

Helper function for 'find_skin'.

Check the vertices on element sides to see if the elements are adjacent.

Parameters:
num_vtxNumber of vertices in each element side
idx_set_1Indices into the first element's vertex list at which the side vertices are located.
vtx_set_1Vertex of first element.
idx_set_2Indices into the second element's vertex list at which the side vertices are located.
vtx_set_2Vertex of second element.

Definition at line 128 of file DomainClassifier.cpp.

Referenced by TopologyInfoTest::compare_sides(), find_skin(), and is_side_boundary().

{
    unsigned i;
    for( i = 0;; ++i )
    {
        if( i >= num_vtx ) return false;
        if( vtx_set_1[idx_set_1[0]] == vtx_set_2[idx_set_2[i]] ) break;
    }

    if( num_vtx == 1 ) return true;

    if( vtx_set_1[idx_set_1[1]] == vtx_set_2[idx_set_2[( i + 1 ) % num_vtx]] )
    {
        for( unsigned j = 2; j < num_vtx; ++j )
            if( vtx_set_1[idx_set_1[j]] != vtx_set_2[idx_set_2[( i + j ) % num_vtx]] ) return false;
        return true;
    }
    else if( vtx_set_1[idx_set_1[1]] == vtx_set_2[idx_set_2[( i + num_vtx - 1 ) % num_vtx]] )
    {
        for( unsigned j = 2; j < num_vtx; ++j )
            if( vtx_set_1[idx_set_1[j]] != vtx_set_2[idx_set_2[( i + num_vtx - j ) % num_vtx]] ) return false;
        return true;
    }
    else
    {
        return false;
    }
}
static double MBMesquite::condition3x3 ( const double  A[9]) [static]

Definition at line 1243 of file NonSmoothDescent.cpp.

References EPSILON.

Referenced by MBMesquite::NonSmoothDescent::singular_test().

{
    //   int ierr;
    double a11, a12, a13;
    double a21, a22, a23;
    double a31, a32, a33;
    //   double s1, s2, s4, s3, t0;
    double s1, s2, s3;
    double denom;
    //   double one = 1.0;
    double temp;
    bool zero_denom = true;

    a11 = A[0];
    a12 = A[1];
    a13 = A[2];
    a21 = A[3];
    a22 = A[4];
    a23 = A[5];
    a31 = A[6];
    a32 = A[7];
    a33 = A[8];

    denom = -a11 * a22 * a33 + a11 * a23 * a32 + a21 * a12 * a33 - a21 * a13 * a32 - a31 * a12 * a23 + a31 * a13 * a22;

    if( ( fabs( a11 ) > EPSILON ) && ( fabs( denom / a11 ) > EPSILON ) ) { zero_denom = false; }
    if( ( fabs( a22 ) > EPSILON ) && ( fabs( denom / a22 ) > EPSILON ) ) { zero_denom = false; }
    if( ( fabs( a33 ) > EPSILON ) && ( fabs( denom / a33 ) > EPSILON ) ) { zero_denom = false; }

    if( zero_denom ) { return HUGE_VAL; }
    else
    {
        s1 = sqrt( a11 * a11 + a12 * a12 + a13 * a13 + a21 * a21 + a22 * a22 + a23 * a23 + a31 * a31 + a32 * a32 +
                   a33 * a33 );

        temp = ( -a22 * a33 + a23 * a32 ) / denom;
        s3   = temp * temp;
        temp = ( a12 * a33 - a13 * a32 ) / denom;
        s3 += temp * temp;
        temp = ( a12 * a23 - a13 * a22 ) / denom;
        s3 += temp * temp;
        temp = ( a21 * a33 - a23 * a31 ) / denom;
        s3 += temp * temp;
        temp = ( a11 * a33 - a13 * a31 ) / denom;
        s3 += temp * temp;
        temp = ( a11 * a23 - a13 * a21 ) / denom;
        s3 += temp * temp;
        temp = ( a21 * a32 - a22 * a31 ) / denom;
        s3 += temp * temp;
        temp = ( -a11 * a32 + a12 * a31 ) / denom;
        s3 += temp * temp;
        temp = ( -a11 * a22 + a12 * a21 ) / denom;
        s3 += temp * temp;

        s2 = sqrt( s3 );
        return s1 * s2;
    }
}
static bool MBMesquite::condition_number_2d ( const Vector3D  temp_vec[],
size_t  e_ind,
PatchData &  pd,
double &  fval,
MsqError &  err 
) [inline, static]

Definition at line 48 of file ConditionNumberFunctions.hpp.

References MBMesquite::PatchData::get_domain_normal_at_element(), MSQ_ERRZERO, and MBMesquite::Vector3D::normalize().

Referenced by MBMesquite::VertexConditionNumberQualityMetric::evaluate(), and MBMesquite::ConditionNumberQualityMetric::evaluate().

{
    // norm squared of J
    double term1 = temp_vec[0] % temp_vec[0] + temp_vec[1] % temp_vec[1];

    Vector3D unit_surf_norm;
    pd.get_domain_normal_at_element( e_ind, unit_surf_norm, err );
    MSQ_ERRZERO( err );
    unit_surf_norm.normalize();

    // det J
    double temp_var = unit_surf_norm % ( temp_vec[0] * temp_vec[1] );

    // revert to old, non-barrier form
    if( temp_var <= 0.0 ) return false;
    fval = term1 / ( 2.0 * temp_var );
    return true;

    /*
    double h;
    double delta=pd.get_barrier_delta(err); MSQ_ERRZERO(err);

    // Note: technically, we want delta=eta*tau-max
    //       whereas the function above gives delta=eta*alpha-max
    //
    //       Because the only requirement on eta is eta << 1,
    //       and because tau-max = alpha-max/0.707 we can
    //       ignore the discrepancy

    if (delta==0) {
       if (temp_var < MSQ_DBL_MIN ) {
          return false;
       }
       else {
          h=temp_var;
       }

    // Note: when delta=0, the vertex_barrier_function
    //       formally gives h=temp_var as well.
    //       We just do it this way to avoid any
    //       roundoff issues.
    // Also: when delta=0, this metric is identical
    //       to the original condition number with
    //       the barrier at temp_var=0
    }
    else {
       h = QualityMetric::vertex_barrier_function(temp_var,delta);

       if (h<MSQ_DBL_MIN && fabs(temp_var) > MSQ_DBL_MIN ) {
         h = delta*delta/fabs(temp_var); }
       // Note: Analytically, h is strictly positive, but
       //       it can be zero numerically if temp_var
       //       is a large negative number
       //       In the case h=0, we use a different analytic
       //       approximation to compute h.
    }

    if (h<MSQ_DBL_MIN) {
      MSQ_SETERR(err)( "Barrier function is zero due to excessively large "
                       "negative area compared to delta. /n Try to untangle "
                       "mesh another way. ", MsqError::INVALID_MESH);
      return false;
    }

    fval=term1/(2*h);

    if (fval>MSQ_MAX_CAP) {
       fval=MSQ_MAX_CAP;
    }
    return true;
    */
}
static bool MBMesquite::condition_number_3d ( const Vector3D  temp_vec[],
PatchData &  ,
double &  fval,
MsqError &   
) [inline, static]

Definition at line 124 of file ConditionNumberFunctions.hpp.

Referenced by MBMesquite::VertexConditionNumberQualityMetric::evaluate(), and MBMesquite::ConditionNumberQualityMetric::evaluate().

{
    // norm squared of J
    double term1 = temp_vec[0] % temp_vec[0] + temp_vec[1] % temp_vec[1] + temp_vec[2] % temp_vec[2];
    // norm squared of adjoint of J
    double term2 = ( temp_vec[0] * temp_vec[1] ) % ( temp_vec[0] * temp_vec[1] ) +
                   ( temp_vec[1] * temp_vec[2] ) % ( temp_vec[1] * temp_vec[2] ) +
                   ( temp_vec[2] * temp_vec[0] ) % ( temp_vec[2] * temp_vec[0] );
    // det of J
    double temp_var = temp_vec[0] % ( temp_vec[1] * temp_vec[2] );

    // revert to old, non-barrier formulation
    if( temp_var <= 0.0 ) return false;
    fval = sqrt( term1 * term2 ) / ( 3.0 * temp_var );
    return true;

    /*
    double h;
    double delta=pd.get_barrier_delta(err); MSQ_ERRZERO(err);

    // Note: technically, we want delta=eta*tau-max
    //       whereas the function above gives delta=eta*alpha-max
    //
    //       Because the only requirement on eta is eta << 1,
    //       and because tau-max = alpha-max/0.707 we can
    //       ignore the discrepancy

    if (delta==0) {
       if (temp_var < MSQ_DBL_MIN ) {
          return false;
       }
       else {
          h=temp_var;
       }

    // Note: when delta=0, the vertex_barrier_function
    //       formally gives h=temp_var as well.
    //       We just do it this way to avoid any
    //       roundoff issues.
    // Also: when delta=0, this metric is identical
    //       to the original condition number with
    //       the barrier at temp_var=0

    }
    else {
       h = QualityMetric::vertex_barrier_function(temp_var,delta);

       if (h<MSQ_DBL_MIN && fabs(temp_var) > MSQ_DBL_MIN ) {
         h = delta*delta/fabs(temp_var); }

       // Note: Analytically, h is strictly positive, but
       //       it can be zero numerically if temp_var
       //       is a large negative number
       //       In the h=0, we use a different analytic
       //       approximation to compute h.
    }
    if (h<MSQ_DBL_MIN) {
      MSQ_SETERR(err)("Barrier function is zero due to excessively large "
                      "negative area compared to delta. /n Try to untangle "
                      "mesh another way. ", MsqError::INVALID_MESH);
      return false;
    }

    fval=sqrt(term1*term2)/(3*h);

    if (fval>MSQ_MAX_CAP) {
       fval=MSQ_MAX_CAP;
    }
    return true;
    */
}
static double MBMesquite::corner_volume ( const Vector3D &  v0,
const Vector3D &  v1,
const Vector3D &  v2,
const Vector3D &  v3 
) [inline, static]

Definition at line 104 of file MsqMeshEntity.cpp.

Referenced by MBMesquite::MsqMeshEntity::compute_unsigned_area().

{
    return ( v1 - v0 ) * ( v2 - v0 ) % ( v3 - v0 );
}
MBMesquite::CPPUNIT_TEST_SUITE_NAMED_REGISTRATION ( CircleDomainTest  ,
"CircleDomainTest"   
)
MBMesquite::CPPUNIT_TEST_SUITE_NAMED_REGISTRATION ( LineDomainTest  ,
"LineDomainTest"   
)
MBMesquite::CPPUNIT_TEST_SUITE_NAMED_REGISTRATION ( CircleDomainTest  ,
"Unit"   
)
MBMesquite::CPPUNIT_TEST_SUITE_NAMED_REGISTRATION ( LineDomainTest  ,
"Unit"   
)
MBMesquite::create_four_quads_patch ( PatchData &  four_quads,
MsqError &  err 
) [inline]

our 2D set up: 4 quads, center vertex outcentered by (0,-0.5) 7____6____5 | | | | 2 | 3 | 8-_ | _-4 vertex 1 is at (0,0) | -_0_- | vertex 5 is at (2,2) | 0 | 1 | 1----2----3

Definition at line 237 of file PatchDataInstances.hpp.

References MBMesquite::PatchData::fill(), and QUADRILATERAL.

Referenced by PMeanPMetricTest::setUp(), CachingTargetTest::setUp(), ExtraDataTest::test_notify_new_patch_fill(), ExtraDataTest::test_notify_new_patch_sub(), and ExtraDataTest::test_notify_subpatch().

{
    double coords[] = { 1, .5, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 2, 1, 0, 2, 2, 0, 1, 2, 0, 0, 2, 0, 0, 1, 0 };

    size_t indices[] = { 1, 2, 0, 8, 2, 3, 4, 0, 8, 0, 6, 7, 0, 4, 5, 6 };

    four_quads.fill( 9, coords, 4, QUADRILATERAL, indices, 0, err );
}
void MBMesquite::create_ideal_element_patch ( PatchData &  pd,
EntityTopology  type,
size_t  num_nodes,
MsqError &  err 
) [inline]

Definition at line 471 of file PatchDataInstances.hpp.

References MBMesquite::PatchData::attach_settings(), conn, corners, dim, MBMesquite::PatchData::fill(), fixed, MSQ_ERRRTN, n, MBMesquite::PatchData::set_domain(), MBMesquite::Settings::set_slaved_ho_node_mode(), settings, MBMesquite::Settings::SLAVE_NONE, unit_edge_element(), and MBMesquite::PlanarDomain::XY.

Referenced by MsqMeshEntityTest::test_check_element_orientation().

{
    static PlanarDomain zplane( PlanarDomain::XY );
    static Settings settings;
    settings.set_slaved_ho_node_mode( Settings::SLAVE_NONE );
    pd.attach_settings( &settings );

    // build list of vertex coordinates
    const Vector3D* corners = unit_edge_element( type );
    std::vector< Vector3D > coords( corners, corners + TopologyInfo::corners( type ) );
    bool mids[4] = { false };
    TopologyInfo::higher_order( type, num_nodes, mids[1], mids[2], mids[3], err );MSQ_ERRRTN( err );
    std::vector< size_t > conn( coords.size() );
    for( unsigned i = 0; i < coords.size(); ++i )
        conn[i] = i;

    for( unsigned dim = 1; dim <= TopologyInfo::dimension( type ); ++dim )
    {
        if( !mids[dim] ) continue;

        int num_side;
        if( dim == TopologyInfo::dimension( type ) )
            num_side = 1;
        else
            num_side = TopologyInfo::adjacent( type, dim );

        for( int s = 0; s < num_side; ++s )
        {
            unsigned idx = TopologyInfo::higher_order_from_side( type, num_nodes, dim, s, err );MSQ_ERRRTN( err );
            conn.push_back( idx );

            unsigned n;
            const unsigned* side = TopologyInfo::side_vertices( type, dim, s, n, err );MSQ_ERRRTN( err );
            Vector3D avg = coords[side[0]];
            for( unsigned v = 1; v < n; ++v )
                avg += coords[side[v]];
            avg *= 1.0 / n;
            coords.push_back( avg );
        }
    }

    bool* fixed = new bool[coords.size()];
    std::fill( fixed, fixed + coords.size(), false );
    pd.fill( coords.size(), coords[0].to_array(), 1, &type, &num_nodes, &conn[0], fixed, err );
    delete[] fixed;MSQ_ERRRTN( err );

    if( TopologyInfo::dimension( type ) == 2 ) pd.set_domain( &zplane );
}
void MBMesquite::create_one_hex_patch ( PatchData &  one_hex_patch,
MsqError &  err 
) [inline]

creates a patch containing one ideal hexahedra

Definition at line 98 of file PatchDataInstances.hpp.

References MBMesquite::PatchData::fill(), and HEXAHEDRON.

Referenced by MsqMeshEntityTest::setUp().

{
    double coords[] = { 1.0, 1.0, 1.0, 2.0, 1.0, 1.0, 2.0, 2.0, 1.0, 1.0, 2.0, 1.0,
                        1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0, 2.0, 2.0, 1.0, 2.0, 2.0 };

    size_t indices[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };

    one_hex_patch.fill( 8, coords, 1, HEXAHEDRON, indices, 0, err );
}
void MBMesquite::create_one_inverted_tet_patch ( PatchData &  one_tet_patch,
MsqError &  err 
) [inline]

creates a Patch containing an ideal tetrahedra, inverted

Definition at line 159 of file PatchDataInstances.hpp.

References MBMesquite::PatchData::fill(), and TETRAHEDRON.

{
    double coords[] = {
        1, 1, 1, 2, 1, 1, 1.5, 1 + sqrt( 3.0 ) / 2.0, 1, 1.5, 1 + sqrt( 3.0 ) / 6.0, 1 - sqrt( 2.0 ) / sqrt( 3.0 ),
    };

    size_t indices[4] = { 0, 1, 2, 3 };

    one_tet_patch.fill( 4, coords, 1, TETRAHEDRON, indices, 0, err );
}
void MBMesquite::create_one_pyr_patch ( PatchData &  one_pyr_patch,
MsqError &  err 
) [inline]

create patch containing one ideal pyramid

Definition at line 130 of file PatchDataInstances.hpp.

References MBMesquite::PatchData::fill(), and PYRAMID.

{
    /* Equilateral triangles
    double coords[] = { 1, -1, 0,
                        1,  1, 0,
                       -1,  1, 0,
                       -1, -1, 0,
                        0,  0, sqrt(2) };
    */
    /* Unit height */
    double coords[] = { 1, -1, 0, 1, 1, 0, -1, 1, 0, -1, -1, 0, 0, 0, 2 };

    size_t indices[5] = { 0, 1, 2, 3, 4 };

    one_pyr_patch.fill( 5, coords, 1, PYRAMID, indices, 0, err );
}
void MBMesquite::create_one_quad_patch ( PatchData &  one_qua_patch,
MsqError &  err 
) [inline]

creates a Patch containing an ideal quadrilateral

Definition at line 171 of file PatchDataInstances.hpp.

References MBMesquite::PatchData::fill(), and QUADRILATERAL.

Referenced by MsqMeshEntityTest::setUp().

{
    double coords[] = { 1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 1 };

    size_t indices[4] = { 0, 1, 2, 3 };

    one_qua_patch.fill( 4, coords, 1, QUADRILATERAL, indices, 0, err );
}
void MBMesquite::create_one_tet_patch ( PatchData &  one_tet_patch,
MsqError &  err 
) [inline]

creates a Patch containing an ideal tetrahedra

Definition at line 109 of file PatchDataInstances.hpp.

References MBMesquite::PatchData::fill(), and TETRAHEDRON.

Referenced by LVQDTargetTest::setUp(), and MsqMeshEntityTest::setUp().

{
    double coords[] = { 1.0,
                        1.0,
                        1.0,
                        2.0,
                        1.0,
                        1.0,
                        1.5,
                        1 + sqrt( 3.0 ) / 2.0,
                        1.0,
                        1.5,
                        1 + sqrt( 3.0 ) / 6.0,
                        1 + sqrt( 2.0 ) / sqrt( 3.0 ) };

    size_t indices[4] = { 0, 1, 2, 3 };

    one_tet_patch.fill( 4, coords, 1, TETRAHEDRON, indices, 0, err );
}
MBMesquite::create_one_tri_patch ( PatchData &  one_tri_patch,
MsqError &  err 
) [inline]

2 / \ creates a Patch containing an ideal triangle / \ 0-----1 This Patch also has the normal information.

Definition at line 187 of file PatchDataInstances.hpp.

References MBMesquite::PatchData::fill(), MBMesquite::PatchData::set_domain(), and TRIANGLE.

Referenced by LVQDTargetTest::setUp(), and MsqMeshEntityTest::setUp().

{
    /* ************** Creates normal info ******************* */
    Vector3D pnt( 0, 0, 0 );
    Vector3D s_norm( 0, 0, 3 );
    one_tri_patch.set_domain( new PlanarDomain( s_norm, pnt ) );

    /* *********************FILL tri************************* */
    double coords[] = { 1, 1, 1, 2, 1, 1, 1.5, 1 + sqrt( 3.0 ) / 2.0, 1 };

    size_t indices[3] = { 0, 1, 2 };
    one_tri_patch.fill( 3, coords, 1, TRIANGLE, indices, 0, err );
}
void MBMesquite::create_one_wdg_patch ( PatchData &  one_wdg_patch,
MsqError &  err 
) [inline]

create patch containing one ideal wedge

Definition at line 148 of file PatchDataInstances.hpp.

References MBMesquite::PatchData::fill(), MSQ_SQRT_THREE, and PRISM.

{
    double hgt      = 0.5 * MSQ_SQRT_THREE;
    double coords[] = { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.5, hgt, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.5, hgt, 1.0 };

    size_t indices[6] = { 0, 1, 2, 3, 4, 5 };

    one_wdg_patch.fill( 6, coords, 1, PRISM, indices, 0, err );
}
void MBMesquite::create_qm_two_hex_patch ( PatchData &  hexPatch,
MsqError &  err 
) [inline]

Definition at line 459 of file PatchDataInstances.hpp.

References conn, MBMesquite::PatchData::fill(), and HEXAHEDRON.

Referenced by CachingTargetTest::setUp().

{
    double coords[] = { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0,  1.0, 1.0, 0.0, 1.0,
                        1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 2.0, 0.0, 0.0, 2.0, 1.0, 0.0, 2.0, -1.0, 1.0, 3.0, 2.0, 1.0 };

    const size_t conn[] = { 0, 1, 2, 3, 4, 5, 6, 7, 1, 8, 9, 2, 5, 10, 11, 6 };

    hexPatch.fill( 12, coords, 2, HEXAHEDRON, conn, 0, err );
}
void MBMesquite::create_qm_two_pyr_patch ( PatchData &  pyrPatch,
MsqError &  err 
) [inline]

Definition at line 408 of file PatchDataInstances.hpp.

References conn, MBMesquite::PatchData::fill(), and PYRAMID.

{
    /* Equilateral triangles
    double coords[] = { 1, -1, 0,
                        1,  1, 0,
                       -1,  1, 0,
                       -1, -1, 0,
                        0,  0, sqrt(2) };
    */
    /* Unit height */
    double coords[] = { /* Equilateral triangles */
                        /*   1, -1, 0,
                             1,  1, 0,
                            -1,  1, 0,
                            -1, -1, 0,
                             0,  0, sqrt(2)  */
                        /* Unit height */
                        1, -1, 0, 1, 1, 0, -1, 1, 0, -1, -1, 0, 0, 0, 2,
                        /* Apex for a squashed pyramid */
                        0, 0, -1
    };

    const size_t conn[] = { 0, 1, 2, 3, 4, 3, 2, 1, 0, 5 };

    pyrPatch.fill( 6, coords, 2, PYRAMID, conn, 0, err );
}
void MBMesquite::create_qm_two_quad_patch_with_domain ( PatchData &  quadPatch,
MsqError &  err 
) [inline]

Definition at line 373 of file PatchDataInstances.hpp.

References conn, MBMesquite::PatchData::fill(), QUADRILATERAL, and MBMesquite::PatchData::set_domain().

{
    Vector3D pnt( 0, 0, 0 );
    Vector3D s_norm( 0, 0, 3 );
    quadPatch.set_domain( new PlanarDomain( s_norm, pnt ) );

    double coords[] = { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 2.0, -1.0, .5, 1.5, 1.0, 1.0 };

    const size_t conn[] = { 0, 1, 2, 3, 1, 4, 5, 2 };

    quadPatch.fill( 6, coords, 2, QUADRILATERAL, conn, 0, err );
}
void MBMesquite::create_qm_two_tet_patch ( PatchData &  tetPatch,
MsqError &  err 
) [inline]

Definition at line 391 of file PatchDataInstances.hpp.

References conn, MBMesquite::PatchData::fill(), and TETRAHEDRON.

Referenced by ObjectiveFunctionTests::compare_numerical_hessian(), ObjectiveFunctionTest::test_compute_ana_hessian_tet(), and ObjectiveFunctionTest::test_compute_ana_hessian_tet_scaled().

{
    double coords[] = {
        0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.5, sqrt( 3.0 ) / 2.0, 0.0, 0.5, sqrt( 3.0 ) / 6.0, sqrt( 2.0 ) / sqrt( 3.0 ),
        2.0, 3.0, -.5
    };

    const size_t conn[] = { 0, 1, 2, 3, 1, 4, 2, 3 };

    tetPatch.fill( 5, coords, 2, TETRAHEDRON, conn, 0, err );
}
void MBMesquite::create_qm_two_tri_patch_with_domain ( PatchData &  triPatch,
MsqError &  err 
) [inline]

Definition at line 353 of file PatchDataInstances.hpp.

References conn, MBMesquite::PatchData::fill(), MBMesquite::PatchData::set_domain(), and TRIANGLE.

{
    Vector3D pnt( 0, 0, 0 );
    Vector3D s_norm( 0, 0, 3 );
    triPatch.set_domain( new PlanarDomain( s_norm, pnt ) );

    double coords[] = { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.5, sqrt( 3.0 ) / 2.0, 0.0, 2.0, -4.0, 2.0 };

    const size_t conn[] = { 0, 1, 2, 0, 3, 1 };

    triPatch.fill( 4, coords, 2, TRIANGLE, conn, 0, err );
}
void MBMesquite::create_qm_two_wdg_patch ( PatchData &  wdgPatch,
MsqError &  err 
) [inline]

Definition at line 440 of file PatchDataInstances.hpp.

References conn, MBMesquite::PatchData::fill(), MSQ_SQRT_THREE, and PRISM.

{
    double hgt      = 0.5 * MSQ_SQRT_THREE;
    double coords[] = { // ideal prism vertices
                        0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.5, hgt, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.5, hgt, 1.0,
                        // top vertices for stretched wedge
                        0.5, -3.0, 0.0, 0.5, -4.0, 1.0
    };

    const size_t conn[] = { 0, 1, 2, 3, 4, 5, 1, 0, 6, 4, 3, 7 };

    wdgPatch.fill( 8, coords, 2, PRISM, conn, 0, err );
}
MBMesquite::create_six_quads_patch_inverted_with_domain ( PatchData &  four_quads,
MsqError &  err 
) [inline]

our 2D set up: 6 quads, 1 center vertex outcentered by (0,-0.5), the other centered 7____6____5___11 | | | | | 2 | 3 | 5 | 8 | 4---10 vertex 1 is at (0,0) |\ /| | vertex 11 is at (3,2) | | | 4 | 1----2----3----9 \ / 0 use destroy_patch_with_domain() in sync.

Definition at line 288 of file PatchDataInstances.hpp.

References create_six_quads_patch_with_domain(), MBMesquite::PatchData::move_vertex(), and MSQ_CHKERR.

{
    create_six_quads_patch_with_domain( pd, err );MSQ_CHKERR( err );

    Vector3D displacement( 0, -1.5, 0 );

    pd.move_vertex( displacement, 0, err );
}
void MBMesquite::create_six_quads_patch_with_domain ( PatchData &  pd,
MsqError &  err 
) [inline]

Definition at line 258 of file PatchDataInstances.hpp.

References MBMesquite::PatchData::fill(), fixed, QUADRILATERAL, and MBMesquite::PatchData::set_domain().

Referenced by create_six_quads_patch_inverted_with_domain(), and MsqFreeVertexIndexIteratorTest::setUp().

{
    // associates domain
    Vector3D pnt( 0, 0, 0 );
    Vector3D s_norm( 0, 0, 3 );
    pd.set_domain( new PlanarDomain( s_norm, pnt ) );

    double coords[] = { 1, .5, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 2, 1, 0, 2, 2, 0,
                        1, 2,  0, 0, 2, 0, 0, 1, 0, 3, 0, 0, 3, 1, 0, 3, 2, 0 };

    size_t indices[] = { 1, 2, 0, 8, 2, 3, 4, 0, 8, 0, 6, 7, 0, 4, 5, 6, 3, 9, 10, 4, 4, 10, 11, 5 };

    bool fixed[] = { false, true, true, true, false, true, true, true, true, true, true, true };

    pd.fill( 12, coords, 6, QUADRILATERAL, indices, fixed, err );
}
MBMesquite::create_twelve_hex_patch ( PatchData &  pd,
MsqError &  err 
) [inline]

3D set up: 12 quads, one center vertex outcentered by (0,-0.5), the other centered. Vertex 1 is at (0,0,-1). Vertex 35 is at (3,2,1).

7____6____5___11 19___18____17__23 31___30___29___35 | | | | | | | | | | | | | 2 | 3 | 5 | | | | | | 8 | 9 | 11 | 8----0----4---10 20-_ | _16---22 32---24---28---34 | | | | | -12_- | | | | | | | 0 | 1 | 4 | | | | | | 6 | 7 | 10 | 1----2----3----9 13---14---15---21 25---26---27---33

Definition at line 309 of file PatchDataInstances.hpp.

References MBMesquite::PatchData::fill(), fixed, and HEXAHEDRON.

Referenced by ObjectiveFunctionTests::compare_diagonal_gradient(), ObjectiveFunctionTests::compare_hessian_diagonal(), ObjectiveFunctionTests::compare_hessian_gradient(), ObjectiveFunctionTests::compare_numerical_gradient(), create_twelve_hex_patch_inverted(), CompositeOFTest::get_hessians(), CachingTargetTest::test_cache_cleared(), TerminationCriterionTest::test_gradient_common(), CompositeOFTest::test_multiply_hess_diagonal(), CompositeOFTest::test_multiply_hessian(), PatchDataTest::test_sub_patch(), TerminationCriterionTest::test_untangled_mesh(), TerminationCriterionTest::test_vertex_bound(), and TerminationCriterionTest::test_vertex_movement_common().

{
    double coords[] = { 1, 1,  -1, 0, 0, -1, 1, 0, -1, 2, 0, -1, 2, 1, -1, 2, 2, -1,
                        1, 2,  -1, 0, 2, -1, 0, 1, -1, 3, 0, -1, 3, 1, -1, 3, 2, -1,

                        1, .5, 0,  0, 0, 0,  1, 0, 0,  2, 0, 0,  2, 1, 0,  2, 2, 0,
                        1, 2,  0,  0, 2, 0,  0, 1, 0,  3, 0, 0,  3, 1, 0,  3, 2, 0,

                        1, 1,  1,  0, 0, 1,  1, 0, 1,  2, 0, 1,  2, 1, 1,  2, 2, 1,
                        1, 2,  1,  0, 2, 1,  0, 1, 1,  3, 0, 1,  3, 1, 1,  3, 2, 1 };

    size_t connectivity[] = { 1,  2,  0,  8,  13, 14, 12, 20,    // 0
                              2,  3,  4,  0,  14, 15, 16, 12,    // 1
                              8,  0,  6,  7,  20, 12, 18, 19,    // 2
                              0,  4,  5,  6,  12, 16, 17, 18,    // 3
                              3,  9,  10, 4,  15, 21, 22, 16,    // 4
                              4,  10, 11, 5,  16, 22, 23, 17,    // 5
                              13, 14, 12, 20, 25, 26, 24, 32,    // 6
                              14, 15, 16, 12, 26, 27, 28, 24,    // 7
                              20, 12, 18, 19, 32, 24, 30, 31,    // 8
                              12, 16, 17, 18, 24, 28, 29, 30,    // 9
                              15, 21, 22, 16, 27, 33, 34, 28,    // 10
                              16, 22, 23, 17, 28, 34, 35, 29 };  // 11

    bool fixed[] = { true,  true, true, true, true,  true, true, true, true, true, true, true,
                     false, true, true, true, false, true, true, true, true, true, true, true,
                     true,  true, true, true, true,  true, true, true, true, true, true, true };

    pd.fill( 36, coords, 12, HEXAHEDRON, connectivity, fixed, err );
}
void MBMesquite::create_twelve_hex_patch_inverted ( PatchData &  pd,
MsqError &  err 
) [inline]

Definition at line 340 of file PatchDataInstances.hpp.

References create_twelve_hex_patch(), move_vertex(), and MSQ_CHKERR.

{
    create_twelve_hex_patch( pd, err );MSQ_CHKERR( err );
    move_vertex( pd, Vector3D( 2, 1, 0 ), Vector3D( 0, 0, 1.5 ), err );MSQ_CHKERR( err );
}
MBMesquite::create_two_tri_patch ( PatchData &  one_tri_patch,
MsqError &  err 
) [inline]

2 / \ creates a Patch containing two ideal triangles / 0 \ 0-----1 \ 1 / \ / 3 This Patch also has the normal information.

Definition at line 211 of file PatchDataInstances.hpp.

References MBMesquite::PatchData::fill(), MBMesquite::PatchData::set_domain(), and TRIANGLE.

Referenced by MsqHessianTest::setUp().

{
    /* ************** Creates normal info ******************* */
    Vector3D pnt( 0, 0, 1 );
    Vector3D s_norm( 0, 0, 3 );
    pd.set_domain( new PlanarDomain( s_norm, pnt ) );

    // **********************FILL tri*************************

    double coords[] = { 1, 1, 1, 2, 1, 1, 1.5, 1 + sqrt( 3.0 ) / 2.0, 1, 1.5, 1 - sqrt( 3.0 ) / 2.0, 1 };

    size_t indices[] = { 0, 1, 2, 0, 3, 1 };

    pd.fill( 4, coords, 2, TRIANGLE, indices, 0, err );
}
const char* MBMesquite::default_name ( bool  free_only)

Definition at line 71 of file QualityAssessor.cpp.

Referenced by MBMesquite::QualityAssessor::QualityAssessor().

{
    static const char all_name[]  = "QualityAssessor";
    static const char free_name[] = "QualityAssessor(free only)";
    return free_only ? free_name : all_name;
}
static void MBMesquite::derivatives_at_corner ( unsigned  corner,
size_t *  vertex_indices,
MsqVector< 2 > *  derivs,
size_t &  num_vtx 
) [static]

Definition at line 99 of file LinearQuadrilateral.cpp.

References eta, sign, and xi.

{
    const unsigned adj_in_xi  = ( 5 - corner ) % 4;
    const unsigned adj_in_eta = 3 - corner;

    num_vtx           = 3;
    vertex_indices[0] = corner;
    vertex_indices[1] = adj_in_xi;
    vertex_indices[2] = adj_in_eta;

    derivs[0][0] = sign[xi][corner];
    derivs[0][1] = sign[eta][corner];
    derivs[1][0] = sign[xi][adj_in_xi];
    derivs[1][1] = 0.0;
    derivs[2][0] = 0.0;
    derivs[2][1] = sign[eta][adj_in_eta];
}
static void MBMesquite::derivatives_at_corner ( unsigned  corner,
NodeSet  nodeset,
size_t *  vertices,
MsqVector< 2 > *  derivs,
size_t &  num_vtx 
) [static]

Definition at line 126 of file QuadLagrangeShape.cpp.

References MBMesquite::NodeSet::mid_edge_node(), and mid_xi.

Referenced by MBMesquite::LinearPrism::derivatives(), MBMesquite::LinearHexahedron::derivatives(), MBMesquite::LinearQuadrilateral::derivatives(), MBMesquite::TriLagrangeShape::derivatives(), MBMesquite::QuadLagrangeShape::derivatives(), and MBMesquite::TetLagrangeShape::derivatives().

{
    static const unsigned xi_adj_corners[]  = { 1, 0, 3, 2 };
    static const unsigned xi_adj_edges[]    = { 0, 0, 2, 2 };
    static const unsigned eta_adj_corners[] = { 3, 2, 1, 0 };
    static const unsigned eta_adj_edges[]   = { 3, 1, 1, 3 };

    static const double corner_xi[]  = { -1, 1, 1, -1 };  // xi values by corner
    static const double corner_eta[] = { -1, -1, 1, 1 };  // eta values by corner
    static const double other_xi[]   = { 1, -1, -1, 1 };  // xi values for adjacent corner in xi direction
    static const double other_eta[]  = { 1, 1, -1, -1 };  // eta values for adjcent corner in eta direction
    static const double mid_xi[]     = { 2, -2, -2, 2 };  // xi values for mid-node in xi direction
    static const double mid_eta[]    = { 2, 2, -2, -2 };  // eta values for mid-node in eta direction

    num_vtx     = 3;
    vertices[0] = corner;
    vertices[1] = xi_adj_corners[corner];
    vertices[2] = eta_adj_corners[corner];

    derivs[0][0] = corner_xi[corner];
    derivs[0][1] = corner_eta[corner];
    derivs[1][0] = other_xi[corner];
    derivs[1][1] = 0.0;
    derivs[2][0] = 0.0;
    derivs[2][1] = other_eta[corner];

    if( nodeset.mid_edge_node( xi_adj_edges[corner] ) )
    {
        vertices[num_vtx]  = 4 + xi_adj_edges[corner];
        derivs[num_vtx][0] = 2.0 * mid_xi[corner];
        derivs[num_vtx][1] = 0.0;
        derivs[0][0] -= mid_xi[corner];
        derivs[1][0] -= mid_xi[corner];
        ++num_vtx;
    }

    if( nodeset.mid_edge_node( eta_adj_edges[corner] ) )
    {
        vertices[num_vtx]  = 4 + eta_adj_edges[corner];
        derivs[num_vtx][0] = 0.0;
        derivs[num_vtx][1] = 2.0 * mid_eta[corner];
        derivs[0][1] -= mid_eta[corner];
        derivs[2][1] -= mid_eta[corner];
        ++num_vtx;
    }
}
static void MBMesquite::derivatives_at_corner ( unsigned  corner,
size_t *  vertex_indices_out,
MsqVector< 3 > *  d_coeff_d_xi_out,
size_t &  num_vtx 
) [static]

Definition at line 169 of file LinearHexahedron.cpp.

References coeff_eta_sign(), coeff_xi_sign(), and coeff_zeta_sign().

{
    const int xi_sign   = coeff_xi_sign( corner );
    const int eta_sign  = coeff_eta_sign( corner );
    const int zeta_sign = coeff_zeta_sign( corner );
    const int offset    = 4 * ( corner / 4 );
    // const int adj_in_xi   = offset + (9 - corner)%4;
    const int adj_in_xi   = corner + 1 - 2 * ( corner % 2 );
    const int adj_in_eta  = 3 + 2 * offset - (int)corner;
    const int adj_in_zeta = corner - zeta_sign * 4;

    num_vtx               = 4;
    vertex_indices_out[0] = corner;
    vertex_indices_out[1] = adj_in_xi;
    vertex_indices_out[2] = adj_in_eta;
    vertex_indices_out[3] = adj_in_zeta;

    d_coeff_d_xi_out[0][0] = xi_sign;
    d_coeff_d_xi_out[0][1] = eta_sign;
    d_coeff_d_xi_out[0][2] = zeta_sign;

    d_coeff_d_xi_out[1][0] = -xi_sign;
    d_coeff_d_xi_out[1][1] = 0.0;
    d_coeff_d_xi_out[1][2] = 0.0;

    d_coeff_d_xi_out[2][0] = 0.0;
    d_coeff_d_xi_out[2][1] = -eta_sign;
    d_coeff_d_xi_out[2][2] = 0.0;

    d_coeff_d_xi_out[3][0] = 0.0;
    d_coeff_d_xi_out[3][1] = 0.0;
    d_coeff_d_xi_out[3][2] = -zeta_sign;
}
static void MBMesquite::derivatives_at_corner ( unsigned  corner,
NodeSet  nodeset,
size_t *  vertices,
MsqVector< 3 > *  derivs,
size_t &  num_vtx 
) [static]

Definition at line 324 of file TetLagrangeShape.cpp.

References get_linear_derivatives(), and MBMesquite::NodeSet::mid_edge_node().

{
    // begin with derivatives for linear tetrahedron
    num_vtx = 4;
    get_linear_derivatives( vertices, derivs );

    // adjust for the presence of mid-edge nodes
    switch( corner )
    {
        case 0:
            if( nodeset.mid_edge_node( 0 ) )
            {
                vertices[num_vtx]  = 4;
                derivs[num_vtx][0] = 4.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 0.0;
                derivs[0][0] -= 2.0;
                derivs[1][0] -= 2.0;
                ++num_vtx;
            }
            if( nodeset.mid_edge_node( 2 ) )
            {
                vertices[num_vtx]  = 6;
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 4.0;
                derivs[num_vtx][2] = 0.0;
                derivs[0][1] -= 2.0;
                derivs[2][1] -= 2.0;
                ++num_vtx;
            }
            if( nodeset.mid_edge_node( 3 ) )
            {
                vertices[num_vtx]  = 7;
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 4.0;
                derivs[0][2] -= 2.0;
                derivs[3][2] -= 2.0;
                ++num_vtx;
            }
            break;

        case 1:
            if( nodeset.mid_edge_node( 0 ) )
            {
                vertices[num_vtx]  = 4;
                derivs[num_vtx][0] = -4.0;
                derivs[num_vtx][1] = -4.0;
                derivs[num_vtx][2] = -4.0;
                derivs[0][0] += 2.0;
                derivs[0][1] += 2.0;
                derivs[0][2] += 2.0;
                derivs[1][0] += 2.0;
                derivs[1][1] += 2.0;
                derivs[1][2] += 2.0;
                ++num_vtx;
            }
            if( nodeset.mid_edge_node( 1 ) )
            {
                vertices[num_vtx]  = 5;
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 4.0;
                derivs[num_vtx][2] = 0.0;
                derivs[1][1] -= 2.0;
                derivs[2][1] -= 2.0;
                ++num_vtx;
            }
            if( nodeset.mid_edge_node( 4 ) )
            {
                vertices[num_vtx]  = 8;
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 4.0;
                derivs[1][2] -= 2.0;
                derivs[3][2] -= 2.0;
                ++num_vtx;
            }
            break;

        case 2:
            if( nodeset.mid_edge_node( 1 ) )
            {
                vertices[num_vtx]  = 5;
                derivs[num_vtx][0] = 4.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 0.0;
                derivs[1][0] -= 2.0;
                derivs[2][0] -= 2.0;
                ++num_vtx;
            }
            if( nodeset.mid_edge_node( 2 ) )
            {
                vertices[num_vtx]  = 6;
                derivs[num_vtx][0] = -4.0;
                derivs[num_vtx][1] = -4.0;
                derivs[num_vtx][2] = -4.0;
                derivs[0][0] += 2.0;
                derivs[0][1] += 2.0;
                derivs[0][2] += 2.0;
                derivs[2][0] += 2.0;
                derivs[2][1] += 2.0;
                derivs[2][2] += 2.0;
                ++num_vtx;
            }
            if( nodeset.mid_edge_node( 5 ) )
            {
                vertices[num_vtx]  = 9;
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 4.0;
                derivs[2][2] -= 2.0;
                derivs[3][2] -= 2.0;
                ++num_vtx;
            }
            break;

        case 3:
            if( nodeset.mid_edge_node( 3 ) )
            {
                vertices[num_vtx]  = 7;
                derivs[num_vtx][0] = -4.0;
                derivs[num_vtx][1] = -4.0;
                derivs[num_vtx][2] = -4.0;
                derivs[0][0] += 2.0;
                derivs[0][1] += 2.0;
                derivs[0][2] += 2.0;
                derivs[3][0] += 2.0;
                derivs[3][1] += 2.0;
                derivs[3][2] += 2.0;
                ++num_vtx;
            }
            if( nodeset.mid_edge_node( 4 ) )
            {
                vertices[num_vtx]  = 8;
                derivs[num_vtx][0] = 4.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 0.0;
                derivs[1][0] -= 2.0;
                derivs[3][0] -= 2.0;
                ++num_vtx;
            }

            if( nodeset.mid_edge_node( 5 ) )
            {
                vertices[num_vtx]  = 9;
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 4.0;
                derivs[num_vtx][2] = 0.0;
                derivs[2][1] -= 2.0;
                derivs[3][1] -= 2.0;
                ++num_vtx;
            }
            break;
    }
}
static void MBMesquite::derivatives_at_mid_edge ( unsigned  edge,
size_t *  vertices,
MsqVector< 2 > *  derivs,
size_t &  num_vtx 
) [static]

Definition at line 117 of file LinearQuadrilateral.cpp.

References sign.

{
    const unsigned start_vtx  = edge;
    const unsigned end_vtx    = ( edge + 1 ) % 4;
    const unsigned othr1_vtx  = ( edge + 2 ) % 4;
    const unsigned othr2_vtx  = ( edge + 3 ) % 4;
    const unsigned direction  = edge % 2;
    const unsigned orthogonal = 1 - direction;

    num_vtx     = 4;
    vertices[0] = 0;
    vertices[1] = 1;
    vertices[2] = 2;
    vertices[3] = 3;

    derivs[start_vtx][direction] = sign[direction][start_vtx];
    derivs[end_vtx][direction]   = sign[direction][end_vtx];
    derivs[othr1_vtx][direction] = 0.0;
    derivs[othr2_vtx][direction] = 0.0;

    derivs[0][orthogonal] = 0.5 * sign[orthogonal][0];
    derivs[1][orthogonal] = 0.5 * sign[orthogonal][1];
    derivs[2][orthogonal] = 0.5 * sign[orthogonal][2];
    derivs[3][orthogonal] = 0.5 * sign[orthogonal][3];
}
static void MBMesquite::derivatives_at_mid_edge ( unsigned  edge,
NodeSet  nodeset,
size_t *  vertices,
MsqVector< 2 > *  derivs,
size_t &  num_vtx 
) [static]

Definition at line 174 of file QuadLagrangeShape.cpp.

References MBMesquite::NodeSet::have_any_mid_node(), MBMesquite::NodeSet::mid_edge_node(), MBMesquite::NodeSet::mid_face_node(), and value().

Referenced by MBMesquite::LinearPrism::derivatives(), MBMesquite::LinearHexahedron::derivatives(), MBMesquite::LinearQuadrilateral::derivatives(), MBMesquite::TriLagrangeShape::derivatives(), MBMesquite::QuadLagrangeShape::derivatives(), and MBMesquite::TetLagrangeShape::derivatives().

{
    static const double values[][9]      = { { -0.5, -0.5, 0.5, 0.5, -1.0, 2.0, 1.0, 2.0, 4.0 },
                                        { -0.5, 0.5, 0.5, -0.5, -2.0, 1.0, -2.0, -1.0, -4.0 },
                                        { -0.5, -0.5, 0.5, 0.5, -1.0, -2.0, 1.0, -2.0, -4.0 },
                                        { -0.5, 0.5, 0.5, -0.5, 2.0, 1.0, 2.0, -1.0, 4.0 } };
    static const double edge_values[][2] = { { -1, 1 }, { -1, 1 }, { 1, -1 }, { 1, -1 } };
    const unsigned prev_corner           = edge;              // index of start vertex of edge
    const unsigned next_corner           = ( edge + 1 ) % 4;  // index of end vertex of edge
    const unsigned is_eta_edge           = edge % 2;          // edge is xi = +/- 0
    const unsigned is_xi_edge            = 1 - is_eta_edge;   // edge is eta = +/- 0
    // const unsigned mid_edge_node = edge + 4;     // mid-edge node index
    const unsigned prev_opposite = ( prev_corner + 3 ) % 4;  // index of corner adjacent to prev_corner
    const unsigned next_opposite = ( next_corner + 1 ) % 4;  // index of corner adjacent to next_corner;

    // First do derivatives along edge (e.g. wrt xi if edge is eta = +/-1)
    num_vtx                = 2;
    vertices[0]            = prev_corner;
    vertices[1]            = next_corner;
    derivs[0][is_eta_edge] = edge_values[edge][0];
    derivs[0][is_xi_edge]  = 0.0;
    derivs[1][is_eta_edge] = edge_values[edge][1];
    derivs[1][is_xi_edge]  = 0.0;
    // That's it for the edge-direction derivatives.  No other vertices contribute.

    // Next handle the linear element case.  Handle this as a special case first,
    // so the generalized solution doesn't impact performance for linear elements
    // too much.
    if( !nodeset.have_any_mid_node() )
    {
        num_vtx                = 4;
        vertices[2]            = prev_opposite;
        vertices[3]            = next_opposite;
        derivs[0][is_xi_edge]  = values[edge][prev_corner];
        derivs[1][is_xi_edge]  = values[edge][next_corner];
        derivs[2][is_xi_edge]  = values[edge][prev_opposite];
        derivs[2][is_eta_edge] = 0.0;
        derivs[3][is_xi_edge]  = values[edge][next_opposite];
        derivs[3][is_eta_edge] = 0.0;
        return;
    }

    // Initial (linear) contribution for each corner
    double v[4] = { values[edge][0], values[edge][1], values[edge][2], values[edge][3] };

    // If mid-face node is present
    double v8 = 0.0;
    if( nodeset.mid_face_node( 0 ) )
    {
        v8                           = values[edge][8];
        vertices[num_vtx]            = 8;
        derivs[num_vtx][is_eta_edge] = 0.0;
        derivs[num_vtx][is_xi_edge]  = v8;
        v[0] -= 0.25 * v8;
        v[1] -= 0.25 * v8;
        v[2] -= 0.25 * v8;
        v[3] -= 0.25 * v8;
        ++num_vtx;
    }

    // If mid-edge nodes are present
    for( unsigned i = 0; i < 4; ++i )
    {
        if( nodeset.mid_edge_node( i ) )
        {
            const double value = values[edge][i + 4] - 0.5 * v8;
            if( fabs( value ) > 0.125 )
            {
                v[i] -= 0.5 * value;
                v[( i + 1 ) % 4] -= 0.5 * value;
                vertices[num_vtx]            = i + 4;
                derivs[num_vtx][is_eta_edge] = 0.0;
                derivs[num_vtx][is_xi_edge]  = value;
                ++num_vtx;
            }
        }
    }

    // update values for adjacent corners
    derivs[0][is_xi_edge] = v[prev_corner];
    derivs[1][is_xi_edge] = v[next_corner];
    // do other two corners
    if( fabs( v[prev_opposite] ) > 0.125 )
    {
        vertices[num_vtx]            = prev_opposite;
        derivs[num_vtx][is_eta_edge] = 0.0;
        derivs[num_vtx][is_xi_edge]  = v[prev_opposite];
        ++num_vtx;
    }
    if( fabs( v[next_opposite] ) > 0.125 )
    {
        vertices[num_vtx]            = next_opposite;
        derivs[num_vtx][is_eta_edge] = 0.0;
        derivs[num_vtx][is_xi_edge]  = v[next_opposite];
        ++num_vtx;
    }
}
static void MBMesquite::derivatives_at_mid_edge ( unsigned  edge,
size_t *  vertex_indices_out,
MsqVector< 3 > *  d_coeff_d_xi_out,
size_t &  num_vtx 
) [static]

Definition at line 204 of file LinearHexahedron.cpp.

References coeff_eta_sign(), coeff_xi_sign(), coeff_zeta_sign(), edge_beg, edge_beg_orth1, edge_beg_orth2, edge_dir, edge_end, edge_end_orth1, edge_end_orth2, signs, and vtx().

{
    const int direction = edge_dir[edge];
    const int ortho1    = ( direction + 1 ) % 3;
    const int ortho2    = ( direction + 2 ) % 3;
    const int vtx       = edge_beg[edge];
    const int signs[]   = { coeff_xi_sign( vtx ), coeff_eta_sign( vtx ), coeff_zeta_sign( vtx ) };
    const int sign_dir  = signs[direction];
    const int sign_or1  = signs[ortho1];
    const int sign_or2  = signs[ortho2];

    num_vtx               = 6;
    vertex_indices_out[0] = edge_beg[edge];
    vertex_indices_out[1] = edge_end[edge];
    vertex_indices_out[2] = edge_beg_orth1[edge];
    vertex_indices_out[3] = edge_end_orth1[edge];
    vertex_indices_out[4] = edge_beg_orth2[edge];
    vertex_indices_out[5] = edge_end_orth2[edge];

    d_coeff_d_xi_out[0][direction] = sign_dir;
    d_coeff_d_xi_out[0][ortho1]    = sign_or1 * 0.5;
    d_coeff_d_xi_out[0][ortho2]    = sign_or2 * 0.5;

    d_coeff_d_xi_out[1][direction] = -sign_dir;
    d_coeff_d_xi_out[1][ortho1]    = sign_or1 * 0.5;
    d_coeff_d_xi_out[1][ortho2]    = sign_or2 * 0.5;

    d_coeff_d_xi_out[2][direction] = 0.0;
    d_coeff_d_xi_out[2][ortho1]    = -sign_or1 * 0.5;
    d_coeff_d_xi_out[2][ortho2]    = 0.0;

    d_coeff_d_xi_out[3][direction] = 0.0;
    d_coeff_d_xi_out[3][ortho1]    = -sign_or1 * 0.5;
    d_coeff_d_xi_out[3][ortho2]    = 0.0;

    d_coeff_d_xi_out[4][direction] = 0.0;
    d_coeff_d_xi_out[4][ortho1]    = 0.0;
    d_coeff_d_xi_out[4][ortho2]    = -sign_or2 * 0.5;

    d_coeff_d_xi_out[5][direction] = 0.0;
    d_coeff_d_xi_out[5][ortho1]    = 0.0;
    d_coeff_d_xi_out[5][ortho2]    = -sign_or2 * 0.5;
}
static void MBMesquite::derivatives_at_mid_edge ( unsigned  edge,
NodeSet  nodeset,
size_t *  vertices,
MsqVector< 3 > *  derivs,
size_t &  num_vtx 
) [static]

Definition at line 481 of file TetLagrangeShape.cpp.

References MBMesquite::NodeSet::mid_edge_node(), and sign.

{
    int sign;
    num_vtx = 2;
    switch( edge )
    {
        case 0:
            vertices[0]  = 0;
            derivs[0][0] = -1.0;
            derivs[0][1] = -1.0;
            derivs[0][2] = -1.0;

            vertices[1]  = 1;
            derivs[1][0] = 1.0;
            derivs[1][1] = 0.0;
            derivs[1][2] = 0.0;

            if( nodeset.mid_edge_node( 1 ) == nodeset.mid_edge_node( 2 ) )
            {
                vertices[num_vtx]  = 2;
                sign               = 1 - 2 * nodeset.mid_edge_node( 1 );
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = sign;
                derivs[num_vtx][2] = 0.0;
                ++num_vtx;
            }

            if( nodeset.mid_edge_node( 3 ) == nodeset.mid_edge_node( 4 ) )
            {
                vertices[num_vtx]  = 3;
                sign               = 1 - 2 * nodeset.mid_edge_node( 3 );
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = sign;
                ++num_vtx;
            }

            if( nodeset.mid_edge_node( 0 ) )
            {
                vertices[num_vtx]  = 4;
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = -2.0;
                derivs[num_vtx][2] = -2.0;
                derivs[0][1] += 1.0;
                derivs[0][2] += 1.0;
                derivs[1][1] += 1.0;
                derivs[1][2] += 1.0;
                ++num_vtx;
            }

            if( nodeset.mid_edge_node( 1 ) )
            {
                vertices[num_vtx]  = 5;
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 2.0;
                derivs[num_vtx][2] = 0.0;
                derivs[1][1] -= 1.0;
                ++num_vtx;
            }

            if( nodeset.mid_edge_node( 2 ) )
            {
                vertices[num_vtx]  = 6;
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 2.0;
                derivs[num_vtx][2] = 0.0;
                derivs[0][1] -= 1.0;
                ++num_vtx;
            }

            if( nodeset.mid_edge_node( 3 ) )
            {
                vertices[num_vtx]  = 7;
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 2.0;
                derivs[0][2] -= 1.0;
                ++num_vtx;
            }

            if( nodeset.mid_edge_node( 4 ) )
            {
                vertices[num_vtx]  = 8;
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 2.0;
                derivs[1][2] -= 1.0;
                ++num_vtx;
            }
            break;

        case 1:
            vertices[0]  = 1;
            derivs[0][0] = 1.0;
            derivs[0][1] = 0.0;
            derivs[0][2] = 0.0;

            vertices[1]  = 2;
            derivs[1][0] = 0.0;
            derivs[1][1] = 1.0;
            derivs[1][2] = 0.0;

            if( nodeset.mid_edge_node( 0 ) == nodeset.mid_edge_node( 2 ) )
            {
                vertices[num_vtx]  = 0;
                sign               = 2 * nodeset.mid_edge_node( 0 ) - 1;
                derivs[num_vtx][0] = sign;
                derivs[num_vtx][1] = sign;
                derivs[num_vtx][2] = sign;
                ++num_vtx;
            }

            if( nodeset.mid_edge_node( 4 ) == nodeset.mid_edge_node( 5 ) )
            {
                vertices[num_vtx]  = 3;
                sign               = 1 - 2 * nodeset.mid_edge_node( 4 );
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = sign;
                ++num_vtx;
            }

            if( nodeset.mid_edge_node( 0 ) )
            {
                vertices[num_vtx]  = 4;
                derivs[num_vtx][0] = -2.0;
                derivs[num_vtx][1] = -2.0;
                derivs[num_vtx][2] = -2.0;
                ++num_vtx;
                derivs[0][0] += 1.0;
                derivs[0][1] += 1.0;
                derivs[0][2] += 1.0;
            }

            if( nodeset.mid_edge_node( 1 ) )
            {
                vertices[num_vtx]  = 5;
                derivs[num_vtx][0] = 2.0;
                derivs[num_vtx][1] = 2.0;
                derivs[num_vtx][2] = 0.0;
                ++num_vtx;
                derivs[0][0] -= 1.0;
                derivs[0][1] -= 1.0;
                derivs[1][0] -= 1.0;
                derivs[1][1] -= 1.0;
            }

            if( nodeset.mid_edge_node( 2 ) )
            {
                vertices[num_vtx]  = 6;
                derivs[num_vtx][0] = -2.0;
                derivs[num_vtx][1] = -2.0;
                derivs[num_vtx][2] = -2.0;
                ++num_vtx;
                derivs[1][0] += 1.0;
                derivs[1][1] += 1.0;
                derivs[1][2] += 1.0;
            }

            if( nodeset.mid_edge_node( 4 ) )
            {
                vertices[num_vtx]  = 8;
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 2.0;
                ++num_vtx;
                derivs[0][2] -= 1.0;
            }

            if( nodeset.mid_edge_node( 5 ) )
            {
                vertices[num_vtx]  = 9;
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 2.0;
                ++num_vtx;
                derivs[1][2] -= 1.0;
            }
            break;

        case 2:
            vertices[0]  = 0;
            derivs[0][0] = -1.0;
            derivs[0][1] = -1.0;
            derivs[0][2] = -1.0;

            vertices[1]  = 2;
            derivs[1][0] = 0.0;
            derivs[1][1] = 1.0;
            derivs[1][2] = 0.0;

            if( nodeset.mid_edge_node( 0 ) == nodeset.mid_edge_node( 1 ) )
            {
                vertices[num_vtx]  = 1;
                sign               = 1 - 2 * nodeset.mid_edge_node( 0 );
                derivs[num_vtx][0] = sign;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 0.0;
                ++num_vtx;
            }

            if( nodeset.mid_edge_node( 3 ) == nodeset.mid_edge_node( 5 ) )
            {
                vertices[num_vtx]  = 3;
                sign               = 1 - 2 * nodeset.mid_edge_node( 3 );
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = sign;
                ++num_vtx;
            }

            if( nodeset.mid_edge_node( 0 ) )
            {
                vertices[num_vtx]  = 4;
                derivs[num_vtx][0] = 2.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 0.0;
                ++num_vtx;
                derivs[0][0] -= 1.0;
            }

            if( nodeset.mid_edge_node( 1 ) )
            {
                vertices[num_vtx]  = 5;
                derivs[num_vtx][0] = 2.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 0.0;
                ++num_vtx;
                derivs[1][0] -= 1.0;
            }

            if( nodeset.mid_edge_node( 2 ) )
            {
                vertices[num_vtx]  = 6;
                derivs[num_vtx][0] = -2.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = -2.0;
                ++num_vtx;
                derivs[0][0] += 1.0;
                derivs[0][2] += 1.0;
                derivs[1][0] += 1.0;
                derivs[1][2] += 1.0;
            }

            if( nodeset.mid_edge_node( 3 ) )
            {
                vertices[num_vtx]  = 7;
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 2.0;
                ++num_vtx;
                derivs[0][2] -= 1.0;
            }

            if( nodeset.mid_edge_node( 5 ) )
            {
                vertices[num_vtx]  = 9;
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 2.0;
                ++num_vtx;
                derivs[1][2] -= 1.0;
            }
            break;

        case 3:
            vertices[0]  = 0;
            derivs[0][0] = -1.0;
            derivs[0][1] = -1.0;
            derivs[0][2] = -1.0;

            vertices[1]  = 3;
            derivs[1][0] = 0.0;
            derivs[1][1] = 0.0;
            derivs[1][2] = 1.0;

            if( nodeset.mid_edge_node( 0 ) == nodeset.mid_edge_node( 4 ) )
            {
                vertices[num_vtx]  = 1;
                sign               = 1 - 2 * nodeset.mid_edge_node( 0 );
                derivs[num_vtx][0] = sign;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 0.0;
                ++num_vtx;
            }

            if( nodeset.mid_edge_node( 2 ) == nodeset.mid_edge_node( 5 ) )
            {
                vertices[num_vtx]  = 2;
                sign               = 1 - 2 * nodeset.mid_edge_node( 2 );
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = sign;
                derivs[num_vtx][2] = 0.0;
                ++num_vtx;
            }

            if( nodeset.mid_edge_node( 0 ) )
            {
                vertices[num_vtx]  = 4;
                derivs[num_vtx][0] = 2.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 0.0;
                ++num_vtx;
                derivs[0][0] -= 1.0;
            }

            if( nodeset.mid_edge_node( 2 ) )
            {
                vertices[num_vtx]  = 6;
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 2.0;
                derivs[num_vtx][2] = 0.0;
                ++num_vtx;
                derivs[0][1] -= 1.0;
            }

            if( nodeset.mid_edge_node( 3 ) )
            {
                vertices[num_vtx]  = 7;
                derivs[num_vtx][0] = -2.0;
                derivs[num_vtx][1] = -2.0;
                derivs[num_vtx][2] = 0.0;
                ++num_vtx;
                derivs[0][0] += 1.0;
                derivs[0][1] += 1.0;
                derivs[1][0] += 1.0;
                derivs[1][1] += 1.0;
            }

            if( nodeset.mid_edge_node( 4 ) )
            {
                vertices[num_vtx]  = 8;
                derivs[num_vtx][0] = 2.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 0.0;
                ++num_vtx;
                derivs[1][0] -= 1.0;
            }

            if( nodeset.mid_edge_node( 5 ) )
            {
                vertices[num_vtx]  = 9;
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 2.0;
                derivs[num_vtx][2] = 0.0;
                ++num_vtx;
                derivs[1][1] -= 1.0;
            }
            break;

        case 4:
            vertices[0]  = 1;
            derivs[0][0] = 1.0;
            derivs[0][1] = 0.0;
            derivs[0][2] = 0.0;

            vertices[1]  = 3;
            derivs[1][0] = 0.0;
            derivs[1][1] = 0.0;
            derivs[1][2] = 1.0;

            if( nodeset.mid_edge_node( 0 ) == nodeset.mid_edge_node( 3 ) )
            {
                vertices[num_vtx]  = 0;
                sign               = 2 * nodeset.mid_edge_node( 0 ) - 1;
                derivs[num_vtx][0] = sign;
                derivs[num_vtx][1] = sign;
                derivs[num_vtx][2] = sign;
                ++num_vtx;
            }

            if( nodeset.mid_edge_node( 1 ) == nodeset.mid_edge_node( 5 ) )
            {
                vertices[num_vtx]  = 2;
                sign               = 1 - 2 * nodeset.mid_edge_node( 1 );
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = sign;
                derivs[num_vtx][2] = 0.0;
                ++num_vtx;
            }

            if( nodeset.mid_edge_node( 0 ) )
            {
                vertices[num_vtx]  = 4;
                derivs[num_vtx][0] = -2.0;
                derivs[num_vtx][1] = -2.0;
                derivs[num_vtx][2] = -2.0;
                ++num_vtx;
                derivs[0][0] += 1.0;
                derivs[0][1] += 1.0;
                derivs[0][2] += 1.0;
            }

            if( nodeset.mid_edge_node( 1 ) )
            {
                vertices[num_vtx]  = 5;
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 2.0;
                derivs[num_vtx][2] = 0.0;
                ++num_vtx;
                derivs[0][1] -= 1.0;
            }

            if( nodeset.mid_edge_node( 3 ) )
            {
                vertices[num_vtx]  = 7;
                derivs[num_vtx][0] = -2.0;
                derivs[num_vtx][1] = -2.0;
                derivs[num_vtx][2] = -2.0;
                ++num_vtx;
                derivs[1][0] += 1.0;
                derivs[1][1] += 1.0;
                derivs[1][2] += 1.0;
            }

            if( nodeset.mid_edge_node( 4 ) )
            {
                vertices[num_vtx]  = 8;
                derivs[num_vtx][0] = 2.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 2.0;
                ++num_vtx;
                derivs[0][0] -= 1.0;
                derivs[0][2] -= 1.0;
                derivs[1][0] -= 1.0;
                derivs[1][2] -= 1.0;
            }

            if( nodeset.mid_edge_node( 5 ) )
            {
                vertices[num_vtx]  = 9;
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 2.0;
                derivs[num_vtx][2] = 0.0;
                ++num_vtx;
                derivs[1][1] -= 1.0;
            }
            break;

        case 5:
            vertices[0]  = 2;
            derivs[0][0] = 0.0;
            derivs[0][1] = 1.0;
            derivs[0][2] = 0.0;

            vertices[1]  = 3;
            derivs[1][0] = 0.0;
            derivs[1][1] = 0.0;
            derivs[1][2] = 1.0;

            if( nodeset.mid_edge_node( 2 ) == nodeset.mid_edge_node( 3 ) )
            {
                vertices[num_vtx]  = 0;
                sign               = 2 * nodeset.mid_edge_node( 2 ) - 1;
                derivs[num_vtx][0] = sign;
                derivs[num_vtx][1] = sign;
                derivs[num_vtx][2] = sign;
                ++num_vtx;
            }

            if( nodeset.mid_edge_node( 1 ) == nodeset.mid_edge_node( 4 ) )
            {
                vertices[num_vtx]  = 1;
                sign               = 1 - 2 * nodeset.mid_edge_node( 1 );
                derivs[num_vtx][0] = sign;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 0.0;
                ++num_vtx;
            }

            if( nodeset.mid_edge_node( 1 ) )
            {
                vertices[num_vtx]  = 5;
                derivs[num_vtx][0] = 2.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 0.0;
                ++num_vtx;
                derivs[0][0] -= 1.0;
            }

            if( nodeset.mid_edge_node( 2 ) )
            {
                vertices[num_vtx]  = 6;
                derivs[num_vtx][0] = -2.0;
                derivs[num_vtx][1] = -2.0;
                derivs[num_vtx][2] = -2.0;
                ++num_vtx;
                derivs[0][0] += 1.0;
                derivs[0][1] += 1.0;
                derivs[0][2] += 1.0;
            }

            if( nodeset.mid_edge_node( 3 ) )
            {
                vertices[num_vtx]  = 7;
                derivs[num_vtx][0] = -2.0;
                derivs[num_vtx][1] = -2.0;
                derivs[num_vtx][2] = -2.0;
                ++num_vtx;
                derivs[1][0] += 1.0;
                derivs[1][1] += 1.0;
                derivs[1][2] += 1.0;
            }

            if( nodeset.mid_edge_node( 4 ) )
            {
                vertices[num_vtx]  = 8;
                derivs[num_vtx][0] = 2.0;
                derivs[num_vtx][1] = 0.0;
                derivs[num_vtx][2] = 0.0;
                ++num_vtx;
                derivs[1][0] -= 1.0;
            }

            if( nodeset.mid_edge_node( 5 ) )
            {
                vertices[num_vtx]  = 9;
                derivs[num_vtx][0] = 0.0;
                derivs[num_vtx][1] = 2.0;
                derivs[num_vtx][2] = 2.0;
                ++num_vtx;
                derivs[0][1] -= 1.0;
                derivs[0][2] -= 1.0;
                derivs[1][1] -= 1.0;
                derivs[1][2] -= 1.0;
            }
            break;
    }
}
static void MBMesquite::derivatives_at_mid_elem ( size_t *  vertices,
MsqVector< 2 > *  derivs,
size_t &  num_vtx 
) [static]

Definition at line 143 of file LinearQuadrilateral.cpp.

{
    num_vtx      = 4;
    vertices[0]  = 0;
    derivs[0][0] = -0.5;
    derivs[0][1] = -0.5;
    vertices[1]  = 1;
    derivs[1][0] = 0.5;
    derivs[1][1] = -0.5;
    vertices[2]  = 2;
    derivs[2][0] = 0.5;
    derivs[2][1] = 0.5;
    vertices[3]  = 3;
    derivs[3][0] = -0.5;
    derivs[3][1] = 0.5;
}
static void MBMesquite::derivatives_at_mid_elem ( NodeSet  nodeset,
size_t *  vertices,
MsqVector< 2 > *  derivs,
size_t &  num_vtx 
) [static]

Definition at line 273 of file QuadLagrangeShape.cpp.

References MBMesquite::NodeSet::both_edge_nodes(), MBMesquite::NodeSet::have_any_mid_node(), and MBMesquite::NodeSet::mid_edge_node().

Referenced by MBMesquite::LinearPrism::derivatives(), MBMesquite::LinearHexahedron::derivatives(), MBMesquite::LinearQuadrilateral::derivatives(), MBMesquite::TriLagrangeShape::derivatives(), MBMesquite::QuadLagrangeShape::derivatives(), and MBMesquite::TetLagrangeShape::derivatives().

{
    // fast linear case
    // This is provided as an optimization for linear elements.
    // If this block of code were removed, the general-case code
    // below should produce the same result.
    if( !nodeset.have_any_mid_node() )
    {
        num_vtx      = 4;
        vertices[0]  = 0;
        derivs[0][0] = -0.5;
        derivs[0][1] = -0.5;
        vertices[1]  = 1;
        derivs[1][0] = 0.5;
        derivs[1][1] = -0.5;
        vertices[2]  = 2;
        derivs[2][0] = 0.5;
        derivs[2][1] = 0.5;
        vertices[3]  = 3;
        derivs[3][0] = -0.5;
        derivs[3][1] = 0.5;
        return;
    }

    num_vtx = 0;

    // N_0
    if( !nodeset.both_edge_nodes( 0, 3 ) )
    {  // if eiter adjacent mid-edge node is missing
        vertices[num_vtx]  = 0;
        derivs[num_vtx][0] = nodeset.mid_edge_node( 3 ) ? 0.0 : -0.5;
        derivs[num_vtx][1] = nodeset.mid_edge_node( 0 ) ? 0.0 : -0.5;
        ++num_vtx;
    }

    // N_1
    if( !nodeset.both_edge_nodes( 0, 1 ) )
    {  // if eiter adjacent mid-edge node is missing
        vertices[num_vtx]  = 1;
        derivs[num_vtx][0] = nodeset.mid_edge_node( 1 ) ? 0.0 : 0.5;
        derivs[num_vtx][1] = nodeset.mid_edge_node( 0 ) ? 0.0 : -0.5;
        ++num_vtx;
    }

    // N_2
    if( !nodeset.both_edge_nodes( 1, 2 ) )
    {  // if eiter adjacent mid-edge node is missing
        vertices[num_vtx]  = 2;
        derivs[num_vtx][0] = nodeset.mid_edge_node( 1 ) ? 0.0 : 0.5;
        derivs[num_vtx][1] = nodeset.mid_edge_node( 2 ) ? 0.0 : 0.5;
        ++num_vtx;
    }

    // N_3
    if( !nodeset.both_edge_nodes( 2, 3 ) )
    {  // if eiter adjacent mid-edge node is missing
        vertices[num_vtx]  = 3;
        derivs[num_vtx][0] = nodeset.mid_edge_node( 3 ) ? 0.0 : -0.5;
        derivs[num_vtx][1] = nodeset.mid_edge_node( 2 ) ? 0.0 : 0.5;
        ++num_vtx;
    }

    // N_4
    if( nodeset.mid_edge_node( 0 ) )
    {
        vertices[num_vtx]  = 4;
        derivs[num_vtx][0] = 0.0;
        derivs[num_vtx][1] = -1.0;
        ++num_vtx;
    }

    // N_5
    if( nodeset.mid_edge_node( 1 ) )
    {
        vertices[num_vtx]  = 5;
        derivs[num_vtx][0] = 1.0;
        derivs[num_vtx][1] = 0.0;
        ++num_vtx;
    }

    // N_6
    if( nodeset.mid_edge_node( 2 ) )
    {
        vertices[num_vtx]  = 6;
        derivs[num_vtx][0] = 0.0;
        derivs[num_vtx][1] = 1.0;
        ++num_vtx;
    }

    // N_7
    if( nodeset.mid_edge_node( 3 ) )
    {
        vertices[num_vtx]  = 7;
        derivs[num_vtx][0] = -1.0;
        derivs[num_vtx][1] = 0.0;
        ++num_vtx;
    }

    // N_8 (mid-quad node) never contributes to Jacobian at element center!!!
}
static void MBMesquite::derivatives_at_mid_elem ( size_t *  vertex_indices_out,
MsqVector< 3 > *  d_coeff_d_xi_out,
size_t &  num_vtx 
) [static]

Definition at line 308 of file LinearHexahedron.cpp.

{
    num_vtx               = 8;
    vertex_indices_out[0] = 0;
    vertex_indices_out[1] = 1;
    vertex_indices_out[2] = 2;
    vertex_indices_out[3] = 3;
    vertex_indices_out[4] = 4;
    vertex_indices_out[5] = 5;
    vertex_indices_out[6] = 6;
    vertex_indices_out[7] = 7;

    d_coeff_d_xi_out[0][0] = -0.25;
    d_coeff_d_xi_out[0][1] = -0.25;
    d_coeff_d_xi_out[0][2] = -0.25;

    d_coeff_d_xi_out[1][0] = 0.25;
    d_coeff_d_xi_out[1][1] = -0.25;
    d_coeff_d_xi_out[1][2] = -0.25;

    d_coeff_d_xi_out[2][0] = 0.25;
    d_coeff_d_xi_out[2][1] = 0.25;
    d_coeff_d_xi_out[2][2] = -0.25;

    d_coeff_d_xi_out[3][0] = -0.25;
    d_coeff_d_xi_out[3][1] = 0.25;
    d_coeff_d_xi_out[3][2] = -0.25;

    d_coeff_d_xi_out[4][0] = -0.25;
    d_coeff_d_xi_out[4][1] = -0.25;
    d_coeff_d_xi_out[4][2] = 0.25;

    d_coeff_d_xi_out[5][0] = 0.25;
    d_coeff_d_xi_out[5][1] = -0.25;
    d_coeff_d_xi_out[5][2] = 0.25;

    d_coeff_d_xi_out[6][0] = 0.25;
    d_coeff_d_xi_out[6][1] = 0.25;
    d_coeff_d_xi_out[6][2] = 0.25;

    d_coeff_d_xi_out[7][0] = -0.25;
    d_coeff_d_xi_out[7][1] = 0.25;
    d_coeff_d_xi_out[7][2] = 0.25;
}
static void MBMesquite::derivatives_at_mid_elem ( NodeSet  nodeset,
size_t *  vertices,
MsqVector< 3 > *  derivs,
size_t &  num_vtx 
) [static]

Definition at line 1056 of file TetLagrangeShape.cpp.

References corners, edges, MBMesquite::NodeSet::mid_edge_node(), sign, signs, and zeros.

{

    bool corners[4]          = { false, false, false, false };
    double corner_vals[4][3] = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } };

    num_vtx = 0;
    for( unsigned i = 4; i < 10; ++i )
    {
        int sign = signs[i - 4];
        int zero = zeros[i - 4];

        if( nodeset.mid_edge_node( i - 4 ) )
        {
            vertices[num_vtx]     = i;
            derivs[num_vtx][0]    = (double)sign;
            derivs[num_vtx][1]    = (double)sign;
            derivs[num_vtx][2]    = (double)sign;
            derivs[num_vtx][zero] = 0.0;
            ++num_vtx;
        }
        else
        {
            for( unsigned j = 0; j < 2; ++j )
            {
                int corner      = edges[i - 4][j];
                int v1          = ( zero + 1 ) % 3;
                int v2          = ( zero + 2 ) % 3;
                corners[corner] = true;
                corner_vals[corner][v1] += 0.5 * sign;
                corner_vals[corner][v2] += 0.5 * sign;
            }
        }
    }

    for( unsigned i = 0; i < 4; ++i )
        if( corners[i] )
        {
            vertices[num_vtx]  = i;
            derivs[num_vtx][0] = corner_vals[i][0];
            derivs[num_vtx][1] = corner_vals[i][1];
            derivs[num_vtx][2] = corner_vals[i][2];
            ++num_vtx;
        }
}
static void MBMesquite::derivatives_at_mid_face ( unsigned  face,
size_t *  vertex_indices_out,
MsqVector< 3 > *  d_coeff_d_xi_out,
size_t &  num_vtx 
) [static]

Definition at line 249 of file LinearHexahedron.cpp.

References coeff_eta_sign(), coeff_xi_sign(), coeff_zeta_sign(), face_dir, face_opp, and face_vtx.

{
    const int vtx_signs[4][3] = { { coeff_xi_sign( face_vtx[face][0] ), coeff_eta_sign( face_vtx[face][0] ),
                                    coeff_zeta_sign( face_vtx[face][0] ) },
                                  { coeff_xi_sign( face_vtx[face][1] ), coeff_eta_sign( face_vtx[face][1] ),
                                    coeff_zeta_sign( face_vtx[face][1] ) },
                                  { coeff_xi_sign( face_vtx[face][2] ), coeff_eta_sign( face_vtx[face][2] ),
                                    coeff_zeta_sign( face_vtx[face][2] ) },
                                  { coeff_xi_sign( face_vtx[face][3] ), coeff_eta_sign( face_vtx[face][3] ),
                                    coeff_zeta_sign( face_vtx[face][3] ) } };
    const int ortho_dir       = face_dir[face];
    const int face_dir1       = ( ortho_dir + 1 ) % 3;
    const int face_dir2       = ( ortho_dir + 2 ) % 3;
    const int ortho_sign      = vtx_signs[0][ortho_dir];  // same for all 4 verts

    num_vtx               = 8;
    vertex_indices_out[0] = face_vtx[face][0];
    vertex_indices_out[1] = face_vtx[face][1];
    vertex_indices_out[2] = face_vtx[face][2];
    vertex_indices_out[3] = face_vtx[face][3];
    vertex_indices_out[4] = face_vtx[face_opp[face]][0];
    vertex_indices_out[5] = face_vtx[face_opp[face]][1];
    vertex_indices_out[6] = face_vtx[face_opp[face]][2];
    vertex_indices_out[7] = face_vtx[face_opp[face]][3];

    d_coeff_d_xi_out[0][ortho_dir] = ortho_sign * 0.25;
    d_coeff_d_xi_out[0][face_dir1] = vtx_signs[0][face_dir1] * 0.5;
    d_coeff_d_xi_out[0][face_dir2] = vtx_signs[0][face_dir2] * 0.5;

    d_coeff_d_xi_out[1][ortho_dir] = ortho_sign * 0.25;
    d_coeff_d_xi_out[1][face_dir1] = vtx_signs[1][face_dir1] * 0.5;
    d_coeff_d_xi_out[1][face_dir2] = vtx_signs[1][face_dir2] * 0.5;

    d_coeff_d_xi_out[2][ortho_dir] = ortho_sign * 0.25;
    d_coeff_d_xi_out[2][face_dir1] = vtx_signs[2][face_dir1] * 0.5;
    d_coeff_d_xi_out[2][face_dir2] = vtx_signs[2][face_dir2] * 0.5;

    d_coeff_d_xi_out[3][ortho_dir] = ortho_sign * 0.25;
    d_coeff_d_xi_out[3][face_dir1] = vtx_signs[3][face_dir1] * 0.5;
    d_coeff_d_xi_out[3][face_dir2] = vtx_signs[3][face_dir2] * 0.5;

    d_coeff_d_xi_out[4][ortho_dir] = -ortho_sign * 0.25;
    d_coeff_d_xi_out[4][face_dir1] = 0.0;
    d_coeff_d_xi_out[4][face_dir2] = 0.0;

    d_coeff_d_xi_out[5][ortho_dir] = -ortho_sign * 0.25;
    d_coeff_d_xi_out[5][face_dir1] = 0.0;
    d_coeff_d_xi_out[5][face_dir2] = 0.0;

    d_coeff_d_xi_out[6][ortho_dir] = -ortho_sign * 0.25;
    d_coeff_d_xi_out[6][face_dir1] = 0.0;
    d_coeff_d_xi_out[6][face_dir2] = 0.0;

    d_coeff_d_xi_out[7][ortho_dir] = -ortho_sign * 0.25;
    d_coeff_d_xi_out[7][face_dir1] = 0.0;
    d_coeff_d_xi_out[7][face_dir2] = 0.0;
}
static void MBMesquite::derivatives_at_mid_face ( unsigned  face,
NodeSet  nodeset,
size_t *  vertices,
MsqVector< 3 > *  derivs,
size_t &  num_vtx 
) [static]

Definition at line 1025 of file TetLagrangeShape.cpp.

References edges, get_linear_derivatives(), ho_dr, ho_ds, ho_dt, and MBMesquite::NodeSet::mid_edge_node().

Referenced by MBMesquite::LinearPrism::derivatives(), MBMesquite::LinearHexahedron::derivatives(), and MBMesquite::TetLagrangeShape::derivatives().

{
    // begin with derivatives for linear tetrahedron
    num_vtx = 4;
    get_linear_derivatives( vertices, derivs );

    for( unsigned i = 0; i < 6; ++i )
        if( nodeset.mid_edge_node( i ) )
        {
            vertices[num_vtx]  = i + 4;
            derivs[num_vtx][0] = ho_dr[i][face];
            derivs[num_vtx][1] = ho_ds[i][face];
            derivs[num_vtx][2] = ho_dt[i][face];
            ++num_vtx;
            int j = edges[i][0];
            derivs[j][0] -= 0.5 * ho_dr[i][face];
            derivs[j][1] -= 0.5 * ho_ds[i][face];
            derivs[j][2] -= 0.5 * ho_dt[i][face];
            j = edges[i][1];
            derivs[j][0] -= 0.5 * ho_dr[i][face];
            derivs[j][1] -= 0.5 * ho_ds[i][face];
            derivs[j][2] -= 0.5 * ho_dt[i][face];
        }
}
void MBMesquite::destroy_patch_with_domain ( PatchData &  pd) [inline]

must be called in sync with create_...._patch_with_domain

Definition at line 67 of file PatchDataInstances.hpp.

References MBMesquite::PatchData::get_domain(), and MBMesquite::PatchData::set_domain().

Referenced by MsqHessianTest::tearDown(), MsqFreeVertexIndexIteratorTest::tearDown(), and MsqMeshEntityTest::tearDown().

{
    MeshDomain* domain = pd.get_domain();
    pd.set_domain( 0 );
    delete domain;

    // Mesh* mesh = pd.get_mesh();
    // pd.set_mesh( 0 );
    // delete mesh;
}
double MBMesquite::det ( const SymMatrix3D &  a) [inline]

Definition at line 236 of file SymMatrix3D.hpp.

{
    return a[0] * a[3] * a[5] + 2.0 * a[1] * a[2] * a[4] - a[0] * a[4] * a[4] - a[3] * a[2] * a[2] - a[5] * a[1] * a[1];
}
double MBMesquite::det ( const Matrix3D &  A) [inline]

Definition at line 798 of file Matrix3D.hpp.

References MBMesquite::Matrix3D::v_.

Referenced by TargetCalculatorTest::check_valid_delta(), TargetCalculatorTest::check_valid_Q(), moab::GeomUtil::closest_location_on_tri(), cofactor(), condition_comp(), LinearMappingFunctionTest::do_ideal_test(), IdealTargetTest::do_test(), MBMesquite::TUntangleBeta::eval(), MBMesquite::TUntangle1::eval(), MBMesquite::AWUntangleBeta::eval(), MBMesquite::TShape2DNB2::evaluate(), MBMesquite::TShapeOrientB1::evaluate(), MBMesquite::TShapeSize2DB2::evaluate(), MBMesquite::TShapeSize2DNB1::evaluate(), MBMesquite::TShapeSize2DNB2::evaluate(), MBMesquite::TShapeSize3DB2::evaluate(), MBMesquite::TShapeSizeB1::evaluate(), MBMesquite::TShapeSizeOrientB1::evaluate(), MBMesquite::TSizeB1::evaluate(), MBMesquite::TInverseMeanRatio::evaluate(), MBMesquite::AWShape2DNB1::evaluate(), MBMesquite::AWShape2DB1::evaluate(), MBMesquite::AWShape2DNB2::evaluate(), MBMesquite::TShapeSizeB3::evaluate(), MBMesquite::InvTransBarrier::evaluate(), MBMesquite::AWShapeSizeB1::evaluate(), MBMesquite::AWSizeB1::evaluate(), MBMesquite::TShapeOrientB2::evaluate(), MBMesquite::TShapeSizeOrientB2::evaluate(), MBMesquite::TShapeSizeNB3::evaluate(), MBMesquite::TTau::evaluate(), MBMesquite::TShape3DB2::evaluate(), MBMesquite::TShapeB1::evaluate(), MBMesquite::TShapeNB1::evaluate(), MBMesquite::TShapeSize3DB4::evaluate(), MBMesquite::TShapeSize3DNB1::evaluate(), TriTauMetric::evaluate(), moab::LinearTet::evaluate_reverse(), moab::LinearTri::evaluate_reverse(), moab::EvalSet::evaluate_reverse(), MBMesquite::TShape2DNB2::evaluate_with_grad(), MBMesquite::TShapeOrientB1::evaluate_with_grad(), MBMesquite::TShapeSize2DB2::evaluate_with_grad(), MBMesquite::TShapeSize2DNB1::evaluate_with_grad(), MBMesquite::TShapeSize2DNB2::evaluate_with_grad(), MBMesquite::TShapeSize3DB2::evaluate_with_grad(), MBMesquite::TShapeSizeB1::evaluate_with_grad(), MBMesquite::TShapeSizeOrientB1::evaluate_with_grad(), MBMesquite::TSizeB1::evaluate_with_grad(), MBMesquite::AWShape2DNB2::evaluate_with_grad(), MBMesquite::AWShape2DNB1::evaluate_with_grad(), MBMesquite::TShapeSizeB3::evaluate_with_grad(), MBMesquite::AWSizeB1::evaluate_with_grad(), MBMesquite::TInverseMeanRatio::evaluate_with_grad(), MBMesquite::TShapeOrientB2::evaluate_with_grad(), MBMesquite::TShapeSizeOrientB2::evaluate_with_grad(), MBMesquite::TShapeSizeNB3::evaluate_with_grad(), MBMesquite::TShape3DB2::evaluate_with_grad(), MBMesquite::TShapeB1::evaluate_with_grad(), MBMesquite::TShapeNB1::evaluate_with_grad(), MBMesquite::TShapeSize3DB4::evaluate_with_grad(), MBMesquite::TShapeSize3DNB1::evaluate_with_grad(), MBMesquite::TShape2DNB2::evaluate_with_hess(), MBMesquite::TShapeOrientB1::evaluate_with_hess(), MBMesquite::TSizeB1::evaluate_with_hess(), MBMesquite::TShapeSize2DB2::evaluate_with_hess(), MBMesquite::TShapeSize2DNB1::evaluate_with_hess(), MBMesquite::TShapeSize2DNB2::evaluate_with_hess(), MBMesquite::TShapeSize3DB2::evaluate_with_hess(), MBMesquite::TShapeSizeB1::evaluate_with_hess(), MBMesquite::TShapeSizeOrientB1::evaluate_with_hess(), MBMesquite::TShapeSizeB3::evaluate_with_hess(), MBMesquite::TInverseMeanRatio::evaluate_with_hess(), MBMesquite::TShapeOrientB2::evaluate_with_hess(), MBMesquite::TShapeSizeOrientB2::evaluate_with_hess(), MBMesquite::TShapeSizeNB3::evaluate_with_hess(), MBMesquite::TShape3DB2::evaluate_with_hess(), MBMesquite::TShapeB1::evaluate_with_hess(), MBMesquite::TShapeNB1::evaluate_with_hess(), MBMesquite::TShapeSize3DB4::evaluate_with_hess(), MBMesquite::TShapeSize3DNB1::evaluate_with_hess(), TriTauMetric::evaluate_with_indices(), MBMesquite::TargetCalculator::factor_2D(), MBMesquite::SphericalDomain::fit_vertices(), MBMesquite::LambdaTarget::get_2D_target(), MBMesquite::LambdaTarget::get_3D_target(), moab::DGMSolver::get_tri_natural_coords(), MBMesquite::TUntangleBeta::grad(), MBMesquite::TUntangle1::grad(), MBMesquite::AWUntangleBeta::grad(), MBMesquite::TUntangleBeta::hess(), MBMesquite::TUntangle1::hess(), MBMesquite::MappingFunction2D::ideal(), MBMesquite::MappingFunction3D::ideal(), moab::Element::Map::ievaluate(), moab::element_utility::Linear_tet_map< Entity_handle, moab::Matrix3 >::integrate_scalar_field(), moab::ElemUtil::integrate_trilinear_hex(), MBMesquite::MsqPlane::intersect(), inv(), moab::Matrix::inverse(), inverse(), MBMesquite::MsqMeshEntity::inverted_jacobian_3d(), moab::Matrix3::is_positive_definite(), MBMesquite::TargetWriter::loop_over_mesh(), moab::SmoothFace::project_to_patch(), LVQDTargetTest::setUp(), MBMesquite::TargetCalculator::shape(), MBMesquite::TargetCalculator::size(), MBMesquite::TargetCalculator::skew(), moab::ElemUtil::VolMap::solve_inverse(), moab::element_utility::Linear_hex_map< moab::Matrix3 >::solve_inverse(), moab::element_utility::Spectral_hex_map< moab::Matrix3 >::solve_inverse(), moab::element_utility::Quadratic_hex_map< moab::Matrix3 >::solve_inverse(), moab::GeomUtil::VolMap::solve_inverse(), TargetCalculatorTest::TargetCalculatorTest(), Matrix3DTest::test_det(), SymMatrix3DTest::test_determinant(), MsqMatrixTest::test_determinant(), QualityMetricTest::test_diagonal_tau(), TargetCalculatorTest::test_factor_2D(), TargetCalculatorTest::test_factor_3D(), TargetCalculatorTest::test_factor_surface(), QualityMetricTest::test_gradient_tau(), QualityMetricTest::test_Hessian_tau(), MappingFunctionTest::test_ideal_2d(), MappingFunctionTest::test_ideal_3d(), TriLagrangeShapeTest::test_ideal_jacobian(), QuadLagrangeShapeTest::test_ideal_jacobian(), TetLagrangeShapeTest::test_ideal_jacobian(), HexLagrangeShapeTest::test_ideal_jacobian(), v_hex_relative_size_squared(), v_hex_shape(), v_hex_shear(), v_tet_condition(), and v_tet_quality().

{
    return ( A.v_[0] * ( A.v_[4] * A.v_[8] - A.v_[7] * A.v_[5] ) - A.v_[1] * ( A.v_[3] * A.v_[8] - A.v_[6] * A.v_[5] ) +
             A.v_[2] * ( A.v_[3] * A.v_[7] - A.v_[6] * A.v_[4] ) );
}
template<unsigned RC>
double MBMesquite::det ( const MsqMatrix< RC, RC > &  m) [inline]

Definition at line 971 of file MsqMatrix.hpp.

References RC.

{
    double result = 0.0;
    for( unsigned i = 0; i < RC; ++i )
        result += m( 0, i ) * cofactor< RC >( m, 0, i );
    return result;
}
double MBMesquite::det ( const MsqMatrix< 2, 2 > &  m) [inline]

Definition at line 983 of file MsqMatrix.hpp.

{
    return m( 0, 0 ) * m( 1, 1 ) - m( 0, 1 ) * m( 1, 0 );
}
double MBMesquite::det ( const MsqMatrix< 3, 3 > &  m) [inline]

Definition at line 988 of file MsqMatrix.hpp.

{
    return m( 0, 0 ) * ( m( 1, 1 ) * m( 2, 2 ) - m( 2, 1 ) * m( 1, 2 ) ) +
           m( 0, 1 ) * ( m( 2, 0 ) * m( 1, 2 ) - m( 1, 0 ) * m( 2, 2 ) ) +
           m( 0, 2 ) * ( m( 1, 0 ) * m( 2, 1 ) - m( 2, 0 ) * m( 1, 1 ) );
}
static void MBMesquite::dimension_sort_domains ( MeshDomain **  domains,
const int *  dims,
unsigned  count,
std::vector< DomainClassifier::DomainSet > &  results,
int  dim_indices[4],
MsqError &  err 
) [static]

Group MeshDomain objectects by topological dimension.

Given an array of MeshDomain pointers and and array of dimensions, where each dimension value is the topological dimension of the corresponding domain, construct a DomainSet vector containing the domains, grouped from lowest dimension to highest.

Parameters:
domainsArray of domains
dimsTopological dimension of each domain
countLength of 'domains' and 'dims' arrays
resultsOutput
dim_indicesOutput: index in output at which the first domain of the corresponding topological dimension occurs.

Definition at line 274 of file DomainClassifier.cpp.

References dim, MBMesquite::MsqError::INVALID_ARG, and MSQ_SETERR.

Referenced by MBMesquite::DomainClassifier::classify_geometrically(), and MBMesquite::DomainClassifier::classify_skin_geometrically().

{
    results.clear();
    results.resize( count );
    unsigned idx = 0;
    int dim;
    for( dim = 0; idx < count; ++dim )
    {
        if( dim > 3 )
        {
            MSQ_SETERR( err )( "Invalid domain dimension", MsqError::INVALID_ARG );
            return;
        }
        dim_indices[dim] = idx;
        for( unsigned j = 0; j < count; ++j )
        {
            if( dims[j] == dim )
            {
                results[idx].domain = domains[j];
                ++idx;
            }
        }
    }
    for( ; dim <= 3; ++dim )
        dim_indices[dim] = idx;
}
bool MBMesquite::divide ( double  num,
double  den,
double &  result 
) [inline]

Perform safe division (no overflow or div by zero).

Do result = num/den iff it would not result in an overflow or div by zero

Parameters:
numNumerator of division.
denDenominator of division
resultThe result of the division if valid, zero otherwise.
Returns:
false if the result of the division would be invalid (inf or nan), true otherwise.

Definition at line 225 of file Mesquite.hpp.

Referenced by MBMesquite::TShapeSize2DNB2::evaluate(), MBMesquite::TShapeSize2DNB2::evaluate_with_grad(), MBMesquite::TShapeSize2DNB2::evaluate_with_hess(), grad(), MBMesquite::MappingFunction2D::ideal(), MBMesquite::MappingFunction3D::ideal(), MBMesquite::ConjugateGradient::optimize_vertex_positions(), project_to_matrix_plane(), and project_to_perp_plane().

{
    const double fden = fabs( den );
    // NOTE: First comparison is necessary to avoid overflow in second.
    // NOTE: Comparison in second half of condition must be '<'
    //       rather than '<=' to correctly handle 0/0.
    if( fden >= 1 || fabs( num ) < fden * std::numeric_limits< double >::max() )
    {
        result = num / den;
        return true;
    }
    else
    {
        result = 0.0;
        return false;
    }
}
template<unsigned Dim>
static double MBMesquite::do_finite_difference ( int  r,
int  c,
AWMetric *  metric,
MsqMatrix< Dim, Dim >  A,
const MsqMatrix< Dim, Dim > &  W,
double  value,
MsqError &  err 
) [inline, static]

Definition at line 42 of file AWMetric.cpp.

References epsilon, MBMesquite::AWMetric::evaluate(), init(), MBMesquite::MsqError::INTERNAL_ERROR, MSQ_ERRZERO, and MSQ_SETERR.

Referenced by do_numerical_gradient().

{
    const double INITAL_STEP = std::max( 1e-6, fabs( 1e-14 * value ) );
    const double init        = A( r, c );
    bool valid;
    double diff_value;
    for( double step = INITAL_STEP; step > std::numeric_limits< double >::epsilon(); step *= 0.1 )
    {
        A( r, c ) = init + step;
        valid     = metric->evaluate( A, W, diff_value, err );
        MSQ_ERRZERO( err );
        if( valid ) return ( diff_value - value ) / step;
    }

    // If we couldn't find a valid step, try stepping in the other
    // direciton
    for( double step = INITAL_STEP; step > std::numeric_limits< double >::epsilon(); step *= 0.1 )
    {
        A( r, c ) = init - step;
        valid     = metric->evaluate( A, W, diff_value, err );
        MSQ_ERRZERO( err );
        if( valid ) return ( value - diff_value ) / step;
    }

    // If that didn't work either, then give up.
    MSQ_SETERR( err )
    ( "No valid step size for finite difference of 2D target metric.", MsqError::INTERNAL_ERROR );
    return 0.0;
}
template<unsigned Dim>
static double MBMesquite::do_finite_difference ( int  r,
int  c,
TMetric *  metric,
MsqMatrix< Dim, Dim >  A,
double  value,
MsqError &  err 
) [inline, static]

Definition at line 43 of file TMetric.cpp.

References epsilon, MBMesquite::TMetric::evaluate(), init(), MBMesquite::MsqError::INTERNAL_ERROR, MSQ_ERRZERO, and MSQ_SETERR.

{
    const double INITIAL_STEP = std::max( 1e-6, fabs( 1e-14 * value ) );
    const double init         = A( r, c );
    bool valid;
    double diff_value;
    for( double step = INITIAL_STEP; step > std::numeric_limits< double >::epsilon(); step *= 0.1 )
    {
        A( r, c ) = init + step;
        valid     = metric->evaluate( A, diff_value, err );
        MSQ_ERRZERO( err );
        if( valid ) return ( diff_value - value ) / step;
    }

    // If we couldn't find a valid step, try stepping in the other
    // direciton
    for( double step = INITIAL_STEP; step > std::numeric_limits< double >::epsilon(); step *= 0.1 )
    {
        A( r, c ) = init - step;
        valid     = metric->evaluate( A, diff_value, err );
        MSQ_ERRZERO( err );
        if( valid ) return ( value - diff_value ) / step;
    }
    // If that didn't work either, then give up.
    MSQ_SETERR( err )
    ( "No valid step size for finite difference of 2D target metric.", MsqError::INTERNAL_ERROR );
    return 0.0;
}
template<unsigned Dim>
static bool MBMesquite::do_numerical_gradient ( AWMetric *  mu,
MsqMatrix< Dim, Dim >  A,
const MsqMatrix< Dim, Dim > &  W,
double &  result,
MsqMatrix< Dim, Dim > &  wrt_A,
MsqError &  err 
) [inline, static]

Definition at line 74 of file AWMetric.cpp.

References do_finite_difference(), MBMesquite::AWMetric::evaluate(), MSQ_CHKERR, and MSQ_ERRZERO.

Referenced by MBMesquite::TMetric::evaluate_with_grad(), and MBMesquite::AWMetric::evaluate_with_grad().

{
    bool valid;
    valid = mu->evaluate( A, W, result, err );
    MSQ_ERRZERO( err );
    if( MSQ_CHKERR( err ) || !valid ) return valid;

    switch( Dim )
    {
        case 3:
            wrt_A( 0, 2 ) = do_finite_difference( 0, 2, mu, A, W, result, err );
            MSQ_ERRZERO( err );
            wrt_A( 1, 2 ) = do_finite_difference( 1, 2, mu, A, W, result, err );
            MSQ_ERRZERO( err );
            wrt_A( 2, 0 ) = do_finite_difference( 2, 0, mu, A, W, result, err );
            MSQ_ERRZERO( err );
            wrt_A( 2, 1 ) = do_finite_difference( 2, 1, mu, A, W, result, err );
            MSQ_ERRZERO( err );
            wrt_A( 2, 2 ) = do_finite_difference( 2, 2, mu, A, W, result, err );
            MSQ_ERRZERO( err );
        case 2:
            wrt_A( 0, 1 ) = do_finite_difference( 0, 1, mu, A, W, result, err );
            MSQ_ERRZERO( err );
            wrt_A( 1, 0 ) = do_finite_difference( 1, 0, mu, A, W, result, err );
            MSQ_ERRZERO( err );
            wrt_A( 1, 1 ) = do_finite_difference( 1, 1, mu, A, W, result, err );
            MSQ_ERRZERO( err );
        case 1:
            wrt_A( 0, 0 ) = do_finite_difference( 0, 0, mu, A, W, result, err );
            MSQ_ERRZERO( err );
            break;
        default:
            assert( false );
    }
    return true;
}
template<unsigned Dim>
static bool MBMesquite::do_numerical_gradient ( TMetric *  mu,
MsqMatrix< Dim, Dim >  A,
double &  result,
MsqMatrix< Dim, Dim > &  wrt_A,
MsqError &  err 
) [inline, static]

Definition at line 74 of file TMetric.cpp.

References do_finite_difference(), MBMesquite::TMetric::evaluate(), MSQ_CHKERR, and MSQ_ERRZERO.

{
    bool valid;
    valid = mu->evaluate( A, result, err );
    MSQ_ERRZERO( err );
    if( MSQ_CHKERR( err ) || !valid ) return valid;

    switch( Dim )
    {
        case 3:
            wrt_A( 0, 2 ) = do_finite_difference( 0, 2, mu, A, result, err );
            MSQ_ERRZERO( err );
            wrt_A( 1, 2 ) = do_finite_difference( 1, 2, mu, A, result, err );
            MSQ_ERRZERO( err );
            wrt_A( 2, 0 ) = do_finite_difference( 2, 0, mu, A, result, err );
            MSQ_ERRZERO( err );
            wrt_A( 2, 1 ) = do_finite_difference( 2, 1, mu, A, result, err );
            MSQ_ERRZERO( err );
            wrt_A( 2, 2 ) = do_finite_difference( 2, 2, mu, A, result, err );
            MSQ_ERRZERO( err );
        case 2:
            wrt_A( 0, 1 ) = do_finite_difference( 0, 1, mu, A, result, err );
            MSQ_ERRZERO( err );
            wrt_A( 1, 0 ) = do_finite_difference( 1, 0, mu, A, result, err );
            MSQ_ERRZERO( err );
            wrt_A( 1, 1 ) = do_finite_difference( 1, 1, mu, A, result, err );
            MSQ_ERRZERO( err );
        case 1:
            wrt_A( 0, 0 ) = do_finite_difference( 0, 0, mu, A, result, err );
            MSQ_ERRZERO( err );
            break;
        default:
            assert( false );
    }
    return true;
}
template<unsigned Dim>
static bool MBMesquite::do_numerical_hessian ( TMetric *  metric,
MsqMatrix< Dim, Dim >  A,
double &  value,
MsqMatrix< Dim, Dim > &  grad,
MsqMatrix< Dim, Dim > *  Hess,
MsqError &  err 
) [inline, static]

Definition at line 113 of file TMetric.cpp.

References MBMesquite::MsqMatrix< R, C >::add_column(), MBMesquite::MsqMatrix< R, C >::add_row(), b, epsilon, MBMesquite::TMetric::evaluate_with_grad(), grad(), MBMesquite::MsqError::INTERNAL_ERROR, MSQ_CHKERR, MSQ_ERRZERO, MSQ_SETERR, MBMesquite::MsqMatrix< R, C >::row(), and transpose().

{
    // zero hessian data
    const int num_block = Dim * ( Dim + 1 ) / 2;
    for( int i = 0; i < num_block; ++i )
        Hess[i].zero();

    // evaluate gradient for input values
    bool valid;
    valid = metric->evaluate_with_grad( A, value, grad, err );
    if( MSQ_CHKERR( err ) || !valid ) return false;

    // do finite difference for each term of A
    const double INITAL_STEP = std::max( 1e-6, fabs( 1e-14 * value ) );
    double value2;
    MsqMatrix< Dim, Dim > grad2;
    for( unsigned r = 0; r < Dim; ++r )
    {  // for each row of A
        for( unsigned c = 0; c < Dim; ++c )
        {  // for each column of A
            const double in_val = A( r, c );
            double step;
            for( step = INITAL_STEP; step > std::numeric_limits< double >::epsilon(); step *= 0.1 )
            {
                A( r, c ) = in_val + step;
                valid     = metric->evaluate_with_grad( A, value2, grad2, err );
                MSQ_ERRZERO( err );
                if( valid ) break;
            }

            // if no valid step size, try step in other direction
            if( !valid )
            {
                for( step = -INITAL_STEP; step < -std::numeric_limits< double >::epsilon(); step *= 0.1 )
                {
                    A( r, c ) = in_val + step;
                    valid     = metric->evaluate_with_grad( A, value2, grad2, err );
                    MSQ_ERRZERO( err );
                    if( valid ) break;
                }

                // if still no valid step size, give up.
                if( !valid )
                {
                    MSQ_SETERR( err )
                    ( "No valid step size for finite difference of 2D target metric.", MsqError::INTERNAL_ERROR );
                    return false;
                }
            }

            // restore A.
            A( r, c ) = in_val;

            // add values into result matrix
            // values of grad2, in row-major order, are a single 9-value row of the Hessian
            grad2 -= grad;
            grad2 /= step;
            for( unsigned b = 0; b < r; ++b )
            {
                const int idx = Dim * b - b * ( b + 1 ) / 2 + r;
                Hess[idx].add_column( c, transpose( grad2.row( b ) ) );
            }
            for( unsigned b = r; b < Dim; ++b )
            {
                const int idx = Dim * r - r * ( r + 1 ) / 2 + b;
                Hess[idx].add_row( c, grad2.row( b ) );
            }
        }  // for (c)
    }      // for (r)

    // Values in non-diagonal blocks were added twice.
    for( unsigned r = 0, h = 1; r < Dim - 1; ++r, ++h )
        for( unsigned c = r + 1; c < Dim; ++c, ++h )
            Hess[h] *= 0.5;

    return true;
}
template<unsigned Dim>
static bool MBMesquite::do_numerical_hessian ( AWMetric *  metric,
MsqMatrix< Dim, Dim >  A,
const MsqMatrix< Dim, Dim > &  W,
double &  value,
MsqMatrix< Dim, Dim > &  grad,
MsqMatrix< Dim, Dim > *  Hess,
MsqError &  err 
) [inline, static]

Definition at line 113 of file AWMetric.cpp.

References MBMesquite::MsqMatrix< R, C >::add_column(), MBMesquite::MsqMatrix< R, C >::add_row(), b, epsilon, MBMesquite::AWMetric::evaluate_with_grad(), grad(), MBMesquite::MsqError::INTERNAL_ERROR, MSQ_CHKERR, MSQ_ERRZERO, MSQ_SETERR, MBMesquite::MsqMatrix< R, C >::row(), and transpose().

Referenced by MBMesquite::TMetric::evaluate_with_hess(), and MBMesquite::AWMetric::evaluate_with_hess().

{
    // zero hessian data
    const int num_block = Dim * ( Dim + 1 ) / 2;
    for( int i = 0; i < num_block; ++i )
        Hess[i].zero();

    // evaluate gradient for input values
    bool valid;
    valid = metric->evaluate_with_grad( A, W, value, grad, err );
    if( MSQ_CHKERR( err ) || !valid ) return false;

    // do finite difference for each term of A
    const double INITAL_STEP = std::max( 1e-6, fabs( 1e-14 * value ) );
    double value2;
    MsqMatrix< Dim, Dim > grad2;
    for( unsigned r = 0; r < Dim; ++r )
    {  // for each row of A
        for( unsigned c = 0; c < Dim; ++c )
        {  // for each column of A
            const double in_val = A( r, c );
            double step;
            for( step = INITAL_STEP; step > std::numeric_limits< double >::epsilon(); step *= 0.1 )
            {
                A( r, c ) = in_val + step;
                valid     = metric->evaluate_with_grad( A, W, value2, grad2, err );
                MSQ_ERRZERO( err );
                if( valid ) break;
            }

            // if no valid step size, try step in other direction
            if( !valid )
            {
                for( step = -INITAL_STEP; step < -std::numeric_limits< double >::epsilon(); step *= 0.1 )
                {
                    A( r, c ) = in_val + step;
                    valid     = metric->evaluate_with_grad( A, W, value2, grad2, err );
                    MSQ_ERRZERO( err );
                    if( valid ) break;
                }

                // if still no valid step size, give up.
                if( !valid )
                {
                    MSQ_SETERR( err )
                    ( "No valid step size for finite difference of 2D target metric.", MsqError::INTERNAL_ERROR );
                    return false;
                }
            }

            // restore A.
            A( r, c ) = in_val;

            // add values into result matrix
            // values of grad2, in row-major order, are a single 9-value row of the Hessian
            grad2 -= grad;
            grad2 /= step;
            for( unsigned b = 0; b < r; ++b )
            {
                const int idx = Dim * b - b * ( b + 1 ) / 2 + r;
                Hess[idx].add_column( c, transpose( grad2.row( b ) ) );
            }
            for( unsigned b = r; b < Dim; ++b )
            {
                const int idx = Dim * r - r * ( r + 1 ) / 2 + b;
                Hess[idx].add_row( c, grad2.row( b ) );
            }
        }  // for (c)
    }      // for (r)

    // Values in non-diagonal blocks were added twice.
    for( unsigned r = 0, h = 1; r < Dim - 1; ++r, ++h )
        for( unsigned c = r + 1; c < Dim; ++c, ++h )
            Hess[h] *= 0.5;

    return true;
}
void MBMesquite::eqAx ( Vector3D &  v,
const Matrix3D &  A,
const Vector3D &  x 
) [inline]

Definition at line 757 of file Matrix3D.hpp.

References MBMesquite::Vector3D::mCoords, and MBMesquite::Matrix3D::v_.

Referenced by axpy(), and operator*().

{
    v.mCoords[0] = A.v_[0] * x[0] + A.v_[1] * x.mCoords[1] + A.v_[2] * x.mCoords[2];
    v.mCoords[1] = A.v_[3] * x[0] + A.v_[4] * x.mCoords[1] + A.v_[5] * x.mCoords[2];
    v.mCoords[2] = A.v_[6] * x[0] + A.v_[7] * x.mCoords[1] + A.v_[8] * x.mCoords[2];
}
void MBMesquite::eqTransAx ( Vector3D &  v,
const Matrix3D &  A,
const Vector3D &  x 
) [inline]

Definition at line 771 of file Matrix3D.hpp.

References MBMesquite::Vector3D::mCoords, and MBMesquite::Matrix3D::v_.

Referenced by operator*().

{
    v.mCoords[0] = A.v_[0] * x.mCoords[0] + A.v_[3] * x.mCoords[1] + A.v_[6] * x.mCoords[2];
    v.mCoords[1] = A.v_[1] * x.mCoords[0] + A.v_[4] * x.mCoords[1] + A.v_[7] * x.mCoords[2];
    v.mCoords[2] = A.v_[2] * x.mCoords[0] + A.v_[5] * x.mCoords[1] + A.v_[8] * x.mCoords[2];
}
template<unsigned DIM>
static bool MBMesquite::eval ( const MsqMatrix< DIM, DIM > &  T,
double &  result 
) [inline, static]

Definition at line 49 of file TSquared.cpp.

References sqr_Frobenius().

Referenced by get_coeffs(), get_partial_wrt_eta(), and get_partial_wrt_xi().

{
    result = sqr_Frobenius( T );
    return true;
}
template<unsigned DIM>
static bool MBMesquite::eval ( const MsqMatrix< DIM, DIM > &  A,
const MsqMatrix< DIM, DIM > &  W,
double &  result 
) [inline, static]

Definition at line 49 of file AWShapeOrientNB1.cpp.

References sqr_Frobenius().

{
    result = std::sqrt( sqr_Frobenius( A ) * sqr_Frobenius( W ) );
    result -= A % W;
    result *= result;
    return true;
}
static void MBMesquite::find_skin ( Mesh *  mesh,
std::vector< Mesh::VertexHandle > &  skin_verts,
std::vector< Mesh::ElementHandle > &  skin_elems,
MsqError &  err 
) [static]

Skin mesh.

Find vertices and lower-dimension elements on the boundary of a mesh.

Definition at line 158 of file DomainClassifier.cpp.

References arrptr(), compare_sides(), corners, dim, edges, MBMesquite::Mesh::elements_get_attached_vertices(), MBMesquite::Mesh::elements_get_topologies(), MBMesquite::Mesh::get_all_elements(), je, MSQ_ERRRTN, and MBMesquite::Mesh::vertices_get_attached_elements().

Referenced by MBMesquite::DomainClassifier::classify_skin_geometrically().

{
    std::vector< Mesh::ElementHandle > elements, adj_elem, side_elem;
    std::vector< Mesh::VertexHandle > vertices, adj_vtx;
    std::vector< size_t > junk;
    mesh->get_all_elements( elements, err );MSQ_ERRRTN( err );
    if( elements.empty() ) return;
    const unsigned elem_idx[] = { 0, 1, 2, 3 };

    std::vector< unsigned > extra_side_vtx;
    for( size_t e = 0; e < elements.size(); ++e )
    {
        Mesh::ElementHandle elem = elements[e];
        vertices.clear();
        mesh->elements_get_attached_vertices( &elem, 1, vertices, junk, err );MSQ_ERRRTN( err );

        EntityTopology type;
        mesh->elements_get_topologies( &elem, &type, 1, err );MSQ_ERRRTN( err );
        const unsigned dim    = TopologyInfo::dimension( type );
        const unsigned nsides = TopologyInfo::sides( type );
        for( unsigned s = 0; s < nsides; ++s )
        {
            unsigned num_side_vtx;
            const unsigned* side_vtx = TopologyInfo::side_vertices( type, dim - 1, s, num_side_vtx );
            adj_elem.clear();
            side_elem.clear();
            mesh->vertices_get_attached_elements( &vertices[*side_vtx], 1, adj_elem, junk, err );MSQ_ERRRTN( err );

            bool found_adj = false;
            for( size_t a = 0; a < adj_elem.size(); ++a )
            {
                if( adj_elem[a] == elem ) continue;
                EntityTopology adj_type;
                mesh->elements_get_topologies( &adj_elem[a], &adj_type, 1, err );MSQ_ERRRTN( err );
                adj_vtx.clear();
                mesh->elements_get_attached_vertices( &adj_elem[a], 1, adj_vtx, junk, err );MSQ_ERRRTN( err );
                if( TopologyInfo::dimension( adj_type ) == dim )
                {
                    unsigned nsides2 = TopologyInfo::sides( adj_type );
                    for( unsigned s2 = 0; s2 < nsides2; ++s2 )
                    {
                        unsigned num_side_vtx2;
                        const unsigned* side_vtx2 = TopologyInfo::side_vertices( adj_type, dim - 1, s2, num_side_vtx2 );
                        if( num_side_vtx2 == num_side_vtx &&
                            compare_sides( num_side_vtx, side_vtx, arrptr( vertices ), side_vtx2, arrptr( adj_vtx ) ) )
                        {
                            found_adj = true;
                            break;
                        }
                    }
                }
                else
                {
                    if( TopologyInfo::corners( adj_type ) == num_side_vtx )
                        if( compare_sides( num_side_vtx, side_vtx, arrptr( vertices ), elem_idx, arrptr( adj_vtx ) ) )
                            side_elem.push_back( adj_elem[a] );
                }
            }

            if( !found_adj )
            {
                int ho = TopologyInfo::higher_order( type, vertices.size(), err );MSQ_ERRRTN( err );
                // mask mid-element node (because that cannot be on the skin)
                ho &= ~( 1 << dim );
                // if element has other higher-order nodes, we need to find the subset on the skin
                // side
                if( ho )
                {
                    extra_side_vtx.clear();
                    extra_side_vtx.insert( extra_side_vtx.end(), side_vtx, side_vtx + num_side_vtx );
                    // get mid-side node
                    if( ho & ( 1 << ( dim - 1 ) ) )
                    {
                        int idx = TopologyInfo::higher_order_from_side( type, vertices.size(), dim - 1, s, err );MSQ_ERRRTN( err );
                        extra_side_vtx.push_back( idx );
                    }
                    if( dim == 3 && ( ho & 2 ) )
                    {  // if volume element, need mid-edge nodes too
                        const unsigned nedges = TopologyInfo::edges( type );
                        for( unsigned je = 0; je < nedges; ++je )
                        {
                            unsigned tmp;
                            const unsigned* edge_vtx = TopologyInfo::side_vertices( type, 1, je, tmp );
                            assert( edge_vtx && 2 == tmp );
                            unsigned idx = std::find( side_vtx, side_vtx + num_side_vtx, edge_vtx[0] ) - side_vtx;
                            if( idx < num_side_vtx )
                            {
                                if( ( edge_vtx[1] == side_vtx[( idx + 1 ) % num_side_vtx] ) ||
                                    ( edge_vtx[1] == side_vtx[( idx + num_side_vtx - 1 ) % num_side_vtx] ) )
                                {
                                    idx = TopologyInfo::higher_order_from_side( type, vertices.size(), 1, je, err );MSQ_ERRRTN( err );
                                    extra_side_vtx.push_back( idx );
                                }
                            }
                        }
                    }

                    num_side_vtx = extra_side_vtx.size();
                    side_vtx     = arrptr( extra_side_vtx );
                }

                for( unsigned v = 0; v < num_side_vtx; ++v )
                    skin_verts.push_back( vertices[side_vtx[v]] );
                for( unsigned j = 0; j < side_elem.size(); ++j )
                    skin_elems.push_back( side_elem[j] );
            }
        }
    }

    std::sort( skin_verts.begin(), skin_verts.end() );
    skin_verts.erase( std::unique( skin_verts.begin(), skin_verts.end() ), skin_verts.end() );
    std::sort( skin_elems.begin(), skin_elems.end() );
    skin_elems.erase( std::unique( skin_elems.begin(), skin_elems.end() ), skin_elems.end() );
}
template<typename T >
static void MBMesquite::free_vector ( std::vector< T > &  v) [inline, static]

Definition at line 43 of file QuasiNewton.cpp.

Referenced by MBMesquite::QuasiNewton::cleanup(), and MBMesquite::TrustRegion::cleanup().

{
    std::vector< T > temp;
    temp.swap( v );
}
double MBMesquite::Frobenius ( const SymMatrix3D &  a) [inline]

Definition at line 254 of file SymMatrix3D.hpp.

References Frobenius_2().

{
    return std::sqrt( Frobenius_2( a ) );
}
double MBMesquite::Frobenius_2 ( const SymMatrix3D &  a) [inline]

Definition at line 249 of file SymMatrix3D.hpp.

{
    return a[0] * a[0] + 2 * a[1] * a[1] + 2 * a[2] * a[2] + a[3] * a[3] + 2 * a[4] * a[5] + a[5] * a[5];
}
double MBMesquite::Frobenius_2 ( const Matrix3D &  A) [inline]

Return the square of the Frobenius norm of A, i.e. sum (diag (A' * A))

Definition at line 478 of file Matrix3D.hpp.

References MBMesquite::Matrix3D::v_.

Referenced by MBMesquite::CompareQM::check_hess(), CompareMetric::equal(), Frobenius(), MAT_EPS(), MBMesquite::MsqHessian::norm(), and Matrix3DTest::test_Frobenius_2().

{
    return A.v_[0] * A.v_[0] + A.v_[1] * A.v_[1] + A.v_[2] * A.v_[2] + A.v_[3] * A.v_[3] + A.v_[4] * A.v_[4] +
           A.v_[5] * A.v_[5] + A.v_[6] * A.v_[6] + A.v_[7] * A.v_[7] + A.v_[8] * A.v_[8];
}
bool MBMesquite::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 
) [inline]

Definition at line 173 of file MeanRatioFunctions.hpp.

References isqrt3, MSQ_MIN, MBMesquite::Exponent::raise(), and MBMesquite::Exponent::value().

Referenced by MBMesquite::IdealWeightMeanRatio::evaluate_with_gradient(), and MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_gradient().

{
    double matr[9], f;
    double adj_m[9], g;  // adj_m[2,5,8] not used
    double loc1, loc2, loc3;

    /* Calculate M = [A*inv(W) n] */
    matr[0] = x[1][0] - x[0][0];
    matr[1] = ( 2.0 * x[2][0] - x[1][0] - x[0][0] ) * isqrt3;
    matr[2] = n[0];

    matr[3] = x[1][1] - x[0][1];
    matr[4] = ( 2.0 * x[2][1] - x[1][1] - x[0][1] ) * isqrt3;
    matr[5] = n[1];

    matr[6] = x[1][2] - x[0][2];
    matr[7] = ( 2.0 * x[2][2] - x[1][2] - x[0][2] ) * isqrt3;
    matr[8] = n[2];

    /* Calculate det([n M]). */
    loc1 = matr[4] * matr[8] - matr[5] * matr[7];
    loc2 = matr[2] * matr[7] - matr[1] * matr[8];
    loc3 = matr[1] * matr[5] - matr[2] * matr[4];
    g    = matr[0] * loc1 + matr[3] * loc2 + matr[6] * loc3;
    if( g < MSQ_MIN )
    {
        obj = g;
        return false;
    }

    /* Calculate norm(M). */
    f = matr[0] * matr[0] + matr[1] * matr[1] + matr[3] * matr[3] + matr[4] * matr[4] + matr[6] * matr[6] +
        matr[7] * matr[7];

    /* Calculate objective function. */
    obj = a * b.raise( f ) * c.raise( g );

    /* Calculate the derivative of the objective function.    */
    f = b.value() * obj / f; /* Constant on nabla f      */
    g = c.value() * obj / g; /* Constant on nable g      */
    f *= 2.0;                /* Modification for nabla f */

    adj_m[0] = matr[0] * f + loc1 * g;
    adj_m[3] = matr[3] * f + loc2 * g;
    adj_m[6] = matr[6] * f + loc3 * g;

    loc1 = matr[0] * g;
    loc2 = matr[3] * g;
    loc3 = matr[6] * g;

    adj_m[1] = matr[1] * f + loc3 * matr[5] - loc2 * matr[8];
    adj_m[4] = matr[4] * f + loc1 * matr[8] - loc3 * matr[2];
    adj_m[7] = matr[7] * f + loc2 * matr[2] - loc1 * matr[5];

    loc1        = isqrt3 * adj_m[1];
    g_obj[0][0] = -adj_m[0] - loc1;
    g_obj[1][0] = adj_m[0] - loc1;
    g_obj[2][0] = 2.0 * loc1;

    loc1        = isqrt3 * adj_m[4];
    g_obj[0][1] = -adj_m[3] - loc1;
    g_obj[1][1] = adj_m[3] - loc1;
    g_obj[2][1] = 2.0 * loc1;

    loc1        = isqrt3 * adj_m[7];
    g_obj[0][2] = -adj_m[6] - loc1;
    g_obj[1][2] = adj_m[6] - loc1;
    g_obj[2][2] = 2.0 * loc1;
    return true;
}
bool MBMesquite::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 
) [inline]

Definition at line 592 of file MeanRatioFunctions.hpp.

References MSQ_MIN, MBMesquite::Exponent::raise(), and MBMesquite::Exponent::value().

Referenced by MBMesquite::IdealWeightMeanRatio::evaluate_with_gradient(), and MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_gradient().

{
    double matr[9], f;
    double adj_m[9], g;  // adj_m[2,5,8] not used
    double loc1, loc2, loc3;

    /* Calculate M = [A*inv(W) n] */
    matr[0] = d[0] * ( x[1][0] - x[0][0] );
    matr[1] = d[1] * ( x[2][0] - x[0][0] );
    matr[2] = n[0];

    matr[3] = d[0] * ( x[1][1] - x[0][1] );
    matr[4] = d[1] * ( x[2][1] - x[0][1] );
    matr[5] = n[1];

    matr[6] = d[0] * ( x[1][2] - x[0][2] );
    matr[7] = d[1] * ( x[2][2] - x[0][2] );
    matr[8] = n[2];

    /* Calculate det([n M]). */
    loc1 = matr[4] * matr[8] - matr[5] * matr[7];
    loc2 = matr[2] * matr[7] - matr[1] * matr[8];
    loc3 = matr[1] * matr[5] - matr[2] * matr[4];
    g    = matr[0] * loc1 + matr[3] * loc2 + matr[6] * loc3;
    if( g < MSQ_MIN )
    {
        obj = g;
        return false;
    }

    /* Calculate norm(M). */
    f = matr[0] * matr[0] + matr[1] * matr[1] + matr[3] * matr[3] + matr[4] * matr[4] + matr[6] * matr[6] +
        matr[7] * matr[7];

    /* Calculate objective function. */
    obj = a * b.raise( f ) * c.raise( g );

    /* Calculate the derivative of the objective function.    */
    f = b.value() * obj / f; /* Constant on nabla f      */
    g = c.value() * obj / g; /* Constant on nable g      */
    f *= 2.0;                /* Modification for nabla f */

    adj_m[0] = d[0] * ( matr[0] * f + loc1 * g );
    adj_m[3] = d[0] * ( matr[3] * f + loc2 * g );
    adj_m[6] = d[0] * ( matr[6] * f + loc3 * g );

    loc1 = matr[0] * g;
    loc2 = matr[3] * g;
    loc3 = matr[6] * g;

    adj_m[1] = d[1] * ( matr[1] * f + loc3 * matr[5] - loc2 * matr[8] );
    adj_m[4] = d[1] * ( matr[4] * f + loc1 * matr[8] - loc3 * matr[2] );
    adj_m[7] = d[1] * ( matr[7] * f + loc2 * matr[2] - loc1 * matr[5] );

    g_obj[0][0] = -adj_m[0] - adj_m[1];
    g_obj[1][0] = adj_m[0];
    g_obj[2][0] = adj_m[1];

    g_obj[0][1] = -adj_m[3] - adj_m[4];
    g_obj[1][1] = adj_m[3];
    g_obj[2][1] = adj_m[4];

    g_obj[0][2] = -adj_m[6] - adj_m[7];
    g_obj[1][2] = adj_m[6];
    g_obj[2][2] = adj_m[7];
    return true;
}
bool MBMesquite::g_fcn_3e ( double &  obj,
Vector3D  g_obj[4],
const Vector3D  x[4],
const double  a,
const Exponent &  b,
const Exponent &  c 
) [inline]

Definition at line 981 of file MeanRatioFunctions.hpp.

References isqrt3, isqrt6, MSQ_MIN, MBMesquite::Exponent::raise(), and MBMesquite::Exponent::value().

Referenced by MBMesquite::IdealWeightMeanRatio::evaluate_with_gradient(), and MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_gradient().

{
    double matr[9], f;
    double adj_m[9], g;
    double loc1, loc2, loc3;

    /* Calculate M = A*inv(W). */
    f       = x[1][0] + x[0][0];
    matr[0] = x[1][0] - x[0][0];
    matr[1] = ( 2.0 * x[2][0] - f ) * isqrt3;
    matr[2] = ( 3.0 * x[3][0] - x[2][0] - f ) * isqrt6;

    f       = x[1][1] + x[0][1];
    matr[3] = x[1][1] - x[0][1];
    matr[4] = ( 2.0 * x[2][1] - f ) * isqrt3;
    matr[5] = ( 3.0 * x[3][1] - x[2][1] - f ) * isqrt6;

    f       = x[1][2] + x[0][2];
    matr[6] = x[1][2] - x[0][2];
    matr[7] = ( 2.0 * x[2][2] - f ) * isqrt3;
    matr[8] = ( 3.0 * x[3][2] - x[2][2] - f ) * isqrt6;

    /* Calculate det(M). */
    loc1 = matr[4] * matr[8] - matr[5] * matr[7];
    loc2 = matr[5] * matr[6] - matr[3] * matr[8];
    loc3 = matr[3] * matr[7] - matr[4] * matr[6];
    g    = matr[0] * loc1 + matr[1] * loc2 + matr[2] * loc3;
    if( g < MSQ_MIN )
    {
        obj = g;
        return false;
    }

    /* Calculate norm(M). */
    f = matr[0] * matr[0] + matr[1] * matr[1] + matr[2] * matr[2] + matr[3] * matr[3] + matr[4] * matr[4] +
        matr[5] * matr[5] + matr[6] * matr[6] + matr[7] * matr[7] + matr[8] * matr[8];

    /* Calculate objective function. */
    obj = a * b.raise( f ) * c.raise( g );

    /* Calculate the derivative of the objective function.    */
    f = b.value() * obj / f; /* Constant on nabla f      */
    g = c.value() * obj / g; /* Constant on nable g      */
    f *= 2.0;                /* Modification for nabla f */

    adj_m[0] = matr[0] * f + loc1 * g;
    adj_m[1] = matr[1] * f + loc2 * g;
    adj_m[2] = matr[2] * f + loc3 * g;

    loc1 = matr[0] * g;
    loc2 = matr[1] * g;
    loc3 = matr[2] * g;

    adj_m[3] = matr[3] * f + loc3 * matr[7] - loc2 * matr[8];
    adj_m[4] = matr[4] * f + loc1 * matr[8] - loc3 * matr[6];
    adj_m[5] = matr[5] * f + loc2 * matr[6] - loc1 * matr[7];

    adj_m[6] = matr[6] * f + loc2 * matr[5] - loc3 * matr[4];
    adj_m[7] = matr[7] * f + loc3 * matr[3] - loc1 * matr[5];
    adj_m[8] = matr[8] * f + loc1 * matr[4] - loc2 * matr[3];

    loc1        = isqrt3 * adj_m[1];
    loc2        = isqrt6 * adj_m[2];
    loc3        = loc1 + loc2;
    g_obj[0][0] = -adj_m[0] - loc3;
    g_obj[1][0] = adj_m[0] - loc3;
    g_obj[2][0] = 2.0 * loc1 - loc2;
    g_obj[3][0] = 3.0 * loc2;

    loc1        = isqrt3 * adj_m[4];
    loc2        = isqrt6 * adj_m[5];
    loc3        = loc1 + loc2;
    g_obj[0][1] = -adj_m[3] - loc3;
    g_obj[1][1] = adj_m[3] - loc3;
    g_obj[2][1] = 2.0 * loc1 - loc2;
    g_obj[3][1] = 3.0 * loc2;

    loc1        = isqrt3 * adj_m[7];
    loc2        = isqrt6 * adj_m[8];
    loc3        = loc1 + loc2;
    g_obj[0][2] = -adj_m[6] - loc3;
    g_obj[1][2] = adj_m[6] - loc3;
    g_obj[2][2] = 2.0 * loc1 - loc2;
    g_obj[3][2] = 3.0 * loc2;
    return true;
}
bool MBMesquite::g_fcn_3e_v0 ( double &  obj,
Vector3D &  g_obj,
const Vector3D  x[4],
const double  a,
const Exponent &  b,
const Exponent &  c 
) [inline]

Definition at line 1694 of file MeanRatioFunctions.hpp.

References g_fcn_3e_v3().

{
    static Vector3D my_x[4];

    my_x[0] = x[1];
    my_x[1] = x[3];
    my_x[2] = x[2];
    my_x[3] = x[0];
    return g_fcn_3e_v3( obj, g_obj, my_x, a, b, c );
}
bool MBMesquite::g_fcn_3e_v1 ( double &  obj,
Vector3D &  g_obj,
const Vector3D  x[4],
const double  a,
const Exponent &  b,
const Exponent &  c 
) [inline]

Definition at line 1706 of file MeanRatioFunctions.hpp.

References g_fcn_3e_v3().

{
    static Vector3D my_x[4];

    my_x[0] = x[0];
    my_x[1] = x[2];
    my_x[2] = x[3];
    my_x[3] = x[1];
    return g_fcn_3e_v3( obj, g_obj, my_x, a, b, c );
}
bool MBMesquite::g_fcn_3e_v2 ( double &  obj,
Vector3D &  g_obj,
const Vector3D  x[4],
const double  a,
const Exponent &  b,
const Exponent &  c 
) [inline]

Definition at line 1718 of file MeanRatioFunctions.hpp.

References g_fcn_3e_v3().

{
    static Vector3D my_x[4];

    my_x[0] = x[1];
    my_x[1] = x[0];
    my_x[2] = x[3];
    my_x[3] = x[2];
    return g_fcn_3e_v3( obj, g_obj, my_x, a, b, c );
}
bool MBMesquite::g_fcn_3e_v3 ( double &  obj,
Vector3D &  g_obj,
const Vector3D  x[4],
const double  a,
const Exponent &  b,
const Exponent &  c 
) [inline]

Definition at line 1639 of file MeanRatioFunctions.hpp.

References isqrt3, isqrt6, MSQ_MIN, MBMesquite::Exponent::raise(), tisqrt6, and MBMesquite::Exponent::value().

Referenced by g_fcn_3e_v0(), g_fcn_3e_v1(), and g_fcn_3e_v2().

{
    double matr[9], f, g;
    double loc1, loc2, loc3;

    /* Calculate M = A*inv(W). */
    f       = x[1][0] + x[0][0];
    matr[0] = x[1][0] - x[0][0];
    matr[1] = ( 2.0 * x[2][0] - f ) * isqrt3;
    matr[2] = ( 3.0 * x[3][0] - x[2][0] - f ) * isqrt6;

    f       = x[1][1] + x[0][1];
    matr[3] = x[1][1] - x[0][1];
    matr[4] = ( 2.0 * x[2][1] - f ) * isqrt3;
    matr[5] = ( 3.0 * x[3][1] - x[2][1] - f ) * isqrt6;

    f       = x[1][2] + x[0][2];
    matr[6] = x[1][2] - x[0][2];
    matr[7] = ( 2.0 * x[2][2] - f ) * isqrt3;
    matr[8] = ( 3.0 * x[3][2] - x[2][2] - f ) * isqrt6;

    /* Calculate det(M). */
    loc1 = matr[4] * matr[8] - matr[5] * matr[7];
    loc2 = matr[5] * matr[6] - matr[3] * matr[8];
    loc3 = matr[3] * matr[7] - matr[4] * matr[6];
    g    = matr[0] * loc1 + matr[1] * loc2 + matr[2] * loc3;
    if( g < MSQ_MIN )
    {
        obj = g;
        return false;
    }

    /* Calculate norm(M). */
    f = matr[0] * matr[0] + matr[1] * matr[1] + matr[2] * matr[2] + matr[3] * matr[3] + matr[4] * matr[4] +
        matr[5] * matr[5] + matr[6] * matr[6] + matr[7] * matr[7] + matr[8] * matr[8];

    /* Calculate objective function. */
    obj = a * b.raise( f ) * c.raise( g );

    /* Calculate the derivative of the objective function.    */
    f = b.value() * obj / f; /* Constant on nabla f      */
    g = c.value() * obj / g; /* Constant on nable g      */
    f *= 2.0;                /* Modification for nabla f */

    g_obj[0] = tisqrt6 * ( matr[2] * f + loc3 * g );

    loc1 = matr[0] * g;
    loc2 = matr[1] * g;

    g_obj[1] = tisqrt6 * ( matr[5] * f + loc2 * matr[6] - loc1 * matr[7] );
    g_obj[2] = tisqrt6 * ( matr[8] * f + loc1 * matr[4] - loc2 * matr[3] );
    return true;
}
bool MBMesquite::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 
) [inline]

Definition at line 1908 of file MeanRatioFunctions.hpp.

References MSQ_MIN, MBMesquite::Exponent::raise(), and MBMesquite::Exponent::value().

Referenced by MBMesquite::IdealWeightMeanRatio::evaluate_with_gradient(), and MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_gradient().

{
    double matr[9], f;
    double adj_m[9], g;
    double loc1, loc2, loc3;

    /* Calculate M = A*inv(W). */
    matr[0] = d[0] * ( x[1][0] - x[0][0] );
    matr[1] = d[1] * ( x[2][0] - x[0][0] );
    matr[2] = d[2] * ( x[3][0] - x[0][0] );

    matr[3] = d[0] * ( x[1][1] - x[0][1] );
    matr[4] = d[1] * ( x[2][1] - x[0][1] );
    matr[5] = d[2] * ( x[3][1] - x[0][1] );

    matr[6] = d[0] * ( x[1][2] - x[0][2] );
    matr[7] = d[1] * ( x[2][2] - x[0][2] );
    matr[8] = d[2] * ( x[3][2] - x[0][2] );

    /* Calculate det(M). */
    loc1 = matr[4] * matr[8] - matr[5] * matr[7];
    loc2 = matr[5] * matr[6] - matr[3] * matr[8];
    loc3 = matr[3] * matr[7] - matr[4] * matr[6];
    g    = matr[0] * loc1 + matr[1] * loc2 + matr[2] * loc3;
    if( g < MSQ_MIN )
    {
        obj = g;
        return false;
    }

    /* Calculate norm(M). */
    f = matr[0] * matr[0] + matr[1] * matr[1] + matr[2] * matr[2] + matr[3] * matr[3] + matr[4] * matr[4] +
        matr[5] * matr[5] + matr[6] * matr[6] + matr[7] * matr[7] + matr[8] * matr[8];

    /* Calculate objective function. */
    obj = a * b.raise( f ) * c.raise( g );

    /* Calculate the derivative of the objective function.    */
    f = b.value() * obj / f; /* Constant on nabla f      */
    g = c.value() * obj / g; /* Constant on nable g      */
    f *= 2.0;                /* Modification for nabla f */

    adj_m[0] = d[0] * ( matr[0] * f + loc1 * g );
    adj_m[1] = d[1] * ( matr[1] * f + loc2 * g );
    adj_m[2] = d[2] * ( matr[2] * f + loc3 * g );

    loc1 = matr[0] * g;
    loc2 = matr[1] * g;
    loc3 = matr[2] * g;

    adj_m[3] = d[0] * ( matr[3] * f + loc3 * matr[7] - loc2 * matr[8] );
    adj_m[4] = d[1] * ( matr[4] * f + loc1 * matr[8] - loc3 * matr[6] );
    adj_m[5] = d[2] * ( matr[5] * f + loc2 * matr[6] - loc1 * matr[7] );

    adj_m[6] = d[0] * ( matr[6] * f + loc2 * matr[5] - loc3 * matr[4] );
    adj_m[7] = d[1] * ( matr[7] * f + loc3 * matr[3] - loc1 * matr[5] );
    adj_m[8] = d[2] * ( matr[8] * f + loc1 * matr[4] - loc2 * matr[3] );

    g_obj[0][0] = -adj_m[0] - adj_m[1] - adj_m[2];
    g_obj[1][0] = adj_m[0];
    g_obj[2][0] = adj_m[1];
    g_obj[3][0] = adj_m[2];

    g_obj[0][1] = -adj_m[3] - adj_m[4] - adj_m[5];
    g_obj[1][1] = adj_m[3];
    g_obj[2][1] = adj_m[4];
    g_obj[3][1] = adj_m[5];

    g_obj[0][2] = -adj_m[6] - adj_m[7] - adj_m[8];
    g_obj[1][2] = adj_m[6];
    g_obj[2][2] = adj_m[7];
    g_obj[3][2] = adj_m[8];
    return true;
}
bool MBMesquite::g_fcn_3p ( double &  obj,
Vector3D  g_obj[4],
const Vector3D  x[4],
const double  a,
const Exponent &  b,
const Exponent &  c 
) [inline]

Definition at line 2437 of file MeanRatioFunctions.hpp.

References MSQ_MIN, MBMesquite::Exponent::raise(), and MBMesquite::Exponent::value().

Referenced by MBMesquite::IdealWeightMeanRatio::evaluate_with_gradient(), MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_gradient(), and h_fcn_3p().

{
    const double h  = 0.5; /* h = 1 / (2*height) */
    const double th = 1.0; /* h = 1 / (height)   */

    double matr[9], f;
    double adj_m[9], g;
    double loc1, loc2, loc3;

    /* Calculate M = A*inv(W). */
    matr[0] = x[1][0] - x[0][0];
    matr[1] = x[2][0] - x[0][0];
    matr[2] = ( 2.0 * x[3][0] - x[1][0] - x[2][0] ) * h;

    matr[3] = x[1][1] - x[0][1];
    matr[4] = x[2][1] - x[0][1];
    matr[5] = ( 2.0 * x[3][1] - x[1][1] - x[2][1] ) * h;

    matr[6] = x[1][2] - x[0][2];
    matr[7] = x[2][2] - x[0][2];
    matr[8] = ( 2.0 * x[3][2] - x[1][2] - x[2][2] ) * h;

    /* Calculate det(M). */
    loc1 = matr[4] * matr[8] - matr[5] * matr[7];
    loc2 = matr[5] * matr[6] - matr[3] * matr[8];
    loc3 = matr[3] * matr[7] - matr[4] * matr[6];
    g    = matr[0] * loc1 + matr[1] * loc2 + matr[2] * loc3;
    if( g < MSQ_MIN )
    {
        obj = g;
        return false;
    }

    /* Calculate norm(M). */
    f = matr[0] * matr[0] + matr[1] * matr[1] + matr[2] * matr[2] + matr[3] * matr[3] + matr[4] * matr[4] +
        matr[5] * matr[5] + matr[6] * matr[6] + matr[7] * matr[7] + matr[8] * matr[8];

    /* Calculate objective function. */
    obj = a * b.raise( f ) * c.raise( g );

    /* Calculate the derivative of the objective function.    */
    f = b.value() * obj / f; /* Constant on nabla f      */
    g = c.value() * obj / g; /* Constant on nable g      */
    f *= 2.0;                /* Modification for nabla f */

    adj_m[0] = matr[0] * f + loc1 * g;
    adj_m[1] = matr[1] * f + loc2 * g;
    adj_m[2] = matr[2] * f + loc3 * g;

    loc1 = matr[0] * g;
    loc2 = matr[1] * g;
    loc3 = matr[2] * g;

    adj_m[3] = matr[3] * f + loc3 * matr[7] - loc2 * matr[8];
    adj_m[4] = matr[4] * f + loc1 * matr[8] - loc3 * matr[6];
    adj_m[5] = matr[5] * f + loc2 * matr[6] - loc1 * matr[7];

    adj_m[6] = matr[6] * f + loc2 * matr[5] - loc3 * matr[4];
    adj_m[7] = matr[7] * f + loc3 * matr[3] - loc1 * matr[5];
    adj_m[8] = matr[8] * f + loc1 * matr[4] - loc2 * matr[3];

    g_obj[0][0] = -adj_m[0] - adj_m[1];
    g_obj[1][0] = adj_m[0] - h * adj_m[2];
    g_obj[2][0] = adj_m[1] - h * adj_m[2];
    g_obj[3][0] = th * adj_m[2];

    g_obj[0][1] = -adj_m[3] - adj_m[4];
    g_obj[1][1] = adj_m[3] - h * adj_m[5];
    g_obj[2][1] = adj_m[4] - h * adj_m[5];
    g_obj[3][1] = th * adj_m[5];

    g_obj[0][2] = -adj_m[6] - adj_m[7];
    g_obj[1][2] = adj_m[6] - h * adj_m[8];
    g_obj[2][2] = adj_m[7] - h * adj_m[8];
    g_obj[3][2] = th * adj_m[8];
    return true;
}
bool MBMesquite::g_fcn_3w ( double &  obj,
Vector3D  g_obj[4],
const Vector3D  x[4],
const double  a,
const Exponent &  b,
const Exponent &  c 
) [inline]

Definition at line 3027 of file MeanRatioFunctions.hpp.

References isqrt3, MSQ_MIN, MBMesquite::Exponent::raise(), tisqrt3, and MBMesquite::Exponent::value().

Referenced by MBMesquite::IdealWeightMeanRatio::evaluate_with_gradient(), and MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_gradient().

{
    double matr[9], f;
    double adj_m[9], g;
    double loc1, loc2, loc3;

    /* Calculate M = A*inv(W). */
    matr[0] = x[1][0] - x[0][0];
    matr[1] = isqrt3 * ( 2 * x[2][0] - x[1][0] - x[0][0] );
    matr[2] = x[3][0] - x[0][0];

    matr[3] = x[1][1] - x[0][1];
    matr[4] = isqrt3 * ( 2 * x[2][1] - x[1][1] - x[0][1] );
    matr[5] = x[3][1] - x[0][1];

    matr[6] = x[1][2] - x[0][2];
    matr[7] = isqrt3 * ( 2 * x[2][2] - x[1][2] - x[0][2] );
    matr[8] = x[3][2] - x[0][2];

    /* Calculate det(M). */
    loc1 = matr[4] * matr[8] - matr[5] * matr[7];
    loc2 = matr[5] * matr[6] - matr[3] * matr[8];
    loc3 = matr[3] * matr[7] - matr[4] * matr[6];
    g    = matr[0] * loc1 + matr[1] * loc2 + matr[2] * loc3;
    if( g < MSQ_MIN )
    {
        obj = g;
        return false;
    }

    /* Calculate norm(M). */
    f = matr[0] * matr[0] + matr[1] * matr[1] + matr[2] * matr[2] + matr[3] * matr[3] + matr[4] * matr[4] +
        matr[5] * matr[5] + matr[6] * matr[6] + matr[7] * matr[7] + matr[8] * matr[8];

    /* Calculate objective function. */
    obj = a * b.raise( f ) * c.raise( g );

    /* Calculate the derivative of the objective function.    */
    f = b.value() * obj / f; /* Constant on nabla f      */
    g = c.value() * obj / g; /* Constant on nable g      */
    f *= 2.0;                /* Modification for nabla f */

    adj_m[0] = matr[0] * f + loc1 * g;
    adj_m[1] = matr[1] * f + loc2 * g;
    adj_m[2] = matr[2] * f + loc3 * g;

    loc1 = matr[0] * g;
    loc2 = matr[1] * g;
    loc3 = matr[2] * g;

    adj_m[3] = matr[3] * f + loc3 * matr[7] - loc2 * matr[8];
    adj_m[4] = matr[4] * f + loc1 * matr[8] - loc3 * matr[6];
    adj_m[5] = matr[5] * f + loc2 * matr[6] - loc1 * matr[7];

    adj_m[6] = matr[6] * f + loc2 * matr[5] - loc3 * matr[4];
    adj_m[7] = matr[7] * f + loc3 * matr[3] - loc1 * matr[5];
    adj_m[8] = matr[8] * f + loc1 * matr[4] - loc2 * matr[3];

    g_obj[0][0] = -adj_m[0] - isqrt3 * adj_m[1] - adj_m[2];
    g_obj[1][0] = adj_m[0] - isqrt3 * adj_m[1];
    g_obj[2][0] = tisqrt3 * adj_m[1];
    g_obj[3][0] = adj_m[2];

    g_obj[0][1] = -adj_m[3] - isqrt3 * adj_m[4] - adj_m[5];
    g_obj[1][1] = adj_m[3] - isqrt3 * adj_m[4];
    g_obj[2][1] = tisqrt3 * adj_m[4];
    g_obj[3][1] = adj_m[5];

    g_obj[0][2] = -adj_m[6] - isqrt3 * adj_m[7] - adj_m[8];
    g_obj[1][2] = adj_m[6] - isqrt3 * adj_m[7];
    g_obj[2][2] = tisqrt3 * adj_m[7];
    g_obj[3][2] = adj_m[8];

    return true;
}
static double MBMesquite::generate_random_number ( int  generate_random_numbers,
int  proc_id,
size_t  glob_id 
) [static]

Definition at line 185 of file ParallelHelper.cpp.

References hash6432shift(), and hash64shift().

Referenced by MBMesquite::ParallelHelperImpl::smoothing_init().

{
    int gid;

    if( sizeof( size_t ) == sizeof( unsigned long long ) ) { gid = hash6432shift( (unsigned long long)glob_id ); }
    else
    {
        gid = (int)glob_id;
    }

    if( generate_random_numbers == 1 )
    {
        // count number of on bits
        int on            = 0;
        unsigned int mist = (unsigned int)gid;
        while( mist )
        {
            if( mist & 1 ) on++;
            mist = mist >> 1;
        }
        unsigned short xsubi[3];
        if( on & 1 )
            mist = (unsigned int)gid;
        else
            mist = (unsigned int)( -gid );
        if( on & 2 )
        {
            xsubi[0] = (unsigned short)( 65535 & mist );
            xsubi[1] = (unsigned short)( 65535 & ( mist >> 16 ) );
        }
        else
        {
            xsubi[1] = (unsigned short)( 65535 & mist );
            xsubi[0] = (unsigned short)( 65535 & ( mist >> 16 ) );
        }
        xsubi[2] = proc_id;

#if( defined WIN32 || defined WIN64 )
        time_t seed = ( gid + xsubi[1] ) / ( ( time( NULL ) % 10 ) + 1 );
        srand( (int)seed );
        return rand() / ( RAND_MAX + 1.0 );
#else
        return erand48( xsubi );
#endif
    }
    else if( generate_random_numbers == 2 )
    {
        // count number of on bits
        int on            = 0;
        unsigned int mist = (unsigned int)gid;
        while( mist )
        {
            if( mist & 1 ) on++;
            mist = mist >> 1;
        }
        unsigned short xsubi[3];
        if( on & 1 )
            mist = (unsigned int)gid;
        else
            mist = (unsigned int)( -gid );
        if( on & 2 )
        {
            xsubi[0] = (unsigned short)( 65535 & mist );
            xsubi[1] = (unsigned short)( 65535 & ( mist >> 16 ) );
        }
        else
        {
            xsubi[1] = (unsigned short)( 65535 & mist );
            xsubi[0] = (unsigned short)( 65535 & ( mist >> 16 ) );
        }
        xsubi[2] = proc_id ^ xsubi[1];

#if( defined WIN32 || defined WIN64 )
        time_t seed = ( gid + xsubi[1] ) / ( ( time( NULL ) % 10 ) + 1 );
        srand( (int)seed );
        return rand() / ( RAND_MAX + 1.0 );
#else
        return erand48( xsubi );
#endif
    }
    else if( generate_random_numbers == 3 )
    {
        unsigned long long key = (unsigned long long)gid;
        key                    = key << 32;
        key                    = key | proc_id;
        return (double)hash64shift( key );
    }
    else if( generate_random_numbers == 4 )
    {
        unsigned long long key = (unsigned long long)gid;
        key                    = key << 32;
        key                    = key | proc_id;
        key                    = hash64shift( key );
        unsigned short xsubi[3];
        xsubi[0] = (unsigned short)( key >> 48 );
        xsubi[1] = (unsigned short)( key >> 32 );
        xsubi[2] = (unsigned short)( key >> 16 );

#if( defined WIN32 || defined WIN64 )
        time_t seed = ( gid + xsubi[1] ) / ( ( time( NULL ) % 10 ) + 1 );
        srand( (int)seed );
        return rand() / ( RAND_MAX + 1.0 );
#else
        return erand48( xsubi );
#endif
    }
    else
    {
        return -1;
    }
}
static void MBMesquite::geom_classify_elements ( Mesh *  mesh,
DomainClassifier::DomainSet *  dim_sorted_domains,
unsigned  num_domain,
int  dim_indices[4],
const std::vector< Mesh::ElementHandle > &  elems,
std::vector< Mesh::ElementHandle > &  unknown_elems,
double  epsilon,
MsqError &  err 
) [static]

Classify mesh elements geometrically.

Definition at line 390 of file DomainClassifier.cpp.

References arrptr(), MBMesquite::DomainClassifier::DomainSet::domain, MBMesquite::DomainClassifier::DomainSet::elements, MBMesquite::Mesh::elements_get_attached_vertices(), epsilon, length_squared(), MSQ_ERRRTN, MBMesquite::MeshDomain::snap_to(), and MBMesquite::Mesh::vertices_get_coordinates().

Referenced by MBMesquite::DomainClassifier::classify_geometrically(), and MBMesquite::DomainClassifier::classify_skin_geometrically().

{
    if( elems.empty() ) return;

    const double epssqr = epsilon * epsilon;
    Vector3D pt;
    MsqVertex coord;
    std::vector< Mesh::ElementHandle >::const_iterator iter;
    std::vector< Mesh::VertexHandle > verts;
    std::vector< MsqVertex > coords;
    std::vector< size_t > junk;
    for( iter = elems.begin(); iter != elems.end(); ++iter )
    {
        verts.clear();
        mesh->elements_get_attached_vertices( &*iter, 1, verts, junk, err );MSQ_ERRRTN( err );
        coords.resize( verts.size() );
        mesh->vertices_get_coordinates( arrptr( verts ), arrptr( coords ), verts.size(), err );MSQ_ERRRTN( err );

        // get all 2D domains that contain first vertex
        std::vector< int > doms;
        for( int i = dim_indices[2]; i < dim_indices[3]; ++i )
        {
            pt = coords[0];
            dim_sorted_domains[i].domain->snap_to( verts[0], pt );
            if( ( pt - coords[0] ).length_squared() <= epssqr ) doms.push_back( i );
        }

        // of the 2D domains containing the first vertex,
        // remove any that do not contain all other corners of the element.
        for( unsigned i = 1; i < verts.size(); ++i )
        {
            for( unsigned j = 0; j < doms.size(); )
            {
                pt = coords[i];
                dim_sorted_domains[doms[j]].domain->snap_to( verts[j], pt );
                if( ( pt - coords[0] ).length_squared() <= epssqr )
                    ++j;
                else
                    doms.erase( doms.begin() + j );
            }
        }

        if( doms.size() == 1 )
            dim_sorted_domains[doms.front()].elements.push_back( *iter );
        else
            unknown_elems.push_back( *iter );
    }
}
static void MBMesquite::geom_classify_vertices ( Mesh *  mesh,
DomainClassifier::DomainSet *  dim_sorted_domains,
unsigned  num_domain,
const std::vector< Mesh::VertexHandle > &  vertices,
double  epsilon,
MsqError &  err 
) [static]

Classify mesh vertices using vertex position.

Classify vertices by distance from each geometric domain. A vertex is assigned to a domain if it lies within the domain. If a vertex lies in multiple domains, it is assigned to the domain with the lowest topological dimension.

Parameters:
meshThe MBMesquite::Mesh instance
dim_sorted_domainsThe list of MeshDomains, sorted from lowest to highest dimension.
num_domainLength of 'dim_sorted_domains' array.
verticesVertices to classify
epsilonMaximum distance a vertex may deviate from its domain.

Definition at line 303 of file DomainClassifier.cpp.

References MBMesquite::MsqError::clear(), dim, MBMesquite::DomainClassifier::DomainSet::domain, MBMesquite::MeshDomain::domain_DoF(), epsilon, length_squared(), MSQ_ERRRTN, MBMesquite::MeshDomain::snap_to(), MBMesquite::DomainClassifier::DomainSet::vertices, and MBMesquite::Mesh::vertices_get_coordinates().

Referenced by MBMesquite::DomainClassifier::classify_geometrically(), and MBMesquite::DomainClassifier::classify_skin_geometrically().

{
    Vector3D pt;
    MsqVertex coord;
    unsigned i;
    unsigned short dim;
    const double epssqr = epsilon * epsilon;
    std::vector< Mesh::VertexHandle >::const_iterator iter;
    for( iter = vertices.begin(); iter != vertices.end(); ++iter )
    {
        mesh->vertices_get_coordinates( &*iter, &coord, 1, err );MSQ_ERRRTN( err );
        for( i = 0; i < num_domain; ++i )
        {
            // Call DoF function first just to see if it fails
            // (e.g. if domain knows which vertices it is responsible for,
            //  it should fail if this vertex isn't one.)
            dim_sorted_domains[i].domain->domain_DoF( &*iter, &dim, 1, err );
            if( err || dim > 2 )
            {
                err.clear();
                continue;
            }
            pt = coord;
            dim_sorted_domains[i].domain->snap_to( *iter, pt );
            if( ( pt - coord ).length_squared() <= epssqr )
            {
                dim_sorted_domains[i].vertices.push_back( *iter );
                break;
            }
        }
    }
}
static double MBMesquite::get_delta_C ( const PatchData &  pd,
const std::vector< size_t > &  indices,
MsqError &  err 
) [inline, static]

Definition at line 54 of file QualityMetric.cpp.

References MBMesquite::PatchData::get_adjacent_vertex_indices(), MBMesquite::MsqError::INVALID_ARG, MSQ_ERRZERO, MSQ_SETERR, u, and MBMesquite::PatchData::vertex_by_index().

Referenced by MBMesquite::QualityMetric::evaluate_with_gradient(), and MBMesquite::QualityMetric::evaluate_with_Hessian().

{
    if( indices.empty() )
    {
        MSQ_SETERR( err )( MsqError::INVALID_ARG );
        return 0.0;
    }

    std::vector< size_t >::const_iterator beg, iter, iter2, end;

    std::vector< size_t > tmp_vect;
    if( indices.size() == 1u )
    {
        pd.get_adjacent_vertex_indices( indices.front(), tmp_vect, err );
        MSQ_ERRZERO( err );
        assert( !tmp_vect.empty() );
        tmp_vect.push_back( indices.front() );
        beg = tmp_vect.begin();
        end = tmp_vect.end();
    }
    else
    {
        beg = indices.begin();
        end = indices.end();
    }

    double min_dist_sqr = HUGE_VAL, sum_dist_sqr = 0.0;
    for( iter = beg; iter != end; ++iter )
    {
        for( iter2 = iter + 1; iter2 != end; ++iter2 )
        {
            Vector3D diff = pd.vertex_by_index( *iter );
            diff -= pd.vertex_by_index( *iter2 );
            double dist_sqr = diff % diff;
            if( dist_sqr < min_dist_sqr ) min_dist_sqr = dist_sqr;
            sum_dist_sqr += dist_sqr;
        }
    }

    return 3e-6 * sqrt( min_dist_sqr ) + 5e-7 * sqrt( sum_dist_sqr / ( end - beg ) );
}
void MBMesquite::get_elem_sample_points ( PatchData &  pd,
size_t  elem,
std::vector< size_t > &  handles,
MsqError &   
)
static void MBMesquite::get_field_names ( const TagDescription &  tag,
std::string &  field_out,
std::string &  member_out,
MsqError &  err 
) [static]

Definition at line 326 of file MeshImpl.cpp.

References MBMesquite::TagDescription::FIELD, MBMesquite::MsqError::FILE_FORMAT, MBMesquite::TagDescription::member, MESQUITE_FIELD_TAG, MSQ_SETERR, MBMesquite::TagDescription::name, and MBMesquite::TagDescription::vtkType.

Referenced by MBMesquite::MeshImpl::vtk_write_attrib_data(), and MBMesquite::MeshImpl::write_vtk().

{
    std::string::size_type idx;

    if( tag.vtkType != TagDescription::FIELD )
    {
        field_out  = tag.name;
        member_out = "";
    }
    else if( !tag.member.empty() )
    {
        field_out  = tag.name;
        member_out = tag.member;
    }
    // If field is a struct, then the Mesquite tag name is a contcatenation
    // of the field name and the struct member name.  Extract them.
    else
    {
        idx = tag.name.find( " " );
        if( idx == std::string::npos )
        {
            field_out  = tag.name;
            member_out = MESQUITE_FIELD_TAG;
        }
        else
        {
            field_out  = tag.name.substr( 0, idx );
            member_out = tag.name.substr( idx + 1 );
        }
    }

    idx = field_out.find( " " );
    if( idx != std::string::npos ) MSQ_SETERR( err )
    ( MsqError::FILE_FORMAT, "Cannot write tag name \"%s\" containing spaces to VTK file.", field_out.c_str() );

    idx = member_out.find( " " );
    if( idx != std::string::npos ) MSQ_SETERR( err )
    ( MsqError::FILE_FORMAT, "Cannot write field member name \"%s\" containing spaces to VTK file.",
      member_out.c_str() );
}
static void MBMesquite::get_linear_derivatives ( size_t *  vertices,
MsqVector< 2 > *  derivs 
) [inline, static]

Definition at line 126 of file TriLagrangeShape.cpp.

{
    vertices[0]  = 0;
    vertices[1]  = 1;
    vertices[2]  = 2;
    derivs[0][0] = -1.0;
    derivs[0][1] = -1.0;
    derivs[1][0] = 1.0;
    derivs[1][1] = 0.0;
    derivs[2][0] = 0.0;
    derivs[2][1] = 1.0;
}
static void MBMesquite::get_linear_derivatives ( size_t *  vertices,
MsqVector< 3 > *  derivs 
) [static]

Definition at line 299 of file TetLagrangeShape.cpp.

Referenced by MBMesquite::TriLagrangeShape::derivatives(), MBMesquite::TetLagrangeShape::derivatives(), derivatives_at_corner(), and derivatives_at_mid_face().

{
    vertices[0]  = 0;
    derivs[0][0] = -1.0;
    derivs[0][1] = -1.0;
    derivs[0][2] = -1.0;

    vertices[1]  = 1;
    derivs[1][0] = 1.0;
    derivs[1][1] = 0.0;
    derivs[1][2] = 0.0;

    vertices[2]  = 2;
    derivs[2][0] = 0.0;
    derivs[2][1] = 1.0;
    derivs[2][2] = 0.0;

    vertices[3]  = 3;
    derivs[3][0] = 0.0;
    derivs[3][1] = 0.0;
    derivs[3][2] = 1.0;
}
static NodeSet MBMesquite::get_nodeset ( EntityTopology  type,
int  num_nodes,
MsqError &  err 
) [static]

Definition at line 505 of file TargetCalculator.cpp.

References midedge, MSQ_CHKERR, MBMesquite::NodeSet::set_all_corner_nodes(), MBMesquite::NodeSet::set_all_mid_edge_nodes(), MBMesquite::NodeSet::set_all_mid_face_nodes(), and MBMesquite::NodeSet::set_mid_region_node().

Referenced by MBMesquite::TargetCalculator::jacobian_2D(), and MBMesquite::TargetCalculator::jacobian_3D().

{
    bool midedge, midface, midvol;
    TopologyInfo::higher_order( type, num_nodes, midedge, midface, midvol, err );
    if( MSQ_CHKERR( err ) ) return NodeSet();

    NodeSet bits;
    bits.set_all_corner_nodes( type );
    if( midedge ) bits.set_all_mid_edge_nodes( type );
    if( midface ) bits.set_all_mid_face_nodes( type );
    if( TopologyInfo::dimension( type ) == 3 && midvol ) bits.set_mid_region_node();

    return bits;
}

Definition at line 35 of file ParallelHelper.cpp.

References MPI_COMM_WORLD, and rank.

Referenced by MBMesquite::ConjugateGradient::initialize(), MBMesquite::VertexMover::loop_over_mesh(), MBMesquite::TerminationCriterion::par_string(), and MBMesquite::TerminationCriterion::terminate().

{
    int rank    = 0;
    int is_init = 0;
    int err     = MPI_Initialized( &is_init );
    if( MPI_SUCCESS != err ) return 0;
    if( is_init ) MPI_Comm_rank( MPI_COMM_WORLD, &rank );
    return rank;
}

Definition at line 45 of file ParallelHelper.cpp.

References MPI_COMM_WORLD.

Referenced by MBMesquite::ConjugateGradient::initialize(), and MBMesquite::TerminationCriterion::par_string().

{
    int nprocs  = 0;
    int is_init = 0;
    int err     = MPI_Initialized( &is_init );
    if( MPI_SUCCESS != err ) return 0;
    if( is_init ) MPI_Comm_size( MPI_COMM_WORLD, &nprocs );
    return nprocs;
}
void MBMesquite::get_sample_pt_evaluations ( PatchData &  pd,
std::vector< size_t > &  handles,
bool  free,
MsqError &  err 
)

Definition at line 130 of file TargetMetricUtil.cpp.

References append_elem_samples(), MBMesquite::ElementQM::get_element_evaluations(), and MSQ_ERRRTN.

Referenced by MBMesquite::AffineMapMetric::get_evaluations(), MBMesquite::TMPQualityMetric::get_evaluations(), and MBMesquite::TMPQualityMetric::get_patch_evaluations().

{
    handles.clear();
    std::vector< size_t > elems;
    ElementQM::get_element_evaluations( pd, elems, free, err );MSQ_ERRRTN( err );
    for( std::vector< size_t >::iterator i = elems.begin(); i != elems.end(); ++i )
        append_elem_samples( pd, *i, handles );
}
static TagHandle MBMesquite::get_tag ( Mesh *  mesh,
unsigned  num_doubles,
const std::string &  base_name,
MsqError &  err 
) [static]

Definition at line 42 of file WeightReader.cpp.

References MBMesquite::Mesh::DOUBLE, MSQ_ERRZERO, MSQ_SETERR, MBMesquite::MsqError::TAG_ALREADY_EXISTS, MBMesquite::Mesh::tag_get(), and MBMesquite::Mesh::tag_properties().

{
    std::ostringstream str;
    str << base_name << num_doubles;

    TagHandle handle = mesh->tag_get( str.str().c_str(), err );
    MSQ_ERRZERO( err );

    // double check tag type
    std::string temp_name;
    Mesh::TagType temp_type;
    unsigned temp_length;
    mesh->tag_properties( handle, temp_name, temp_type, temp_length, err );
    MSQ_ERRZERO( err );

    if( temp_type != Mesh::DOUBLE || temp_length != num_doubles )
    {
        MSQ_SETERR( err )
        ( MsqError::TAG_ALREADY_EXISTS, "Mismatched type or length for existing tag \"%s\"", str.str().c_str() );
    }

    return handle;
}
static TagHandle MBMesquite::get_tag ( Mesh *  mesh,
unsigned  num_matrices,
unsigned  dimension,
const char *  base_name,
bool  orient_surface,
MsqError &  err 
) [static]

Definition at line 43 of file TargetReader.cpp.

References MBMesquite::Mesh::DOUBLE, MSQ_ERRZERO, MSQ_SETERR, MBMesquite::MsqError::TAG_ALREADY_EXISTS, MBMesquite::Mesh::tag_get(), and MBMesquite::Mesh::tag_properties().

Referenced by MBMesquite::TargetReader::get_2D_target(), MBMesquite::TargetReader::get_3D_target(), MBMesquite::TargetReader::get_surface_target(), and MBMesquite::WeightReader::get_weight().

{
    unsigned matrix_size;
    if( dimension == 2 && !orient_surface )
        matrix_size = 4;
    else
        matrix_size = dimension * 3;
    unsigned num_doubles = num_matrices * matrix_size;
    std::ostringstream str;
    str << base_name << num_doubles;

    TagHandle handle = mesh->tag_get( str.str().c_str(), err );
    MSQ_ERRZERO( err );

    // check tag type
    std::string temp_name;
    Mesh::TagType temp_type;
    unsigned temp_length;
    mesh->tag_properties( handle, temp_name, temp_type, temp_length, err );
    MSQ_ERRZERO( err );

    if( temp_type != Mesh::DOUBLE || temp_length != num_doubles )
    {
        MSQ_SETERR( err )
        ( MsqError::TAG_ALREADY_EXISTS, "Mismatched type or length for existing tag \"%s\"", str.str().c_str() );
    }

    return handle;
}
static void MBMesquite::get_u_perp ( const MsqVector< 3 > &  u,
MsqVector< 3 > &  u_perp 
) [static]

Definition at line 118 of file TMPQualityMetric.cpp.

References b.

Referenced by project_to_matrix_plane().

{
    double a = sqrt( u[0] * u[0] + u[1] * u[1] );
    if( a < 1e-10 )
    {
        u_perp[0] = 1.0;
        u_perp[1] = u_perp[2] = 0.0;
    }
    else
    {
        double b  = -u[2] / a;
        u_perp[0] = u[0] * b;
        u_perp[1] = u[1] * b;
        u_perp[2] = a;
    }
}
template<unsigned DIM>
static bool MBMesquite::grad ( const MsqMatrix< DIM, DIM > &  T,
double &  result,
MsqMatrix< DIM, DIM > &  wrt_T 
) [inline, static]

Definition at line 56 of file TSquared.cpp.

References sqr_Frobenius(), and T.

Referenced by ObjectiveFunctionTests::compare_diagonal_gradient(), QualityMetricTester::compare_eval_with_indices_and_eval_with_diagonal(), QualityMetricTester::compare_eval_with_indices_and_eval_with_gradient(), QualityMetricTester::compare_eval_with_indices_and_eval_with_hessian(), ObjectiveFunctionTests::compare_hessian_gradient(), ObjectiveFunctionTests::compare_numerical_hessian(), do_numerical_hessian(), GradTestMetricRel::evaluate(), GradTestMetricAbs::evaluate(), ObjectiveFunctionTests::evaluate_internal(), MBMesquite::AWQualityMetric::evaluate_with_gradient(), MBMesquite::TQualityMetric::evaluate_with_gradient(), MBMesquite::AWQualityMetric::evaluate_with_Hessian(), MBMesquite::TQualityMetric::evaluate_with_Hessian(), MBMesquite::AWQualityMetric::evaluate_with_Hessian_diagonal(), MBMesquite::TQualityMetric::evaluate_with_Hessian_diagonal(), CompositeOFTest::get_hessians(), UnOptimizer::optimize_vertex_positions(), MBMesquite::FeasibleNewton::optimize_vertex_positions(), pmean_corner_diagonals(), pmean_corner_hessians(), sum_corner_diagonals(), sum_corner_hessians(), sum_sqr_corner_diagonals(), sum_sqr_corner_hessians(), PMeanPTemplateTest::test_diagonal(), QualityMetricTester::test_diagonal_with_fixed_vertex(), QualityMetricTester::test_domain_deviation_gradient(), PMeanPTemplateTest::test_gradient(), TerminationCriterionTest::test_gradient_common(), QualityMetricTester::test_gradient_reflects_quality(), QualityMetricTester::test_gradient_with_fixed_vertex(), ObjectiveFunctionTests::test_handles_invalid_qm(), ObjectiveFunctionTests::test_handles_qm_error(), PMeanPTemplateTest::test_Hessian(), StdDevTemplateTest::test_hessian_fails(), StdDevTemplateTest::test_hessian_fails_sqr(), QualityMetricTester::test_hessian_with_fixed_vertex(), QualityMetricTester::test_ideal_element_positive_definite_Hessian(), QualityMetricTester::test_ideal_element_zero_gradient(), QualityMetricTester::test_ideal_element_zero_vertex_gradient(), CompositeOFTest::test_multiply_hess_diagonal(), CompositeOFTest::test_multiply_hessian(), ObjectiveFunctionTests::test_negate_flag(), QualityMetricTester::test_symmetric_Hessian_diagonal_blocks(), QualityMetricTester::test_type_is_not_supported(), QualityMetricTester::test_type_is_supported(), and QualityMetricTester::test_vertex_gradient_reflects_quality().

{
    result = sqr_Frobenius( T );
    wrt_T  = 2 * T;
    return true;
}
template<unsigned DIM>
static bool MBMesquite::grad ( const MsqMatrix< DIM, DIM > &  A,
const MsqMatrix< DIM, DIM > &  W,
double &  result,
MsqMatrix< DIM, DIM > &  deriv 
) [inline, static]

Definition at line 58 of file AWShapeOrientNB1.cpp.

References divide(), moab::dot(), and sqr_Frobenius().

{
    const double nsW = sqr_Frobenius( W );
    const double nsA = sqr_Frobenius( A );
    const double nW  = std::sqrt( nsW );
    const double nA  = std::sqrt( nsA );
    const double dot = A % W;
    result           = nA * nW - dot;
    result *= result;

    deriv = nA * W;
    double tmp;
    if( divide( dot, nA, tmp ) ) deriv += tmp * A;
    deriv *= -nW;
    deriv += nsW * A;
    deriv += dot * W;
    deriv *= 2.0;
    return true;
}
bool MBMesquite::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 
) [inline]

Definition at line 249 of file MeanRatioFunctions.hpp.

References moab::cross(), MBMesquite::Matrix3D::fill_lower_triangle(), isqrt3, MSQ_MIN, MBMesquite::Exponent::raise(), tisqrt3, and MBMesquite::Exponent::value().

Referenced by MBMesquite::IdealWeightMeanRatio::evaluate_with_Hessian(), MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_Hessian(), MBMesquite::IdealWeightMeanRatio::evaluate_with_Hessian_diagonal(), and MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_Hessian_diagonal().

{
    double matr[9], f;
    double adj_m[9], g;  // adj_m[2,5,8] not used
    double dg[9];        // dg[2,5,8] not used
    double loc0, loc1, loc2, loc3, loc4;
    double A[12], J_A[6], J_B[9], J_C[9], cross;  // only 2x2 corners used

    /* Calculate M = [A*inv(W) n] */
    matr[0] = x[1][0] - x[0][0];
    matr[1] = ( 2.0 * x[2][0] - x[1][0] - x[0][0] ) * isqrt3;
    matr[2] = n[0];

    matr[3] = x[1][1] - x[0][1];
    matr[4] = ( 2.0 * x[2][1] - x[1][1] - x[0][1] ) * isqrt3;
    matr[5] = n[1];

    matr[6] = x[1][2] - x[0][2];
    matr[7] = ( 2.0 * x[2][2] - x[1][2] - x[0][2] ) * isqrt3;
    matr[8] = n[2];

    /* Calculate det([n M]). */
    dg[0] = matr[4] * matr[8] - matr[5] * matr[7];
    dg[3] = matr[2] * matr[7] - matr[1] * matr[8];
    dg[6] = matr[1] * matr[5] - matr[2] * matr[4];
    g     = matr[0] * dg[0] + matr[3] * dg[3] + matr[6] * dg[6];
    if( g < MSQ_MIN )
    {
        obj = g;
        return false;
    }

    /* Calculate norm(M). */
    f = matr[0] * matr[0] + matr[1] * matr[1] + matr[3] * matr[3] + matr[4] * matr[4] + matr[6] * matr[6] +
        matr[7] * matr[7];

    loc3 = f;
    loc4 = g;

    /* Calculate objective function. */
    obj = a * b.raise( f ) * c.raise( g );

    /* Calculate the derivative of the objective function.    */
    f = b.value() * obj / f; /* Constant on nabla f      */
    g = c.value() * obj / g; /* Constant on nable g      */
    f *= 2.0;                /* Modification for nabla f */

    dg[1] = matr[5] * matr[6] - matr[3] * matr[8];
    dg[4] = matr[0] * matr[8] - matr[2] * matr[6];
    dg[7] = matr[2] * matr[3] - matr[0] * matr[5];

    adj_m[0] = matr[0] * f + dg[0] * g;
    adj_m[1] = matr[1] * f + dg[1] * g;
    adj_m[3] = matr[3] * f + dg[3] * g;
    adj_m[4] = matr[4] * f + dg[4] * g;
    adj_m[6] = matr[6] * f + dg[6] * g;
    adj_m[7] = matr[7] * f + dg[7] * g;

    loc1        = isqrt3 * adj_m[1];
    g_obj[0][0] = -adj_m[0] - loc1;
    g_obj[1][0] = adj_m[0] - loc1;
    g_obj[2][0] = 2.0 * loc1;

    loc1        = isqrt3 * adj_m[4];
    g_obj[0][1] = -adj_m[3] - loc1;
    g_obj[1][1] = adj_m[3] - loc1;
    g_obj[2][1] = 2.0 * loc1;

    loc1        = isqrt3 * adj_m[7];
    g_obj[0][2] = -adj_m[6] - loc1;
    g_obj[1][2] = adj_m[6] - loc1;
    g_obj[2][2] = 2.0 * loc1;

    /* Calculate the hessian of the objective.                   */
    loc0  = f;                            /* Constant on nabla^2 f       */
    loc1  = g;                            /* Constant on nabla^2 g       */
    cross = f * c.value() / loc4;         /* Constant on nabla g nabla f */
    f     = f * ( b.value() - 1 ) / loc3; /* Constant on nabla f nabla f */
    g     = g * ( c.value() - 1 ) / loc4; /* Constant on nabla g nabla g */
    f *= 2.0;                             /* Modification for nabla f    */

    /* First block of rows */
    loc3 = matr[0] * f + dg[0] * cross;
    loc4 = dg[0] * g + matr[0] * cross;

    J_A[0] = loc0 + loc3 * matr[0] + loc4 * dg[0];
    J_A[1] = loc3 * matr[1] + loc4 * dg[1];
    J_B[0] = loc3 * matr[3] + loc4 * dg[3];
    J_B[1] = loc3 * matr[4] + loc4 * dg[4];
    J_C[0] = loc3 * matr[6] + loc4 * dg[6];
    J_C[1] = loc3 * matr[7] + loc4 * dg[7];

    loc3 = matr[1] * f + dg[1] * cross;
    loc4 = dg[1] * g + matr[1] * cross;

    J_A[3] = loc0 + loc3 * matr[1] + loc4 * dg[1];
    J_B[3] = loc3 * matr[3] + loc4 * dg[3];
    J_B[4] = loc3 * matr[4] + loc4 * dg[4];
    J_C[3] = loc3 * matr[6] + loc4 * dg[6];
    J_C[4] = loc3 * matr[7] + loc4 * dg[7];

    /* First diagonal block */
    loc2 = isqrt3 * J_A[1];
    A[0] = -J_A[0] - loc2;
    A[1] = J_A[0] - loc2;

    loc2 = isqrt3 * J_A[3];
    A[4] = -J_A[1] - loc2;
    A[5] = J_A[1] - loc2;
    A[6] = 2.0 * loc2;

    loc2           = isqrt3 * A[4];
    h_obj[0][0][0] = -A[0] - loc2;
    h_obj[1][0][0] = A[0] - loc2;
    h_obj[2][0][0] = 2.0 * loc2;

    loc2           = isqrt3 * A[5];
    h_obj[3][0][0] = A[1] - loc2;
    h_obj[4][0][0] = 2.0 * loc2;

    h_obj[5][0][0] = tisqrt3 * A[6];

    /* First off-diagonal block */
    loc2 = matr[8] * loc1;
    J_B[1] += loc2;
    J_B[3] -= loc2;

    loc2 = isqrt3 * J_B[3];
    A[0] = -J_B[0] - loc2;
    A[1] = J_B[0] - loc2;
    A[2] = 2.0 * loc2;

    loc2 = isqrt3 * J_B[4];
    A[4] = -J_B[1] - loc2;
    A[5] = J_B[1] - loc2;
    A[6] = 2.0 * loc2;

    loc2           = isqrt3 * A[4];
    h_obj[0][0][1] = -A[0] - loc2;
    h_obj[1][0][1] = A[0] - loc2;
    h_obj[2][0][1] = 2.0 * loc2;

    loc2           = isqrt3 * A[5];
    h_obj[1][1][0] = -A[1] - loc2;
    h_obj[3][0][1] = A[1] - loc2;
    h_obj[4][0][1] = 2.0 * loc2;

    loc2           = isqrt3 * A[6];
    h_obj[2][1][0] = -A[2] - loc2;
    h_obj[4][1][0] = A[2] - loc2;
    h_obj[5][0][1] = 2.0 * loc2;

    /* Second off-diagonal block */
    loc2 = matr[5] * loc1;
    J_C[1] -= loc2;
    J_C[3] += loc2;

    loc2 = isqrt3 * J_C[3];
    A[0] = -J_C[0] - loc2;
    A[1] = J_C[0] - loc2;
    A[2] = 2.0 * loc2;

    loc2 = isqrt3 * J_C[4];
    A[4] = -J_C[1] - loc2;
    A[5] = J_C[1] - loc2;
    A[6] = 2.0 * loc2;

    loc2           = isqrt3 * A[4];
    h_obj[0][0][2] = -A[0] - loc2;
    h_obj[1][0][2] = A[0] - loc2;
    h_obj[2][0][2] = 2.0 * loc2;

    loc2           = isqrt3 * A[5];
    h_obj[1][2][0] = -A[1] - loc2;
    h_obj[3][0][2] = A[1] - loc2;
    h_obj[4][0][2] = 2.0 * loc2;

    loc2           = isqrt3 * A[6];
    h_obj[2][2][0] = -A[2] - loc2;
    h_obj[4][2][0] = A[2] - loc2;
    h_obj[5][0][2] = 2.0 * loc2;

    /* Second block of rows */
    loc3 = matr[3] * f + dg[3] * cross;
    loc4 = dg[3] * g + matr[3] * cross;

    J_A[0] = loc0 + loc3 * matr[3] + loc4 * dg[3];
    J_A[1] = loc3 * matr[4] + loc4 * dg[4];
    J_B[0] = loc3 * matr[6] + loc4 * dg[6];
    J_B[1] = loc3 * matr[7] + loc4 * dg[7];

    loc3 = matr[4] * f + dg[4] * cross;
    loc4 = dg[4] * g + matr[4] * cross;

    J_A[3] = loc0 + loc3 * matr[4] + loc4 * dg[4];
    J_B[3] = loc3 * matr[6] + loc4 * dg[6];
    J_B[4] = loc3 * matr[7] + loc4 * dg[7];

    /* Second diagonal block */
    loc2 = isqrt3 * J_A[1];
    A[0] = -J_A[0] - loc2;
    A[1] = J_A[0] - loc2;

    loc2 = isqrt3 * J_A[3];
    A[4] = -J_A[1] - loc2;
    A[5] = J_A[1] - loc2;
    A[6] = 2.0 * loc2;

    loc2           = isqrt3 * A[4];
    h_obj[0][1][1] = -A[0] - loc2;
    h_obj[1][1][1] = A[0] - loc2;
    h_obj[2][1][1] = 2.0 * loc2;

    loc2           = isqrt3 * A[5];
    h_obj[3][1][1] = A[1] - loc2;
    h_obj[4][1][1] = 2.0 * loc2;

    h_obj[5][1][1] = tisqrt3 * A[6];

    /* Third off-diagonal block */
    loc2 = matr[2] * loc1;
    J_B[1] += loc2;
    J_B[3] -= loc2;

    loc2 = isqrt3 * J_B[3];
    A[0] = -J_B[0] - loc2;
    A[1] = J_B[0] - loc2;
    A[2] = 2.0 * loc2;

    loc2 = isqrt3 * J_B[4];
    A[4] = -J_B[1] - loc2;
    A[5] = J_B[1] - loc2;
    A[6] = 2.0 * loc2;

    loc2           = isqrt3 * A[4];
    h_obj[0][1][2] = -A[0] - loc2;
    h_obj[1][1][2] = A[0] - loc2;
    h_obj[2][1][2] = 2.0 * loc2;

    loc2           = isqrt3 * A[5];
    h_obj[1][2][1] = -A[1] - loc2;
    h_obj[3][1][2] = A[1] - loc2;
    h_obj[4][1][2] = 2.0 * loc2;

    loc2           = isqrt3 * A[6];
    h_obj[2][2][1] = -A[2] - loc2;
    h_obj[4][2][1] = A[2] - loc2;
    h_obj[5][1][2] = 2.0 * loc2;

    /* Third block of rows */
    loc3 = matr[6] * f + dg[6] * cross;
    loc4 = dg[6] * g + matr[6] * cross;

    J_A[0] = loc0 + loc3 * matr[6] + loc4 * dg[6];
    J_A[1] = loc3 * matr[7] + loc4 * dg[7];

    loc3 = matr[7] * f + dg[7] * cross;
    loc4 = dg[7] * g + matr[7] * cross;

    J_A[3] = loc0 + loc3 * matr[7] + loc4 * dg[7];

    /* Third diagonal block */
    loc2 = isqrt3 * J_A[1];
    A[0] = -J_A[0] - loc2;
    A[1] = J_A[0] - loc2;

    loc2 = isqrt3 * J_A[3];
    A[4] = -J_A[1] - loc2;
    A[5] = J_A[1] - loc2;
    A[6] = 2.0 * loc2;

    loc2           = isqrt3 * A[4];
    h_obj[0][2][2] = -A[0] - loc2;
    h_obj[1][2][2] = A[0] - loc2;
    h_obj[2][2][2] = 2.0 * loc2;

    loc2           = isqrt3 * A[5];
    h_obj[3][2][2] = A[1] - loc2;
    h_obj[4][2][2] = 2.0 * loc2;

    h_obj[5][2][2] = tisqrt3 * A[6];

    // completes diagonal blocks.
    h_obj[0].fill_lower_triangle();
    h_obj[3].fill_lower_triangle();
    h_obj[5].fill_lower_triangle();
    return true;
}
bool MBMesquite::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 
) [inline]

Definition at line 665 of file MeanRatioFunctions.hpp.

References moab::cross(), MBMesquite::Matrix3D::fill_lower_triangle(), MSQ_MIN, MBMesquite::Exponent::raise(), scale(), and MBMesquite::Exponent::value().

Referenced by MBMesquite::IdealWeightMeanRatio::evaluate_with_Hessian(), MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_Hessian(), MBMesquite::IdealWeightMeanRatio::evaluate_with_Hessian_diagonal(), and MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_Hessian_diagonal().

{
    double matr[9], f;
    double adj_m[9], g;  // adj_m[2,5,8] not used
    double dg[9];        // dg[2,5,8] not used
    double loc0, loc1, loc2, loc3, loc4;
    double A[12], J_A[6], J_B[9], J_C[9], cross;  // only 2x2 corners used

    const double scale[3] = { d[0] * d[0], d[0] * d[1], d[1] * d[1] };

    /* Calculate M = [A*inv(W) n] */
    matr[0] = d[0] * ( x[1][0] - x[0][0] );
    matr[1] = d[1] * ( x[2][0] - x[0][0] );
    matr[2] = n[0];

    matr[3] = d[0] * ( x[1][1] - x[0][1] );
    matr[4] = d[1] * ( x[2][1] - x[0][1] );
    matr[5] = n[1];

    matr[6] = d[0] * ( x[1][2] - x[0][2] );
    matr[7] = d[1] * ( x[2][2] - x[0][2] );
    matr[8] = n[2];

    /* Calculate det([n M]). */
    dg[0] = matr[4] * matr[8] - matr[5] * matr[7];
    dg[3] = matr[2] * matr[7] - matr[1] * matr[8];
    dg[6] = matr[1] * matr[5] - matr[2] * matr[4];
    g     = matr[0] * dg[0] + matr[3] * dg[3] + matr[6] * dg[6];
    if( g < MSQ_MIN )
    {
        obj = g;
        return false;
    }

    /* Calculate norm(M). */
    f = matr[0] * matr[0] + matr[1] * matr[1] + matr[3] * matr[3] + matr[4] * matr[4] + matr[6] * matr[6] +
        matr[7] * matr[7];

    loc3 = f;
    loc4 = g;

    /* Calculate objective function. */
    obj = a * b.raise( f ) * c.raise( g );

    /* Calculate the derivative of the objective function.    */
    f = b.value() * obj / f; /* Constant on nabla f      */
    g = c.value() * obj / g; /* Constant on nable g      */
    f *= 2.0;                /* Modification for nabla f */

    dg[1] = matr[5] * matr[6] - matr[3] * matr[8];
    dg[4] = matr[0] * matr[8] - matr[2] * matr[6];
    dg[7] = matr[2] * matr[3] - matr[0] * matr[5];

    adj_m[0] = d[0] * ( matr[0] * f + dg[0] * g );
    adj_m[1] = d[1] * ( matr[1] * f + dg[1] * g );
    adj_m[3] = d[0] * ( matr[3] * f + dg[3] * g );
    adj_m[4] = d[1] * ( matr[4] * f + dg[4] * g );
    adj_m[6] = d[0] * ( matr[6] * f + dg[6] * g );
    adj_m[7] = d[1] * ( matr[7] * f + dg[7] * g );

    g_obj[0][0] = -adj_m[0] - adj_m[1];
    g_obj[1][0] = adj_m[0];
    g_obj[2][0] = adj_m[1];

    g_obj[0][1] = -adj_m[3] - adj_m[4];
    g_obj[1][1] = adj_m[3];
    g_obj[2][1] = adj_m[4];

    g_obj[0][2] = -adj_m[6] - adj_m[7];
    g_obj[1][2] = adj_m[6];
    g_obj[2][2] = adj_m[7];

    /* Calculate the hessian of the objective.                   */
    loc0  = f;                            /* Constant on nabla^2 f       */
    loc1  = g;                            /* Constant on nabla^2 g       */
    cross = f * c.value() / loc4;         /* Constant on nabla g nabla f */
    f     = f * ( b.value() - 1 ) / loc3; /* Constant on nabla f nabla f */
    g     = g * ( c.value() - 1 ) / loc4; /* Constant on nabla g nabla g */
    f *= 2.0;                             /* Modification for nabla f    */

    /* First block of rows */
    loc3 = matr[0] * f + dg[0] * cross;
    loc4 = dg[0] * g + matr[0] * cross;

    J_A[0] = loc0 + loc3 * matr[0] + loc4 * dg[0];
    J_A[1] = loc3 * matr[1] + loc4 * dg[1];
    J_B[0] = loc3 * matr[3] + loc4 * dg[3];
    J_B[1] = loc3 * matr[4] + loc4 * dg[4];
    J_C[0] = loc3 * matr[6] + loc4 * dg[6];
    J_C[1] = loc3 * matr[7] + loc4 * dg[7];

    loc3 = matr[1] * f + dg[1] * cross;
    loc4 = dg[1] * g + matr[1] * cross;

    J_A[3] = loc0 + loc3 * matr[1] + loc4 * dg[1];
    J_B[3] = loc3 * matr[3] + loc4 * dg[3];
    J_B[4] = loc3 * matr[4] + loc4 * dg[4];
    J_C[3] = loc3 * matr[6] + loc4 * dg[6];
    J_C[4] = loc3 * matr[7] + loc4 * dg[7];

    /* First diagonal block */
    J_A[0] *= scale[0];
    J_A[1] *= scale[1];
    J_A[3] *= scale[2];

    A[0] = -J_A[0] - J_A[1];
    A[4] = -J_A[1] - J_A[3];

    h_obj[0][0][0] = -A[0] - A[4];
    h_obj[1][0][0] = A[0];
    h_obj[2][0][0] = A[4];

    h_obj[3][0][0] = J_A[0];
    h_obj[4][0][0] = J_A[1];

    h_obj[5][0][0] = J_A[3];

    /* First off-diagonal block */
    loc2 = matr[8] * loc1;
    J_B[1] += loc2;
    J_B[3] -= loc2;

    J_B[0] *= scale[0];
    J_B[1] *= scale[1];
    J_B[3] *= scale[1];
    J_B[4] *= scale[2];

    A[0] = -J_B[0] - J_B[3];
    A[4] = -J_B[1] - J_B[4];

    h_obj[0][0][1] = -A[0] - A[4];
    h_obj[1][0][1] = A[0];
    h_obj[2][0][1] = A[4];

    h_obj[1][1][0] = -J_B[0] - J_B[1];
    h_obj[3][0][1] = J_B[0];
    h_obj[4][0][1] = J_B[1];

    h_obj[2][1][0] = -J_B[3] - J_B[4];
    h_obj[4][1][0] = J_B[3];
    h_obj[5][0][1] = J_B[4];

    /* Second off-diagonal block */
    loc2 = matr[5] * loc1;
    J_C[1] -= loc2;
    J_C[3] += loc2;

    J_C[0] *= scale[0];
    J_C[1] *= scale[1];
    J_C[3] *= scale[1];
    J_C[4] *= scale[2];

    A[0] = -J_C[0] - J_C[3];
    A[4] = -J_C[1] - J_C[4];

    h_obj[0][0][2] = -A[0] - A[4];
    h_obj[1][0][2] = A[0];
    h_obj[2][0][2] = A[4];

    h_obj[1][2][0] = -J_C[0] - J_C[1];
    h_obj[3][0][2] = J_C[0];
    h_obj[4][0][2] = J_C[1];

    h_obj[2][2][0] = -J_C[3] - J_C[4];
    h_obj[4][2][0] = J_C[3];
    h_obj[5][0][2] = J_C[4];

    /* Second block of rows */
    loc3 = matr[3] * f + dg[3] * cross;
    loc4 = dg[3] * g + matr[3] * cross;

    J_A[0] = loc0 + loc3 * matr[3] + loc4 * dg[3];
    J_A[1] = loc3 * matr[4] + loc4 * dg[4];
    J_B[0] = loc3 * matr[6] + loc4 * dg[6];
    J_B[1] = loc3 * matr[7] + loc4 * dg[7];

    loc3 = matr[4] * f + dg[4] * cross;
    loc4 = dg[4] * g + matr[4] * cross;

    J_A[3] = loc0 + loc3 * matr[4] + loc4 * dg[4];
    J_B[3] = loc3 * matr[6] + loc4 * dg[6];
    J_B[4] = loc3 * matr[7] + loc4 * dg[7];

    /* Second diagonal block */
    J_A[0] *= scale[0];
    J_A[1] *= scale[1];
    J_A[3] *= scale[2];

    A[0] = -J_A[0] - J_A[1];
    A[4] = -J_A[1] - J_A[3];

    h_obj[0][1][1] = -A[0] - A[4];
    h_obj[1][1][1] = A[0];
    h_obj[2][1][1] = A[4];

    h_obj[3][1][1] = J_A[0];
    h_obj[4][1][1] = J_A[1];

    h_obj[5][1][1] = J_A[3];

    /* Third off-diagonal block */
    loc2 = matr[2] * loc1;
    J_B[1] += loc2;
    J_B[3] -= loc2;

    J_B[0] *= scale[0];
    J_B[1] *= scale[1];
    J_B[3] *= scale[1];
    J_B[4] *= scale[2];

    A[0] = -J_B[0] - J_B[3];
    A[4] = -J_B[1] - J_B[4];

    h_obj[0][1][2] = -A[0] - A[4];
    h_obj[1][1][2] = A[0];
    h_obj[2][1][2] = A[4];

    h_obj[1][2][1] = -J_B[0] - J_B[1];
    h_obj[3][1][2] = J_B[0];
    h_obj[4][1][2] = J_B[1];

    h_obj[2][2][1] = -J_B[3] - J_B[4];
    h_obj[4][2][1] = J_B[3];
    h_obj[5][1][2] = J_B[4];

    /* Third block of rows */
    loc3 = matr[6] * f + dg[6] * cross;
    loc4 = dg[6] * g + matr[6] * cross;

    J_A[0] = loc0 + loc3 * matr[6] + loc4 * dg[6];
    J_A[1] = loc3 * matr[7] + loc4 * dg[7];

    loc3 = matr[7] * f + dg[7] * cross;
    loc4 = dg[7] * g + matr[7] * cross;

    J_A[3] = loc0 + loc3 * matr[7] + loc4 * dg[7];

    /* Third diagonal block */
    J_A[0] *= scale[0];
    J_A[1] *= scale[1];
    J_A[3] *= scale[2];

    A[0] = -J_A[0] - J_A[1];
    A[4] = -J_A[1] - J_A[3];

    h_obj[0][2][2] = -A[0] - A[4];
    h_obj[1][2][2] = A[0];
    h_obj[2][2][2] = A[4];

    h_obj[3][2][2] = J_A[0];
    h_obj[4][2][2] = J_A[1];

    h_obj[5][2][2] = J_A[3];

    // completes diagonal blocks.
    h_obj[0].fill_lower_triangle();
    h_obj[3].fill_lower_triangle();
    h_obj[5].fill_lower_triangle();
    return true;
}
bool MBMesquite::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 
) [inline]

Definition at line 1073 of file MeanRatioFunctions.hpp.

References moab::cross(), MBMesquite::Matrix3D::fill_lower_triangle(), isqrt3, isqrt6, MSQ_MIN, MBMesquite::Exponent::raise(), tisqrt3, tisqrt6, and MBMesquite::Exponent::value().

Referenced by MBMesquite::IdealWeightMeanRatio::evaluate_with_Hessian(), MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_Hessian(), MBMesquite::IdealWeightMeanRatio::evaluate_with_Hessian_diagonal(), and MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_Hessian_diagonal().

{
    double matr[9], f;
    double adj_m[9], g;
    double dg[9], loc0, loc1, loc2, loc3, loc4;
    double A[12], J_A[6], J_B[9], J_C[9], cross;

    /* Calculate M = A*inv(W). */
    f       = x[1][0] + x[0][0];
    matr[0] = x[1][0] - x[0][0];
    matr[1] = ( 2.0 * x[2][0] - f ) * isqrt3;
    matr[2] = ( 3.0 * x[3][0] - x[2][0] - f ) * isqrt6;

    f       = x[1][1] + x[0][1];
    matr[3] = x[1][1] - x[0][1];
    matr[4] = ( 2.0 * x[2][1] - f ) * isqrt3;
    matr[5] = ( 3.0 * x[3][1] - x[2][1] - f ) * isqrt6;

    f       = x[1][2] + x[0][2];
    matr[6] = x[1][2] - x[0][2];
    matr[7] = ( 2.0 * x[2][2] - f ) * isqrt3;
    matr[8] = ( 3.0 * x[3][2] - x[2][2] - f ) * isqrt6;

    /* Calculate det(M). */
    dg[0] = matr[4] * matr[8] - matr[5] * matr[7];
    dg[1] = matr[5] * matr[6] - matr[3] * matr[8];
    dg[2] = matr[3] * matr[7] - matr[4] * matr[6];
    g     = matr[0] * dg[0] + matr[1] * dg[1] + matr[2] * dg[2];
    if( g < MSQ_MIN )
    {
        obj = g;
        return false;
    }

    /* Calculate norm(M). */
    f = matr[0] * matr[0] + matr[1] * matr[1] + matr[2] * matr[2] + matr[3] * matr[3] + matr[4] * matr[4] +
        matr[5] * matr[5] + matr[6] * matr[6] + matr[7] * matr[7] + matr[8] * matr[8];

    loc3 = f;
    loc4 = g;

    /* Calculate objective function. */
    obj = a * b.raise( f ) * c.raise( g );

    /* Calculate the derivative of the objective function.    */
    f = b.value() * obj / f; /* Constant on nabla f      */
    g = c.value() * obj / g; /* Constant on nable g      */
    f *= 2.0;                /* Modification for nabla f */

    dg[3] = matr[2] * matr[7] - matr[1] * matr[8];
    dg[4] = matr[0] * matr[8] - matr[2] * matr[6];
    dg[5] = matr[1] * matr[6] - matr[0] * matr[7];
    dg[6] = matr[1] * matr[5] - matr[2] * matr[4];
    dg[7] = matr[2] * matr[3] - matr[0] * matr[5];
    dg[8] = matr[0] * matr[4] - matr[1] * matr[3];

    adj_m[0] = matr[0] * f + dg[0] * g;
    adj_m[1] = matr[1] * f + dg[1] * g;
    adj_m[2] = matr[2] * f + dg[2] * g;
    adj_m[3] = matr[3] * f + dg[3] * g;
    adj_m[4] = matr[4] * f + dg[4] * g;
    adj_m[5] = matr[5] * f + dg[5] * g;
    adj_m[6] = matr[6] * f + dg[6] * g;
    adj_m[7] = matr[7] * f + dg[7] * g;
    adj_m[8] = matr[8] * f + dg[8] * g;

    loc0        = isqrt3 * adj_m[1];
    loc1        = isqrt6 * adj_m[2];
    loc2        = loc0 + loc1;
    g_obj[0][0] = -adj_m[0] - loc2;
    g_obj[1][0] = adj_m[0] - loc2;
    g_obj[2][0] = 2.0 * loc0 - loc1;
    g_obj[3][0] = 3.0 * loc1;

    loc0        = isqrt3 * adj_m[4];
    loc1        = isqrt6 * adj_m[5];
    loc2        = loc0 + loc1;
    g_obj[0][1] = -adj_m[3] - loc2;
    g_obj[1][1] = adj_m[3] - loc2;
    g_obj[2][1] = 2.0 * loc0 - loc1;
    g_obj[3][1] = 3.0 * loc1;

    loc0        = isqrt3 * adj_m[7];
    loc1        = isqrt6 * adj_m[8];
    loc2        = loc0 + loc1;
    g_obj[0][2] = -adj_m[6] - loc2;
    g_obj[1][2] = adj_m[6] - loc2;
    g_obj[2][2] = 2.0 * loc0 - loc1;
    g_obj[3][2] = 3.0 * loc1;

    /* Calculate the hessian of the objective.                   */
    loc0  = f;                            /* Constant on nabla^2 f       */
    loc1  = g;                            /* Constant on nabla^2 g       */
    cross = f * c.value() / loc4;         /* Constant on nabla g nabla f */
    f     = f * ( b.value() - 1 ) / loc3; /* Constant on nabla f nabla f */
    g     = g * ( c.value() - 1 ) / loc4; /* Constant on nabla g nabla g */
    f *= 2.0;                             /* Modification for nabla f    */

    /* First block of rows */
    loc3 = matr[0] * f + dg[0] * cross;
    loc4 = dg[0] * g + matr[0] * cross;

    J_A[0] = loc0 + loc3 * matr[0] + loc4 * dg[0];
    J_A[1] = loc3 * matr[1] + loc4 * dg[1];
    J_A[2] = loc3 * matr[2] + loc4 * dg[2];
    J_B[0] = loc3 * matr[3] + loc4 * dg[3];
    J_B[1] = loc3 * matr[4] + loc4 * dg[4];
    J_B[2] = loc3 * matr[5] + loc4 * dg[5];
    J_C[0] = loc3 * matr[6] + loc4 * dg[6];
    J_C[1] = loc3 * matr[7] + loc4 * dg[7];
    J_C[2] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[1] * f + dg[1] * cross;
    loc4 = dg[1] * g + matr[1] * cross;

    J_A[3] = loc0 + loc3 * matr[1] + loc4 * dg[1];
    J_A[4] = loc3 * matr[2] + loc4 * dg[2];
    J_B[3] = loc3 * matr[3] + loc4 * dg[3];
    J_B[4] = loc3 * matr[4] + loc4 * dg[4];
    J_B[5] = loc3 * matr[5] + loc4 * dg[5];
    J_C[3] = loc3 * matr[6] + loc4 * dg[6];
    J_C[4] = loc3 * matr[7] + loc4 * dg[7];
    J_C[5] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[2] * f + dg[2] * cross;
    loc4 = dg[2] * g + matr[2] * cross;

    J_A[5] = loc0 + loc3 * matr[2] + loc4 * dg[2];
    J_B[6] = loc3 * matr[3] + loc4 * dg[3];
    J_B[7] = loc3 * matr[4] + loc4 * dg[4];
    J_B[8] = loc3 * matr[5] + loc4 * dg[5];
    J_C[6] = loc3 * matr[6] + loc4 * dg[6];
    J_C[7] = loc3 * matr[7] + loc4 * dg[7];
    J_C[8] = loc3 * matr[8] + loc4 * dg[8];

    /* First diagonal block */
    loc2 = isqrt3 * J_A[1];
    loc3 = isqrt6 * J_A[2];
    loc4 = loc2 + loc3;

    A[0] = -J_A[0] - loc4;
    A[1] = J_A[0] - loc4;

    loc2 = isqrt3 * J_A[3];
    loc3 = isqrt6 * J_A[4];
    loc4 = loc2 + loc3;

    A[4] = -J_A[1] - loc4;
    A[5] = J_A[1] - loc4;
    A[6] = 2.0 * loc2 - loc3;

    loc2 = isqrt3 * J_A[4];
    loc3 = isqrt6 * J_A[5];
    loc4 = loc2 + loc3;

    A[8]  = -J_A[2] - loc4;
    A[9]  = J_A[2] - loc4;
    A[10] = 2.0 * loc2 - loc3;
    A[11] = 3.0 * loc3;

    loc2 = isqrt3 * A[4];
    loc3 = isqrt6 * A[8];
    loc4 = loc2 + loc3;

    h_obj[0][0][0] = -A[0] - loc4;
    h_obj[1][0][0] = A[0] - loc4;
    h_obj[2][0][0] = 2.0 * loc2 - loc3;
    h_obj[3][0][0] = 3.0 * loc3;

    loc2 = isqrt3 * A[5];
    loc3 = isqrt6 * A[9];

    h_obj[4][0][0] = A[1] - loc2 - loc3;
    h_obj[5][0][0] = 2.0 * loc2 - loc3;
    h_obj[6][0][0] = 3.0 * loc3;

    loc3           = isqrt6 * A[10];
    h_obj[7][0][0] = tisqrt3 * A[6] - loc3;
    h_obj[8][0][0] = 3.0 * loc3;

    h_obj[9][0][0] = tisqrt6 * A[11];

    /* First off-diagonal block */
    loc2 = matr[8] * loc1;
    J_B[1] += loc2;
    J_B[3] -= loc2;

    loc2 = matr[7] * loc1;
    J_B[2] -= loc2;
    J_B[6] += loc2;

    loc2 = matr[6] * loc1;
    J_B[5] += loc2;
    J_B[7] -= loc2;

    loc2 = isqrt3 * J_B[3];
    loc3 = isqrt6 * J_B[6];
    loc4 = loc2 + loc3;

    A[0] = -J_B[0] - loc4;
    A[1] = J_B[0] - loc4;
    A[2] = 2.0 * loc2 - loc3;
    A[3] = 3.0 * loc3;

    loc2 = isqrt3 * J_B[4];
    loc3 = isqrt6 * J_B[7];
    loc4 = loc2 + loc3;

    A[4] = -J_B[1] - loc4;
    A[5] = J_B[1] - loc4;
    A[6] = 2.0 * loc2 - loc3;
    A[7] = 3.0 * loc3;

    loc2 = isqrt3 * J_B[5];
    loc3 = isqrt6 * J_B[8];
    loc4 = loc2 + loc3;

    A[8]  = -J_B[2] - loc4;
    A[9]  = J_B[2] - loc4;
    A[10] = 2.0 * loc2 - loc3;
    A[11] = 3.0 * loc3;

    loc2 = isqrt3 * A[4];
    loc3 = isqrt6 * A[8];
    loc4 = loc2 + loc3;

    h_obj[0][0][1] = -A[0] - loc4;
    h_obj[1][0][1] = A[0] - loc4;
    h_obj[2][0][1] = 2.0 * loc2 - loc3;
    h_obj[3][0][1] = 3.0 * loc3;

    loc2 = isqrt3 * A[5];
    loc3 = isqrt6 * A[9];
    loc4 = loc2 + loc3;

    h_obj[1][1][0] = -A[1] - loc4;
    h_obj[4][0][1] = A[1] - loc4;
    h_obj[5][0][1] = 2.0 * loc2 - loc3;
    h_obj[6][0][1] = 3.0 * loc3;

    loc2 = isqrt3 * A[6];
    loc3 = isqrt6 * A[10];
    loc4 = loc2 + loc3;

    h_obj[2][1][0] = -A[2] - loc4;
    h_obj[5][1][0] = A[2] - loc4;
    h_obj[7][0][1] = 2.0 * loc2 - loc3;
    h_obj[8][0][1] = 3.0 * loc3;

    loc2 = isqrt3 * A[7];
    loc3 = isqrt6 * A[11];
    loc4 = loc2 + loc3;

    h_obj[3][1][0] = -A[3] - loc4;
    h_obj[6][1][0] = A[3] - loc4;
    h_obj[8][1][0] = 2.0 * loc2 - loc3;
    h_obj[9][0][1] = 3.0 * loc3;

    /* Second off-diagonal block */
    loc2 = matr[5] * loc1;
    J_C[1] -= loc2;
    J_C[3] += loc2;

    loc2 = matr[4] * loc1;
    J_C[2] += loc2;
    J_C[6] -= loc2;

    loc2 = matr[3] * loc1;
    J_C[5] -= loc2;
    J_C[7] += loc2;

    loc2 = isqrt3 * J_C[3];
    loc3 = isqrt6 * J_C[6];
    loc4 = loc2 + loc3;

    A[0] = -J_C[0] - loc4;
    A[1] = J_C[0] - loc4;
    A[2] = 2.0 * loc2 - loc3;
    A[3] = 3.0 * loc3;

    loc2 = isqrt3 * J_C[4];
    loc3 = isqrt6 * J_C[7];
    loc4 = loc2 + loc3;

    A[4] = -J_C[1] - loc4;
    A[5] = J_C[1] - loc4;
    A[6] = 2.0 * loc2 - loc3;
    A[7] = 3.0 * loc3;

    loc2 = isqrt3 * J_C[5];
    loc3 = isqrt6 * J_C[8];
    loc4 = loc2 + loc3;

    A[8]  = -J_C[2] - loc4;
    A[9]  = J_C[2] - loc4;
    A[10] = 2.0 * loc2 - loc3;
    A[11] = 3.0 * loc3;

    loc2 = isqrt3 * A[4];
    loc3 = isqrt6 * A[8];
    loc4 = loc2 + loc3;

    h_obj[0][0][2] = -A[0] - loc4;
    h_obj[1][0][2] = A[0] - loc4;
    h_obj[2][0][2] = 2.0 * loc2 - loc3;
    h_obj[3][0][2] = 3.0 * loc3;

    loc2 = isqrt3 * A[5];
    loc3 = isqrt6 * A[9];
    loc4 = loc2 + loc3;

    h_obj[1][2][0] = -A[1] - loc4;
    h_obj[4][0][2] = A[1] - loc4;
    h_obj[5][0][2] = 2.0 * loc2 - loc3;
    h_obj[6][0][2] = 3.0 * loc3;

    loc2 = isqrt3 * A[6];
    loc3 = isqrt6 * A[10];
    loc4 = loc2 + loc3;

    h_obj[2][2][0] = -A[2] - loc4;
    h_obj[5][2][0] = A[2] - loc4;
    h_obj[7][0][2] = 2.0 * loc2 - loc3;
    h_obj[8][0][2] = 3.0 * loc3;

    loc2 = isqrt3 * A[7];
    loc3 = isqrt6 * A[11];
    loc4 = loc2 + loc3;

    h_obj[3][2][0] = -A[3] - loc4;
    h_obj[6][2][0] = A[3] - loc4;
    h_obj[8][2][0] = 2.0 * loc2 - loc3;
    h_obj[9][0][2] = 3.0 * loc3;

    /* Second block of rows */
    loc3 = matr[3] * f + dg[3] * cross;
    loc4 = dg[3] * g + matr[3] * cross;

    J_A[0] = loc0 + loc3 * matr[3] + loc4 * dg[3];
    J_A[1] = loc3 * matr[4] + loc4 * dg[4];
    J_A[2] = loc3 * matr[5] + loc4 * dg[5];
    J_B[0] = loc3 * matr[6] + loc4 * dg[6];
    J_B[1] = loc3 * matr[7] + loc4 * dg[7];
    J_B[2] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[4] * f + dg[4] * cross;
    loc4 = dg[4] * g + matr[4] * cross;

    J_A[3] = loc0 + loc3 * matr[4] + loc4 * dg[4];
    J_A[4] = loc3 * matr[5] + loc4 * dg[5];
    J_B[3] = loc3 * matr[6] + loc4 * dg[6];
    J_B[4] = loc3 * matr[7] + loc4 * dg[7];
    J_B[5] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[5] * f + dg[5] * cross;
    loc4 = dg[5] * g + matr[5] * cross;

    J_A[5] = loc0 + loc3 * matr[5] + loc4 * dg[5];
    J_B[6] = loc3 * matr[6] + loc4 * dg[6];
    J_B[7] = loc3 * matr[7] + loc4 * dg[7];
    J_B[8] = loc3 * matr[8] + loc4 * dg[8];

    /* Second diagonal block */
    loc2 = isqrt3 * J_A[1];
    loc3 = isqrt6 * J_A[2];
    loc4 = loc2 + loc3;

    A[0] = -J_A[0] - loc4;
    A[1] = J_A[0] - loc4;

    loc2 = isqrt3 * J_A[3];
    loc3 = isqrt6 * J_A[4];
    loc4 = loc2 + loc3;

    A[4] = -J_A[1] - loc4;
    A[5] = J_A[1] - loc4;
    A[6] = 2.0 * loc2 - loc3;

    loc2 = isqrt3 * J_A[4];
    loc3 = isqrt6 * J_A[5];
    loc4 = loc2 + loc3;

    A[8]  = -J_A[2] - loc4;
    A[9]  = J_A[2] - loc4;
    A[10] = 2.0 * loc2 - loc3;
    A[11] = 3.0 * loc3;

    loc2 = isqrt3 * A[4];
    loc3 = isqrt6 * A[8];
    loc4 = loc2 + loc3;

    h_obj[0][1][1] = -A[0] - loc4;
    h_obj[1][1][1] = A[0] - loc4;
    h_obj[2][1][1] = 2.0 * loc2 - loc3;
    h_obj[3][1][1] = 3.0 * loc3;

    loc2 = isqrt3 * A[5];
    loc3 = isqrt6 * A[9];

    h_obj[4][1][1] = A[1] - loc2 - loc3;
    h_obj[5][1][1] = 2.0 * loc2 - loc3;
    h_obj[6][1][1] = 3.0 * loc3;

    loc3           = isqrt6 * A[10];
    h_obj[7][1][1] = tisqrt3 * A[6] - loc3;
    h_obj[8][1][1] = 3.0 * loc3;

    h_obj[9][1][1] = tisqrt6 * A[11];

    /* Third off-diagonal block */
    loc2 = matr[2] * loc1;
    J_B[1] += loc2;
    J_B[3] -= loc2;

    loc2 = matr[1] * loc1;
    J_B[2] -= loc2;
    J_B[6] += loc2;

    loc2 = matr[0] * loc1;
    J_B[5] += loc2;
    J_B[7] -= loc2;

    loc2 = isqrt3 * J_B[3];
    loc3 = isqrt6 * J_B[6];
    loc4 = loc2 + loc3;

    A[0] = -J_B[0] - loc4;
    A[1] = J_B[0] - loc4;
    A[2] = 2.0 * loc2 - loc3;
    A[3] = 3.0 * loc3;

    loc2 = isqrt3 * J_B[4];
    loc3 = isqrt6 * J_B[7];
    loc4 = loc2 + loc3;

    A[4] = -J_B[1] - loc4;
    A[5] = J_B[1] - loc4;
    A[6] = 2.0 * loc2 - loc3;
    A[7] = 3.0 * loc3;

    loc2 = isqrt3 * J_B[5];
    loc3 = isqrt6 * J_B[8];
    loc4 = loc2 + loc3;

    A[8]  = -J_B[2] - loc4;
    A[9]  = J_B[2] - loc4;
    A[10] = 2.0 * loc2 - loc3;
    A[11] = 3.0 * loc3;

    loc2 = isqrt3 * A[4];
    loc3 = isqrt6 * A[8];
    loc4 = loc2 + loc3;

    h_obj[0][1][2] = -A[0] - loc4;
    h_obj[1][1][2] = A[0] - loc4;
    h_obj[2][1][2] = 2.0 * loc2 - loc3;
    h_obj[3][1][2] = 3.0 * loc3;

    loc2 = isqrt3 * A[5];
    loc3 = isqrt6 * A[9];
    loc4 = loc2 + loc3;

    h_obj[1][2][1] = -A[1] - loc4;
    h_obj[4][1][2] = A[1] - loc4;
    h_obj[5][1][2] = 2.0 * loc2 - loc3;
    h_obj[6][1][2] = 3.0 * loc3;

    loc2 = isqrt3 * A[6];
    loc3 = isqrt6 * A[10];
    loc4 = loc2 + loc3;

    h_obj[2][2][1] = -A[2] - loc4;
    h_obj[5][2][1] = A[2] - loc4;
    h_obj[7][1][2] = 2.0 * loc2 - loc3;
    h_obj[8][1][2] = 3.0 * loc3;

    loc2 = isqrt3 * A[7];
    loc3 = isqrt6 * A[11];
    loc4 = loc2 + loc3;

    h_obj[3][2][1] = -A[3] - loc4;
    h_obj[6][2][1] = A[3] - loc4;
    h_obj[8][2][1] = 2.0 * loc2 - loc3;
    h_obj[9][1][2] = 3.0 * loc3;

    /* Third block of rows */
    loc3 = matr[6] * f + dg[6] * cross;
    loc4 = dg[6] * g + matr[6] * cross;

    J_A[0] = loc0 + loc3 * matr[6] + loc4 * dg[6];
    J_A[1] = loc3 * matr[7] + loc4 * dg[7];
    J_A[2] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[7] * f + dg[7] * cross;
    loc4 = dg[7] * g + matr[7] * cross;

    J_A[3] = loc0 + loc3 * matr[7] + loc4 * dg[7];
    J_A[4] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[8] * f + dg[8] * cross;
    loc4 = dg[8] * g + matr[8] * cross;

    J_A[5] = loc0 + loc3 * matr[8] + loc4 * dg[8];

    /* Third diagonal block */
    loc2 = isqrt3 * J_A[1];
    loc3 = isqrt6 * J_A[2];
    loc4 = loc2 + loc3;

    A[0] = -J_A[0] - loc4;
    A[1] = J_A[0] - loc4;

    loc2 = isqrt3 * J_A[3];
    loc3 = isqrt6 * J_A[4];
    loc4 = loc2 + loc3;

    A[4] = -J_A[1] - loc4;
    A[5] = J_A[1] - loc4;
    A[6] = 2.0 * loc2 - loc3;

    loc2 = isqrt3 * J_A[4];
    loc3 = isqrt6 * J_A[5];
    loc4 = loc2 + loc3;

    A[8]  = -J_A[2] - loc4;
    A[9]  = J_A[2] - loc4;
    A[10] = 2.0 * loc2 - loc3;
    A[11] = 3.0 * loc3;

    loc2 = isqrt3 * A[4];
    loc3 = isqrt6 * A[8];
    loc4 = loc2 + loc3;

    h_obj[0][2][2] = -A[0] - loc4;
    h_obj[1][2][2] = A[0] - loc4;
    h_obj[2][2][2] = 2.0 * loc2 - loc3;
    h_obj[3][2][2] = 3.0 * loc3;

    loc2 = isqrt3 * A[5];
    loc3 = isqrt6 * A[9];

    h_obj[4][2][2] = A[1] - loc2 - loc3;
    h_obj[5][2][2] = 2.0 * loc2 - loc3;
    h_obj[6][2][2] = 3.0 * loc3;

    loc3           = isqrt6 * A[10];
    h_obj[7][2][2] = tisqrt3 * A[6] - loc3;
    h_obj[8][2][2] = 3.0 * loc3;

    h_obj[9][2][2] = tisqrt6 * A[11];

    // completes diagonal blocks.
    h_obj[0].fill_lower_triangle();
    h_obj[4].fill_lower_triangle();
    h_obj[7].fill_lower_triangle();
    h_obj[9].fill_lower_triangle();
    return true;
}
bool MBMesquite::h_fcn_3e_v0 ( double &  obj,
Vector3D &  g_obj,
Matrix3D &  h_obj,
const Vector3D  x[4],
const double  a,
const Exponent &  b,
const Exponent &  c 
) [inline]

Definition at line 1820 of file MeanRatioFunctions.hpp.

References h_fcn_3e_v3().

{
    static Vector3D my_x[4];

    my_x[0] = x[1];
    my_x[1] = x[3];
    my_x[2] = x[2];
    my_x[3] = x[0];
    return h_fcn_3e_v3( obj, g_obj, h_obj, my_x, a, b, c );
}
bool MBMesquite::h_fcn_3e_v1 ( double &  obj,
Vector3D &  g_obj,
Matrix3D &  h_obj,
const Vector3D  x[4],
const double  a,
const Exponent &  b,
const Exponent &  c 
) [inline]

Definition at line 1832 of file MeanRatioFunctions.hpp.

References h_fcn_3e_v3().

{
    static Vector3D my_x[4];

    my_x[0] = x[0];
    my_x[1] = x[2];
    my_x[2] = x[3];
    my_x[3] = x[1];
    return h_fcn_3e_v3( obj, g_obj, h_obj, my_x, a, b, c );
}
bool MBMesquite::h_fcn_3e_v2 ( double &  obj,
Vector3D &  g_obj,
Matrix3D &  h_obj,
const Vector3D  x[4],
const double  a,
const Exponent &  b,
const Exponent &  c 
) [inline]

Definition at line 1844 of file MeanRatioFunctions.hpp.

References h_fcn_3e_v3().

{
    static Vector3D my_x[4];

    my_x[0] = x[1];
    my_x[1] = x[0];
    my_x[2] = x[3];
    my_x[3] = x[2];
    return h_fcn_3e_v3( obj, g_obj, h_obj, my_x, a, b, c );
}
bool MBMesquite::h_fcn_3e_v3 ( double &  obj,
Vector3D &  g_obj,
Matrix3D &  h_obj,
const Vector3D  x[4],
const double  a,
const Exponent &  b,
const Exponent &  c 
) [inline]

Definition at line 1730 of file MeanRatioFunctions.hpp.

References moab::cross(), MBMesquite::Matrix3D::fill_lower_triangle(), isqrt3, isqrt6, MSQ_MIN, MBMesquite::Exponent::raise(), tisqrt6, and MBMesquite::Exponent::value().

Referenced by h_fcn_3e_v0(), h_fcn_3e_v1(), and h_fcn_3e_v2().

{
    double matr[9], f, g;
    double dg[9], loc0, /*loc1,*/ loc3, loc4;
    double cross;

    /* Calculate M = A*inv(W). */
    f       = x[1][0] + x[0][0];
    matr[0] = x[1][0] - x[0][0];
    matr[1] = ( 2.0 * x[2][0] - f ) * isqrt3;
    matr[2] = ( 3.0 * x[3][0] - x[2][0] - f ) * isqrt6;

    f       = x[1][1] + x[0][1];
    matr[3] = x[1][1] - x[0][1];
    matr[4] = ( 2.0 * x[2][1] - f ) * isqrt3;
    matr[5] = ( 3.0 * x[3][1] - x[2][1] - f ) * isqrt6;

    f       = x[1][2] + x[0][2];
    matr[6] = x[1][2] - x[0][2];
    matr[7] = ( 2.0 * x[2][2] - f ) * isqrt3;
    matr[8] = ( 3.0 * x[3][2] - x[2][2] - f ) * isqrt6;

    /* Calculate det(M). */
    dg[0] = matr[4] * matr[8] - matr[5] * matr[7];
    dg[1] = matr[5] * matr[6] - matr[3] * matr[8];
    dg[2] = matr[3] * matr[7] - matr[4] * matr[6];
    g     = matr[0] * dg[0] + matr[1] * dg[1] + matr[2] * dg[2];
    if( g < MSQ_MIN )
    {
        obj = g;
        return false;
    }

    /* Calculate norm(M). */
    f = matr[0] * matr[0] + matr[1] * matr[1] + matr[2] * matr[2] + matr[3] * matr[3] + matr[4] * matr[4] +
        matr[5] * matr[5] + matr[6] * matr[6] + matr[7] * matr[7] + matr[8] * matr[8];

    loc3 = f;
    loc4 = g;

    /* Calculate objective function. */
    obj = a * b.raise( f ) * c.raise( g );

    /* Calculate the derivative of the objective function.    */
    f = b.value() * obj / f; /* Constant on nabla f      */
    g = c.value() * obj / g; /* Constant on nable g      */
    f *= 2.0;                /* Modification for nabla f */

    dg[5] = matr[1] * matr[6] - matr[0] * matr[7];
    dg[8] = matr[0] * matr[4] - matr[1] * matr[3];

    g_obj[0] = tisqrt6 * ( matr[2] * f + dg[2] * g );
    g_obj[1] = tisqrt6 * ( matr[5] * f + dg[5] * g );
    g_obj[2] = tisqrt6 * ( matr[8] * f + dg[8] * g );

    /* Calculate the hessian of the objective.                   */
    loc0 = f; /* Constant on nabla^2 f       */
    //  loc1 = g;           /* Constant on nabla^2 g       */
    cross = f * c.value() / loc4;         /* Constant on nabla g nabla f */
    f     = f * ( b.value() - 1 ) / loc3; /* Constant on nabla f nabla f */
    g     = g * ( c.value() - 1 ) / loc4; /* Constant on nabla g nabla g */
    f *= 2.0;                             /* Modification for nabla f    */

    /* First block of rows */
    loc3 = matr[2] * f + dg[2] * cross;
    loc4 = dg[2] * g + matr[2] * cross;

    h_obj[0][0] = 1.5 * ( loc0 + loc3 * matr[2] + loc4 * dg[2] );
    h_obj[0][1] = 1.5 * ( loc3 * matr[5] + loc4 * dg[5] );
    h_obj[0][2] = 1.5 * ( loc3 * matr[8] + loc4 * dg[8] );

    /* Second block of rows */
    loc3 = matr[5] * f + dg[5] * cross;
    loc4 = dg[5] * g + matr[5] * cross;

    h_obj[1][1] = 1.5 * ( loc0 + loc3 * matr[5] + loc4 * dg[5] );
    h_obj[1][2] = 1.5 * ( loc3 * matr[8] + loc4 * dg[8] );

    /* Third block of rows */
    loc3 = matr[8] * f + dg[8] * cross;
    loc4 = dg[8] * g + matr[8] * cross;

    h_obj[2][2] = 1.5 * ( loc0 + loc3 * matr[8] + loc4 * dg[8] );

    // completes diagonal block.
    h_obj.fill_lower_triangle();
    return true;
}
int MBMesquite::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 
) [inline]

Definition at line 1988 of file MeanRatioFunctions.hpp.

References moab::cross(), MBMesquite::Matrix3D::fill_lower_triangle(), MSQ_MIN, MBMesquite::Exponent::raise(), scale(), and MBMesquite::Exponent::value().

Referenced by MBMesquite::IdealWeightMeanRatio::evaluate_with_Hessian(), MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_Hessian(), MBMesquite::IdealWeightMeanRatio::evaluate_with_Hessian_diagonal(), and MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_Hessian_diagonal().

{
    double matr[9], f;
    double adj_m[9], g;
    double dg[9], loc0, loc1, loc2, loc3, loc4;
    double A[3], J_A[6], J_B[9], J_C[9], cross;

    const double scale[6] = { d[0] * d[0], d[0] * d[1], d[0] * d[2], d[1] * d[1], d[1] * d[2], d[2] * d[2] };

    /* Calculate M = A*inv(W). */
    matr[0] = d[0] * ( x[1][0] - x[0][0] );
    matr[1] = d[1] * ( x[2][0] - x[0][0] );
    matr[2] = d[2] * ( x[3][0] - x[0][0] );

    matr[3] = d[0] * ( x[1][1] - x[0][1] );
    matr[4] = d[1] * ( x[2][1] - x[0][1] );
    matr[5] = d[2] * ( x[3][1] - x[0][1] );

    matr[6] = d[0] * ( x[1][2] - x[0][2] );
    matr[7] = d[1] * ( x[2][2] - x[0][2] );
    matr[8] = d[2] * ( x[3][2] - x[0][2] );

    /* Calculate det(M). */
    dg[0] = matr[4] * matr[8] - matr[5] * matr[7];
    dg[1] = matr[5] * matr[6] - matr[3] * matr[8];
    dg[2] = matr[3] * matr[7] - matr[4] * matr[6];
    g     = matr[0] * dg[0] + matr[1] * dg[1] + matr[2] * dg[2];
    if( g < MSQ_MIN )
    {
        obj = g;
        return false;
    }

    /* Calculate norm(M). */
    f = matr[0] * matr[0] + matr[1] * matr[1] + matr[2] * matr[2] + matr[3] * matr[3] + matr[4] * matr[4] +
        matr[5] * matr[5] + matr[6] * matr[6] + matr[7] * matr[7] + matr[8] * matr[8];

    loc3 = f;
    loc4 = g;

    /* Calculate objective function. */
    obj = a * b.raise( f ) * c.raise( g );

    /* Calculate the derivative of the objective function.    */
    f = b.value() * obj / f; /* Constant on nabla f      */
    g = c.value() * obj / g; /* Constant on nable g      */
    f *= 2.0;                /* Modification for nabla f */

    dg[3] = matr[2] * matr[7] - matr[1] * matr[8];
    dg[4] = matr[0] * matr[8] - matr[2] * matr[6];
    dg[5] = matr[1] * matr[6] - matr[0] * matr[7];
    dg[6] = matr[1] * matr[5] - matr[2] * matr[4];
    dg[7] = matr[2] * matr[3] - matr[0] * matr[5];
    dg[8] = matr[0] * matr[4] - matr[1] * matr[3];

    adj_m[0] = d[0] * ( matr[0] * f + dg[0] * g );
    adj_m[1] = d[1] * ( matr[1] * f + dg[1] * g );
    adj_m[2] = d[2] * ( matr[2] * f + dg[2] * g );
    adj_m[3] = d[0] * ( matr[3] * f + dg[3] * g );
    adj_m[4] = d[1] * ( matr[4] * f + dg[4] * g );
    adj_m[5] = d[2] * ( matr[5] * f + dg[5] * g );
    adj_m[6] = d[0] * ( matr[6] * f + dg[6] * g );
    adj_m[7] = d[1] * ( matr[7] * f + dg[7] * g );
    adj_m[8] = d[2] * ( matr[8] * f + dg[8] * g );

    g_obj[0][0] = -adj_m[0] - adj_m[1] - adj_m[2];
    g_obj[1][0] = adj_m[0];
    g_obj[2][0] = adj_m[1];
    g_obj[3][0] = adj_m[2];

    g_obj[0][1] = -adj_m[3] - adj_m[4] - adj_m[5];
    g_obj[1][1] = adj_m[3];
    g_obj[2][1] = adj_m[4];
    g_obj[3][1] = adj_m[5];

    g_obj[0][2] = -adj_m[6] - adj_m[7] - adj_m[8];
    g_obj[1][2] = adj_m[6];
    g_obj[2][2] = adj_m[7];
    g_obj[3][2] = adj_m[8];

    /* Calculate the hessian of the objective.                   */
    loc0  = f;                            /* Constant on nabla^2 f       */
    loc1  = g;                            /* Constant on nabla^2 g       */
    cross = f * c.value() / loc4;         /* Constant on nabla g nabla f */
    f     = f * ( b.value() - 1 ) / loc3; /* Constant on nabla f nabla f */
    g     = g * ( c.value() - 1 ) / loc4; /* Constant on nabla g nabla g */
    f *= 2.0;                             /* Modification for nabla f    */

    /* First block of rows */
    loc3 = matr[0] * f + dg[0] * cross;
    loc4 = dg[0] * g + matr[0] * cross;

    J_A[0] = loc0 + loc3 * matr[0] + loc4 * dg[0];
    J_A[1] = loc3 * matr[1] + loc4 * dg[1];
    J_A[2] = loc3 * matr[2] + loc4 * dg[2];
    J_B[0] = loc3 * matr[3] + loc4 * dg[3];
    J_B[1] = loc3 * matr[4] + loc4 * dg[4];
    J_B[2] = loc3 * matr[5] + loc4 * dg[5];
    J_C[0] = loc3 * matr[6] + loc4 * dg[6];
    J_C[1] = loc3 * matr[7] + loc4 * dg[7];
    J_C[2] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[1] * f + dg[1] * cross;
    loc4 = dg[1] * g + matr[1] * cross;

    J_A[3] = loc0 + loc3 * matr[1] + loc4 * dg[1];
    J_A[4] = loc3 * matr[2] + loc4 * dg[2];
    J_B[3] = loc3 * matr[3] + loc4 * dg[3];
    J_B[4] = loc3 * matr[4] + loc4 * dg[4];
    J_B[5] = loc3 * matr[5] + loc4 * dg[5];
    J_C[3] = loc3 * matr[6] + loc4 * dg[6];
    J_C[4] = loc3 * matr[7] + loc4 * dg[7];
    J_C[5] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[2] * f + dg[2] * cross;
    loc4 = dg[2] * g + matr[2] * cross;

    J_A[5] = loc0 + loc3 * matr[2] + loc4 * dg[2];
    J_B[6] = loc3 * matr[3] + loc4 * dg[3];
    J_B[7] = loc3 * matr[4] + loc4 * dg[4];
    J_B[8] = loc3 * matr[5] + loc4 * dg[5];
    J_C[6] = loc3 * matr[6] + loc4 * dg[6];
    J_C[7] = loc3 * matr[7] + loc4 * dg[7];
    J_C[8] = loc3 * matr[8] + loc4 * dg[8];

    /* First diagonal block */
    J_A[0] *= scale[0];
    J_A[1] *= scale[1];
    J_A[2] *= scale[2];
    J_A[3] *= scale[3];
    J_A[4] *= scale[4];
    J_A[5] *= scale[5];

    A[0] = -J_A[0] - J_A[1] - J_A[2];
    A[1] = -J_A[1] - J_A[3] - J_A[4];
    A[2] = -J_A[2] - J_A[4] - J_A[5];

    h_obj[0][0][0] = -A[0] - A[1] - A[2];
    h_obj[1][0][0] = A[0];
    h_obj[2][0][0] = A[1];
    h_obj[3][0][0] = A[2];

    h_obj[4][0][0] = J_A[0];
    h_obj[5][0][0] = J_A[1];
    h_obj[6][0][0] = J_A[2];

    h_obj[7][0][0] = J_A[3];
    h_obj[8][0][0] = J_A[4];

    h_obj[9][0][0] = J_A[5];

    /* First off-diagonal block */
    loc2 = matr[8] * loc1;
    J_B[1] += loc2;
    J_B[3] -= loc2;

    loc2 = matr[7] * loc1;
    J_B[2] -= loc2;
    J_B[6] += loc2;

    loc2 = matr[6] * loc1;
    J_B[5] += loc2;
    J_B[7] -= loc2;

    J_B[0] *= scale[0];
    J_B[1] *= scale[1];
    J_B[2] *= scale[2];
    J_B[3] *= scale[1];
    J_B[4] *= scale[3];
    J_B[5] *= scale[4];
    J_B[6] *= scale[2];
    J_B[7] *= scale[4];
    J_B[8] *= scale[5];

    A[0] = -J_B[0] - J_B[3] - J_B[6];
    A[1] = -J_B[1] - J_B[4] - J_B[7];
    A[2] = -J_B[2] - J_B[5] - J_B[8];

    h_obj[0][0][1] = -A[0] - A[1] - A[2];
    h_obj[1][0][1] = A[0];
    h_obj[2][0][1] = A[1];
    h_obj[3][0][1] = A[2];

    h_obj[1][1][0] = -J_B[0] - J_B[1] - J_B[2];
    h_obj[4][0][1] = J_B[0];
    h_obj[5][0][1] = J_B[1];
    h_obj[6][0][1] = J_B[2];

    h_obj[2][1][0] = -J_B[3] - J_B[4] - J_B[5];
    h_obj[5][1][0] = J_B[3];
    h_obj[7][0][1] = J_B[4];
    h_obj[8][0][1] = J_B[5];

    h_obj[3][1][0] = -J_B[6] - J_B[7] - J_B[8];
    h_obj[6][1][0] = J_B[6];
    h_obj[8][1][0] = J_B[7];
    h_obj[9][0][1] = J_B[8];

    /* Second off-diagonal block */
    loc2 = matr[5] * loc1;
    J_C[1] -= loc2;
    J_C[3] += loc2;

    loc2 = matr[4] * loc1;
    J_C[2] += loc2;
    J_C[6] -= loc2;

    loc2 = matr[3] * loc1;
    J_C[5] -= loc2;
    J_C[7] += loc2;

    J_C[0] *= scale[0];
    J_C[1] *= scale[1];
    J_C[2] *= scale[2];
    J_C[3] *= scale[1];
    J_C[4] *= scale[3];
    J_C[5] *= scale[4];
    J_C[6] *= scale[2];
    J_C[7] *= scale[4];
    J_C[8] *= scale[5];

    A[0] = -J_C[0] - J_C[3] - J_C[6];
    A[1] = -J_C[1] - J_C[4] - J_C[7];
    A[2] = -J_C[2] - J_C[5] - J_C[8];

    h_obj[0][0][2] = -A[0] - A[1] - A[2];
    h_obj[1][0][2] = A[0];
    h_obj[2][0][2] = A[1];
    h_obj[3][0][2] = A[2];

    h_obj[1][2][0] = -J_C[0] - J_C[1] - J_C[2];
    h_obj[4][0][2] = J_C[0];
    h_obj[5][0][2] = J_C[1];
    h_obj[6][0][2] = J_C[2];

    h_obj[2][2][0] = -J_C[3] - J_C[4] - J_C[5];
    h_obj[5][2][0] = J_C[3];
    h_obj[7][0][2] = J_C[4];
    h_obj[8][0][2] = J_C[5];

    h_obj[3][2][0] = -J_C[6] - J_C[7] - J_C[8];
    h_obj[6][2][0] = J_C[6];
    h_obj[8][2][0] = J_C[7];
    h_obj[9][0][2] = J_C[8];

    /* Second block of rows */
    loc3 = matr[3] * f + dg[3] * cross;
    loc4 = dg[3] * g + matr[3] * cross;

    J_A[0] = loc0 + loc3 * matr[3] + loc4 * dg[3];
    J_A[1] = loc3 * matr[4] + loc4 * dg[4];
    J_A[2] = loc3 * matr[5] + loc4 * dg[5];
    J_B[0] = loc3 * matr[6] + loc4 * dg[6];
    J_B[1] = loc3 * matr[7] + loc4 * dg[7];
    J_B[2] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[4] * f + dg[4] * cross;
    loc4 = dg[4] * g + matr[4] * cross;

    J_A[3] = loc0 + loc3 * matr[4] + loc4 * dg[4];
    J_A[4] = loc3 * matr[5] + loc4 * dg[5];
    J_B[3] = loc3 * matr[6] + loc4 * dg[6];
    J_B[4] = loc3 * matr[7] + loc4 * dg[7];
    J_B[5] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[5] * f + dg[5] * cross;
    loc4 = dg[5] * g + matr[5] * cross;

    J_A[5] = loc0 + loc3 * matr[5] + loc4 * dg[5];
    J_B[6] = loc3 * matr[6] + loc4 * dg[6];
    J_B[7] = loc3 * matr[7] + loc4 * dg[7];
    J_B[8] = loc3 * matr[8] + loc4 * dg[8];

    /* Second diagonal block */
    J_A[0] *= scale[0];
    J_A[1] *= scale[1];
    J_A[2] *= scale[2];
    J_A[3] *= scale[3];
    J_A[4] *= scale[4];
    J_A[5] *= scale[5];

    A[0] = -J_A[0] - J_A[1] - J_A[2];
    A[1] = -J_A[1] - J_A[3] - J_A[4];
    A[2] = -J_A[2] - J_A[4] - J_A[5];

    h_obj[0][1][1] = -A[0] - A[1] - A[2];
    h_obj[1][1][1] = A[0];
    h_obj[2][1][1] = A[1];
    h_obj[3][1][1] = A[2];

    h_obj[4][1][1] = J_A[0];
    h_obj[5][1][1] = J_A[1];
    h_obj[6][1][1] = J_A[2];

    h_obj[7][1][1] = J_A[3];
    h_obj[8][1][1] = J_A[4];

    h_obj[9][1][1] = J_A[5];

    /* Third off-diagonal block */
    loc2 = matr[2] * loc1;
    J_B[1] += loc2;
    J_B[3] -= loc2;

    loc2 = matr[1] * loc1;
    J_B[2] -= loc2;
    J_B[6] += loc2;

    loc2 = matr[0] * loc1;
    J_B[5] += loc2;
    J_B[7] -= loc2;

    J_B[0] *= scale[0];
    J_B[1] *= scale[1];
    J_B[2] *= scale[2];
    J_B[3] *= scale[1];
    J_B[4] *= scale[3];
    J_B[5] *= scale[4];
    J_B[6] *= scale[2];
    J_B[7] *= scale[4];
    J_B[8] *= scale[5];

    A[0] = -J_B[0] - J_B[3] - J_B[6];
    A[1] = -J_B[1] - J_B[4] - J_B[7];
    A[2] = -J_B[2] - J_B[5] - J_B[8];

    h_obj[0][1][2] = -A[0] - A[1] - A[2];
    h_obj[1][1][2] = A[0];
    h_obj[2][1][2] = A[1];
    h_obj[3][1][2] = A[2];

    h_obj[1][2][1] = -J_B[0] - J_B[1] - J_B[2];
    h_obj[4][1][2] = J_B[0];
    h_obj[5][1][2] = J_B[1];
    h_obj[6][1][2] = J_B[2];

    h_obj[2][2][1] = -J_B[3] - J_B[4] - J_B[5];
    h_obj[5][2][1] = J_B[3];
    h_obj[7][1][2] = J_B[4];
    h_obj[8][1][2] = J_B[5];

    h_obj[3][2][1] = -J_B[6] - J_B[7] - J_B[8];
    h_obj[6][2][1] = J_B[6];
    h_obj[8][2][1] = J_B[7];
    h_obj[9][1][2] = J_B[8];

    /* Third block of rows */
    loc3 = matr[6] * f + dg[6] * cross;
    loc4 = dg[6] * g + matr[6] * cross;

    J_A[0] = loc0 + loc3 * matr[6] + loc4 * dg[6];
    J_A[1] = loc3 * matr[7] + loc4 * dg[7];
    J_A[2] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[7] * f + dg[7] * cross;
    loc4 = dg[7] * g + matr[7] * cross;

    J_A[3] = loc0 + loc3 * matr[7] + loc4 * dg[7];
    J_A[4] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[8] * f + dg[8] * cross;
    loc4 = dg[8] * g + matr[8] * cross;

    J_A[5] = loc0 + loc3 * matr[8] + loc4 * dg[8];

    /* Third diagonal block */
    J_A[0] *= scale[0];
    J_A[1] *= scale[1];
    J_A[2] *= scale[2];
    J_A[3] *= scale[3];
    J_A[4] *= scale[4];
    J_A[5] *= scale[5];

    A[0] = -J_A[0] - J_A[1] - J_A[2];
    A[1] = -J_A[1] - J_A[3] - J_A[4];
    A[2] = -J_A[2] - J_A[4] - J_A[5];

    h_obj[0][2][2] = -A[0] - A[1] - A[2];
    h_obj[1][2][2] = A[0];
    h_obj[2][2][2] = A[1];
    h_obj[3][2][2] = A[2];

    h_obj[4][2][2] = J_A[0];
    h_obj[5][2][2] = J_A[1];
    h_obj[6][2][2] = J_A[2];

    h_obj[7][2][2] = J_A[3];
    h_obj[8][2][2] = J_A[4];

    h_obj[9][2][2] = J_A[5];

    // completes diagonal blocks.
    h_obj[0].fill_lower_triangle();
    h_obj[4].fill_lower_triangle();
    h_obj[7].fill_lower_triangle();
    h_obj[9].fill_lower_triangle();
    return true;
}
bool MBMesquite::h_fcn_3p ( double &  obj,
Vector3D  g_obj[4],
Matrix3D  h_obj[10],
const Vector3D  x[4],
const double  a,
const Exponent &  b,
const Exponent &  c 
) [inline]

Definition at line 2516 of file MeanRatioFunctions.hpp.

References moab::cross(), MBMesquite::Matrix3D::fill_lower_triangle(), g_fcn_3p(), l, m_fcn_3p(), MSQ_MIN, MBMesquite::Exponent::raise(), and MBMesquite::Exponent::value().

Referenced by MBMesquite::IdealWeightMeanRatio::evaluate_with_Hessian(), MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_Hessian(), MBMesquite::IdealWeightMeanRatio::evaluate_with_Hessian_diagonal(), and MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_Hessian_diagonal().

{
    const double h  = 0.5; /* h = 1 / (2*height) */
    const double th = 1.0; /* h = 1 / (height)   */

    double matr[9], f;
    double adj_m[9], g;
    double dg[9], loc0, loc1, loc2, loc3, loc4;
    double A[12], J_A[6], J_B[9], J_C[9], cross;

    /* Calculate M = A*inv(W). */
    matr[0] = x[1][0] - x[0][0];
    matr[1] = x[2][0] - x[0][0];
    matr[2] = ( 2.0 * x[3][0] - x[1][0] - x[2][0] ) * h;

    matr[3] = x[1][1] - x[0][1];
    matr[4] = x[2][1] - x[0][1];
    matr[5] = ( 2.0 * x[3][1] - x[1][1] - x[2][1] ) * h;

    matr[6] = x[1][2] - x[0][2];
    matr[7] = x[2][2] - x[0][2];
    matr[8] = ( 2.0 * x[3][2] - x[1][2] - x[2][2] ) * h;

    /* Calculate det(M). */
    dg[0] = matr[4] * matr[8] - matr[5] * matr[7];
    dg[1] = matr[5] * matr[6] - matr[3] * matr[8];
    dg[2] = matr[3] * matr[7] - matr[4] * matr[6];
    g     = matr[0] * dg[0] + matr[1] * dg[1] + matr[2] * dg[2];
    if( g < MSQ_MIN )
    {
        obj = g;
        return false;
    }

    dg[3] = matr[2] * matr[7] - matr[1] * matr[8];
    dg[4] = matr[0] * matr[8] - matr[2] * matr[6];
    dg[5] = matr[1] * matr[6] - matr[0] * matr[7];
    dg[6] = matr[1] * matr[5] - matr[2] * matr[4];
    dg[7] = matr[2] * matr[3] - matr[0] * matr[5];
    dg[8] = matr[0] * matr[4] - matr[1] * matr[3];

    /* Calculate norm(M). */
    f = matr[0] * matr[0] + matr[1] * matr[1] + matr[2] * matr[2] + matr[3] * matr[3] + matr[4] * matr[4] +
        matr[5] * matr[5] + matr[6] * matr[6] + matr[7] * matr[7] + matr[8] * matr[8];

    loc3 = f;
    loc4 = g;

    /* Calculate objective function. */
    obj = a * b.raise( f ) * c.raise( g );

    /* Calculate the derivative of the objective function.    */
    f = b.value() * obj / f; /* Constant on nabla f      */
    g = c.value() * obj / g; /* Constant on nable g      */
    f *= 2.0;                /* Modification for nabla f */

    adj_m[0] = matr[0] * f + dg[0] * g;
    adj_m[1] = matr[1] * f + dg[1] * g;
    adj_m[2] = matr[2] * f + dg[2] * g;
    adj_m[3] = matr[3] * f + dg[3] * g;
    adj_m[4] = matr[4] * f + dg[4] * g;
    adj_m[5] = matr[5] * f + dg[5] * g;
    adj_m[6] = matr[6] * f + dg[6] * g;
    adj_m[7] = matr[7] * f + dg[7] * g;
    adj_m[8] = matr[8] * f + dg[8] * g;

    g_obj[0][0] = -adj_m[0] - adj_m[1];
    g_obj[1][0] = adj_m[0] - h * adj_m[2];
    g_obj[2][0] = adj_m[1] - h * adj_m[2];
    g_obj[3][0] = th * adj_m[2];

    g_obj[0][1] = -adj_m[3] - adj_m[4];
    g_obj[1][1] = adj_m[3] - h * adj_m[5];
    g_obj[2][1] = adj_m[4] - h * adj_m[5];
    g_obj[3][1] = th * adj_m[5];

    g_obj[0][2] = -adj_m[6] - adj_m[7];
    g_obj[1][2] = adj_m[6] - h * adj_m[8];
    g_obj[2][2] = adj_m[7] - h * adj_m[8];
    g_obj[3][2] = th * adj_m[8];

    /* Calculate the hessian of the objective.                   */
    loc0  = f;                            /* Constant on nabla^2 f       */
    loc1  = g;                            /* Constant on nabla^2 g       */
    cross = f * c.value() / loc4;         /* Constant on nabla g nabla f */
    f     = f * ( b.value() - 1 ) / loc3; /* Constant on nabla f nabla f */
    g     = g * ( c.value() - 1 ) / loc4; /* Constant on nabla g nabla g */
    f *= 2.0;                             /* Modification for nabla f    */

    /* First block of rows */
    loc3 = matr[0] * f + dg[0] * cross;
    loc4 = dg[0] * g + matr[0] * cross;

    J_A[0] = loc0 + loc3 * matr[0] + loc4 * dg[0];
    J_A[1] = loc3 * matr[1] + loc4 * dg[1];
    J_A[2] = loc3 * matr[2] + loc4 * dg[2];
    J_B[0] = loc3 * matr[3] + loc4 * dg[3];
    J_B[1] = loc3 * matr[4] + loc4 * dg[4];
    J_B[2] = loc3 * matr[5] + loc4 * dg[5];
    J_C[0] = loc3 * matr[6] + loc4 * dg[6];
    J_C[1] = loc3 * matr[7] + loc4 * dg[7];
    J_C[2] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[1] * f + dg[1] * cross;
    loc4 = dg[1] * g + matr[1] * cross;

    J_A[3] = loc0 + loc3 * matr[1] + loc4 * dg[1];
    J_A[4] = loc3 * matr[2] + loc4 * dg[2];
    J_B[3] = loc3 * matr[3] + loc4 * dg[3];
    J_B[4] = loc3 * matr[4] + loc4 * dg[4];
    J_B[5] = loc3 * matr[5] + loc4 * dg[5];
    J_C[3] = loc3 * matr[6] + loc4 * dg[6];
    J_C[4] = loc3 * matr[7] + loc4 * dg[7];
    J_C[5] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[2] * f + dg[2] * cross;
    loc4 = dg[2] * g + matr[2] * cross;

    J_A[5] = loc0 + loc3 * matr[2] + loc4 * dg[2];
    J_B[6] = loc3 * matr[3] + loc4 * dg[3];
    J_B[7] = loc3 * matr[4] + loc4 * dg[4];
    J_B[8] = loc3 * matr[5] + loc4 * dg[5];
    J_C[6] = loc3 * matr[6] + loc4 * dg[6];
    J_C[7] = loc3 * matr[7] + loc4 * dg[7];
    J_C[8] = loc3 * matr[8] + loc4 * dg[8];

    /* First diagonal block */
    A[0] = -J_A[0] - J_A[1];
    A[1] = J_A[0] - h * J_A[2];
    A[2] = J_A[1] - h * J_A[2];
    A[3] = th * J_A[2];

    A[4] = -J_A[1] - J_A[3];
    A[5] = J_A[1] - h * J_A[4];
    A[6] = J_A[3] - h * J_A[4];
    A[7] = th * J_A[4];

    A[8]  = -J_A[2] - J_A[4];
    A[9]  = J_A[2] - h * J_A[5];
    A[10] = J_A[4] - h * J_A[5];
    A[11] = th * J_A[5];

    h_obj[0][0][0] = -A[0] - A[4];
    h_obj[1][0][0] = A[0] - h * A[8];
    h_obj[2][0][0] = A[4] - h * A[8];
    h_obj[3][0][0] = th * A[8];

    h_obj[4][0][0] = A[1] - h * A[9];
    h_obj[5][0][0] = A[5] - h * A[9];
    h_obj[6][0][0] = th * A[9];

    h_obj[7][0][0] = A[6] - h * A[10];
    h_obj[8][0][0] = th * A[10];

    h_obj[9][0][0] = th * A[11];

    /* First off-diagonal block */
    loc2 = matr[8] * loc1;
    J_B[1] += loc2;
    J_B[3] -= loc2;

    loc2 = matr[7] * loc1;
    J_B[2] -= loc2;
    J_B[6] += loc2;

    loc2 = matr[6] * loc1;
    J_B[5] += loc2;
    J_B[7] -= loc2;

    A[0] = -J_B[0] - J_B[1];
    A[1] = J_B[0] - h * J_B[2];
    A[2] = J_B[1] - h * J_B[2];
    A[3] = th * J_B[2];

    A[4] = -J_B[3] - J_B[4];
    A[5] = J_B[3] - h * J_B[5];
    A[6] = J_B[4] - h * J_B[5];
    A[7] = th * J_B[5];

    A[8]  = -J_B[6] - J_B[7];
    A[9]  = J_B[6] - h * J_B[8];
    A[10] = J_B[7] - h * J_B[8];
    A[11] = th * J_B[8];

    h_obj[0][0][1] = -A[0] - A[4];
    h_obj[1][1][0] = A[0] - h * A[8];
    h_obj[2][1][0] = A[4] - h * A[8];
    h_obj[3][1][0] = th * A[8];

    h_obj[1][0][1] = -A[1] - A[5];
    h_obj[4][0][1] = A[1] - h * A[9];
    h_obj[5][1][0] = A[5] - h * A[9];
    h_obj[6][1][0] = th * A[9];

    h_obj[2][0][1] = -A[2] - A[6];
    h_obj[5][0][1] = A[2] - h * A[10];
    h_obj[7][0][1] = A[6] - h * A[10];
    h_obj[8][1][0] = th * A[10];

    h_obj[3][0][1] = -A[3] - A[7];
    h_obj[6][0][1] = A[3] - h * A[11];
    h_obj[8][0][1] = A[7] - h * A[11];
    h_obj[9][0][1] = th * A[11];

    /* Second off-diagonal block */
    loc2 = matr[5] * loc1;
    J_C[1] -= loc2;
    J_C[3] += loc2;

    loc2 = matr[4] * loc1;
    J_C[2] += loc2;
    J_C[6] -= loc2;

    loc2 = matr[3] * loc1;
    J_C[5] -= loc2;
    J_C[7] += loc2;

    A[0] = -J_C[0] - J_C[1];
    A[1] = J_C[0] - h * J_C[2];
    A[2] = J_C[1] - h * J_C[2];
    A[3] = th * J_C[2];

    A[4] = -J_C[3] - J_C[4];
    A[5] = J_C[3] - h * J_C[5];
    A[6] = J_C[4] - h * J_C[5];
    A[7] = th * J_C[5];

    A[8]  = -J_C[6] - J_C[7];
    A[9]  = J_C[6] - h * J_C[8];
    A[10] = J_C[7] - h * J_C[8];
    A[11] = th * J_C[8];

    h_obj[0][0][2] = -A[0] - A[4];
    h_obj[1][2][0] = A[0] - h * A[8];
    h_obj[2][2][0] = A[4] - h * A[8];
    h_obj[3][2][0] = th * A[8];

    h_obj[1][0][2] = -A[1] - A[5];
    h_obj[4][0][2] = A[1] - h * A[9];
    h_obj[5][2][0] = A[5] - h * A[9];
    h_obj[6][2][0] = th * A[9];

    h_obj[2][0][2] = -A[2] - A[6];
    h_obj[5][0][2] = A[2] - h * A[10];
    h_obj[7][0][2] = A[6] - h * A[10];
    h_obj[8][2][0] = th * A[10];

    h_obj[3][0][2] = -A[3] - A[7];
    h_obj[6][0][2] = A[3] - h * A[11];
    h_obj[8][0][2] = A[7] - h * A[11];
    h_obj[9][0][2] = th * A[11];

    /* Second block of rows */
    loc3 = matr[3] * f + dg[3] * cross;
    loc4 = dg[3] * g + matr[3] * cross;

    J_A[0] = loc0 + loc3 * matr[3] + loc4 * dg[3];
    J_A[1] = loc3 * matr[4] + loc4 * dg[4];
    J_A[2] = loc3 * matr[5] + loc4 * dg[5];
    J_B[0] = loc3 * matr[6] + loc4 * dg[6];
    J_B[1] = loc3 * matr[7] + loc4 * dg[7];
    J_B[2] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[4] * f + dg[4] * cross;
    loc4 = dg[4] * g + matr[4] * cross;

    J_A[3] = loc0 + loc3 * matr[4] + loc4 * dg[4];
    J_A[4] = loc3 * matr[5] + loc4 * dg[5];
    J_B[3] = loc3 * matr[6] + loc4 * dg[6];
    J_B[4] = loc3 * matr[7] + loc4 * dg[7];
    J_B[5] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[5] * f + dg[5] * cross;
    loc4 = dg[5] * g + matr[5] * cross;

    J_A[5] = loc0 + loc3 * matr[5] + loc4 * dg[5];
    J_B[6] = loc3 * matr[6] + loc4 * dg[6];
    J_B[7] = loc3 * matr[7] + loc4 * dg[7];
    J_B[8] = loc3 * matr[8] + loc4 * dg[8];

    /* Second diagonal block */
    A[0] = -J_A[0] - J_A[1];
    A[1] = J_A[0] - h * J_A[2];
    A[2] = J_A[1] - h * J_A[2];
    A[3] = th * J_A[2];

    A[4] = -J_A[1] - J_A[3];
    A[5] = J_A[1] - h * J_A[4];
    A[6] = J_A[3] - h * J_A[4];
    A[7] = th * J_A[4];

    A[8]  = -J_A[2] - J_A[4];
    A[9]  = J_A[2] - h * J_A[5];
    A[10] = J_A[4] - h * J_A[5];
    A[11] = th * J_A[5];

    h_obj[0][1][1] = -A[0] - A[4];
    h_obj[1][1][1] = A[0] - h * A[8];
    h_obj[2][1][1] = A[4] - h * A[8];
    h_obj[3][1][1] = th * A[8];

    h_obj[4][1][1] = A[1] - h * A[9];
    h_obj[5][1][1] = A[5] - h * A[9];
    h_obj[6][1][1] = th * A[9];

    h_obj[7][1][1] = A[6] - h * A[10];
    h_obj[8][1][1] = th * A[10];

    h_obj[9][1][1] = th * A[11];

    /* Third off-diagonal block */
    loc2 = matr[2] * loc1;
    J_B[1] += loc2;
    J_B[3] -= loc2;

    loc2 = matr[1] * loc1;
    J_B[2] -= loc2;
    J_B[6] += loc2;

    loc2 = matr[0] * loc1;
    J_B[5] += loc2;
    J_B[7] -= loc2;

    A[0] = -J_B[0] - J_B[1];
    A[1] = J_B[0] - h * J_B[2];
    A[2] = J_B[1] - h * J_B[2];
    A[3] = th * J_B[2];

    A[4] = -J_B[3] - J_B[4];
    A[5] = J_B[3] - h * J_B[5];
    A[6] = J_B[4] - h * J_B[5];
    A[7] = th * J_B[5];

    A[8]  = -J_B[6] - J_B[7];
    A[9]  = J_B[6] - h * J_B[8];
    A[10] = J_B[7] - h * J_B[8];
    A[11] = th * J_B[8];

    h_obj[0][1][2] = -A[0] - A[4];
    h_obj[1][2][1] = A[0] - h * A[8];
    h_obj[2][2][1] = A[4] - h * A[8];
    h_obj[3][2][1] = th * A[8];

    h_obj[1][1][2] = -A[1] - A[5];
    h_obj[4][1][2] = A[1] - h * A[9];
    h_obj[5][2][1] = A[5] - h * A[9];
    h_obj[6][2][1] = th * A[9];

    h_obj[2][1][2] = -A[2] - A[6];
    h_obj[5][1][2] = A[2] - h * A[10];
    h_obj[7][1][2] = A[6] - h * A[10];
    h_obj[8][2][1] = th * A[10];

    h_obj[3][1][2] = -A[3] - A[7];
    h_obj[6][1][2] = A[3] - h * A[11];
    h_obj[8][1][2] = A[7] - h * A[11];
    h_obj[9][1][2] = th * A[11];

    /* Third block of rows */
    loc3 = matr[6] * f + dg[6] * cross;
    loc4 = dg[6] * g + matr[6] * cross;

    J_A[0] = loc0 + loc3 * matr[6] + loc4 * dg[6];
    J_A[1] = loc3 * matr[7] + loc4 * dg[7];
    J_A[2] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[7] * f + dg[7] * cross;
    loc4 = dg[7] * g + matr[7] * cross;

    J_A[3] = loc0 + loc3 * matr[7] + loc4 * dg[7];
    J_A[4] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[8] * f + dg[8] * cross;
    loc4 = dg[8] * g + matr[8] * cross;

    J_A[5] = loc0 + loc3 * matr[8] + loc4 * dg[8];

    /* Third diagonal block */
    A[0] = -J_A[0] - J_A[1];
    A[1] = J_A[0] - h * J_A[2];
    A[2] = J_A[1] - h * J_A[2];
    A[3] = th * J_A[2];

    A[4] = -J_A[1] - J_A[3];
    A[5] = J_A[1] - h * J_A[4];
    A[6] = J_A[3] - h * J_A[4];
    A[7] = th * J_A[4];

    A[8]  = -J_A[2] - J_A[4];
    A[9]  = J_A[2] - h * J_A[5];
    A[10] = J_A[4] - h * J_A[5];
    A[11] = th * J_A[5];

    h_obj[0][2][2] = -A[0] - A[4];
    h_obj[1][2][2] = A[0] - h * A[8];
    h_obj[2][2][2] = A[4] - h * A[8];
    h_obj[3][2][2] = th * A[8];

    h_obj[4][2][2] = A[1] - h * A[9];
    h_obj[5][2][2] = A[5] - h * A[9];
    h_obj[6][2][2] = th * A[9];

    h_obj[7][2][2] = A[6] - h * A[10];
    h_obj[8][2][2] = th * A[10];

    h_obj[9][2][2] = th * A[11];

#if 0
  int i, j, k, l;
  double   nobj;
  Vector3D nx[4];
  Vector3D ng_obj[4];

  for (i = 0; i < 4; ++i) {
    nx[i] = x[i];
    ng_obj[i] = 0.0;
  }

  m_fcn_3p(obj, x, a, b, c);
  for (i = 0; i < 4; ++i) {
    for (j = 0; j < 3; ++j) {
      nx[i][j] += 1e-6;
      m_fcn_3p(nobj, nx, a, b, c);
      nx[i][j] = x[i][j];

      ng_obj[i][j] = (nobj - obj) / 1e-6;
      std::cout << i << " " << j << " " << g_obj[i][j] << " " << ng_obj[i][j] << std::endl;
    }
  }
  std::cout << std::endl;

  for (i = 0; i < 4; ++i) {
    for (j = 0; j < 3; ++j) {
      nx[i][j] += 1e-6;
      g_fcn_3p(nobj, ng_obj, nx, a, b, c);
      nx[i][j] = x[i][j];

      printf("%d %d", i, j);
      for (k = 0; k < 4; ++k) {
    for (l = 0; l < 3; ++l) {
      printf(" % 5.4e", (ng_obj[k][l] - g_obj[k][l]) / 1e-6);
    }
      }
      printf("\n");
    }
  }

  for (i = 0; i < 10; ++i) {
    std::cout << i << std::endl << h_obj[i] << std::endl << std::endl;
  }
#endif

    // completes diagonal blocks.
    h_obj[0].fill_lower_triangle();
    h_obj[4].fill_lower_triangle();
    h_obj[7].fill_lower_triangle();
    h_obj[9].fill_lower_triangle();
    return true;
}
bool MBMesquite::h_fcn_3w ( double &  obj,
Vector3D  g_obj[4],
Matrix3D  h_obj[10],
const Vector3D  x[4],
const double  a,
const Exponent &  b,
const Exponent &  c 
) [inline]

Definition at line 3104 of file MeanRatioFunctions.hpp.

References moab::cross(), MBMesquite::Matrix3D::fill_lower_triangle(), isqrt3, MSQ_MIN, MBMesquite::Exponent::raise(), tisqrt3, and MBMesquite::Exponent::value().

Referenced by MBMesquite::IdealWeightMeanRatio::evaluate_with_Hessian(), MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_Hessian(), MBMesquite::IdealWeightMeanRatio::evaluate_with_Hessian_diagonal(), and MBMesquite::IdealWeightInverseMeanRatio::evaluate_with_Hessian_diagonal().

{
    double matr[9], f;
    double adj_m[9], g;
    double dg[9], loc0, loc1, loc2, loc3, loc4;
    double A[12], J_A[6], J_B[9], J_C[9], cross;

    /* Calculate M = A*inv(W). */
    matr[0] = x[1][0] - x[0][0];
    matr[1] = isqrt3 * ( 2 * x[2][0] - x[1][0] - x[0][0] );
    matr[2] = x[3][0] - x[0][0];

    matr[3] = x[1][1] - x[0][1];
    matr[4] = isqrt3 * ( 2 * x[2][1] - x[1][1] - x[0][1] );
    matr[5] = x[3][1] - x[0][1];

    matr[6] = x[1][2] - x[0][2];
    matr[7] = isqrt3 * ( 2 * x[2][2] - x[1][2] - x[0][2] );
    matr[8] = x[3][2] - x[0][2];

    /* Calculate det(M). */
    dg[0] = matr[4] * matr[8] - matr[5] * matr[7];
    dg[1] = matr[5] * matr[6] - matr[3] * matr[8];
    dg[2] = matr[3] * matr[7] - matr[4] * matr[6];
    g     = matr[0] * dg[0] + matr[1] * dg[1] + matr[2] * dg[2];
    if( g < MSQ_MIN )
    {
        obj = g;
        return false;
    }

    dg[3] = matr[2] * matr[7] - matr[1] * matr[8];
    dg[4] = matr[0] * matr[8] - matr[2] * matr[6];
    dg[5] = matr[1] * matr[6] - matr[0] * matr[7];
    dg[6] = matr[1] * matr[5] - matr[2] * matr[4];
    dg[7] = matr[2] * matr[3] - matr[0] * matr[5];
    dg[8] = matr[0] * matr[4] - matr[1] * matr[3];

    /* Calculate norm(M). */
    f = matr[0] * matr[0] + matr[1] * matr[1] + matr[2] * matr[2] + matr[3] * matr[3] + matr[4] * matr[4] +
        matr[5] * matr[5] + matr[6] * matr[6] + matr[7] * matr[7] + matr[8] * matr[8];

    loc3 = f;
    loc4 = g;

    /* Calculate objective function. */
    obj = a * b.raise( f ) * c.raise( g );

    /* Calculate the derivative of the objective function.    */
    f = b.value() * obj / f; /* Constant on nabla f      */
    g = c.value() * obj / g; /* Constant on nable g      */
    f *= 2.0;                /* Modification for nabla f */

    adj_m[0] = matr[0] * f + dg[0] * g;
    adj_m[1] = matr[1] * f + dg[1] * g;
    adj_m[2] = matr[2] * f + dg[2] * g;
    adj_m[3] = matr[3] * f + dg[3] * g;
    adj_m[4] = matr[4] * f + dg[4] * g;
    adj_m[5] = matr[5] * f + dg[5] * g;
    adj_m[6] = matr[6] * f + dg[6] * g;
    adj_m[7] = matr[7] * f + dg[7] * g;
    adj_m[8] = matr[8] * f + dg[8] * g;

    g_obj[0][0] = -adj_m[0] - isqrt3 * adj_m[1] - adj_m[2];
    g_obj[1][0] = adj_m[0] - isqrt3 * adj_m[1];
    g_obj[2][0] = tisqrt3 * adj_m[1];
    g_obj[3][0] = adj_m[2];

    g_obj[0][1] = -adj_m[3] - isqrt3 * adj_m[4] - adj_m[5];
    g_obj[1][1] = adj_m[3] - isqrt3 * adj_m[4];
    g_obj[2][1] = tisqrt3 * adj_m[4];
    g_obj[3][1] = adj_m[5];

    g_obj[0][2] = -adj_m[6] - isqrt3 * adj_m[7] - adj_m[8];
    g_obj[1][2] = adj_m[6] - isqrt3 * adj_m[7];
    g_obj[2][2] = tisqrt3 * adj_m[7];
    g_obj[3][2] = adj_m[8];

    /* Calculate the hessian of the objective.                   */
    loc0  = f;                            /* Constant on nabla^2 f       */
    loc1  = g;                            /* Constant on nabla^2 g       */
    cross = f * c.value() / loc4;         /* Constant on nabla g nabla f */
    f     = f * ( b.value() - 1 ) / loc3; /* Constant on nabla f nabla f */
    g     = g * ( c.value() - 1 ) / loc4; /* Constant on nabla g nabla g */
    f *= 2.0;                             /* Modification for nabla f    */

    /* First block of rows */
    loc3 = matr[0] * f + dg[0] * cross;
    loc4 = dg[0] * g + matr[0] * cross;

    J_A[0] = loc0 + loc3 * matr[0] + loc4 * dg[0];
    J_A[1] = loc3 * matr[1] + loc4 * dg[1];
    J_A[2] = loc3 * matr[2] + loc4 * dg[2];
    J_B[0] = loc3 * matr[3] + loc4 * dg[3];
    J_B[1] = loc3 * matr[4] + loc4 * dg[4];
    J_B[2] = loc3 * matr[5] + loc4 * dg[5];
    J_C[0] = loc3 * matr[6] + loc4 * dg[6];
    J_C[1] = loc3 * matr[7] + loc4 * dg[7];
    J_C[2] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[1] * f + dg[1] * cross;
    loc4 = dg[1] * g + matr[1] * cross;

    J_A[3] = loc0 + loc3 * matr[1] + loc4 * dg[1];
    J_A[4] = loc3 * matr[2] + loc4 * dg[2];
    J_B[3] = loc3 * matr[3] + loc4 * dg[3];
    J_B[4] = loc3 * matr[4] + loc4 * dg[4];
    J_B[5] = loc3 * matr[5] + loc4 * dg[5];
    J_C[3] = loc3 * matr[6] + loc4 * dg[6];
    J_C[4] = loc3 * matr[7] + loc4 * dg[7];
    J_C[5] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[2] * f + dg[2] * cross;
    loc4 = dg[2] * g + matr[2] * cross;

    J_A[5] = loc0 + loc3 * matr[2] + loc4 * dg[2];
    J_B[6] = loc3 * matr[3] + loc4 * dg[3];
    J_B[7] = loc3 * matr[4] + loc4 * dg[4];
    J_B[8] = loc3 * matr[5] + loc4 * dg[5];
    J_C[6] = loc3 * matr[6] + loc4 * dg[6];
    J_C[7] = loc3 * matr[7] + loc4 * dg[7];
    J_C[8] = loc3 * matr[8] + loc4 * dg[8];

    /* First diagonal block */
    A[0] = -J_A[0] - isqrt3 * J_A[1] - J_A[2];
    A[1] = J_A[0] - isqrt3 * J_A[1];
    // A[2]  =          tisqrt3*J_A[1];
    // A[3]  =                           J_A[2];

    A[4] = -J_A[1] - isqrt3 * J_A[3] - J_A[4];
    A[5] = J_A[1] - isqrt3 * J_A[3];
    A[6] = tisqrt3 * J_A[3];
    // A[7]  =                           J_A[4];

    A[8]  = -J_A[2] - isqrt3 * J_A[4] - J_A[5];
    A[9]  = J_A[2] - isqrt3 * J_A[4];
    A[10] = tisqrt3 * J_A[4];
    A[11] = J_A[5];

    h_obj[0][0][0] = -A[0] - isqrt3 * A[4] - A[8];
    h_obj[1][0][0] = A[0] - isqrt3 * A[4];
    h_obj[2][0][0] = tisqrt3 * A[4];
    h_obj[3][0][0] = A[8];

    h_obj[4][0][0] = A[1] - isqrt3 * A[5];
    h_obj[5][0][0] = tisqrt3 * A[5];
    h_obj[6][0][0] = A[9];

    h_obj[7][0][0] = tisqrt3 * A[6];
    h_obj[8][0][0] = A[10];

    h_obj[9][0][0] = A[11];

    /* First off-diagonal block */
    loc2 = matr[8] * loc1;
    J_B[1] += loc2;
    J_B[3] -= loc2;

    loc2 = matr[7] * loc1;
    J_B[2] -= loc2;
    J_B[6] += loc2;

    loc2 = matr[6] * loc1;
    J_B[5] += loc2;
    J_B[7] -= loc2;

    A[0] = -J_B[0] - isqrt3 * J_B[1] - J_B[2];
    A[1] = J_B[0] - isqrt3 * J_B[1];
    A[2] = tisqrt3 * J_B[1];
    A[3] = J_B[2];

    A[4] = -J_B[3] - isqrt3 * J_B[4] - J_B[5];
    A[5] = J_B[3] - isqrt3 * J_B[4];
    A[6] = tisqrt3 * J_B[4];
    A[7] = J_B[5];

    A[8]  = -J_B[6] - isqrt3 * J_B[7] - J_B[8];
    A[9]  = J_B[6] - isqrt3 * J_B[7];
    A[10] = tisqrt3 * J_B[7];
    A[11] = J_B[8];

    h_obj[0][0][1] = -A[0] - isqrt3 * A[4] - A[8];
    h_obj[1][1][0] = A[0] - isqrt3 * A[4];
    h_obj[2][1][0] = tisqrt3 * A[4];
    h_obj[3][1][0] = A[8];

    h_obj[1][0][1] = -A[1] - isqrt3 * A[5] - A[9];
    h_obj[4][0][1] = A[1] - isqrt3 * A[5];
    h_obj[5][1][0] = tisqrt3 * A[5];
    h_obj[6][1][0] = A[9];

    h_obj[2][0][1] = -A[2] - isqrt3 * A[6] - A[10];
    h_obj[5][0][1] = A[2] - isqrt3 * A[6];
    h_obj[7][0][1] = tisqrt3 * A[6];
    h_obj[8][1][0] = A[10];

    h_obj[3][0][1] = -A[3] - isqrt3 * A[7] - A[11];
    h_obj[6][0][1] = A[3] - isqrt3 * A[7];
    h_obj[8][0][1] = tisqrt3 * A[7];
    h_obj[9][0][1] = A[11];

    /* Second off-diagonal block */
    loc2 = matr[5] * loc1;
    J_C[1] -= loc2;
    J_C[3] += loc2;

    loc2 = matr[4] * loc1;
    J_C[2] += loc2;
    J_C[6] -= loc2;

    loc2 = matr[3] * loc1;
    J_C[5] -= loc2;
    J_C[7] += loc2;

    A[0] = -J_C[0] - isqrt3 * J_C[1] - J_C[2];
    A[1] = J_C[0] - isqrt3 * J_C[1];
    A[2] = tisqrt3 * J_C[1];
    A[3] = J_C[2];

    A[4] = -J_C[3] - isqrt3 * J_C[4] - J_C[5];
    A[5] = J_C[3] - isqrt3 * J_C[4];
    A[6] = tisqrt3 * J_C[4];
    A[7] = J_C[5];

    A[8]  = -J_C[6] - isqrt3 * J_C[7] - J_C[8];
    A[9]  = J_C[6] - isqrt3 * J_C[7];
    A[10] = tisqrt3 * J_C[7];
    A[11] = J_C[8];

    h_obj[0][0][2] = -A[0] - isqrt3 * A[4] - A[8];
    h_obj[1][2][0] = A[0] - isqrt3 * A[4];
    h_obj[2][2][0] = tisqrt3 * A[4];
    h_obj[3][2][0] = A[8];

    h_obj[1][0][2] = -A[1] - isqrt3 * A[5] - A[9];
    h_obj[4][0][2] = A[1] - isqrt3 * A[5];
    h_obj[5][2][0] = tisqrt3 * A[5];
    h_obj[6][2][0] = A[9];

    h_obj[2][0][2] = -A[2] - isqrt3 * A[6] - A[10];
    h_obj[5][0][2] = A[2] - isqrt3 * A[6];
    h_obj[7][0][2] = tisqrt3 * A[6];
    h_obj[8][2][0] = A[10];

    h_obj[3][0][2] = -A[3] - isqrt3 * A[7] - A[11];
    h_obj[6][0][2] = A[3] - isqrt3 * A[7];
    h_obj[8][0][2] = tisqrt3 * A[7];
    h_obj[9][0][2] = A[11];

    /* Second block of rows */
    loc3 = matr[3] * f + dg[3] * cross;
    loc4 = dg[3] * g + matr[3] * cross;

    J_A[0] = loc0 + loc3 * matr[3] + loc4 * dg[3];
    J_A[1] = loc3 * matr[4] + loc4 * dg[4];
    J_A[2] = loc3 * matr[5] + loc4 * dg[5];
    J_B[0] = loc3 * matr[6] + loc4 * dg[6];
    J_B[1] = loc3 * matr[7] + loc4 * dg[7];
    J_B[2] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[4] * f + dg[4] * cross;
    loc4 = dg[4] * g + matr[4] * cross;

    J_A[3] = loc0 + loc3 * matr[4] + loc4 * dg[4];
    J_A[4] = loc3 * matr[5] + loc4 * dg[5];
    J_B[3] = loc3 * matr[6] + loc4 * dg[6];
    J_B[4] = loc3 * matr[7] + loc4 * dg[7];
    J_B[5] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[5] * f + dg[5] * cross;
    loc4 = dg[5] * g + matr[5] * cross;

    J_A[5] = loc0 + loc3 * matr[5] + loc4 * dg[5];
    J_B[6] = loc3 * matr[6] + loc4 * dg[6];
    J_B[7] = loc3 * matr[7] + loc4 * dg[7];
    J_B[8] = loc3 * matr[8] + loc4 * dg[8];

    /* Second diagonal block */
    A[0] = -J_A[0] - isqrt3 * J_A[1] - J_A[2];
    A[1] = J_A[0] - isqrt3 * J_A[1];
    // A[2]  =          tisqrt3*J_A[1];
    // A[3]  =                           J_A[2];

    A[4] = -J_A[1] - isqrt3 * J_A[3] - J_A[4];
    A[5] = J_A[1] - isqrt3 * J_A[3];
    A[6] = tisqrt3 * J_A[3];
    // A[7]  =                           J_A[4];

    A[8]  = -J_A[2] - isqrt3 * J_A[4] - J_A[5];
    A[9]  = J_A[2] - isqrt3 * J_A[4];
    A[10] = tisqrt3 * J_A[4];
    A[11] = J_A[5];

    h_obj[0][1][1] = -A[0] - isqrt3 * A[4] - A[8];
    h_obj[1][1][1] = A[0] - isqrt3 * A[4];
    h_obj[2][1][1] = tisqrt3 * A[4];
    h_obj[3][1][1] = A[8];

    h_obj[4][1][1] = A[1] - isqrt3 * A[5];
    h_obj[5][1][1] = tisqrt3 * A[5];
    h_obj[6][1][1] = A[9];

    h_obj[7][1][1] = tisqrt3 * A[6];
    h_obj[8][1][1] = A[10];

    h_obj[9][1][1] = A[11];

    /* Third off-diagonal block */
    loc2 = matr[2] * loc1;
    J_B[1] += loc2;
    J_B[3] -= loc2;

    loc2 = matr[1] * loc1;
    J_B[2] -= loc2;
    J_B[6] += loc2;

    loc2 = matr[0] * loc1;
    J_B[5] += loc2;
    J_B[7] -= loc2;

    A[0] = -J_B[0] - isqrt3 * J_B[1] - J_B[2];
    A[1] = J_B[0] - isqrt3 * J_B[1];
    A[2] = tisqrt3 * J_B[1];
    A[3] = J_B[2];

    A[4] = -J_B[3] - isqrt3 * J_B[4] - J_B[5];
    A[5] = J_B[3] - isqrt3 * J_B[4];
    A[6] = tisqrt3 * J_B[4];
    A[7] = J_B[5];

    A[8]  = -J_B[6] - isqrt3 * J_B[7] - J_B[8];
    A[9]  = J_B[6] - isqrt3 * J_B[7];
    A[10] = tisqrt3 * J_B[7];
    A[11] = J_B[8];

    h_obj[0][1][2] = -A[0] - isqrt3 * A[4] - A[8];
    h_obj[1][2][1] = A[0] - isqrt3 * A[4];
    h_obj[2][2][1] = tisqrt3 * A[4];
    h_obj[3][2][1] = A[8];

    h_obj[1][1][2] = -A[1] - isqrt3 * A[5] - A[9];
    h_obj[4][1][2] = A[1] - isqrt3 * A[5];
    h_obj[5][2][1] = tisqrt3 * A[5];
    h_obj[6][2][1] = A[9];

    h_obj[2][1][2] = -A[2] - isqrt3 * A[6] - A[10];
    h_obj[5][1][2] = A[2] - isqrt3 * A[6];
    h_obj[7][1][2] = tisqrt3 * A[6];
    h_obj[8][2][1] = A[10];

    h_obj[3][1][2] = -A[3] - isqrt3 * A[7] - A[11];
    h_obj[6][1][2] = A[3] - isqrt3 * A[7];
    h_obj[8][1][2] = tisqrt3 * A[7];
    h_obj[9][1][2] = A[11];

    /* Third block of rows */
    loc3 = matr[6] * f + dg[6] * cross;
    loc4 = dg[6] * g + matr[6] * cross;

    J_A[0] = loc0 + loc3 * matr[6] + loc4 * dg[6];
    J_A[1] = loc3 * matr[7] + loc4 * dg[7];
    J_A[2] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[7] * f + dg[7] * cross;
    loc4 = dg[7] * g + matr[7] * cross;

    J_A[3] = loc0 + loc3 * matr[7] + loc4 * dg[7];
    J_A[4] = loc3 * matr[8] + loc4 * dg[8];

    loc3 = matr[8] * f + dg[8] * cross;
    loc4 = dg[8] * g + matr[8] * cross;

    J_A[5] = loc0 + loc3 * matr[8] + loc4 * dg[8];

    /* Third diagonal block */
    A[0] = -J_A[0] - isqrt3 * J_A[1] - J_A[2];
    A[1] = J_A[0] - isqrt3 * J_A[1];
    // A[2]  =          tisqrt3*J_A[1];
    // A[3]  =                           J_A[2];

    A[4] = -J_A[1] - isqrt3 * J_A[3] - J_A[4];
    A[5] = J_A[1] - isqrt3 * J_A[3];
    A[6] = tisqrt3 * J_A[3];
    // A[7]  =                           J_A[4];

    A[8]  = -J_A[2] - isqrt3 * J_A[4] - J_A[5];
    A[9]  = J_A[2] - isqrt3 * J_A[4];
    A[10] = tisqrt3 * J_A[4];
    A[11] = J_A[5];

    h_obj[0][2][2] = -A[0] - isqrt3 * A[4] - A[8];
    h_obj[1][2][2] = A[0] - isqrt3 * A[4];
    h_obj[2][2][2] = tisqrt3 * A[4];
    h_obj[3][2][2] = A[8];

    h_obj[4][2][2] = A[1] - isqrt3 * A[5];
    h_obj[5][2][2] = tisqrt3 * A[5];
    h_obj[6][2][2] = A[9];

    h_obj[7][2][2] = tisqrt3 * A[6];
    h_obj[8][2][2] = A[10];

    h_obj[9][2][2] = A[11];

    // completes diagonal blocks.
    h_obj[0].fill_lower_triangle();
    h_obj[4].fill_lower_triangle();
    h_obj[7].fill_lower_triangle();
    h_obj[9].fill_lower_triangle();

    return true;
}
static int MBMesquite::hash6432shift ( unsigned long long  key) [static]

Definition at line 162 of file ParallelHelper.cpp.

Referenced by generate_random_number().

{
    key = ( ~key ) + ( key << 18 );  // key = (key << 18) - key - 1;
    key = key ^ ( key >> 31 );
    key = key * 21;  // key = (key + (key << 2)) + (key << 4);
    key = key ^ ( key >> 11 );
    key = key + ( key << 6 );
    key = key ^ ( key >> 22 );
    return (int)key;
}
static unsigned long long MBMesquite::hash64shift ( unsigned long long  key) [static]

Definition at line 173 of file ParallelHelper.cpp.

Referenced by generate_random_number().

{
    key = ( ~key ) + ( key << 21 );  // key = (key << 21) - key - 1;
    key = key ^ ( key >> 24 );
    key = ( key + ( key << 3 ) ) + ( key << 8 );  // key * 265
    key = key ^ ( key >> 14 );
    key = ( key + ( key << 2 ) ) + ( key << 4 );  // key * 21
    key = key ^ ( key >> 28 );
    key = key + ( key << 31 );
    return key;
}
template<unsigned DIM>
static bool MBMesquite::hess ( const MsqMatrix< DIM, DIM > &  T,
double &  result,
MsqMatrix< DIM, DIM > &  deriv_wrt_T,
MsqMatrix< DIM, DIM > *  second_wrt_T 
) [inline, static]
template<unsigned DIM>
static bool MBMesquite::hess ( const MsqMatrix< DIM, DIM > &  A,
const MsqMatrix< DIM, DIM > &  W,
double &  result,
MsqMatrix< DIM, DIM > &  deriv,
MsqMatrix< DIM, DIM > *  second 
) [inline, static]

Definition at line 66 of file AWShapeSizeOrientNB1.cpp.

References set_scaled_I(), and sqr_Frobenius().

{
    deriv  = A - W;
    result = sqr_Frobenius( deriv );
    deriv *= 2.0;
    set_scaled_I( second, 2.0 );
    return true;
}
void MBMesquite::hess_scale ( MsqMatrix< 3, 3 >  R[6],
double  alpha 
) [inline]

Definition at line 50 of file TMPDerivs.hpp.

References moab::R.

Referenced by MBMesquite::TShapeSize3DB2::evaluate_with_hess(), MBMesquite::TPower2::hess(), and MBMesquite::TUntangleMu::hess().

{
    hess_scale_t< 3 >( R, alpha );
}
void MBMesquite::hess_scale ( MsqMatrix< 2, 2 >  R[3],
double  alpha 
) [inline]

Definition at line 55 of file TMPDerivs.hpp.

References moab::R.

{
    hess_scale_t< 2 >( R, alpha );
}
template<unsigned D>
void MBMesquite::hess_scale_t ( MsqMatrix< D, D >  R[D *(D+1)/2],
double  alpha 
) [inline]

\( R *= s \)

template<int DIM, typename MAT >
void MBMesquite::hessian ( size_t  num_free_verts,
const MsqVector< DIM > *  dNdxi,
const MsqMatrix< DIM, DIM > *  d2mdA2,
MAT *  hess 
) [inline]

Calculate Hessian from derivatives of mapping function terms and derivatives of target metric.

Definition at line 91 of file TargetMetricUtil.hpp.

References transpose().

{
    MsqMatrix< 1, DIM > tmp[DIM][DIM];
    size_t h = 0;  // index of current Hessian block

    for( size_t i = 0; i < num_free_verts; ++i )
    {

        // Populate TMP with vector-matrix procucts common
        // to terms of this Hessian row.
        const MsqMatrix< 1, DIM >& gi = transpose( dNdxi[i] );
        switch( DIM )
        {
            case 3:
                tmp[0][2] = gi * d2mdA2[2];
                tmp[1][2] = gi * d2mdA2[4];
                tmp[2][0] = gi * transpose( d2mdA2[2] );
                tmp[2][1] = gi * transpose( d2mdA2[4] );
                tmp[2][2] = gi * d2mdA2[5];
            case 2:
                tmp[0][1] = gi * d2mdA2[1];
                tmp[1][0] = gi * transpose( d2mdA2[1] );
                tmp[1][1] = gi * d2mdA2[DIM];
            case 1:
                tmp[0][0] = gi * d2mdA2[0];
            case 0:
                break;
            default:
                assert( false );
        }

        // Calculate Hessian diagonal block
        MAT& H = hess[h++];
        switch( DIM )
        {
            case 3:
                H( 0, 2 ) = H( 2, 0 ) = tmp[0][2] * transpose( gi );
                H( 1, 2 ) = H( 2, 1 ) = tmp[1][2] * transpose( gi );
                H( 2, 2 )             = tmp[2][2] * transpose( gi );
            case 2:
                H( 0, 1 ) = H( 1, 0 ) = tmp[0][1] * transpose( gi );
                H( 1, 1 )             = tmp[1][1] * transpose( gi );
            case 1:
                H( 0, 0 ) = tmp[0][0] * transpose( gi );
            case 0:
                break;
            default:
                assert( false );
        }

        // Calculate remainder of Hessian row
        for( size_t j = i + 1; j < num_free_verts; ++j )
        {
            MAT& HH                       = hess[h++];
            const MsqMatrix< DIM, 1 >& gj = dNdxi[j];
            switch( DIM )
            {
                case 3:
                    HH( 0, 2 ) = tmp[0][2] * gj;
                    HH( 1, 2 ) = tmp[1][2] * gj;
                    HH( 2, 0 ) = tmp[2][0] * gj;
                    HH( 2, 1 ) = tmp[2][1] * gj;
                    HH( 2, 2 ) = tmp[2][2] * gj;
                case 2:
                    HH( 0, 1 ) = tmp[0][1] * gj;
                    HH( 1, 0 ) = tmp[1][0] * gj;
                    HH( 1, 1 ) = tmp[1][1] * gj;
                case 1:
                    HH( 0, 0 ) = tmp[0][0] * gj;
                case 0:
                    break;
                default:
                    assert( false );
            }
        }
    }
}
template<int DIM>
void MBMesquite::hessian_diagonal ( size_t  num_free_verts,
const MsqVector< DIM > *  dNdxi,
const MsqMatrix< DIM, DIM > *  d2mdA2,
SymMatrix3D *  diagonal 
) [inline]

Calculate Hessian from derivatives of mapping function terms and derivatives of target metric.

Definition at line 173 of file TargetMetricUtil.hpp.

References transpose().

{
    for( size_t i = 0; i < num_free_verts; ++i )
    {
        SymMatrix3D& H = diagonal[i];
        for( unsigned j = 0; j < ( ( DIM ) * ( DIM + 1 ) / 2 ); ++j )
            H[j] = transpose( dNdxi[i] ) * d2mdA2[j] * dNdxi[i];
    }
}
static bool MBMesquite::ideal_constant_skew_I_2D ( EntityTopology  element_type,
MsqMatrix< 2, 2 > &  q 
) [inline, static]

If, for the specified element type, the skew is constant for an ideal element and the aspect is identity everywhere within the element, pass back the constant skew/shape term and return true. Otherwise return false.

Definition at line 398 of file TargetCalculator.cpp.

References QUADRILATERAL, and TRIANGLE.

Referenced by MBMesquite::TargetCalculator::ideal_shape_2D(), and MBMesquite::TargetCalculator::ideal_skew_2D().

{
    switch( element_type )
    {
        case QUADRILATERAL:
            q = MsqMatrix< 2, 2 >( 1.0 );  // Identity
            return true;
        case TRIANGLE:
            // [ x, x/2 ]  x = pow(4/3, 0.25)
            // [ 0, y   ]  y = 1/x
            q( 0, 0 ) = 1.074569931823542;
            q( 0, 1 ) = 0.537284965911771;
            q( 1, 0 ) = 0.0;
            q( 1, 1 ) = 0.93060485910209956;
            return true;
        default:
            return false;
    }
}
static bool MBMesquite::ideal_constant_skew_I_3D ( EntityTopology  element_type,
MsqMatrix< 3, 3 > &  q 
) [inline, static]

If, for the specified element type, the skew is constant for an ideal element and the aspect is identity everywhere within the element, pass back the constant skew/shape term and return true. Otherwise return false.

Definition at line 357 of file TargetCalculator.cpp.

References HEXAHEDRON, PRISM, and TETRAHEDRON.

Referenced by MBMesquite::TargetCalculator::ideal_shape_3D(), and MBMesquite::TargetCalculator::ideal_skew_3D().

{
    switch( element_type )
    {
        case HEXAHEDRON:
            q = MsqMatrix< 3, 3 >( 1.0 );  // Identity
            return false;
        case TETRAHEDRON:
            // [ x,   x/2, x/2 ] x^6 = 2
            // [ 0,   y,   y/3 ] y^2 = 3/4 x^2
            // [ 0,   0,   z   ] z^2 = 2/3 x^2
            q( 0, 0 ) = 1.122462048309373;
            q( 0, 1 ) = q( 0, 2 ) = 0.56123102415468651;
            q( 1, 0 ) = q( 2, 0 ) = q( 2, 1 ) = 0.0;
            q( 1, 1 )                         = 0.97208064861983279;
            q( 1, 2 )                         = 0.32402688287327758;
            q( 2, 2 )                         = 0.91648642466573493;
            return true;
        case PRISM:
            //            [ 1   0   0 ]
            //  a^(-1/3)  [ 0   1  1/2]
            //            [ 0   0   a ]
            //
            // a = sqrt(3)/2
            //
            q( 0, 0 ) = q( 1, 1 ) = 1.0491150634216482;
            q( 0, 1 ) = q( 0, 2 ) = q( 1, 0 ) = 0.0;
            q( 1, 2 )                         = 0.52455753171082409;
            q( 2, 0 ) = q( 2, 1 ) = 0.0;
            q( 2, 2 )             = 0.90856029641606972;
            return true;
        default:
            return false;
    }
}
static void MBMesquite::init_hex_pyr ( Vector3D *  coords,
double  height 
) [static]

Definition at line 162 of file IdealElements.cpp.

Referenced by init_unit_edge(), and init_unit_elem().

{
    coords[0] = Vector3D( 0.5 * side, -0.5 * side, -0.25 * side );
    coords[1] = Vector3D( 0.5 * side, 0.5 * side, -0.25 * side );
    coords[2] = Vector3D( -0.5 * side, 0.5 * side, -0.25 * side );
    coords[3] = Vector3D( -0.5 * side, -0.5 * side, -0.25 * side );
    coords[4] = Vector3D( 0.0, 0.0, 0.75 * side );
}