184 double tauinv=1.0/tau;
202 for (
int icell=0; icell<ncells; icell++)
205 double klocal=(kappa(cells(icell,0))+kappa(cells(icell,1))+kappa(cells(icell,2)))/3.0;
208 double KLocal=(kappa(cells(icell,0))+kappa(cells(icell,1))+kappa(cells(icell,2)))/3.0;
212 for (
int i=0;i<=ndim;i++)
213 for (
int j=0;j<=ndim;j++)
215 SGlobal(cells(icell,i),cells(icell,j))+=theta*KLocal*SLocal(i,j)+ tauinv*vol*MLocal(i,j);
217 Rhs(cells(icell,i))+=((theta-1)*KLocal*SLocal(i,j)+tauinv*vol*MLocal(i,j))*
218 OldSol(cells(icell,j))+vol*MLocal(i,j)*source(cells(icell,j));
227 for (
int ibface=0; ibface<nbfaces; ibface++)
230 int ireg=bfaceregions(ibface);
231 int i0=bfaces(ibface,0);
232 int i1=bfaces(ibface,1);
238 SGlobal(i0,i0)+=bcfac(ireg);
239 Rhs(i0)+=bcfac(ireg)*bcval(ireg);
241 SGlobal(i1,i1)+=bcfac(ireg);
242 Rhs(i1)+=bcfac(ireg)*bcval(ireg);
244 else if (bcfac(ireg)>0.0)
247 double dx= points(bfaces(ibface,1),0)-points(bfaces(ibface,0),0);
248 double dy= points(bfaces(ibface,1),1)-points(bfaces(ibface,0),1);
249 double h=sqrt(dx*dx+dy*dy);
251 int i0=bfaces(ibface,0);
252 int i1=bfaces(ibface,1);
254 SGlobal(i0,i0)+=theta*h*bcfac(ireg)/3.0;
255 SGlobal(i0,i1)+=theta*h*bcfac(ireg)/6.0;
257 SGlobal(i1,i0)+=theta*h*bcfac(ireg)/6.0;
258 SGlobal(i1,i1)+=theta*h*bcfac(ireg)/3.0;
260 Rhs(i0)+=OldSol(i0)*(1.0-theta)*h*bcfac(ireg)/3.0;
261 Rhs(i0)+=OldSol(i1)*(1.0-theta)*h*bcfac(ireg)/6.0;
262 Rhs(i1)+=OldSol(i0)*(1.0-theta)*h*bcfac(ireg)/6.0;
263 Rhs(i1)+=OldSol(i1)*(1.0-theta)*h*bcfac(ireg)/3.0;
265 Rhs(i0)+=0.5*h*bcval(ireg);
266 Rhs(i0)+=0.5*h*bcval(ireg);
const int ncells() const
Return number of cells.
const int nbfaces() const
Return number of boundary faces.
void compute_local_stiffness_matrix(const int icell, const numcxx::DArray2 &points, const numcxx::IArray2 &cells, numcxx::DArray2 &SLocal, double &vol)
const TArray2< int > & get_bfaces() const
Get array of point indices describing boundary faces.
void flush()
Re-create the internal data structure in order to accomodated all newly created elements.
const TArray2< double > & get_points() const
Get array of point coordinates.
const TArray1< int > & get_bfaceregions() const
Get array of boundary markers.
const double Dirichlet
BC value marking Dirichlet boundary condition.
Two-dimensional array class.
const int npoints() const
Return number of points.
const TArray2< int > & get_cells() const
Get array of point indices describing cells.
const int spacedim() const
Return dimension of space.