Commit e79a39e0 authored by Radu Popescu's avatar Radu Popescu
Browse files

Astyle for PrecomputedGraphETA branch

parent fa6a3daf
......@@ -519,7 +519,7 @@ public:
//! Return the fill-complete status of the Epetra_FECrsMatrix
bool filled() const
{
return M_epetraCrs->Filled();
return M_epetraCrs->Filled();
}
//! Return the shared_pointer of the Epetra_FECrsMatrix
......@@ -1542,8 +1542,8 @@ sumIntoCoefficients ( Int const numRows, Int const numColumns,
DataType* const* const localValues,
Int format )
{
Int ierr = M_epetraCrs->SumIntoGlobalValues ( numRows, &rowIndices[0], numColumns,
&columnIndices[0], localValues, format );
Int ierr = M_epetraCrs->SumIntoGlobalValues ( numRows, &rowIndices[0], numColumns,
&columnIndices[0], localValues, format );
std::stringstream errorMessage;
errorMessage << " error in matrix insertion [addToCoefficients] " << ierr
......
......@@ -169,7 +169,7 @@ public:
//! Return the fill-complete status of the inner Epetra_FECrsMatrix
bool filled() const
{
return M_matrix->matrixPtr()->Filled();
return M_matrix->matrixPtr()->Filled();
}
//! Return the pointer of the full matrix
......
......@@ -1637,7 +1637,7 @@ FESpace<MeshType, MapType>::setSpace ( const std::string& space, UInt dimension
{
switch (dimension)
{
// 1D case
// 1D case
case 1:
switch ( M_spaceMap[space] )
{
......@@ -1657,7 +1657,7 @@ FESpace<MeshType, MapType>::setSpace ( const std::string& space, UInt dimension
M_bdQr = &quadRuleNode1pt;
break;
// In 1D, P1Bubble are "somehow" equivalent to P2, so just use those (same pattern, same dimension of the system).
// In 1D, P1Bubble are "somehow" equivalent to P2, so just use those (same pattern, same dimension of the system).
case P1Bubble :
case P2 :
M_refFE = &feSegP2;
......@@ -1677,7 +1677,7 @@ FESpace<MeshType, MapType>::setSpace ( const std::string& space, UInt dimension
}
break;
// 2D case
// 2D case
case 2:
switch ( M_spaceMap[space] )
{
......@@ -1721,7 +1721,7 @@ FESpace<MeshType, MapType>::setSpace ( const std::string& space, UInt dimension
}
break;
// 3D case
// 3D case
case 3:
switch ( M_spaceMap[space] )
{
......@@ -1773,9 +1773,9 @@ FESpace<MeshType, MapType>::setSpace ( const std::string& space, UInt dimension
}
break;
// Other dimensions not supported
// Other dimensions not supported
default:
ERROR_MSG("Error! This dimension is not supported by LifeV.\n");
ERROR_MSG ("Error! This dimension is not supported by LifeV.\n");
}
}
......
......@@ -103,7 +103,7 @@ void LifeV::HDF5IO::openTable (const std::string& tableName,
tableHandle& currentTable = M_tableList[tableName];
#ifdef H5_USE_16_API
currentTable.dataset = H5Dopen (M_fileId, tableName.c_str());
currentTable.dataset = H5Dopen (M_fileId, tableName.c_str() );
#else
currentTable.dataset = H5Dopen (M_fileId, tableName.c_str(), H5P_DEFAULT);
#endif
......
......@@ -91,7 +91,7 @@ int atoi ( const std::string& s )
std::string operator+ ( const std::string& str, const int i )
{
int digits = i==0 ? 2 : std::log10( std::abs(i) ) + 2;
int digits = i == 0 ? 2 : std::log10 ( std::abs (i) ) + 2;
char* str_i = new char[ digits ];
sprintf ( str_i, "%i", i );
std::string str2 = str + str_i;
......@@ -101,7 +101,7 @@ std::string operator+ ( const std::string& str, const int i )
std::string operator+ ( const std::string& str, const long i )
{
int digits = i==0 ? 2 : std::log10( std::abs(i) ) + 2;
int digits = i == 0 ? 2 : std::log10 ( std::abs (i) ) + 2;
char* str_i = new char[ digits ];
sprintf ( str_i, "%ld", i );
std::string str2 = str + str_i;
......@@ -111,7 +111,7 @@ std::string operator+ ( const std::string& str, const long i )
std::string operator+ ( const std::string& str, const unsigned int i )
{
int digits = i==0 ? 2 : std::log10(i) + 2;
int digits = i == 0 ? 2 : std::log10 (i) + 2;
char* str_i = new char[ digits ];
sprintf ( str_i, "%u", i );
std::string str2 = str + str_i;
......
......@@ -121,21 +121,21 @@ public:
}
//! Assembly procedure for a matrix or a block of a matrix
/*!
This method puts the values stored in this elemental matrix into the global
matrix passed as argument, using the positions given in the global indices
stored.
The method is used when the global matrix is closed
*/
// Method defined in class to allow compiler optimization
// as this class is used repeatedly during the assembly
template <typename MatrixType>
void pushToClosedGlobal (MatrixType& mat)
{
mat.sumIntoCoefficients ( M_nbRow, M_nbColumn,
rowIndices(), columnIndices(),
M_rawData, Epetra_FECrsMatrix::ROW_MAJOR);
}
/*!
This method puts the values stored in this elemental matrix into the global
matrix passed as argument, using the positions given in the global indices
stored.
The method is used when the global matrix is closed
*/
// Method defined in class to allow compiler optimization
// as this class is used repeatedly during the assembly
template <typename MatrixType>
void pushToClosedGlobal (MatrixType& mat)
{
mat.sumIntoCoefficients ( M_nbRow, M_nbColumn,
rowIndices(), columnIndices(),
M_rawData, Epetra_FECrsMatrix::ROW_MAJOR);
}
//! Assembly procedure for a matrix or a block of a matrix passed in a shared_ptr
/*!
......
......@@ -70,23 +70,23 @@ namespace ExpressionAssembly
a FECrsMatrix in closed optimized form
*/
template < typename MeshType,
typename TestSpaceType,
typename SolutionSpaceType,
typename ExpressionType>
GraphElement<MeshType,
TestSpaceType,
SolutionSpaceType,
ExpressionType>
buildGraph ( const RequestLoopElement<MeshType>& request,
const QuadratureRule& quadrature,
const boost::shared_ptr<TestSpaceType>& testSpace,
const boost::shared_ptr<SolutionSpaceType>& solutionSpace,
const ExpressionType& expression)
typename TestSpaceType,
typename SolutionSpaceType,
typename ExpressionType >
GraphElement < MeshType,
TestSpaceType,
SolutionSpaceType,
ExpressionType >
buildGraph ( const RequestLoopElement<MeshType>& request,
const QuadratureRule& quadrature,
const boost::shared_ptr<TestSpaceType>& testSpace,
const boost::shared_ptr<SolutionSpaceType>& solutionSpace,
const ExpressionType& expression)
{
return GraphElement<MeshType,
TestSpaceType,
SolutionSpaceType,
ExpressionType>
return GraphElement < MeshType,
TestSpaceType,
SolutionSpaceType,
ExpressionType >
(request.mesh(), quadrature, testSpace, solutionSpace, expression);
}
......
......@@ -65,9 +65,9 @@ namespace ExpressionAssembly
matrix
*/
template < typename MeshType,
typename TestSpaceType,
typename SolutionSpaceType,
typename ExpressionType>
typename TestSpaceType,
typename SolutionSpaceType,
typename ExpressionType >
class GraphElement
{
public:
......@@ -95,10 +95,10 @@ public:
const ExpressionType& expression);
//! Copy constructor
GraphElement (const GraphElement<MeshType,
TestSpaceType,
SolutionSpaceType,
ExpressionType>& integrator);
GraphElement (const GraphElement < MeshType,
TestSpaceType,
SolutionSpaceType,
ExpressionType > & integrator);
//! Destructor
~GraphElement();
......@@ -183,10 +183,10 @@ private:
template < typename MeshType, typename TestSpaceType, typename SolutionSpaceType, typename ExpressionType>
GraphElement<MeshType, TestSpaceType, SolutionSpaceType, ExpressionType>::
GraphElement (const boost::shared_ptr<MeshType>& mesh,
const QuadratureRule& quadrature,
const boost::shared_ptr<TestSpaceType>& testSpace,
const boost::shared_ptr<SolutionSpaceType>& solutionSpace,
const ExpressionType& /*expression*/)
const QuadratureRule& quadrature,
const boost::shared_ptr<TestSpaceType>& testSpace,
const boost::shared_ptr<SolutionSpaceType>& solutionSpace,
const ExpressionType& /*expression*/)
: M_mesh (mesh),
M_quadrature (quadrature),
M_testSpace (testSpace),
......@@ -232,42 +232,42 @@ addTo (GraphType& graph)
UInt nbTestDof (M_testSpace->refFE().nbDof() );
UInt nbSolutionDof (M_solutionSpace->refFE().nbDof() );
ETMatrixElemental elementalMatrix(TestSpaceType::S_fieldDim * M_testSpace->refFE().nbDof(),
SolutionSpaceType::S_fieldDim * M_solutionSpace->refFE().nbDof() );
for (UInt iElement = 0; iElement < nbElements; ++iElement)
{
// Zeros out the matrix
elementalMatrix.zero();
// Loop on the blocks
for (UInt iblock (0); iblock < TestSpaceType::S_fieldDim; ++iblock)
{
for (UInt jblock (0); jblock < SolutionSpaceType::S_fieldDim; ++jblock)
{
// Set the row global indices in the local matrix
for (UInt i (0); i < nbTestDof; ++i)
{
elementalMatrix.setRowIndex
(i + iblock * nbTestDof,
M_testSpace->dof().localToGlobalMap (iElement, i) + iblock * M_testSpace->dof().numTotalDof() );
}
// Set the column global indices in the local matrix
for (UInt j (0); j < nbSolutionDof; ++j)
{
elementalMatrix.setColumnIndex
(j + jblock * nbSolutionDof,
M_solutionSpace->dof().localToGlobalMap (iElement, j) + jblock * M_solutionSpace->dof().numTotalDof() );
}
}
}
const std::vector<Int>& rowIdx = elementalMatrix.rowIndices();
const std::vector<Int>& colIdx = elementalMatrix.columnIndices();
graph.InsertGlobalIndices(rowIdx.size(), &rowIdx[0],
colIdx.size(), &colIdx[0]);
}
ETMatrixElemental elementalMatrix (TestSpaceType::S_fieldDim * M_testSpace->refFE().nbDof(),
SolutionSpaceType::S_fieldDim * M_solutionSpace->refFE().nbDof() );
for (UInt iElement = 0; iElement < nbElements; ++iElement)
{
// Zeros out the matrix
elementalMatrix.zero();
// Loop on the blocks
for (UInt iblock (0); iblock < TestSpaceType::S_fieldDim; ++iblock)
{
for (UInt jblock (0); jblock < SolutionSpaceType::S_fieldDim; ++jblock)
{
// Set the row global indices in the local matrix
for (UInt i (0); i < nbTestDof; ++i)
{
elementalMatrix.setRowIndex
(i + iblock * nbTestDof,
M_testSpace->dof().localToGlobalMap (iElement, i) + iblock * M_testSpace->dof().numTotalDof() );
}
// Set the column global indices in the local matrix
for (UInt j (0); j < nbSolutionDof; ++j)
{
elementalMatrix.setColumnIndex
(j + jblock * nbSolutionDof,
M_solutionSpace->dof().localToGlobalMap (iElement, j) + jblock * M_solutionSpace->dof().numTotalDof() );
}
}
}
const std::vector<Int>& rowIdx = elementalMatrix.rowIndices();
const std::vector<Int>& colIdx = elementalMatrix.columnIndices();
graph.InsertGlobalIndices (rowIdx.size(), &rowIdx[0],
colIdx.size(), &colIdx[0]);
}
}
......
......@@ -109,22 +109,28 @@ public:
template <typename MatrixType>
inline void operator>> (MatrixType& mat)
{
if (mat.filled()) {
addToClosed (mat);
} else {
addTo (mat);
}
if (mat.filled() )
{
addToClosed (mat);
}
else
{
addTo (mat);
}
}
//! Operator wrapping the addTo method (for shared_ptr)
template <typename MatrixType>
inline void operator>> (boost::shared_ptr<MatrixType> mat)
{
if (mat->filled()) {
addToClosed (mat);
} else {
addTo (mat);
}
if (mat->filled() )
{
addToClosed (mat);
}
else
{
addTo (mat);
}
}
//@}
......@@ -208,11 +214,11 @@ private:
* This method computes the elemental matrix for a given element
* index
*/
void integrateElement(const UInt iElement,
const UInt nbElements,
const UInt nbQuadPt,
const UInt nbTestDof,
const UInt nbSolutionDof);
void integrateElement (const UInt iElement,
const UInt nbElements,
const UInt nbQuadPt,
const UInt nbTestDof,
const UInt nbSolutionDof);
//@}
......@@ -323,8 +329,8 @@ template < typename MeshType, typename TestSpaceType, typename SolutionSpaceType
void
IntegrateMatrixElement<MeshType, TestSpaceType, SolutionSpaceType, ExpressionType>::
integrateElement (const UInt iElement, const UInt nbElements,
const UInt nbQuadPt, const UInt nbTestDof,
const UInt nbSolutionDof)
const UInt nbQuadPt, const UInt nbTestDof,
const UInt nbSolutionDof)
{
// Zeros out the matrix
M_elementalMatrix.zero();
......@@ -390,8 +396,8 @@ addTo (MatrixType& mat)
for (UInt iElement (0); iElement < nbElements; ++iElement)
{
integrateElement(iElement, nbElements, nbQuadPt, nbTestDof,
nbSolutionDof);
integrateElement (iElement, nbElements, nbQuadPt, nbTestDof,
nbSolutionDof);
M_elementalMatrix.pushToGlobal (mat);
}
......@@ -410,8 +416,8 @@ addToClosed (MatrixType& mat)
for (UInt iElement (0); iElement < nbElements; ++iElement)
{
integrateElement(iElement, nbElements, nbQuadPt, nbTestDof,
nbSolutionDof);
integrateElement (iElement, nbElements, nbQuadPt, nbTestDof,
nbSolutionDof);
M_elementalMatrix.pushToClosedGlobal (mat);
}
......
......@@ -85,15 +85,17 @@ int main ( int argc, char** argv )
const bool verbose (Comm->MyPID() == 0);
if (argc != 2) {
if (verbose) {
std::cout << "Please run program as " << argv[0]
<< " " << "<num_elements>\n";
return EXIT_FAILURE;
}
if (argc != 2)
{
if (verbose)
{
std::cout << "Please run program as " << argv[0]
<< " " << "<num_elements>\n";
return EXIT_FAILURE;
}
}
const UInt Nelements = std::atoi(argv[1]);
const UInt Nelements = std::atoi (argv[1]);
if (verbose)
{
......@@ -148,7 +150,7 @@ int main ( int argc, char** argv )
using namespace ExpressionAssembly;
// We first build a static graph for our problem matrix
matrixGraph.reset(new Epetra_FECrsGraph(Copy, *(uSpace->map().map(Unique)), 0));
matrixGraph.reset (new Epetra_FECrsGraph (Copy, * (uSpace->map().map (Unique) ), 0) );
buildGraph ( elements (uSpace->mesh() ),
quadRuleTetra4pt,
......@@ -175,7 +177,7 @@ int main ( int argc, char** argv )
using namespace ExpressionAssembly;
// We build the system matrix using the precomputed graph
closedSystemMatrix.reset(new matrix_Type ( uSpace->map(), *matrixGraph ) );
closedSystemMatrix.reset (new matrix_Type ( uSpace->map(), *matrixGraph ) );
*closedSystemMatrix *= 0.0;
// Finally, we perform the FE assembly, which should be faster with
......@@ -205,7 +207,7 @@ int main ( int argc, char** argv )
{
using namespace ExpressionAssembly;
openSystemMatrix.reset(new matrix_Type ( uSpace->map() ) );
openSystemMatrix.reset (new matrix_Type ( uSpace->map() ) );
*openSystemMatrix *= 0.0;
// Finally, we perform the FE assembly, which should be faster with
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment