MOAB: Mesh Oriented datABase  (version 5.4.1)
size_adapt_shape.cpp File Reference
#include "TestUtil.hpp"
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include "Mesquite.hpp"
#include "MsqError.hpp"
#include "MeshImpl.hpp"
#include "SizeAdaptShapeWrapper.hpp"
#include "SphericalDomain.hpp"
#include "MsqVertex.hpp"
+ Include dependency graph for size_adapt_shape.cpp:

Go to the source code of this file.

Typedefs

typedef std::vector
< Mesh::ElementHandle
elem_vec_t

Functions

void help (const char *argv0)
void find_z10_extreme_elements (Mesh &mesh, elem_vec_t &polar_elems, elem_vec_t &equatorial_elems, MsqError &err)
void elem_areas (Mesh &mesh, const elem_vec_t &elems, double &min, double &mean, double &max, MsqError &err)
int main (int argc, char *argv[])

Variables

std::string DEFAULT_INPUT = "unittest/mesquite/2D/vtk/quads/untangled/bias-sphere-quads.vtk"

Typedef Documentation

typedef std::vector< Mesh::ElementHandle > elem_vec_t

Definition at line 60 of file size_adapt_shape.cpp.


Function Documentation

void elem_areas ( Mesh mesh,
const elem_vec_t elems,
double &  min,
double &  mean,
double &  max,
MsqError err 
)
void find_z10_extreme_elements ( Mesh mesh,
elem_vec_t polar_elems,
elem_vec_t equatorial_elems,
MsqError err 
)
void help ( const char *  argv0)

Definition at line 52 of file size_adapt_shape.cpp.

References DEFAULT_INPUT.

{
    std::cerr << "Usage: " << argv0 << " [<output_file>]" << std::endl
              << "  Input file is always: " << DEFAULT_INPUT << std::endl
              << "  default is no output file" << std::endl;
    exit( 1 );
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 69 of file size_adapt_shape.cpp.

References DEFAULT_INPUT, elem_areas(), find_z10_extreme_elements(), geom, help(), input_file, mesh, MBMesquite::MeshImpl::read_vtk(), MBMesquite::IQInterface::run_instructions(), and MBMesquite::MeshImpl::write_vtk().

{
    const char* input_file  = DEFAULT_INPUT.c_str();
    const char* output_file = NULL;
    switch( argc )
    {
        default:
            help( argv[0] );
        case 2:
            if( !strcmp( argv[1], "-h" ) ) help( argv[0] );
            output_file = argv[1];
        case 1:;
    }

    /* Read a VTK Mesh file */
    MsqPrintError err( cout );
    MBMesquite::MeshImpl mesh;
    mesh.read_vtk( input_file, err );
    if( err )
    {
        std::cerr << input_file << ": file read failed" << endl;
        return 1;
    }

    elem_vec_t polar, equatorial;
    find_z10_extreme_elements( mesh, polar, equatorial, err );
    if( err ) return 1;

    double eq_min, eq_max, eq_mean, pol_min, pol_max, pol_mean;
    elem_areas( mesh, polar, pol_min, pol_mean, pol_max, err );
    if( err ) return 1;
    elem_areas( mesh, equatorial, eq_min, eq_mean, eq_max, err );
    if( err ) return 1;

    /* Run optimizer */
    SphericalDomain geom( Vector3D( 0, 0, 0 ), 10.0 );
    SizeAdaptShapeWrapper smoother( 1e-2 );
    MeshDomainAssoc mesh_and_domain = MeshDomainAssoc( &mesh, &geom );
    smoother.run_instructions( &mesh_and_domain, err );
    if( err ) return 1;

    if( output_file )
    {
        mesh.write_vtk( output_file, err );
        if( err )
        {
            std::cerr << output_file << ": file write failed" << endl;
            return 1;
        }
        else
        {
            std::cout << "Wrote file: " << output_file << endl;
        }
    }

    double eq2_min, eq2_max, eq2_mean, pol2_min, pol2_max, pol2_mean;
    elem_areas( mesh, polar, pol2_min, pol2_mean, pol2_max, err );
    if( err ) return 1;
    elem_areas( mesh, equatorial, eq2_min, eq2_mean, eq2_max, err );
    if( err ) return 1;

    double eq_min_pct   = 100 * fabs( eq_min - eq2_min ) / eq_min;
    double eq_max_pct   = 100 * fabs( eq_max - eq2_max ) / eq_max;
    double eq_mean_pct  = 100 * fabs( eq_mean - eq2_mean ) / eq_mean;
    double pol_min_pct  = 100 * fabs( pol_min - pol2_min ) / pol_min;
    double pol_max_pct  = 100 * fabs( pol_max - pol2_max ) / pol_max;
    double pol_mean_pct = 100 * fabs( pol_mean - pol2_mean ) / pol_mean;

    std::printf( "\n\n" );
    std::printf( "AREAS:      Initial     Final       Difference  Change\n" );
    std::printf( "Polar:\n" );
    std::printf( "  Minimum:  %10f  %10f  %10f  %10f%%\n", pol_min, pol2_min, fabs( pol_min - pol2_min ), pol_min_pct );
    std::printf( "  Average:  %10f  %10f  %10f  %10f%%\n", pol_mean, pol2_mean, fabs( pol_mean - pol2_mean ),
                 pol_mean_pct );
    std::printf( "  Maximum:  %10f  %10f  %10f  %10f%%\n", pol_max, pol2_max, fabs( pol_max - pol2_max ), pol_max_pct );
    std::printf( "Equatorial:\n" );
    std::printf( "  Minimum:  %10f  %10f  %10f  %10f%%\n", eq_min, eq2_min, fabs( eq_min - eq2_min ), eq_min_pct );
    std::printf( "  Average:  %10f  %10f  %10f  %10f%%\n", eq_mean, eq2_mean, fabs( eq_mean - eq2_mean ), eq_mean_pct );
    std::printf( "  Maximum:  %10f  %10f  %10f  %10f%%\n", eq_max, eq2_max, fabs( eq_max - eq2_max ), eq_max_pct );

    bool success = pol_min_pct < 6.0 && pol_max_pct < 6.5 && eq_min_pct < 25.0 && eq_max_pct < 6.5;
    return !success;
}

Variable Documentation

std::string DEFAULT_INPUT = "unittest/mesquite/2D/vtk/quads/untangled/bias-sphere-quads.vtk"

Definition at line 50 of file size_adapt_shape.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines