MOAB: Mesh Oriented datABase  (version 5.2.1)
update_tracer.cpp
Go to the documentation of this file.
00001 #include "iMesh.h"
00002 #include "MBiMesh.hpp"
00003 #include "moab/Core.hpp"
00004 #include "moab/Range.hpp"
00005 #include "moab/IntxMesh/Intx2MeshOnSphere.hpp"
00006 #include "moab/IntxMesh/IntxUtils.hpp"
00007 #include "IntxUtilsCSLAM.hpp"
00008 
00009 extern "C" void update_tracer( iMesh_Instance instance, iBase_EntitySetHandle imesh_euler_set, int* ierr )
00010 {
00011     using namespace moab;
00012     const double radius = 1.;
00013     const double gtol   = 1.e-9;
00014     const bool debug    = false;
00015 
00016     Range ents;
00017     moab::Interface* mb = MOABI;
00018     *ierr               = 1;
00019 
00020     EntityHandle euler_set = (EntityHandle)imesh_euler_set;
00021 
00022     Intx2MeshOnSphere worker( mb );
00023     worker.set_radius_source_mesh( radius );
00024     worker.set_radius_destination_mesh( radius );
00025     worker.set_error_tolerance( gtol );
00026 
00027     EntityHandle covering_lagr_set;
00028 
00029     ErrorCode rval = mb->create_meshset( MESHSET_SET, covering_lagr_set );MB_CHK_SET_ERR_RET( rval, "can't create covering set " );
00030 
00031     // we need to update the correlation tag and remote tuples
00032     rval = worker.create_departure_mesh_2nd_alg( euler_set, covering_lagr_set );MB_CHK_SET_ERR_RET( rval, "can't populate covering set " );
00033 
00034     if( debug )
00035     {
00036         rval = mb->write_file( "lagr.h5m", 0, 0, &covering_lagr_set, 1 );MB_CHK_SET_ERR_RET( rval, "can't write covering set " );
00037     }
00038 
00039     // enforce convexity for the set
00040     rval = moab::IntxUtils::enforce_convexity( mb, covering_lagr_set );MB_CHK_SET_ERR_RET( rval, "can't write covering set " );
00041 
00042     EntityHandle outputSet;
00043     rval = mb->create_meshset( MESHSET_SET, outputSet );MB_CHK_SET_ERR_RET( rval, "can't create output set " );
00044 
00045     rval = worker.intersect_meshes( covering_lagr_set, euler_set, outputSet );MB_CHK_SET_ERR_RET( rval, "can't intersect " );
00046 
00047     if( debug )
00048     {
00049         rval = mb->write_file( "output.vtk", 0, 0, &outputSet, 1 );MB_CHK_SET_ERR_RET( rval, "can't write covering set " );
00050     }
00051 
00052     // tagElem is the average computed at each element, from nodal values
00053     Tag tagElem = 0;
00054     std::string tag_name2( "TracerAverage" );
00055     rval = mb->tag_get_handle( tag_name2.c_str(), 1, MB_TYPE_DOUBLE, tagElem, MB_TAG_DENSE | MB_TAG_CREAT );MB_CHK_SET_ERR_RET( rval, "can't get tracer tag " );
00056 
00057     // area of the euler element is fixed, store it; it is used to recompute the averages at each
00058     // time step
00059     Tag tagArea = 0;
00060     std::string tag_name4( "Area" );
00061     rval = mb->tag_get_handle( tag_name4.c_str(), 1, MB_TYPE_DOUBLE, tagArea, MB_TAG_DENSE | MB_TAG_CREAT );MB_CHK_SET_ERR_RET( rval, "can't get area tag" );
00062 
00063     rval = worker.update_tracer_data( outputSet, tagElem, tagArea );MB_CHK_SET_ERR_RET( rval, "can't update tracer " );
00064 
00065     // everything can be deleted now from intx data; polygons, etc.
00066 
00067     *ierr = 0;
00068     return;
00069 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines