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

Go to the source code of this file.

Classes

class  ParShapeImprover
class  ParShapeImprover::ParShapeImprovementWrapper

Defines

#define VTK_3D_DIR   ( TestDir + "unittest/mesquite/3D/vtk/hexes/tangled/" )
#define VTK_2D_DIR   ( TestDir + "unittest/mesquite/2D/vtk/quads/tangled/" )

Functions

static int test (std::string filename_prefix, std::string mesh_topology_name, MeshDomain *domain=0)
int main (int argc, char *argv[])

Variables

const double DEF_UNT_BETA = 1e-8
const double DEF_SUC_EPS = 1e-4

Define Documentation

#define VTK_2D_DIR   ( TestDir + "unittest/mesquite/2D/vtk/quads/tangled/" )

Definition at line 104 of file par_hex_untangle_shape.cpp.

Referenced by main().

#define VTK_3D_DIR   ( TestDir + "unittest/mesquite/3D/vtk/hexes/tangled/" )

Definition at line 103 of file par_hex_untangle_shape.cpp.

Referenced by main().


Function Documentation

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

Definition at line 527 of file par_hex_untangle_shape.cpp.

References test, VTK_2D_DIR, and VTK_3D_DIR.

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

    Vector3D pnt( 0, 0, 0 );
    Vector3D s_norm( 0, 0, 1 );
    PlanarDomain msq_geom( s_norm, pnt );

    int t1 = test( VTK_2D_DIR, "quad", &msq_geom );
    if( t1 ) return t1;
    t1 = test( VTK_3D_DIR, "hex" );
    if( t1 ) return t1;

    MPI_Finalize();
    return 0;
}
static int test ( std::string  filename_prefix,
std::string  mesh_topology_name,
MeshDomain domain = 0 
) [static]

Definition at line 426 of file par_hex_untangle_shape.cpp.

References mesh, MBMesquite::MeshUtil::meshes_are_different(), MPI_COMM_WORLD, MBMesquite::print_timing_diagnostics(), rank, MBMesquite::MeshImpl::read_vtk(), ParShapeImprover::run(), MBMesquite::ParallelHelperImpl::set_communicator(), MBMesquite::ParallelMesh::set_parallel_helper(), MBMesquite::ParallelHelperImpl::set_parallel_mesh(), and MBMesquite::MeshImpl::write_vtk().

{
    int rank, nprocs;
    MPI_Comm_rank( MPI_COMM_WORLD, &rank );
    MPI_Comm_size( MPI_COMM_WORLD, &nprocs );

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

    /* create processor-specific file names */
    ostringstream in_name, out_name, gold_name;
    in_name << filename_prefix << "par_untangle_original_" << mesh_topology_name << "_mesh." << nprocs << "." << rank
            << ".vtk";
    gold_name << filename_prefix << "par_untangle_smoothed_" << mesh_topology_name << "_mesh." << nprocs << "." << rank
              << ".vtk";
    out_name << "par_untangle_smoothed_" << mesh_topology_name << "_mesh." << nprocs << "." << rank << ".vtk";

    cout << "in_name= " << in_name.str() << " gold_name= " << gold_name.str() << " out_name= " << out_name.str()
         << std::endl;

    /* load different mesh files on each processor */
    MsqError err;
    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 */
    ParallelMeshImpl parallel_mesh( &mesh, "GLOBAL_ID", "PROCESSOR_ID" );
    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.run_instructions(&parallel_mesh, err);

    int msq_debug      = 0;  // 1,2,3 for more debug info
    bool always_smooth = true;
    int innerIter      = 100;
    double gradNorm    = 1.e-9;

    ParShapeImprover si( innerIter, gradNorm );
    // Mesh *pmesh = &parallel_mesh;
    si.run( parallel_mesh, domain, err, always_smooth, msq_debug );
    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;
    }

    // std::cout << "P[ " << rank <<"] reading gold..." << std::endl;

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

    // std::cout << "P[ " << rank <<"] read gold, checking mesh diff..." << std::endl;
    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;
    }
    // std::cout << "P[ " << rank <<"] read gold, checking mesh diff...done" << std::endl;

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

    print_timing_diagnostics( cout );

    return 0;
}

Variable Documentation

const double DEF_SUC_EPS = 1e-4

Definition at line 109 of file par_hex_untangle_shape.cpp.

const double DEF_UNT_BETA = 1e-8

Definition at line 108 of file par_hex_untangle_shape.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines