SyFi
0.3
|
#include <Polygon.h>
Public Member Functions | |
Triangle (GiNaC::ex x0, GiNaC::ex x1, GiNaC::ex x2, const std::string &subscript="") | |
Triangle (const Triangle &triangle) | |
virtual | ~Triangle () |
virtual unsigned int | no_space_dim () const |
virtual Line | line (unsigned int i) const |
virtual GiNaC::ex | repr (Repr_format=SUBS_PERFORMED) const |
virtual const std::string | str () const |
virtual GiNaC::ex | integrate (GiNaC::ex f, Repr_format format=SUBS_PERFORMED) |
virtual Triangle * | copy () const |
Protected Member Functions | |
Triangle (const std::string &subscript="") |
SyFi::Triangle::Triangle | ( | const std::string & | subscript = "" | ) | [protected] |
Referenced by copy().
SyFi::Triangle::Triangle | ( | GiNaC::ex | x0, |
GiNaC::ex | x1, | ||
GiNaC::ex | x2, | ||
const std::string & | subscript = "" |
||
) |
SyFi::Triangle::Triangle | ( | const Triangle & | triangle | ) |
Definition at line 440 of file Polygon.cpp.
virtual SyFi::Triangle::~Triangle | ( | ) | [inline, virtual] |
Triangle * SyFi::Triangle::copy | ( | ) | const [virtual] |
Implements SyFi::Polygon.
Reimplemented in SyFi::ReferenceTriangle.
Definition at line 607 of file Polygon.cpp.
References Triangle().
{ return new Triangle(*this); }
ex SyFi::Triangle::integrate | ( | GiNaC::ex | f, |
Repr_format | format = SUBS_PERFORMED |
||
) | [virtual] |
Implements SyFi::Polygon.
Reimplemented in SyFi::ReferenceTriangle.
Definition at line 502 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(), SyFi::Robust::compute_basis_functions(), and main().
{ ex ret; if ( format == SUBS_PERFORMED ) { ex t_repr = repr(); lst sub; int counter=0; // perform substitution if ( p[0].nops() == 3) { sub = lst(t_repr.op(0), t_repr.op(1), t_repr.op(2)); counter = 3; } else if ( p[0].nops() == 2) { sub = lst(t_repr.op(0), t_repr.op(1)); counter = 2; } ex intf = func.subs(sub); // compute D ex D; if ( p[0].nops() == 3) { ex r = t_repr.op(3).op(0); ex s = t_repr.op(4).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(1).rhs().coeff(r,1); ex d = t_repr.op(1).rhs().coeff(s,1); ex e = t_repr.op(2).rhs().coeff(r,1); ex f = t_repr.op(2).rhs().coeff(s,1); D = pow(c*f-d*e,2) + pow(a*f - b*e,2) + pow(a*d - b*c,2); D = sqrt(D); } else if ( p[0].nops() == 2) { ex r = t_repr.op(2).op(0); ex s = t_repr.op(3).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(1).rhs().coeff(r,1); ex d = t_repr.op(1).rhs().coeff(s,1); D = abs(a*d-b*c); } intf = intf*D; counter++; intf = GiNaC::integral(t_repr.op(counter).op(0), t_repr.op(counter).op(1), t_repr.op(counter).op(2), intf); intf = eval_integ(intf); counter--; intf = GiNaC::integral(t_repr.op(counter).op(0), t_repr.op(counter).op(1), t_repr.op(counter).op(2), intf); ret = eval_integ(intf); } else if ( format == SUBS_NOT_PERFORMED ) { ex t_repr = repr(); lst sub; int counter=0; GiNaC::symbol a("a"), b("b"), c("c"), d("d"), e("e"), f("f"), r("r"), s("s"), D("D"); // perform substitution if ( p[0].nops() == 3) { sub = lst(x == p[0].op(0) + a*r + b*s, y == p[0].op(1) + c*r + d*s, z == p[0].op(2) + e*r + f*s); counter = 3; } else if ( p[0].nops() == 2) { sub = lst(t_repr.op(0), t_repr.op(1)); sub = lst(x == p[0].op(0) + a*r + b*s, y == p[0].op(1) + c*r + d*s); counter = 2; } ex intf = func.subs(sub); counter++; intf = GiNaC::integral(t_repr.op(counter).op(0), t_repr.op(counter).op(1), t_repr.op(counter).op(2), intf); intf = eval_integ(intf); counter--; intf = GiNaC::integral(t_repr.op(counter).op(0), t_repr.op(counter).op(1), t_repr.op(counter).op(2), intf); intf = eval_integ(intf); ret = intf*D; } else { throw std::runtime_error("Invalid format!"); } return ret; }
Line SyFi::Triangle::line | ( | unsigned int | i | ) | const [virtual] |
Reimplemented from SyFi::Polygon.
Definition at line 444 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::BrezziDouglasMarini::compute_basis_functions(), SyFi::Robust::compute_basis_functions(), SyFi::RaviartThomas::compute_basis_functions(), SyFi::Robust::compute_basis_functions_old(), main(), SyFi::normal(), and SyFi::tangent().
unsigned int SyFi::Triangle::no_space_dim | ( | ) | const [virtual] |
ex SyFi::Triangle::repr | ( | Repr_format | format = SUBS_PERFORMED | ) | const [virtual] |
Implements SyFi::Polygon.
Definition at line 454 of file Polygon.cpp.
References SyFi::Polygon::p, SyFi::Line::repr(), SyFi::Polygon::vertex(), and SyFi::x.
Referenced by integrate(), and main().
{ GiNaC::symbol r("r"), s("s"); GiNaC::symbol G("G"), H("H"); ex l1_repr = Line(vertex(0), vertex(1)).repr(r); ex l2_repr = Line(vertex(0), vertex(2)).repr(s); lst ret; //2D if ( p[0].nops() == 2) { 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, 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); } else if ( p[0].nops() == 3) { 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, 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, 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); } ret.append(lst(r, 0, 1)); ret.append(lst(s, 0, 1 - r)); return ret; }
const string SyFi::Triangle::str | ( | ) | const [virtual] |
Implements SyFi::Polygon.
Reimplemented in SyFi::ReferenceTriangle.
Definition at line 494 of file Polygon.cpp.
Referenced by main().
{ std::ostringstream s; // s <<"Triangle("<<p[0]<<","<<p[1]<<","<<p[2]<<")"; s <<"Triangle"; return s.str(); }