本文整理汇总了C++中teuchos::Array::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::empty方法的具体用法?C++ Array::empty怎么用?C++ Array::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类teuchos::Array
的用法示例。
在下文中一共展示了Array::empty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scNames
// =============================================================================
void
VIO::EpetraMesh::Writer::
setValues( const Epetra_MultiVector & x,
const Teuchos::Array<std::string> & scalarsNames
)
{
unsigned int numVecs = x.NumVectors();
unsigned int numVariables = x.GlobalLength();
unsigned int numNodes = mesh_->getNodesMap()->NumGlobalElements();
// make sure the sizes match the mesh
if ( !mesh_.is_null() )
TEUCHOS_ASSERT_EQUALITY( numVariables, 2*numNodes );
// cast into a vtkUnstructuredGrid
vtkSmartPointer<vtkUnstructuredGrid> vtkMesh =
dynamic_cast<vtkUnstructuredGrid*> ( vtkDataSet_.GetPointer() );
TEUCHOS_ASSERT_INEQUALITY( 0, !=, vtkMesh );
// get scalarsNames, and insert default names if empty
Teuchos::Array<std::string> scNames ( scalarsNames );
if ( scNames.empty() )
{
scNames.resize ( numVecs );
for ( int vec=0; vec<numVecs; vec++ )
scNames[vec] = "x" + EpetraExt::toString ( vec );
}
// fill the scalar field
vtkSmartPointer<vtkDoubleArray> scalars =
vtkSmartPointer<vtkDoubleArray>::New();
// real and imaginary part
scalars->SetNumberOfComponents ( 2 );
for ( int vec=0; vec<numVecs; vec++ )
{
scalars->SetName ( scNames[vec].c_str() );
for ( int k=0; k<numNodes; k++ )
{
// const unsigned int dof_id = libmeshMesh_->node(k).dof_number(0,k,0);
scalars->InsertNextValue ( x[vec][2*k] );
scalars->InsertNextValue ( x[vec][2*k+1] );
}
vtkMesh->GetPointData()->AddArray ( scalars );
}
return;
}
示例2: BoundingBox
BoundingBox GeometryManager<Geometry,GlobalOrdinal>::localBoundingBox() const
{
double global_x_min = Teuchos::ScalarTraits<double>::rmax();
double global_y_min = Teuchos::ScalarTraits<double>::rmax();
double global_z_min = Teuchos::ScalarTraits<double>::rmax();
double global_x_max = -Teuchos::ScalarTraits<double>::rmax();
double global_y_max = -Teuchos::ScalarTraits<double>::rmax();
double global_z_max = -Teuchos::ScalarTraits<double>::rmax();
// Get the local bounding boxes compute the local bounding box.
BoundingBox local_box;
Teuchos::Tuple<double,6> box_bounds;
Teuchos::Array<BoundingBox> boxes = boundingBoxes();
Teuchos::Array<BoundingBox>::const_iterator box_iterator;
DTK_CHECK( !boxes.empty() );
for ( box_iterator = boxes.begin();
box_iterator != boxes.end();
++box_iterator )
{
box_bounds = box_iterator->getBounds();
if ( box_bounds[0] < global_x_min )
{
global_x_min = box_bounds[0];
}
if ( box_bounds[1] < global_y_min )
{
global_y_min = box_bounds[1];
}
if ( box_bounds[2] < global_z_min )
{
global_z_min = box_bounds[2];
}
if ( box_bounds[3] > global_x_max )
{
global_x_max = box_bounds[3];
}
if ( box_bounds[4] > global_y_max )
{
global_y_max = box_bounds[4];
}
if ( box_bounds[5] > global_z_max )
{
global_z_max = box_bounds[5];
}
}
return BoundingBox( global_x_min, global_y_min, global_z_min,
global_x_max, global_y_max, global_z_max );
}
示例3: scNames
// =============================================================================
void
VIO::Image::Writer::Abstract::
setImageData ( const Epetra_MultiVector & x,
const Teuchos::Tuple<unsigned int,2> & Nx,
const Point & h,
const Teuchos::Array<int> & p,
const Teuchos::Array<std::string> & scalarsNames
)
{
int numVecs = x.NumVectors();
int numPoints = ( Nx[0]+1 ) * ( Nx[1]+1 );
// get scalarsNames, and insert default names if empty
Teuchos::Array<std::string> scNames ( scalarsNames );
if ( scNames.empty() )
{
scNames.resize ( numVecs );
for ( int vec=0; vec<numVecs; vec++ )
scNames[vec] = "x" + EpetraExt::toString ( vec );
}
// cast into vtkImageData
vtkSmartPointer<vtkImageData> imageData =
dynamic_cast<vtkImageData*> ( vtkDataSet_.GetPointer() );
TEUCHOS_ASSERT_INEQUALITY( 0, !=, imageData );
// set other image data
imageData->SetDimensions ( Nx[0]+1, Nx[1]+1, 1 );
imageData->SetOrigin ( 0.0, 0.0, 0.0 );
imageData->SetSpacing ( h[0], h[1], 0.0 );
// fill the scalar field
vtkSmartPointer<vtkDoubleArray> scalars =
vtkSmartPointer<vtkDoubleArray>::New();
bool isScrambled = !p.empty();
if ( isScrambled )
{
TEUCHOS_ASSERT_EQUALITY ( numPoints, p.length() );
addFieldData ( p, "p" );
}
// fill the scalars vector and add it to imageData_
if ( isScrambled )
{
double dummy = 0.0;
for ( int vec=0; vec<numVecs; vec++ )
{
scalars->SetName ( scNames[vec].c_str() );
for ( int k=0; k<numPoints; k++ )
scalars->InsertNextValue ( p[k]>=0 ? x[vec][p[k]] : dummy );
imageData->GetPointData()->AddArray ( scalars );
}
}
else
for ( int vec=0; vec<numVecs; vec++ )
{
scalars->SetName ( scNames[vec].c_str() );
for ( int k=0; k<numPoints; k++ )
scalars->InsertNextValue ( x[vec][k] );
imageData->GetPointData()->AddArray ( scalars );
}
return;
}