| 1667 | |
| 1668 | |
| 1669 | //---------------------------------------------------------------------- |
| 1670 | // P0 Finite Element |
| 1671 | //---------------------------------------------------------------------- |
| 1672 | |
| 1673 | void plot_P0_fill( std::stringstream &Content, const Fem2D::Mesh &Th, const KN<double> &f_P0, |
| 1674 | const KNM<double> &palette, |
| 1675 | const int sizex, const int sizey, const double scale, const double ar, |
| 1676 | const double x0, const double y0, const double y1, |
| 1677 | const int marginl, const int marginb, |
| 1678 | const double textfontsize, const bool monochrome, |
| 1679 | const bool legend, const int prec, const bool logscale, |
| 1680 | const double withmesh, |
| 1681 | const long nbfill, const KN<double> *const frange ) |
| 1682 | { |
| 1683 | const int &nVertices = Th.nv; |
| 1684 | const int &nTriangles = Th.nt; |
| 1685 | const int &nEdges = Th.neb; |
| 1686 | const double &r = scale; |
| 1687 | |
| 1688 | const double fmax = (frange)? (*frange)[1]: f_P0.max(); |
| 1689 | const double fmin = (frange)? (*frange)[0]: f_P0.min(); |
| 1690 | const double df = (logscale)? |
| 1691 | exp( (static_cast<double>(1)/nbfill)*(log(fmax/fmin)) ): |
| 1692 | (fmax - fmin)/nbfill; |
| 1693 | |
| 1694 | std::stringstream &st = Content; |
| 1695 | st.str(""); |
| 1696 | |
| 1697 | //------------------------------ |
| 1698 | // element(triangle)-wise process |
| 1699 | //------------------------------ |
| 1700 | st << "q\n"; |
| 1701 | st << "1 0 0 1 " << PLOTPDFVAR::PADDING+marginl << " " << PLOTPDFVAR::PADDING+marginb << " cm\n"; |
| 1702 | |
| 1703 | for(int k = 0; k < nTriangles; k++){ |
| 1704 | |
| 1705 | const int &v0 = Th(k,0); |
| 1706 | const int &v1 = Th(k,1); |
| 1707 | const int &v2 = Th(k,2); |
| 1708 | |
| 1709 | const double &f = f_P0[k]; |
| 1710 | |
| 1711 | if( frange && (f < fmin) ) |
| 1712 | continue; |
| 1713 | if( frange && (f > fmax) ) |
| 1714 | continue; |
| 1715 | |
| 1716 | int level = (logscale)? |
| 1717 | static_cast<int>( log(f/fmin) / log(df) ): |
| 1718 | static_cast<int>( (f-fmin) / df ); |
| 1719 | |
| 1720 | if( level == 0 ){ |
| 1721 | setrgbcolor(st, fmin, palette, fmin, fmax, monochrome, logscale); |
| 1722 | } else if( level >= nbfill-1 ){ |
| 1723 | setrgbcolor(st, fmax, palette, fmin, fmax, monochrome, logscale); |
| 1724 | } else { |
| 1725 | const double c = (logscale)? (pow(df,level+0.5)*fmin): ((level+0.5)*df + fmin); |
| 1726 | setrgbcolor(st, c, palette, fmin, fmax, monochrome, logscale); |
no test coverage detected