00001 /************************************************************************ 00002 File pdh_heat_weakform.h - weakform functions for heat 00003 00004 Contains declarations of routines: 00005 pdr_heat_select_el_coeff - to select coefficients returned to approximation 00006 routines for element integrals 00007 00008 pdr_heat_el_coeff - to return coefficients for element integrals 00009 00010 pdr_heat_comp_el_stiff_mat - to construct a stiffness matrix and 00011 a load vector for an element 00012 00013 pdr_heat_comp_fa_stiff_mat - to construct a stiffness matrix and 00014 a load vector for a face 00015 00016 pdr_heat_get_temperature_at_point - to provide the temperature and its 00017 gradient at a particular point given its local coordinates within an element 00018 MODULE PROVIDES IMPLEMENTATION FOR ALL OTHER MODULES (in pds_heat_weakform.c) 00019 00020 pdr_heat_normpu 00021 pdr_heat_ksireynolds 00022 pdr_heat_ksipeclet 00023 pdr_heat_reynoldslocal 00024 pdr_heat_pecletlocal 00025 pdr_heat_mk 00026 pdr_heat_sigma 00027 pdr_heat_tau_therm 00028 pdr_heat_tau_fluid 00029 00030 ------------------------------ 00031 History: 00032 2011 - Przemyslaw Plaszewski (pplaszew@agh.edu.pl) 00033 2012 - Krzysztof Banas (pobanas@cyf-kr.edu.pl) 00034 *************************************************************************/ 00035 00036 #ifndef PDH_HEAT_WEAKFORM 00037 #define PDH_HEAT_WEAKFORM 00038 00039 #include<stdio.h> 00040 00041 #ifdef __cplusplus 00042 extern "C"{ 00043 #endif 00044 00045 /**************************************/ 00046 /* INTERNAL PROCEDURES */ 00047 /**************************************/ 00048 /* Rules: 00049 /* - name always begins with pdr_ */ 00050 /* - argument names start uppercase */ 00051 00056 int pdr_heat_select_el_coeff_vect( // returns success indicator 00057 int Problem_id, 00058 int *Coeff_vect_ind /* out: coefficient indicator */ 00059 ); 00060 00066 extern double* pdr_heat_select_el_coeff( 00067 /* returns: pointer !=NULL to indicate selection */ 00068 int Problem_id, 00069 double **Mval, /* out: mass matrix coefficient */ 00070 double **Axx,double **Axy,double **Axz, /* out:diffusion coefficients, e.g.*/ 00071 double **Ayx,double **Ayy,double **Ayz, /* Axy denotes scalar or matrix */ 00072 double **Azx,double **Azy,double **Azz, /* related to terms with dv/dx*du/dy */ 00073 /* second order derivatives in weak formulation (scalar for scalar problems */ 00074 /* matrix for vector problems) */ 00075 /* WARNING: if axy==NULL only diagonal (axx, ayy, azz) terms are considered */ 00076 /* in apr_num_int_el */ 00077 double **Bx,double **By,double **Bz, /* out: convection coefficients */ 00078 /* Bx denotes scalar or matrix related to terms with du/dx*v in weak form */ 00079 double **Tx,double **Ty,double **Tz, /* out: convection coefficients */ 00080 /* Tx denotes scalar or matrix related to terms with u*dv/dx in weak form */ 00081 double **Cval,/* out: reaction coefficients - for terms without derivatives */ 00082 /* in weak form (as usual: scalar for scalar problems, matrix for vectors) */ 00083 double **Lval,/* out: rhs coefficient for time term, Lval denotes scalar */ 00084 /* or matrix corresponding to time derivative - similar as mass matrix but */ 00085 /* with known solution at the previous time step (usually denoted by u_n) */ 00086 double **Qx,/* out: rhs coefficients for terms with derivatives */ 00087 double **Qy,/* Qy denotes scalar or matrix corresponding to terms with dv/dy */ 00088 double **Qz,/* derivatives in weak formulation */ 00089 double **Sval /* out: rhs coefficients without derivatives (source terms) */ 00090 ); 00091 00095 extern int pdr_heat_el_coeff( 00096 int Problem_id, 00097 int Elem, /* in: element number */ 00098 int Mat_num, /* in: material number */ 00099 double Hsize, /* in: size of an element */ 00100 int Pdeg, /* in: local degree of polynomial */ 00101 double *X_loc, /* in: local coordinates of point within element */ 00102 double *Base_phi, /* in: basis functions */ 00103 double *Base_dphix, /* in: x-derivatives of basis functions */ 00104 double *Base_dphiy, /* in: y-derivatives of basis functions */ 00105 double *Base_dphiz, /* in: z-derivatives of basis functions */ 00106 double *Xcoor, /* in: global coordinates of a point */ 00107 double *Uk_val, /* in: computed solution from previous iteration */ 00108 double *Uk_x, /* in: gradient of computed solution Uk_val */ 00109 double *Uk_y, /* in: gradient of computed solution Uk_val */ 00110 double *Uk_z, /* in: gradient of computed solution Uk_val */ 00111 double *Un_val, /* in: computed solution from previous time step */ 00112 double *Un_x, /* in: gradient of computed solution Un_val */ 00113 double *Un_y, /* in: gradient of computed solution Un_val */ 00114 double *Un_z, /* in: gradient of computed solution Un_val */ 00115 double *Mval, /* out: mass matrix coefficient */ 00116 double *Axx, double *Axy, double *Axz, /* out:diffusion coefficients */ 00117 double *Ayx, double *Ayy, double *Ayz, /* e.g. Axy denotes scalar or matrix */ 00118 double *Azx, double *Azy, double *Azz, /* related to terms with dv/dx*du/dy */ 00119 /* second order derivatives in weak formulation (scalar for scalar problems */ 00120 /* matrix for vector problems) */ 00121 double *Bx, double *By, double *Bz, /* out: convection coefficients */ 00122 /* Bx denotes scalar or matrix related to terms with du/dx*v in weak form */ 00123 double *Tx, double *Ty, double *Tz, /* out: convection coefficients */ 00124 /* Tx denotes scalar or matrix related to terms with u*dv/dx in weak form */ 00125 double *Cval, /* out: reaction coefficients - for terms without derivatives */ 00126 /* in weak form (as usual: scalar for scalar problems, matrix for vectors) */ 00127 double *Lval, /* out: rhs coefficient for time term, Lval denotes scalar */ 00128 /* or matrix corresponding to time derivative - similar as mass matrix but */ 00129 /* with known solution at the previous time step (usually denoted by u_n) */ 00130 double *Qx, /* out: rhs coefficients for terms with derivatives */ 00131 double *Qy, /* Qy denotes scalar or matrix corresponding to terms with dv/dy */ 00132 double *Qz, /* derivatives in weak formulation */ 00133 double *Sval, /* out: rhs coefficients without derivatives (source terms) */ 00134 /* arguments SPECIFIC to heat problem */ 00135 double *Velocity, // in: velocity vector at point 00136 //double Thermal_diffusivity, // in: thermal diffusivity - old 00137 double Thermal_conductivity, // in: thermal conductivity - new 00138 double Density_times_specific_heat, // in: density*specific_heat - new 00139 double Delta_t, // in: current time step 00140 double Implicitness_coeff // in: implicitnes parameter alpha 00141 ); 00142 00147 extern int pdr_heat_comp_el_stiff_mat(/*returns: >=0 -success code, <0 -error code */ 00148 int Problem_id, /* in: approximation field ID */ 00149 int El_id, /* in: unique identifier of the element */ 00150 int Comp_sm, /* in: indicator for the scope of computations: */ 00151 /* PDC_NO_COMP - do not compute anything */ 00152 /* PDC_COMP_SM - compute entries to stiff matrix only */ 00153 /* PDC_COMP_RHS - compute entries to rhs vector only */ 00154 /* PDC_COMP_BOTH - compute entries for sm and rhsv */ 00155 int Pdeg_in, /* in: enforced degree of polynomial (if > 0 ) */ 00156 int *Nrdofs_loc, /* in(optional): size of Stiff_mat and Rhs_vect */ 00157 /* out(optional): actual number of dofs per integration entity */ 00158 double *Stiff_mat, /* out(optional): stiffness matrix stored columnwise */ 00159 double *Rhs_vect, /* out(optional): rhs vector */ 00160 char *Rewr_dofs /* out(optional): flag to rewrite or sum up entries */ 00161 /* 'T' - true, rewrite entries when assembling */ 00162 /* 'F' - false, sum up entries when assembling */ 00163 ); 00164 00169 extern int pdr_heat_comp_fa_stiff_mat(/*returns: >=0 -success code, <0 -error code */ 00170 int Problem_id, /* in: approximation field ID */ 00171 int Fa_id, /* in: unique identifier of the face */ 00172 int Comp_sm, /* in: indicator for the scope of computations: */ 00173 /* PDC_NO_COMP - do not compute anything */ 00174 /* PDC_COMP_SM - compute entries to stiff matrix only */ 00175 /* PDC_COMP_RHS - compute entries to rhs vector only */ 00176 /* PDC_COMP_BOTH - compute entries for sm and rhsv */ 00177 int Pdeg_in, /* in: enforced degree of polynomial (if > 0 ) */ 00178 int *Nrdofs_loc, /* in(optional): size of Stiff_mat and Rhs_vect */ 00179 /* out(optional): actual number of dofs per integration entity */ 00180 double *Stiff_mat, /* out(optional): stiffness matrix stored columnwise */ 00181 double *Rhs_vect, /* out(optional): rhs vector */ 00182 char *Rewr_dofs /* out(optional): flag to rewrite or sum up entries */ 00183 /* 'T' - true, rewrite entries when assembling */ 00184 /* 'F' - false, sum up entries when assembling */ 00185 ); 00186 00192 extern int pdr_heat_get_temperature_at_point( 00193 int Problem_id, 00194 int El_id, // element 00195 double *X_loc, // local coordinates of point 00196 double *Base_phi, // shape functions at point (if available - to speed up) 00197 double *Base_dphix, // derivatives of shape functions at point 00198 double *Base_dphiy, // derivatives of shape functions at point 00199 double *Base_dphiz, // derivatives of shape functions at point 00200 double *Temp, // temperature 00201 double *DTemp_dx, // x-derivative of temperature 00202 double *DTemp_dy, // y-derivative of temperature 00203 double *DTemp_dz // z-derivative of temperature 00204 ); 00205 00212 extern int pdr_heat_give_me_dtdt_at_point( 00213 int Problem_id, 00214 int El_id, // element 00215 double *X_loc, // local coordinates of point 00216 double *Base_phi, // shape functions at point (if available - to speed up) 00217 double *Base_dphix, // derivatives of shape functions at point 00218 double *Base_dphiy, // derivatives of shape functions at point 00219 double *Base_dphiz, // derivatives of shape functions at point 00220 double *dtdt, // temperature 00221 double *Ddtdt_dx, // x-derivative of temperature 00222 double *Ddtdt_dy, // y-derivative of temperature 00223 double *Ddtdt_dz // z-derivative of temperature 00224 ); 00225 00231 extern int pdr_heat_get_dtdt_at_point( 00232 int Problem_id, 00233 int El_id, // element 00234 double *X_loc, // local coordinates of point 00235 double *Base_phi, // shape functions at point (if available - to speed up) 00236 double *Base_dphix, // derivatives of shape functions at point 00237 double *Base_dphiy, // derivatives of shape functions at point 00238 double *Base_dphiz, // derivatives of shape functions at point 00239 double *dtdt, // temperature 00240 double *Ddtdt_dx, // x-derivative of temperature 00241 double *Ddtdt_dy, // y-derivative of temperature 00242 double *Ddtdt_dz // z-derivative of temperature 00243 ); 00244 00245 /* EXCEPTIONS FROM NAMING CONVENTION HERE: 00246 functions below are small computational ones without variable definitions 00247 No need to distinguish arguments */ 00248 00249 extern double pdr_heat_normpu(int p, double u_x, double u_y, double u_z); 00250 extern double pdr_heat_ksipeclet(double peclet); 00251 extern double pdr_heat_pecletlocal(double m_k, double h_k, double normp_u, double diffusitvity); 00252 extern double pdr_heat_mk(); 00253 extern double pdr_heat_tau(double h_k, double normp_u, double ksi_peclet); 00254 00255 #ifdef __cplusplus 00256 } 00257 #endif 00258 00259 #endif