# JordanBlocher/hermes-tutorial forked from hpfem/hermes-tutorial

### Subversion checkout URL

You can clone with
or
.
Fetching contributors…

Cannot retrieve contributors at this time

109 lines (89 sloc) 3.99 KB
 #include "definitions.h" CustomWeakForm::CustomWeakForm(Hermes::vector newton_boundaries, double heatcap, double rho, double tau, double lambda, double alpha, double temp_ext, Solution* sln_prev_time, bool JFNK) : WeakForm(1, JFNK) { // Jacobian forms - volumetric. add_matrix_form(new JacobianFormVol(0, 0, heatcap, rho, lambda, tau)); // Jacobian forms - surface. add_matrix_form_surf(new JacobianFormSurf(0, 0, newton_boundaries, alpha, lambda)); // Residual forms - volumetric. ResidualFormVol* res_form = new ResidualFormVol(0, heatcap, rho, lambda, tau); res_form->ext.push_back(sln_prev_time); add_vector_form(res_form); // Residual forms - surface. add_vector_form_surf(new ResidualFormSurf(0, newton_boundaries, alpha, lambda, temp_ext)); } double CustomWeakForm::JacobianFormVol::value(int n, double *wt, Func *u_ext[], Func *u, Func *v, Geom *e, ExtData *ext) const { double result = 0; for (int i = 0; i < n; i++) result += wt[i] * (heatcap * rho * u->val[i] * v->val[i] / tau + lambda * (u->dx[i] * v->dx[i] + u->dy[i] * v->dy[i])); return result; } Ord CustomWeakForm::JacobianFormVol::ord(int n, double *wt, Func *u_ext[], Func *u, Func *v, Geom *e, ExtData *ext) const { // Returning the sum of the degrees of the basis and test function plus two. return Ord(10); } MatrixFormVol* CustomWeakForm::JacobianFormVol::clone() { return new CustomWeakForm::JacobianFormVol(*this); } double CustomWeakForm::JacobianFormSurf::value(int n, double *wt, Func *u_ext[], Func *u, Func *v, Geom *e, ExtData *ext) const { double result = 0; for (int i = 0; i < n; i++) result += wt[i] * alpha * lambda * u->val[i] * v->val[i]; return result; } Ord CustomWeakForm::JacobianFormSurf::ord(int n, double *wt, Func *u_ext[], Func *u, Func *v, Geom *e, ExtData *ext) const { // Returning the sum of the degrees of the basis and test function plus two. return Ord(10); } MatrixFormSurf* CustomWeakForm::JacobianFormSurf::clone() { return new CustomWeakForm::JacobianFormSurf(*this); } double CustomWeakForm::ResidualFormVol::value(int n, double *wt, Func *u_ext[], Func *v, Geom *e, ExtData *ext) const { double result = 0; for (int i = 0; i < n; i++) result += wt[i] * (heatcap * rho * (u_ext[0]->val[i] - ext->fn[0]->val[i]) * v->val[i] / tau + lambda * (u_ext[0]->dx[i] * v->dx[i] + u_ext[0]->dy[i] * v->dy[i])); return result; } Ord CustomWeakForm::ResidualFormVol::ord(int n, double *wt, Func *u_ext[], Func *v, Geom *e, ExtData *ext) const { // Returning the sum of the degrees of the test function and solution plus two. return Ord(10); } VectorFormVol* CustomWeakForm::ResidualFormVol::clone() { return new CustomWeakForm::ResidualFormVol(*this); } double CustomWeakForm::ResidualFormSurf::value(int n, double *wt, Func *u_ext[], Func *v, Geom *e, ExtData *ext) const { double result = 0; for (int i = 0; i < n; i++) result += wt[i] * alpha * lambda * (u_ext[0]->val[i] - temp_ext) * v->val[i]; return result; } Ord CustomWeakForm::ResidualFormSurf::ord(int n, double *wt, Func *u_ext[], Func *v, Geom *e, ExtData *ext) const { // Returning the sum of the degrees of the test function and solution plus two. return Ord(10); } VectorFormSurf* CustomWeakForm::ResidualFormSurf::clone() { return new CustomWeakForm::ResidualFormSurf(*this); }
Something went wrong with that request. Please try again.