Mesh Oriented datABase  (version 5.5.0)
An array-based unstructured mesh library
moab::Element::SphericalTri Class Reference

Shape function space for linear triangle on sphere, obtained from the canonical linear (affine) functions. It is mapped using gnomonic projection to a plane tangent at the first vertex It works well for edges that are great circle arcs; RLL meshes do not have this property, but HOMME or MPAS meshes do have it. More...

#include <ElemUtil.hpp>

+ Inheritance diagram for moab::Element::SphericalTri:
+ Collaboration diagram for moab::Element::SphericalTri:

Public Member Functions

 SphericalTri (const std::vector< CartVect > &vertices)
 
virtual ~SphericalTri ()
 
virtual bool inside_box (const CartVect &pos, double &tol) const
 
CartVect ievaluate (const CartVect &x, double tol=1e-6, const CartVect &x0=CartVect(0.0)) const
 Evaluate the inverse map (calculate \(\vec \xi = F^-1($\vec x)\) to given tolerance) More...
 
- Public Member Functions inherited from moab::Element::LinearTri
 LinearTri (const std::vector< CartVect > &vertices)
 
 LinearTri ()
 
virtual ~LinearTri ()
 
virtual CartVect evaluate (const CartVect &xi) const
 Evaluate the map on \(x_i\) (calculate \(\vec x = F($\vec \xi)\) ) More...
 
virtual Matrix3 jacobian (const CartVect &) const
 Evaluate the map's Jacobi matrix. More...
 
virtual Matrix3 ijacobian (const CartVect &) const
 Evaluate the inverse of the Jacobi matrix. More...
 
virtual double det_jacobian (const CartVect &) const
 Evaluate the determinate of the Jacobi matrix. More...
 
virtual double det_ijacobian (const CartVect &) const
 Evaluate the determinate of the inverse Jacobi matrix. More...
 
virtual void set_vertices (const std::vector< CartVect > &v)
 Set vertices.
More...
 
virtual bool inside_nat_space (const CartVect &xi, double &tol) const
 decide if within the natural param space, with a tolerance More...
 
virtual double evaluate_scalar_field (const CartVect &xi, const double *field_vertex_values) const
 Evaluate a scalar field at a point given field values at the vertices. More...
 
virtual double integrate_scalar_field (const double *field_vertex_values) const
 Integrate a scalar field over the element given field values at the vertices. More...
 
- Public Member Functions inherited from moab::Element::Map
 Map (const std::vector< CartVect > &v)
 Construct a Map defined by the given std::vector of vertices. More...
 
 Map (const unsigned int n)
 Construct a Map defined by n vertices. More...
 
virtual ~Map ()
 
unsigned int size ()
 Size of the vertices vector. More...
 
const std::vector< CartVect > & get_vertices ()
 Retrieve vertices. More...
 

Protected Attributes

CartVect v1
 
Matrix3 transf
 
- Protected Attributes inherited from moab::Element::LinearTri
Matrix3 T
 
Matrix3 T_inverse
 
double det_T
 
double det_T_inverse
 
- Protected Attributes inherited from moab::Element::Map
std::vector< CartVectvertex
 

Additional Inherited Members

- Static Protected Attributes inherited from moab::Element::LinearTri
static const double corner [3][3] = { { 0, 0, 0 }, { 1, 0, 0 }, { 0, 1, 0 } }
 

Detailed Description

Shape function space for linear triangle on sphere, obtained from the canonical linear (affine) functions. It is mapped using gnomonic projection to a plane tangent at the first vertex It works well for edges that are great circle arcs; RLL meshes do not have this property, but HOMME or MPAS meshes do have it.

Definition at line 382 of file ElemUtil.hpp.

Constructor & Destructor Documentation

◆ SphericalTri()

moab::Element::SphericalTri::SphericalTri ( const std::vector< CartVect > &  vertices)

Definition at line 553 of file ElemUtil.cpp.

554  {
555  vertex.resize( vertices.size() );
556  vertex = vertices;
557  // project the vertices to the plane tangent at first vertex
558  v1 = vertex[0]; // member data
559  double v1v1 = v1 % v1; // this is 1, in general, for unit sphere meshes
560  for( int j = 1; j < 3; j++ )
561  {
562  // first, bring all vertices in the gnomonic plane
563  // the new vertex will intersect the plane at vnew
564  // so that (vnew-v1)%v1 is 0 ( vnew is in the tangent plane, i.e. normal to v1 )
565  // pos is the old position of the vertex, and it is in general on the sphere
566  // vnew = alfa*pos; (alfa*pos-v1)%v1 = 0 <=> alfa*(pos%v1)=v1%v1 <=> alfa =
567  // v1v1/(pos%v1)
568  // <=> vnew = ( v1v1/(pos%v1) )*pos
569  CartVect vnew = v1v1 / ( vertex[j] % v1 ) * vertex[j];
570  vertex[j] = vnew;
571  }
572  // will compute a transf matrix, such that a new point will be transformed with
573  // newpos = transf * (vnew-v1), and it will be a point in the 2d plane
574  // the transformation matrix will be oriented in such a way that orientation will be
575  // positive
576  CartVect vx = vertex[1] - v1; // this will become Ox axis
577  // z axis will be along v1, in such a way that orientation of the quad is positive
578  // look at the first 2 edges
579  CartVect vz = vx * ( vertex[2] - vertex[1] );
580  vz = vz / vz.length();
581 
582  vx = vx / vx.length();
583 
584  CartVect vy = vz * vx;
585  transf = Matrix3( vx[0], vx[1], vx[2], vy[0], vy[1], vy[2], vz[0], vz[1], vz[2] );
586  vertex[0] = CartVect( 0. );
587  for( int j = 1; j < 3; j++ )
588  vertex[j] = transf * ( vertex[j] - v1 );
589 
591  }

References moab::CartVect::length(), moab::Element::LinearTri::set_vertices(), transf, and v1.

◆ ~SphericalTri()

virtual moab::Element::SphericalTri::~SphericalTri ( )
inlinevirtual

Definition at line 386 of file ElemUtil.hpp.

386 {};

Member Function Documentation

◆ ievaluate()

CartVect moab::Element::SphericalTri::ievaluate ( const CartVect x,
double  tol = 1e-6,
const CartVect x0 = CartVect( 0.0 ) 
) const
virtual

Evaluate the inverse map (calculate \(\vec \xi = F^-1($\vec x)\) to given tolerance)

Reimplemented from moab::Element::LinearTri.

Definition at line 593 of file ElemUtil.cpp.

594  {
595  // project to the plane tangent at first vertex (gnomonic projection)
596  double v1v1 = v1 % v1;
597  CartVect vnew = v1v1 / ( x % v1 ) * x; // so that (vnew-v1)%v1 is 0
598  vnew = transf * ( vnew - v1 );
599  // det will be positive now
600  return LinearTri::ievaluate( vnew );
601  }

References moab::Element::LinearTri::ievaluate(), transf, and v1.

Referenced by moab::Coupler::nat_param(), and test_spherical_tri().

◆ inside_box()

bool moab::Element::SphericalTri::inside_box ( const CartVect pos,
double &  tol 
) const
virtual

Reimplemented from moab::Element::Map.

Definition at line 603 of file ElemUtil.cpp.

604  {
605  // project to the plane tangent at first vertex
606  // CartVect v1=vertex[0];
607  double v1v1 = v1 % v1;
608  CartVect vnew = v1v1 / ( pos % v1 ) * pos; // so that (x-v1)%v1 is 0
609  vnew = transf * ( vnew - v1 );
610  return Map::inside_box( vnew, tol );
611  }

References moab::Element::Map::inside_box(), transf, and v1.

Referenced by test_spherical_tri().

Member Data Documentation

◆ transf

Matrix3 moab::Element::SphericalTri::transf
protected

Definition at line 392 of file ElemUtil.hpp.

Referenced by ievaluate(), inside_box(), and SphericalTri().

◆ v1

CartVect moab::Element::SphericalTri::v1
protected

Definition at line 391 of file ElemUtil.hpp.

Referenced by ievaluate(), inside_box(), and SphericalTri().


The documentation for this class was generated from the following files: