54 #include "Shards_Array.hpp"
59 #include "Teuchos_oblackholestream.hpp"
60 #include "Teuchos_RCP.hpp"
61 #include "Teuchos_GlobalMPISession.hpp"
64 using namespace Intrepid;
66 SHARDS_ARRAY_DIM_TAG_SIMPLE_DECLARATION( Cell )
67 SHARDS_ARRAY_DIM_TAG_SIMPLE_IMPLEMENTATION( Cell )
69 SHARDS_ARRAY_DIM_TAG_SIMPLE_DECLARATION( Field )
70 SHARDS_ARRAY_DIM_TAG_SIMPLE_IMPLEMENTATION( Field )
72 SHARDS_ARRAY_DIM_TAG_SIMPLE_DECLARATION( Point )
73 SHARDS_ARRAY_DIM_TAG_SIMPLE_IMPLEMENTATION( Point )
75 SHARDS_ARRAY_DIM_TAG_SIMPLE_DECLARATION( Dim )
76 SHARDS_ARRAY_DIM_TAG_SIMPLE_IMPLEMENTATION( Dim )
78 SHARDS_ARRAY_DIM_TAG_SIMPLE_DECLARATION( Node )
79 SHARDS_ARRAY_DIM_TAG_SIMPLE_IMPLEMENTATION( Node )
85 int main(
int argc,
char *argv[]) {
87 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
91 int iprint = argc - 1;
92 Teuchos::RCP<std::ostream> outStream;
93 Teuchos::oblackholestream bhs;
95 outStream = Teuchos::rcp(&std::cout,
false);
97 outStream = Teuchos::rcp(&bhs,
false);
100 Teuchos::oblackholestream oldFormatState;
101 oldFormatState.copyfmt(std::cout);
104 <<
"===============================================================================\n" \
106 <<
"| Unit Test (FunctionSpaceTools) |\n" \
108 <<
"| 1) basic operator transformations and integration in HDIV |\n" \
109 <<
"| via shards::Array wrappers |\n" \
111 <<
"| Questions? Contact Pavel Bochev (pbboche@sandia.gov) or |\n" \
112 <<
"| Denis Ridzal (dridzal@sandia.gov). |\n" \
114 <<
"| Intrepid's website: http://trilinos.sandia.gov/packages/intrepid |\n" \
115 <<
"| Trilinos website: http://trilinos.sandia.gov |\n" \
117 <<
"===============================================================================\n";
126 <<
"===============================================================================\n"\
127 <<
"| TEST 1: correctness of math operations |\n"\
128 <<
"===============================================================================\n";
130 outStream->precision(20);
133 shards::CellTopology cellType = shards::getCellTopologyData< shards::Hexahedron<> >();
138 Teuchos::RCP<Cubature<double> > myCub = cubFactory.
create(cellType, cubDegree);
139 int spaceDim = myCub->getDimension();
140 int numCubPoints = myCub->getNumPoints();
149 int numCellData = numCells*numNodes*spaceDim;
150 int numSignData = numCells*numFields;
152 double hexnodes[] = {
191 short facesigns[] = {
200 Teuchos::Array<double> work_space(numCubPoints*spaceDim +
202 numCells*numNodes*spaceDim +
203 numCells*numCubPoints*spaceDim*spaceDim +
204 2*numCells*numCubPoints +
205 numFields*numCubPoints +
206 2*numCells*numFields*numCubPoints +
207 numCells*numFields*numFields +
208 numFields*numCubPoints*spaceDim +
209 2*numCells*numFields*numCubPoints*spaceDim +
210 numCells*numFields*numFields
214 shards::Array<double,shards::NaturalOrder,Point,Dim> cub_points(&work_space[offset], numCubPoints, spaceDim);
215 FC cub_points_FC(cub_points);
216 offset += numCubPoints*spaceDim;
217 shards::Array<double,shards::NaturalOrder,Point> cub_weights(&work_space[offset], numCubPoints);
218 FC cub_weights_FC(cub_weights);
219 offset += numCubPoints;
220 shards::Array<double,shards::NaturalOrder,Cell,Node,Dim> cell_nodes(&work_space[offset], numCells, numNodes, spaceDim);
221 FC cell_nodes_FC(cell_nodes);
222 offset += numCells*numNodes*spaceDim;
224 shards::Array<double,shards::NaturalOrder,Cell,Point,Dim,Dim> jacobian(&work_space[offset], numCells, numCubPoints, spaceDim, spaceDim);
225 FC jacobian_FC(jacobian);
226 offset += numCells*numCubPoints*spaceDim*spaceDim;
228 shards::Array<double,shards::NaturalOrder,Cell,Point> jacobian_det(&work_space[offset], numCells, numCubPoints);
229 FC jacobian_det_FC(jacobian_det);
230 offset += numCells*numCubPoints;
231 shards::Array<double,shards::NaturalOrder,Cell,Point> weighted_measure(&work_space[offset], numCells, numCubPoints);
232 FC weighted_measure_FC(weighted_measure);
233 offset += numCells*numCubPoints;
235 shards::Array<double,shards::NaturalOrder,Field,Point> div_of_basis_at_cub_points(&work_space[offset], numFields, numCubPoints);
236 FC div_of_basis_at_cub_points_FC(div_of_basis_at_cub_points);
237 offset += numFields*numCubPoints;
238 shards::Array<double,shards::NaturalOrder,Cell,Field,Point>
239 transformed_div_of_basis_at_cub_points(&work_space[offset], numCells, numFields, numCubPoints);
240 FC transformed_div_of_basis_at_cub_points_FC(transformed_div_of_basis_at_cub_points);
241 offset += numCells*numFields*numCubPoints;
242 shards::Array<double,shards::NaturalOrder,Cell,Field,Point>
243 weighted_transformed_div_of_basis_at_cub_points(&work_space[offset], numCells, numFields, numCubPoints);
244 FC weighted_transformed_div_of_basis_at_cub_points_FC(weighted_transformed_div_of_basis_at_cub_points);
245 offset += numCells*numFields*numCubPoints;
246 shards::Array<double,shards::NaturalOrder,Cell,Field,Field> stiffness_matrices(&work_space[offset], numCells, numFields, numFields);
247 FC stiffness_matrices_FC(stiffness_matrices);
248 offset += numCells*numFields*numFields;
250 shards::Array<double,shards::NaturalOrder,Field,Point,Dim> value_of_basis_at_cub_points(&work_space[offset], numFields, numCubPoints, spaceDim);
251 FC value_of_basis_at_cub_points_FC(value_of_basis_at_cub_points);
252 offset += numFields*numCubPoints*spaceDim;
253 shards::Array<double,shards::NaturalOrder,Cell,Field,Point,Dim>
254 transformed_value_of_basis_at_cub_points(&work_space[offset], numCells, numFields, numCubPoints, spaceDim);
255 FC transformed_value_of_basis_at_cub_points_FC(transformed_value_of_basis_at_cub_points);
256 offset += numCells*numFields*numCubPoints*spaceDim;
257 shards::Array<double,shards::NaturalOrder,Cell,Field,Point,Dim>
258 weighted_transformed_value_of_basis_at_cub_points(&work_space[offset], numCells, numFields, numCubPoints, spaceDim);
259 FC weighted_transformed_value_of_basis_at_cub_points_FC(weighted_transformed_value_of_basis_at_cub_points);
260 offset += numCells*numFields*numCubPoints*spaceDim;
261 shards::Array<double,shards::NaturalOrder,Cell,Field,Field> mass_matrices(&work_space[offset], numCells, numFields, numFields);
262 FC mass_matrices_FC(mass_matrices);
268 myCub->getCubature(cub_points_FC, cub_weights_FC);
271 cell_nodes_FC.setValues(hexnodes, numCellData);
274 field_signs.setValues(facesigns, numSignData);
282 fst::computeCellMeasure<double>(weighted_measure_FC, jacobian_det_FC, cub_weights_FC);
287 hexBasis.
getValues(div_of_basis_at_cub_points_FC, cub_points_FC, OPERATOR_DIV);
290 fst::HDIVtransformDIV<double>(transformed_div_of_basis_at_cub_points_FC,
292 div_of_basis_at_cub_points_FC);
295 fst::multiplyMeasure<double>(weighted_transformed_div_of_basis_at_cub_points_FC,
297 transformed_div_of_basis_at_cub_points_FC);
300 fst::integrate<double>(stiffness_matrices_FC,
301 transformed_div_of_basis_at_cub_points_FC,
302 weighted_transformed_div_of_basis_at_cub_points_FC,
306 fst::applyLeftFieldSigns<double>(stiffness_matrices_FC, field_signs);
307 fst::applyRightFieldSigns<double>(stiffness_matrices_FC, field_signs);
312 hexBasis.
getValues(value_of_basis_at_cub_points_FC, cub_points_FC, OPERATOR_VALUE);
315 fst::HDIVtransformVALUE<double>(transformed_value_of_basis_at_cub_points_FC,
318 value_of_basis_at_cub_points_FC);
321 fst::multiplyMeasure<double>(weighted_transformed_value_of_basis_at_cub_points_FC,
323 transformed_value_of_basis_at_cub_points_FC);
326 fst::integrate<double>(mass_matrices_FC,
327 transformed_value_of_basis_at_cub_points_FC,
328 weighted_transformed_value_of_basis_at_cub_points_FC,
332 fst::applyLeftFieldSigns<double>(mass_matrices_FC, field_signs);
333 fst::applyRightFieldSigns<double>(mass_matrices_FC, field_signs);
339 string basedir =
"./testdata";
340 for (
int cell_id = 0; cell_id < numCells-1; cell_id++) {
342 stringstream namestream;
344 namestream << basedir <<
"/mass_HDIV_HEX_I1_FEM" <<
"_" <<
"0" << cell_id+1 <<
".dat";
345 namestream >> filename;
347 ifstream massfile(&filename[0]);
348 if (massfile.is_open()) {
349 if (compareToAnalytic<double>(&mass_matrices(cell_id, 0, 0), massfile, 1e-10, iprint) > 0)
355 std::cout <<
"End Result: TEST FAILED\n";
360 namestream << basedir <<
"/stiff_HDIV_HEX_I1_FEM" <<
"_" <<
"0" << cell_id+1 <<
".dat";
361 namestream >> filename;
363 ifstream stifffile(&filename[0]);
364 if (stifffile.is_open())
366 if (compareToAnalytic<double>(&stiffness_matrices(cell_id, 0, 0), stifffile, 1e-10, iprint) > 0)
372 std::cout <<
"End Result: TEST FAILED\n";
377 for (
int cell_id = 3; cell_id < numCells; cell_id++) {
379 stringstream namestream;
381 namestream << basedir <<
"/mass_fp_HDIV_HEX_I1_FEM" <<
"_" <<
"0" << cell_id+1 <<
".dat";
382 namestream >> filename;
384 ifstream massfile(&filename[0]);
385 if (massfile.is_open()) {
386 if (compareToAnalytic<double>(&mass_matrices(cell_id, 0, 0), massfile, 1e-4, iprint, INTREPID_UTILS_SCALAR) > 0)
392 std::cout <<
"End Result: TEST FAILED\n";
397 namestream << basedir <<
"/stiff_fp_HDIV_HEX_I1_FEM" <<
"_" <<
"0" << cell_id+1 <<
".dat";
398 namestream >> filename;
400 ifstream stifffile(&filename[0]);
401 if (stifffile.is_open())
403 if (compareToAnalytic<double>(&stiffness_matrices(cell_id, 0, 0), stifffile, 1e-4, iprint, INTREPID_UTILS_SCALAR) > 0)
409 std::cout <<
"End Result: TEST FAILED\n";
418 catch (
const std::logic_error & err) {
419 *outStream <<
"UNEXPECTED ERROR !!! ----------------------------------------------------------\n";
420 *outStream << err.what() <<
'\n';
421 *outStream <<
"-------------------------------------------------------------------------------" <<
"\n\n";
427 std::cout <<
"End Result: TEST FAILED\n";
429 std::cout <<
"End Result: TEST PASSED\n";
432 std::cout.copyfmt(oldFormatState);
void getValues(ArrayScalar &outputValues, const ArrayScalar &inputPoints, const EOperator operatorType) const
Evaluation of a FEM basis on a reference Hexahedron cell.
virtual int getCardinality() const
Returns cardinality of the basis.
Header file for utility class to provide multidimensional containers.
Header file for the Intrepid::HDIV_HEX_I1_FEM class.
Header file for the abstract base class Intrepid::DefaultCubatureFactory.
Implementation of the default H(div)-compatible FEM basis of degree 1 on Hexahedron cell...
Implementation of a templated lexicographical container for a multi-indexed scalar quantity...
A factory class that generates specific instances of cubatures.
Teuchos::RCP< Cubature< Scalar, ArrayPoint, ArrayWeight > > create(const shards::CellTopology &cellTopology, const std::vector< int > °ree)
Factory method.