00001 #include "sourcet.h"
00002 #include "globalt.h"
00003 #include "globmatt.h"
00004
00005 sourcet::sourcet()
00006 {
00007
00008 sourtype = (sourcetype) 0;
00009
00010
00011 gf=NULL;
00012
00013
00014 v = 0.0;
00015
00016
00017 hydrh=NULL;
00018
00019
00020
00021 }
00022
00023 sourcet::~sourcet()
00024 {
00025 delete gf;
00026 delete hydrh;
00027
00028 }
00029
00030
00031
00032
00033
00034
00035
00036
00037 long sourcet::read (XFILE *in)
00038 {
00039
00040
00041 switch (Tp->tprob){
00042 case stationary_problem:{
00043 xfscanf (in, "%k%lf", "src_val", &v);
00044 break;
00045 }
00046 case nonstationary_problem:
00047 case nonlinear_nonstationary_problem:
00048 case discont_nonstat_problem:
00049 case discont_nonlin_nonstat_problem:
00050 case growing_np_problem:
00051 case growing_np_problem_nonlin:{
00052
00053
00054
00055 xfscanf (in,"%k%m","src_type", &sourcetype_kwdset, &sourtype);
00056
00057 switch (sourtype){
00058 case matfunction:{
00059 gf = new gfunct;
00060 gf->read (in);
00061 break;
00062 }
00063 case concrete_heat:{
00064 hydrh = new hydrationheat;
00065 hydrh->read (in);
00066 break;
00067 }
00068 case cement_hydration:{
00069
00070
00071
00072
00073
00074 break;
00075 }
00076 default:{
00077 print_err("unknown type of model of quantity source is required",__FILE__,__LINE__,__func__);
00078 }
00079 }
00080
00081 break;
00082 }
00083 default:{
00084 print_err("unknown type of problem is required",__FILE__,__LINE__,__func__);
00085 }
00086 }
00087
00088 return(0);
00089 }
00090
00091
00092
00093
00094
00095
00096
00097
00098 long sourcet::print(FILE *out)
00099 {
00100 switch (Tp->tprob){
00101 case stationary_problem:{
00102 fprintf (out,"\n %lf ",v);
00103 break;
00104 }
00105 case nonstationary_problem:
00106 case nonlinear_nonstationary_problem:
00107 case discont_nonstat_problem:
00108 case discont_nonlin_nonstat_problem:
00109 case growing_np_problem:
00110 case growing_np_problem_nonlin:{
00111
00112 fprintf (out,"\n %d \n",sourtype);
00113
00114 switch (sourtype){
00115 case matfunction:{
00116 gf->print (out);
00117 break;
00118 }
00119 case concrete_heat:{
00120 hydrh->print (out);
00121 break;
00122 }
00123 case cement_hydration:{
00124
00125 break;
00126 }
00127 default:{
00128 print_err("unknown type of model of quantity source is required",__FILE__,__LINE__,__func__);
00129 }
00130 }
00131
00132 break;
00133 }
00134 default:{
00135 print_err("unknown type of problem is required",__FILE__,__LINE__,__func__);
00136 }
00137 }
00138
00139 return(0);
00140 }
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 double sourcet::giveval (long eid)
00152 {
00153 long i,ipp;
00154 double ret,t;
00155
00156 switch (Tp->tprob){
00157 case stationary_problem:{
00158 ret=v;
00159 break;
00160 }
00161
00162 case nonstationary_problem:
00163 case nonlinear_nonstationary_problem:
00164 case discont_nonstat_problem:
00165 case discont_nonlin_nonstat_problem:
00166 case growing_np_problem:
00167 case growing_np_problem_nonlin:{
00168
00169 switch (sourtype){
00170 case matfunction:{
00171 t = Tp->time;
00172 ret = gf->getval (t);
00173 break;
00174 }
00175 case concrete_heat:{
00176 t = Tp->time;
00177 ret = hydrh->give_value (t);
00178 break;
00179 }
00180 case cement_hydration:{
00181 ipp=Tt->elements[eid].ipp[0][0];
00182 i = Tm->ip[ipp].idm;
00183 ret = Tm->cemhydr[i].get_source(ipp,0,0);
00184 break;
00185 }
00186 default:{
00187 print_err("unknown type of model of quantity source is required",__FILE__,__LINE__,__func__);
00188 }
00189 }
00190
00191 break;
00192 }
00193 default:{
00194 print_err("unknown type of problem is required",__FILE__,__LINE__,__func__);
00195 }
00196 }
00197
00198 return(ret);
00199 }
00200
00201
00202
00203
00204 long sourcet::read_prop(FILE *in, long lc)
00205 {
00206
00207
00208
00209
00210
00211
00212
00213
00214 return(0);
00215 }
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231 long sourcet::compare(sourcet &src)
00232 {
00233 if (sourtype != src.sourtype)
00234 return 1;
00235
00236 if (v != src.v)
00237 return 1;
00238
00239 if (gf->compare(*src.gf))
00240 return 1;
00241
00242 if (hydrh->compare(*src.hydrh))
00243 return 1;
00244
00245
00246
00247 return 0;
00248 }