11 static LoggerPtr logger(Logger::getLogger(
"substruct.dohrsubstruct"));
37 for(i=0;i<fPhiC.
Rows();i++) {
38 for(j=0;j<fPhiC.
Cols();j++) {
39 temp1(i,j) = fPhiC(i,j)*fWeights[i];
45 for(i=0;i<fCoarseIndex.NElements();i++) {
46 temp1.GetSub(0,i,temp1.
Rows(),1,col);
47 temp2.
PutSub(0,fCoarseIndex[i],col);
51 for(i=0;i<fNEquations;i++) {
54 for(j=0;j<NumCoarse;j++) {
55 testV1(fGlobalIndex[i],j) += col(0,j);
65 int neqs = fGlobalEqs.NElements();
68 std::pair<int,int> ind = fGlobalEqs[i];
69 ulocal(ind.first,0) = u(ind.second,0);
71 fStiffness->Residual(ulocal, fLocalLoad, reslocal);
72 for (i=0;i<neqs;i++) {
73 std::pair<int,int> ind = fGlobalEqs[i];
74 r(ind.second,0) += reslocal(ind.first,0);
81 fLocalWeightedResidual.Resize(fNEquations,1);
82 int neqs = fGlobalEqs.NElements();
85 std::pair<int,int> ind = fGlobalEqs[i];
86 fLocalWeightedResidual(ind.first,0) = fWeights[ind.first]*r_global.
GetVal(ind.second,0);
94 fPhiC.
Multiply(fLocalWeightedResidual, temp, 1);
95 for (i=0;i<fCoarseIndex.NElements();i++) {
96 rc(fCoarseIndex[i],0) += temp(i,0);
107 fPhiC_Weighted_Condensed.Multiply(residual_local, rc_local, 1);
115 for (i=0;i<fCoarseIndex.NElements();i++) {
116 for (j=0;j<fCoarseIndex.NElements();j++) {
117 Kc(fCoarseIndex[i],fCoarseIndex[j]) += fKCi(i,j);
129 for (i=0;i<fCoarseIndex.NElements();i++) {
130 temp(i, 0) = invKc_rc(fCoarseIndex[i],0);
133 fPhiC.Multiply(temp, temp2, 0);
135 #ifdef ZERO_INTERNAL_RESIDU 136 for(i=0; i<fInternalEqs.NElements(); i++)
138 temp2(fInternalEqs[i],0) = 0.;
141 int neqs = fGlobalEqs.NElements();
142 for (i=0;i<neqs;i++) {
143 std::pair<int,int> ind = fGlobalEqs[i];
144 v1(ind.second,0) += fWeights[ind.first]*temp2(ind.first,0);
150 int neqs = fGlobalEqs.NElements();
152 fPhiC_Weighted_Condensed.Multiply(invKc_rc_local,v1_local);
159 #ifdef ZERO_INTERNAL_RESIDU 160 for(i=0; i<fInternalEqs.NElements(); i++)
162 fzi(fInternalEqs[i],0) = 0.;
165 int neqs = fGlobalEqs.NElements();
168 std::pair<int,int> ind = fGlobalEqs[i];
169 v2(ind.second,0) += fWeights[ind.first] * fzi(ind.first,0);
179 int ncols = residual_local.
Cols();
181 int neqs = fGlobalEqs.NElements();
183 for (
int ic=0; ic<ncols; ic++)
187 std::pair<int,int> ind = fGlobalEqs[i];
188 LocalWeightedResidual(ind.first,ic) += fWeights[ind.first] * residual_local(i,ic);
191 int ncoarse = fCoarseIndex.NElements();
193 int nnull = fNullPivots.Rows();
195 int nglob = fNEquations;
205 fInvertedStiffness.Solve(LocalWeightedResidual,KWeightedResidual);
209 fC_star.MultAdd(KWeightedResidual,KWeightedResidual,CstarKW,-1,0,0);
211 I_lambda.
Add(CstarKW,temp2);
212 finv.Solve(temp2, Lambda_star);
214 if(logger->isDebugEnabled())
216 std::stringstream sout;
217 Lambda_star.
Print(
"Lambda_star ",sout);
223 temp2.
Resize(nglob,ncols);
224 fKeC_star.Multiply(Lambda_star,temp2);
226 temp2.
Add(KWeightedResidual,zi);
228 if(logger->isDebugEnabled())
230 std::stringstream sout;
231 zi.Print(
"zi ",sout);
235 #ifdef ZERO_INTERNAL_RESIDU
236 for(i=0; i<fInternalEqs.NElements(); i++)
238 zi(fInternalEqs[i],0) = 0.;
241 v2_local.
Resize(neqs, ncols);
242 for (
int ic=0; ic<ncols; ic++)
246 std::pair<int,int> ind = fGlobalEqs[i];
247 v2_local(i,ic) = fWeights[ind.first] * zi(ind.first,ic);
261 int neqs = fGlobalEqs.NElements();
263 for (i=0;i<neqs;i++) {
264 std::pair<int,int> ind = fGlobalEqs[i];
265 vec_t(ind.first,0) = v1Plusv2(ind.second,0);
268 fStiffness->Multiply(vec_t, vec_t2, 0);
270 for (i=0;i<neqs;i++) {
271 std::pair<int,int> ind = fGlobalEqs[i];
272 vec_t(ind.first,0) = r.
GetVal(ind.second,0);
275 for (i=0;i<fInternalEqs.NElements();i++) {
276 vec_t3(i,0) = vec_t(fInternalEqs[i],0) - vec_t2(fInternalEqs[i],0);
279 fInvertedInternalStiffness.Solve(vec_t3, inv_sys);
282 for (i=0;i<fInternalEqs.NElements();i++) {
283 vec_t(fInternalEqs[i],0) = inv_sys(i,0);
287 for (i=0;i<neqs;i++) {
288 std::pair<int,int> ind = fGlobalEqs[i];
289 v3(ind.second,0) += vec_t(ind.first,0);
304 fStiffness->Multiply(v1Plusv2, vec_t2);
305 for (i=0;i<fInternalEqs.NElements();i++) {
306 vec_t3(i,0) = vec_t2(fInternalEqs[i],0);
309 fInvertedInternalStiffness.Solve(vec_t3, inv_sys);
311 v3.
Redim(fNEquations,1);
312 for (i=0;i<fInternalEqs.NElements();i++) {
313 v3(fInternalEqs[i],0) = -inv_sys(i,0);
320 out <<
"++++++++++++++++++++++++++++++++++++" << std::endl;
321 out <<
"Coarse Index " << fCoarseIndex << std::endl;
322 out <<
"Global Index " << fGlobalIndex << std::endl;
323 out <<
"Internal Nodes " << fInternalEqs << std::endl;
324 out <<
"Coarse Nodes " << fCoarseNodes << std::endl;
326 fC_star.Print(
"fC_star",out);
327 fKeC_star.Print(
"fKeC_star", out);
328 fNullPivots.Print(
"fNullPivots", out);
329 out <<
"fNEquations = " << fNEquations << std::endl;
330 out <<
"fCoarseNodes " << fCoarseNodes << std::endl;
332 out <<
"fCoarseIndex " << fCoarseIndex << std::endl;
334 out <<
"fGlobalEqs " << fGlobalEqs << std::endl;
335 out <<
"fInternalEqs " << fInternalEqs << std::endl;
336 out <<
"fBoundaryEqs " << fBoundaryEqs << std::endl;
337 fLocalLoad.Print(
"fLocalLoad",out);
338 fLocalWeightedResidual.Print(
"fLocalWeightedResidual",out);
339 fzi.Print(
"fzi", out);
340 fAdjustSolution.Print(
"fAdjustSolution", out);
343 fKCi.Print(
"Coarse Matrix",out);
349 out <<
"fWeights = " << fWeights << endl;
350 fPhiC_Weighted_Condensed.Print(
"fPhiC_Weighted_Condensed = ", out);
355 int ncoarse = fCoarseIndex.NElements();
364 for (i=0;i<ncoarse;i++) {
373 finv.Solve(I_lambda, Lambda_star);
376 if(logger->isDebugEnabled())
378 std::stringstream sout;
379 Lambda_star.
Print(
"matrix lambda star",sout );
389 fPhiC.Resize(fNEquations,ncoarse);
390 fKeC_star.Multiply(Lambda_star,fPhiC);
392 ComputeCoarseStiffness();
399 int ncoarse = fCoarseIndex.NElements();
401 int nnull = fNullPivots.Rows();
403 int nglob = fNEquations;
413 fInvertedStiffness.Solve(fLocalWeightedResidual,KWeightedResidual);
417 fC_star.MultAdd(KWeightedResidual,KWeightedResidual,CstarKW,-1,0,0);
419 I_lambda.
Add(CstarKW,temp2);
420 finv.Solve(temp2, Lambda_star);
424 fKeC_star.Multiply(Lambda_star,temp2);
426 temp2.
Add(KWeightedResidual,fzi);
432 fKCi.
Resize(fCoarseIndex.NElements(),fCoarseIndex.NElements());
433 fStiffness->Multiply(fPhiC,temp1);
435 if(logger->isDebugEnabled())
437 std::stringstream sout;
438 temp1.Print(
"stiffness matrix times phi",sout);
442 fPhiC.MultAdd(temp1,temp1,fKCi,1,0,1);
444 if(logger->isDebugEnabled())
446 std::stringstream sout;
447 fKCi.Print(
"Coarse stiffness matrix",sout);
456 fWeights.Resize(fNEquations);
458 for (i=0;i<fNEquations;i++) {
459 fWeights[i] = fStiffness->operator()(i,i);
461 if(fWeightType == CorrectWeight)
463 for (i=0;i<fNEquations;i++) {
464 fWeights[i] = fStiffness->operator()(i,i);
466 for (i=0;i<fCoarseNodes.NElements();i++) {
467 fWeights[fCoarseNodes[i]] = fKCi(i,i);
470 for (i=0;i<fNEquations;i++) {
473 for (i=0;i<fCoarseNodes.NElements();i++) {
474 fWeights[fCoarseNodes[i]] = 1.;
479 std::stringstream sout;
480 sout <<
"Weight used for assembly" << fWeights;
485 int neqs = fGlobalEqs.NElements();
486 for (i=0;i<neqs;i++) {
487 std::pair<int,int> ind = fGlobalEqs[i];
488 StiffnessDiag(ind.second,0) += fWeights[ind.first];
495 fWeights.Resize(fNEquations);
497 for (i=0;i<fNEquations;i++) {
498 fWeights[i] = fStiffness->operator()(i,i);
500 if(fWeightType == CorrectWeight)
502 for (i=0;i<fNEquations;i++) {
503 fWeights[i] = fStiffness->operator()(i,i);
505 for (i=0;i<fCoarseNodes.NElements();i++) {
506 fWeights[fCoarseNodes[i]] = fKCi(i,i);
509 for (i=0;i<fNEquations;i++) {
512 for (i=0;i<fCoarseNodes.NElements();i++) {
513 fWeights[fCoarseNodes[i]] = 1.;
518 std::stringstream sout;
519 sout <<
"Weight used for assembly" << fWeights;
524 int neqs = fGlobalEqs.NElements();
525 StiffnessDiagLocal.
Resize(neqs,1);
526 for (i=0;i<neqs;i++) {
527 std::pair<int,int> ind = fGlobalEqs[i];
528 StiffnessDiagLocal(i,0) = fWeights[ind.first];
536 int neqs = fGlobalEqs.NElements();
537 for (i=0;i<neqs;i++) {
538 std::pair<int,int> ind = fGlobalEqs[i];
539 fWeights[ind.first] = fWeights[ind.first] / StiffnessDiag(ind.second,0);
541 for(i=0; i<fInternalEqs.NElements(); i++)
543 fWeights[fInternalEqs[i]] = 1.;
547 std::stringstream sout;
548 sout <<
"Weights = " << fWeights;
557 int neqs = fGlobalEqs.NElements();
558 for (i=0;i<neqs;i++) {
559 std::pair<int,int> ind = fGlobalEqs[i];
560 fWeights[ind.first] = fWeights[ind.first] / StiffnessDiagLocal(i,0);
562 for(i=0; i<fInternalEqs.NElements(); i++)
564 fWeights[fInternalEqs[i]] = 1.;
568 std::stringstream sout;
569 sout <<
"Weights = " << fWeights;
573 int c,nc = fPhiC.Cols();
574 #ifdef ZERO_INTERNAL_RESIDU 576 int nint = fInternalEqs.NElements();
577 for(i=0; i<nint; i++)
581 fPhiC(fInternalEqs[i],c) = 0.;
585 fPhiC_Weighted_Condensed.Resize(neqs,fPhiC.Cols());
590 std::pair<int,int> ind = fGlobalEqs[i];
591 fPhiC_Weighted_Condensed(i,c) = fPhiC(ind.first,c)*fWeights[ind.first];
600 int nglob = fNEquations;
601 int nglobglob = uglobal.
Rows();
602 int ncols = uglobal.
Cols();
605 TPZFNMatrix<100,TVar> temp1glob(nglobglob,ncols,0.),zero(nglobglob,ncols,0.),v3glob(nglobglob,ncols,0.);
608 int neqs = fGlobalEqs.NElements();
610 for (i=0;i<neqs;i++) {
611 std::pair<int,int> ind = fGlobalEqs[i];
612 for(j=0; j<ncols; j++)
614 uloc(ind.first,j) = uglobal.
Get(ind.second,j);
619 std::stringstream sout;
620 sout <<
"Value of the local solution = ";
621 uloc.
Print(
"uloc " ,sout);
625 #ifdef ZERO_INTERNAL_RESIDU
627 for (i=0;i<neqs;i++) {
628 for(j=0; j<ncols; j++)
630 std::pair<int,int> ind = fGlobalEqs[i];
631 temp1glob(ind.second,j) = uloc(ind.first,j);
635 this->Contribute_v3(v3glob,zero,temp1glob);
638 for (i=0;i<neqs;i++) {
639 for(j=0; j<ncols; j++)
641 std::pair<int,int> ind = fGlobalEqs[i];
642 v3(ind.first,j) = v3glob(ind.second,j);
650 std::stringstream sout;
651 sout <<
"Contribution of v3";
659 std::stringstream sout;
660 sout <<
"New value of uloc";
661 uloc.
Print(
"uloc",sout);
667 temp1.Resize(nglob,ncols);
668 fStiffness->Multiply(uloc,temp1);
671 std::stringstream sout;
672 sout <<
"After multiplying the solution temp1 = ";
673 temp1.Print(
"temp1 " ,sout);
677 int zcols = z.
Cols();
678 for (i=0;i<neqs;i++) {
679 std::pair<int,int> ind = fGlobalEqs[i];
681 for (j=0;j<zcols;j++) {
682 z(ind.second,j) += alpha*temp1(ind.first,j);
691 int nglob = fNEquations;
692 int ncols = u.
Cols();
699 for (i=0;i<neqs;i++) {
700 std::pair<int,int> ind = fGlobalEqs[i];
701 for(j=0; j<ncols; j++)
703 uloc(ind.first,j) = u.
Get(i,j);
708 std::stringstream sout;
709 sout <<
"Value of the local solution = ";
710 uloc.
Print(
"uloc " ,sout);
715 #ifdef ZERO_INTERNAL_RESIDU
717 this->Contribute_v3_local(uloc,v3);
720 std::stringstream sout;
721 sout <<
"Contribution of v3";
729 std::stringstream sout;
730 sout <<
"New value of uloc";
731 uloc.
Print(
"uloc",sout);
737 temp1.Resize(nglob,ncols);
738 fStiffness->Multiply(uloc,temp1);
741 std::stringstream sout;
742 sout <<
"After multiplying the solution temp1 = ";
743 temp1.Print(
"temp1 " ,sout);
747 int zcols = z.
Cols();
748 for (i=0;i<neqs;i++) {
749 std::pair<int,int> ind = fGlobalEqs[i];
751 for (j=0;j<zcols;j++) {
752 z(i,j) += alpha*temp1(ind.first,j);
761 ComputeCoarseStiffness();
767 int ncoarse = fCoarseIndex.NElements();
787 fInvertedStiffness.Solve(C_transposed,KeC);
791 std::stringstream sout;
792 sout <<
"Number of zero pivots of the substructure : " << fInvertedStiffness.Singular().size();
799 fNullPivots.Resize(fInvertedStiffness.Singular().size(),fInvertedStiffness.Matrix()->Cols());
802 if(fNullPivots.Rows())
806 std::list<int64_t>::iterator it = fInvertedStiffness.Singular().begin();
807 for(;it != fInvertedStiffness.Singular().end(); it++,count++)
811 fNullPivots(count,*it) = 1.;
819 TPZFMatrix<TVar> I_star(ncoarse+fNullPivots.Rows(),ncoarse+fNullPivots.Rows());
822 for (i=ncoarse;i<ncoarse+fNullPivots.Rows();i++) {
826 fC_star.Resize(ncoarse+fNullPivots.Rows(),fNEquations);
827 fC_star.PutSub(0,0,fC);
828 fC_star.PutSub(ncoarse,0,fNullPivots);
831 fKeC_star.Resize(fNEquations,ncoarse+fNullPivots.Rows());
834 fInvertedStiffness.Solve(C_star_trans,fKeC_star);
837 fC_star.
MultAdd(fKeC_star,I_star,*temp1,-1,1,0);
838 finv.SetMatrix(temp1);
849 int nglob = fNEquations;
850 int nint = this->fInternalEqs.NElements();
853 for(i=0; i<nint; i++)
855 if(fGlobalIndex[fInternalEqs[i]] >= 0)
857 rint(i,0) = r_global(fGlobalIndex[fInternalEqs[i]]);
862 int neqs = fGlobalEqs.NElements();
863 for(i=0; i<neqs; i++)
865 std::pair<int,int> ind = fGlobalEqs[i];
866 radapt(ind.first,0) = r_global(ind.second,0);
868 fInvertedInternalStiffness.Solve(rint,fAdjustSolution);
871 std::stringstream sout;
872 sout <<
"Adjusted internal solution";
873 fAdjustSolution.Print(
"fAdjustSolution",sout);
874 rint.Print(
"Internal residual",sout);
879 for(i=0; i<nint; i++)
881 rloc(fInternalEqs[i],0) = fAdjustSolution(i,0);
883 fStiffness->MultAdd(rloc,radapt,radjust,-1.,1.);
884 for(i=0; i<nint; i++)
886 if(
fabs(radjust(fInternalEqs[i],0)) >= 1.e-10)
888 std::cout <<
"Internal node " << i <<
" was not zeroed " << radjust(fInternalEqs[i],0) << std::endl;
890 radjust(fInternalEqs[i],0) = 0.;
894 for(i=0; i<neqs; i++)
896 std::pair<int,int> ind = fGlobalEqs[i];
897 r_global(ind.second,0) = radjust(ind.first,0);
907 int nglob = fNEquations;
908 int nint = this->fInternalEqs.NElements();
910 int i,c,nc = sol.
Cols();
911 for(i=0; i<nint; i++)
for(c=0; c<nc; c++)
913 if(fGlobalIndex[fInternalEqs[i]] >=0) sol(fGlobalIndex[fInternalEqs[i]],c) += this->fAdjustSolution(i,c);
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ fabs
void Contribute_Kc(TPZMatrix< TVar > &Kc, TPZVec< int > &coarseindex)
It computes the local contribution to K(c)
void Contribute_v1(TPZFMatrix< TVar > &v1, TPZFMatrix< TVar > &invKc_rc)
It computes the local contribution to v1.
virtual int PutSub(const int64_t sRow, const int64_t sCol, const TPZFMatrix< TVar > &Source)
It puts submatrix Source on actual matrix structure.
Contains definitions to LOGPZ_DEBUG, LOGPZ_INFO, LOGPZ_WARN, LOGPZ_ERROR and LOGPZ_FATAL, and the implementation of the inline InitializePZLOG(string) function using log4cxx library or not. It must to be called out of "#ifdef LOG4CXX" scope.
void Contribute_v3(TPZFMatrix< TVar > &v3, const TPZFMatrix< TVar > &r, TPZFMatrix< TVar > &v1Plusv2) const
It computes the local contribution to v(3)
void ContributeKU(const TVar alpha, const TPZFMatrix< TVar > &uglobal, TPZFMatrix< TVar > &z) const
Contribute to the global matrix vector multiplication. It's needed to the MultAdd method of TPZDohrMa...
void SolveSystemPhi()
Solves the system for Phi and for v2.
void ContributeTestV1(TPZFMatrix< TVar > &testV1, int NumCoarse)
Contains the TPZDohrSubstruct class which implements sub structure matrices using Dohrman algorithm...
void PrepareSystems()
It prepares the datas for solving systems for phi and zi.
void ComputeWeights(TPZFMatrix< TVar > &StiffnessDiag)
Computes the weight matrix.
virtual const TVar & Get(const int64_t row, const int64_t col) const
Get value with bound checking.
void ContributeResidual(TPZFMatrix< TVar > &u, TPZFMatrix< TVar > &r)
ContributeResidual.
void Contribute_v2(TPZFMatrix< TVar > &v2)
It computes the local contribution to v2.
Implements sub structure matrices using Dohrman algorithm. Sub Structure.
virtual int GetSub(const int64_t sRow, const int64_t sCol, const int64_t rowSize, const int64_t colSize, TPZFMatrix< TVar > &Target) const
Gets submatrix storing it on Target.
void ContributeKULocal(const TVar alpha, const TPZFMatrix< TVar > &u, TPZFMatrix< TVar > &z) const
Compute the multiplication of the local stiffness matrix with the vector u.
void AdjustResidual(TPZFMatrix< TVar > &r_global)
Adjust the residual to reflect a static condensation.
void SolveSystemZi()
Solves the system for zi.
int Zero() override
Makes Zero all the elements.
void Contribute_rc(TPZFMatrix< TVar > &rc)
It computes the local contribution to r(c).
void ComputeCoarseStiffness()
Computes K(ci) and stores it in fKCi.
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
virtual void Add(const TPZMatrix< TVar > &A, TPZMatrix< TVar > &res) const
It adds itself to TPZMatrix<TVar>A putting the result in res.
int64_t Rows() const
Returns number of rows.
Full matrix class. Matrix.
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
void LoadWeightedResidual(const TPZFMatrix< TVar > &r_global)
It computes W(i)*R(i)*r and stores it in fLocalWeightedResidual;.
void Print(std::ostream &out) const
void Contribute_v1_local(TPZFMatrix< TVar > &v1_local, TPZFMatrix< TVar > &invKc_rc) const
It computes the local contribution to v1.
void AddInternalSolution(TPZFMatrix< TVar > &sol)
Add the internal solution to the final result.
virtual void Multiply(const TPZFMatrix< TVar > &A, TPZFMatrix< TVar > &res, int opt=0) const
It mutiplies itself by TPZMatrix<TVar>A putting the result in res.
void ContributeDiagonalLocal(TPZFMatrix< TVar > &StiffnessDiag)
Computes the contribution of each substructure node to global Stiffness diagonal (or something like t...
virtual void MultAdd(const TPZFMatrix< TVar > &x, const TPZFMatrix< TVar > &y, TPZFMatrix< TVar > &z, const TVar alpha=1., const TVar beta=0., const int opt=0) const override
It computes z = beta * y + alpha * opt(this)*x but z and x can not overlap in memory.
int64_t Cols() const
Returns number of cols.
virtual void Print(std::ostream &out) const
int Resize(const int64_t newRows, const int64_t wCols) override
Redimension a matrix, but maintain your elements.
void Contribute_v2_local(TPZFMatrix< TVar > &residual_local, TPZFMatrix< TVar > &v2_local)
It computes the local contribution to v2.
void Initialize()
Initializes the substructure.
const TVar & GetVal(const int64_t row, const int64_t col) const override
Get values without bounds checking This method is faster than "Get" if DEBUG is defined.
void Transpose(TPZMatrix< TVar > *const T) const override
It makes *T the transpose of current matrix.
void Contribute_v3_local(TPZFMatrix< TVar > &v3, TPZFMatrix< TVar > &v1Plusv2) const
It computes the local contribution to v(3)
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
Root matrix class (abstract). Matrix.
void Contribute_rc_local(TPZFMatrix< TVar > &residual_local, TPZFMatrix< TVar > &rc_local) const
It computes the local contribution to r(c).