Mesh Oriented datABase  (version 5.5.0)
An array-based unstructured mesh library
case1_test.cpp File Reference
#include <iostream>
#include <cmath>
#include "moab/Core.hpp"
#include "moab/Interface.hpp"
#include "moab/IntxMesh/Intx2MeshOnSphere.hpp"
#include "moab/ProgOptions.hpp"
#include "MBTagConventions.hpp"
#include "moab/IntxMesh/IntxUtils.hpp"
#include "IntxUtilsCSLAM.hpp"
#include "TestUtil.hpp"
+ Include dependency graph for case1_test.cpp:

Go to the source code of this file.

Functions

ErrorCode manufacture_lagrange_mesh_on_sphere (Interface *mb, EntityHandle euler_set, EntityHandle &lagr_set)
 
int main (int argc, char **argv)
 

Variables

double gtol = 0.0001
 
double CubeSide = 6.
 
double t = 0.1
 
double delta_t = 0.43
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 97 of file case1_test.cpp.

98 {
99 
100  const char* filename_mesh1 = STRINGIFY( MESHDIR ) "/mbcslam/eulerHomme.vtk";
101  if( argc > 1 )
102  {
103  int index = 1;
104  while( index < argc )
105  {
106  if( !strcmp( argv[index], "-gtol" ) ) // this is for geometry tolerance
107  {
108  gtol = atof( argv[++index] );
109  }
110  if( !strcmp( argv[index], "-cube" ) )
111  {
112  CubeSide = atof( argv[++index] );
113  }
114  if( !strcmp( argv[index], "-dt" ) )
115  {
116  delta_t = atof( argv[++index] );
117  }
118  if( !strcmp( argv[index], "-input" ) )
119  {
120  filename_mesh1 = argv[++index];
121  }
122  index++;
123  }
124  }
125  std::cout << " case 1: use -gtol " << gtol << " -dt " << delta_t << " -cube " << CubeSide << " -input "
126  << filename_mesh1 << "\n";
127 
128  Core moab;
129  Interface& mb = moab;
130  EntityHandle euler_set;
131  ErrorCode rval;
132  rval = mb.create_meshset( MESHSET_SET, euler_set );
133  if( MB_SUCCESS != rval ) return 1;
134 
135  rval = mb.load_file( filename_mesh1, &euler_set );
136 
137  if( MB_SUCCESS != rval ) return 1;
138 
139  // everybody will get a DP tag, including the non owned entities; so exchange tags is not
140  // required for LOC (here)
141  EntityHandle lagrange_set;
142  rval = manufacture_lagrange_mesh_on_sphere( &mb, euler_set, lagrange_set );
143  if( MB_SUCCESS != rval ) return 1;
144  rval = mb.write_file( "lagrIni.h5m", 0, 0, &lagrange_set, 1 );
145  if( MB_SUCCESS != rval ) std::cout << "can't write lagr set\n";
146 
147  rval = moab::IntxUtils::enforce_convexity( &mb, lagrange_set );
148  if( MB_SUCCESS != rval ) return 1;
149 
150  rval = mb.write_file( "lagr.h5m", 0, 0, &lagrange_set, 1 );
151  if( MB_SUCCESS != rval ) std::cout << "can't write lagr set\n";
152 
153  Intx2MeshOnSphere worker( &mb );
154 
155  double radius = CubeSide / 2 * sqrt( 3. ); // input
156 
157  worker.set_radius_source_mesh( radius );
158  worker.set_radius_destination_mesh( radius );
159 
160  // worker.SetEntityType(MBQUAD);
161 
162  worker.set_error_tolerance( gtol );
163  std::cout << "error tolerance epsilon_1=" << gtol << "\n";
164 
165  EntityHandle outputSet;
166  rval = mb.create_meshset( MESHSET_SET, outputSet );
167  if( MB_SUCCESS != rval ) return 1;
168  rval = worker.FindMaxEdges( lagrange_set, euler_set );
169  if( MB_SUCCESS != rval ) return 1;
170  rval = worker.intersect_meshes( lagrange_set, euler_set, outputSet );
171  if( MB_SUCCESS != rval ) return 1;
172 
173  // std::string opts_write("");
174  std::stringstream outf;
175  outf << "intersect1"
176  << ".h5m";
177  rval = mb.write_file( outf.str().c_str(), 0, 0, &outputSet, 1 );
178  if( MB_SUCCESS != rval ) std::cout << "can't write output\n";
179 
180  moab::IntxAreaUtils sphAreaUtils;
181  double intx_area = sphAreaUtils.area_on_sphere( &mb, outputSet, radius );
182  double arrival_area = sphAreaUtils.area_on_sphere( &mb, euler_set, radius );
183  std::cout << " Arrival area: " << arrival_area << " intersection area:" << intx_area
184  << " rel error: " << fabs( ( intx_area - arrival_area ) / arrival_area ) << "\n";
185  if( MB_SUCCESS != rval ) return 1;
186 
187  return 0;
188 }

References moab::IntxAreaUtils::area_on_sphere(), moab::Core::create_meshset(), CubeSide, delta_t, moab::IntxUtils::enforce_convexity(), ErrorCode, moab::Intx2Mesh::FindMaxEdges(), gtol, moab::Intx2Mesh::intersect_meshes(), moab::Core::load_file(), manufacture_lagrange_mesh_on_sphere(), mb, MB_SUCCESS, MESHSET_SET, radius, moab::Intx2Mesh::set_error_tolerance(), moab::Intx2MeshOnSphere::set_radius_destination_mesh(), moab::Intx2MeshOnSphere::set_radius_source_mesh(), STRINGIFY, and moab::Core::write_file().

◆ manufacture_lagrange_mesh_on_sphere()

ErrorCode manufacture_lagrange_mesh_on_sphere ( Interface mb,
EntityHandle  euler_set,
EntityHandle lagr_set 
)

Definition at line 29 of file case1_test.cpp.

30 {
31  /*
32  * get all quads first, then vertices, then move them on the surface of the sphere
33  * radius is in, it comes from MeshKit/python/examples/manufHomme.py :
34  * length = 6.
35  * each edge of the cube will be divided using this meshcount
36  * meshcount = 11
37  * circumscribed sphere radius
38  * radius = length * math.sqrt(3) /2
39  */
40  double radius = CubeSide / 2 * sqrt( 3. ); // our value depends on cube side
41  Range quads;
42  ErrorCode rval = mb->get_entities_by_type( euler_set, MBQUAD, quads );
43  if( MB_SUCCESS != rval ) return rval;
44 
45  Range connecVerts;
46  rval = mb->get_connectivity( quads, connecVerts );
47  if( MB_SUCCESS != rval ) return rval;
48 
49  // create new set
50  rval = mb->create_meshset( MESHSET_SET, lagr_set );
51  if( MB_SUCCESS != rval ) return rval;
52 
53  // get the coordinates of the old mesh, and move it around the sphere according to case 1
54  // now put the vertices in the right place....
55  // int vix=0; // vertex index in new array
56 
57  // first create departure points (vertices in the lagrange mesh)
58  // then connect them in quads
59  std::map< EntityHandle, EntityHandle > newNodes;
60  for( Range::iterator vit = connecVerts.begin(); vit != connecVerts.end(); ++vit )
61  {
62  EntityHandle oldV = *vit;
63  CartVect posi;
64  rval = mb->get_coords( &oldV, 1, &( posi[0] ) );
65  if( MB_SUCCESS != rval ) return rval;
66  // Intx utils, case 1
67  CartVect newPos;
69  newPos = radius * newPos;
70  EntityHandle new_vert;
71  rval = mb->create_vertex( &( newPos[0] ), new_vert );
72  if( MB_SUCCESS != rval ) return rval;
73  newNodes[oldV] = new_vert;
74  }
75  for( Range::iterator it = quads.begin(); it != quads.end(); ++it )
76  {
77  EntityHandle q = *it;
78  int nnodes;
79  const EntityHandle* conn4;
80  rval = mb->get_connectivity( q, conn4, nnodes );
81  if( MB_SUCCESS != rval ) return rval;
82  EntityHandle new_conn[4];
83  for( int i = 0; i < nnodes; i++ )
84  {
85  EntityHandle v1 = conn4[i];
86  new_conn[i] = newNodes[v1];
87  }
88  EntityHandle new_quad;
89  rval = mb->create_element( MBQUAD, new_conn, 4, new_quad );
90  if( MB_SUCCESS != rval ) return rval;
91  rval = mb->add_entities( lagr_set, &new_quad, 1 );
92  if( MB_SUCCESS != rval ) return rval;
93  }
94 
95  return rval;
96 }

References moab::Core::add_entities(), moab::Range::begin(), moab::Core::create_element(), moab::Core::create_meshset(), moab::Core::create_vertex(), CubeSide, delta_t, IntxUtilsCSLAM::departure_point_case1(), moab::Range::end(), ErrorCode, moab::Core::get_connectivity(), moab::Core::get_coords(), moab::Core::get_entities_by_type(), mb, MB_SUCCESS, MBQUAD, MESHSET_SET, radius, and t.

Referenced by main().

Variable Documentation

◆ CubeSide

double CubeSide = 6.

Definition at line 26 of file case1_test.cpp.

Referenced by main(), and manufacture_lagrange_mesh_on_sphere().

◆ delta_t

◆ gtol

double gtol = 0.0001

Definition at line 25 of file case1_test.cpp.

Referenced by main().

◆ t

double t = 0.1

Definition at line 27 of file case1_test.cpp.

Referenced by add_tag_counts(), MetisPartitioner::assemble_taggedsets_graph(), moab::ReadNASTRAN::assign_ids(), moab::HiReconstruction::average_vertex_tangent(), moab::box_from_axes(), moab::SequenceManager::clear(), moab::GeomUtil::closest_location_on_polygon(), moab::GeomUtil::closest_location_on_tri(), moab::NCWriteHelper::collect_variable_data(), compute_tracer_case1(), compute_velocity_case1(), moab::ReadCGM::create_group_entsets(), moab::Coupler::create_tuples(), moab::BSPTreePoly::cut_polyhedron(), moab::ReadABAQUS::cyl2rect(), moab::Skinner::deinitialize(), IntxUtilsCSLAM::departure_point_case1(), departure_point_swirl(), departure_point_swirl_rot(), moab::HalfFacetRep::determine_border_vertices(), moab::CN::Dimension(), moab::ParallelComm::estimate_ents_buffer_size(), moab::VarLenDenseTag::find_entities_with_value(), moab::DenseTag::find_entities_with_value(), moab::Skinner::find_skin_vertices_3D(), gather_tag_counts(), get_departure_grid(), moab::ReorderTool::get_entities(), moab::SequenceManager::get_entities(), moab::BitTag::get_entities_with_bits(), moab::Coupler::get_matching_entities(), moab::BitTag::get_memory_use(), moab::DenseTag::get_memory_use(), moab::VarLenDenseTag::get_memory_use(), moab::AEntityFactory::get_memory_use(), moab::SequenceManager::get_number_entities(), moab::ReadUtil::get_ordered_vertices(), moab::get_tagged(), moab::BitTag::get_tagged(), moab::DenseTag::get_tagged_entities(), ProgOptions::getOpt(), moab::ReorderTool::handle_order_from_int_tag(), moab::NCHelperEuler::init_mesh_vals(), moab::NCHelperFV::init_mesh_vals(), moab::NCHelperGCRM::init_mesh_vals(), moab::NCHelperHOMME::init_mesh_vals(), moab::NCHelperMPAS::init_mesh_vals(), moab::Coupler::interpolate(), moab::RayIntersectSets::leaf(), moab::TempestOnlineMap::LinearRemapGLLtoGLL2_MOAB(), moab::TempestOnlineMap::LinearRemapGLLtoGLL2_Pointwise_MOAB(), moab::Core::load_file(), lob_bnd_2(), main(), manufacture_lagrange_mesh_on_sphere(), MBCN_Dimension(), MBCN_NumSubEntities(), MBCN_VerticesPerEntity(), min_edge_length(), moab::Coupler::normalize_subset(), moab::CN::NumSubEntities(), moab::WriteHDF5::ExportType::operator!=(), moab::WriteHDF5::ExportType::operator<(), moab::operator<<(), moab::WriteHDF5::ExportType::operator==(), MetisPartitioner::partition_mesh(), ZoltanPartitioner::partition_mesh_and_geometry(), moab::ParallelMergeMesh::PerformRealSort(), moab::permute_this(), moab::CN::permuteThis(), moab::plane_cut_edge(), moab::point_perp(), moab::SmoothCurve::position_from_u(), moab::Core::print_database(), moab::FBEngine::print_debug_triangle(), print_memory_stats(), print_tag_counts(), moab::WriteHDF5::print_times(), moab::DGMSolver::qr_polyfit_safeguarded(), moab::TupleList::radix_index_sort(), moab::TupleList::radix_offsets(), moab::AdaptiveKDTree::ray_intersect_triangles(), moab::OrientedBoxTreeTool::ray_intersect_triangles(), moab::SmoothFace::ray_intersection_correct(), moab::GeomUtil::ray_tri_intersect(), moab::ReadHDF5::read_elems(), moab::ScdNCHelper::read_scd_variables_to_nonset(), moab::ScdNCHelper::read_scd_variables_to_nonset_allocate(), moab::NCHelperGCRM::read_ucd_variables_to_nonset(), moab::NCHelperHOMME::read_ucd_variables_to_nonset(), moab::NCHelperMPAS::read_ucd_variables_to_nonset(), moab::NCHelperGCRM::read_ucd_variables_to_nonset_allocate(), moab::NCHelperHOMME::read_ucd_variables_to_nonset_allocate(), moab::NCHelperMPAS::read_ucd_variables_to_nonset_allocate(), moab::NCHelper::read_variables_to_set(), moab::NCHelper::read_variables_to_set_allocate(), moab::GQT_IntRegCtxt::register_intersection(), moab::BitTag::release_all_data(), moab::SequenceManager::release_tag_array(), moab::ReorderTool::reorder_entities(), ZoltanPartitioner::repartition(), moab::CN::resetPermutation(), moab::ParallelComm::resolve_shared_sets(), moab::rev_permute_this(), moab::CN::revPermuteThis(), moab::CN::setPermutation(), moab::TagInfo::size_from_data_type(), moab::ReadABAQUS::sph2rect(), moab::OrientedBoxTreeTool::sphere_intersect_triangles(), moab::Range::subset_by_type(), moab::ParallelMergeMesh::SwapTuples(), moab::HomXform::three_pt_xform(), moab::Core::valid_tag_handle(), IntxUtilsCSLAM::velocity_case1(), moab::CN::VerticesPerEntity(), moab::WriteVtk::write_bit_tag(), moab::WriteVtk::write_elems(), moab::NCWriteGCRM::write_nonset_variables(), moab::ScdNCWriteHelper::write_nonset_variables(), moab::NCWriteHOMME::write_nonset_variables(), moab::NCWriteMPAS::write_nonset_variables(), moab::WriteHDF5::write_qa(), moab::WriteVtk::write_tag(), and moab::TempestOnlineMap::WriteHDF5MapFile().