SyFi  0.3
SyFi::Tetrahedron Class Reference

#include <Polygon.h>

Inheritance diagram for SyFi::Tetrahedron:
SyFi::Polygon SyFi::ReferenceTetrahedron

List of all members.

Public Member Functions

 Tetrahedron (GiNaC::ex x0, GiNaC::ex x1, GiNaC::ex x2, GiNaC::ex x3, const std::string &subscript="")
 Tetrahedron (const Tetrahedron &tetrahedron)
virtual ~Tetrahedron ()
virtual unsigned int no_space_dim () const
virtual Line line (unsigned int i) const
virtual Triangle triangle (unsigned int i) const
virtual GiNaC::ex repr (Repr_format format=SUBS_PERFORMED) const
virtual const std::string str () const
virtual GiNaC::ex integrate (GiNaC::ex f, Repr_format format=SUBS_PERFORMED)
virtual Tetrahedroncopy () const

Detailed Description

Definition at line 176 of file Polygon.h.


Constructor & Destructor Documentation

SyFi::Tetrahedron::Tetrahedron ( GiNaC::ex  x0,
GiNaC::ex  x1,
GiNaC::ex  x2,
GiNaC::ex  x3,
const std::string &  subscript = "" 
)

Referenced by copy().

SyFi::Tetrahedron::Tetrahedron ( const Tetrahedron tetrahedron)

Definition at line 892 of file Polygon.cpp.

: Polygon(tetrahedron) { }
virtual SyFi::Tetrahedron::~Tetrahedron ( ) [inline, virtual]

Definition at line 181 of file Polygon.h.

{}

Member Function Documentation

Tetrahedron * SyFi::Tetrahedron::copy ( ) const [virtual]

Implements SyFi::Polygon.

Reimplemented in SyFi::ReferenceTetrahedron.

Definition at line 1051 of file Polygon.cpp.

References Tetrahedron().

        {
                return new Tetrahedron(*this);
        }
ex SyFi::Tetrahedron::integrate ( GiNaC::ex  f,
Repr_format  format = SUBS_PERFORMED 
) [virtual]

Implements SyFi::Polygon.

Reimplemented in SyFi::ReferenceTetrahedron.

Definition at line 971 of file Polygon.cpp.

References test_syfi::debug::c, run_tests::f, SyFi::Polygon::p, repr(), SyFi::sub(), SyFi::SUBS_NOT_PERFORMED, SyFi::SUBS_PERFORMED, and SyFi::x.

Referenced by SyFi::Nedelec::compute_basis_functions(), SyFi::Nedelec2Hdiv::compute_basis_functions(), SyFi::RaviartThomas::compute_basis_functions(), and main().

        {
                ex ret;

                if ( format == SUBS_PERFORMED )
                {
                        ex t_repr = repr();
                        //      std::cout <<"t "<<t_repr<<std::endl;

                        //perform substitution
                        lst sub = lst(t_repr.op(0), t_repr.op(1), t_repr.op(2));
                        ex intf = func.subs(sub);

                        // compute D
                        ex D;
                        ex r = t_repr.op(3).op(0);
                        ex s = t_repr.op(4).op(0);
                        ex t = t_repr.op(5).op(0);
                        ex a = t_repr.op(0).rhs().coeff(r,1);
                        ex b = t_repr.op(0).rhs().coeff(s,1);
                        ex c = t_repr.op(0).rhs().coeff(t,1);
                        ex d = t_repr.op(1).rhs().coeff(r,1);
                        ex e = t_repr.op(1).rhs().coeff(s,1);
                        ex f = t_repr.op(1).rhs().coeff(t,1);
                        ex g = t_repr.op(2).rhs().coeff(r,1);
                        ex h = t_repr.op(2).rhs().coeff(s,1);
                        ex k = t_repr.op(2).rhs().coeff(t,1);

                        D = a*(e*k-f*h) - b*(d*k-f*g) + c*(d*h - g*e);

                        intf = intf*D;

                        intf = GiNaC::integral(t_repr.op(5).op(0), t_repr.op(5).op(1), t_repr.op(5).op(2), intf);
                        intf = GiNaC::eval_integ(intf);

                        intf = GiNaC::integral(t_repr.op(4).op(0), t_repr.op(4).op(1), t_repr.op(4).op(2), intf);
                        intf = GiNaC::eval_integ(intf);

                        intf = GiNaC::integral(t_repr.op(3).op(0), t_repr.op(3).op(1), t_repr.op(3).op(2), intf);
                        ret = GiNaC::eval_integ(intf);

                }
                else if ( format == SUBS_NOT_PERFORMED )
                {
                        ex t_repr = repr();

                        GiNaC::symbol a("a"), b("b"), c("c"), d("d"), e("e"), f("f"), g("g"), h("h"), k("k"), D("D");
                        ex r = t_repr.op(3).op(0);
                        ex s = t_repr.op(4).op(0);
                        ex t = t_repr.op(5).op(0);

                        //perform substitution
                        //    lst sub = lst(t_repr.op(0), t_repr.op(1), t_repr.op(2));
                        ex sub = lst(
                                x == p[0].op(0) + a*r + b*s + c*t,
                                y == p[0].op(1) + d*r + e*s + f*t,
                                z == p[0].op(2) + g*r + h*s + k*t);

                        ex intf = func.subs(sub);

                        intf = GiNaC::integral(t_repr.op(5).op(0), t_repr.op(5).op(1), t_repr.op(5).op(2), intf);
                        intf = GiNaC::eval_integ(intf);

                        intf = GiNaC::integral(t_repr.op(4).op(0), t_repr.op(4).op(1), t_repr.op(4).op(2), intf);
                        intf = GiNaC::eval_integ(intf);

                        intf = GiNaC::integral(t_repr.op(3).op(0), t_repr.op(3).op(1), t_repr.op(3).op(2), intf);
                        intf = GiNaC::eval_integ(intf);

                        ret = intf*D;

                }
                else
                {
                        throw std::runtime_error("Invalid format.");
                }

                return ret;
        }
Line SyFi::Tetrahedron::line ( unsigned int  i) const [virtual]

Reimplemented from SyFi::Polygon.

Definition at line 899 of file Polygon.cpp.

References SyFi::istr(), SyFi::Polygon::p, and SyFi::Polygon::subscript.

Referenced by SyFi::Nedelec::compute_basis_functions().

        {
                int i0, i1;
                switch(i)
                {
                        case 0:  i0 = 0; i1 = 1;  break;
                        case 1:  i0 = 0; i1 = 2;  break;
                        case 2:  i0 = 0; i1 = 3;  break;
                        case 3:  i0 = 1; i1 = 2;  break;
                        case 4:  i0 = 1; i1 = 3;  break;
                        case 5:  i0 = 2; i1 = 3;  break;
                        default:
                                throw std::out_of_range("Line index is out of range!");
                }
                return Line(p[i0], p[i1], istr(subscript,i));
        }
unsigned int SyFi::Tetrahedron::no_space_dim ( ) const [virtual]

Implements SyFi::Polygon.

Definition at line 894 of file Polygon.cpp.

        {
                return 3;
        }
ex SyFi::Tetrahedron::repr ( Repr_format  format = SUBS_PERFORMED) const [virtual]

Implements SyFi::Polygon.

Definition at line 940 of file Polygon.cpp.

References SyFi::Line::repr(), SyFi::t, SyFi::Polygon::vertex(), and SyFi::x.

Referenced by integrate(), and main().

        {
                GiNaC::symbol r("r"), s("s"), t("t");
                ex l1_repr = Line(vertex(0), vertex(1)).repr(r);
                ex l2_repr = Line(vertex(0), vertex(2)).repr(s);
                ex l3_repr = Line(vertex(0), vertex(3)).repr(t);
                lst ret;

                ret = lst(
                        x == l1_repr.op(0).rhs().coeff(r,0)   + l1_repr.op(0).rhs().coeff(r,1)*r
                        +    l2_repr.op(0).rhs().coeff(s,1)*s + l3_repr.op(0).rhs().coeff(t,1)*t,
                        y == l1_repr.op(1).rhs().coeff(r,0)   + l1_repr.op(1).rhs().coeff(r,1)*r
                        +    l2_repr.op(1).rhs().coeff(s,1)*s + l3_repr.op(1).rhs().coeff(t,1)*t,
                        z == l1_repr.op(2).rhs().coeff(r,0)   + l1_repr.op(2).rhs().coeff(r,1)*r
                        +    l2_repr.op(2).rhs().coeff(s,1)*s + l3_repr.op(2).rhs().coeff(t,1)*t);

                ret.append(lst(r, 0, 1));
                ret.append(lst(s, 0, 1 - r));
                ret.append(lst(t, 0, 1 - r - s));

                return ret;
        }
const string SyFi::Tetrahedron::str ( ) const [virtual]

Implements SyFi::Polygon.

Reimplemented in SyFi::ReferenceTetrahedron.

Definition at line 963 of file Polygon.cpp.

Referenced by main().

        {
                std::ostringstream s;
                //    s <<"Tetrahedron("<<p[0]<<","<<p[1]<<","<<p[2]<<","<<p[3]<<")";
                s <<"Tetrahedron";
                return s.str();
        }
Triangle SyFi::Tetrahedron::triangle ( unsigned int  i) const [virtual]

Reimplemented from SyFi::Polygon.

Definition at line 916 of file Polygon.cpp.

References SyFi::istr(), SyFi::Polygon::p, and SyFi::Polygon::subscript.

Referenced by SyFi::CrouzeixRaviart::compute_basis_functions(), SyFi::Nedelec::compute_basis_functions(), SyFi::Nedelec2Hdiv::compute_basis_functions(), SyFi::RaviartThomas::compute_basis_functions(), and SyFi::normal().

        {

                if ( i == 0 )
                {
                        return Triangle(p[1], p[2], p[3], istr(subscript,i));
                }
                else if ( i == 1)
                {
                        return Triangle(p[0], p[2], p[3], istr(subscript,i));
                }
                else if ( i == 2)
                {
                        return Triangle(p[0], p[1], p[3], istr(subscript,i));
                }
                else if ( i == 3)
                {
                        return Triangle(p[0], p[1], p[2], istr(subscript,i));
                }

                throw std::out_of_range("Face index is out of range!");

        }

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