MOAB: Mesh Oriented datABase  (version 5.4.1)
SizeAdaptShapeWrapper.cpp
Go to the documentation of this file.
00001 /* *****************************************************************
00002     MESQUITE -- The Mesh Quality Improvement Toolkit
00003 
00004     Copyright 2009 Sandia National Laboratories.  Developed at the
00005     University of Wisconsin--Madison under SNL contract number
00006     624796.  The U.S. Government and the University of Wisconsin
00007     retain certain rights to this software.
00008 
00009     This library is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU Lesser General Public
00011     License as published by the Free Software Foundation; either
00012     version 2.1 of the License, or (at your option) any later version.
00013 
00014     This library is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017     Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public License
00020     (lgpl.txt) along with this library; if not, write to the Free Software
00021     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 
00023     (2009) [email protected]
00024 
00025   ***************************************************************** */
00026 
00027 /** \file SizeAdaptShapeWrapper.cpp
00028  *  \brief
00029  *  \author Jason Kraftcheck
00030  */
00031 
00032 #include "Mesquite.hpp"
00033 #include "SizeAdaptShapeWrapper.hpp"
00034 
00035 #include "TerminationCriterion.hpp"
00036 #include "InstructionQueue.hpp"
00037 #include "QualityAssessor.hpp"
00038 #include "MeshImpl.hpp"
00039 #include "PlanarDomain.hpp"
00040 
00041 #include "PMeanPTemplate.hpp"
00042 #include "ElementPMeanP.hpp"
00043 #include "TrustRegion.hpp"
00044 #include "TQualityMetric.hpp"
00045 #include "IdealShapeTarget.hpp"
00046 #include "TShapeSizeB1.hpp"
00047 #include "RefMeshTargetCalculator.hpp"
00048 #include "ReferenceMesh.hpp"
00049 #include "TagVertexMesh.hpp"
00050 #include "LambdaTarget.hpp"
00051 #include "EdgeLengthMetric.hpp"
00052 
00053 namespace MBMesquite
00054 {
00055 
00056 void SizeAdaptShapeWrapper::run_wrapper( MeshDomainAssoc* mesh_and_domain,
00057                                          ParallelMesh* pmesh,
00058                                          Settings* settings,
00059                                          QualityAssessor* qa,
00060                                          MsqError& err )
00061 {
00062     InstructionQueue q;
00063     Mesh* mesh = mesh_and_domain->get_mesh();
00064 
00065     // calculate average lambda for mesh
00066     TagVertexMesh init_mesh( err, mesh );MSQ_ERRRTN( err );
00067     ReferenceMesh ref_mesh( &init_mesh );
00068     RefMeshTargetCalculator W_0( &ref_mesh );
00069     q.add_tag_vertex_mesh( &init_mesh, err );MSQ_ERRRTN( err );
00070 
00071     // create objective function
00072     IdealShapeTarget W_i;
00073     LambdaTarget W( &W_0, &W_i );
00074     TShapeSizeB1 tm;
00075     TQualityMetric mu_0( &W, &tm );
00076     ElementPMeanP mu( 1.0, &mu_0 );
00077     PMeanPTemplate of( 1.0, &mu );
00078 
00079     // create quality assessor
00080     EdgeLengthMetric len( 0.0 );
00081     qa->add_quality_assessment( &mu );
00082     qa->add_quality_assessment( &len );
00083     q.add_quality_assessor( qa, err );
00084 
00085     // create solver
00086     TrustRegion solver( &of );
00087     TerminationCriterion tc, ptc;
00088     tc.add_absolute_vertex_movement( maxVtxMovement );
00089     tc.add_iteration_limit( iterationLimit );
00090     ptc.add_iteration_limit( pmesh ? parallelIterations : 1 );
00091     solver.set_inner_termination_criterion( &tc );
00092     solver.set_outer_termination_criterion( &ptc );
00093     q.set_master_quality_improver( &solver, err );MSQ_ERRRTN( err );
00094     q.add_quality_assessor( qa, err );
00095 
00096     // Optimize mesh
00097     q.run_common( mesh_and_domain, pmesh, settings, err );MSQ_CHKERR( err );
00098 }
00099 
00100 }  // namespace MBMesquite
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines