41 #include "MeshSet.hpp"
42 #include "MsqVertex.hpp"
43 #include "MsqInterrupt.hpp"
44 #include "ObjectiveFunction.hpp"
45 #include "MsqError.hpp"
46 #include "MsqDebug.hpp"
64 initialVerticesMemento(0),
65 previousVerticesMemento(0),
292 mGrad.resize( num_vertices );
298 MSQ_SETERR(err)(
"Initial patch is invalid for gradient computation.",
326 MSQ_SETERR(err)(
"Error termination criteria set which uses objective "
327 "functions, but no objective function is available.",
342 if (totalFlag & (GRAD_FLAGS|OF_FLAGS))
385 MSQ_SETERR(err)(
"Initial patch is invalid for gradient compuation.",
394 MSQ_SETERR(err)(
"Invalid patch passed to TerminationCriterion.",
475 for(i=0;i<num_vert;++
i)
495 bool return_flag =
false;
596 <<
" vertices out of bounds." << msq_stdio::endl;
625 bool b, cull_bool=
false;
626 double prev_m, init_m;
686 MSQ_SETERR(err)(
"Requested culling method not yet implemented.",
double successiveImprovementsAbsoluteEps
void set_free_vertices_soft_fixed(MsqError &err)
Add a soft_fixed flag to all free vertices in the patch.
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
const unsigned long GRAD_FLAGS
static bool interrupt()
Check if an interrupt was seen.
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
double get_max_vertex_movement_squared(PatchDataVerticesMemento *memento, MsqError &err)
Calculates the distance each vertex has moved from its original position as defined by the PatchDataV...
Terminates when the decrease in the objective function value since the previous iteration is below th...
double gradL2NormAbsoluteEps
double gradL2NormRelativeEps
void set_patch_type(PatchData::PatchType patch_type, MsqError &err, int patch_param1=0, int patch_param2=0)
Tells the MeshSet what kind of data the patches should include.
void cleanup(MeshSet &ms, MsqError &err)
Cleans up after the TerminationCriterion is finished.
double qualityImprovementRelativeEps
void set_all_vertices_soft_free(MsqError &err)
Remove the soft_fixed flag from all vertices in the patch.
double successiveImprovementsRelativeEps
Terminates when any vertex leaves the bounding box, defined by the given value, d.
Used to hold the error state and return it to the application.
double boundedVertexMovementEps
void accumulate_patch(PatchData &pd, MsqError &err)
Common code for both inner and outer termination criteria during inner iteration. ...
double currentGradInfNorm
void recreate_vertices_memento(PatchDataVerticesMemento *memento, MsqError &err, bool include_higher_order=false)
reinstantiates a memento to holds the current state of the PatchData coordinates. ...
requested functionality is not (yet) implemented
bool evaluate(PatchData &patch, double &fval, MsqError &err)
Vector3D is the object that effeciently stores information about about three-deminsional vectors...
checks the gradient of objective function against a double and stops when
TerminationCriterion()
Constructor which does not take any arguements.
void reset_outer(MeshSet &ms, ObjectiveFunction *of, MsqError &err)
Clear any data accumulated during an outer iteration.
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
void reset_inner(PatchData &pd, ObjectiveFunction *of, MsqError &err)
Clear any data accumulated during an inner iteration.
bool terminate()
Check if termination criterion has been met.
terminates on the j_th iteration when That is, terminates when the norm of the gradient is small tha...
bool cull_vertices(PatchData &pd, ObjectiveFunction *obj_ptr, MsqError &err)
Function which determines whether this patch should be 'culled'.
void reset_patch(PatchData &pd, MsqError &err)
Shared inner and outer initialization during inner loop.
Terminates when the decrease in the objective function value since the previous iteration is below th...
PatchDataVerticesMemento * create_vertices_memento(MsqError &err, bool include_higher_order=false)
Creates a memento that holds the current state of the PatchData coordinates.
double length(Vector3D *const v, int n)
double since_birth() const
msq_std::vector< Vector3D > mGrad
const unsigned long OF_FLAGS
invalid function argument passed
double qualityImprovementAbsoluteEps
#define MSQ_CHKERR(err)
Mesquite's Error Checking macro.
double maxSquaredMovement
double gradInfNormAbsoluteEps
bool compute_gradient(PatchData &patch, Vector3D *const &grad, double &OF_val, MsqError &err, size_t array_size=0)
Calls either compute_numerical_gradient or compute_analytical_gradient depending on the value of grad...
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
Terminates when the objective function value is smaller than the given scalar value.
double maxSquaredInitialMovement
double initialGradInfNorm
Terminates when the algorithm exceeds an allotted time limit (given in seconds).
double vertexMovementRelativeEps
void set_culling_type(TCType tc_type, double eps, MsqError &err)
Sets the type of criterion that the user would like to use for culling purposes (along with the assoc...
void add_criterion_type_with_double(TCType tc_type, double eps, MsqError &err)
Sets the criterion by specifing the TCType and the eps value.
long unsigned int terminationCriterionFlag
Bit flag of termination crit.
PatchDataVerticesMemento * initialVerticesMemento
double Linf(Vector3D *const v, int n)
size_t num_vertices() const
number of vertices in the patch.
void accumulate_inner(PatchData &pd, MsqError &err)
Accumulate data during inner iteration.
const MsqVertex * get_vertex_array(MsqError &err) const
Returns a pointer to the start of the vertex array.
long unsigned int cullingMethodFlag
Terminates when the number of iterations exceeds a given integer.
double gradInfNormRelativeEps
int vertexMovementExceedsBound
void remove_criterion_type(TCType tc_type, MsqError &err)
Removes the criterion by specifing just the TCType.
void remove_culling(MsqError &err)
Removes any previously set culling types (sets the culling type to be NONE).
PatchDataVerticesMemento * previousVerticesMemento
double vertexMovementAbsoluteEps
object is in an invalid state
bool clear_all_soft_fixed_flags(MsqError &err)
void accumulate_outer(MeshSet &ms, MsqError &err)
Terminates when the objective function value is smaller than the given scalar value times the origina...
void add_criterion_type_with_int(TCType tc_type, int bound, MsqError &err)
Sets the criterion by specifing the TCType and the integer value.
terminates on the j_th iteration when
checks the gradient of objective function against a double and stops when
#define MSQ_DBGOUT(flag)
Check debug flag and return ostream associated with flag.
ObjectiveFunction * OFPtr
MsqVertex is the Mesquite object that stores information about the vertices in the mesh...
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.
Base class for concrete Objective Functions ObjectiveFunction contains a pointer to a QualityMetric...
The MeshSet class stores one or more Mesquite::Mesh pointers and manages access to the mesh informati...
bool get_next_patch(PatchData &pd, PatchDataUser *pd_user, MsqError &err)
Gets the next PatchData.