Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
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)

Protected Attributes

CartVect v1
Matrix3 transf

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

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

Definition at line 553 of file ElemUtil.cpp.

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

    {
        vertex.resize( vertices.size() );
        vertex = vertices;
        // project the vertices to the plane tangent at first vertex
        v1          = vertex[0];  // member data
        double v1v1 = v1 % v1;    // this is 1, in general, for unit sphere meshes
        for( int j = 1; j < 3; j++ )
        {
            // first, bring all vertices in the gnomonic plane
            //  the new vertex will intersect the plane at vnew
            //   so that (vnew-v1)%v1 is 0 ( vnew is in the tangent plane, i.e. normal to v1 )
            // pos is the old position of the vertex, and it is in general on the sphere
            // vnew = alfa*pos;  (alfa*pos-v1)%v1 = 0  <=> alfa*(pos%v1)=v1%v1 <=> alfa =
            // v1v1/(pos%v1)
            //  <=> vnew = ( v1v1/(pos%v1) )*pos
            CartVect vnew = v1v1 / ( vertex[j] % v1 ) * vertex[j];
            vertex[j]     = vnew;
        }
        // will compute a transf matrix, such that a new point will be transformed with
        // newpos =  transf * (vnew-v1), and it will be a point in the 2d plane
        // the transformation matrix will be oriented in such a way that orientation will be
        // positive
        CartVect vx = vertex[1] - v1;  // this will become Ox axis
        // z axis will be along v1, in such a way that orientation of the quad is positive
        // look at the first 2 edges
        CartVect vz = vx * ( vertex[2] - vertex[1] );
        vz          = vz / vz.length();

        vx = vx / vx.length();

        CartVect vy = vz * vx;
        transf      = Matrix3( vx[0], vx[1], vx[2], vy[0], vy[1], vy[2], vz[0], vz[1], vz[2] );
        vertex[0]   = CartVect( 0. );
        for( int j = 1; j < 3; j++ )
            vertex[j] = transf * ( vertex[j] - v1 );

        LinearTri::set_vertices( vertex );
    }
virtual moab::Element::SphericalTri::~SphericalTri ( ) [inline, virtual]

Definition at line 386 of file ElemUtil.hpp.

{};

Member Function Documentation

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.

References transf, and v1.

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

    {
        // project to the plane tangent at first vertex (gnomonic projection)
        double v1v1   = v1 % v1;
        CartVect vnew = v1v1 / ( x % v1 ) * x;  // so that (vnew-v1)%v1 is 0
        vnew          = transf * ( vnew - v1 );
        // det will be positive now
        return LinearTri::ievaluate( vnew );
    }
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.

References transf, and v1.

Referenced by test_spherical_tri().

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

Member Data Documentation

Definition at line 392 of file ElemUtil.hpp.

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

Definition at line 391 of file ElemUtil.hpp.

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

List of all members.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines