Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
addfield.cpp File Reference
#include <iostream>
#include "moab/Core.hpp"
#include <cmath>
#include <cstdlib>
#include <cassert>
+ Include dependency graph for addfield.cpp:

Go to the source code of this file.

Namespaces

 moab
 Class representing axis-aligned bounding box.
 

Functions

double moab::physField (double x, double y, double z, double factor)
 
void moab::putElementField (Interface *mbi, const char *tagname, double factor)
 
void moab::putSpectralElementField (Interface *mbi, int dim, int np, const char *tagname, double factor)
 
void moab::putVertexField (Interface *mbi, const char *tagname, double factor)
 
int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 130 of file addfield.cpp.

131 {
132 
133  using namespace moab;
134 
135  Interface* mbi = new Core();
136 
137  if( argc < 3 )
138  {
139  cout << "Usage: " << argv[0] << " <infile> <outfile> [factor]\n"
140  << "Writes both vertex and element fields.\n";
141  return 0;
142  }
143 
144  mbi->load_mesh( argv[1] );
145 
146  double factor = 1.0;
147  if( argc == 4 ) factor = atof( argv[3] );
148 
149  putVertexField( mbi, "vertex_field", factor );
150  putElementField( mbi, "element_field", factor );
151  // putSpectralElementField(mbi, 2, 4, "spectral_element_field", factor);
152  putSpectralElementField( mbi, 2, 4, "a2oTAG", factor );
153 
154  ErrorCode result = mbi->write_mesh( argv[2] );
155  if( MB_SUCCESS == result )
156  cout << "wrote " << argv[2] << endl;
157  else
158  cout << "Failed to write " << argv[2] << endl;
159 
160  // vector<double> coords;
161  // mbi->get_vertex_coordinates(coords);
162  // double xavg = 0;
163  // for (int i = 0; i < coords.size()/3; i++) xavg += coords[i];
164  // cout << xavg << endl;
165 
166  return 1;
167 }

References ErrorCode, moab::Interface::load_mesh(), MB_SUCCESS, moab::putElementField(), moab::putSpectralElementField(), moab::putVertexField(), and moab::Interface::write_mesh().