void PDESolver<T,lFunc,rFunc,bFunc,tFunc,force>::generateB() { m_B = Vector<T>((m_size - 1) * (m_size - 1)); ulong index = 0; T hVal = (m_rightBound - m_leftBound) / ((T)m_size); T x,y; for(ulong i = 1; i < m_size; i++) { for(ulong j = 1; j < m_size; j++) { m_B.at(index) = 0; x = ((T)j * (m_rightBound - m_leftBound))/m_size + m_leftBound; y = ((T)i * (m_upperBound - m_lowerBound))/m_size + m_lowerBound; if(i - 1 == 0) m_B.at(index) += bFunc(x); if(i + 1 == m_size) m_B.at(index) += tFunc(x); if(j - 1 == 0) m_B.at(index) += lFunc(y); if(j + 1 == m_size) m_B.at(index) += rFunc(y); m_B.at(index) -= hVal*hVal*force(x,y); m_B.at(index) /= 4; index++; } } }
bool emit( xmlNode & node ) { string name = node.name; pf_map::iterator pos = function_map.find(name); if( pos!=function_map.end() ) { base_functor & rFunc = * pos->second; rFunc(node); } }
void PDESolver<T,lFunc,rFunc,bFunc,tFunc,force>::gnuPlotify( const Vector<T>& sol, const string &method) const { string size; stringstream strStream; strStream<<m_size; strStream>>size; ofstream pnts,up,down,left,right; pnts.open(("points"+method+size+".dat").c_str()); up.open(("up"+method+size+".dat").c_str()); down.open(("down"+method+size+".dat").c_str()); left.open(("left"+method+size+".dat").c_str()); right.open(("right"+method+size+".dat").c_str()); T val = (m_upperBound-m_lowerBound)/m_size; for(unsigned long i = 0;i<m_size;i++) { up<<m_upperBound<<","<<val<<","<<tFunc(val)<<endl; down<<m_lowerBound<<","<<val<<","<<bFunc(val)<<endl; left<<val<<","<<m_leftBound<<","<<lFunc(val)<<endl; right<<val<<","<<m_rightBound<<","<<rFunc(val)<<endl; } for(unsigned long i = 0;i<(m_size-1)*(m_size-1);i++) { T y = i/(m_size-1); T x = i%(m_size-1); pnts<<x*val<<", "<<y*val<<", "<<sol[i]<<endl; } pnts.close(); up.close(); down.close(); left.close(); right.close(); }