moab
DeformMeshRemap.cpp File Reference
#include "moab/Core.hpp"
#include "moab/Range.hpp"
#include "moab/Skinner.hpp"
#include "moab/LloydSmoother.hpp"
#include "moab/ProgOptions.hpp"
#include "moab/BoundBox.hpp"
#include "moab/SpatialLocator.hpp"
#include "MBTagConventions.hpp"
#include "DataCoupler.hpp"
#include "moab/Error.hpp"
#include <iostream>
#include <set>
#include <sstream>
#include <assert.h>

Go to the source code of this file.

Classes

class  DeformMeshRemap

Defines

#define IS_BUILDING_MB
#define MESH_DIR   "."
#define RR(a)   if (MB_SUCCESS != rval) {cout << a << endl; return MB_FAILURE;}

Functions

ErrorCode read_file (string &fname, EntityHandle &seth, Range &solids, Range &solid_elems, Range &fluids, Range &fluid_elems)
void deform_func (const BoundBox &bbox, double *xold, double *xnew)
ErrorCode deform_master (Range &fluid_elems, Range &solid_elems, Tag &xnew)
ErrorCode smooth_master (int dim, Tag xnew, EntityHandle &master, Range &fluids)
ErrorCode write_to_coords (Range &elems, Tag tagh)
int main (int argc, char **argv)

Variables

const int SOLID_SETNO = 100
const int FLUID_SETNO = 200
Interfacemb
const bool debug = true

Define Documentation

#define IS_BUILDING_MB

Definition at line 23 of file DeformMeshRemap.cpp.

#define RR (   a)    if (MB_SUCCESS != rval) {cout << a << endl; return MB_FAILURE;}

Definition at line 53 of file DeformMeshRemap.cpp.


Function Documentation

void deform_func ( const BoundBox bbox,
double *  xold,
double *  xnew 
)
Examples:
DeformMeshRemap.cpp.

Definition at line 515 of file DeformMeshRemap.cpp.

{
/*  Deformation function based on max delx and dely at top of rod
    const double RODWIDTH = 0.2, RODHEIGHT = 0.5;
    // function: origin is at middle base of rod, and is .5 high
    // top of rod is (0,.55) on left and (.2,.6) on right
  double delx = 0.5*RODWIDTH;
  
  double xfrac = (xold[0] + .5*RODWIDTH)/RODWIDTH, yfrac = xold[1]/RODHEIGHT;
  xnew[0] = xold[0] + yfrac * delx;
  xnew[1] = xold[1] + yfrac * (1.0 + xfrac) * 0.05;
*/
/* Deformation function based on fraction of bounding box dimension in each direction */
  double frac = 0.01; // taken from approximate relative deformation from LLNL Diablo of XX09 assys
  CartVect *xo = reinterpret_cast<CartVect*>(xold), *xn = reinterpret_cast<CartVect*>(xnew);
  CartVect disp = frac * (*xo - bbox.bMin);
  *xn = *xo + disp;
}
ErrorCode deform_master ( Range fluid_elems,
Range solid_elems,
Tag xnew 
)
Examples:
DeformMeshRemap.cpp.
int main ( int  argc,
char **  argv 
)

Definition at line 401 of file DeformMeshRemap.cpp.

                                {

  ErrorCode rval;

  ProgOptions po("Deformed mesh options");
  po.addOpt<std::string> ("master,m", "Specify the master meshfile name" );
  po.addOpt<std::string> ("worker,w", "Specify the slave/worker meshfile name, or 'none' (no quotes) if master only" );
  po.addOpt<std::string> ("d1,", "Tag name for displacement x or xyz" );
  po.addOpt<std::string> ("d2,", "Tag name for displacement y" );
  po.addOpt<std::string> ("d3,", "Tag name for displacement z" );
  po.addOpt<int> ("fm,", "Specify master fluid material set number(s). If none specified, fluid sets derived from complement of solid sets.");
  po.addOpt<int> ("fs,", "Specify master solid material set number(s). If none specified, solid sets derived from complement of fluid sets.");
  po.addOpt<int> ("sm,", "Specify slave fluid material set number(s). If none specified, fluid sets derived from complement of solid sets.");
  po.addOpt<int> ("ss,", "Specify slave solid material set number(s). If none specified, solid sets derived from complement of fluid sets.");
  
  po.parseCommandLine(argc, argv);

  mb = new Core();

  DeformMeshRemap *dfr;
#ifdef USE_MPI
  ParallelComm *pc = new ParallelComm(mb, MPI_COMM_WORLD);
  dfr = new DeformMeshRemap(mb, pc);
#else  
  dfr = new DeformMeshRemap(mb);
#endif


  std::string masterf, slavef;
  if(!po.getOpt("master", &masterf))
    masterf = string(MESH_DIR) + string("/rodquad.g");
  dfr->set_file_name(DeformMeshRemap::MASTER, masterf);

  if(!po.getOpt("worker", &slavef))
    slavef = string(MESH_DIR) + string("/rodtri.g");
  dfr->set_file_name(DeformMeshRemap::SLAVE, slavef);
  if (slavef.empty()) {
    std::cerr << "Empty slave file name; if no slave, use filename 'none' (no quotes)." << std::endl;
    return 1;
  }

  std::vector<int> set_nos;
  po.getOptAllArgs("fm", set_nos);
  for (std::vector<int>::iterator vit = set_nos.begin(); vit != set_nos.end(); vit++) 
    dfr->add_set_no(DeformMeshRemap::MASTER, DeformMeshRemap::FLUID, *vit);
  set_nos.clear();
  
  po.getOptAllArgs("fs", set_nos);
  for (std::vector<int>::iterator vit = set_nos.begin(); vit != set_nos.end(); vit++) 
    dfr->add_set_no(DeformMeshRemap::SLAVE, DeformMeshRemap::FLUID, *vit);
  set_nos.clear();
  
  po.getOptAllArgs("sm", set_nos);
  for (std::vector<int>::iterator vit = set_nos.begin(); vit != set_nos.end(); vit++) 
    dfr->add_set_no(DeformMeshRemap::MASTER, DeformMeshRemap::SOLID, *vit);

  po.getOptAllArgs("ss", set_nos);
  for (std::vector<int>::iterator vit = set_nos.begin(); vit != set_nos.end(); vit++) 
    dfr->add_set_no(DeformMeshRemap::SLAVE, DeformMeshRemap::SOLID, *vit);

  std::string tnames[3];
  po.getOpt("d1", &tnames[0]);
  po.getOpt("d2", &tnames[1]);
  po.getOpt("d3", &tnames[2]);
  for (int i = 0; i < 3; i++) 
    if (!tnames[i].empty()) dfr->xdisp_name(tnames[i], i);
  
  rval = dfr->execute();
  
  delete dfr;
  delete mb;
  
  return rval;
}
ErrorCode read_file ( string &  fname,
EntityHandle seth,
Range solids,
Range solid_elems,
Range fluids,
Range fluid_elems 
)
Examples:
DeformMeshRemap.cpp.
ErrorCode smooth_master ( int  dim,
Tag  xnew,
EntityHandle master,
Range fluids 
)
Examples:
DeformMeshRemap.cpp.
ErrorCode write_to_coords ( Range elems,
Tag  tagh 
)
Examples:
DeformMeshRemap.cpp.

Variable Documentation

const bool debug = true

Definition at line 55 of file DeformMeshRemap.cpp.

const int FLUID_SETNO = 200
Examples:
DeformMeshRemap.cpp.

Definition at line 50 of file DeformMeshRemap.cpp.

Definition at line 52 of file DeformMeshRemap.cpp.

const int SOLID_SETNO = 100
Examples:
DeformMeshRemap.cpp.

Definition at line 50 of file DeformMeshRemap.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines