Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
inks/ShapeImprovementWrapper.cpp
Go to the documentation of this file.
1  /* *****************************************************************
2  MESQUITE -- The Mesh Quality Improvement Toolkit
3 
4  Copyright 2004 Sandia Corporation and Argonne National
5  Laboratory. Under the terms of Contract DE-AC04-94AL85000
6  with Sandia Corporation, the U.S. Government retains certain
7  rights in this software.
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  (lgpl.txt) along with this library; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 
23  diachin2@llnl.gov, djmelan@sandia.gov, mbrewer@sandia.gov,
24  pknupp@sandia.gov, tleurent@mcs.anl.gov, tmunson@mcs.anl.gov
25 
26  ***************************************************************** */
27 // -*- Mode : c++; tab-width: 3; c-tab-always-indent: t; indent-tabs-mode: nil; c-basic-offset: 3 -*-
28 
37 #include "InstructionQueue.hpp"
38 #include "ShapeImprovementWrapper.hpp"
39 #include "MeshSet.hpp"
40 #include "MsqTimer.hpp"
41 #include "MsqDebug.hpp"
42 
43 namespace Mesquite {
44 
52  double cpu_time,
53  double grad_norm)
54  : inverseMeanRatio(0),
55  objFunc(0),
56  feasNewt(0),
57  mQA(0),
58  termOuter(0),
59  termInner(0)
60 {
61 
62  //arbitrarily chosen variables
63  untBeta=1.e-8;
64  successiveEps=1.e-4;
65 
66  inverseMeanRatio = new IdealWeightInverseMeanRatio(err); MSQ_ERRRTN(err);
70  // creates the l_2 squared objective function
71  objFunc = new LPtoPTemplate(inverseMeanRatio, 2, err); MSQ_ERRRTN(err);
73  //creates a FeasibleNewtone improver
74  feasNewt = new FeasibleNewton(objFunc);
76 
77  mQA = new QualityAssessor(inverseMeanRatio,QualityAssessor::MAXIMUM, err); MSQ_ERRRTN(err);
79  //**************Set stopping criterion*e***************
80  termInner = new TerminationCriterion();
81  termOuter = new TerminationCriterion();
82  //termInner->add_criterion_type_with_double(TerminationCriterion::GRADIENT_L2_NORM_ABSOLUTE,grad_norm,err); MSQ_ERRRTN(err);
83  //termInner->add_criterion_type_with_double(TerminationCriterion::SUCCESSIVE_IMPROVEMENTS_RELATIVE,successiveEps,err); MSQ_ERRRTN(err);
89 
90 }
91 
92 
94 {
95  delete inverseMeanRatio;
96  delete objFunc;
97  delete feasNewt;
98  delete mQA;
99  delete termInner;
100  delete termOuter;
101 }
102 
103 
111 void ShapeImprovementWrapper::run_instructions(MeshSet &ms, MsqError &err)
112 {
113 
114  mQA->loop_over_mesh(ms, err);
115  MSQ_ERRRTN(err);
116 
117  feasNewt->loop_over_mesh(ms, err);
118  MSQ_ERRRTN(err);
119 
120  mQA->loop_over_mesh(ms, err);
121  MSQ_ERRRTN(err);
122 
123 }
124 
125 } // namespace Mesquite
126 
127 
void set_averaging_method(AveragingMethod method, MsqError &err)
void set_gradient_type(GRADIENT_TYPE grad)
Set gradType to either NUMERICAL_GRADIENT or ANALYTICAL_GRADIENT.
void add_culling_method(enum PatchData::culling_method cm)
Sets on the culling method passed as argument.
virtual void set_patch_type(PatchData::PatchType patch_type, MsqError &err, int param1=0, int param2=0)
Sets the Patch Type.
virtual void run_instructions(MeshSet &ms, MsqError &err)
run_instructions runs the wrapper on the given MeshSet.
every differentiable function should have an analytical gradient implemented.
virtual double loop_over_mesh(MeshSet &ms, MsqError &err)
Does one sweep over the mesh and assess the quality with the metrics previously added.
void set_hessian_type(HESSIAN_TYPE ht)
Sets hessianType for this metric.
virtual double loop_over_mesh(MeshSet &ms, MsqError &err)
Improves the quality of the MeshSet, calling some methods specified in a class derived from VertexMov...
virtual ~ShapeImprovementWrapper()
Destructor must delete the objects inserted in the queue.
Terminates when the number of iterations exceeds a given integer.
void set_gradient_type(GRADIENT_TYPE grad)
Sets gradType for this metric.
void set_outer_termination_criterion(TerminationCriterion *crit)
Sets in the termination criterion for the outer loop over patches.
ShapeImprovementWrapper(MsqError &err, double cpu_time=0.0, double grad_norm=1.e-6)
void add_criterion_type_with_int(TCType tc_type, int bound, MsqError &err)
Sets the criterion by specifing the TCType and the integer value.
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.
void set_inner_termination_criterion(TerminationCriterion *crit)
Sets in the termination criterion for the concrete solver's optimization.
void disable_printing_results()
Do not print results of assessment.