00001 #include "floatsub.h"
00002 #include <stdlib.h>
00003
00004 floatsub::floatsub (void)
00005 {
00006
00007 nsd=0;
00008
00009
00010 nnsd=NULL; fnnsd=NULL;
00011
00012 nesd=NULL; fensd=NULL;
00013
00014 ndofd = NULL; fdofd = NULL;
00015
00016 }
00017
00018 floatsub::~floatsub (void)
00019 {
00020 delete [] nnsd; delete [] fnnsd;
00021 delete [] nesd; delete [] fensd;
00022 delete [] ndofd; delete [] fdofd;
00023 }
00024
00025
00026
00027
00028
00029
00030 void floatsub::ndof_subdom (gnode *gnodes)
00031 {
00032 long i,j,k;
00033
00034
00035 if (ndofd==NULL)
00036 ndofd = new long [nsd];
00037 if (fdofd==NULL)
00038 fdofd = new long [nsd+1];
00039
00040
00041 fdofd[0]=0;
00042 for (i=0;i<nsd;i++){
00043 j=fnnsd[i]; k=fnnsd[i+1];
00044 ndofd[i] = gnodes[k].cn[0] - gnodes[j].cn[0];
00045 fdofd[i+1] = gnodes[k].cn[0];
00046 }
00047
00048 }
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 long floatsub::number_of_lagr_mult (long nlgn,lgnode *lgnodes,gnode *gnodes)
00060 {
00061 long i,j,nn,n1,n2,ndofn;
00062
00063
00064 nlm=0;
00065
00066
00067 for (i=0;i<nlgn;i++){
00068
00069 nn = lgnodes[i].nl;
00070 if (nn!=2){
00071 fprintf (stderr,"\n\n wrong number of connected nodes in layered node %ld (file %s, line %d).\n",i+1,__FILE__,__LINE__);
00072 }
00073
00074 n1=lgnodes[i].nodes[0];
00075 n2=lgnodes[i].nodes[1];
00076
00077 ndofn = gnodes[n1].ndofn;
00078 j = gnodes[n2].ndofn;
00079
00080 if (j!=ndofn){
00081 fprintf (stderr,"\n\n wrong numbers of DOFs at nodes (file %s, line %d).\n",__FILE__,__LINE__);
00082 }
00083
00084 for (j=0;j<ndofn;j++){
00085 if (gnodes[n1].cn[j]!=gnodes[n2].cn[j])
00086 nlm++;
00087 }
00088 }
00089
00090 return nlm;
00091 }
00092
00093
00094
00095
00096
00097
00098
00099 void floatsub::displ_extract (long nlgn,lgnode *lgnodes,gnode *gnodes)
00100 {
00101 long i,j,k,nn,n1,n2,cn1,cn2,ndofn;
00102
00103
00104 extrtab = new long* [nlm];
00105 for (i=0;i<nlm;i++){
00106 extrtab[i] = new long [2];
00107 }
00108
00109 k=0;
00110
00111 for (i=0;i<nlgn;i++){
00112
00113 nn = lgnodes[i].nl;
00114 if (nn!=2){
00115 fprintf (stderr,"\n\n wrong number of connected nodes in layered node %ld (file %s, line %d).\n",i+1,__FILE__,__LINE__);
00116 }
00117
00118 n1=lgnodes[i].nodes[0];
00119 n2=lgnodes[i].nodes[1];
00120
00121 ndofn = gnodes[n1].ndofn;
00122 j = gnodes[n2].ndofn;
00123
00124 if (j!=ndofn){
00125 fprintf (stderr,"\n\n wrong numbers of DOFs at nodes (file %s, line %d).\n",__FILE__,__LINE__);
00126 }
00127
00128 for (j=0;j<ndofn;j++){
00129 cn1=gnodes[n1].cn[j];
00130 cn2=gnodes[n2].cn[j];
00131 if (cn1!=cn2){
00132 if (cn1>0 && cn2>0){
00133 extrtab[k][0]=0-cn1;
00134 extrtab[k][1]=cn2;
00135 }
00136 if (cn1<1 && cn2>0){
00137 extrtab[k][0]=0;
00138 extrtab[k][1]=cn2;
00139 }
00140 if (cn1>0 && cn2<1){
00141 extrtab[k][0]=0-cn1;
00142 extrtab[k][1]=0;
00143 }
00144 if (cn1<1 && cn2<1){
00145 extrtab[k][0]=0;
00146 extrtab[k][1]=0;
00147 }
00148 k++;
00149 }
00150 }
00151 }
00152 }
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162 void floatsub::local_coarse (double *cv,double *lv)
00163 {
00164 long i,cn1,cn2;
00165
00166 for (i=0;i<nlm;i++){
00167 cn1=extrtab[i][0];
00168 cn2=extrtab[i][1];
00169
00170
00171 if (cn1<0 && cn2>0){
00172 cv[i]-=lv[0-cn1-1];
00173 cv[i]+=lv[cn2-1];
00174 }
00175 if (cn1==0 && cn2>0){
00176 cv[i]+=lv[cn2-1];
00177 }
00178 if (cn1<0 && cn2==0){
00179 cv[i]-=lv[0-cn1-1];
00180 }
00181 }
00182
00183 }
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193 void floatsub::coarse_local (double *cv,double *lv)
00194 {
00195 long i,cn1,cn2;
00196
00197 for (i=0;i<nlm;i++){
00198 cn1=extrtab[i][0];
00199 cn2=extrtab[i][1];
00200
00201
00202 if (cn1<0 && cn2>0){
00203 lv[0-cn1-1]-=cv[i];
00204 lv[cn2-1]+=cv[i];
00205 }
00206 if (cn1==0 && cn2>0){
00207 lv[cn2-1]+=cv[i];
00208 }
00209 if (cn1<0 && cn2==0){
00210 lv[0-cn1-1]-=cv[i];
00211 }
00212 }
00213
00214 }