本文整理汇总了C++中teuchos::oblackholestream类的典型用法代码示例。如果您正苦于以下问题:C++ oblackholestream类的具体用法?C++ oblackholestream怎么用?C++ oblackholestream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了oblackholestream类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: compareToAnalytic
ordinal_type compareToAnalytic( std::ifstream &inputFile,
const Kokkos::DynRankView<ValueType,testMatProperties...> testMat,
const ValueType reltol,
const ordinal_type iprint,
const TypeOfExactData analyticDataType ) {
INTREPID2_TEST_FOR_EXCEPTION( testMat.rank() != 2, std::invalid_argument,
">>> ERROR (compareToAnalytic): testMat must have rank 2");
Teuchos::RCP<std::ostream> outStream;
Teuchos::oblackholestream outNothing;
if (iprint > 0)
outStream = Teuchos::rcp(&std::cout, false);
else
outStream = Teuchos::rcp(&outNothing, false);
// Save the format state of the original std::cout.
Teuchos::oblackholestream oldFormatState;
oldFormatState.copyfmt(std::cout);
std::string line;
ValueType testentry;
ValueType abstol;
ValueType absdiff;
ordinal_type i = 0, j = 0;
ordinal_type err = 0;
while (! inputFile.eof() && i < static_cast<ordinal_type>(testMat.dimension(0)) ) {
std::getline(inputFile,line);
std::istringstream linestream(line);
std::string chunk;
j = 0;
while( linestream >> chunk ) {
ordinal_type num1;
ordinal_type num2;
std::string::size_type loc = chunk.find( "/", 0);
if( loc != std::string::npos ) {
chunk.replace( loc, 1, " ");
std::istringstream chunkstream(chunk);
chunkstream >> num1;
chunkstream >> num2;
testentry = (ValueType)(num1)/(ValueType)(num2);
abstol = ( std::fabs(testentry) < reltol ? reltol : std::fabs(reltol*testentry) );
absdiff = std::fabs(testentry - testMat(i, j));
if (absdiff > abstol) {
++err;
*outStream << "FAILURE --> ";
}
*outStream << "entry[" << i << "," << j << "]:" << " "
<< testMat(i, j) << " " << num1 << "/" << num2 << " "
<< absdiff << " " << "<?" << " " << abstol << "\n";
}
else {
std::istringstream chunkstream(chunk);
if (analyticDataType == INTREPID2_UTILS_FRACTION) {
chunkstream >> num1;
testentry = (ValueType)(num1);
}
else if (analyticDataType == INTREPID2_UTILS_SCALAR)
开发者ID:KineticTheory,项目名称:Trilinos,代码行数:58,代码来源:Intrepid2_Utils_ExtDataDef.hpp
示例2: main
int main(int argc, char *argv[]) {
// feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
typedef ROL::Vector<RealT> V;
typedef ROL::Objective<RealT> OBJ;
typedef ROL::BoundConstraint<RealT> CON;
using Teuchos::RCP;
Teuchos::GlobalMPISession mpiSession(&argc, &argv);
// This little trick lets us print to std::cout only if a (dummy) command-line argument is provided.
int iprint = argc - 1;
Teuchos::RCP<std::ostream> outStream;
Teuchos::oblackholestream bhs; // outputs nothing
if (iprint > 0)
outStream = Teuchos::rcp(&std::cout, false);
else
outStream = Teuchos::rcp(&bhs, false);
// Save the format state of the original std::cout.
Teuchos::oblackholestream oldFormatState;
oldFormatState.copyfmt(std::cout);
RealT zero(0);
RCP<V> x0;
RCP<V> x;
RCP<V> g;
RCP<OBJ> obj;
RCP<CON> con;
RCP<OBJ> model;
ROL::ZOO::getHS2(obj,con,x0,x);
g = x->dual().clone();
// Need to evaluate the gradient to construct the model
obj->gradient(*g,*x,zero);
model = Teuchos::rcp(new ROL::ColemanLiModel<RealT>(*obj,*con,*x,*g));
RCP<V> s = x->clone();
RCP<V> v = x->clone();
RCP<V> u = x->clone();
ROL::RandomizeVector(*s,-1.0,1.0);
ROL::RandomizeVector(*u,-1.0,1.0);
ROL::RandomizeVector(*v,-1.0,1.0);
model->checkGradient(*s,*v);
model->checkHessVec(*s,*v);
model->checkHessSym(*s,*u,*v);
return 0;
}
开发者ID:trilinos,项目名称:Trilinos,代码行数:55,代码来源:test_11.cpp
示例3: hsymCheck
std::vector<Real> Objective<Real>::checkHessSym( const Vector<Real> &x,
const Vector<Real> &hv,
const Vector<Real> &v,
const Vector<Real> &w,
const bool printToStream,
std::ostream & outStream ) {
Real tol = std::sqrt(ROL_EPSILON);
// Compute (Hessian at x) times (vector v).
Teuchos::RCP<Vector<Real> > h = hv.clone();
this->hessVec(*h, v, x, tol);
Real wHv = w.dot(h->dual());
this->hessVec(*h, w, x, tol);
Real vHw = v.dot(h->dual());
std::vector<Real> hsymCheck(3, 0);
hsymCheck[0] = wHv;
hsymCheck[1] = vHw;
hsymCheck[2] = std::abs(vHw-wHv);
// Save the format state of the original outStream.
Teuchos::oblackholestream oldFormatState;
oldFormatState.copyfmt(outStream);
if (printToStream) {
outStream << std::right
<< std::setw(20) << "<w, H(x)v>"
<< std::setw(20) << "<v, H(x)w>"
<< std::setw(20) << "abs error"
<< "\n";
outStream << std::scientific << std::setprecision(11) << std::right
<< std::setw(20) << hsymCheck[0]
<< std::setw(20) << hsymCheck[1]
<< std::setw(20) << hsymCheck[2]
<< "\n";
}
// Reset format state of outStream.
outStream.copyfmt(oldFormatState);
return hsymCheck;
} // checkHessSym
开发者ID:ChiahungTai,项目名称:Trilinos,代码行数:46,代码来源:ROL_ObjectiveDef.hpp
示例4: ConstructWithLabel
int HDIV_WEDGE_I1_FEM_Test01(const bool verbose) {
Teuchos::RCP<std::ostream> outStream;
Teuchos::oblackholestream bhs; // outputs nothing
if (1)// (verbose)
outStream = Teuchos::rcp(&std::cout, false);
else
outStream = Teuchos::rcp(&bhs, false);
Teuchos::oblackholestream oldFormatState;
oldFormatState.copyfmt(std::cout);
typedef typename
Kokkos::Impl::is_space<DeviceSpaceType>::host_mirror_space::execution_space HostSpaceType ;
*outStream << "DeviceSpace:: "; DeviceSpaceType::print_configuration(*outStream, false);
*outStream << "HostSpace:: "; HostSpaceType::print_configuration(*outStream, false);
*outStream
<< "===============================================================================\n"
<< "| |\n"
<< "| Unit Test (Basis_HDIV_WEDGE_I1_FEM) |\n"
<< "| |\n"
<< "| 1) Conversion of Dof tags into Dof ordinals and back |\n"
<< "| 2) Basis values for VALUE and DIV operators |\n"
<< "| |\n"
<< "| Questions? Contact Pavel Bochev ([email protected]), |\n"
<< "| Denis Ridzal ([email protected]), |\n"
<< "| Kara Peterson ([email protected]). |\n"
<< "| |\n"
<< "| Intrepid's website: http://trilinos.sandia.gov/packages/intrepid |\n"
<< "| Trilinos website: http://trilinos.sandia.gov |\n"
<< "| |\n"
<< "===============================================================================\n";
typedef Kokkos::DynRankView<ValueType,DeviceSpaceType> DynRankView;
typedef Kokkos::DynRankView<ValueType,HostSpaceType> DynRankViewHost;
#define ConstructWithLabel(obj, ...) obj(#obj, __VA_ARGS__)
const ValueType tol = tolerence();
int errorFlag = 0;
// for virtual function, value and point types are declared in the class
typedef ValueType outputValueType;
typedef ValueType pointValueType;
Basis_HDIV_WEDGE_I1_FEM<DeviceSpaceType,outputValueType,pointValueType> wedgeBasis;
*outStream
<< "\n"
<< "===============================================================================\n"
<< "| TEST 1: constructors and exceptions |\n"
<< "===============================================================================\n";
try {
ordinal_type nthrow = 0, ncatch = 0;
#ifdef HAVE_INTREPID2_DEBUG
// Define array containing the 6 vertices of the reference WEDGE and 6 other points.
DynRankView ConstructWithLabel(wedgeNodes, 12, 3);
// Generic array for the output values; needs to be properly resized depending on the operator type
const auto numFields = wedgeBasis.getCardinality();
const auto numPoints = wedgeNodes.dimension(0);
const auto spaceDim = wedgeBasis.getBaseCellTopology().getDimension();
// exception #1: GRAD cannot be applied to HDIV functions
DynRankView ConstructWithLabel(vals, numFields, numPoints, spaceDim );
INTREPID2_TEST_ERROR_EXPECTED( wedgeBasis.getValues(vals, wedgeNodes, OPERATOR_GRAD));
// exception #2: CURL cannot be applied to HDIV functions
INTREPID2_TEST_ERROR_EXPECTED( wedgeBasis.getValues(vals, wedgeNodes, OPERATOR_CURL));
// Exceptions 3-7: all bf tags/bf Ids below are wrong and should cause getDofOrdinal() and
// getDofTag() to access invalid array elements thereby causing bounds check exception
// exception #3
INTREPID2_TEST_ERROR_EXPECTED( wedgeBasis.getDofOrdinal(3,0,0));
// exception #4
INTREPID2_TEST_ERROR_EXPECTED( wedgeBasis.getDofOrdinal(1,1,1));
// exception #5
INTREPID2_TEST_ERROR_EXPECTED( wedgeBasis.getDofOrdinal(0,4,1));
// exception #6
INTREPID2_TEST_ERROR_EXPECTED( wedgeBasis.getDofTag(11));
// exception #7
INTREPID2_TEST_ERROR_EXPECTED( wedgeBasis.getDofTag(-1));
// Exceptions 8-15 test exception handling with incorrectly dimensioned input/output arrays
// exception #8: input points array must be of rank-2
DynRankView ConstructWithLabel(badPoints1, 4, 5, 3);
INTREPID2_TEST_ERROR_EXPECTED( wedgeBasis.getValues(vals, badPoints1, OPERATOR_VALUE));
// exception #9 dimension 1 in the input point array must equal space dimension of the cell
DynRankView ConstructWithLabel(badPoints2, 4, 2);
INTREPID2_TEST_ERROR_EXPECTED( wedgeBasis.getValues(vals, badPoints2, OPERATOR_VALUE));
// exception #10 output values must be of rank-3 for OPERATOR_VALUE
DynRankView ConstructWithLabel(badVals1, 4, 3);
INTREPID2_TEST_ERROR_EXPECTED( wedgeBasis.getValues(badVals1, wedgeNodes, OPERATOR_VALUE));
// exception #11 output values must be of rank-2 for OPERATOR_DIV
DynRankView ConstructWithLabel(badVals2, 4, 3, 1);
//.........这里部分代码省略.........
开发者ID:KineticTheory,项目名称:Trilinos,代码行数:101,代码来源:test_01.hpp
示例5: ConstructWithLabel
int HCURL_WEDGE_I1_FEM_Test01(const bool verbose) {
Teuchos::RCP<std::ostream> outStream;
Teuchos::oblackholestream bhs; // outputs nothing
if (verbose)
outStream = Teuchos::rcp(&std::cout, false);
else
outStream = Teuchos::rcp(&bhs, false);
Teuchos::oblackholestream oldFormatState;
oldFormatState.copyfmt(std::cout);
typedef typename
Kokkos::Impl::is_space<DeviceSpaceType>::host_mirror_space::execution_space HostSpaceType ;
*outStream << "DeviceSpace:: "; DeviceSpaceType::print_configuration(*outStream, false);
*outStream << "HostSpace:: "; HostSpaceType::print_configuration(*outStream, false);
*outStream
<< "\n"
<< "===============================================================================\n"
<< "| |\n"
<< "| Unit Test (Basis_HCURL_WEDGE_I1_FEM) |\n"
<< "| |\n"
<< "| 1) Conversion of Dof tags into Dof ordinals and back |\n"
<< "| 2) Basis values for VALUE and CURL operators |\n"
<< "| |\n"
<< "| Questions? Contact Pavel Bochev ([email protected]), |\n"
<< "| Denis Ridzal ([email protected]), |\n"
<< "| Kara Peterson ([email protected]). |\n"
<< "| Kyungjoo Kim ([email protected]). |\n"
<< "| |\n"
<< "| Intrepid's website: http://trilinos.sandia.gov/packages/intrepid |\n"
<< "| Trilinos website: http://trilinos.sandia.gov |\n"
<< "| |\n"
<< "===============================================================================\n";
typedef Kokkos::DynRankView<ValueType,DeviceSpaceType> DynRankView;
typedef Kokkos::DynRankView<ValueType,HostSpaceType> DynRankViewHost;
#define ConstructWithLabel(obj, ...) obj(#obj, __VA_ARGS__)
const ValueType tol = tolerence();
int errorFlag = 0;
// for virtual function, value and point types are declared in the class
typedef ValueType outputValueType;
typedef ValueType pointValueType;
Basis_HCURL_WEDGE_I1_FEM<DeviceSpaceType,outputValueType,pointValueType> wedgeBasis;
*outStream
<< "\n"
<< "===============================================================================\n"
<< "| TEST 1: Basis creation, exception testing |\n"
<< "===============================================================================\n";
try{
ordinal_type nthrow = 0, ncatch = 0;
#ifdef HAVE_INTREPID2_DEBUG
// Define array containing the 4 vertices of the reference WEDGE and its center.
DynRankView ConstructWithLabel(wedgeNodes, 12, 3);
// Generic array for the output values; needs to be properly resized depending on the operator type
const ordinal_type numFields = wedgeBasis.getCardinality();
const ordinal_type numPoints = wedgeNodes.dimension(0);
const ordinal_type spaceDim = wedgeBasis.getBaseCellTopology().getDimension();
DynRankView vals ("vals", numFields, numPoints);
DynRankView vals_vec ("vals", numFields, numPoints, spaceDim);
{
// exception #1: GRAD cannot be applied to HCURL functions
// resize vals to rank-3 container with dimensions (num. basis functions, num. points, arbitrary)
INTREPID2_TEST_ERROR_EXPECTED( wedgeBasis.getValues(vals_vec, wedgeNodes, OPERATOR_GRAD) );
// exception #2: DIV cannot be applied to HCURL functions
// resize vals to rank-2 container with dimensions (num. basis functions, num. points)
INTREPID2_TEST_ERROR_EXPECTED( wedgeBasis.getValues(vals, wedgeNodes, OPERATOR_DIV) );
}
// Exceptions 3-7: all bf tags/bf Ids below are wrong and should cause getDofOrdinal() and
// getDofTag() to access invalid array elements thereby causing bounds check exception
{
// exception #3
INTREPID2_TEST_ERROR_EXPECTED( wedgeBasis.getDofOrdinal(3,0,0) );
// exception #4
INTREPID2_TEST_ERROR_EXPECTED( wedgeBasis.getDofOrdinal(1,1,1) );
// exception #5
INTREPID2_TEST_ERROR_EXPECTED( wedgeBasis.getDofOrdinal(0,4,1) );
// exception #6
INTREPID2_TEST_ERROR_EXPECTED( wedgeBasis.getDofTag(numFields) );
// exception #7
INTREPID2_TEST_ERROR_EXPECTED( wedgeBasis.getDofTag(-1) );
}
// Exceptions 8- test exception handling with incorrectly dimensioned input/output arrays
{
// exception #8: input points array must be of rank-2
DynRankView ConstructWithLabel(badPoints1, 4, 5, 3);
INTREPID2_TEST_ERROR_EXPECTED( wedgeBasis.getValues(vals, badPoints1, OPERATOR_VALUE) );
}
//.........这里部分代码省略.........
开发者ID:brian-kelley,项目名称:Trilinos,代码行数:101,代码来源:test_01.hpp
示例6: Test
int Orientation_Test05(const bool verbose) {
Teuchos::RCP<std::ostream> outStream;
Teuchos::oblackholestream bhs; // outputs nothing
if (verbose)
outStream = Teuchos::rcp(&std::cout, false);
else
outStream = Teuchos::rcp(&bhs, false);
Teuchos::oblackholestream oldFormatState;
oldFormatState.copyfmt(std::cout);
typedef typename
Kokkos::Impl::is_space<DeviceSpaceType>::host_mirror_space::execution_space HostSpaceType ;
*outStream << "DeviceSpace:: "; DeviceSpaceType::print_configuration(*outStream, false);
*outStream << "HostSpace:: "; HostSpaceType::print_configuration(*outStream, false);
*outStream << "\n";
*outStream
<< "===============================================================================\n"
<< "| |\n"
<< "| Unit Test (OrientationTools, getModifiedHcurl_I1_Basis) |\n"
<< "| |\n"
<< "===============================================================================\n";
int errorFlag = 0;
const double tol = tolerence();
typedef OrientationTools<DeviceSpaceType> ots;
try {
{
*outStream << "\n -- Testing Quadrilateral \n\n";
Basis_HCURL_QUAD_I1_FEM<DeviceSpaceType> cellBasis;
const auto cellTopo = cellBasis.getBaseCellTopology();
const ordinal_type ndofBasis = cellBasis.getCardinality();
//
// 9 12 13 16
// 4 3 11 15
// 5 2 8 14
// 1 6 7 10
ordinal_type refMesh[9][4] = { { 1, 6, 2, 5 },
{ 6, 7, 8, 2 },
{ 7,10,14, 8 },
{ 5, 2, 3, 4 },
{ 2, 8,11, 3 },
{ 8,14,15,11 },
{ 4, 3,12, 9 },
{ 3,11,13,12 },
{11,15,16,13 } };
const ordinal_type numCells = 9, numVerts = 4, numEdges = 4;
// view to import refMesh from host
Kokkos::DynRankView<ordinal_type,Kokkos::LayoutRight,HostSpaceType>
elemNodesHost(&refMesh[0][0], numCells, numVerts);
auto elemNodes = Kokkos::create_mirror_view(typename DeviceSpaceType::memory_space(), elemNodesHost);
Kokkos::deep_copy(elemNodes, elemNodesHost);
// compute orientations for cells (one time computation)
Kokkos::DynRankView<Orientation,DeviceSpaceType> elemOrts("elemOrts", numCells);
ots::getOrientation(elemOrts, elemNodes, cellTopo);
auto elemOrtsHost = Kokkos::create_mirror_view(typename HostSpaceType::memory_space(), elemOrts);
Kokkos::deep_copy(elemOrtsHost, elemOrts);
// cell specific modified basis
Kokkos::DynRankView<double,DeviceSpaceType> outValues("outValues", numCells, ndofBasis);
Kokkos::DynRankView<double,DeviceSpaceType> refValues("refValues", numCells, ndofBasis);
auto refValuesHost = Kokkos::create_mirror_view(typename HostSpaceType::memory_space(), refValues);
for (auto cell=0;cell<numCells;++cell)
for (auto bf=0;bf<ndofBasis;++bf)
refValuesHost(cell, bf) = bf;
Kokkos::deep_copy(refValues, refValuesHost);
// modify refValues accounting for orientations
ots::modifyBasisByOrientation(outValues,
refValues,
elemOrts,
&cellBasis);
auto outValuesHost = Kokkos::create_mirror_view(typename HostSpaceType::memory_space(), outValues);
Kokkos::deep_copy(outValuesHost, outValues);
for (auto cell=0;cell<numCells;++cell) {
int flag = 0 ;
std::stringstream s1, s2;
ordinal_type orts[numEdges];
elemOrtsHost(cell).getEdgeOrientation(orts, numEdges);
const double ortVal[2] = { 1.0 , - 1.0 };
s1 << " :: edge(0000) = " ;
s2 << " :: edge(" << orts[0] << orts[1] << orts[2] << orts[3] << ") = ";
//.........这里部分代码省略.........
开发者ID:mhoemmen,项目名称:Trilinos,代码行数:101,代码来源:test_05.hpp
示例7: ConstructWithLabel
int HGRAD_TET_C2_FEM_Test01(const bool verbose) {
Teuchos::RCP<std::ostream> outStream;
Teuchos::oblackholestream bhs; // outputs nothing
if (verbose)
outStream = Teuchos::rcp(&std::cout, false);
else
outStream = Teuchos::rcp(&bhs, false);
Teuchos::oblackholestream oldFormatState;
oldFormatState.copyfmt(std::cout);
typedef typename
Kokkos::Impl::is_space<DeviceSpaceType>::host_mirror_space::execution_space HostSpaceType ;
*outStream << "DeviceSpace:: "; DeviceSpaceType::print_configuration(*outStream, false);
*outStream << "HostSpace:: "; HostSpaceType::print_configuration(*outStream, false);
*outStream
<< "\n"
<< "===============================================================================\n"
<< "| |\n"
<< "| Unit Test (Basis_HGRAD_TET_C2_FEM) |\n"
<< "| |\n"
<< "| 1) Conversion of Dof tags into Dof ordinals and back |\n"
<< "| 2) Basis values for VALUE, GRAD, and Dk operators |\n"
<< "| |\n"
<< "| Questions? Contact Pavel Bochev ([email protected]), |\n"
<< "| Denis Ridzal ([email protected]), |\n"
<< "| Kara Peterson ([email protected]). |\n"
<< "| Kyungjoo Kim ([email protected]). |\n"
<< "| |\n"
<< "| Intrepid's website: http://trilinos.sandia.gov/packages/intrepid |\n"
<< "| Trilinos website: http://trilinos.sandia.gov |\n"
<< "| |\n"
<< "===============================================================================\n";
typedef Kokkos::DynRankView<ValueType,DeviceSpaceType> DynRankView;
typedef Kokkos::DynRankView<ValueType,HostSpaceType> DynRankViewHost;
#define ConstructWithLabel(obj, ...) obj(#obj, __VA_ARGS__)
const ValueType tol = tolerence();
int errorFlag = 0;
// for virtual function, value and point types are declared in the class
typedef ValueType outputValueType;
typedef ValueType pointValueType;
Basis_HGRAD_TET_C2_FEM<DeviceSpaceType,outputValueType,pointValueType> tetBasis;
*outStream
<< "\n"
<< "===============================================================================\n"
<< "| TEST 1: Basis creation, exception testing |\n"
<< "===============================================================================\n";
try{
ordinal_type nthrow = 0, ncatch = 0;
#ifdef HAVE_INTREPID2_DEBUG
DynRankView ConstructWithLabel(tetNodes, 10, 3);
const auto numFields = tetBasis.getCardinality();
const auto numPoints = tetNodes.dimension(0);
const auto spaceDim = tetBasis.getBaseCellTopology().getDimension();
DynRankView ConstructWithLabel(vals, numFields, numPoints);
DynRankView ConstructWithLabel(vals_vec, numFields, numPoints, 4);
{
// exception #1: CURL cannot be applied to scalar functions
// resize vals to rank-3 container with dimensions (num. points, num. basis functions, arbitrary)
INTREPID2_TEST_ERROR_EXPECTED( tetBasis.getValues(vals_vec, tetNodes, OPERATOR_CURL) );
}
{
// exception #2: DIV cannot be applied to scalar functions
// resize vals to rank-2 container with dimensions (num. points, num. basis functions)
INTREPID2_TEST_ERROR_EXPECTED( tetBasis.getValues(vals, tetNodes, OPERATOR_DIV) );
}
// Exceptions 3-7: all bf tags/bf Ids below are wrong and should cause getDofOrdinal() and
// getDofTag() to access invalid array elements thereby causing bounds check exception
{
// exception #3
INTREPID2_TEST_ERROR_EXPECTED( tetBasis.getDofOrdinal(3,0,0) );
// exception #4
INTREPID2_TEST_ERROR_EXPECTED( tetBasis.getDofOrdinal(1,1,1) );
// exception #5
INTREPID2_TEST_ERROR_EXPECTED( tetBasis.getDofOrdinal(0,4,0) );
// exception #6
INTREPID2_TEST_ERROR_EXPECTED( tetBasis.getDofTag(10) );
// exception #7
INTREPID2_TEST_ERROR_EXPECTED( tetBasis.getDofTag(-1) );
}
// Exceptions 8-18 test exception handling with incorrectly dimensioned input/output arrays
{
// exception #8: input points array must be of rank-2
DynRankView ConstructWithLabel(badPoints1, 4, 5, 3);
INTREPID2_TEST_ERROR_EXPECTED( tetBasis.getValues(vals, badPoints1, OPERATOR_VALUE) );
}
//.........这里部分代码省略.........
开发者ID:KineticTheory,项目名称:Trilinos,代码行数:101,代码来源:test_01.hpp
示例8: main
int main(int argc, char *argv[]) {
Teuchos::GlobalMPISession mpiSession(&argc, &argv);
Kokkos::initialize();
// This little trick lets us print to std::cout only if
// a (dummy) command-line argument is provided.
int iprint = argc - 1;
Teuchos::RCP<std::ostream> outStream;
Teuchos::oblackholestream bhs; // outputs nothing
if (iprint > 0)
outStream = Teuchos::rcp(&std::cout, false);
else
outStream = Teuchos::rcp(&bhs, false);
// Save the format state of the original std::cout.
Teuchos::oblackholestream oldFormatState;
oldFormatState.copyfmt(std::cout);
*outStream \
<< "===============================================================================\n" \
<< "| |\n" \
<< "| Unit Test (Basis_HGRAD_TET_Cn_FEM) |\n" \
<< "| |\n" \
<< "| 1) Patch test involving mass and stiffness matrices, |\n" \
<< "| for the Neumann problem on a tetrahedral patch |\n" \
<< "| Omega with boundary Gamma. |\n" \
<< "| |\n" \
<< "| - div (grad u) + u = f in Omega, (grad u) . n = g on Gamma |\n" \
<< "| |\n" \
<< "| Questions? Contact Pavel Bochev ([email protected]), |\n" \
<< "| Denis Ridzal ([email protected]), |\n" \
<< "| Kara Peterson ([email protected]). |\n" \
<< "| |\n" \
<< "| Intrepid's website: http://trilinos.sandia.gov/packages/intrepid |\n" \
<< "| Trilinos website: http://trilinos.sandia.gov |\n" \
<< "| |\n" \
<< "===============================================================================\n"\
<< "| TEST 1: Patch test |\n"\
<< "===============================================================================\n";
int errorFlag = 0;
outStream -> precision(16);
try {
int max_order = 5; // max total order of polynomial solution
DefaultCubatureFactory<double> cubFactory; // create factory
shards::CellTopology cell(shards::getCellTopologyData< shards::Tetrahedron<> >()); // create parent cell topology
shards::CellTopology side(shards::getCellTopologyData< shards::Triangle<> >()); // create relevant subcell (side) topology
int cellDim = cell.getDimension();
int sideDim = side.getDimension();
// Define array containing points at which the solution is evaluated, on the reference tet.
int numIntervals = 10;
int numInterpPoints = ((numIntervals + 1)*(numIntervals + 2)*(numIntervals + 3))/6;
FieldContainer<double> interp_points_ref(numInterpPoints, 3);
int counter = 0;
for (int k=0; k<=numIntervals; k++) {
for (int j=0; j<=numIntervals; j++) {
for (int i=0; i<=numIntervals; i++) {
if (i+j+k <= numIntervals) {
interp_points_ref(counter,0) = i*(1.0/numIntervals);
interp_points_ref(counter,1) = j*(1.0/numIntervals);
interp_points_ref(counter,2) = k*(1.0/numIntervals);
counter++;
}
}
}
}
/* Definition of parent cell. */
FieldContainer<double> cell_nodes(1, 4, cellDim);
// funky tet
cell_nodes(0, 0, 0) = -1.0;
cell_nodes(0, 0, 1) = -2.0;
cell_nodes(0, 0, 2) = 0.0;
cell_nodes(0, 1, 0) = 6.0;
cell_nodes(0, 1, 1) = 2.0;
cell_nodes(0, 1, 2) = 0.0;
cell_nodes(0, 2, 0) = -5.0;
cell_nodes(0, 2, 1) = 1.0;
cell_nodes(0, 2, 2) = 0.0;
cell_nodes(0, 3, 0) = -4.0;
cell_nodes(0, 3, 1) = -1.0;
cell_nodes(0, 3, 2) = 3.0;
// perturbed reference tet
/*cell_nodes(0, 0, 0) = 0.1;
cell_nodes(0, 0, 1) = -0.1;
cell_nodes(0, 0, 2) = 0.2;
cell_nodes(0, 1, 0) = 1.2;
cell_nodes(0, 1, 1) = -0.1;
cell_nodes(0, 1, 2) = 0.05;
cell_nodes(0, 2, 0) = 0.0;
cell_nodes(0, 2, 1) = 0.9;
cell_nodes(0, 2, 2) = 0.1;
cell_nodes(0, 3, 0) = 0.1;
cell_nodes(0, 3, 1) = -0.1;
//.........这里部分代码省略.........
开发者ID:crtrott,项目名称:Trilinos,代码行数:101,代码来源:test_02.cpp
示例9: main
int main(int argc, char *argv[]) {
Teuchos::GlobalMPISession mpiSession(&argc, &argv);
// This little trick lets us print to std::cout only if
// a (dummy) command-line argument is provided.
int iprint = argc - 1;
Teuchos::RCP<std::ostream> outStream;
Teuchos::oblackholestream bhs; // outputs nothing
if (iprint > 0)
outStream = Teuchos::rcp(&std::cout, false);
else
outStream = Teuchos::rcp(&bhs, false);
// Save the format state of the original std::cout.
Teuchos::oblackholestream oldFormatState;
oldFormatState.copyfmt(std::cout);
*outStream \
<< "===============================================================================\n" \
<< "| |\n" \
<< "| Unit Test (Basis_HGRAD_WEDGE_C2_FEM) |\n" \
<< "| |\n" \
<< "| 1) Conversion of Dof tags into Dof ordinals and back |\n" \
<< "| 2) Basis values for VALUE, GRAD, and Dk operators |\n" \
<< "| |\n" \
<< "| Questions? Contact Pavel Bochev ([email protected]), |\n" \
<< "| Denis Ridzal ([email protected]), |\n" \
<< "| Kara Peterson ([email protected]). |\n" \
<< "| |\n" \
<< "| Intrepid's website: http://trilinos.sandia.gov/packages/intrepid |\n" \
<< "| Trilinos website: http://trilinos.sandia.gov |\n" \
<< "| |\n" \
<< "===============================================================================\n"\
<< "| TEST 1: Basis creation, exception testing |\n"\
<< "===============================================================================\n";
// Define basis and error flag
Basis_HGRAD_WEDGE_C2_FEM<double, FieldContainer<double> > wedgeBasis;
int errorFlag = 0;
// Initialize throw counter for exception testing
int nException = 0;
int throwCounter = 0;
// Nodes of Wedde<18>: vertices, edge midpoints, Quadrilateral face centers
FieldContainer<double> wedgeNodes(18, 3);
wedgeNodes(0,0) = 0.0; wedgeNodes(0,1) = 0.0; wedgeNodes(0,2) = -1.0;
wedgeNodes(1,0) = 1.0; wedgeNodes(1,1) = 0.0; wedgeNodes(1,2) = -1.0;
wedgeNodes(2,0) = 0.0; wedgeNodes(2,1) = 1.0; wedgeNodes(2,2) = -1.0;
wedgeNodes(3,0) = 0.0; wedgeNodes(3,1) = 0.0; wedgeNodes(3,2) = 1.0;
wedgeNodes(4,0) = 1.0; wedgeNodes(4,1) = 0.0; wedgeNodes(4,2) = 1.0;
wedgeNodes(5,0) = 0.0; wedgeNodes(5,1) = 1.0; wedgeNodes(5,2) = 1.0;
wedgeNodes(6,0) = 0.5; wedgeNodes(6,1) = 0.0; wedgeNodes(6,2) = -1.0;
wedgeNodes(7,0) = 0.5; wedgeNodes(7,1) = 0.5; wedgeNodes(7,2) = -1.0;
wedgeNodes(8,0) = 0.0; wedgeNodes(8,1) = 0.5; wedgeNodes(8,2) = -1.0;
wedgeNodes(9,0) = 0.0; wedgeNodes(9,1) = 0.0; wedgeNodes(9,2) = 0.0;
wedgeNodes(10,0)= 1.0; wedgeNodes(10,1)= 0.0; wedgeNodes(10,2)= 0.0;
wedgeNodes(11,0)= 0.0; wedgeNodes(11,1)= 1.0; wedgeNodes(11,2)= 0.0;
wedgeNodes(12,0)= 0.5; wedgeNodes(12,1)= 0.0; wedgeNodes(12,2)= 1.0;
wedgeNodes(13,0)= 0.5; wedgeNodes(13,1)= 0.5; wedgeNodes(13,2)= 1.0;
wedgeNodes(14,0)= 0.0; wedgeNodes(14,1)= 0.5; wedgeNodes(14,2)= 1.0;
wedgeNodes(15,0)= 0.5; wedgeNodes(15,1)= 0.0; wedgeNodes(15,2)= 0.0;
wedgeNodes(16,0)= 0.5; wedgeNodes(16,1)= 0.5; wedgeNodes(16,2)= 0.0;
wedgeNodes(17,0)= 0.0; wedgeNodes(17,1)= 0.5; wedgeNodes(17,2)= 0.0;
// Generic array for the output values; needs to be properly resized depending on the operator type
FieldContainer<double> vals;
try{
// exception #1: CURL cannot be applied to scalar functions
// resize vals to rank-3 container with dimensions (num. points, num. basis functions)
vals.resize(wedgeBasis.getCardinality(), wedgeNodes.dimension(0), 3 );
INTREPID_TEST_COMMAND( wedgeBasis.getValues(vals, wedgeNodes, OPERATOR_DIV), throwCounter, nException );
// exception #2: DIV cannot be applied to scalar functions
// resize vals to rank-2 container with dimensions (num. points, num. basis functions)
vals.resize(wedgeBasis.getCardinality(), wedgeNodes.dimension(0) );
INTREPID_TEST_COMMAND( wedgeBasis.getValues(vals, wedgeNodes, OPERATOR_DIV), throwCounter, nException );
// Exceptions 3-7: all bf tags/bf Ids below are wrong and should cause getDofOrdinal() and
// getDofTag() to access invalid array elements thereby causing bounds check exception
// exception #3
INTREPID_TEST_COMMAND( wedgeBasis.getDofOrdinal(3,0,0), throwCounter, nException );
// exception #4
INTREPID_TEST_COMMAND( wedgeBasis.getDofOrdinal(1,1,1), throwCounter, nException );
// exception #5
INTREPID_TEST_COMMAND( wedgeBasis.getDofOrdinal(0,9,0), throwCounter, nException );
// exception #6
INTREPID_TEST_COMMAND( wedgeBasis.getDofTag(18), throwCounter, nException );
// exception #7
INTREPID_TEST_COMMAND( wedgeBasis.getDofTag(-1), throwCounter, nException );
#ifdef HAVE_INTREPID_DEBUG
// Exceptions 8-18 test exception handling with incorrectly dimensioned input/output arrays
// exception #8: input points array must be of rank-2
FieldContainer<double> badPoints1(4, 5, 3);
//.........这里部分代码省略.........
开发者ID:haripandey,项目名称:trilinos,代码行数:101,代码来源:test_01.cpp
示例10: main
int main(int argc, char *argv[]) {
Teuchos::GlobalMPISession mpiSession(&argc, &argv);
// This little trick lets us print to std::cout only if
// a (dummy) command-line argument is provided.
int iprint = argc - 1;
Teuchos::RCP<std::ostream> outStream;
Teuchos::oblackholestream bhs; // outputs nothing
if (iprint > 0)
outStream = Teuchos::rcp(&std::cout, false);
else
outStream = Teuchos::rcp(&bhs, false);
// Save the format state of the original std::cout.
Teuchos::oblackholestream oldFormatState;
oldFormatState.copyfmt(std::cout);
*outStream \
<< "===============================================================================\n" \
<< "| |\n" \
<< "| Unit Test (Basis_HGRAD_LINE_Cn_FEM_JACOBI) |\n" \
<< "| |\n" \
<< "| 1) Conversion of Dof tags into Dof ordinals and back |\n" \
<< "| 2) Basis values for VALUE, GRAD, CURL, and Dk operators |\n" \
<< "| |\n" \
<< "| Questions? Contact Pavel Bochev ([email protected]), |\n" \
<< "| Denis Ridzal ([email protected]), |\n" \
<< "| Kara Peterson ([email protected]). |\n" \
<< "| |\n" \
<< "| Intrepid's website: http://trilinos.sandia.gov/packages/intrepid |\n" \
<< "| Trilinos website: http://trilinos.sandia.gov |\n" \
<< "| |\n" \
<< "===============================================================================\n"\
<< "| TEST 1: Basis creation, exception testing |\n"\
<< "===============================================================================\n";
// Define basis and error flag
double alpha = 0.0, beta = 0.0;
Basis_HGRAD_LINE_Cn_FEM_JACOBI<double, FieldContainer<double> > lineBasis(5, alpha, beta);
int errorFlag = 0;
// Initialize throw counter for exception testing
int nException = 0;
int throwCounter = 0;
// Define array containing vertices of the reference Line and a few other points
int numIntervals = 100;
FieldContainer<double> lineNodes(numIntervals+1, 1);
for (int i=0; i<numIntervals+1; i++) {
lineNodes(i,0) = -1.0+(2.0*(double)i)/(double)numIntervals;
}
// Generic array for the output values; needs to be properly resized depending on the operator type
FieldContainer<double> vals;
try{
// Exceptions 1-5: all bf tags/bf Ids below are wrong and should cause getDofOrdinal() and
// getDofTag() to access invalid array elements thereby causing bounds check exception
// exception #1
INTREPID_TEST_COMMAND( lineBasis.getDofOrdinal(2,0,0), throwCounter, nException );
// exception #2
INTREPID_TEST_COMMAND( lineBasis.getDofOrdinal(1,1,1), throwCounter, nException );
// exception #3
INTREPID_TEST_COMMAND( lineBasis.getDofOrdinal(1,0,7), throwCounter, nException );
// not an exception
INTREPID_TEST_COMMAND( lineBasis.getDofOrdinal(1,0,5), throwCounter, nException ); --nException;
// exception #4
INTREPID_TEST_COMMAND( lineBasis.getDofTag(6), throwCounter, nException );
// exception #5
INTREPID_TEST_COMMAND( lineBasis.getDofTag(-1), throwCounter, nException );
// not an exception
INTREPID_TEST_COMMAND( lineBasis.getDofTag(5), throwCounter, nException ); --nException;
#ifdef HAVE_INTREPID_DEBUG
// Exceptions 6-16 test exception handling with incorrectly dimensioned input/output arrays
// exception #6: input points array must be of rank-2
FieldContainer<double> badPoints1(4, 5, 3);
INTREPID_TEST_COMMAND( lineBasis.getValues(vals, badPoints1, OPERATOR_VALUE), throwCounter, nException );
// exception #7: dimension 1 in the input point array must equal space dimension of the cell
FieldContainer<double> badPoints2(4, 3);
INTREPID_TEST_COMMAND( lineBasis.getValues(vals, badPoints2, OPERATOR_VALUE), throwCounter, nException );
// exception #8: output values must be of rank-2 for OPERATOR_VALUE
FieldContainer<double> badVals1(4, 3, 1);
INTREPID_TEST_COMMAND( lineBasis.getValues(badVals1, lineNodes, OPERATOR_VALUE), throwCounter, nException );
// exception #9: output values must be of rank-3 for OPERATOR_GRAD
FieldContainer<double> badVals2(4, 3);
INTREPID_TEST_COMMAND( lineBasis.getValues(badVals2, lineNodes, OPERATOR_GRAD), throwCounter, nException );
// exception #10: output values must be of rank-3 for OPERATOR_CURL
INTREPID_TEST_COMMAND( lineBasis.getValues(badVals2, lineNodes, OPERATOR_CURL), throwCounter, nException );
// exception #11: output values must be of rank-2 for OPERATOR_DIV
INTREPID_TEST_COMMAND( lineBasis.getValues(badVals2, lineNodes, OPERATOR_DIV), throwCounter, nException );
// exception #12: output values must be of rank-2 for OPERATOR_D1
INTREPID_TEST_COMMAND( lineBasis.getValues(badVals2, lineNodes, OPERATOR_D1), throwCounter, nException );
//.........这里部分代码省略.........
开发者ID:rainiscold,项目名称:trilinos,代码行数:101,代码来源:test_01.cpp
示例11: main
int main(int argc, char *argv[]) {
Teuchos::GlobalMPISession mpiSession(&argc, &argv);
Kokkos::initialize();
typedef CellTools<double> CellTools;
typedef shards::CellTopology CellTopology;
// This little trick lets us print to std::cout only if a (dummy) command-line argument is provided.
int iprint = argc - 1;
Teuchos::RCP<std::ostream> outStream;
Teuchos::oblackholestream bhs; // outputs nothing
if (iprint > 0)
outStream = Teuchos::rcp(&std::cout, false);
else
outStream = Teuchos::rcp(&bhs, false);
// Save the format state of the original std::cout.
Teuchos::oblackholestream oldFormatState;
oldFormatState.copyfmt(std::cout);
*outStream \
<< "===============================================================================\n" \
<< "| |\n" \
<< "| Unit Test CellTools |\n" \
<< "| |\n" \
<< "| 1) Edge parametrizations |\n" \
<< "| 2) Face parametrizations |\n" \
<< "| 3) Edge tangents |\n" \
<< "| 4) Face tangents and normals |\n" \
<< "| |\n" \
<< "| Questions? Contact Pavel Bochev ([email protected]) |\n" \
<< "| Denis Ridzal ([email protected]), or |\n" \
<< "| Kara Peterson ([email protected]) |\n" \
<< "| |\n" \
<< "| Intrepid's website: http://trilinos.sandia.gov/packages/intrepid |\n" \
<< "| Trilinos website: http://trilinos.sandia.gov |\n" \
<< "| |\n" \
<< "===============================================================================\n";
int errorFlag = 0;
// Vertices of the parametrization domain for 1-subcells: standard 1-cube [-1,1]
FieldContainer<double> cube_1(2, 1);
cube_1(0,0) = -1.0;
cube_1(1,0) = 1.0;
// Vertices of the parametrization domain for triangular faces: the standard 2-simplex
FieldContainer<double> simplex_2(3, 2);
simplex_2(0, 0) = 0.0; simplex_2(0, 1) = 0.0;
simplex_2(1, 0) = 1.0; simplex_2(1, 1) = 0.0;
simplex_2(2, 0) = 0.0; simplex_2(2, 1) = 1.0;
// Vertices of the parametrization domain for quadrilateral faces: the standard 2-cube
FieldContainer<double> cube_2(4, 2);
cube_2(0, 0) = -1.0; cube_2(0, 1) = -1.0;
cube_2(1, 0) = 1.0; cube_2(1, 1) = -1.0;
cube_2(2, 0) = 1.0; cube_2(2, 1) = 1.0;
cube_2(3, 0) = -1.0; cube_2(3, 1) = 1.0;
// Pull all available topologies from Shards
std::vector<shards::CellTopology> allTopologies;
shards::getTopologies(allTopologies);
// Set to 1 for edge and 2 for face tests
int subcDim;
try{
*outStream \
<< "\n"
<< "===============================================================================\n"\
<< "| Test 1: edge parametrizations:
|
请发表评论