mirror of
https://github.com/yoshiya-usui/femtic.git
synced 2025-05-05 21:51:11 +08:00
modify some files for large-scale models
This commit is contained in:
parent
fe3d58fe37
commit
8eaec75b2e
@ -61,11 +61,11 @@ ComplexSparseMatrix::ComplexSparseMatrix( const int nrows, const int ncols, cons
|
|||||||
assert( ncols > 0 );
|
assert( ncols > 0 );
|
||||||
assert( nrhs > 0 );
|
assert( nrhs > 0 );
|
||||||
|
|
||||||
const int num = m_numRows*m_numRightHandSideVectors;
|
const long long num = static_cast<long long>(m_numRows)*static_cast<long long>(m_numRightHandSideVectors);
|
||||||
m_rightHandSideVector = new std::complex<double>[num];
|
m_rightHandSideVector = new std::complex<double>[num];
|
||||||
for( int i = 0; i < num; ++i ){
|
for( long long i = 0; i < num; ++i ){
|
||||||
m_rightHandSideVector[i] = std::complex<double>(0.0,0.0); // Initialize
|
m_rightHandSideVector[i] = std::complex<double>(0.0,0.0); // Initialize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructer
|
// Destructer
|
||||||
@ -125,9 +125,9 @@ void ComplexSparseMatrix::setNumRowsAndColumns( const int nrows, const int ncols
|
|||||||
m_rightHandSideVector = NULL;
|
m_rightHandSideVector = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int num = m_numRows*m_numRightHandSideVectors;
|
const long long num = static_cast<long long>(m_numRows)*static_cast<long long>(m_numRightHandSideVectors);
|
||||||
m_rightHandSideVector = new std::complex<double>[num];
|
m_rightHandSideVector = new std::complex<double>[num];
|
||||||
for( int i = 0; i < num; ++i ){
|
for( long long i = 0; i < num; ++i ){
|
||||||
m_rightHandSideVector[i] = std::complex<double>(0.0,0.0); // Initialize
|
m_rightHandSideVector[i] = std::complex<double>(0.0,0.0); // Initialize
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,14 +374,16 @@ void ComplexSparseMatrix::addRightHandSideVector( const int row, const std::comp
|
|||||||
assert( irhs <= m_numRightHandSideVectors - 1 );
|
assert( irhs <= m_numRightHandSideVectors - 1 );
|
||||||
assert( irhs >= 0 );
|
assert( irhs >= 0 );
|
||||||
|
|
||||||
m_rightHandSideVector[ row + m_numRows * irhs ] += val;
|
const long long index = static_cast<long long>(row) + static_cast<long long>(m_numRows)*static_cast<long long>(irhs);
|
||||||
|
m_rightHandSideVector[index] += val;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Zero clear non-zero values of the right hand side vector
|
//Zero clear non-zero values of the right hand side vector
|
||||||
void ComplexSparseMatrix::zeroClearRightHandSideVector(){
|
void ComplexSparseMatrix::zeroClearRightHandSideVector(){
|
||||||
|
|
||||||
const int num = m_numRows*m_numRightHandSideVectors;
|
const long long num = static_cast<long long>(m_numRows)*static_cast<long long>(m_numRightHandSideVectors);
|
||||||
for( int i = 0; i < num; ++i ){
|
for( long long i = 0; i < num; ++i ){
|
||||||
m_rightHandSideVector[i] = std::complex<double>(0.0,0.0); // Zero clear
|
m_rightHandSideVector[i] = std::complex<double>(0.0,0.0); // Zero clear
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,9 +446,9 @@ void ComplexSparseMatrix::initializeMatrixAndRhsVectors( const int nrows, const
|
|||||||
//m_matrixTripletFormat = new std::set<int>[nrows];
|
//m_matrixTripletFormat = new std::set<int>[nrows];
|
||||||
m_matrixTripletFormat = new std::map< int, std::complex<double> >[nrows];
|
m_matrixTripletFormat = new std::map< int, std::complex<double> >[nrows];
|
||||||
|
|
||||||
const int num = m_numRows*m_numRightHandSideVectors;
|
const long long num = static_cast<long long>(m_numRows)*static_cast<long long>(m_numRightHandSideVectors);
|
||||||
m_rightHandSideVector = new std::complex<double>[num];
|
m_rightHandSideVector = new std::complex<double>[num];
|
||||||
for( int i = 0; i < num; ++i ){
|
for( long long i = 0; i < num; ++i ){
|
||||||
m_rightHandSideVector[i] = std::complex<double>(0.0,0.0); // Initialize
|
m_rightHandSideVector[i] = std::complex<double>(0.0,0.0); // Initialize
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,9 +532,9 @@ void ComplexSparseMatrix::reallocateMemoryForRightHandSideVectors( const int nrh
|
|||||||
|
|
||||||
m_numRightHandSideVectors = nrhs;
|
m_numRightHandSideVectors = nrhs;
|
||||||
|
|
||||||
const int num = m_numRows*m_numRightHandSideVectors;
|
const long long num = static_cast<long long>(m_numRows)*static_cast<long long>(m_numRightHandSideVectors);
|
||||||
m_rightHandSideVector = new std::complex<double>[num];
|
m_rightHandSideVector = new std::complex<double>[num];
|
||||||
for( int i = 0; i < num; ++i ){
|
for( long long i = 0; i < num; ++i ){
|
||||||
m_rightHandSideVector[i] = std::complex<double>(0.0,0.0); // Initialize
|
m_rightHandSideVector[i] = std::complex<double>(0.0,0.0); // Initialize
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -574,17 +576,18 @@ void ComplexSparseMatrix::copyRhsVector( std::complex<double>* vecOut ) const{
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
memcpy( vecOut, m_rightHandSideVector, sizeof(std::complex<double>)*(m_numRightHandSideVectors*m_numRows) );
|
const long long num = static_cast<long long>(m_numRightHandSideVectors)*static_cast<long long>(m_numRows);
|
||||||
|
memcpy( vecOut, m_rightHandSideVector, static_cast<long long>(sizeof(std::complex<double>))*num );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Copy specified components of right-hand side vector to another vector
|
//Copy specified components of right-hand side vector to another vector
|
||||||
void ComplexSparseMatrix::copyRhsVector( const int numCompsCopied, const int* const compsCopied, std::complex<double>* vecOut ) const{
|
void ComplexSparseMatrix::copyRhsVector( const int numCompsCopied, const int* const compsCopied, std::complex<double>* vecOut ) const{
|
||||||
|
|
||||||
for( int j = 0; j < m_numRightHandSideVectors; ++j ){
|
for( long long j = 0; j < m_numRightHandSideVectors; ++j ){
|
||||||
const int offset = m_numRows * j;
|
const long long offset = static_cast<long long>(m_numRows) * j;
|
||||||
for( int i = 0; i < numCompsCopied; ++i ){
|
for( long long i = 0; i < numCompsCopied; ++i ){
|
||||||
vecOut[ i + offset ] = m_rightHandSideVector[ compsCopied[i] + offset ];
|
vecOut[ i + offset ] = m_rightHandSideVector[ static_cast<long long>(compsCopied[i]) + offset ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,11 +333,11 @@ void ComplexSparseSquareMatrix::factorizationPhaseMatrixSolver(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Solve phase of matrix solver with a specified number of right-hand side
|
//Solve phase of matrix solver with a specified number of right-hand side
|
||||||
void ComplexSparseSquareMatrix::solvePhaseMatrixSolver( std::complex<double>* solution, const int iRhsStart ,const int nRhs ){
|
void ComplexSparseSquareMatrix::solvePhaseMatrixSolver( std::complex<double>* solution, const long long iRhsStart ,const int nRhs ){
|
||||||
|
|
||||||
assert( m_hasConvertedToCRSFormat );
|
assert( m_hasConvertedToCRSFormat );
|
||||||
|
|
||||||
const long long index = static_cast<long long>(m_numRows) * static_cast<long long>(iRhsStart);
|
const long long index = static_cast<long long>(m_numRows) * iRhsStart;
|
||||||
m_pardisoSolver.solve( m_rowIndex, m_columns, m_values, nRhs, &m_rightHandSideVector[index], solution );
|
m_pardisoSolver.solve( m_rowIndex, m_columns, m_values, nRhs, &m_rightHandSideVector[index], solution );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ public:
|
|||||||
void factorizationPhaseMatrixSolver();
|
void factorizationPhaseMatrixSolver();
|
||||||
|
|
||||||
//Solve phase of matrix solver with a specified number of right-hand side
|
//Solve phase of matrix solver with a specified number of right-hand side
|
||||||
void solvePhaseMatrixSolver( std::complex<double>* solution, const int iRhsStart ,const int nRhs );
|
void solvePhaseMatrixSolver( std::complex<double>* solution, const long long iRhsStart ,const int nRhs );
|
||||||
|
|
||||||
//Solve phase of matrix solver
|
//Solve phase of matrix solver
|
||||||
void solvePhaseMatrixSolver( std::complex<double>* solution );
|
void solvePhaseMatrixSolver( std::complex<double>* solution );
|
||||||
|
@ -117,9 +117,9 @@ void DoubleSparseSquareMatrix::factorizationPhaseMatrixSolver(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Solve phase of matrix solver with a specified number of right-hand side
|
//Solve phase of matrix solver with a specified number of right-hand side
|
||||||
void DoubleSparseSquareMatrix::solvePhaseMatrixSolver( double* solution, const int iRhsStart ,const int nRhs ){
|
void DoubleSparseSquareMatrix::solvePhaseMatrixSolver( double* solution, const long long iRhsStart ,const int nRhs ){
|
||||||
assert( m_hasConvertedToCRSFormat );
|
assert( m_hasConvertedToCRSFormat );
|
||||||
const long long index = static_cast<long long>(m_numRows) * static_cast<long long>(iRhsStart);
|
const long long index = static_cast<long long>(m_numRows) * iRhsStart;
|
||||||
m_pardisoSolver.solve( m_rowIndex, m_columns, m_values, nRhs, &m_rightHandSideVector[index], solution );
|
m_pardisoSolver.solve( m_rowIndex, m_columns, m_values, nRhs, &m_rightHandSideVector[index], solution );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
void factorizationPhaseMatrixSolver();
|
void factorizationPhaseMatrixSolver();
|
||||||
|
|
||||||
//Solve phase of matrix solver with a specified number of right-hand side
|
//Solve phase of matrix solver with a specified number of right-hand side
|
||||||
void solvePhaseMatrixSolver( double* solution, const int iRhsStart ,const int nRhs );
|
void solvePhaseMatrixSolver( double* solution, const long long iRhsStart ,const int nRhs );
|
||||||
|
|
||||||
//Solve phase of matrix solver
|
//Solve phase of matrix solver
|
||||||
void solvePhaseMatrixSolver( double* solution );
|
void solvePhaseMatrixSolver( double* solution );
|
||||||
|
@ -189,13 +189,13 @@ void Forward3D::solvePhaseForRhsConsistingInterpolatorVectors( const int numInte
|
|||||||
const int numOfEquationFinallySolved = getNumOfEquationFinallySolved();
|
const int numOfEquationFinallySolved = getNumOfEquationFinallySolved();
|
||||||
const int numRHSDividedWithoutOdds = numInterpolatorVectors / numDivRhs;
|
const int numRHSDividedWithoutOdds = numInterpolatorVectors / numDivRhs;
|
||||||
const int numAdds = numInterpolatorVectors % numDivRhs;
|
const int numAdds = numInterpolatorVectors % numDivRhs;
|
||||||
int iRhsStart = 0;
|
long long iRhsStart = 0;
|
||||||
for( int iDiv = 0; iDiv < numDivRhs; ++iDiv ){
|
for( int iDiv = 0; iDiv < numDivRhs; ++iDiv ){
|
||||||
const int numRHSDividedWithout = iDiv < numAdds ? numRHSDividedWithoutOdds + 1 : numRHSDividedWithoutOdds;
|
const int numRHSDividedWithout = iDiv < numAdds ? numRHSDividedWithoutOdds + 1 : numRHSDividedWithoutOdds;
|
||||||
OutputFiles::m_logFile << "# Solve phase is performed simultaneously for " << numRHSDividedWithout << " right-hand sides" << ptrAnalysisControl->outputElapsedTime() << std::endl;
|
OutputFiles::m_logFile << "# Solve phase is performed simultaneously for " << numRHSDividedWithout << " right-hand sides" << ptrAnalysisControl->outputElapsedTime() << std::endl;
|
||||||
const int long long index = static_cast<long long>(numOfEquationFinallySolved) * static_cast<long long>(iRhsStart);
|
const int long long index = static_cast<long long>(numOfEquationFinallySolved) * iRhsStart;
|
||||||
m_matrix3DAnalysis.solvePhaseMatrixSolver( &solutionForInterpolatorVectors[index], iRhsStart, numRHSDividedWithout );
|
m_matrix3DAnalysis.solvePhaseMatrixSolver( &solutionForInterpolatorVectors[index], iRhsStart, numRHSDividedWithout );
|
||||||
iRhsStart += numRHSDividedWithout;
|
iRhsStart += static_cast<long long>(numRHSDividedWithout);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----- debug >>>>>
|
//----- debug >>>>>
|
||||||
|
@ -73,7 +73,7 @@ void InversionGaussNewtonDataSpace::inversionCalculation(){
|
|||||||
// Perform inversion by the new method
|
// Perform inversion by the new method
|
||||||
void InversionGaussNewtonDataSpace::inversionCalculationByNewMethod() const{
|
void InversionGaussNewtonDataSpace::inversionCalculationByNewMethod() const{
|
||||||
|
|
||||||
const bool useBLAS = false;
|
const bool useBLAS = true;
|
||||||
|
|
||||||
// Get process ID and total process number
|
// Get process ID and total process number
|
||||||
const AnalysisControl* const ptrAnalysisControl = AnalysisControl::getInstance();
|
const AnalysisControl* const ptrAnalysisControl = AnalysisControl::getInstance();
|
||||||
@ -254,11 +254,11 @@ void InversionGaussNewtonDataSpace::inversionCalculationByNewMethod() const{
|
|||||||
|
|
||||||
const int numRHSDividedWithoutOdds = numDataThisFreq / numDivRhs;
|
const int numRHSDividedWithoutOdds = numDataThisFreq / numDivRhs;
|
||||||
const int numAdds = numDataThisFreq % numDivRhs;
|
const int numAdds = numDataThisFreq % numDivRhs;
|
||||||
int iRhsStart = 0;
|
long long iRhsStart = 0;
|
||||||
for( int iDiv = 0; iDiv < numDivRhs; ++iDiv ){
|
for( int iDiv = 0; iDiv < numDivRhs; ++iDiv ){
|
||||||
const int numRHSDivided = iDiv < numAdds ? numRHSDividedWithoutOdds + 1 : numRHSDividedWithoutOdds;
|
const int numRHSDivided = iDiv < numAdds ? numRHSDividedWithoutOdds + 1 : numRHSDividedWithoutOdds;
|
||||||
OutputFiles::m_logFile << "# Solve phase is performed simultaneously for " << numRHSDivided << " right-hand sides" << ptrAnalysisControl->outputElapsedTime() << std::endl;
|
OutputFiles::m_logFile << "# Solve phase is performed simultaneously for " << numRHSDivided << " right-hand sides" << ptrAnalysisControl->outputElapsedTime() << std::endl;
|
||||||
const long long index = static_cast<long long>(numModel) * static_cast<long long>(iRhsStart);
|
const long long index = static_cast<long long>(numModel) * iRhsStart;
|
||||||
transposedConstrainingMatrix.solvePhaseMatrixSolver( numRHSDivided, &sensitivityMatrix[index], &sensitivityMatrixTemp[index] );// Solve
|
transposedConstrainingMatrix.solvePhaseMatrixSolver( numRHSDivided, &sensitivityMatrix[index], &sensitivityMatrixTemp[index] );// Solve
|
||||||
iRhsStart += numRHSDivided;
|
iRhsStart += numRHSDivided;
|
||||||
}
|
}
|
||||||
@ -564,11 +564,11 @@ void InversionGaussNewtonDataSpace::inversionCalculationByNewMethod() const{
|
|||||||
CBLAS_TRANSPOSE transA = CblasNoTrans;
|
CBLAS_TRANSPOSE transA = CblasNoTrans;
|
||||||
CBLAS_TRANSPOSE transB = CblasTrans;
|
CBLAS_TRANSPOSE transB = CblasTrans;
|
||||||
cblas_dgemm(order, transA, transB, m, n, k, alpha, sensitivityMatrixLeft, lda, sensitivityMatrixRight, ldb, beta, result, ldc);
|
cblas_dgemm(order, transA, transB, m, n, k, alpha, sensitivityMatrixLeft, lda, sensitivityMatrixRight, ldb, beta, result, ldc);
|
||||||
for( int irow = 0; irow < numDataThisFreqLeft; ++irow ){
|
for( long long irow = 0; irow < numDataThisFreqLeft; ++irow ){
|
||||||
const int row = irow + offsetRows;
|
const long long row = irow + static_cast<long long>(offsetRows);
|
||||||
for( int icol = 0; icol < numDataThisFreqRight; ++icol ){
|
for( long long icol = 0; icol < numDataThisFreqRight; ++icol ){
|
||||||
const int col = icol + offsetCols;
|
const long long col = icol + static_cast<long long>(offsetCols);
|
||||||
matrix[ row * numDataTotal + col ] = result[ irow * numDataThisFreqRight + icol ];
|
matrix[ row * static_cast<long long>(numDataTotal) + col ] = result[ irow * static_cast<long long>(numDataThisFreqRight) + icol ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete [] result;
|
delete [] result;
|
||||||
@ -897,7 +897,7 @@ void InversionGaussNewtonDataSpace::inversionCalculationByNewMethod() const{
|
|||||||
// Perform inversion by the new method using inverse of [R]T[R] matrix
|
// Perform inversion by the new method using inverse of [R]T[R] matrix
|
||||||
void InversionGaussNewtonDataSpace::inversionCalculationByNewMethodUsingInvRTRMatrix() const{
|
void InversionGaussNewtonDataSpace::inversionCalculationByNewMethodUsingInvRTRMatrix() const{
|
||||||
|
|
||||||
const bool useBLAS = false;
|
const bool useBLAS = true;
|
||||||
|
|
||||||
// Get process ID and total process number
|
// Get process ID and total process number
|
||||||
const AnalysisControl* const ptrAnalysisControl = AnalysisControl::getInstance();
|
const AnalysisControl* const ptrAnalysisControl = AnalysisControl::getInstance();
|
||||||
@ -1088,11 +1088,11 @@ void InversionGaussNewtonDataSpace::inversionCalculationByNewMethodUsingInvRTRMa
|
|||||||
|
|
||||||
const int numRHSDividedWithoutOdds = numDataThisFreq / numDivRhs;
|
const int numRHSDividedWithoutOdds = numDataThisFreq / numDivRhs;
|
||||||
const int numAdds = numDataThisFreq % numDivRhs;
|
const int numAdds = numDataThisFreq % numDivRhs;
|
||||||
int iRhsStart = 0;
|
long long iRhsStart = 0;
|
||||||
for( int iDiv = 0; iDiv < numDivRhs; ++iDiv ){
|
for( int iDiv = 0; iDiv < numDivRhs; ++iDiv ){
|
||||||
const int numRHSDivided = iDiv < numAdds ? numRHSDividedWithoutOdds + 1 : numRHSDividedWithoutOdds;
|
const int numRHSDivided = iDiv < numAdds ? numRHSDividedWithoutOdds + 1 : numRHSDividedWithoutOdds;
|
||||||
OutputFiles::m_logFile << "# Solve phase is performed simultaneously for " << numRHSDivided << " right-hand sides" << ptrAnalysisControl->outputElapsedTime() << std::endl;
|
OutputFiles::m_logFile << "# Solve phase is performed simultaneously for " << numRHSDivided << " right-hand sides" << ptrAnalysisControl->outputElapsedTime() << std::endl;
|
||||||
const long long index = static_cast<long long>(numModel) * static_cast<long long>(iRhsStart);
|
const long long index = static_cast<long long>(numModel) * iRhsStart;
|
||||||
RTRMatrix.solvePhaseMatrixSolver( numRHSDivided, &sensitivityMatrix[index], &sensitivityMatrixTemp[index] );// Solve
|
RTRMatrix.solvePhaseMatrixSolver( numRHSDivided, &sensitivityMatrix[index], &sensitivityMatrixTemp[index] );// Solve
|
||||||
iRhsStart += numRHSDivided;
|
iRhsStart += numRHSDivided;
|
||||||
}
|
}
|
||||||
@ -1374,11 +1374,11 @@ void InversionGaussNewtonDataSpace::inversionCalculationByNewMethodUsingInvRTRMa
|
|||||||
CBLAS_TRANSPOSE transA = CblasNoTrans;
|
CBLAS_TRANSPOSE transA = CblasNoTrans;
|
||||||
CBLAS_TRANSPOSE transB = CblasTrans;
|
CBLAS_TRANSPOSE transB = CblasTrans;
|
||||||
cblas_dgemm(order, transA, transB, m, n, k, alpha, sensitivityMatrixLeft, lda, sensitivityMatrixRight, ldb, beta, result, ldc);
|
cblas_dgemm(order, transA, transB, m, n, k, alpha, sensitivityMatrixLeft, lda, sensitivityMatrixRight, ldb, beta, result, ldc);
|
||||||
for( int irow = 0; irow < numDataThisFreqLeft; ++irow ){
|
for( long long irow = 0; irow < numDataThisFreqLeft; ++irow ){
|
||||||
const int row = irow + offsetRows;
|
const long long row = irow + static_cast<long long>(offsetRows);
|
||||||
for( int icol = 0; icol < numDataThisFreqRight; ++icol ){
|
for( long long icol = 0; icol < numDataThisFreqRight; ++icol ){
|
||||||
const int col = icol + offsetCols;
|
const long long col = icol + static_cast<long long>(offsetCols);
|
||||||
matrix[ row * numDataTotal + col ] = result[ irow * numDataThisFreqRight + icol ];
|
matrix[ row * static_cast<long long>(numDataTotal) + col ] = result[ irow * static_cast<long long>(numDataThisFreqRight) + icol ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete [] result;
|
delete [] result;
|
||||||
|
Loading…
Reference in New Issue
Block a user