Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Misc/SphericalDomain.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  kraftche@cae.wisc.edu
26 
27  ***************************************************************** */
28 #include "Mesquite.hpp"
29 #include "SphericalDomain.hpp"
30 #include "Vector3D.hpp"
31 
32 #ifdef HAVE_IEEEFP
33 # include <ieeefp.h>
34 #endif
35 
37  Vector3D &coordinate) const
38 {
39  // Get vector center to coordinate, store in coordinate.
40  coordinate -= mCenter;
41  // Get distance from center of sphere
42  double len = coordinate.length();
43  // Scale vector to have length of radius
44  coordinate *= mRadius / len;
45  // If was at center, return arbitrary position on sphere
46  // (all possitions are equally close)
47  if (!finite(coordinate.x()))
48  coordinate.set( mRadius, 0.0, 0.0 );
49  // Get position from vector
50  coordinate += mCenter;
51 }
52 
54  Vector3D &coordinate) const
55 {
56  // normal is vector from center to input position
57  coordinate -= mCenter;
58  // make it a unit vector
59  double length = coordinate.length();
60  coordinate /= length;
61  // if input position was at center, choose same position
62  // on sphere as snap_to.
63  if (!finite(coordinate.x()))
64  coordinate.set( 1.0, 0.0, 0.0 );
65 }
66 
68  Mesquite::Vector3D coords[],
69  unsigned count,
70  Mesquite::MsqError& ) const
71 {
72  for (unsigned i = 0; i < count; ++i)
73  normal_at( handle, coords[i] );
74 }
75 
77  const Mesquite::Vector3D& position,
78  Mesquite::Vector3D& closest,
79  Mesquite::Vector3D& normal,
80  Mesquite::MsqError& ) const
81 {
82  normal = position - mCenter;
83  normal.normalize();
84  if (!finite(normal.x()))
85  normal.set( 1.0, 0.0, 0.0 );
86  closest = mCenter + mRadius * normal;
87 }
88 
89 
90 
virtual void normal_at(Mesh::EntityHandle entity_handle, Vector3D &coordinate) const
Returns the normal of the domain to which &quot;entity_handle&quot; is constrained.
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...
void * EntityHandle
Opaque EntityHandle type and tag type.
double length(Vector3D *const v, int n)
blockLoc i
Definition: read.cpp:79
virtual void snap_to(Mesh::EntityHandle entity_handle, Vector3D &coordinate) const
Modifies &quot;coordinate&quot; so that it lies on the domain to which &quot;entity_handle&quot; is constrained.
void set(const double x, const double y, const double z)
virtual void closest_point(Mesh::EntityHandle handle, const Vector3D &position, Vector3D &closest, Vector3D &normal, MsqError &err) const
evaluate closest point and normal