MOAB: Mesh Oriented datABase  (version 5.5.0)
test_remapping.cpp File Reference
#include <iostream>
#include "moab/Core.hpp"
#include "moab/Remapping/TempestRemapper.hpp"
#include "Internals.hpp"
#include "TestRunner.hpp"
+ Include dependency graph for test_remapping.cpp:

Go to the source code of this file.

Macros

#define IS_BUILDING_MB
 

Functions

void test_tempest_cs_create ()
 
void test_tempest_rll_create ()
 
void test_tempest_ico_create ()
 
void test_tempest_mpas_create ()
 
void test_tempest_overlap_combinations ()
 
void test_tempest_to_moab_convert ()
 
int main (int argc, char **argv)
 

Variables

static const double radius = 1.0
 
const double MOAB_PI = 3.1415926535897932384626433832795028841971693993751058209749445923
 
static const double surface_area = 4.0 * MOAB_PI * radius * radius
 
static const std::string outFilenames [5]
 

Macro Definition Documentation

◆ IS_BUILDING_MB

#define IS_BUILDING_MB

MOAB, a Mesh-Oriented datABase, is a software component for creating, storing and accessing finite element mesh data.

Copyright 2004 Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

Definition at line 33 of file test_remapping.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 54 of file test_remapping.cpp.

55 {
62 
63 #ifdef MOAB_HAVE_MPI
64  MPI_Init( &argc, &argv );
65 #endif
66  int result = RUN_TESTS( argc, argv );
67 #ifdef MOAB_HAVE_MPI
68  MPI_Finalize();
69 #endif
70  return result;
71 }

References REGISTER_TEST, RUN_TESTS, test_tempest_cs_create(), test_tempest_ico_create(), test_tempest_mpas_create(), test_tempest_overlap_combinations(), test_tempest_rll_create(), and test_tempest_to_moab_convert().

◆ test_tempest_cs_create()

void test_tempest_cs_create ( )

Definition at line 73 of file test_remapping.cpp.

74 {
75  NcError error( NcError::verbose_nonfatal );
76  const int blockSize = 30;
77  const std::string outFilename = outFilenames[0];
78 
79  std::cout << "Creating TempestRemap Cubed-Sphere Mesh ...\n";
80  Mesh tempest_mesh;
81  int ierr = GenerateCSMesh( tempest_mesh, blockSize, outFilename, "NetCDF4" );
82  CHECK_EQUAL( ierr, 0 );
83 
84  // Compute the surface area of CS mesh
85  const double sphere_area = tempest_mesh.CalculateFaceAreas( false );
86  CHECK_REAL_EQUAL( sphere_area, surface_area, 1e-10 );
87 }

References CHECK_EQUAL, CHECK_REAL_EQUAL, moab::error(), ierr, outFilenames, and surface_area.

Referenced by main().

◆ test_tempest_ico_create()

void test_tempest_ico_create ( )

Definition at line 110 of file test_remapping.cpp.

111 {
112  NcError error( NcError::verbose_nonfatal );
113  const int blockSize = 30;
114  const bool computeDual = false;
115  const std::string outFilename = outFilenames[2];
116 
117  std::cout << "Creating TempestRemap Icosahedral Mesh ...\n";
118  Mesh tempest_mesh;
119  int ierr = GenerateICOMesh( tempest_mesh, blockSize, computeDual, outFilename, "NetCDF4" );
120  CHECK_EQUAL( ierr, 0 );
121 
122  // Compute the surface area of ICO mesh
123  const double sphere_area = tempest_mesh.CalculateFaceAreas( false );
124  CHECK_REAL_EQUAL( sphere_area, surface_area, 1e-10 );
125 }

References CHECK_EQUAL, CHECK_REAL_EQUAL, moab::error(), ierr, outFilenames, and surface_area.

Referenced by main().

◆ test_tempest_mpas_create()

void test_tempest_mpas_create ( )

Definition at line 127 of file test_remapping.cpp.

128 {
129  NcError error( NcError::verbose_nonfatal );
130  const int blockSize = 30;
131  const bool computeDual = true;
132  const std::string outFilename = outFilenames[3];
133 
134  std::cout << "Creating TempestRemap MPAS Mesh (dual of the Icosahedral) ...\n";
135  Mesh tempest_mesh;
136  int ierr = GenerateICOMesh( tempest_mesh, blockSize, computeDual, outFilename, "NetCDF4" );
137  CHECK_EQUAL( ierr, 0 );
138 
139  // Compute the surface area of MPAS mesh
140  const double sphere_area = tempest_mesh.CalculateFaceAreas( false );
141  CHECK_REAL_EQUAL( sphere_area, surface_area, 1e-10 );
142 }

References CHECK_EQUAL, CHECK_REAL_EQUAL, moab::error(), ierr, outFilenames, and surface_area.

Referenced by main().

◆ test_tempest_overlap_combinations()

void test_tempest_overlap_combinations ( )

Definition at line 144 of file test_remapping.cpp.

145 {
146  NcError error( NcError::verbose_nonfatal );
147  const std::string outFilename = outFilenames[4];
148 
149  Mesh inpMesh( outFilenames[0] );
150  // verify input mesh area first
151  const double inpArea = inpMesh.CalculateFaceAreas( false );
152  CHECK_REAL_EQUAL( inpArea, surface_area, 1e-10 );
153 
154  for( int isrc = 0; isrc < 4; ++isrc )
155  {
156  for( int jsrc = 0; jsrc < 4; ++jsrc )
157  {
158  std::cout << "Computing Overlap between " << outFilenames[isrc] << " and " << outFilenames[jsrc]
159  << " ...\n";
160  Mesh tempest_mesh;
161  int ierr = GenerateOverlapMesh( outFilenames[isrc], outFilenames[jsrc], tempest_mesh, outFilename,
162  "NetCDF4", "exact", false, false, false, false, false );
163  CHECK_EQUAL( ierr, 0 );
164  // verify overlap mesh area
165  const double ovArea = tempest_mesh.CalculateFaceAreas( false );
166  CHECK_REAL_EQUAL( ovArea, surface_area, 1e-10 );
167  }
168  }
169 }

References CHECK_EQUAL, CHECK_REAL_EQUAL, moab::error(), ierr, outFilenames, and surface_area.

Referenced by main().

◆ test_tempest_rll_create()

void test_tempest_rll_create ( )

Definition at line 89 of file test_remapping.cpp.

90 {
91  NcError error( NcError::verbose_nonfatal );
92  const int blockSize = 30;
93  const std::string outFilename = outFilenames[1];
94 
95  std::cout << "Creating TempestRemap Latitude-Longitude Mesh ...\n";
96  Mesh tempest_mesh;
97  int ierr =
98  GenerateRLLMesh( tempest_mesh, blockSize * 2, blockSize, 0.0, 360.0, -90.0, 90.0, false, false, true, "", "",
99  "", // std::string strInputFile, std::string strInputFileLonName, std::string
100  // strInputFileLatName,
101  outFilename, "NetCDF4", // std::string strOutputFile, std::string strOutputFormat
102  false );
103  CHECK_EQUAL( ierr, 0 );
104 
105  // Compute the surface area of RLL mesh
106  const double sphere_area = tempest_mesh.CalculateFaceAreas( false );
107  CHECK_REAL_EQUAL( sphere_area, surface_area, 1e-10 );
108 }

References CHECK_EQUAL, CHECK_REAL_EQUAL, moab::error(), ierr, outFilenames, and surface_area.

Referenced by main().

◆ test_tempest_to_moab_convert()

void test_tempest_to_moab_convert ( )

Definition at line 171 of file test_remapping.cpp.

172 {
173  NcError error( NcError::verbose_nonfatal );
174 
175  // Allocate and create MOAB Remapper object
176  moab::ErrorCode rval;
177  moab::Interface* mbCore = new( std::nothrow ) moab::Core;
178  CHECK( NULL != mbCore );
179 
180 #ifdef MOAB_HAVE_MPI
181  moab::ParallelComm* pcomm = new moab::ParallelComm( mbCore, MPI_COMM_WORLD, 0 );
182  moab::TempestRemapper* remapper = new moab::TempestRemapper( mbCore, pcomm );
183 #else
184  moab::TempestRemapper* remapper = new moab::TempestRemapper( mbCore );
185 #endif
186  remapper->meshValidate = true;
187  remapper->constructEdgeMap = true;
188  remapper->initialize();
189 
190 #ifdef MOAB_HAVE_MPI
191  rval = pcomm->check_all_shared_handles();CHECK_ERR( rval );
192 #endif
193 
195 
196  // Load the meshes and validate
197  rval = remapper->ConvertTempestMesh( moab::Remapper::SourceMesh );CHECK_ERR( rval );
198 
199  Mesh* srcTempest = remapper->GetMesh( moab::Remapper::SourceMesh );
200 
202 
204 
205  tgtset = srcset;
206 
207  // Load the meshes and validate
208  rval = remapper->ConvertMeshToTempest( moab::Remapper::TargetMesh );CHECK_ERR( rval );
209 
210  Mesh* tgtTempest = remapper->GetMesh( moab::Remapper::TargetMesh );
211 
212  const size_t tempest_nodes_src = srcTempest->nodes.size(), tempest_elems_src = srcTempest->faces.size();
213  const size_t tempest_nodes_tgt = tgtTempest->nodes.size(), tempest_elems_tgt = tgtTempest->faces.size();
214  CHECK_EQUAL( tempest_nodes_src, tempest_nodes_tgt );
215  CHECK_EQUAL( tempest_elems_src, tempest_elems_tgt );
216 
217  delete remapper;
218 #ifdef MOAB_HAVE_MPI
219  delete pcomm;
220 #endif
221  delete mbCore;
222 }

References CHECK, moab::ParallelComm::check_all_shared_handles(), CHECK_EQUAL, CHECK_ERR, moab::TempestRemapper::constructEdgeMap, moab::TempestRemapper::ConvertMeshToTempest(), moab::TempestRemapper::ConvertTempestMesh(), moab::TempestRemapper::CS, moab::error(), ErrorCode, moab::TempestRemapper::GetMesh(), moab::TempestRemapper::GetMeshSet(), moab::TempestRemapper::initialize(), moab::TempestRemapper::LoadMesh(), moab::TempestRemapper::meshValidate, MPI_COMM_WORLD, outFilenames, moab::Remapper::SourceMesh, and moab::Remapper::TargetMesh.

Referenced by main().

Variable Documentation

◆ MOAB_PI

const double MOAB_PI = 3.1415926535897932384626433832795028841971693993751058209749445923

Definition at line 42 of file test_remapping.cpp.

◆ outFilenames

const std::string outFilenames[5]
static
Initial value:
= { "outTempestCS.g", "outTempestRLL.g", "outTempestICO.g", "outTempestICOD.g",
"outTempestOV.g" }

Definition at line 44 of file test_remapping.cpp.

Referenced by test_tempest_cs_create(), test_tempest_ico_create(), test_tempest_mpas_create(), test_tempest_overlap_combinations(), test_tempest_rll_create(), and test_tempest_to_moab_convert().

◆ radius

const double radius = 1.0
static

Definition at line 41 of file test_remapping.cpp.

◆ surface_area