15 #if !defined(KRATOS_SKYLINE_LU_FACTORIZATION_SOLVER_H_INCLUDED )
16 #define KRATOS_SKYLINE_LU_FACTORIZATION_SOLVER_H_INCLUDED
70 int i,
j, newi, newj, indexj, ordering, *invperm;
84 invperm=
new int[
size];
92 int initialNode, next, currentLevelSet, nMDICLS,
node, soughtDegree;
93 int maxDegreeInCurrentLevelSet, maxDegree, firstVal, finalVal, increment;
94 std::vector<IndexType> neighbors;
100 int *degree =
new int[
size];
101 int *levelSet =
new int[
size];
102 int *nextSameDegree=
new int[
size];
105 degree[
i] = TSparseSpaceType::GraphDegree(
i,
A);
106 if (degree[
i]>maxDegree) maxDegree=degree[
i];
108 nextSameDegree[
i]= -1;
110 int *firstWithDegree =
new int[maxDegree+1];
111 int *nFirstWithDegree =
new int[maxDegree+1];
112 for (
i=0;
i<maxDegree+1;
i++) firstWithDegree[
i]=-1;
127 perm[0]= initialNode;
129 levelSet[initialNode]= currentLevelSet;
130 maxDegreeInCurrentLevelSet= degree[initialNode];
131 firstWithDegree[maxDegreeInCurrentLevelSet]= initialNode;
139 for (
i=0;
i<maxDegree+1;
i++) nFirstWithDegree[
i]=-1;
146 finalVal = maxDegreeInCurrentLevelSet+1;
152 firstVal = maxDegreeInCurrentLevelSet;
158 for (soughtDegree=firstVal; soughtDegree!=finalVal; soughtDegree+=increment)
160 node= firstWithDegree[soughtDegree];
164 TSparseSpaceType::GraphNeighbors(
node,
A, neighbors);
165 for (indexj=0; indexj<degree[
node]; indexj++)
167 j = neighbors[indexj];
170 levelSet[
j]= currentLevelSet+1;
174 nextSameDegree[
j]= nFirstWithDegree[degree[
j]];
175 nFirstWithDegree[degree[
j]]=
j;
176 if (nMDICLS<degree[
j]) nMDICLS=degree[
j];
186 maxDegreeInCurrentLevelSet= nMDICLS;
187 for (
i=0;
i<nMDICLS+1;
i++) firstWithDegree[
i]= nFirstWithDegree[
i];
201 levelSet[
i]= currentLevelSet;
202 maxDegreeInCurrentLevelSet= degree[
i];
203 firstWithDegree[maxDegreeInCurrentLevelSet]=
i;
212 throw std::runtime_error(
"This cannot happen! Internal consistency error at LUSkylineFactorization::copyFromCSRMatrix(CSRMatrix A)");
219 delete[] nextSameDegree;
221 delete[] firstWithDegree;
222 delete[] nFirstWithDegree;
238 for (
typename SparseMatrixType::iterator1 a_iterator =
A.begin1();
239 a_iterator !=
A.end1(); a_iterator++)
241 #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
242 for (
typename SparseMatrixType::iterator2 row_iterator = a_iterator.begin() ;
243 row_iterator != a_iterator.end() ; ++row_iterator)
246 for ( SparseMatrixType::iterator2 row_iterator = begin(a_iterator,
247 boost::numeric::ublas::iterator1_tag());
248 row_iterator !=
end(a_iterator,
249 boost::numeric::ublas::iterator1_tag()); ++row_iterator )
252 i = row_iterator.index1();
253 j = row_iterator.index2();
254 entry = *row_iterator;
304 oldCarryOut= newCarryOut;
321 for (
typename SparseMatrixType::iterator1 a_iterator =
A.begin1();
322 a_iterator !=
A.end1(); a_iterator++)
324 #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
325 for (
typename SparseMatrixType::iterator2 row_iterator = a_iterator.begin() ;
326 row_iterator != a_iterator.end() ; ++row_iterator)
329 for ( SparseMatrixType::iterator2 row_iterator = begin(a_iterator,
330 boost::numeric::ublas::iterator1_tag());
331 row_iterator !=
end(a_iterator,
332 boost::numeric::ublas::iterator1_tag()); ++row_iterator )
335 i = row_iterator.index1();
336 j = row_iterator.index2();
337 entry = *row_iterator;
407 int indexEntry, indexL, indexU;
408 int jBeginRow, jBeginCol, jBeginMult, iBeginCol;
414 std::cout <<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! LUSkylineFactorization::factorize: Error zero in diagonal" << std::endl;
436 jBeginMult= ( iBeginCol > jBeginRow ) ? iBeginCol : jBeginRow ;
437 indexL=
rowIndex[
i ] + jBeginMult - jBeginRow;
438 indexU=
rowIndex[
k+1] + jBeginMult - iBeginCol;
439 for (
j=jBeginMult;
j<
i;
j++)
462 jBeginMult= ( jBeginCol > jBeginRow ) ? jBeginCol : jBeginRow ;
463 indexL=
rowIndex[
k+1] + jBeginMult - jBeginRow;
464 indexU=
rowIndex[
i ] + jBeginMult - jBeginCol;
465 for (
j=jBeginMult;
j<
i;
j++)
484 std::cout <<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! LUSkylineFactorization::factorize: Error zero sum" << std::endl;
501 int i,
j, indexL, indexU;
503 if (this->size != vector_size)
505 throw std::runtime_error(
"matrix and vector have different sizes at LUSkylineFactorization::backForwardSolve");
558 template<
class TSparseSpaceType,
class TDenseSpaceType,
559 class TReordererType = Reorderer<TSparseSpaceType, TDenseSpaceType> >
561 :
public DirectSolver<TSparseSpaceType, TDenseSpaceType, TReordererType>
593 if(this->IsNotConsistent(rA, rX, rB))
625 bool is_solved =
true;
637 for(
int i = 0 ;
i < size2 ;
i++)
639 TDenseSpaceType::GetColumn(
i,rX,
x);
640 TDenseSpaceType::GetColumn(
i,rB,
b);
645 TDenseSpaceType::SetColumn(
i,rX,
x);
646 TDenseSpaceType::SetColumn(
i,rB,
b);
657 rOStream <<
"LU factorization solver finished.";
767 template<
class TSparseSpaceType,
class TDenseSpaceType,
class TReordererType>
770 TReordererType>& rThis)
776 template<
class TSparseSpaceType,
class TDenseSpaceType,
class TReordererType>
780 TReordererType>& rThis)
782 rThis.PrintInfo(rOStream);
783 rOStream << std::endl;
784 rThis.PrintData(rOStream);
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
Definition: direct_solver.h:48
Definition: skyline_lu_factorization_solver.h:30
int * rowIndex
Definition: skyline_lu_factorization_solver.h:43
std::size_t IndexType
Definition: skyline_lu_factorization_solver.h:39
void copyFromCSRMatrix(SparseMatrixType &A)
Definition: skyline_lu_factorization_solver.h:68
void clear()
Definition: skyline_lu_factorization_solver.h:49
int size
Definition: skyline_lu_factorization_solver.h:42
double * entriesU
Definition: skyline_lu_factorization_solver.h:47
LUSkylineFactorization()
Definition: skyline_lu_factorization_solver.h:541
TSparseSpaceType::MatrixType SparseMatrixType
Definition: skyline_lu_factorization_solver.h:33
~LUSkylineFactorization()
Definition: skyline_lu_factorization_solver.h:550
void factorize()
Definition: skyline_lu_factorization_solver.h:404
double * entriesD
Definition: skyline_lu_factorization_solver.h:46
int * perm
Definition: skyline_lu_factorization_solver.h:44
void backForwardSolve(int vector_size, const VectorType &b, VectorType &x)
Definition: skyline_lu_factorization_solver.h:496
TSparseSpaceType::VectorType VectorType
Definition: skyline_lu_factorization_solver.h:35
TDenseSpaceType::MatrixType DenseMatrixType
Definition: skyline_lu_factorization_solver.h:37
double * entriesL
Definition: skyline_lu_factorization_solver.h:45
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
Definition: skyline_lu_factorization_solver.h:562
KRATOS_CLASS_POINTER_DEFINITION(SkylineLUFactorizationSolver)
Counted pointer of SkylineLUFactorizationSolver.
bool Solve(SparseMatrixType &rA, DenseMatrixType &rX, DenseMatrixType &rB) override
Definition: skyline_lu_factorization_solver.h:620
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: skyline_lu_factorization_solver.h:661
~SkylineLUFactorizationSolver() override
Destructor.
Definition: skyline_lu_factorization_solver.h:581
DirectSolver< TSparseSpaceType, TDenseSpaceType, TReordererType > BaseType
Definition: skyline_lu_factorization_solver.h:568
TSparseSpaceType::VectorType VectorType
Definition: skyline_lu_factorization_solver.h:572
bool Solve(SparseMatrixType &rA, VectorType &rX, VectorType &rB) override
Definition: skyline_lu_factorization_solver.h:591
SkylineLUFactorizationSolver(Parameters settings)
Definition: skyline_lu_factorization_solver.h:578
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: skyline_lu_factorization_solver.h:655
SkylineLUFactorizationSolver()
Default constructor.
Definition: skyline_lu_factorization_solver.h:577
TSparseSpaceType::MatrixType SparseMatrixType
Definition: skyline_lu_factorization_solver.h:570
TDenseSpaceType::MatrixType DenseMatrixType
Definition: skyline_lu_factorization_solver.h:574
end
Definition: DEM_benchmarks.py:180
TSpaceType::IndexType Size1(TSpaceType &dummy, typename TSpaceType::MatrixType const &rM)
Definition: add_strategies_to_python.cpp:117
TSpaceType::IndexType Size2(TSpaceType &dummy, typename TSpaceType::MatrixType const &rM)
Definition: add_strategies_to_python.cpp:123
TSpaceType::IndexType Size(TSpaceType &dummy, typename TSpaceType::VectorType const &rV)
Definition: add_strategies_to_python.cpp:111
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
TExpressionType::data_type sum(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:675
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
y
Other simbols definition.
Definition: generate_axisymmetric_navier_stokes_element.py:54
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
A
Definition: sensitivityMatrix.py:70
x
Definition: sensitivityMatrix.py:49
integer i
Definition: TensorModule.f:17
Definition: mesh_converter.cpp:38