MOAB: Mesh Oriented datABase  (version 5.2.1)
par_hex_smooth_laplace.cpp File Reference
#include "TestUtil.hpp"
#include "MeshImpl.hpp"
#include "MeshUtil.hpp"
#include "MsqTimer.hpp"
#include "MsqDebug.hpp"
#include "Mesquite.hpp"
#include "MsqError.hpp"
#include "Vector3D.hpp"
#include "InstructionQueue.hpp"
#include "LaplaceWrapper.hpp"
#include "PatchData.hpp"
#include "TerminationCriterion.hpp"
#include "QualityAssessor.hpp"
#include "ParallelMeshImpl.hpp"
#include "ParallelHelper.hpp"
#include "Randomize.hpp"
#include "ConditionNumberQualityMetric.hpp"
#include "UntangleBetaQualityMetric.hpp"
#include "LPtoPTemplate.hpp"
#include "LInfTemplate.hpp"
#include "SteepestDescent.hpp"
#include "ConjugateGradient.hpp"
#include "PlanarDomain.hpp"
#include <iostream>
#include <cstdlib>
#include <mpi.h>
#include <sstream>
+ Include dependency graph for par_hex_smooth_laplace.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])

Variables

std::string VTK_3D_DIR = "/3D/vtk/hexes/tangled/"

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 94 of file par_hex_smooth_laplace.cpp.

References moab::debug, MBMesquite::MsqDebug::enable(), MBMesquite::LaplaceWrapper::enable_culling(), mesh, MBMesquite::MeshUtil::meshes_are_different(), MPI_COMM_WORLD, MBMesquite::print_timing_diagnostics(), rank, MBMesquite::MeshImpl::read_vtk(), MBMesquite::IQInterface::run_instructions(), MBMesquite::ParallelHelperImpl::set_communicator(), MBMesquite::LaplaceWrapper::set_iteration_limit(), MBMesquite::ParallelMesh::set_parallel_helper(), MBMesquite::ParallelHelperImpl::set_parallel_mesh(), MBMesquite::LaplaceWrapper::set_vertex_movement_limit_factor(), VTK_3D_DIR, and MBMesquite::MeshImpl::write_vtk().

{
    /* init MPI */
    int rank, nprocs;
    if( MPI_SUCCESS != MPI_Init( &argc, &argv ) )
    {
        cerr << "MPI_Init failed." << endl;
        return 2;
    }
    MPI_Comm_rank( MPI_COMM_WORLD, &rank );
    MPI_Comm_size( MPI_COMM_WORLD, &nprocs );

    if( nprocs > 2 )
    {
        cerr << "parallel_laplace_smooth test can only be run with 1 or 2 processors" << std::endl;
        return 0;
    }

    const int debug = 0;  // 1,2,3 for more debug info
    if( debug )
    {
        MsqDebug::enable( 1 );
        if( debug > 1 ) MsqDebug::enable( 2 );
        if( debug > 2 ) MsqDebug::enable( 3 );
    }

    /* create processor-specific file names */
    ostringstream in_name, out_name, gold_name;
    in_name << VTK_3D_DIR << "par_original_hex_mesh." << nprocs << "." << rank << ".vtk";
    gold_name << VTK_3D_DIR << "par_smoothed_hex_mesh." << nprocs << "." << rank << ".vtk";
    out_name << "par_smoothed_hex_mesh." << nprocs << "." << rank << ".vtk";

    /* load different mesh files on each processor */
    MBMesquite::MsqError err;
    MBMesquite::MeshImpl mesh;
    mesh.read_vtk( in_name.str().c_str(), err );
    if( err )
    {
        cerr << err << endl;
        return 1;
    }

    /* create parallel mesh instance, specifying tags
     * containing parallel data */
    MBMesquite::ParallelMeshImpl parallel_mesh( &mesh, "GLOBAL_ID", "PROCESSOR_ID" );
    MBMesquite::ParallelHelperImpl helper;
    helper.set_communicator( MPI_COMM_WORLD );
    helper.set_parallel_mesh( &parallel_mesh );
    parallel_mesh.set_parallel_helper( &helper );

    /* do Laplacian smooth */
    LaplaceWrapper optimizer;
    optimizer.set_vertex_movement_limit_factor( 1.e-10 );
    optimizer.set_iteration_limit( 2000 );
    optimizer.enable_culling( false );
    optimizer.run_instructions( &parallel_mesh, err );
    if( err )
    {
        cerr << err << endl;
        return 1;
    }

    /* write mesh */
    mesh.write_vtk( out_name.str().c_str(), err );
    if( err )
    {
        cerr << err << endl;
        return 1;
    }

    /* compare mesh with gold copy */
    MeshImpl gold;
    gold.read_vtk( gold_name.str().c_str(), err );
    if( err )
    {
        cerr << err << endl;
        return 1;
    }

    bool do_print = true;
    double tol    = 1.e-4;
    bool diff     = MeshUtil::meshes_are_different( mesh, gold, err, tol, do_print );
    if( err )
    {
        cerr << err << endl;
        return 1;
    }

    if( diff )
    {
        cerr << "Error, computed mesh different from gold copy" << std::endl;
        return 1;
    }

    print_timing_diagnostics( cout );

    MPI_Finalize();
    return 0;
}

Variable Documentation

std::string VTK_3D_DIR = "/3D/vtk/hexes/tangled/"

Definition at line 90 of file par_hex_smooth_laplace.cpp.

Referenced by main().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines