MOAB: Mesh Oriented datABase  (version 5.2.1)
ToolContext Struct Reference
+ Collaboration diagram for ToolContext:

Public Member Functions

 ToolContext (moab::Interface *icore)
 ~ToolContext ()
void timer_push (std::string operation)
void timer_pop ()
void ParseCLOptions (int argc, char *argv[])

Public Attributes

moab::Interface * mbcore
const int proc_id
const int n_procs
moab::DebugOutput outputFormatter
int blockSize
std::vector< std::string > inFilenames
std::vector< Mesh * > meshes
std::vector< moab::EntityHandlemeshsets
std::vector< int > disc_orders
std::vector< std::string > disc_methods
std::vector< std::string > doftag_names
std::string outFilename
std::string intxFilename
moab::TempestRemapper::TempestMeshType meshType
bool computeDual
bool computeWeights
bool verifyWeights
bool enforceConvexity
int ensureMonotonicity
bool fNoConservation
bool fVolumetric
bool rrmGrids
bool kdtreeSearch
bool fNoBubble
bool fInputConcave
bool fOutputConcave
bool fNoCheck

Private Attributes

moab::CpuTimertimer
double timer_ops
std::string opName

Detailed Description

Definition at line 41 of file mbtempest.cpp.


Constructor & Destructor Documentation

ToolContext::ToolContext ( moab::Interface *  icore) [inline]

Definition at line 75 of file mbtempest.cpp.

References doftag_names, inFilenames, outputFormatter, moab::DebugOutput::set_prefix(), and timer.

                                         :
            mbcore(icore),
            proc_id ( 0 ), n_procs ( 1 ),
            outputFormatter ( std::cout, 0, 0 ),
#endif
          blockSize( 5 ), outFilename( "output.exo" ), intxFilename( "" ), meshType( moab::TempestRemapper::DEFAULT ),
          computeDual( false ), computeWeights( false ), verifyWeights( false ), enforceConvexity(false), ensureMonotonicity( 0 ),
          fNoConservation( false ), fVolumetric( false ), rrmGrids( false ), kdtreeSearch( true ), fNoBubble( false ),
          fInputConcave( false ), fOutputConcave( false ), fNoCheck( false )
    {
        inFilenames.resize( 2 );
        doftag_names.resize( 2 );
        timer = new moab::CpuTimer();

        outputFormatter.set_prefix( "[MBTempest]: " );
    }

Definition at line 92 of file mbtempest.cpp.

References disc_methods, disc_orders, doftag_names, inFilenames, intxFilename, meshes, meshsets, outFilename, and timer.

    {
        // for (unsigned i=0; i < meshes.size(); ++i) delete meshes[i];
        meshes.clear();
        inFilenames.clear();
        disc_orders.clear();
        disc_methods.clear();
        doftag_names.clear();
        outFilename.clear();
        intxFilename.clear();
        meshsets.clear();
        delete timer;
    }

Member Function Documentation

void ToolContext::ParseCLOptions ( int  argc,
char *  argv[] 
) [inline]

Definition at line 133 of file mbtempest.cpp.

References ProgOptions::addOpt(), blockSize, computeDual, computeWeights, moab::TempestRemapper::CS, moab::TempestRemapper::DEFAULT, disc_methods, disc_orders, doftag_names, enforceConvexity, ensureMonotonicity, fNoCheck, fNoConservation, fVolumetric, ProgOptions::getOptAllArgs(), moab::TempestRemapper::ICO, inFilenames, intxFilename, kdtreeSearch, meshType, ProgOptions::numOptSet(), outFilename, moab::TempestRemapper::OVERLAP_FILES, moab::TempestRemapper::OVERLAP_MEMORY, moab::TempestRemapper::OVERLAP_MOAB, ProgOptions::parseCommandLine(), proc_id, moab::TempestRemapper::RLL, rrmGrids, and verifyWeights.

Referenced by main().

    {
        ProgOptions opts;
        int imeshType                  = 0;
        std::string expectedFName      = "output.exo";
        std::string expectedMethod     = "fv";
        std::string expectedDofTagName = "GLOBAL_ID";
        int expectedOrder              = 1;

        if( !proc_id )
        {
            std::cout << "Command line options provided to mbtempest:\n  ";
            for( int iarg = 0; iarg < argc; ++iarg )
                std::cout << argv[iarg] << " ";
            std::cout << std::endl << std::endl;
        }

        opts.addOpt< int >( "type,t",
                            "Type of mesh (default=CS; Choose from [CS=0, RLL=1, ICO=2, OVERLAP_FILES=3, "
                            "OVERLAP_MEMORY=4, OVERLAP_MOAB=5])",
                            &imeshType );
        opts.addOpt< int >( "res,r", "Resolution of the mesh (default=5)", &blockSize );
        opts.addOpt< void >( "dual,d", "Output the dual of the mesh (generally relevant only for ICO mesh)",
                             &computeDual );
        opts.addOpt< void >( "weights,w",
                             "Compute and output the weights using the overlap mesh (generally "
                             "relevant only for OVERLAP mesh)",
                             &computeWeights );
        opts.addOpt< void >( "noconserve,c",
                             "Do not apply conservation to the resultant weights (relevant only "
                             "when computing weights)",
                             &fNoConservation );
        opts.addOpt< void >( "volumetric,v",
                             "Apply a volumetric projection to compute the weights (relevant only "
                             "when computing weights)",
                             &fVolumetric );
        opts.addOpt< void >( "rrmgrids",
                             "At least one of the meshes is a regionally refined grid (relevant to "
                             "accelerate intersection computation)",
                             &rrmGrids );
        opts.addOpt< void >( "nocheck", "Do not check the generated map for conservation and consistency", &fNoCheck );
        opts.addOpt< void >( "advfront,a",
                             "Use the advancing front intersection instead of the Kd-tree based algorithm "
                             "to compute mesh intersections" );
        opts.addOpt< void >( "verify",
                             "Verify the accuracy of the maps by projecting analytical functions "
                             "from source to target "
                             "grid by applying the maps",
                             &verifyWeights );
        opts.addOpt< int >( "monotonic,n", "Ensure monotonicity in the weight generation", &ensureMonotonicity );
        opts.addOpt< std::string >( "load,l", "Input mesh filenames (a source and target mesh)", &expectedFName );
        opts.addOpt< int >( "order,o", "Discretization orders for the source and target solution fields",
                            &expectedOrder );
        opts.addOpt< std::string >( "method,m", "Discretization method for the source and target solution fields",
                                    &expectedMethod );
        opts.addOpt< std::string >( "global_id,g",
                                    "Tag name that contains the global DoF IDs for source and target solution fields",
                                    &expectedDofTagName );
        opts.addOpt< std::string >( "file,f", "Output remapping weights filename", &outFilename );
        opts.addOpt< std::string >( "intx,i", "Output TempestRemap intersection mesh filename", &intxFilename );

        opts.addOpt< void >( "enforce_convexity",
                                "check convexity of input meshes to compute mesh intersections" , &enforceConvexity);

        opts.parseCommandLine( argc, argv );

        // By default - use Kd-tree based search; if user asks for advancing front, disable Kd-tree
        // algorithm
        kdtreeSearch = opts.numOptSet( "advfront,a" ) == 0;

        switch( imeshType )
        {
            case 0:
                meshType = moab::TempestRemapper::CS;
                break;

            case 1:
                meshType = moab::TempestRemapper::RLL;
                break;

            case 2:
                meshType = moab::TempestRemapper::ICO;
                break;

            case 3:
                meshType = moab::TempestRemapper::OVERLAP_FILES;
                break;

            case 4:
                meshType = moab::TempestRemapper::OVERLAP_MEMORY;
                break;

            case 5:
                meshType = moab::TempestRemapper::OVERLAP_MOAB;
                break;

            default:
                meshType = moab::TempestRemapper::DEFAULT;
                break;
        }

        if( meshType > moab::TempestRemapper::ICO )
        {
            opts.getOptAllArgs( "load,l", inFilenames );
            opts.getOptAllArgs( "order,o", disc_orders );
            opts.getOptAllArgs( "method,m", disc_methods );
            opts.getOptAllArgs( "global_id,i", doftag_names );

            if( disc_orders.size() == 0 ) { disc_orders.resize( 2, 1 ); }

            if( disc_orders.size() == 1 ) { disc_orders.push_back( 1 ); }

            if( disc_methods.size() == 0 ) { disc_methods.resize( 2, "fv" ); }

            if( disc_methods.size() == 1 ) { disc_methods.push_back( "fv" ); }

            if( doftag_names.size() == 0 ) { doftag_names.resize( 2, "GLOBAL_ID" ); }

            if( doftag_names.size() == 1 ) { doftag_names.push_back( "GLOBAL_ID" ); }

            assert( inFilenames.size() == 2 );
            assert( disc_orders.size() == 2 );
            assert( disc_methods.size() == 2 );
        }

        expectedFName.clear();
    }
void ToolContext::timer_pop ( ) [inline]

Definition at line 112 of file mbtempest.cpp.

References n_procs, opName, proc_id, moab::CpuTimer::time_since_birth(), timer, and timer_ops.

Referenced by main().

    {
        double locElapsed = timer->time_since_birth() - timer_ops, avgElapsed = 0, maxElapsed = 0;
#ifdef MOAB_HAVE_MPI
        MPI_Reduce( &locElapsed, &maxElapsed, 1, MPI_DOUBLE, MPI_MAX, 0, pcomm->comm() );
        MPI_Reduce( &locElapsed, &avgElapsed, 1, MPI_DOUBLE, MPI_SUM, 0, pcomm->comm() );
#else
        maxElapsed = locElapsed;
        avgElapsed = locElapsed;
#endif
        if( !proc_id )
        {
            avgElapsed /= n_procs;
            std::cout << "[LOG] Time taken to " << opName.c_str() << ": max = " << maxElapsed
                      << ", avg = " << avgElapsed << "\n";
        }
        // std::cout << "\n[LOG" << proc_id << "] Time taken to " << opName << " = " <<
        // timer->time_since_birth() - timer_ops << std::endl;
        opName.clear();
    }
void ToolContext::timer_push ( std::string  operation) [inline]

Definition at line 106 of file mbtempest.cpp.

References opName, moab::CpuTimer::time_since_birth(), timer, and timer_ops.

Referenced by main().

    {
        timer_ops = timer->time_since_birth();
        opName    = operation;
    }

Member Data Documentation

Definition at line 49 of file mbtempest.cpp.

Referenced by CreateTempestMesh(), and ParseCLOptions().

Definition at line 59 of file mbtempest.cpp.

Referenced by CreateTempestMesh(), and ParseCLOptions().

Definition at line 60 of file mbtempest.cpp.

Referenced by main(), and ParseCLOptions().

std::vector< std::string > ToolContext::disc_methods

Definition at line 54 of file mbtempest.cpp.

Referenced by main(), ParseCLOptions(), and ~ToolContext().

std::vector< int > ToolContext::disc_orders

Definition at line 53 of file mbtempest.cpp.

Referenced by main(), ParseCLOptions(), and ~ToolContext().

std::vector< std::string > ToolContext::doftag_names

Definition at line 55 of file mbtempest.cpp.

Referenced by main(), ParseCLOptions(), ToolContext(), and ~ToolContext().

Definition at line 62 of file mbtempest.cpp.

Referenced by main(), and ParseCLOptions().

Definition at line 63 of file mbtempest.cpp.

Referenced by main(), and ParseCLOptions().

Definition at line 68 of file mbtempest.cpp.

Referenced by main().

Definition at line 68 of file mbtempest.cpp.

Referenced by main().

Definition at line 68 of file mbtempest.cpp.

Referenced by main(), and ParseCLOptions().

Definition at line 64 of file mbtempest.cpp.

Referenced by main(), and ParseCLOptions().

Definition at line 68 of file mbtempest.cpp.

Referenced by main().

Definition at line 65 of file mbtempest.cpp.

Referenced by main(), and ParseCLOptions().

std::vector< std::string > ToolContext::inFilenames

Definition at line 50 of file mbtempest.cpp.

Referenced by CreateTempestMesh(), main(), ParseCLOptions(), ToolContext(), and ~ToolContext().

Definition at line 57 of file mbtempest.cpp.

Referenced by main(), ParseCLOptions(), and ~ToolContext().

Definition at line 67 of file mbtempest.cpp.

Referenced by main(), and ParseCLOptions().

moab::Interface* ToolContext::mbcore

Definition at line 43 of file mbtempest.cpp.

Referenced by CreateTempestMesh().

std::vector< Mesh* > ToolContext::meshes

Definition at line 51 of file mbtempest.cpp.

Referenced by CreateTempestMesh(), main(), and ~ToolContext().

Definition at line 52 of file mbtempest.cpp.

Referenced by CreateTempestMesh(), main(), and ~ToolContext().

Definition at line 47 of file mbtempest.cpp.

Referenced by CreateTempestMesh(), and timer_pop().

std::string ToolContext::opName [private]

Definition at line 264 of file mbtempest.cpp.

Referenced by timer_pop(), and timer_push().

Definition at line 56 of file mbtempest.cpp.

Referenced by CreateTempestMesh(), main(), ParseCLOptions(), and ~ToolContext().

Definition at line 47 of file mbtempest.cpp.

Referenced by CreateTempestMesh(), main(), ParseCLOptions(), and timer_pop().

Definition at line 66 of file mbtempest.cpp.

Referenced by main(), and ParseCLOptions().

Definition at line 262 of file mbtempest.cpp.

Referenced by timer_pop(), timer_push(), ToolContext(), and ~ToolContext().

double ToolContext::timer_ops [private]

Definition at line 263 of file mbtempest.cpp.

Referenced by timer_pop(), and timer_push().

Definition at line 61 of file mbtempest.cpp.

Referenced by main(), and ParseCLOptions().

List of all members.


The documentation for this struct was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines