Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Misc/MeshTransform.cpp
Go to the documentation of this file.
1 /* *****************************************************************
2  MESQUITE -- The Mesh Quality Improvement Toolkit
3 
4  Copyright 2004 Sandia Corporation and Argonne National
5  Laboratory. Under the terms of Contract DE-AC04-94AL85000
6  with Sandia Corporation, the U.S. Government retains certain
7  rights in this software.
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  (lgpl.txt) along with this library; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 
23  diachin2@llnl.gov, djmelan@sandia.gov, mbrewer@sandia.gov,
24  pknupp@sandia.gov, tleurent@mcs.anl.gov, tmunson@mcs.anl.gov
25 
26  ***************************************************************** */
38 #include "MeshTransform.hpp"
39 #include "MeshSet.hpp"
40 #include "MsqTimer.hpp"
41 #include "MsqDebug.hpp"
42 
43 namespace Mesquite {
51  {
52  mMat = in_mat;
53  mVec = in_vec;
56  }
58  int param1=0, int param2=0) {
59  if(patch_type != PatchData::ELEMENTS_ON_VERTEX_PATCH ||
60  param1 != 0){
61  MSQ_SETERR(err)("Patch type must be ELEMENTS_ON_VERTEX_PATCH, depth 1.\n", MsqError::INVALID_ARG);
62  }
64  0, param2);
65  }
66 
73  {
74  //This shouldn't be an issue, but make sure the patch type is still
75  //correct.
77  MSQ_SETERR(err)("Incorrect patch type being used.\n",
79  return 1.;
80  }
81  //get the first patch
82  PatchData patch_data;
83  bool next_patch=ms.get_next_patch(patch_data, this, err);
84  assert(!err);
85  if(err)
86  return 1.0;
87  //loop over the patches (ie, loop over the vertices.
88  while( next_patch )
89  {
90  //make sure we have a vertex.
91  if(patch_data.num_vertices()!=1){
92  MSQ_SETERR(err)( "Incorrect patch depth being used.",
94  return 1.;
95  }
96  MsqVertex* vert_array = patch_data.get_vertex_array(err);
97  if(err)
98  return 1.0;
99  //perform the affine transormation
100  Vector3D temp_vec = vert_array[0];
101  vert_array[0]=mMat*temp_vec+mVec;
102  //update the vertex postion
103  patch_data.update_mesh(err);
104  //get the next patch
105  next_patch = ms.get_next_patch(patch_data, this, err);
106  if(err)
107  return 1.0;
108  }
109  //return
110  return 0.;
111  }
112 
113 } // namespace Mesquite
void update_mesh(MsqError &err)
Updates the underlying mesh (the Mesquite::Mesh implementation) with new node coordinates and flag va...
MeshTransform(Matrix3D &in_mat, Vector3D &in_vec, MsqError &err)
virtual void set_patch_type(PatchData::PatchType patch_type, MsqError &err, int param1=0, int param2=0)
Sets the Patch Type.
Used to hold the error state and return it to the application.
Vector3D is the object that effeciently stores information about about three-deminsional vectors...
virtual void set_patch_type(PatchData::PatchType patch_type, MsqError &err, int param1, int param2)
MeshTransform is built to use ELEMETNS_ON_VERTEX_PATCH with a depth one.
invalid function argument passed
virtual double loop_over_mesh(MeshSet &ms, MsqError &err)
Loop over the mesh and perform the affine transformation.
3*3 Matric class, row-oriented, 0-based [i][j] indexing.
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
PatchData::PatchType get_patch_type()
Returns the Patch Type.
Vector3D mVec
Matrix for the affine transformation.
PatchType
Tells MeshSet how to retrieve the mesh entities that will be stored in PatchData. ...
size_t num_vertices() const
number of vertices in the patch.
const MsqVertex * get_vertex_array(MsqError &err) const
Returns a pointer to the start of the vertex array.
void no_culling_method()
Sets off all culling methods.
object is in an invalid state
MsqVertex is the Mesquite object that stores information about the vertices in the mesh...
The MeshSet class stores one or more Mesquite::Mesh pointers and manages access to the mesh informati...
bool get_next_patch(PatchData &pd, PatchDataUser *pd_user, MsqError &err)
Gets the next PatchData.