00001 #include "npglvec.h" 00002 #include "vector.h" 00003 00004 /** 00005 Default constructor initializes data members 00006 to the default values. 00007 00008 Created by Tomas Krejci according to Tomas Koudelka, 11/2012 00009 */ 00010 np_glob_vec::np_glob_vec() 00011 { 00012 istep = 0; 00013 lhs = tdlhs = rhs = f = d = p = fb = fi = NULL; 00014 v = z = lhsb = tdlhsb = NULL; 00015 } 00016 00017 00018 00019 /** 00020 The function allocates vectors tdlhs, f, d, p 00021 with length n. Vectors lhs and rhs remains unallocated because 00022 they are used as pointers to the right and left hand sides 00023 that are allocated separately. 00024 00025 @param n - length of vectors allocated i.e. total number of unknowns 00026 00027 @return The function does not return anything. 00028 00029 Created by Tomas Krejci according to Tomas Koudelka, 11/2012 00030 */ 00031 void np_glob_vec::alloc(long n) 00032 { 00033 // vector of prescribed fluxes (right hand side) 00034 f = new double [n]; 00035 nullv (f,n); 00036 // predictor 00037 d = new double [n]; 00038 nullv (d,n); 00039 // auxiliary vector 00040 p = new double [n]; 00041 nullv (p,n); 00042 } 00043 00044 /** 00045 The function allocates auxiliary vectors fb, fi 00046 00047 @param n - length of vectors allocated i.e. total number of unknowns 00048 00049 @return The function does not return anything. 00050 00051 Created by Tomas Krejci according to Tomas Koudelka, 11/2012 00052 */ 00053 void np_glob_vec::alloc_aux(long n) 00054 { 00055 // auxiliary vector 00056 fb = new double [n]; 00057 nullv (fb,n); 00058 fi = new double [n]; 00059 nullv (fi,n); 00060 } 00061 00062 00063 00064 /** 00065 The function allocates auxiliary vectors v, z, lhsb and tdlhsb for 00066 the dform solver type. 00067 00068 @param n - length of vectors allocated i.e. total number of unknowns 00069 00070 @return The function does not return anything. 00071 00072 Created by Tomas Koudelka, 6/2014 00073 */ 00074 void np_glob_vec::alloc_daux(long n) 00075 { 00076 // auxiliary vector 00077 v = new double [n]; 00078 nullv (v,n); 00079 // auxiliary vector 00080 z = new double [n]; 00081 nullv (z,n); 00082 // backup of nodal values 00083 lhsb = new double [n]; 00084 nullv (lhsb,n); 00085 // backup of time derivatives of nodal values 00086 tdlhsb = new double [n]; 00087 nullv (tdlhs,n); 00088 } 00089 00090 00091 00092 /** 00093 The function deallocates vectors lhs, tdlhs, rhs, f, d, p. 00094 00095 Created by Tomas Krejci according to Tomas Koudelka, 11/2012 00096 */ 00097 void np_glob_vec::dealloc() 00098 { 00099 delete [] f; 00100 delete [] d; 00101 delete [] p; 00102 00103 if(fb != NULL) 00104 delete [] fb; 00105 if(fi != NULL) 00106 delete [] fi; 00107 00108 if(v != NULL) 00109 delete [] v; 00110 if(z != NULL) 00111 delete [] z; 00112 if(lhsb != NULL) 00113 delete [] lhsb; 00114 if(tdlhsb != NULL) 00115 delete [] tdlhsb; 00116 } 00117 00118 00119 00120 /** 00121 Destructor deallocates vectors lhs, tdlhs, rhs, f, d, p. 00122 00123 Created by Tomas Krejci according to Tomas Koudelka, 11/2012 00124 */ 00125 np_glob_vec::~np_glob_vec() 00126 { 00127 dealloc(); 00128 }