56 #include "Teuchos_oblackholestream.hpp" 57 #include "Teuchos_RCP.hpp" 58 #include "Teuchos_GlobalMPISession.hpp" 59 #include "Teuchos_SerialDenseMatrix.hpp" 60 #include "Teuchos_SerialDenseVector.hpp" 61 #include "Teuchos_LAPACK.hpp" 70 const shards::CellTopology & ,
84 for (
int cell=0; cell<result.
dimension(0); cell++) {
85 for (
int pt=0; pt<result.
dimension(1); pt++) {
86 result(cell,pt) = - xd*(xd-1)*std::pow(points(cell,pt,x), xd-2) * std::pow(points(cell,pt,y), yd);
93 for (
int cell=0; cell<result.
dimension(0); cell++) {
94 for (
int pt=0; pt<result.
dimension(1); pt++) {
95 result(cell,pt) -= yd*(yd-1)*std::pow(points(cell,pt,y), yd-2) * std::pow(points(cell,pt,x), xd);
101 for (
int cell=0; cell<result.
dimension(0); cell++) {
102 for (
int pt=0; pt<result.
dimension(1); pt++) {
103 result(cell,pt) += std::pow(points(cell,pt,x), xd) * std::pow(points(cell,pt,y), yd);
114 const shards::CellTopology & parentCell,
115 int sideOrdinal,
int xd,
int yd) {
128 for (
int cell=0; cell<numCells; cell++) {
129 for (
int pt=0; pt<numPoints; pt++) {
130 grad_u(cell,pt,x) = xd*std::pow(points(cell,pt,x), xd-1) * std::pow(points(cell,pt,y), yd);
137 for (
int cell=0; cell<numCells; cell++) {
138 for (
int pt=0; pt<numPoints; pt++) {
139 grad_u(cell,pt,y) = yd*std::pow(points(cell,pt,y), yd-1) * std::pow(points(cell,pt,x), xd);
148 FunctionSpaceTools::scalarMultiplyDataData<double>(side_normals, normal_lengths, side_normals,
true);
150 FunctionSpaceTools::dotMultiplyDataData<double>(result, grad_u, side_normals);
157 for (
int cell=0; cell<result.
dimension(0); cell++) {
158 for (
int pt=0; pt<result.
dimension(1); pt++) {
159 result(cell,pt) = std::pow(points(pt,x), xd)*std::pow(points(pt,y), yd);
167 int main(
int argc,
char *argv[]) {
169 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
173 int iprint = argc - 1;
174 Teuchos::RCP<std::ostream> outStream;
175 Teuchos::oblackholestream bhs;
177 outStream = Teuchos::rcp(&std::cout,
false);
179 outStream = Teuchos::rcp(&bhs,
false);
182 Teuchos::oblackholestream oldFormatState;
183 oldFormatState.copyfmt(std::cout);
186 <<
"===============================================================================\n" \
188 <<
"| Unit Test (Basis_HGRAD_TRI_Cn_FEM) |\n" \
190 <<
"| 1) Patch test involving mass and stiffness matrices, |\n" \
191 <<
"| for the Neumann problem on a triangular patch |\n" \
192 <<
"| Omega with boundary Gamma. |\n" \
194 <<
"| - div (grad u) + u = f in Omega, (grad u) . n = g on Gamma |\n" \
196 <<
"| Questions? Contact Pavel Bochev (pbboche@sandia.gov), |\n" \
197 <<
"| Denis Ridzal (dridzal@sandia.gov), |\n" \
198 <<
"| Kara Peterson (kjpeter@sandia.gov). |\n" \
200 <<
"| Intrepid's website: http://trilinos.sandia.gov/packages/intrepid |\n" \
201 <<
"| Trilinos website: http://trilinos.sandia.gov |\n" \
203 <<
"===============================================================================\n"\
204 <<
"| TEST 1: Patch test |\n"\
205 <<
"===============================================================================\n";
210 outStream -> precision(16);
217 shards::CellTopology cell(shards::getCellTopologyData< shards::Triangle<> >());
218 shards::CellTopology side(shards::getCellTopologyData< shards::Line<> >());
219 int cellDim = cell.getDimension();
220 int sideDim = side.getDimension();
223 int numIntervals = 10;
224 int numInterpPoints = ((numIntervals + 1)*(numIntervals + 2))/2;
227 for (
int j=0; j<=numIntervals; j++) {
228 for (
int i=0; i<=numIntervals; i++) {
229 if (i <= numIntervals-j) {
230 interp_points_ref(counter,0) = i*(1.0/numIntervals);
231 interp_points_ref(counter,1) = j*(1.0/numIntervals);
240 cell_nodes(0, 0, 0) = 0.1;
241 cell_nodes(0, 0, 1) = -0.1;
242 cell_nodes(0, 1, 0) = 1.1;
243 cell_nodes(0, 1, 1) = -0.1;
244 cell_nodes(0, 2, 0) = 0.1;
245 cell_nodes(0, 2, 1) = 0.9;
256 interp_points.resize(numInterpPoints, cellDim);
259 EPointType pointtype[] = {POINTTYPE_EQUISPACED, POINTTYPE_WARPBLEND};
260 for (
int ptype=0; ptype < 2; ptype++) {
262 *outStream <<
"\nTesting bases with " << EPointTypeToString(pointtype[ptype]) <<
":\n";
264 for (
int x_order=0; x_order <= max_order; x_order++) {
265 for (
int y_order=0; y_order <= max_order-x_order; y_order++) {
269 u_exact(exact_solution, interp_points, x_order, y_order);
271 int total_order = std::max(x_order + y_order, 1);
273 for (
int basis_order=total_order; basis_order <= max_order; basis_order++) {
276 double zero = basis_order*basis_order*100*INTREPID_TOL;
279 Teuchos::RCP<Basis<double,FieldContainer<double> > > basis =
281 int numFields = basis->getCardinality();
284 Teuchos::RCP<Cubature<double> > cellCub = cubFactory.
create(cell, 2*basis_order);
285 Teuchos::RCP<Cubature<double> > sideCub = cubFactory.
create(side, 2*basis_order);
286 int numCubPointsCell = cellCub->getNumPoints();
287 int numCubPointsSide = sideCub->getNumPoints();
301 FieldContainer<double> weighted_transformed_value_of_basis_at_cub_points_cell(1, numFields, numCubPointsCell);
303 FieldContainer<double> transformed_grad_of_basis_at_cub_points_cell(1, numFields, numCubPointsCell, cellDim);
304 FieldContainer<double> weighted_transformed_grad_of_basis_at_cub_points_cell(1, numFields, numCubPointsCell, cellDim);
311 unsigned numSides = 3;
321 FieldContainer<double> transformed_value_of_basis_at_cub_points_side_refcell(1, numFields, numCubPointsSide);
322 FieldContainer<double> weighted_transformed_value_of_basis_at_cub_points_side_refcell(1, numFields, numCubPointsSide);
338 cellCub->getCubature(cub_points_cell, cub_weights_cell);
346 FunctionSpaceTools::computeCellMeasure<double>(weighted_measure_cell, jacobian_det_cell, cub_weights_cell);
351 basis->getValues(value_of_basis_at_cub_points_cell, cub_points_cell, OPERATOR_VALUE);
354 FunctionSpaceTools::HGRADtransformVALUE<double>(transformed_value_of_basis_at_cub_points_cell,
355 value_of_basis_at_cub_points_cell);
358 FunctionSpaceTools::multiplyMeasure<double>(weighted_transformed_value_of_basis_at_cub_points_cell,
359 weighted_measure_cell,
360 transformed_value_of_basis_at_cub_points_cell);
363 FunctionSpaceTools::integrate<double>(fe_matrix,
364 transformed_value_of_basis_at_cub_points_cell,
365 weighted_transformed_value_of_basis_at_cub_points_cell,
372 basis->getValues(grad_of_basis_at_cub_points_cell, cub_points_cell, OPERATOR_GRAD);
375 FunctionSpaceTools::HGRADtransformGRAD<double>(transformed_grad_of_basis_at_cub_points_cell,
377 grad_of_basis_at_cub_points_cell);
380 FunctionSpaceTools::multiplyMeasure<double>(weighted_transformed_grad_of_basis_at_cub_points_cell,
381 weighted_measure_cell,
382 transformed_grad_of_basis_at_cub_points_cell);
385 FunctionSpaceTools::integrate<double>(fe_matrix,
386 transformed_grad_of_basis_at_cub_points_cell,
387 weighted_transformed_grad_of_basis_at_cub_points_cell,
398 rhsFunc(rhs_at_cub_points_cell_physical, cub_points_cell_physical, x_order, y_order);
401 FunctionSpaceTools::integrate<double>(rhs_and_soln_vector,
402 rhs_at_cub_points_cell_physical,
403 weighted_transformed_value_of_basis_at_cub_points_cell,
407 sideCub->getCubature(cub_points_side, cub_weights_side);
408 for (
unsigned i=0; i<numSides; i++) {
415 FunctionSpaceTools::computeEdgeMeasure<double>(weighted_measure_side_refcell,
416 jacobian_side_refcell,
422 basis->getValues(value_of_basis_at_cub_points_side_refcell, cub_points_side_refcell, OPERATOR_VALUE);
424 FunctionSpaceTools::HGRADtransformVALUE<double>(transformed_value_of_basis_at_cub_points_side_refcell,
425 value_of_basis_at_cub_points_side_refcell);
428 FunctionSpaceTools::multiplyMeasure<double>(weighted_transformed_value_of_basis_at_cub_points_side_refcell,
429 weighted_measure_side_refcell,
430 transformed_value_of_basis_at_cub_points_side_refcell);
436 neumann(neumann_data_at_cub_points_side_physical, cub_points_side_physical, jacobian_side_refcell,
437 cell, (
int)i, x_order, y_order);
439 FunctionSpaceTools::integrate<double>(neumann_fields_per_side,
440 neumann_data_at_cub_points_side_physical,
441 weighted_transformed_value_of_basis_at_cub_points_side_refcell,
452 Teuchos::LAPACK<int, double> solver;
453 solver.GESV(numFields, 1, &fe_matrix[0], numFields, &ipiv(0), &rhs_and_soln_vector[0], numFields, &info);
459 basis->getValues(value_of_basis_at_interp_points, interp_points_ref, OPERATOR_VALUE);
461 FunctionSpaceTools::HGRADtransformVALUE<double>(transformed_value_of_basis_at_interp_points,
462 value_of_basis_at_interp_points);
463 FunctionSpaceTools::evaluate<double>(interpolant, rhs_and_soln_vector, transformed_value_of_basis_at_interp_points);
470 *outStream <<
"\nRelative norm-2 error between exact solution polynomial of order (" 471 << x_order <<
", " << y_order <<
") and finite element interpolant of order " << basis_order <<
": " 477 *outStream <<
"\n\nPatch test failed for solution polynomial order (" 478 << x_order <<
", " << y_order <<
") and basis order " << basis_order <<
"\n\n";
488 catch (std::logic_error err) {
489 *outStream << err.what() <<
"\n\n";
494 std::cout <<
"End Result: TEST FAILED\n";
496 std::cout <<
"End Result: TEST PASSED\n";
499 std::cout.copyfmt(oldFormatState);
Header file for the Intrepid::HGRAD_TRI_Cn_FEM class.
int main(int argc, char *argv[])
outdated tests for orthogonal bases
int dimension(const int whichDim) const
Returns the specified dimension.
Header file for utility class to provide multidimensional containers.
Header file for the abstract base class Intrepid::DefaultCubatureFactory.
Implementation of the default H(grad)-compatible Lagrange basis of arbitrary degree on Triangle cell...
A factory class that generates specific instances of cubatures.
EPointType
Enumeration of types of point distributions in Intrepid.
Teuchos::RCP< Cubature< Scalar, ArrayPoint, ArrayWeight > > create(const shards::CellTopology &cellTopology, const std::vector< int > °ree)
Factory method.