MOAB: Mesh Oriented datABase  (version 5.4.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::Interfacembcore
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 fvMethod
std::string outFilename
std::string intxFilename
std::string baselineFile
moab::TempestRemapper::TempestMeshType meshType
bool computeDual
bool computeWeights
bool verifyWeights
bool enforceConvexity
int ensureMonotonicity
bool rrmGrids
bool kdtreeSearch
bool fCheck
bool fVolumetric
GenerateOfflineMapAlgorithmOptions mapOptions

Private Attributes

moab::CpuTimertimer
double timer_ops
std::string opName

Detailed Description

Definition at line 42 of file mbtempest.cpp.


Constructor & Destructor Documentation

Definition at line 78 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 ), fvMethod("none"), outFilename( "outputFile.nc" ), intxFilename( "intxFile.h5m" ), baselineFile( "" ),
          meshType( moab::TempestRemapper::DEFAULT ), computeDual( false ), computeWeights( false ),
          verifyWeights( false ), enforceConvexity( false ), ensureMonotonicity( 0 ), rrmGrids( false ),
          kdtreeSearch( true ), fCheck( n_procs > 1 ? false : true ), fVolumetric(false)
    {
        inFilenames.resize( 2 );
        doftag_names.resize( 2 );
        timer = new moab::CpuTimer();

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

Definition at line 93 of file mbtempest.cpp.

References baselineFile, 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();
        baselineFile.clear();
        meshsets.clear();
        delete timer;
    }

Member Function Documentation

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

Definition at line 135 of file mbtempest.cpp.

References ProgOptions::addOpt(), baselineFile, blockSize, computeDual, computeWeights, moab::TempestRemapper::CS, moab::TempestRemapper::DEFAULT, disc_methods, disc_orders, doftag_names, enforceConvexity, ensureMonotonicity, fCheck, fVolumetric, ProgOptions::getOptAllArgs(), moab::TempestRemapper::ICO, inFilenames, intxFilename, kdtreeSearch, mapOptions, 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 expectedFVMethod   = "none";
        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 (relevant only for ICO mesh type)", &computeDual );

        opts.addOpt< std::string >( "file,f", "Output computed mesh or remapping weights to specified filename",
                                    &outFilename );
        opts.addOpt< std::string >(
            "load,l", "Input mesh filenames for source and target meshes. (relevant only when computing weights)",
            &expectedFName );

        opts.addOpt< void >( "advfront,a",
                             "Use the advancing front intersection instead of the Kd-tree based algorithm "
                             "to compute mesh intersections. (relevant only when computing weights)" );

        opts.addOpt< std::string >( "intx,i", "Output TempestRemap intersection mesh filename", &intxFilename );

        opts.addOpt< void >( "weights,w",
                             "Compute and output the weights using the overlap mesh (generally "
                             "relevant only for OVERLAP mesh)",
                             &computeWeights );

        opts.addOpt< std::string >( "method,m", "Discretization method for the source and target solution fields",
                                    &expectedMethod );

        opts.addOpt< int >( "order,o", "Discretization orders for the source and target solution fields",
                            &expectedOrder );

        opts.addOpt< std::string >( "global_id,g",
                                    "Tag name that contains the global DoF IDs for source and target solution fields",
                                    &expectedDofTagName );

        opts.addOpt< void >( "noconserve",
                             "Do not apply conservation to the resultant weights (relevant only "
                             "when computing weights)",
                             &mapOptions.fNoConservation );

        opts.addOpt< void >( "volumetric",
                             "Apply a volumetric projection to compute the weights (relevant only "
                             "when computing weights)",
                             &fVolumetric );

        opts.addOpt< int >( "monotonicity", "Ensure monotonicity in the weight generation. Options=[0,1,2,3]",
                            &ensureMonotonicity );

        opts.addOpt< std::string >( "fvmethod",
                                    "Sub-type method for FV-FV projections (invdist, delaunay, bilin, "
                                    "intbilin, intbilingb, none. Default: none)",
                                    &expectedFVMethod );

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

        opts.addOpt< void >( "nobubble", "do not use bubble on interior of spectral element nodes",
                             &mapOptions.fNoBubble );

        opts.addOpt< void >( "sparseconstraints", "do not use bubble on interior of spectral element nodes",
                             &mapOptions.fSparseConstraints );

        opts.addOpt< void >( "rrmgrids",
                             "At least one of the meshes is a regionally refined grid (relevant to "
                             "accelerate intersection computation)",
                             &rrmGrids );

        opts.addOpt< void >( "checkmap", "Check the generated map for conservation and consistency", &fCheck );

        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< std::string >( "baseline", "Output baseline file", &baselineFile );

        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 ) // compute overlap mesh and maps possibly
        {
            opts.getOptAllArgs( "load,l", inFilenames );
            opts.getOptAllArgs( "order,o", disc_orders );
            opts.getOptAllArgs( "method,m", disc_methods );
            opts.getOptAllArgs( "global_id,i", doftag_names );

            assert( inFilenames.size() == 2 );
            assert( disc_orders.size() == 2 );
            assert( disc_methods.size() == 2 );
            assert( ensureMonotonicity >= 0 && ensureMonotonicity <= 3 );

            // get discretization order parameters
            if( disc_orders.size() == 0 ) disc_orders.resize( 2, 1 );
            if( disc_orders.size() == 1 ) disc_orders.push_back( 1 );

            // get discretization method parameters
            if( disc_methods.size() == 0 ) disc_methods.resize( 2, "fv" );
            if( disc_methods.size() == 1 ) disc_methods.push_back( "fv" );

            // get DoF tagname parameters
            if( doftag_names.size() == 0 ) doftag_names.resize( 2, "GLOBAL_ID" );
            if( doftag_names.size() == 1 ) doftag_names.push_back( "GLOBAL_ID" );

            // for computing maps and overlaps, set discretization orders
            mapOptions.nPin           = disc_orders[0];
            mapOptions.nPout          = disc_orders[1];
            mapOptions.fSourceConcave = false;
            mapOptions.fTargetConcave = false;

            mapOptions.strMethod = "";

            if( expectedFVMethod != "none" )
            {
                mapOptions.strMethod += expectedFVMethod + ";";
                // These FV projection methods are non-conservative; specify it explicitly
                mapOptions.fNoConservation = true;
            }
            switch( ensureMonotonicity )
            {
                case 0:
                    mapOptions.fMonotone = false;
                    break;
                case 3:
                    mapOptions.strMethod += "mono3;";
                    break;
                case 2:
                    mapOptions.strMethod += "mono2;";
                    break;
                default:
                    mapOptions.fMonotone = true;
            }
            mapOptions.fNoCorrectAreas = false;
            mapOptions.fNoCheck        = !fCheck;

            //assert( fVolumetric && fInverseDistanceMap == false );  // both options cannot be active
            if( fVolumetric ) mapOptions.strMethod += "volumetric;";
        }

        // clear temporary string name
        expectedFName.clear();

        mapOptions.strOutputMapFile = outFilename;
        mapOptions.strOutputFormat  = "Netcdf4";
    }
void ToolContext::timer_pop ( ) [inline]

Definition at line 114 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 108 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 60 of file mbtempest.cpp.

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

Definition at line 50 of file mbtempest.cpp.

Referenced by CreateTempestMesh(), and ParseCLOptions().

Definition at line 62 of file mbtempest.cpp.

Referenced by CreateTempestMesh(), and ParseCLOptions().

Definition at line 63 of file mbtempest.cpp.

Referenced by main(), and ParseCLOptions().

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

Definition at line 55 of file mbtempest.cpp.

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

std::vector< int > ToolContext::disc_orders

Definition at line 54 of file mbtempest.cpp.

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

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

Definition at line 56 of file mbtempest.cpp.

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

Definition at line 65 of file mbtempest.cpp.

Referenced by main(), and ParseCLOptions().

Definition at line 66 of file mbtempest.cpp.

Referenced by main(), and ParseCLOptions().

Definition at line 69 of file mbtempest.cpp.

Referenced by main(), and ParseCLOptions().

std::string ToolContext::fvMethod

Definition at line 57 of file mbtempest.cpp.

Definition at line 70 of file mbtempest.cpp.

Referenced by ParseCLOptions().

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

Definition at line 51 of file mbtempest.cpp.

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

Definition at line 59 of file mbtempest.cpp.

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

Definition at line 68 of file mbtempest.cpp.

Referenced by main(), and ParseCLOptions().

GenerateOfflineMapAlgorithmOptions ToolContext::mapOptions

Definition at line 71 of file mbtempest.cpp.

Referenced by main(), and ParseCLOptions().

Definition at line 44 of file mbtempest.cpp.

Referenced by CreateTempestMesh().

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

Definition at line 52 of file mbtempest.cpp.

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

Definition at line 53 of file mbtempest.cpp.

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

Definition at line 48 of file mbtempest.cpp.

Referenced by CreateTempestMesh(), and timer_pop().

std::string ToolContext::opName [private]

Definition at line 337 of file mbtempest.cpp.

Referenced by timer_pop(), and timer_push().

Definition at line 58 of file mbtempest.cpp.

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

Definition at line 48 of file mbtempest.cpp.

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

Definition at line 67 of file mbtempest.cpp.

Referenced by main(), and ParseCLOptions().

Definition at line 335 of file mbtempest.cpp.

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

double ToolContext::timer_ops [private]

Definition at line 336 of file mbtempest.cpp.

Referenced by timer_pop(), and timer_push().

Definition at line 64 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