本文整理汇总了C++中fei::SharedPtr::createMatrixGraph方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedPtr::createMatrixGraph方法的具体用法?C++ SharedPtr::createMatrixGraph怎么用?C++ SharedPtr::createMatrixGraph使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fei::SharedPtr
的用法示例。
在下文中一共展示了SharedPtr::createMatrixGraph方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_data
fei::SharedPtr<fei::Matrix>
test_Matrix::create_matrix(fei::SharedPtr<fei::Factory> factory)
{
testData test_data(localProc_, numProcs_);
fei::SharedPtr<fei::VectorSpace> vspace =
test_VectorSpace::create_VectorSpace(comm_, &test_data, localProc_, numProcs_,
false, false, (const char*)0, factory);
int err = vspace->initComplete();
if (err != 0) {
FEI_COUT << "ERROR, failed to create valid fei::VectorSpace." << FEI_ENDL;
throw std::runtime_error("test_Vector::vector_test1: ERROR, failed to create valid fei::VectorSpace.");
}
fei::SharedPtr<fei::MatrixGraph> mgraph =
factory->createMatrixGraph(vspace, vspace, NULL);
std::vector<int>& fieldIDs = test_data.fieldIDs;
std::vector<int>& idTypes = test_data.idTypes;
std::vector<int>& ids = test_data.ids;
int numIDs = ids.size();
int fieldID = fieldIDs[0];
int idType = idTypes[0];
int patternID = mgraph->definePattern(numIDs, idType, fieldID);
mgraph->initConnectivityBlock(0, 1, patternID);
mgraph->initConnectivity(0, 0, &ids[0]);
mgraph->initComplete();
fei::SharedPtr<fei::Matrix> matrix = factory->createMatrix(mgraph);
return(matrix);
}
示例2: tmp
fei::SharedPtr<fei::MatrixGraph> test_MatrixGraph::create_MatrixGraph(testData* testdata,
int localProc, int numProcs,
bool bothFields, bool nonSymmetric,
const char* name,
fei::SharedPtr<fei::VectorSpace> vectorSpacePtr,
fei::SharedPtr<fei::Factory> factory,
const std::string& path,
bool turnOnDebugOutput)
{
//
//This function creates a MatrixGraph object, and initializes it as follows:
//
//setRowSpace(vectorSpacePtr)
//
//definePattern patternID=0, numIDs=4, idType=testdata->idTypes[0]
// fieldID=testdata->fieldIDs[0] if !bothFields, else
// fieldIDs=testdata->fieldIDs
//
//initConnectivityBlock blockID=0, numConnectivityLists=1
//
//initConnectivity blockID, 0, testdata->ids
//
//If nonSymmetric==true, then also do the following:
// definePattern patternID=1, numIDs=1, idType=testdata->idTypes[0]
// fieldID=testdata->fieldIDs[0] if !bothFields, else
// fieldIDs=testdata->fieldIDs
// definePattern patternID=2, numIDs=4, idType=testdata->idTypes[0]
// fieldID=testdata->fieldIDs[0] if !bothFields, else
// fieldIDs=testdata->fieldIDs
//
//initConnectivityBlock blockID=1, patterns 1 and 2
//
//initConnectivity blockID, 0, testdata->ids
//
fei::SharedPtr<fei::MatrixGraph> mgptr;
if (factory.get() == NULL) {
fei::SharedPtr<fei::MatrixGraph> tmp(new fei::MatrixGraph_Impl2(vectorSpacePtr,
vectorSpacePtr, name));
mgptr = tmp;
}
else {
mgptr = factory->createMatrixGraph(vectorSpacePtr, vectorSpacePtr, name);
}
fei::ParameterSet paramset;
fei::Param param1("name", name);
paramset.add(param1);
if (turnOnDebugOutput) {
if (path.empty()) {
fei::Param param2("debugOutput", ".");
paramset.add(param2);
}
else {
fei::Param param2("debugOutput", path.c_str());
paramset.add(param2);
}
}
fei::MatrixGraph* matrixGraphPtr = mgptr.get();
matrixGraphPtr->setParameters(paramset);
matrixGraphPtr->setRowSpace(vectorSpacePtr);
int patternID = 0;
int numIDs = 4;
int idType = testdata->idTypes[0];
int fieldID = testdata->fieldIDs[0];
if (bothFields) {
std::vector<int> numFieldsPerID(numIDs, 2);
std::vector<int> fieldIDsArray(numIDs*2);
for(int i=0; i<numIDs; ++i) {
fieldIDsArray[i*2] = testdata->fieldIDs[0];
fieldIDsArray[i*2+1] = testdata->fieldIDs[1];
}
patternID = matrixGraphPtr->definePattern(numIDs, idType,
&numFieldsPerID[0],
&fieldIDsArray[0]);
}
else {
patternID = matrixGraphPtr->definePattern(numIDs, idType, fieldID);
}
int blockID = 0;
int numConnectivityLists = 1;
matrixGraphPtr->initConnectivityBlock(blockID,
numConnectivityLists,
patternID);
matrixGraphPtr->initConnectivity(blockID, 0, &(testdata->ids[0]));
if (!nonSymmetric) {
return(mgptr);
}
int patternID1 = 1, patternID2 = 2;
int numRowIDs = 1, numColIDs = 4;
//.........这里部分代码省略.........