本文整理汇总了C++中SparseMatrix::Save方法的典型用法代码示例。如果您正苦于以下问题:C++ SparseMatrix::Save方法的具体用法?C++ SparseMatrix::Save怎么用?C++ SparseMatrix::Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SparseMatrix
的用法示例。
在下文中一共展示了SparseMatrix::Save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExportMassMatrix
void MyFrame::ExportMassMatrix(bool fullMatrix)
{
if ((!fullMatrix) && (!precomputationState.fixedVerticesAvailable))
{
this->errMsg( _T("Error"),
_T("No fixed vertices have been specified.") );
return;
}
wxFileDialog *dlg = new wxFileDialog(this, _T("Export mass matrix"), uiState.currentWorkingDirectory, _T(""), _T("Mass Matrix Files(*.M)|*.M|All files(*.*)|*.*"), wxFD_SAVE /*| wxHIDE_READONLY*/, wxDefaultPosition);
if ( dlg->ShowModal() == wxID_OK )
{
wxString massMatrixFilename( dlg->GetPath() );
SaveCurrentWorkingDirectory(massMatrixFilename);
if( !massMatrixFilename.empty() )
{
// create mass matrix
SparseMatrix * massMatrix;
GenerateMassMatrix::computeMassMatrix(precomputationState.simulationMesh, &massMatrix, true);
if (!fullMatrix)
{
// constrain the degrees of freedom
int numConstrainedVertices = (int) (precomputationState.fixedVertices.size());
int * constrainedDOFs = (int*) malloc (sizeof(int) * 3 * numConstrainedVertices);
int i = 0;
for(set<int> :: iterator iter = precomputationState.fixedVertices.begin();
iter != precomputationState.fixedVertices.end(); iter++)
{
constrainedDOFs[3*i+0] = 3 * (*iter) + 1;
constrainedDOFs[3*i+1] = 3 * (*iter) + 2;
constrainedDOFs[3*i+2] = 3 * (*iter) + 3;
i++;
}
int oneIndexed = 1;
massMatrix->RemoveRowsColumns(
3 * numConstrainedVertices, constrainedDOFs, oneIndexed);
free(constrainedDOFs);
}
const char * filename = massMatrixFilename.mb_str();
int code = massMatrix->Save((char*)filename);
delete(massMatrix);
if (code != 0)
{
this->errMsg( _T("Saving error"),
_T("Unable to save mass matrix to ") + massMatrixFilename );
dlg->Destroy();
return;
}
}
}
dlg->Destroy();
}
示例2: ExportStiffnessMatrix
void MyFrame::ExportStiffnessMatrix(bool fullMatrix)
{
if ((!fullMatrix) && (!precomputationState.fixedVerticesAvailable))
{
this->errMsg( _T("Error"),
_T("No fixed vertices have been specified.") );
return;
}
wxFileDialog *dlg = new wxFileDialog(this, _T("Export stiffness matrix"), uiState.currentWorkingDirectory, _T(""), _T("Stiffness Matrix Files(*.K)|*.K|All files(*.*)|*.*"), wxFD_SAVE /*| wxHIDE_READONLY*/, wxDefaultPosition);
if ( dlg->ShowModal() == wxID_OK )
{
wxString stiffnessMatrixFilename( dlg->GetPath() );
SaveCurrentWorkingDirectory(stiffnessMatrixFilename);
if( !stiffnessMatrixFilename.empty() )
{
// create stiffness matrix
StVKElementABCD * precomputedIntegrals = StVKElementABCDLoader::load(precomputationState.simulationMesh);
StVKInternalForces * internalForces =
new StVKInternalForces(precomputationState.simulationMesh, precomputedIntegrals);
SparseMatrix * stiffnessMatrix;
StVKStiffnessMatrix * stiffnessMatrixClass = new StVKStiffnessMatrix(internalForces);
stiffnessMatrixClass->GetStiffnessMatrixTopology(&stiffnessMatrix);
double * zero = (double*) calloc(3 * precomputationState.simulationMesh->getNumVertices(), sizeof(double));
stiffnessMatrixClass->ComputeStiffnessMatrix(zero, stiffnessMatrix);
free(zero);
delete(precomputedIntegrals);
delete(stiffnessMatrixClass);
delete(internalForces);
if (!fullMatrix)
{
// constrain the degrees of freedom
int numConstrainedVertices = (int) (precomputationState.fixedVertices.size());
int * constrainedDOFs = (int*) malloc (sizeof(int) * 3 * numConstrainedVertices);
int i = 0;
for(set<int> :: iterator iter = precomputationState.fixedVertices.begin();
iter != precomputationState.fixedVertices.end(); iter++)
{
constrainedDOFs[3*i+0] = 3 * (*iter) + 1;
constrainedDOFs[3*i+1] = 3 * (*iter) + 2;
constrainedDOFs[3*i+2] = 3 * (*iter) + 3;
i++;
}
int oneIndexed = 1;
stiffnessMatrix->RemoveRowsColumns(
3 * numConstrainedVertices, constrainedDOFs, oneIndexed);
free(constrainedDOFs);
}
const char * filename = stiffnessMatrixFilename.mb_str();
int code = stiffnessMatrix->Save((char*)filename);
delete(stiffnessMatrix);
if (code != 0)
{
this->errMsg( _T("Saving error"),
_T("Unable to save stiffness matrix to ") + stiffnessMatrixFilename );
dlg->Destroy();
return;
}
}
}
dlg->Destroy();
}