Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
moab::TempestRemapper Class Reference

#include <TempestRemapper.hpp>

+ Inheritance diagram for moab::TempestRemapper:
+ Collaboration diagram for moab::TempestRemapper:

Public Types

enum  TempestMeshType {
  DEFAULT = -1 , CS = 0 , RLL = 1 , ICO = 2 ,
  ICOD = 3 , OVERLAP_FILES = 4 , OVERLAP_MEMORY = 5 , OVERLAP_MOAB = 6
}
 
- Public Types inherited from moab::Remapper
enum  IntersectionContext {
  DEFAULT = -1 , SourceMesh = 0 , TargetMesh = 1 , OverlapMesh = 2 ,
  CoveringMesh = 3
}
 

Public Member Functions

 TempestRemapper (moab::Interface *mbInt, bool offlineMode=false)
 
virtual ~TempestRemapper ()
 
virtual ErrorCode initialize (bool initialize_fsets=true)
 Initialize the TempestRemapper object internal datastructures including the mesh sets and TempestRemap mesh references. More...
 
virtual ErrorCode clear ()
 Deallocate and clear any memory initialized in the TempestRemapper object More...
 
moab::ErrorCode GenerateMesh (Remapper::IntersectionContext ctx, TempestMeshType type)
 Generate a mesh in memory of given type (CS/RLL/ICO/MPAS(structured)) and store it under the context specified by the user. More...
 
moab::ErrorCode LoadMesh (Remapper::IntersectionContext ctx, std::string inputFilename, TempestMeshType type)
 Load a mesh from disk of given type and store it under the context specified by the user. More...
 
moab::ErrorCode ConstructCoveringSet (double tolerance=1e-8, double radius_src=1.0, double radius_tgt=1.0, double boxeps=0.1, bool regional_mesh=false, bool gnomonic=true, int nb_ghost_layers=0)
 Construct a source covering mesh such that it completely encompasses the target grid in parallel. This operation is critical to ensure that the parallel advancing-front intersection algorithm can compute the intersection mesh only locally without any process communication. More...
 
moab::ErrorCode ComputeOverlapMesh (bool kdtree_search=true, bool use_tempest=false)
 Compute the intersection mesh between the source and target grids that have been instantiated in the Remapper. This function invokes the parallel advancing-front intersection algorithm internally for spherical meshes and can handle arbitrary unstructured grids (CS, RLL, ICO, MPAS) with and without holes. More...
 
moab::ErrorCode ConvertTempestMesh (Remapper::IntersectionContext ctx)
 Convert the TempestRemap mesh object to a corresponding MOAB mesh representation according to the intersection context. More...
 
moab::ErrorCode ConvertMeshToTempest (Remapper::IntersectionContext ctx)
 Convert the MOAB mesh representation to a corresponding TempestRemap mesh object according to the intersection context. More...
 
Mesh * GetMesh (Remapper::IntersectionContext ctx)
 Get the TempestRemap mesh object according to the intersection context. More...
 
void SetMesh (Remapper::IntersectionContext ctx, Mesh *mesh, bool overwrite=true)
 Set the TempestRemap mesh object according to the intersection context. More...
 
void SetMeshSet (Remapper::IntersectionContext ctx, moab::EntityHandle mset, moab::Range *entities=nullptr)
 
Mesh * GetCoveringMesh ()
 Get the covering mesh (TempestRemap) object. More...
 
moab::EntityHandleGetMeshSet (Remapper::IntersectionContext ctx)
 Get the MOAB mesh set corresponding to the intersection context. More...
 
moab::EntityHandle GetMeshSet (Remapper::IntersectionContext ctx) const
 Const overload. Get the MOAB mesh set corresponding to the intersection context. More...
 
moab::RangeGetMeshEntities (Remapper::IntersectionContext ctx)
 Get the mesh element entities corresponding to the intersection context. More...
 
const moab::RangeGetMeshEntities (Remapper::IntersectionContext ctx) const
 Const overload. Get the mesh element entities corresponding to the intersection context. More...
 
moab::RangeGetMeshVertices (Remapper::IntersectionContext ctx)
 Get the mesh vertices corresponding to the intersection context. Useful for point-cloud meshes More...
 
const moab::RangeGetMeshVertices (Remapper::IntersectionContext ctx) const
 Const overload. Get the mesh vertices corresponding to the intersection context. Useful for point-cloud meshes. More...
 
moab::EntityHandleGetCoveringSet ()
 Get access to the underlying source covering set if available. Else return the source set. More...
 
void SetMeshType (Remapper::IntersectionContext ctx, const std::vector< int > &metadata)
 Set the mesh type corresponding to the intersection context More...
 
void ResetMeshSet (Remapper::IntersectionContext ctx, moab::EntityHandle meshSet)
 reconstruct mesh, used now only for IO; need a better solution maybe More...
 
TempestMeshType GetMeshType (Remapper::IntersectionContext ctx) const
 Get the mesh type corresponding to the intersection context More...
 
int GetGlobalID (Remapper::IntersectionContext ctx, int localID)
 Get the global ID corresponding to the local entity ID according to the context (source, target, intersection) More...
 
int GetLocalID (Remapper::IntersectionContext ctx, int globalID)
 Get the local ID corresponding to the global entity ID according to the context (source, target, intersection) More...
 
moab::ErrorCode WriteTempestIntersectionMesh (std::string strOutputFileName, const bool fAllParallel, const bool fInputConcave, const bool fOutputConcave)
 Gather the overlap mesh and asssociated source/target data and write it out to disk using the TempestRemap output interface. This information can then be used with the "GenerateOfflineMap" tool in TempestRemap as needed. More...
 
moab::ErrorCode GenerateCSMeshMetadata (const int ntot_elements, moab::Range &entities, moab::Range *secondary_entities, const std::string &dofTagName, int nP)
 Generate the necessary metadata and specifically the GLL node numbering for DoFs for a CS mesh. This negates the need for running external code like HOMME to output the numbering needed for computing maps. The functionality is used through the mbconvert tool to compute processor-invariant Global DoF IDs at GLL nodes. More...
 
moab::ErrorCode GenerateMeshMetadata (Mesh &mesh, const int ntot_elements, moab::Range &entities, moab::Range *secondary_entities, const std::string dofTagName, int nP)
 Generate the necessary metadata for DoF node numbering in a given mesh. Currently, only the functionality to generate numbering on CS grids is supported. More...
 
moab::ErrorCode ComputeGlobalLocalMaps ()
 Compute the local and global IDs for elements in source/target/coverage meshes. More...
 
moab::ErrorCode GetOverlapAugmentedEntities (moab::Range &sharedGhostEntities)
 Get all the ghosted overlap entities that were accumulated to enable conservation in parallel More...
 
moab::ErrorCode assign_vertex_element_IDs (Tag idtag, EntityHandle this_set, const int dimension=2, const int start_id=1)
 Internal method to assign vertex and element global IDs if one does not exist already More...
 
ErrorCode GetIMasks (Remapper::IntersectionContext ctx, std::vector< int > &masks)
 Get the masks that could have been defined. More...
 
- Public Member Functions inherited from moab::Remapper
 Remapper (moab::Interface *mbInt)
 
virtual ~Remapper ()
 
moab::Interfaceget_interface ()
 
ErrorCode LoadNativeMesh (std::string filename, moab::EntityHandle &meshset, std::vector< int > &metadata, const char *readopts=0)
 

Public Attributes

const bool offlineWorkflow
 
bool meshValidate
 
bool constructEdgeMap
 

Static Public Attributes

static const bool verbose = true
 

Private Member Functions

moab::ErrorCode convert_overlap_mesh_sorted_by_source ()
 
moab::ErrorCode load_tempest_mesh_private (std::string inputFilename, Mesh **tempest_mesh)
 
moab::ErrorCode convert_mesh_to_tempest_private (Mesh *mesh, moab::EntityHandle meshset, moab::Range &entities, moab::Range *pverts)
 
moab::ErrorCode convert_tempest_mesh_private (TempestMeshType type, Mesh *mesh, moab::EntityHandle &meshset, moab::Range &entities, moab::Range *vertices)
 
moab::ErrorCode augment_overlap_set ()
 

Private Attributes

Mesh * m_source
 
TempestMeshType m_source_type
 
moab::Range m_source_entities
 
moab::Range m_source_vertices
 
moab::EntityHandle m_source_set
 
int max_source_edges
 
bool point_cloud_source
 
std::vector< int > m_source_metadata
 
Mesh * m_target
 
TempestMeshType m_target_type
 
moab::Range m_target_entities
 
moab::Range m_target_vertices
 
moab::EntityHandle m_target_set
 
int max_target_edges
 
bool point_cloud_target
 
std::vector< int > m_target_metadata
 
Mesh * m_overlap
 
TempestMeshType m_overlap_type
 
moab::Range m_overlap_entities
 
moab::EntityHandle m_overlap_set
 
std::vector< std::pair< int, int > > m_sorted_overlap_order
 
moab::Intx2MeshOnSpherembintx
 
Mesh * m_covering_source
 
moab::EntityHandle m_covering_source_set
 
moab::Range m_covering_source_entities
 
moab::Range m_covering_source_vertices
 
std::map< int, int > gid_to_lid_src
 
std::map< int, int > gid_to_lid_covsrc
 
std::map< int, int > gid_to_lid_tgt
 
std::map< int, int > lid_to_gid_src
 
std::map< int, int > lid_to_gid_covsrc
 
std::map< int, int > lid_to_gid_tgt
 
IntxAreaUtils::AreaMethod m_area_method
 
bool rrmgrids
 
bool is_parallel
 
bool is_root
 
int rank
 
int size
 

Friends

class TempestOnlineMap
 

Additional Inherited Members

- Protected Attributes inherited from moab::Remapper
Interfacem_interface
 

Detailed Description

Definition at line 36 of file TempestRemapper.hpp.

Member Enumeration Documentation

◆ TempestMeshType

Enumerator
DEFAULT 
CS 
RLL 
ICO 
ICOD 
OVERLAP_FILES 
OVERLAP_MEMORY 
OVERLAP_MOAB 

Definition at line 54 of file TempestRemapper.hpp.

55  { 56  DEFAULT = -1, 57  CS = 0, 58  RLL = 1, 59  ICO = 2, 60  ICOD = 3, 61  OVERLAP_FILES = 4, 62  OVERLAP_MEMORY = 5, 63  OVERLAP_MOAB = 6 64  };

Constructor & Destructor Documentation

◆ TempestRemapper()

moab::TempestRemapper::TempestRemapper ( moab::Interface mbInt,
bool  offlineMode = false 
)
inline

Definition at line 43 of file TempestRemapper.hpp.

44  : Remapper( mbInt ), 45 #endif 46  offlineWorkflow( offlineMode ), meshValidate( false ), constructEdgeMap( false ), m_source_type( DEFAULT ), 47  m_target_type( DEFAULT ) 48  { 49  }

◆ ~TempestRemapper()

moab::TempestRemapper::~TempestRemapper ( )
virtual

Definition at line 101 of file TempestRemapper.cpp.

102 { 103  this->clear(); 104 }

References clear().

Member Function Documentation

◆ assign_vertex_element_IDs()

ErrorCode moab::TempestRemapper::assign_vertex_element_IDs ( Tag  idtag,
EntityHandle  this_set,
const int  dimension = 2,
const int  start_id = 1 
)

Internal method to assign vertex and element global IDs if one does not exist already

Definition at line 1017 of file TempestRemapper.cpp.

1021 { 1022  assert( idtag ); 1023  1024  ErrorCode rval; 1025  Range entities; 1026  rval = m_interface->get_entities_by_dimension( this_set, dimension, entities );MB_CHK_SET_ERR( rval, "Failed to get entities" ); 1027  1028  if( entities.size() == 0 ) return moab::MB_SUCCESS; 1029  1030  int idoffset = start_id; 1031  std::vector< int > gid( entities.size() ); 1032  for( unsigned i = 0; i < entities.size(); ++i ) 1033  gid[i] = idoffset++; 1034  1035  rval = m_interface->tag_set_data( idtag, entities, &gid[0] );MB_CHK_ERR( rval ); 1036  1037  return moab::MB_SUCCESS; 1038 }

References entities, ErrorCode, moab::Interface::get_entities_by_dimension(), moab::Remapper::m_interface, MB_CHK_ERR, MB_CHK_SET_ERR, MB_SUCCESS, and moab::Interface::tag_set_data().

Referenced by main().

◆ augment_overlap_set()

moab::ErrorCode moab::TempestRemapper::augment_overlap_set ( )
private

Referenced by ComputeOverlapMesh().

◆ clear()

ErrorCode moab::TempestRemapper::clear ( )
virtual

Deallocate and clear any memory initialized in the TempestRemapper object

Definition at line 106 of file TempestRemapper.cpp.

107 { 108  // destroy all meshes 109  if( m_source ) 110  { 111  delete m_source; 112  m_source = nullptr; 113  } 114  if( m_target ) 115  { 116  delete m_target; 117  m_target = nullptr; 118  } 119  if( m_overlap ) 120  { 121  delete m_overlap; 122  m_overlap = nullptr; 123  } 124  if( m_covering_source && size > 1 ) 125  { 126  delete m_covering_source; 127  m_covering_source = nullptr; 128  } 129  130  point_cloud_source = false; 131  point_cloud_target = false; 132  133  m_source_entities.clear(); 134  m_source_vertices.clear(); 135  m_covering_source_entities.clear(); 136  m_covering_source_vertices.clear(); 137  m_target_entities.clear(); 138  m_target_vertices.clear(); 139  m_overlap_entities.clear(); 140  gid_to_lid_src.clear(); 141  gid_to_lid_tgt.clear(); 142  gid_to_lid_covsrc.clear(); 143  lid_to_gid_src.clear(); 144  lid_to_gid_tgt.clear(); 145  lid_to_gid_covsrc.clear(); 146  147  return MB_SUCCESS; 148 }

References moab::Range::clear(), gid_to_lid_covsrc, gid_to_lid_src, gid_to_lid_tgt, lid_to_gid_covsrc, lid_to_gid_src, lid_to_gid_tgt, m_covering_source, m_covering_source_entities, m_covering_source_vertices, m_overlap, m_overlap_entities, m_source, m_source_entities, m_source_vertices, m_target, m_target_entities, m_target_vertices, MB_SUCCESS, point_cloud_source, point_cloud_target, and size.

Referenced by main(), and ~TempestRemapper().

◆ ComputeGlobalLocalMaps()

ErrorCode moab::TempestRemapper::ComputeGlobalLocalMaps ( )

Compute the local and global IDs for elements in source/target/coverage meshes.

Definition at line 871 of file TempestRemapper.cpp.

872 { 873  ErrorCode rval; 874  875  if( 0 == m_covering_source ) 876  { 877  m_covering_source = new Mesh(); 878  rval = convert_mesh_to_tempest_private( m_covering_source, m_covering_source_set, m_covering_source_entities, 879  &m_covering_source_vertices );MB_CHK_SET_ERR( rval, "Can't convert source Tempest mesh" ); 880  } 881  882 #ifdef VERBOSE 883  m_covering_source->Write( std::string( "coverage_TR_p" + std::to_string( rank ) + ".g" ) ); 884  m_target->Write( std::string( "target_TR_p" + std::to_string( rank ) + ".g" ) ); 885 #endif 886  887  gid_to_lid_src.clear(); 888  lid_to_gid_src.clear(); 889  gid_to_lid_covsrc.clear(); 890  lid_to_gid_covsrc.clear(); 891  gid_to_lid_tgt.clear(); 892  lid_to_gid_tgt.clear(); 893  { 894  Tag gidtag = m_interface->globalId_tag(); 895  896  std::vector< int > gids; 897  if( point_cloud_source ) 898  { 899  gids.resize( m_covering_source_vertices.size(), -1 ); 900  rval = m_interface->tag_get_data( gidtag, m_covering_source_vertices, &gids[0] );MB_CHK_ERR( rval ); 901  } 902  else 903  { 904  gids.resize( m_covering_source_entities.size(), -1 ); 905  rval = m_interface->tag_get_data( gidtag, m_covering_source_entities, &gids[0] );MB_CHK_ERR( rval ); 906  } 907  for( unsigned ie = 0; ie < gids.size(); ++ie ) 908  { 909  gid_to_lid_covsrc[gids[ie]] = ie; 910  lid_to_gid_covsrc[ie] = gids[ie]; 911  } 912  913  if( point_cloud_source ) 914  { 915  gids.resize( m_source_vertices.size(), -1 ); 916  rval = m_interface->tag_get_data( gidtag, m_source_vertices, &gids[0] );MB_CHK_ERR( rval ); 917  } 918  else 919  { 920  gids.resize( m_source_entities.size(), -1 ); 921  rval = m_interface->tag_get_data( gidtag, m_source_entities, &gids[0] );MB_CHK_ERR( rval ); 922  } 923  for( unsigned ie = 0; ie < gids.size(); ++ie ) 924  { 925  gid_to_lid_src[gids[ie]] = ie; 926  lid_to_gid_src[ie] = gids[ie]; 927  } 928  929  if( point_cloud_target ) 930  { 931  gids.resize( m_target_vertices.size(), -1 ); 932  rval = m_interface->tag_get_data( gidtag, m_target_vertices, &gids[0] );MB_CHK_ERR( rval ); 933  } 934  else 935  { 936  gids.resize( m_target_entities.size(), -1 ); 937  rval = m_interface->tag_get_data( gidtag, m_target_entities, &gids[0] );MB_CHK_ERR( rval ); 938  } 939  for( unsigned ie = 0; ie < gids.size(); ++ie ) 940  { 941  gid_to_lid_tgt[gids[ie]] = ie; 942  lid_to_gid_tgt[ie] = gids[ie]; 943  } 944  } 945  946  return MB_SUCCESS; 947 }

References convert_mesh_to_tempest_private(), ErrorCode, gid_to_lid_covsrc, gid_to_lid_src, gid_to_lid_tgt, moab::Interface::globalId_tag(), lid_to_gid_covsrc, lid_to_gid_src, lid_to_gid_tgt, m_covering_source, m_covering_source_entities, m_covering_source_set, m_covering_source_vertices, moab::Remapper::m_interface, m_source_entities, m_source_vertices, m_target, m_target_entities, m_target_vertices, MB_CHK_ERR, MB_CHK_SET_ERR, MB_SUCCESS, point_cloud_source, point_cloud_target, rank, moab::Range::size(), and moab::Interface::tag_get_data().

Referenced by ComputeOverlapMesh().

◆ ComputeOverlapMesh()

ErrorCode moab::TempestRemapper::ComputeOverlapMesh ( bool  kdtree_search = true,
bool  use_tempest = false 
)

Compute the intersection mesh between the source and target grids that have been instantiated in the Remapper. This function invokes the parallel advancing-front intersection algorithm internally for spherical meshes and can handle arbitrary unstructured grids (CS, RLL, ICO, MPAS) with and without holes.

Definition at line 1370 of file TempestRemapper.cpp.

1371 { 1372  ErrorCode rval; 1373  const bool outputEnabled = ( this->rank == 0 ); 1374  moab::DebugOutput dbgprint( std::cout, this->rank, 0 ); 1375  dbgprint.set_prefix( "[ComputeOverlapMesh]: " ); 1376  1377  // const double radius = 1.0 /*2.0*acos(-1.0)*/; 1378  // const double boxeps = 0.1; 1379  // Create the intersection on the sphere object and set up necessary parameters 1380  1381  // First, split based on whether to use Tempest or MOAB 1382  // If Tempest 1383  // 1) Check for valid Mesh and pointers to objects for source/target 1384  // 2) Invoke GenerateOverlapWithMeshes routine from Tempest library 1385  // If MOAB 1386  // 1) Check for valid source and target meshsets (and entities) 1387  // 2) Build processor bounding boxes and construct a covering set 1388  // 3) Perform intersection between the source (covering) and target entities 1389  if( use_tempest ) 1390  { 1391  // Now let us construct the overlap mesh, by calling TempestRemap interface directly 1392  // For the overlap method, choose between: "fuzzy", "exact" or "mixed" 1393  assert( m_source != nullptr ); 1394  assert( m_target != nullptr ); 1395  if( m_overlap != nullptr ) delete m_overlap; 1396  m_overlap = new Mesh(); 1397  bool concaveMeshA = false, concaveMeshB = false; 1398  int err = GenerateOverlapWithMeshes( *m_covering_source, *m_target, *m_overlap, "" /*outFilename*/, "Netcdf4", 1399  "exact", concaveMeshA, concaveMeshB, false ); 1400  if( err ) 1401  { 1402  MB_CHK_SET_ERR( MB_FAILURE, "TempestRemap: Can't compute the intersection of meshes on the sphere" ); 1403  } 1404  } 1405  else 1406  { 1407  // Now perform the actual parallel intersection between the source and the target meshes 1408  if( kdtree_search ) 1409  { 1410  if( outputEnabled ) dbgprint.printf( 0, "Computing intersection mesh with the Kd-tree search algorithm" ); 1411  rval = mbintx->intersect_meshes_kdtree( m_covering_source_set, m_target_set, m_overlap_set );MB_CHK_SET_ERR( rval, "Can't compute the intersection of meshes on the sphere with brute-force" ); 1412  } 1413  else 1414  { 1415  if( outputEnabled ) 1416  dbgprint.printf( 0, "Computing intersection mesh with the advancing-front propagation algorithm" ); 1417  rval = mbintx->intersect_meshes( m_covering_source_set, m_target_set, m_overlap_set );MB_CHK_SET_ERR( rval, "Can't compute the intersection of meshes on the sphere" ); 1418  } 1419  1420 #ifdef MOAB_HAVE_MPI 1421  if( is_parallel || rrmgrids ) 1422  { 1423 #ifdef VERBOSE 1424  std::stringstream ffc, fft, ffo; 1425  ffc << "cover_" << rank << ".h5m"; 1426  fft << "target_" << rank << ".h5m"; 1427  ffo << "intx_" << rank << ".h5m"; 1428  rval = m_interface->write_mesh( ffc.str().c_str(), &m_covering_source_set, 1 );MB_CHK_ERR( rval ); 1429  rval = m_interface->write_mesh( fft.str().c_str(), &m_target_set, 1 );MB_CHK_ERR( rval ); 1430  rval = m_interface->write_mesh( ffo.str().c_str(), &m_overlap_set, 1 );MB_CHK_ERR( rval ); 1431 #endif 1432  // because we do not want to work with elements in coverage set that do not participate 1433  // in intersection, remove them from the coverage set we will not delete them yet, just 1434  // remove from the set ! 1435  if( !point_cloud_target ) 1436  { 1437  Range covEnts; 1438  rval = m_interface->get_entities_by_dimension( m_covering_source_set, 2, covEnts );MB_CHK_ERR( rval ); 1439  1440  std::map< int, int > loc_gid_to_lid_covsrc; 1441  std::vector< int > gids( covEnts.size(), -1 ); 1442  1443  Tag gidtag = m_interface->globalId_tag(); 1444  rval = m_interface->tag_get_data( gidtag, covEnts, gids.data() );MB_CHK_ERR( rval ); 1445  1446  for( unsigned ie = 0; ie < gids.size(); ++ie ) 1447  { 1448  assert( gids[ie] > 0 ); 1449  loc_gid_to_lid_covsrc[gids[ie]] = ie; 1450  } 1451  1452  Range intxCov, intxCells; 1453  Tag srcParentTag; 1454  rval = m_interface->tag_get_handle( "SourceParent", srcParentTag );MB_CHK_ERR( rval ); 1455  rval = m_interface->get_entities_by_dimension( m_overlap_set, 2, intxCells );MB_CHK_ERR( rval ); 1456  for( Range::iterator it = intxCells.begin(); it != intxCells.end(); it++ ) 1457  { 1458  EntityHandle intxCell = *it; 1459  int srcParent = -1; 1460  rval = m_interface->tag_get_data( srcParentTag, &intxCell, 1, &srcParent );MB_CHK_ERR( rval ); 1461  1462  assert( srcParent >= 0 ); 1463  intxCov.insert( covEnts[loc_gid_to_lid_covsrc[srcParent]] ); 1464  } 1465  1466  Range notNeededCovCells = moab::subtract( covEnts, intxCov ); 1467  1468  // now let us get only the covering entities that participate in intersection mesh 1469  covEnts = moab::subtract( covEnts, notNeededCovCells ); 1470  1471  // in order for getting 1-ring neighborhood, we need to be sure that the adjacencies are updated (created) 1472  if( false ) 1473  { 1474  // update all adjacency list 1475  Core* mb = dynamic_cast< Core* >( m_interface ); 1476  AEntityFactory* adj_fact = mb->a_entity_factory(); 1477  if( !adj_fact->vert_elem_adjacencies() ) 1478  adj_fact->create_vert_elem_adjacencies(); 1479  else 1480  { 1481  for( Range::iterator it = covEnts.begin(); it != covEnts.end(); ++it ) 1482  { 1483  EntityHandle eh = *it; 1484  const EntityHandle* conn = nullptr; 1485  int num_nodes = 0; 1486  rval = mb->get_connectivity( eh, conn, num_nodes );MB_CHK_ERR( rval ); 1487  adj_fact->notify_create_entity( eh, conn, num_nodes ); 1488  } 1489  } 1490  1491  // next, for elements on the edge of the partition, get one ring adjacencies 1492  Skinner skinner( mb ); 1493  Range skin; 1494  rval = skinner.find_skin( m_covering_source_set, covEnts, false, skin );MB_CHK_SET_ERR( rval, "Unable to find skin" ); 1495  for( Range::iterator it = skin.begin(); it != skin.end(); ++it ) 1496  { 1497  const EntityHandle* conn = nullptr; 1498  int len = 0; 1499  rval = mb->get_connectivity( *it, conn, len, false );MB_CHK_ERR( rval ); 1500  for( int ie = 0; ie < len; ++ie ) 1501  { 1502  std::vector< EntityHandle > adjacent_entities; 1503  rval = adj_fact->get_adjacencies( conn[ie], 2, false, adjacent_entities );MB_CHK_ERR( rval ); 1504  for( auto ent : adjacent_entities ) 1505  notNeededCovCells.erase( ent ); // ent is part of the 1-ring neighborhood 1506  } 1507  } 1508  1509  rval = m_interface->write_mesh( 1510  std::string( "sourcecoveragemesh_p" + std::to_string( rank ) + ".h5m" ).c_str(), 1511  &m_covering_source_set, 1 );MB_CHK_ERR( rval ); 1512  } 1513  1514  // remove now from coverage set the cells that are not needed 1515  // rval = m_interface->remove_entities( m_covering_source_set, notNeededCovCells );MB_CHK_ERR( rval ); 1516  1517  // Need to loop over covEnts now and ensure at least N-rings are available dependign on whether bilinear (1) or 1518  // high order FV (p) methods are being used for map generation. For bilinear/FV(1): need 1 ring, and for FV(p) 1519  // need p=ring neighborhood to recover exact conservation and consistency wrt serial/parallel. 1520 #ifdef VERBOSE 1521  std::cout << " total participating elements in the covering set: " << intxCov.size() << "\n"; 1522  std::cout << " remove from coverage set elements that are not intersected: " << notNeededCovCells.size() 1523  << "\n"; 1524 #endif 1525  if( size > 1 ) 1526  { 1527  1528  // some source elements cover multiple target partitions; the conservation logic 1529  // requires to know all overlap elements for a source element; they need to be 1530  // communicated from the other target partitions 1531  // 1532  // so first we have to identify source (coverage) elements that cover multiple 1533  // target partitions 1534  // 1535  // we will then mark the source, we will need to migrate the overlap elements 1536  // that cover this to the original source for the source element; then 1537  // distribute the overlap elements to all processors that have the coverage mesh 1538  // used 1539  rval = augment_overlap_set();MB_CHK_ERR( rval ); 1540  } 1541  } 1542  } 1543 #endif 1544  1545  // Fix any inconsistencies in the overlap mesh 1546  { 1547  IntxAreaUtils areaAdaptor; 1548  rval = IntxUtils::fix_degenerate_quads( m_interface, m_overlap_set );MB_CHK_ERR( rval ); 1549  rval = areaAdaptor.positive_orientation( m_interface, m_overlap_set, 1.0 /*radius*/ );MB_CHK_ERR( rval ); 1550  } 1551  1552  // Now let us re-convert the MOAB mesh back to Tempest representation 1553  rval = this->ComputeGlobalLocalMaps();MB_CHK_ERR( rval ); 1554  1555  rval = this->convert_overlap_mesh_sorted_by_source();MB_CHK_ERR( rval ); 1556  1557  // free the memory 1558  delete mbintx; 1559  } 1560  1561  return MB_SUCCESS; 1562 }

References augment_overlap_set(), moab::Range::begin(), ComputeGlobalLocalMaps(), convert_overlap_mesh_sorted_by_source(), moab::AEntityFactory::create_vert_elem_adjacencies(), dbgprint, moab::Range::end(), moab::Range::erase(), ErrorCode, moab::Skinner::find_skin(), moab::IntxUtils::fix_degenerate_quads(), moab::AEntityFactory::get_adjacencies(), moab::Interface::get_entities_by_dimension(), moab::Interface::globalId_tag(), moab::Range::insert(), moab::Intx2Mesh::intersect_meshes(), moab::Intx2Mesh::intersect_meshes_kdtree(), is_parallel, m_covering_source, m_covering_source_set, moab::Remapper::m_interface, m_overlap, m_overlap_set, m_source, m_target, m_target_set, mb, MB_CHK_ERR, MB_CHK_SET_ERR, MB_SUCCESS, mbintx, moab::AEntityFactory::notify_create_entity(), point_cloud_target, moab::IntxAreaUtils::positive_orientation(), rank, rrmgrids, moab::DebugOutput::set_prefix(), moab::Range::size(), size, moab::subtract(), moab::Interface::tag_get_data(), moab::Interface::tag_get_handle(), moab::AEntityFactory::vert_elem_adjacencies(), and moab::Interface::write_mesh().

Referenced by main().

◆ ConstructCoveringSet()

ErrorCode moab::TempestRemapper::ConstructCoveringSet ( double  tolerance = 1e-8,
double  radius_src = 1.0,
double  radius_tgt = 1.0,
double  boxeps = 0.1,
bool  regional_mesh = false,
bool  gnomonic = true,
int  nb_ghost_layers = 0 
)

Construct a source covering mesh such that it completely encompasses the target grid in parallel. This operation is critical to ensure that the parallel advancing-front intersection algorithm can compute the intersection mesh only locally without any process communication.

Definition at line 1229 of file TempestRemapper.cpp.

1236 { 1237  ErrorCode rval; 1238  1239  rrmgrids = regional_mesh; 1240  moab::Range local_verts; 1241  1242  // Initialize intersection context 1243  mbintx = new moab::Intx2MeshOnSphere( m_interface, moab::IntxAreaUtils::GaussQuadrature ); 1244  1245  mbintx->set_error_tolerance( tolerance ); 1246  mbintx->set_radius_source_mesh( radius_src ); 1247  mbintx->set_radius_destination_mesh( radius_tgt ); 1248  mbintx->set_box_error( boxeps ); 1249 #ifdef MOAB_HAVE_MPI 1250  mbintx->set_parallel_comm( m_pcomm ); 1251 #endif 1252  1253  // compute the maxiumum edges in elements comprising source and target mesh 1254  rval = mbintx->FindMaxEdges( m_source_set, m_target_set );MB_CHK_ERR( rval ); 1255  1256  this->max_source_edges = mbintx->max_edges_1; 1257  this->max_target_edges = mbintx->max_edges_2; 1258  1259  // Note: lots of communication possible, if mesh is distributed very differently 1260 #ifdef MOAB_HAVE_MPI 1261  if( is_parallel ) 1262  { 1263  rval = mbintx->build_processor_euler_boxes( m_target_set, local_verts, gnomonic );MB_CHK_ERR( rval ); 1264  1265  rval = m_interface->create_meshset( moab::MESHSET_SET, m_covering_source_set );MB_CHK_SET_ERR( rval, "Can't create new set" ); 1266  1267  rval = mbintx->construct_covering_set( m_source_set, m_covering_source_set, gnomonic, nb_ghost_layers );MB_CHK_ERR( rval ); 1268 #ifdef MOAB_DBG 1269  std::stringstream filename; 1270  filename << "covering" << rank << ".h5m"; 1271  rval = m_interface->write_file( filename.str().c_str(), 0, 0, &m_covering_source_set, 1 );MB_CHK_ERR( rval ); 1272  std::stringstream targetFile; 1273  targetFile << "target" << rank << ".h5m"; 1274  rval = m_interface->write_file( targetFile.str().c_str(), 0, 0, &m_target_set, 1 );MB_CHK_ERR( rval ); 1275 #endif 1276  } 1277  else 1278  { 1279 #endif 1280  if( rrmgrids ) 1281  { 1282  rval = m_interface->create_meshset( moab::MESHSET_SET, m_covering_source_set );MB_CHK_SET_ERR( rval, "Can't create new set" ); 1283  1284  double tolerance = 1e-6, btolerance = 1e-3; 1285  moab::AdaptiveKDTree tree( m_interface ); 1286  moab::Range targetVerts; 1287  1288  rval = m_interface->get_connectivity( m_target_entities, targetVerts, true );MB_CHK_ERR( rval ); 1289  1290  rval = tree.build_tree( m_source_entities, &m_source_set );MB_CHK_ERR( rval ); 1291  1292  for( unsigned ie = 0; ie < targetVerts.size(); ++ie ) 1293  { 1294  EntityHandle el = targetVerts[ie], leaf; 1295  double point[3]; 1296  1297  // Get the element centroid to be queried 1298  rval = m_interface->get_coords( &el, 1, point );MB_CHK_ERR( rval ); 1299  1300  // Search for the closest source element in the master mesh corresponding 1301  // to the target element centroid in the slave mesh 1302  rval = tree.point_search( point, leaf, tolerance, btolerance );MB_CHK_ERR( rval ); 1303  1304  if( leaf == 0 ) 1305  { 1306  leaf = m_source_set; // no hint 1307  } 1308  1309  std::vector< moab::EntityHandle > leaf_elems; 1310  // We only care about the dimension that the user specified. 1311  // MOAB partitions are ordered by elements anyway. 1312  rval = m_interface->get_entities_by_dimension( leaf, 2, leaf_elems );MB_CHK_ERR( rval ); 1313  1314  if( !leaf_elems.size() ) 1315  { 1316  // std::cout << ie << ": " << " No leaf elements found." << std::endl; 1317  continue; 1318  } 1319  1320  // Now get the master element centroids so that we can compute 1321  // the minimum distance to the target point 1322  std::vector< double > centroids( leaf_elems.size() * 3 ); 1323  rval = m_interface->get_coords( &leaf_elems[0], leaf_elems.size(), &centroids[0] );MB_CHK_ERR( rval ); 1324  1325  double dist = 1e5; 1326  int pinelem = -1; 1327  for( size_t il = 0; il < leaf_elems.size(); ++il ) 1328  { 1329  const double* centroid = &centroids[il * 3]; 1330  const double locdist = std::pow( point[0] - centroid[0], 2 ) + 1331  std::pow( point[1] - centroid[1], 2 ) + 1332  std::pow( point[2] - centroid[2], 2 ); 1333  1334  if( locdist < dist ) 1335  { 1336  dist = locdist; 1337  pinelem = il; 1338  m_covering_source_entities.insert( leaf_elems[il] ); 1339  } 1340  } 1341  1342  if( pinelem < 0 ) 1343  { 1344  std::cout << ie 1345  << ": [Error] - Could not find a minimum distance within the leaf " 1346  "nodes. Dist = " 1347  << dist << std::endl; 1348  } 1349  } 1350  // rval = tree.reset_tree();MB_CHK_ERR(rval); 1351  std::cout << "[INFO] - Total covering source entities = " << m_covering_source_entities.size() << std::endl; 1352  rval = m_interface->add_entities( m_covering_source_set, m_covering_source_entities );MB_CHK_ERR( rval ); 1353  } 1354  else 1355  { 1356  m_covering_source_set = m_source_set; 1357  m_covering_source = m_source; 1358  m_covering_source_entities = m_source_entities; // this is a tempest mesh object; careful about 1359  // incrementing the reference? 1360  m_covering_source_vertices = m_source_vertices; // this is a tempest mesh object; careful about 1361  // incrementing the reference? 1362  } 1363 #ifdef MOAB_HAVE_MPI 1364  } 1365 #endif 1366  1367  return rval; 1368 }

References moab::Interface::add_entities(), moab::AdaptiveKDTree::build_tree(), moab::Interface::create_meshset(), ErrorCode, moab::Intx2Mesh::FindMaxEdges(), moab::IntxAreaUtils::GaussQuadrature, moab::Interface::get_connectivity(), moab::Interface::get_coords(), moab::Interface::get_entities_by_dimension(), moab::Range::insert(), is_parallel, m_covering_source, m_covering_source_entities, m_covering_source_set, m_covering_source_vertices, moab::Remapper::m_interface, m_source, m_source_entities, m_source_set, m_source_vertices, m_target_entities, m_target_set, moab::Intx2Mesh::max_edges_1, moab::Intx2Mesh::max_edges_2, max_source_edges, max_target_edges, MB_CHK_ERR, MB_CHK_SET_ERR, mbintx, MESHSET_SET, moab::AdaptiveKDTree::point_search(), rank, rrmgrids, moab::Intx2Mesh::set_box_error(), moab::Intx2Mesh::set_error_tolerance(), moab::Intx2MeshOnSphere::set_radius_destination_mesh(), moab::Intx2MeshOnSphere::set_radius_source_mesh(), moab::Range::size(), moab::tolerance, and moab::Interface::write_file().

Referenced by main().

◆ convert_mesh_to_tempest_private()

ErrorCode moab::TempestRemapper::convert_mesh_to_tempest_private ( Mesh *  mesh,
moab::EntityHandle  meshset,
moab::Range entities,
moab::Range pverts 
)
private

Definition at line 584 of file TempestRemapper.cpp.

588 { 589  ErrorCode rval; 590  Range verts; 591  592  NodeVector& nodes = mesh->nodes; 593  FaceVector& faces = mesh->faces; 594  595  elems.clear(); 596  rval = m_interface->get_entities_by_dimension( mesh_set, 2, elems );MB_CHK_ERR( rval ); 597  598  const size_t nelems = elems.size(); 599  600  // resize the number of elements in Tempest mesh 601  faces.resize( nelems ); 602  603  // let us now get the vertices from all the elements 604  rval = m_interface->get_connectivity( elems, verts );MB_CHK_ERR( rval ); 605  if( verts.size() == 0 ) 606  { 607  rval = m_interface->get_entities_by_dimension( mesh_set, 0, verts );MB_CHK_ERR( rval ); 608  } 609  // assert(verts.size() > 0); // If not, this may be an invalid mesh ! possible for unbalanced loads 610  611  std::map< EntityHandle, int > indxMap; 612  bool useRange = true; 613  if( verts.compactness() > 0.01 ) 614  { 615  int j = 0; 616  for( Range::iterator it = verts.begin(); it != verts.end(); it++ ) 617  indxMap[*it] = j++; 618  useRange = false; 619  } 620  621  std::vector< int > globIds( nelems ); 622  moab::Tag gid = m_interface->globalId_tag(); 623  rval = m_interface->tag_get_data( gid, elems, &globIds[0] );MB_CHK_ERR( rval ); 624  std::vector< size_t > sortedIdx; 625  if( offlineWorkflow ) 626  { 627  sortedIdx.resize( nelems ); 628  // initialize original index locations 629  std::iota( sortedIdx.begin(), sortedIdx.end(), 0 ); 630  // sort indexes based on comparing values in v, using std::stable_sort instead of std::sort 631  // to avoid unnecessary index re-orderings when v contains elements of equal values 632  std::sort( sortedIdx.begin(), sortedIdx.end(), 633  [&globIds]( size_t i1, size_t i2 ) { return globIds[i1] < globIds[i2]; } ); 634  } 635  636  for( unsigned iface = 0; iface < nelems; ++iface ) 637  { 638  Face& face = faces[iface]; 639  EntityHandle ehandle = ( offlineWorkflow ? elems[sortedIdx[iface]] : elems[iface] ); 640  641  // get the connectivity for each edge 642  const EntityHandle* connectface; 643  int nnodesf; 644  rval = m_interface->get_connectivity( ehandle, connectface, nnodesf );MB_CHK_ERR( rval ); 645  // account for padded polygons 646  while( connectface[nnodesf - 2] == connectface[nnodesf - 1] && nnodesf > 3 ) 647  nnodesf--; 648  649  face.edges.resize( nnodesf ); 650  for( int iverts = 0; iverts < nnodesf; ++iverts ) 651  { 652  int indx = ( useRange ? verts.index( connectface[iverts] ) : indxMap[connectface[iverts]] ); 653  assert( indx >= 0 ); 654  face.SetNode( iverts, indx ); 655  } 656  } 657  658  unsigned nnodes = verts.size(); 659  nodes.resize( nnodes ); 660  661  // Set the data for the vertices 662  std::vector< double > coordx( nnodes ), coordy( nnodes ), coordz( nnodes ); 663  rval = m_interface->get_coords( verts, &coordx[0], &coordy[0], &coordz[0] );MB_CHK_ERR( rval ); 664  for( unsigned inode = 0; inode < nnodes; ++inode ) 665  { 666  Node& node = nodes[inode]; 667  node.x = coordx[inode]; 668  node.y = coordy[inode]; 669  node.z = coordz[inode]; 670  } 671  coordx.clear(); 672  coordy.clear(); 673  coordz.clear(); 674  675  mesh->RemoveCoincidentNodes(); 676  mesh->RemoveZeroEdges(); 677  678  // Generate reverse node array and edge map 679  if( constructEdgeMap ) mesh->ConstructEdgeMap( false ); 680  // mesh->ConstructReverseNodeArray(); 681  682  // mesh->Validate(); 683  684  if( pverts ) 685  { 686  pverts->clear(); 687  *pverts = verts; 688  } 689  verts.clear(); 690  691  return MB_SUCCESS; 692 }

References moab::Range::begin(), moab::Range::clear(), moab::Range::compactness(), constructEdgeMap, moab::Range::end(), ErrorCode, moab::Interface::get_connectivity(), moab::Interface::get_coords(), moab::Interface::get_entities_by_dimension(), moab::Interface::globalId_tag(), iface, moab::Range::index(), moab::Remapper::m_interface, MB_CHK_ERR, MB_SUCCESS, offlineWorkflow, moab::Range::size(), and moab::Interface::tag_get_data().

Referenced by ComputeGlobalLocalMaps(), ConvertMeshToTempest(), and ResetMeshSet().

◆ convert_overlap_mesh_sorted_by_source()

ErrorCode moab::TempestRemapper::convert_overlap_mesh_sorted_by_source ( )
private

Definition at line 744 of file TempestRemapper.cpp.

745 { 746  ErrorCode rval; 747  748  m_overlap_entities.clear(); 749  rval = m_interface->get_entities_by_dimension( m_overlap_set, 2, m_overlap_entities );MB_CHK_ERR( rval ); 750  751  // Allocate for the overlap mesh 752  if( !m_overlap ) m_overlap = new Mesh(); 753  754  size_t n_overlap_entitites = m_overlap_entities.size(); 755  756  std::vector< std::array< int, 3 > > sorted_overlap_order( n_overlap_entitites, 757  std::array< int, 3 >( { -1, -1, -1 } ) ); 758  { 759  Tag srcParentTag, tgtParentTag; 760  rval = m_interface->tag_get_handle( "SourceParent", srcParentTag );MB_CHK_ERR( rval ); 761  rval = m_interface->tag_get_handle( "TargetParent", tgtParentTag );MB_CHK_ERR( rval ); 762  // Overlap mesh: resize the source and target connection arrays 763  m_overlap->vecTargetFaceIx.resize( n_overlap_entitites ); 764  m_overlap->vecSourceFaceIx.resize( n_overlap_entitites ); 765  766  // Overlap mesh: resize the source and target connection arrays 767  std::vector< int > rbids_src( n_overlap_entitites ), rbids_tgt( n_overlap_entitites ); 768  rval = m_interface->tag_get_data( srcParentTag, m_overlap_entities, &rbids_src[0] );MB_CHK_ERR( rval ); 769  rval = m_interface->tag_get_data( tgtParentTag, m_overlap_entities, &rbids_tgt[0] );MB_CHK_ERR( rval ); 770  for( size_t ix = 0; ix < n_overlap_entitites; ++ix ) 771  { 772  std::get< 0 >( sorted_overlap_order[ix] ) = ix; 773  std::get< 1 >( sorted_overlap_order[ix] ) = 774  ( gid_to_lid_covsrc.size() ? gid_to_lid_covsrc[rbids_src[ix]] : rbids_src[ix] - 1 ); 775  std::get< 2 >( sorted_overlap_order[ix] ) = 776  ( gid_to_lid_tgt.size() ? gid_to_lid_tgt[rbids_tgt[ix]] : rbids_tgt[ix] - 1 ); 777  } 778  std::sort( sorted_overlap_order.begin(), sorted_overlap_order.end(), IntPairComparator ); 779  // sorted_overlap_order[ie].second , ie=0,nOverlap-1 is the order such that overlap elems 780  // are ordered by source parent 781  782  std::vector< int > ghFlags; 783  if( is_parallel && size > 1 ) 784  { 785  Tag ghostTag; 786  ghFlags.resize( n_overlap_entitites ); 787  rval = m_interface->tag_get_handle( "ORIG_PROC", ghostTag );MB_CHK_ERR( rval ); 788  rval = m_interface->tag_get_data( ghostTag, m_overlap_entities, &ghFlags[0] );MB_CHK_ERR( rval ); 789  } 790  for( unsigned ie = 0; ie < n_overlap_entitites; ++ie ) 791  { 792  int ix = std::get< 0 >( sorted_overlap_order[ie] ); // original index of the element 793  m_overlap->vecSourceFaceIx[ie] = std::get< 1 >( sorted_overlap_order[ie] ); 794  if( is_parallel && size > 1 && ghFlags[ix] >= 0 ) // it means it is a ghost overlap element 795  m_overlap->vecTargetFaceIx[ie] = -1; // this should not participate in smat! 796  else 797  m_overlap->vecTargetFaceIx[ie] = std::get< 2 >( sorted_overlap_order[ie] ); 798  } 799  } 800  801  FaceVector& faces = m_overlap->faces; 802  faces.resize( n_overlap_entitites ); 803  804  Range verts; 805  // let us now get the vertices from all the elements 806  rval = m_interface->get_connectivity( m_overlap_entities, verts );MB_CHK_ERR( rval ); 807  // std::cout << "Vertices size = " << verts.size() << " , psize = " << verts.psize() << ", 808  // compactness = " << verts.compactness() << std::endl; 809  810  std::map< EntityHandle, int > indxMap; 811  { 812  int j = 0; 813  for( Range::iterator it = verts.begin(); it != verts.end(); ++it ) 814  indxMap[*it] = j++; 815  } 816  817  for( unsigned ifac = 0; ifac < m_overlap_entities.size(); ++ifac ) 818  { 819  const unsigned iface = std::get< 0 >( sorted_overlap_order[ifac] ); 820  Face& face = faces[ifac]; 821  EntityHandle ehandle = m_overlap_entities[iface]; 822  823  // get the connectivity for each edge 824  const EntityHandle* connectface; 825  int nnodesf; 826  rval = m_interface->get_connectivity( ehandle, connectface, nnodesf );MB_CHK_ERR( rval ); 827  828  face.edges.resize( nnodesf ); 829  for( int iverts = 0; iverts < nnodesf; ++iverts ) 830  { 831  int indx = indxMap[connectface[iverts]]; 832  assert( indx >= 0 ); 833  face.SetNode( iverts, indx ); 834  } 835  } 836  indxMap.clear(); 837  838  sorted_overlap_order.clear(); 839  840  unsigned nnodes = verts.size(); 841  NodeVector& nodes = m_overlap->nodes; 842  nodes.resize( nnodes ); 843  844  // Set the data for the vertices 845  std::vector< double > coordx( nnodes ), coordy( nnodes ), coordz( nnodes ); 846  rval = m_interface->get_coords( verts, &coordx[0], &coordy[0], &coordz[0] );MB_CHK_ERR( rval ); 847  for( unsigned inode = 0; inode < nnodes; ++inode ) 848  { 849  Node& node = nodes[inode]; 850  node.x = coordx[inode]; 851  node.y = coordy[inode]; 852  node.z = coordz[inode]; 853  } 854  coordx.clear(); 855  coordy.clear(); 856  coordz.clear(); 857  verts.clear(); 858  859  // m_overlap->RemoveZeroEdges(); 860  // m_overlap->RemoveCoincidentNodes( false ); 861  862  // Generate reverse node array and edge map 863  // if ( constructEdgeMap ) m_overlap->ConstructEdgeMap(false); 864  // m_overlap->ConstructReverseNodeArray(); 865  866  m_overlap->Validate(); 867  return MB_SUCCESS; 868 }

References moab::Range::begin(), moab::Range::clear(), moab::Range::end(), ErrorCode, moab::Interface::get_connectivity(), moab::Interface::get_coords(), moab::Interface::get_entities_by_dimension(), gid_to_lid_covsrc, gid_to_lid_tgt, iface, moab::IntPairComparator(), is_parallel, moab::Remapper::m_interface, m_overlap, m_overlap_entities, m_overlap_set, MB_CHK_ERR, MB_SUCCESS, moab::Range::size(), size, moab::Interface::tag_get_data(), and moab::Interface::tag_get_handle().

Referenced by ComputeOverlapMesh(), and ConvertMeshToTempest().

◆ convert_tempest_mesh_private()

ErrorCode moab::TempestRemapper::convert_tempest_mesh_private ( TempestMeshType  type,
Mesh *  mesh,
moab::EntityHandle meshset,
moab::Range entities,
moab::Range vertices 
)
private

Definition at line 255 of file TempestRemapper.cpp.

260 { 261  ErrorCode rval; 262  const bool outputEnabled = ( TempestRemapper::verbose && is_root ); 263  const NodeVector& nodes = mesh->nodes; 264  const FaceVector& faces = mesh->faces; 265  266  moab::DebugOutput dbgprint( std::cout, this->rank, 0 ); 267  dbgprint.set_prefix( "[TempestToMOAB]: " ); 268  269  ReadUtilIface* iface; 270  rval = m_interface->query_interface( iface );MB_CHK_SET_ERR( rval, "Can't get reader interface" ); 271  272  Tag gidTag = m_interface->globalId_tag(); 273  274  // Set the data for the vertices 275  std::vector< double* > arrays; 276  std::vector< int > gidsv( nodes.size() ); 277  EntityHandle startv; 278  rval = iface->get_node_coords( 3, nodes.size(), 0, startv, arrays );MB_CHK_SET_ERR( rval, "Can't get node coords" ); 279  for( unsigned iverts = 0; iverts < nodes.size(); ++iverts ) 280  { 281  const Node& node = nodes[iverts]; 282  arrays[0][iverts] = node.x; 283  arrays[1][iverts] = node.y; 284  arrays[2][iverts] = node.z; 285  gidsv[iverts] = iverts + 1; 286  } 287  Range mbverts( startv, startv + nodes.size() - 1 ); 288  rval = m_interface->add_entities( mesh_set, mbverts );MB_CHK_SET_ERR( rval, "Can't add entities" ); 289  rval = m_interface->tag_set_data( gidTag, mbverts, &gidsv[0] );MB_CHK_SET_ERR( rval, "Can't set global_id tag" ); 290  291  gidsv.clear(); 292  entities.clear(); 293  294  Tag srcParentTag, tgtParentTag; 295  std::vector< int > srcParent( faces.size(), -1 ), tgtParent( faces.size(), -1 ); 296  std::vector< int > gidse( faces.size(), -1 ); 297  bool storeParentInfo = ( mesh->vecSourceFaceIx.size() > 0 ); 298  299  if( storeParentInfo ) 300  { 301  int defaultInt = -1; 302  rval = m_interface->tag_get_handle( "TargetParent", 1, MB_TYPE_INTEGER, tgtParentTag, 303  MB_TAG_DENSE | MB_TAG_CREAT, &defaultInt );MB_CHK_SET_ERR( rval, "can't create positive tag" ); 304  305  rval = m_interface->tag_get_handle( "SourceParent", 1, MB_TYPE_INTEGER, srcParentTag, 306  MB_TAG_DENSE | MB_TAG_CREAT, &defaultInt );MB_CHK_SET_ERR( rval, "can't create negative tag" ); 307  } 308  309  // Let us first perform a full pass assuming arbitrary polygons. This is especially true for 310  // overlap meshes. 311  // 1. We do a first pass over faces, decipher edge size and group into categories based on 312  // element type 313  // 2. Next we loop over type, and add blocks of elements into MOAB 314  // 3. For each block within the loop, also update the connectivity of elements. 315  { 316  if( outputEnabled ) 317  dbgprint.printf( 0, "..Mesh size: Nodes [%zu] Elements [%zu].\n", nodes.size(), faces.size() ); 318  std::vector< EntityHandle > mbcells( faces.size() ); 319  unsigned ntris = 0, nquads = 0, npolys = 0; 320  std::vector< EntityHandle > conn( 16 ); 321  322  for( unsigned ifaces = 0; ifaces < faces.size(); ++ifaces ) 323  { 324  const Face& face = faces[ifaces]; 325  const unsigned num_v_per_elem = face.edges.size(); 326  327  for( unsigned iedges = 0; iedges < num_v_per_elem; ++iedges ) 328  { 329  conn[iedges] = startv + face.edges[iedges].node[0]; 330  } 331  332  switch( num_v_per_elem ) 333  { 334  case 3: 335  // if( outputEnabled ) 336  // dbgprint.printf( 0, "....Block %d: Triangular Elements [%u].\n", iBlock++, nPolys[iType] ); 337  rval = m_interface->create_element( MBTRI, &conn[0], num_v_per_elem, mbcells[ifaces] );MB_CHK_SET_ERR( rval, "Can't get element connectivity" ); 338  ntris++; 339  break; 340  case 4: 341  // if( outputEnabled ) 342  // dbgprint.printf( 0, "....Block %d: Quadrilateral Elements [%u].\n", iBlock++, nPolys[iType] ); 343  rval = m_interface->create_element( MBQUAD, &conn[0], num_v_per_elem, mbcells[ifaces] );MB_CHK_SET_ERR( rval, "Can't get element connectivity" ); 344  nquads++; 345  break; 346  default: 347  // if( outputEnabled ) 348  // dbgprint.printf( 0, "....Block %d: Polygonal [%u] Elements [%u].\n", iBlock++, iType, 349  // nPolys[iType] ); 350  rval = m_interface->create_element( MBPOLYGON, &conn[0], num_v_per_elem, mbcells[ifaces] );MB_CHK_SET_ERR( rval, "Can't get element connectivity" ); 351  npolys++; 352  break; 353  } 354  355  gidse[ifaces] = ifaces + 1; 356  357  if( storeParentInfo ) 358  { 359  srcParent[ifaces] = mesh->vecSourceFaceIx[ifaces] + 1; 360  tgtParent[ifaces] = mesh->vecTargetFaceIx[ifaces] + 1; 361  } 362  } 363  364  if( ntris ) dbgprint.printf( 0, "....Triangular Elements [%u].\n", ntris ); 365  if( nquads ) dbgprint.printf( 0, "....Quadrangular Elements [%u].\n", nquads ); 366  if( npolys ) dbgprint.printf( 0, "....Polygonal Elements [%u].\n", npolys ); 367  368  rval = m_interface->add_entities( mesh_set, &mbcells[0], mbcells.size() );MB_CHK_SET_ERR( rval, "Could not add entities" ); 369  370  rval = m_interface->tag_set_data( gidTag, &mbcells[0], mbcells.size(), &gidse[0] );MB_CHK_SET_ERR( rval, "Can't set global_id tag" ); 371  if( storeParentInfo ) 372  { 373  rval = m_interface->tag_set_data( srcParentTag, &mbcells[0], mbcells.size(), &srcParent[0] );MB_CHK_SET_ERR( rval, "Can't set tag data" ); 374  rval = m_interface->tag_set_data( tgtParentTag, &mbcells[0], mbcells.size(), &tgtParent[0] );MB_CHK_SET_ERR( rval, "Can't set tag data" ); 375  } 376  377  // insert from mbcells to entities to preserve ordering 378  std::copy( mbcells.begin(), mbcells.end(), range_inserter( entities ) ); 379  } 380  381  if( vertices ) *vertices = mbverts; 382  383  return MB_SUCCESS; 384 }

References moab::Interface::add_entities(), moab::Interface::create_element(), dbgprint, entities, ErrorCode, moab::Interface::globalId_tag(), iface, is_root, moab::Remapper::m_interface, MB_CHK_SET_ERR, MB_SUCCESS, MB_TAG_CREAT, MB_TAG_DENSE, MB_TYPE_INTEGER, MBPOLYGON, MBQUAD, MBTRI, moab::Interface::query_interface(), rank, moab::DebugOutput::set_prefix(), moab::Interface::tag_get_handle(), moab::Interface::tag_set_data(), and verbose.

Referenced by ConvertTempestMesh().

◆ ConvertMeshToTempest()

ErrorCode moab::TempestRemapper::ConvertMeshToTempest ( Remapper::IntersectionContext  ctx)

Convert the MOAB mesh representation to a corresponding TempestRemap mesh object according to the intersection context.

Definition at line 545 of file TempestRemapper.cpp.

546 { 547  ErrorCode rval; 548  const bool outputEnabled = ( TempestRemapper::verbose && is_root ); 549  550  moab::DebugOutput dbgprint( std::cout, this->rank, 0 ); 551  dbgprint.set_prefix( "[MOABToTempest]: " ); 552  553  if( ctx == Remapper::SourceMesh ) 554  { 555  if( !m_source ) m_source = new Mesh(); 556  if( outputEnabled ) dbgprint.printf( 0, "Converting (source) MOAB to TempestRemap Mesh representation ...\n" ); 557  rval = convert_mesh_to_tempest_private( m_source, m_source_set, m_source_entities, &m_source_vertices );MB_CHK_SET_ERR( rval, "Can't convert source mesh to Tempest" ); 558  if( m_source_entities.size() == 0 && m_source_vertices.size() != 0 ) 559  { 560  this->point_cloud_source = true; 561  } 562  } 563  else if( ctx == Remapper::TargetMesh ) 564  { 565  if( !m_target ) m_target = new Mesh(); 566  if( outputEnabled ) dbgprint.printf( 0, "Converting (target) MOAB to TempestRemap Mesh representation ...\n" ); 567  rval = convert_mesh_to_tempest_private( m_target, m_target_set, m_target_entities, &m_target_vertices );MB_CHK_SET_ERR( rval, "Can't convert target mesh to Tempest" ); 568  if( m_target_entities.size() == 0 && m_target_vertices.size() != 0 ) this->point_cloud_target = true; 569  } 570  else if( ctx == Remapper::OverlapMesh ) // Overlap mesh 571  { 572  if( !m_overlap ) m_overlap = new Mesh(); 573  if( outputEnabled ) dbgprint.printf( 0, "Converting (overlap) MOAB to TempestRemap Mesh representation ...\n" ); 574  rval = convert_overlap_mesh_sorted_by_source();MB_CHK_SET_ERR( rval, "Can't convert overlap mesh to Tempest" ); 575  } 576  else 577  { 578  MB_CHK_SET_ERR( MB_FAILURE, "Invalid IntersectionContext context provided" ); 579  } 580  581  return rval; 582 }

References convert_mesh_to_tempest_private(), convert_overlap_mesh_sorted_by_source(), dbgprint, ErrorCode, is_root, m_overlap, m_source, m_source_entities, m_source_set, m_source_vertices, m_target, m_target_entities, m_target_set, m_target_vertices, MB_CHK_SET_ERR, moab::Remapper::OverlapMesh, point_cloud_source, point_cloud_target, rank, moab::DebugOutput::set_prefix(), moab::Range::size(), moab::Remapper::SourceMesh, moab::Remapper::TargetMesh, and verbose.

Referenced by CreateTempestMesh(), and main().

◆ ConvertTempestMesh()

ErrorCode moab::TempestRemapper::ConvertTempestMesh ( Remapper::IntersectionContext  ctx)

Convert the TempestRemap mesh object to a corresponding MOAB mesh representation according to the intersection context.

Definition at line 226 of file TempestRemapper.cpp.

227 { 228  const bool outputEnabled = ( TempestRemapper::verbose && is_root ); 229  if( ctx == Remapper::SourceMesh ) 230  { 231  if( outputEnabled ) std::cout << "Converting (source) TempestRemap Mesh object to MOAB representation ...\n"; 232  return convert_tempest_mesh_private( m_source_type, m_source, m_source_set, m_source_entities, 233  &m_source_vertices ); 234  } 235  else if( ctx == Remapper::TargetMesh ) 236  { 237  if( outputEnabled ) std::cout << "Converting (target) TempestRemap Mesh object to MOAB representation ...\n"; 238  return convert_tempest_mesh_private( m_target_type, m_target, m_target_set, m_target_entities, 239  &m_target_vertices ); 240  } 241  else if( ctx != Remapper::DEFAULT ) 242  { 243  if( outputEnabled ) std::cout << "Converting (overlap) TempestRemap Mesh object to MOAB representation ...\n"; 244  return convert_tempest_mesh_private( m_overlap_type, m_overlap, m_overlap_set, m_overlap_entities, nullptr ); 245  } 246  else 247  { 248  MB_CHK_SET_ERR( MB_FAILURE, "Invalid IntersectionContext context provided" ); 249  } 250 }

References convert_tempest_mesh_private(), moab::Remapper::DEFAULT, is_root, m_overlap, m_overlap_entities, m_overlap_set, m_overlap_type, m_source, m_source_entities, m_source_set, m_source_type, m_source_vertices, m_target, m_target_entities, m_target_set, m_target_type, m_target_vertices, MB_CHK_SET_ERR, moab::Remapper::SourceMesh, moab::Remapper::TargetMesh, and verbose.

Referenced by main().

◆ GenerateCSMeshMetadata()

ErrorCode moab::TempestRemapper::GenerateCSMeshMetadata ( const int  ntot_elements,
moab::Range entities,
moab::Range secondary_entities,
const std::string &  dofTagName,
int  nP 
)

Generate the necessary metadata and specifically the GLL node numbering for DoFs for a CS mesh. This negates the need for running external code like HOMME to output the numbering needed for computing maps. The functionality is used through the mbconvert tool to compute processor-invariant Global DoF IDs at GLL nodes.

Definition at line 1049 of file TempestRemapper.cpp.

1054 { 1055  Mesh csMesh; 1056  int err; 1057  moab::ErrorCode rval; 1058  1059  const int csResolution = std::sqrt( ntot_elements / 6.0 ); 1060  1061  if( csResolution * csResolution * 6 != ntot_elements ) return MB_INVALID_SIZE; 1062  1063  // Create a temporary Cubed-Sphere mesh 1064  // NOTE: This will not work for RRM grids. Need to run HOMME for that case anyway 1065  err = GenerateCSMesh( csMesh, csResolution, "", "NetCDF4" );MB_CHK_SET_ERR( err ? MB_FAILURE : MB_SUCCESS, "Failed to generate CS mesh through TempestRemap" ); 1066  1067  rval = this->GenerateMeshMetadata( csMesh, ntot_elements, ents, secondary_ents, dofTagName, nP );MB_CHK_SET_ERR( rval, "Failed in call to GenerateMeshMetadata" ); 1068  1069  return moab::MB_SUCCESS; 1070 }

References ErrorCode, GenerateMeshMetadata(), MB_CHK_SET_ERR, MB_INVALID_SIZE, and MB_SUCCESS.

◆ GenerateMesh()

moab::ErrorCode moab::TempestRemapper::GenerateMesh ( Remapper::IntersectionContext  ctx,
TempestMeshType  type 
)

Generate a mesh in memory of given type (CS/RLL/ICO/MPAS(structured)) and store it under the context specified by the user.

◆ GenerateMeshMetadata()

ErrorCode moab::TempestRemapper::GenerateMeshMetadata ( Mesh &  mesh,
const int  ntot_elements,
moab::Range entities,
moab::Range secondary_entities,
const std::string  dofTagName,
int  nP 
)

Generate the necessary metadata for DoF node numbering in a given mesh. Currently, only the functionality to generate numbering on CS grids is supported.

Definition at line 1072 of file TempestRemapper.cpp.

1078 { 1079  moab::ErrorCode rval; 1080  1081  Tag dofTag; 1082  bool created = false; 1083  rval = m_interface->tag_get_handle( dofTagName.c_str(), nP * nP, MB_TYPE_INTEGER, dofTag, 1084  MB_TAG_DENSE | MB_TAG_CREAT, 0, &created );MB_CHK_SET_ERR( rval, "Failed creating DoF tag" ); 1085  1086  // Number of Faces 1087  int nElements = static_cast< int >( csMesh.faces.size() ); 1088  1089  if( nElements != ntot_elements ) return MB_INVALID_SIZE; 1090  1091  // Initialize data structures 1092  DataArray3D< int > dataGLLnodes; 1093  dataGLLnodes.Allocate( nP, nP, nElements ); 1094  1095  std::map< Node, int > mapNodes; 1096  std::map< Node, moab::EntityHandle > mapLocalMBNodes; 1097  1098  // GLL Quadrature nodes 1099  DataArray1D< double > dG; 1100  DataArray1D< double > dW; 1101  GaussLobattoQuadrature::GetPoints( nP, 0.0, 1.0, dG, dW ); 1102  1103  moab::Range entities( ents ); 1104  if( secondary_ents ) entities.insert( secondary_ents->begin(), secondary_ents->end() ); 1105  double elcoords[3]; 1106  for( unsigned iel = 0; iel < entities.size(); ++iel ) 1107  { 1108  EntityHandle eh = entities[iel]; 1109  rval = m_interface->get_coords( &eh, 1, elcoords ); 1110  Node elCentroid( elcoords[0], elcoords[1], elcoords[2] ); 1111  mapLocalMBNodes.insert( std::pair< Node, moab::EntityHandle >( elCentroid, eh ) ); 1112  } 1113  1114  // Build a Kd-tree for local mesh (nearest neighbor searches) 1115  // Loop over all elements in CS-Mesh 1116  // Then find if current centroid is in an element 1117  // If yes - then let us compute the DoF numbering and set to tag data 1118  // If no - then compute DoF numbering BUT DO NOT SET to tag data 1119  // continue 1120  int* dofIDs = new int[nP * nP]; 1121  1122  // Write metadata 1123  for( int k = 0; k < nElements; k++ ) 1124  { 1125  const Face& face = csMesh.faces[k]; 1126  const NodeVector& nodes = csMesh.nodes; 1127  1128  if( face.edges.size() != 4 ) 1129  { 1130  _EXCEPTIONT( "Mesh must only contain quadrilateral elements" ); 1131  } 1132  1133  Node centroid; 1134  centroid.x = centroid.y = centroid.z = 0.0; 1135  for( unsigned l = 0; l < face.edges.size(); ++l ) 1136  { 1137  centroid.x += nodes[face[l]].x; 1138  centroid.y += nodes[face[l]].y; 1139  centroid.z += nodes[face[l]].z; 1140  } 1141  const double factor = 1.0 / face.edges.size(); 1142  centroid.x *= factor; 1143  centroid.y *= factor; 1144  centroid.z *= factor; 1145  1146  bool locElem = false; 1147  EntityHandle current_eh; 1148  if( mapLocalMBNodes.find( centroid ) != mapLocalMBNodes.end() ) 1149  { 1150  locElem = true; 1151  current_eh = mapLocalMBNodes[centroid]; 1152  } 1153  1154  for( int j = 0; j < nP; j++ ) 1155  { 1156  for( int i = 0; i < nP; i++ ) 1157  { 1158  // Get local map vectors 1159  Node nodeGLL; 1160  Node dDx1G; 1161  Node dDx2G; 1162  1163  // ApplyLocalMap( 1164  // face, 1165  // nodevec, 1166  // dG[i], 1167  // dG[j], 1168  // nodeGLL, 1169  // dDx1G, 1170  // dDx2G); 1171  const double& dAlpha = dG[i]; 1172  const double& dBeta = dG[j]; 1173  1174  // Calculate nodal locations on the plane 1175  double dXc = nodes[face[0]].x * ( 1.0 - dAlpha ) * ( 1.0 - dBeta ) + 1176  nodes[face[1]].x * dAlpha * ( 1.0 - dBeta ) + nodes[face[2]].x * dAlpha * dBeta + 1177  nodes[face[3]].x * ( 1.0 - dAlpha ) * dBeta; 1178  1179  double dYc = nodes[face[0]].y * ( 1.0 - dAlpha ) * ( 1.0 - dBeta ) + 1180  nodes[face[1]].y * dAlpha * ( 1.0 - dBeta ) + nodes[face[2]].y * dAlpha * dBeta + 1181  nodes[face[3]].y * ( 1.0 - dAlpha ) * dBeta; 1182  1183  double dZc = nodes[face[0]].z * ( 1.0 - dAlpha ) * ( 1.0 - dBeta ) + 1184  nodes[face[1]].z * dAlpha * ( 1.0 - dBeta ) + nodes[face[2]].z * dAlpha * dBeta + 1185  nodes[face[3]].z * ( 1.0 - dAlpha ) * dBeta; 1186  1187  double dR = sqrt( dXc * dXc + dYc * dYc + dZc * dZc ); 1188  1189  // Mapped node location 1190  nodeGLL.x = dXc / dR; 1191  nodeGLL.y = dYc / dR; 1192  nodeGLL.z = dZc / dR; 1193  1194  // Determine if this is a unique Node 1195  std::map< Node, int >::const_iterator iter = mapNodes.find( nodeGLL ); 1196  if( iter == mapNodes.end() ) 1197  { 1198  // Insert new unique node into map 1199  int ixNode = static_cast< int >( mapNodes.size() ); 1200  mapNodes.insert( std::pair< Node, int >( nodeGLL, ixNode ) ); 1201  dataGLLnodes[j][i][k] = ixNode + 1; 1202  } 1203  else 1204  { 1205  dataGLLnodes[j][i][k] = iter->second + 1; 1206  } 1207  1208  dofIDs[j * nP + i] = dataGLLnodes[j][i][k]; 1209  } 1210  } 1211  1212  if( locElem ) 1213  { 1214  rval = m_interface->tag_set_data( dofTag, &current_eh, 1, dofIDs );MB_CHK_SET_ERR( rval, "Failed to tag_set_data for DoFs" ); 1215  } 1216  } 1217  1218  // clear memory 1219  delete[] dofIDs; 1220  mapLocalMBNodes.clear(); 1221  mapNodes.clear(); 1222  1223  return moab::MB_SUCCESS; 1224 }

References moab::Range::begin(), moab::Range::end(), entities, ErrorCode, moab::Interface::get_coords(), moab::Remapper::m_interface, MB_CHK_SET_ERR, MB_INVALID_SIZE, MB_SUCCESS, MB_TAG_CREAT, MB_TAG_DENSE, MB_TYPE_INTEGER, moab::Interface::tag_get_handle(), and moab::Interface::tag_set_data().

Referenced by GenerateCSMeshMetadata(), and main().

◆ GetCoveringMesh()

Mesh * moab::TempestRemapper::GetCoveringMesh ( )
inline

Get the covering mesh (TempestRemap) object.

Definition at line 578 of file TempestRemapper.hpp.

579 { 580  return m_covering_source; 581 }

References m_covering_source.

Referenced by moab::TempestOnlineMap::TempestOnlineMap().

◆ GetCoveringSet()

moab::EntityHandle & moab::TempestRemapper::GetCoveringSet ( )
inline

Get access to the underlying source covering set if available. Else return the source set.

Definition at line 583 of file TempestRemapper.hpp.

584 { 585  return m_covering_source_set; 586 }

References m_covering_source_set.

◆ GetGlobalID()

int moab::TempestRemapper::GetGlobalID ( Remapper::IntersectionContext  ctx,
int  localID 
)
inline

Get the global ID corresponding to the local entity ID according to the context (source, target, intersection)

Definition at line 588 of file TempestRemapper.hpp.

589 { 590  switch( ctx ) 591  { 592  case Remapper::SourceMesh: 593  return lid_to_gid_src[localID]; 594  case Remapper::TargetMesh: 595  return lid_to_gid_tgt[localID]; 596  case Remapper::CoveringMesh: 597  return lid_to_gid_covsrc[localID]; 598  case Remapper::OverlapMesh: 599  case Remapper::DEFAULT: 600  default: 601  return -1; 602  } 603 }

References moab::Remapper::CoveringMesh, moab::Remapper::DEFAULT, lid_to_gid_covsrc, lid_to_gid_src, lid_to_gid_tgt, moab::Remapper::OverlapMesh, moab::Remapper::SourceMesh, and moab::Remapper::TargetMesh.

◆ GetIMasks()

ErrorCode moab::TempestRemapper::GetIMasks ( Remapper::IntersectionContext  ctx,
std::vector< int > &  masks 
)

Get the masks that could have been defined.

Definition at line 2176 of file TempestRemapper.cpp.

2177 { 2178  Tag maskTag; 2179  // it should have been created already, if not, we might have a problem 2180  int def_val = 1; 2181  ErrorCode rval = 2182  m_interface->tag_get_handle( "GRID_IMASK", 1, MB_TYPE_INTEGER, maskTag, MB_TAG_DENSE | MB_TAG_CREAT, &def_val );MB_CHK_SET_ERR( rval, "Trouble creating GRID_IMASK tag" ); 2183  2184  switch( ctx ) 2185  { 2186  case Remapper::SourceMesh: { 2187  if( point_cloud_source ) 2188  { 2189  masks.resize( m_source_vertices.size() ); 2190  rval = m_interface->tag_get_data( maskTag, m_source_vertices, &masks[0] );MB_CHK_SET_ERR( rval, "Trouble getting GRID_IMASK tag" ); 2191  } 2192  else 2193  { 2194  masks.resize( m_source_entities.size() ); 2195  rval = m_interface->tag_get_data( maskTag, m_source_entities, &masks[0] );MB_CHK_SET_ERR( rval, "Trouble getting GRID_IMASK tag" ); 2196  } 2197  return MB_SUCCESS; 2198  } 2199  case Remapper::TargetMesh: { 2200  if( point_cloud_target ) 2201  { 2202  masks.resize( m_target_vertices.size() ); 2203  rval = m_interface->tag_get_data( maskTag, m_target_vertices, &masks[0] );MB_CHK_SET_ERR( rval, "Trouble getting GRID_IMASK tag" ); 2204  } 2205  else 2206  { 2207  masks.resize( m_target_entities.size() ); 2208  rval = m_interface->tag_get_data( maskTag, m_target_entities, &masks[0] );MB_CHK_SET_ERR( rval, "Trouble getting GRID_IMASK tag" ); 2209  } 2210  return MB_SUCCESS; 2211  } 2212  case Remapper::CoveringMesh: 2213  case Remapper::OverlapMesh: 2214  default: 2215  return MB_SUCCESS; 2216  } 2217 }

References moab::Remapper::CoveringMesh, ErrorCode, moab::Remapper::m_interface, m_source_entities, m_source_vertices, m_target_entities, m_target_vertices, MB_CHK_SET_ERR, MB_SUCCESS, MB_TAG_CREAT, MB_TAG_DENSE, MB_TYPE_INTEGER, moab::Remapper::OverlapMesh, point_cloud_source, point_cloud_target, moab::Range::size(), moab::Remapper::SourceMesh, moab::Interface::tag_get_data(), moab::Interface::tag_get_handle(), and moab::Remapper::TargetMesh.

◆ GetLocalID()

int moab::TempestRemapper::GetLocalID ( Remapper::IntersectionContext  ctx,
int  globalID 
)
inline

Get the local ID corresponding to the global entity ID according to the context (source, target, intersection)

Definition at line 605 of file TempestRemapper.hpp.

606 { 607  switch( ctx ) 608  { 609  case Remapper::SourceMesh: 610  return gid_to_lid_src[globalID]; 611  case Remapper::TargetMesh: 612  return gid_to_lid_tgt[globalID]; 613  case Remapper::CoveringMesh: 614  return gid_to_lid_covsrc[globalID]; 615  case Remapper::DEFAULT: 616  case Remapper::OverlapMesh: 617  default: 618  return -1; 619  } 620 }

References moab::Remapper::CoveringMesh, moab::Remapper::DEFAULT, gid_to_lid_covsrc, gid_to_lid_src, gid_to_lid_tgt, moab::Remapper::OverlapMesh, moab::Remapper::SourceMesh, and moab::Remapper::TargetMesh.

◆ GetMesh()

Mesh * moab::TempestRemapper::GetMesh ( Remapper::IntersectionContext  ctx)
inline

Get the TempestRemap mesh object according to the intersection context.

Definition at line 344 of file TempestRemapper.hpp.

345 { 346  switch( ctx ) 347  { 348  case Remapper::SourceMesh: 349  return m_source; 350  case Remapper::TargetMesh: 351  return m_target; 352  case Remapper::OverlapMesh: 353  return m_overlap; 354  case Remapper::CoveringMesh: 355  return m_covering_source; 356  case Remapper::DEFAULT: 357  default: 358  return NULL; 359  } 360 }

References moab::Remapper::CoveringMesh, moab::Remapper::DEFAULT, m_covering_source, m_overlap, m_source, m_target, moab::Remapper::OverlapMesh, moab::Remapper::SourceMesh, and moab::Remapper::TargetMesh.

Referenced by CreateTempestMesh(), main(), and moab::TempestOnlineMap::TempestOnlineMap().

◆ GetMeshEntities() [1/2]

moab::Range & moab::TempestRemapper::GetMeshEntities ( Remapper::IntersectionContext  ctx)
inline

Get the mesh element entities corresponding to the intersection context.

Definition at line 455 of file TempestRemapper.hpp.

456 { 457  switch( ctx ) 458  { 459  case Remapper::SourceMesh: 460  return m_source_entities; 461  case Remapper::TargetMesh: 462  return m_target_entities; 463  case Remapper::OverlapMesh: 464  return m_overlap_entities; 465  case Remapper::CoveringMesh: 466  return m_covering_source_entities; 467  case Remapper::DEFAULT: 468  default: 469  MB_SET_ERR_RET_VAL( "Invalid context passed to GetMeshSet", m_overlap_entities ); 470  } 471 }

References moab::Remapper::CoveringMesh, moab::Remapper::DEFAULT, m_covering_source_entities, m_overlap_entities, m_source_entities, m_target_entities, MB_SET_ERR_RET_VAL, moab::Remapper::OverlapMesh, moab::Remapper::SourceMesh, and moab::Remapper::TargetMesh.

Referenced by main().

◆ GetMeshEntities() [2/2]

const moab::Range & moab::TempestRemapper::GetMeshEntities ( Remapper::IntersectionContext  ctx) const
inline

Const overload. Get the mesh element entities corresponding to the intersection context.

Definition at line 473 of file TempestRemapper.hpp.

474 { 475  switch( ctx ) 476  { 477  case Remapper::SourceMesh: 478  return m_source_entities; 479  case Remapper::TargetMesh: 480  return m_target_entities; 481  case Remapper::OverlapMesh: 482  return m_overlap_entities; 483  case Remapper::CoveringMesh: 484  return m_covering_source_entities; 485  case Remapper::DEFAULT: 486  default: 487  MB_SET_ERR_RET_VAL( "Invalid context passed to GetMeshSet", m_overlap_entities ); 488  } 489 }

References moab::Remapper::CoveringMesh, moab::Remapper::DEFAULT, m_covering_source_entities, m_overlap_entities, m_source_entities, m_target_entities, MB_SET_ERR_RET_VAL, moab::Remapper::OverlapMesh, moab::Remapper::SourceMesh, and moab::Remapper::TargetMesh.

◆ GetMeshSet() [1/2]

moab::EntityHandle & moab::TempestRemapper::GetMeshSet ( Remapper::IntersectionContext  ctx)
inline

Get the MOAB mesh set corresponding to the intersection context.

Definition at line 419 of file TempestRemapper.hpp.

420 { 421  switch( ctx ) 422  { 423  case Remapper::SourceMesh: 424  return m_source_set; 425  case Remapper::TargetMesh: 426  return m_target_set; 427  case Remapper::OverlapMesh: 428  return m_overlap_set; 429  case Remapper::CoveringMesh: 430  return m_covering_source_set; 431  case Remapper::DEFAULT: 432  default: 433  MB_SET_ERR_RET_VAL( "Invalid context passed to GetMeshSet", m_overlap_set ); 434  } 435 }

References moab::Remapper::CoveringMesh, moab::Remapper::DEFAULT, m_covering_source_set, m_overlap_set, m_source_set, m_target_set, MB_SET_ERR_RET_VAL, moab::Remapper::OverlapMesh, moab::Remapper::SourceMesh, and moab::Remapper::TargetMesh.

Referenced by CreateTempestMesh(), and main().

◆ GetMeshSet() [2/2]

moab::EntityHandle moab::TempestRemapper::GetMeshSet ( Remapper::IntersectionContext  ctx) const
inline

Const overload. Get the MOAB mesh set corresponding to the intersection context.

Definition at line 437 of file TempestRemapper.hpp.

438 { 439  switch( ctx ) 440  { 441  case Remapper::SourceMesh: 442  return m_source_set; 443  case Remapper::TargetMesh: 444  return m_target_set; 445  case Remapper::OverlapMesh: 446  return m_overlap_set; 447  case Remapper::CoveringMesh: 448  return m_covering_source_set; 449  case Remapper::DEFAULT: 450  default: 451  MB_SET_ERR_RET_VAL( "Invalid context passed to GetMeshSet", m_overlap_set ); 452  } 453 }

References moab::Remapper::CoveringMesh, moab::Remapper::DEFAULT, m_covering_source_set, m_overlap_set, m_source_set, m_target_set, MB_SET_ERR_RET_VAL, moab::Remapper::OverlapMesh, moab::Remapper::SourceMesh, and moab::Remapper::TargetMesh.

◆ GetMeshType()

TempestRemapper::TempestMeshType moab::TempestRemapper::GetMeshType ( Remapper::IntersectionContext  ctx) const
inline

Get the mesh type corresponding to the intersection context

Definition at line 562 of file TempestRemapper.hpp.

563 { 564  switch( ctx ) 565  { 566  case Remapper::SourceMesh: 567  return m_source_type; 568  case Remapper::TargetMesh: 569  return m_target_type; 570  case Remapper::OverlapMesh: 571  return m_overlap_type; 572  case Remapper::DEFAULT: 573  default: 574  return TempestRemapper::DEFAULT; 575  } 576 }

References moab::Remapper::DEFAULT, DEFAULT, m_overlap_type, m_source_type, m_target_type, moab::Remapper::OverlapMesh, moab::Remapper::SourceMesh, and moab::Remapper::TargetMesh.

◆ GetMeshVertices() [1/2]

moab::Range & moab::TempestRemapper::GetMeshVertices ( Remapper::IntersectionContext  ctx)
inline

Get the mesh vertices corresponding to the intersection context. Useful for point-cloud meshes

Definition at line 491 of file TempestRemapper.hpp.

492 { 493  switch( ctx ) 494  { 495  case Remapper::SourceMesh: 496  return m_source_vertices; 497  case Remapper::TargetMesh: 498  return m_target_vertices; 499  case Remapper::CoveringMesh: 500  return m_covering_source_vertices; 501  case Remapper::DEFAULT: 502  default: 503  MB_SET_ERR_RET_VAL( "Invalid context passed to GetMeshSet", m_source_vertices ); 504  } 505 }

References moab::Remapper::CoveringMesh, moab::Remapper::DEFAULT, m_covering_source_vertices, m_source_vertices, m_target_vertices, MB_SET_ERR_RET_VAL, moab::Remapper::SourceMesh, and moab::Remapper::TargetMesh.

Referenced by main().

◆ GetMeshVertices() [2/2]

const moab::Range & moab::TempestRemapper::GetMeshVertices ( Remapper::IntersectionContext  ctx) const
inline

Const overload. Get the mesh vertices corresponding to the intersection context. Useful for point-cloud meshes.

Definition at line 507 of file TempestRemapper.hpp.

508 { 509  switch( ctx ) 510  { 511  case Remapper::SourceMesh: 512  return m_source_vertices; 513  case Remapper::TargetMesh: 514  return m_target_vertices; 515  case Remapper::CoveringMesh: 516  return m_covering_source_vertices; 517  case Remapper::DEFAULT: 518  default: 519  MB_SET_ERR_RET_VAL( "Invalid context passed to GetMeshSet", m_source_vertices ); 520  } 521 }

References moab::Remapper::CoveringMesh, moab::Remapper::DEFAULT, m_covering_source_vertices, m_source_vertices, m_target_vertices, MB_SET_ERR_RET_VAL, moab::Remapper::SourceMesh, and moab::Remapper::TargetMesh.

◆ GetOverlapAugmentedEntities()

moab::ErrorCode moab::TempestRemapper::GetOverlapAugmentedEntities ( moab::Range sharedGhostEntities)

Get all the ghosted overlap entities that were accumulated to enable conservation in parallel

Definition at line 704 of file TempestRemapper.cpp.

705 { 706  sharedGhostEntities.clear(); 707 #ifdef MOAB_HAVE_MPI 708  moab::ErrorCode rval; 709  710  // Remove entities in the intersection mesh that are part of the ghosted overlap 711  if( is_parallel && size > 1 ) 712  { 713  moab::Range allents; 714  rval = m_interface->get_entities_by_dimension( m_overlap_set, 2, allents );MB_CHK_SET_ERR( rval, "Getting entities dim 2 failed" ); 715  716  moab::Range sharedents; 717  moab::Tag ghostTag; 718  std::vector< int > ghFlags( allents.size() ); 719  rval = m_interface->tag_get_handle( "ORIG_PROC", ghostTag );MB_CHK_ERR( rval ); 720  rval = m_interface->tag_get_data( ghostTag, allents, &ghFlags[0] );MB_CHK_ERR( rval ); 721  for( unsigned i = 0; i < allents.size(); ++i ) 722  if( ghFlags[i] >= 0 ) // it means it is a ghost overlap element 723  sharedents.insert( allents[i] ); // this should not participate in smat! 724  725  allents = subtract( allents, sharedents ); 726  727  // Get connectivity from all ghosted elements and filter out 728  // the vertices that are not owned 729  moab::Range ownedverts, sharedverts; 730  rval = m_interface->get_connectivity( allents, ownedverts );MB_CHK_SET_ERR( rval, "Deleting entities dim 0 failed" ); 731  rval = m_interface->get_connectivity( sharedents, sharedverts );MB_CHK_SET_ERR( rval, "Deleting entities dim 0 failed" ); 732  sharedverts = subtract( sharedverts, ownedverts ); 733  // rval = m_interface->remove_entities(m_overlap_set, sharedents);MB_CHK_SET_ERR(rval, 734  // "Deleting entities dim 2 failed"); rval = m_interface->remove_entities(m_overlap_set, 735  // sharedverts);MB_CHK_SET_ERR(rval, "Deleting entities dim 0 failed"); 736  737  sharedGhostEntities.merge( sharedents ); 738  // sharedGhostEntities.merge(sharedverts); 739  } 740 #endif 741  return moab::MB_SUCCESS; 742 }

References moab::Range::clear(), ErrorCode, moab::Range::insert(), MB_CHK_ERR, MB_CHK_SET_ERR, MB_SUCCESS, moab::Range::merge(), size, moab::Range::size(), and moab::subtract().

Referenced by main().

◆ initialize()

ErrorCode moab::TempestRemapper::initialize ( bool  initialize_fsets = true)
virtual

Initialize the TempestRemapper object internal datastructures including the mesh sets and TempestRemap mesh references.

Definition at line 53 of file TempestRemapper.cpp.

54 { 55  ErrorCode rval; 56  if( initialize_fsets ) 57  { 58  rval = m_interface->create_meshset( moab::MESHSET_SET, m_source_set );MB_CHK_SET_ERR( rval, "Can't create new set" ); 59  rval = m_interface->create_meshset( moab::MESHSET_SET, m_target_set );MB_CHK_SET_ERR( rval, "Can't create new set" ); 60  rval = m_interface->create_meshset( moab::MESHSET_SET, m_overlap_set );MB_CHK_SET_ERR( rval, "Can't create new set" ); 61  } 62  else 63  { 64  m_source_set = 0; 65  m_target_set = 0; 66  m_overlap_set = 0; 67  } 68  69  is_parallel = false; 70  is_root = true; 71  rank = 0; 72  size = 1; 73 #ifdef MOAB_HAVE_MPI 74  int flagInit; 75  MPI_Initialized( &flagInit ); 76  if( flagInit ) 77  { 78  assert( m_pcomm != nullptr ); 79  rank = m_pcomm->rank(); 80  size = m_pcomm->size(); 81  is_root = ( rank == 0 ); 82  is_parallel = ( size > 1 ); 83  // is_parallel = true; 84  } 85  AnnounceOnlyOutputOnRankZero(); 86 #endif 87  88  m_source = nullptr; 89  m_target = nullptr; 90  m_overlap = nullptr; 91  m_covering_source = nullptr; 92  93  point_cloud_source = false; 94  point_cloud_target = false; 95  96  return MB_SUCCESS; 97 }

References moab::Interface::create_meshset(), ErrorCode, is_parallel, is_root, m_covering_source, moab::Remapper::m_interface, m_overlap, m_overlap_set, m_source, m_source_set, m_target, m_target_set, MB_CHK_SET_ERR, MB_SUCCESS, MESHSET_SET, point_cloud_source, point_cloud_target, rank, and size.

Referenced by main().

◆ load_tempest_mesh_private()

ErrorCode moab::TempestRemapper::load_tempest_mesh_private ( std::string  inputFilename,
Mesh **  tempest_mesh 
)
private

Definition at line 177 of file TempestRemapper.cpp.

178 { 179  const bool outputEnabled = ( TempestRemapper::verbose && is_root ); 180  if( outputEnabled ) std::cout << "\nLoading TempestRemap Mesh object from file = " << inputFilename << " ...\n"; 181  182  { 183  NcError error( NcError::silent_nonfatal ); 184  185  try 186  { 187  // Load input mesh 188  if( outputEnabled ) std::cout << "Loading mesh ...\n"; 189  Mesh* mesh = new Mesh( inputFilename ); 190  mesh->RemoveZeroEdges(); 191  if( outputEnabled ) std::cout << "----------------\n"; 192  193  // Validate mesh 194  if( meshValidate ) 195  { 196  if( outputEnabled ) std::cout << "Validating mesh ...\n"; 197  mesh->Validate(); 198  if( outputEnabled ) std::cout << "-------------------\n"; 199  } 200  201  // Construct the edge map on the mesh 202  if( constructEdgeMap ) 203  { 204  if( outputEnabled ) std::cout << "Constructing edge map on mesh ...\n"; 205  mesh->ConstructEdgeMap( false ); 206  if( outputEnabled ) std::cout << "---------------------------------\n"; 207  } 208  209  if( tempest_mesh ) *tempest_mesh = mesh; 210  } 211  catch( Exception& e ) 212  { 213  std::cout << "TempestRemap ERROR: " << e.ToString() << "\n"; 214  return MB_FAILURE; 215  } 216  catch( ... ) 217  { 218  return MB_FAILURE; 219  } 220  } 221  return MB_SUCCESS; 222 }

References constructEdgeMap, moab::error(), is_root, MB_SUCCESS, meshValidate, and verbose.

Referenced by LoadMesh().

◆ LoadMesh()

ErrorCode moab::TempestRemapper::LoadMesh ( Remapper::IntersectionContext  ctx,
std::string  inputFilename,
TempestMeshType  type 
)

Load a mesh from disk of given type and store it under the context specified by the user.

Definition at line 152 of file TempestRemapper.cpp.

155 { 156  if( ctx == Remapper::SourceMesh ) 157  { 158  m_source_type = type; 159  return load_tempest_mesh_private( inputFilename, &m_source ); 160  } 161  else if( ctx == Remapper::TargetMesh ) 162  { 163  m_target_type = type; 164  return load_tempest_mesh_private( inputFilename, &m_target ); 165  } 166  else if( ctx != Remapper::DEFAULT ) 167  { 168  m_overlap_type = type; 169  return load_tempest_mesh_private( inputFilename, &m_overlap ); 170  } 171  else 172  { 173  MB_CHK_SET_ERR( MB_FAILURE, "Invalid IntersectionContext context provided" ); 174  } 175 }

References moab::Remapper::DEFAULT, load_tempest_mesh_private(), m_overlap, m_overlap_type, m_source, m_source_type, m_target, m_target_type, MB_CHK_SET_ERR, moab::Remapper::SourceMesh, and moab::Remapper::TargetMesh.

Referenced by CreateTempestMesh(), and main().

◆ ResetMeshSet()

void moab::TempestRemapper::ResetMeshSet ( Remapper::IntersectionContext  ctx,
moab::EntityHandle  meshSet 
)
inline

reconstruct mesh, used now only for IO; need a better solution maybe

Definition at line 392 of file TempestRemapper.hpp.

393 { 394  switch( ctx ) 395  { 396  case Remapper::SourceMesh: 397  delete m_source; 398  m_source = new Mesh; 399  m_source_set = meshSet; 400  convert_mesh_to_tempest_private( m_source, m_source_set, m_source_entities, &m_source_vertices ); 401  m_source->CalculateFaceAreas( false ); // fInputConcave is false ? 402  break; 403  case Remapper::TargetMesh: 404  // not needed yet 405  break; 406  case Remapper::OverlapMesh: 407  // not needed yet 408  break; 409  case Remapper::CoveringMesh: 410  // not needed yet 411  break; 412  case Remapper::DEFAULT: 413  default: 414  break; 415  } 416 }

References convert_mesh_to_tempest_private(), moab::Remapper::CoveringMesh, moab::Remapper::DEFAULT, m_source, m_source_entities, m_source_set, m_source_vertices, moab::Remapper::OverlapMesh, moab::Remapper::SourceMesh, and moab::Remapper::TargetMesh.

◆ SetMesh()

void moab::TempestRemapper::SetMesh ( Remapper::IntersectionContext  ctx,
Mesh *  mesh,
bool  overwrite = true 
)
inline

Set the TempestRemap mesh object according to the intersection context.

Definition at line 362 of file TempestRemapper.hpp.

363 { 364  switch( ctx ) 365  { 366  case Remapper::SourceMesh: 367  if( !overwrite && m_source ) return; 368  if( overwrite && m_source ) delete m_source; 369  m_source = mesh; 370  break; 371  case Remapper::TargetMesh: 372  if( !overwrite && m_target ) return; 373  if( overwrite && m_target ) delete m_target; 374  m_target = mesh; 375  break; 376  case Remapper::OverlapMesh: 377  if( !overwrite && m_overlap ) return; 378  if( overwrite && m_overlap ) delete m_overlap; 379  m_overlap = mesh; 380  break; 381  case Remapper::CoveringMesh: 382  if( !overwrite && m_covering_source ) return; 383  if( overwrite && m_covering_source ) delete m_covering_source; 384  m_covering_source = mesh; 385  break; 386  case Remapper::DEFAULT: 387  default: 388  break; 389  } 390 }

References moab::Remapper::CoveringMesh, moab::Remapper::DEFAULT, m_covering_source, m_overlap, m_source, m_target, moab::Remapper::OverlapMesh, moab::Remapper::SourceMesh, and moab::Remapper::TargetMesh.

Referenced by CreateTempestMesh().

◆ SetMeshSet()

void moab::TempestRemapper::SetMeshSet ( Remapper::IntersectionContext  ctx,
moab::EntityHandle  mset,
moab::Range entities = nullptr 
)

Definition at line 987 of file TempestRemapper.cpp.

990 { 991  992  if( ctx == Remapper::SourceMesh ) // should not be used 993  { 994  m_source_set = mset; 995  if( entities ) m_source_entities = *entities; 996  } 997  else if( ctx == Remapper::TargetMesh ) 998  { 999  m_target_set = mset; 1000  if( entities ) m_target_entities = *entities; 1001  } 1002  else if( ctx == Remapper::CoveringMesh ) 1003  { 1004  m_covering_source_set = mset; 1005  if( entities ) m_covering_source_entities = *entities; 1006  } 1007  else 1008  { 1009  // nothing to do really.. 1010  return; 1011  } 1012 }

References moab::Remapper::CoveringMesh, entities, m_covering_source_entities, m_covering_source_set, m_source_entities, m_source_set, m_target_entities, m_target_set, moab::Remapper::SourceMesh, and moab::Remapper::TargetMesh.

◆ SetMeshType()

void moab::TempestRemapper::SetMeshType ( Remapper::IntersectionContext  ctx,
const std::vector< int > &  metadata 
)
inline

Set the mesh type corresponding to the intersection context

Definition at line 523 of file TempestRemapper.hpp.

524 { 525  switch( ctx ) 526  { 527  case Remapper::SourceMesh: 528  m_source_type = static_cast< moab::TempestRemapper::TempestMeshType >( metadata[0] ); 529  if( metadata[0] == 1 ) // RLL mesh 530  { 531  m_source_metadata.resize( 2 ); 532  m_source_metadata[0] = metadata[1]; 533  m_source_metadata[1] = metadata[2]; 534  } 535  else 536  { 537  m_source_metadata.resize( 1 ); 538  m_source_metadata[0] = metadata[1]; 539  } 540  break; 541  case Remapper::TargetMesh: 542  m_target_type = static_cast< moab::TempestRemapper::TempestMeshType >( metadata[0] ); 543  if( metadata[0] == 1 ) // RLL mesh 544  { 545  m_target_metadata.resize( 2 ); 546  m_target_metadata[0] = metadata[1]; 547  m_target_metadata[1] = metadata[2]; 548  } 549  else 550  { 551  m_target_metadata.resize( 1 ); 552  m_target_metadata[0] = metadata[1]; 553  } 554  break; 555  case Remapper::OverlapMesh: 556  m_overlap_type = moab::TempestRemapper::OVERLAP_FILES; 557  default: 558  break; 559  } 560 }

References m_overlap_type, m_source_metadata, m_source_type, m_target_metadata, m_target_type, OVERLAP_FILES, moab::Remapper::OverlapMesh, moab::Remapper::SourceMesh, and moab::Remapper::TargetMesh.

Referenced by CreateTempestMesh().

◆ WriteTempestIntersectionMesh()

moab::ErrorCode moab::TempestRemapper::WriteTempestIntersectionMesh ( std::string  strOutputFileName,
const bool  fAllParallel,
const bool  fInputConcave,
const bool  fOutputConcave 
)

Gather the overlap mesh and asssociated source/target data and write it out to disk using the TempestRemap output interface. This information can then be used with the "GenerateOfflineMap" tool in TempestRemap as needed.

Definition at line 951 of file TempestRemapper.cpp.

955 { 956  // Let us alos write out the TempestRemap equivalent so that we can do some verification checks 957  if( fAllParallel ) 958  { 959  if( is_root && size == 1 ) 960  { 961  this->m_source->CalculateFaceAreas( fInputConcave ); 962  this->m_target->CalculateFaceAreas( fOutputConcave ); 963  this->m_overlap->Write( strOutputFileName.c_str(), NcFile::Netcdf4 ); 964  } 965  else 966  { 967  // Perform reduction and write from root processor 968  // if ( is_root ) 969  // std::cout << "--- PARALLEL IMPLEMENTATION is NOT AVAILABLE yet ---\n"; 970  971  this->m_source->CalculateFaceAreas( fInputConcave ); 972  this->m_covering_source->CalculateFaceAreas( fInputConcave ); 973  this->m_target->CalculateFaceAreas( fOutputConcave ); 974  this->m_overlap->Write( strOutputFileName.c_str(), NcFile::Netcdf4 ); 975  } 976  } 977  else 978  { 979  this->m_source->CalculateFaceAreas( fInputConcave ); 980  this->m_target->CalculateFaceAreas( fOutputConcave ); 981  this->m_overlap->Write( strOutputFileName.c_str(), NcFile::Netcdf4 ); 982  } 983  984  return moab::MB_SUCCESS; 985 }

References MB_SUCCESS, and size.

Friends And Related Function Documentation

◆ TempestOnlineMap

friend class TempestOnlineMap
friend

Definition at line 66 of file TempestRemapper.hpp.

Member Data Documentation

◆ constructEdgeMap

bool moab::TempestRemapper::constructEdgeMap

◆ gid_to_lid_covsrc

std::map< int, int > moab::TempestRemapper::gid_to_lid_covsrc
private

◆ gid_to_lid_src

std::map< int, int > moab::TempestRemapper::gid_to_lid_src
private

Definition at line 333 of file TempestRemapper.hpp.

Referenced by clear(), ComputeGlobalLocalMaps(), and GetLocalID().

◆ gid_to_lid_tgt

std::map< int, int > moab::TempestRemapper::gid_to_lid_tgt
private

◆ is_parallel

bool moab::TempestRemapper::is_parallel
private

◆ is_root

◆ lid_to_gid_covsrc

std::map< int, int > moab::TempestRemapper::lid_to_gid_covsrc
private

Definition at line 334 of file TempestRemapper.hpp.

Referenced by clear(), ComputeGlobalLocalMaps(), and GetGlobalID().

◆ lid_to_gid_src

std::map< int, int > moab::TempestRemapper::lid_to_gid_src
private

Definition at line 334 of file TempestRemapper.hpp.

Referenced by clear(), ComputeGlobalLocalMaps(), and GetGlobalID().

◆ lid_to_gid_tgt

std::map< int, int > moab::TempestRemapper::lid_to_gid_tgt
private

Definition at line 334 of file TempestRemapper.hpp.

Referenced by clear(), ComputeGlobalLocalMaps(), and GetGlobalID().

◆ m_area_method

IntxAreaUtils::AreaMethod moab::TempestRemapper::m_area_method
private

Definition at line 336 of file TempestRemapper.hpp.

◆ m_covering_source

Mesh* moab::TempestRemapper::m_covering_source
private

◆ m_covering_source_entities

moab::Range moab::TempestRemapper::m_covering_source_entities
private

◆ m_covering_source_set

moab::EntityHandle moab::TempestRemapper::m_covering_source_set
private

◆ m_covering_source_vertices

moab::Range moab::TempestRemapper::m_covering_source_vertices
private

◆ m_overlap

Mesh* moab::TempestRemapper::m_overlap
private

◆ m_overlap_entities

moab::Range moab::TempestRemapper::m_overlap_entities
private

◆ m_overlap_set

moab::EntityHandle moab::TempestRemapper::m_overlap_set
private

◆ m_overlap_type

TempestMeshType moab::TempestRemapper::m_overlap_type
private

Definition at line 318 of file TempestRemapper.hpp.

Referenced by ConvertTempestMesh(), GetMeshType(), LoadMesh(), and SetMeshType().

◆ m_sorted_overlap_order

std::vector< std::pair< int, int > > moab::TempestRemapper::m_sorted_overlap_order
private

Definition at line 321 of file TempestRemapper.hpp.

◆ m_source

Mesh* moab::TempestRemapper::m_source
private

◆ m_source_entities

◆ m_source_metadata

std::vector< int > moab::TempestRemapper::m_source_metadata
private

Definition at line 304 of file TempestRemapper.hpp.

Referenced by SetMeshType().

◆ m_source_set

moab::EntityHandle moab::TempestRemapper::m_source_set
private

◆ m_source_type

TempestMeshType moab::TempestRemapper::m_source_type
private

Definition at line 298 of file TempestRemapper.hpp.

Referenced by ConvertTempestMesh(), GetMeshType(), LoadMesh(), and SetMeshType().

◆ m_source_vertices

moab::Range moab::TempestRemapper::m_source_vertices
private

◆ m_target

Mesh* moab::TempestRemapper::m_target
private

◆ m_target_entities

moab::Range moab::TempestRemapper::m_target_entities
private

◆ m_target_metadata

std::vector< int > moab::TempestRemapper::m_target_metadata
private

Definition at line 314 of file TempestRemapper.hpp.

Referenced by SetMeshType().

◆ m_target_set

moab::EntityHandle moab::TempestRemapper::m_target_set
private

◆ m_target_type

TempestMeshType moab::TempestRemapper::m_target_type
private

Definition at line 308 of file TempestRemapper.hpp.

Referenced by ConvertTempestMesh(), GetMeshType(), LoadMesh(), and SetMeshType().

◆ m_target_vertices

moab::Range moab::TempestRemapper::m_target_vertices
private

◆ max_source_edges

int moab::TempestRemapper::max_source_edges
private

Definition at line 302 of file TempestRemapper.hpp.

Referenced by ConstructCoveringSet().

◆ max_target_edges

int moab::TempestRemapper::max_target_edges
private

Definition at line 312 of file TempestRemapper.hpp.

Referenced by ConstructCoveringSet().

◆ mbintx

moab::Intx2MeshOnSphere* moab::TempestRemapper::mbintx
private

Definition at line 324 of file TempestRemapper.hpp.

Referenced by ComputeOverlapMesh(), and ConstructCoveringSet().

◆ meshValidate

bool moab::TempestRemapper::meshValidate

Definition at line 271 of file TempestRemapper.hpp.

Referenced by load_tempest_mesh_private(), and main().

◆ offlineWorkflow

const bool moab::TempestRemapper::offlineWorkflow

Definition at line 270 of file TempestRemapper.hpp.

Referenced by convert_mesh_to_tempest_private().

◆ point_cloud_source

bool moab::TempestRemapper::point_cloud_source
private

◆ point_cloud_target

bool moab::TempestRemapper::point_cloud_target
private

◆ rank

◆ rrmgrids

bool moab::TempestRemapper::rrmgrids
private

Definition at line 338 of file TempestRemapper.hpp.

Referenced by ComputeOverlapMesh(), and ConstructCoveringSet().

◆ size

int moab::TempestRemapper::size
private

◆ verbose

const bool moab::TempestRemapper::verbose = true
static

The documentation for this class was generated from the following files: