MOAB: Mesh Oriented datABase
(version 5.4.1)
|
#include "Mesquite.hpp"
#include "MsqMOAB.hpp"
#include "MeshImpl.hpp"
#include "MsqError.hpp"
#include "InstructionQueue.hpp"
#include "TerminationCriterion.hpp"
#include "QualityAssessor.hpp"
#include "PlanarDomain.hpp"
#include "MeshWriter.hpp"
#include "TestUtil.hpp"
#include "IdealWeightInverseMeanRatio.hpp"
#include "EdgeLengthQualityMetric.hpp"
#include "LPtoPTemplate.hpp"
#include "FeasibleNewton.hpp"
#include "ConjugateGradient.hpp"
#include "SmartLaplacianSmoother.hpp"
#include <iostream>
#include "iBase.h"
Go to the source code of this file.
Functions | |
void | usage () |
Mesh * | get_imesh_mesh (const char *file_name) |
Mesh * | get_native_mesh (const char *file_name) |
int | run_global_smoother (Mesh *mesh, MsqError &err) |
int | run_local_smoother (Mesh *mesh, MsqError &err) |
int | main (int argc, char *argv[]) |
Variables | |
std::string | default_file_name = "unittest/mesquite/3D/vtk/large_box_hex_1000.vtk" |
Mesh * get_imesh_mesh | ( | const char * | file_name | ) |
Definition at line 267 of file test/mesquite/imesh/main.cpp.
References ErrorCode, iBase_REGION, iBase_SUCCESS, ierr, iMesh_dtor, iMesh_getRootSet, iMesh_getTagHandle, iMesh_load, iMesh_newMesh, moab::Core::load_file(), mb, MB_CHK_SET_ERR_RET_VAL, MBHEX, MSQ_CHKERR, root_set, and moab::Core::tag_get_handle().
Referenced by main().
{ #ifdef USE_IMESH int ierr; iMesh_Instance imesh_mesh = 0; iMesh_newMesh( NULL, &imesh_mesh, &ierr, 0 ); if( iBase_SUCCESS != ierr ) { return 0; } iBase_EntitySetHandle root_set; iMesh_getRootSet( imesh_mesh, &root_set, &ierr ); if( iBase_SUCCESS != ierr ) { iMesh_dtor( imesh_mesh, &ierr ); return 0; } iMesh_load( imesh_mesh, root_set, file_name, 0, &ierr, strlen( file_name ), 0 ); if( iBase_SUCCESS != ierr ) { std::cerr << file_name << ": failed to load file." << std::endl; iMesh_dtor( imesh_mesh, &ierr ); return 0; } iBase_TagHandle fixed_tag; iMesh_getTagHandle( imesh_mesh, "fixed", &fixed_tag, &ierr, strlen( "fixed" ) ); if( iBase_SUCCESS != ierr ) { iMesh_dtor( imesh_mesh, &ierr ); return 0; } MsqError err; Mesh* result = new MBMesquite::MsqIMesh( imesh_mesh, root_set, iBase_REGION, err, &fixed_tag ); if( MSQ_CHKERR( err ) ) { delete result; cerr << err << endl; return 0; } #else moab::Core* mb = new( std::nothrow ) moab::Core; if( NULL == mb ) return 0; moab::ErrorCode rval; // This file is in the mesh files directory rval = mb->load_file( file_name );MB_CHK_SET_ERR_RET_VAL( rval, "Failed to read", 0 ); moab::Tag fixed_tag; rval = mb->tag_get_handle( "fixed", fixed_tag );MB_CHK_SET_ERR_RET_VAL( rval, "Failed to create fixed tag", 0 ); moab::EntityHandle root_set = 0; MsqError err; Mesh* result = new MBMesquite::MsqMOAB( mb, root_set, moab::MBHEX, err, &fixed_tag ); if( MSQ_CHKERR( err ) ) { delete result; cerr << err << endl; return 0; } #endif return result; }
Mesh * get_native_mesh | ( | const char * | file_name | ) |
Definition at line 338 of file test/mesquite/imesh/main.cpp.
References mesh, and MBMesquite::MeshImpl::read_vtk().
Referenced by main().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 103 of file test/mesquite/imesh/main.cpp.
References default_file_name, get_imesh_mesh(), get_native_mesh(), mesh, run_global_smoother(), run_local_smoother(), usage, and MBMesquite::MeshWriter::write_vtk().
{ MBMesquite::MsqPrintError err( cout ); // command line arguments const char* file_name = 0; bool use_native = false, opts_done = false; for( int arg = 1; arg < argc; ++arg ) { if( !opts_done && argv[arg][0] == '-' ) { if( !strcmp( argv[arg], "-N" ) ) use_native = true; else if( !strcmp( argv[arg], "--" ) ) opts_done = true; else usage(); } else if( !file_name ) file_name = argv[arg]; else usage(); } if( !file_name ) { file_name = default_file_name.c_str(); cout << "No file specified: using default: " << default_file_name << endl; } // Try running a global smoother on the mesh Mesh* mesh = use_native ? get_native_mesh( file_name ) : get_imesh_mesh( file_name ); if( !mesh ) { std::cerr << "Failed to load input file. Aborting." << std::endl; return 1; } MeshWriter::write_vtk( mesh, "original.vtk", err ); if( err ) return 1; cout << "Wrote \"original.vtk\"" << endl; run_global_smoother( mesh, err ); if( err ) return 1; // Try running a local smoother on the mesh mesh = use_native ? get_native_mesh( file_name ) : get_imesh_mesh( file_name ); if( !mesh ) { std::cerr << "Failed to load input file. Aborting." << std::endl; return 1; } run_local_smoother( mesh, err ); if( err ) return 1; return 0; }
int run_global_smoother | ( | Mesh * | mesh, |
MsqError & | err | ||
) |
Definition at line 160 of file test/mesquite/imesh/main.cpp.
References MBMesquite::TerminationCriterion::add_absolute_vertex_movement(), MBMesquite::TerminationCriterion::add_iteration_limit(), MBMesquite::InstructionQueue::add_quality_assessor(), MBMesquite::IQInterface::run_instructions(), MBMesquite::AveragingQM::set_averaging_method(), MBMesquite::QualityImprover::set_inner_termination_criterion(), MBMesquite::InstructionQueue::set_master_quality_improver(), MBMesquite::QualityImprover::set_outer_termination_criterion(), MBMesquite::QualityMetric::SUM, MBMesquite::PatchSetUser::use_global_patch(), and MBMesquite::MeshWriter::write_vtk().
Referenced by main().
{ double OF_value = 0.0001; // creates an intruction queue InstructionQueue queue1; // creates a mean ratio quality metric ... IdealWeightInverseMeanRatio* mean_ratio = new IdealWeightInverseMeanRatio( err ); if( err ) return 1; mean_ratio->set_averaging_method( QualityMetric::SUM, err ); if( err ) return 1; // ... and builds an objective function with it LPtoPTemplate* obj_func = new LPtoPTemplate( mean_ratio, 1, err ); if( err ) return 1; // creates the feas newt optimization procedures FeasibleNewton* pass1 = new FeasibleNewton( obj_func ); pass1->use_global_patch(); if( err ) return 1; QualityAssessor stop_qa( mean_ratio ); // **************Set stopping criterion**************** TerminationCriterion tc_inner; tc_inner.add_absolute_vertex_movement( OF_value ); if( err ) return 1; TerminationCriterion tc_outer; tc_outer.add_iteration_limit( 1 ); pass1->set_inner_termination_criterion( &tc_inner ); pass1->set_outer_termination_criterion( &tc_outer ); queue1.add_quality_assessor( &stop_qa, err ); if( err ) return 1; // adds 1 pass of pass1 to mesh_set1 queue1.set_master_quality_improver( pass1, err ); if( err ) return 1; queue1.add_quality_assessor( &stop_qa, err ); if( err ) return 1; // launches optimization on mesh_set queue1.run_instructions( mesh, err ); if( err ) return 1; MeshWriter::write_vtk( mesh, "feasible-newton-result.vtk", err ); if( err ) return 1; cout << "Wrote \"feasible-newton-result.vtk\"" << endl; // print_timing_diagnostics( cout ); return 0; }
int run_local_smoother | ( | Mesh * | mesh, |
MsqError & | err | ||
) |
Definition at line 215 of file test/mesquite/imesh/main.cpp.
References MBMesquite::TerminationCriterion::add_absolute_vertex_movement(), MBMesquite::TerminationCriterion::add_iteration_limit(), MBMesquite::InstructionQueue::add_quality_assessor(), MBMesquite::IQInterface::run_instructions(), MBMesquite::AveragingQM::set_averaging_method(), MBMesquite::QualityImprover::set_inner_termination_criterion(), MBMesquite::InstructionQueue::set_master_quality_improver(), MBMesquite::QualityImprover::set_outer_termination_criterion(), MBMesquite::QualityMetric::SUM, and MBMesquite::MeshWriter::write_vtk().
Referenced by main().
{ double OF_value = 0.0001; // creates an intruction queue InstructionQueue queue1; // creates a mean ratio quality metric ... IdealWeightInverseMeanRatio* mean_ratio = new IdealWeightInverseMeanRatio( err ); if( err ) return 1; mean_ratio->set_averaging_method( QualityMetric::SUM, err ); if( err ) return 1; // ... and builds an objective function with it LPtoPTemplate* obj_func = new LPtoPTemplate( mean_ratio, 1, err ); if( err ) return 1; // creates the smart laplacian optimization procedures SmartLaplacianSmoother* pass1 = new SmartLaplacianSmoother( obj_func ); QualityAssessor stop_qa( mean_ratio ); // **************Set stopping criterion**************** TerminationCriterion tc_inner; tc_inner.add_absolute_vertex_movement( OF_value ); TerminationCriterion tc_outer; tc_outer.add_iteration_limit( 1 ); pass1->set_inner_termination_criterion( &tc_inner ); pass1->set_outer_termination_criterion( &tc_outer ); queue1.add_quality_assessor( &stop_qa, err ); if( err ) return 1; // adds 1 pass of pass1 to mesh_set queue1.set_master_quality_improver( pass1, err ); if( err ) return 1; queue1.add_quality_assessor( &stop_qa, err ); if( err ) return 1; // launches optimization on mesh_set queue1.run_instructions( mesh, err ); if( err ) return 1; MeshWriter::write_vtk( mesh, "smart-laplacian-result.vtk", err ); if( err ) return 1; cout << "Wrote \"smart-laplacian-result.vtk\"" << endl; // print_timing_diagnostics( cout ); return 0; }
void usage | ( | ) |
Definition at line 83 of file test/mesquite/imesh/main.cpp.
References default_file_name.
{ cout << "main [-N] [filename]" << endl; cout << " -N : Use native representation instead of TSTT implementation\n"; cout << " If no file name is specified, will use \"" << default_file_name << '"' << endl; exit( 1 ); }
std::string default_file_name = "unittest/mesquite/3D/vtk/large_box_hex_1000.vtk" |
Definition at line 81 of file test/mesquite/imesh/main.cpp.