Skip to content

Commit

Permalink
Merge Pull Request trilinos#6323 from CamelliaDPG/Trilinos/resolve-6317
Browse files Browse the repository at this point in the history
Automatically Merged using Trilinos Pull Request AutoTester
PR Title: Intrepid2: tweaks to OrientationTools::modifyBasisByOrientation() to allow reference-space inputs.
PR Author: CamelliaDPG
  • Loading branch information
trilinos-autotester authored Nov 21, 2019
2 parents c5c6883 + 9adcdad commit 98104b0
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ namespace Intrepid2 {
typedef typename inputViewType::non_const_value_type input_value_type;

auto out = Kokkos::subview(output, cell, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
auto in = Kokkos::subview(input, cell, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
auto in = (input.rank() == output.rank()) ?
Kokkos::subview(input, cell, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL())
: Kokkos::subview(input, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());

// vertex copy (no orientation)
for (ordinal_type vertId=0;vertId<numVerts;++vertId) {
Expand Down Expand Up @@ -276,13 +278,25 @@ namespace Intrepid2 {
const BasisPtrType basis ) {
#ifdef HAVE_INTREPID2_DEBUG
{
INTREPID2_TEST_FOR_EXCEPTION( input.rank() != output.rank(), std::invalid_argument,
">>> ERROR (OrientationTools::modifyBasisByOrientation): Input and output rank are not 3.");
for (size_type i=0;i<input.rank();++i)
INTREPID2_TEST_FOR_EXCEPTION( input.extent(i) != output.extent(i), std::invalid_argument,
">>> ERROR (OrientationTools::modifyBasisByOrientation): Input and output dimension does not match.");
if (input.rank() == output.rank())
{
for (size_type i=0;i<input.rank();++i)
INTREPID2_TEST_FOR_EXCEPTION( input.extent(i) != output.extent(i), std::invalid_argument,
">>> ERROR (OrientationTools::modifyBasisByOrientation): Input and output dimension does not match.");
}
else if (input.rank() == output.rank() - 1)
{
for (size_type i=0;i<input.rank();++i)
INTREPID2_TEST_FOR_EXCEPTION( input.extent(i) != output.extent(i+1), std::invalid_argument,
">>> ERROR (OrientationTools::modifyBasisByOrientation): Input dimensions must match output dimensions exactly, or else match all but the first dimension (in the case that input does not have a 'cell' dimension).");
}
else
{
INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument,
">>> ERROR (OrientationTools::modifyBasisByOrientation): input and output ranks must either match, or input rank must be one less than that of output.")
}

INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(input.extent(1)) != basis->getCardinality(), std::invalid_argument,
INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(output.extent(1)) != basis->getCardinality(), std::invalid_argument,
">>> ERROR (OrientationTools::modifyBasisByOrientation): Field dimension of input/output does not match to basis cardinality.");
}
#endif
Expand Down
37 changes: 18 additions & 19 deletions packages/intrepid2/unit-test/Orientation/test_orientation_HEX.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@


/** \file
\brief Test for checking orientation tools for Hexaedral elements
\brief Test for checking orientation tools for Hexahedral elements
The test considers two hexahedra in the physical space sharing a common face.
In order to test significant configurations, we consider 6 mappings of the reference hexahedron
Expand Down Expand Up @@ -456,25 +456,26 @@ int OrientationHex(const bool verbose) {

//Testing Kronecker property of basis functions
{
DynRankView ConstructWithLabel(basisValuesAtDofCoords, numCells, basisCardinality, basisCardinality);
DynRankView ConstructWithLabel(basisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality);
DynRankView ConstructWithLabel(transformedBasisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality);
for(ordinal_type i=0; i<numCells; ++i) {
DynRankView ConstructWithLabel(basisValuesAtDofCoords, numCells, basisCardinality, basisCardinality);
DynRankView ConstructWithLabel(basisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality);
DynRankView ConstructWithLabel(transformedBasisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality);
auto inView = Kokkos::subview( dofCoordsOriented,i,Kokkos::ALL(),Kokkos::ALL());
auto outView =Kokkos::subview( basisValuesAtDofCoords,i,Kokkos::ALL(),Kokkos::ALL());
basis.getValues(outView, inView);
}

// modify basis values to account for orientations
ots::modifyBasisByOrientation(basisValuesAtDofCoordsOriented,
basisValuesAtDofCoords,
elemOrts,
&basis);

// transform basis values
deep_copy(transformedBasisValuesAtDofCoordsOriented,
basisValuesAtDofCoordsOriented);
// modify basis values to account for orientations
ots::modifyBasisByOrientation(basisValuesAtDofCoordsOriented,
basisValuesAtDofCoords,
elemOrts,
&basis);

// transform basis values
deep_copy(transformedBasisValuesAtDofCoordsOriented,
basisValuesAtDofCoordsOriented);

for(ordinal_type i=0; i<numCells; ++i) {
for(ordinal_type k=0; k<basisCardinality; ++k) {
for(ordinal_type j=0; j<basisCardinality; ++j){
ValueType dofValue = transformedBasisValuesAtDofCoordsOriented(i,k,j) * dofCoeffsPhys(i,j);
Expand All @@ -493,7 +494,7 @@ int OrientationHex(const bool verbose) {
}
}

//check function reproducbility
//check function reproducibility
Fun fun;
DynRankView ConstructWithLabel(funDofs, numCells, basisCardinality);
DynRankView ConstructWithLabel(funAtPhysRefCoords, numCells, numRefCoords);
Expand Down Expand Up @@ -555,17 +556,15 @@ int OrientationHex(const bool verbose) {
//check that fun values at reference points coincide with those computed using basis functions
DynRankView ConstructWithLabel(basisValuesAtRefCoordsOriented, numCells, basisCardinality, numRefCoords);
DynRankView ConstructWithLabel(transformedBasisValuesAtRefCoordsOriented, numCells, basisCardinality, numRefCoords);
DynRankView basisValuesAtRefCoordsCells("inValues", numCells, basisCardinality, numRefCoords);

DynRankView ConstructWithLabel(basisValuesAtRefCoords, basisCardinality, numRefCoords);
basis.getValues(basisValuesAtRefCoords, refPoints);
rst::clone(basisValuesAtRefCoordsCells,basisValuesAtRefCoords);

// modify basis values to account for orientations
ots::modifyBasisByOrientation(basisValuesAtRefCoordsOriented,
basisValuesAtRefCoordsCells,
elemOrts,
&basis);
basisValuesAtRefCoords,
elemOrts,
&basis);

// transform basis values
deep_copy(transformedBasisValuesAtRefCoordsOriented,
Expand Down
34 changes: 17 additions & 17 deletions packages/intrepid2/unit-test/Orientation/test_orientation_QUAD.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,25 +362,27 @@ int OrientationQuad(const bool verbose) {

//Testing Kronecker property of basis functions
{
DynRankView ConstructWithLabel(basisValuesAtDofCoords, numCells, basisCardinality, basisCardinality);
DynRankView ConstructWithLabel(basisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality);
DynRankView ConstructWithLabel(transformedBasisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality);

for(ordinal_type i=0; i<numCells; ++i) {
DynRankView ConstructWithLabel(basisValuesAtDofCoords, numCells, basisCardinality, basisCardinality);
DynRankView ConstructWithLabel(basisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality);
DynRankView ConstructWithLabel(transformedBasisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality);
auto inView = Kokkos::subview( dofCoordsOriented,i,Kokkos::ALL(),Kokkos::ALL());
auto outView =Kokkos::subview( basisValuesAtDofCoords,i,Kokkos::ALL(),Kokkos::ALL());
basis.getValues(outView, inView);
}

// modify basis values to account for orientations
ots::modifyBasisByOrientation(basisValuesAtDofCoordsOriented,
basisValuesAtDofCoords,
elemOrts,
&basis);

// transform basis values
deep_copy(transformedBasisValuesAtDofCoordsOriented,
basisValuesAtDofCoordsOriented);
// modify basis values to account for orientations
ots::modifyBasisByOrientation(basisValuesAtDofCoordsOriented,
basisValuesAtDofCoords,
elemOrts,
&basis);

// transform basis values
deep_copy(transformedBasisValuesAtDofCoordsOriented,
basisValuesAtDofCoordsOriented);

for(ordinal_type i=0; i<numCells; ++i) {
for(ordinal_type k=0; k<basisCardinality; ++k) {
for(ordinal_type j=0; j<basisCardinality; ++j){
ValueType dofValue = transformedBasisValuesAtDofCoordsOriented(i,k,j) * dofCoeffsPhys(i,j);
Expand Down Expand Up @@ -437,17 +439,15 @@ int OrientationQuad(const bool verbose) {
//check that fun values at reference points coincide with those computed using basis functions
DynRankView ConstructWithLabel(basisValuesAtRefCoordsOriented, numCells, basisCardinality, numRefCoords);
DynRankView ConstructWithLabel(transformedBasisValuesAtRefCoordsOriented, numCells, basisCardinality, numRefCoords);
DynRankView basisValuesAtRefCoordsCells("inValues", numCells, basisCardinality, numRefCoords);

DynRankView ConstructWithLabel(basisValuesAtRefCoords, basisCardinality, numRefCoords);
basis.getValues(basisValuesAtRefCoords, refPoints);
rst::clone(basisValuesAtRefCoordsCells,basisValuesAtRefCoords);

// modify basis values to account for orientations
ots::modifyBasisByOrientation(basisValuesAtRefCoordsOriented,
basisValuesAtRefCoordsCells,
elemOrts,
&basis);
basisValuesAtRefCoords,
elemOrts,
&basis);

// transform basis values
deep_copy(transformedBasisValuesAtRefCoordsOriented,
Expand Down
34 changes: 17 additions & 17 deletions packages/intrepid2/unit-test/Orientation/test_orientation_TET.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,25 +423,27 @@ int OrientationTet(const bool verbose) {

//Testing Kronecker property of basis functions
{
DynRankView ConstructWithLabel(basisValuesAtDofCoords, numCells, basisCardinality, basisCardinality);
DynRankView ConstructWithLabel(basisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality);
DynRankView ConstructWithLabel(transformedBasisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality);

for(ordinal_type i=0; i<numCells; ++i) {
DynRankView ConstructWithLabel(basisValuesAtDofCoords, numCells, basisCardinality, basisCardinality);
DynRankView ConstructWithLabel(basisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality);
DynRankView ConstructWithLabel(transformedBasisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality);
auto inView = Kokkos::subview( dofCoordsOriented,i,Kokkos::ALL(),Kokkos::ALL());
auto outView =Kokkos::subview( basisValuesAtDofCoords,i,Kokkos::ALL(),Kokkos::ALL());
basis.getValues(outView, inView);
}

// modify basis values to account for orientations
ots::modifyBasisByOrientation(basisValuesAtDofCoordsOriented,
basisValuesAtDofCoords,
elemOrts,
&basis);

// transform basis values
deep_copy(transformedBasisValuesAtDofCoordsOriented,
basisValuesAtDofCoordsOriented);
// modify basis values to account for orientations
ots::modifyBasisByOrientation(basisValuesAtDofCoordsOriented,
basisValuesAtDofCoords,
elemOrts,
&basis);

// transform basis values
deep_copy(transformedBasisValuesAtDofCoordsOriented,
basisValuesAtDofCoordsOriented);

for(ordinal_type i=0; i<numCells; ++i) {
for(ordinal_type k=0; k<basisCardinality; ++k) {
for(ordinal_type j=0; j<basisCardinality; ++j){
ValueType dofValue = transformedBasisValuesAtDofCoordsOriented(i,k,j) * dofCoeffsPhys(i,j);
Expand Down Expand Up @@ -522,17 +524,15 @@ int OrientationTet(const bool verbose) {
//check that fun values at reference points coincide with those computed using basis functions
DynRankView ConstructWithLabel(basisValuesAtRefCoordsOriented, numCells, basisCardinality, numRefCoords);
DynRankView ConstructWithLabel(transformedBasisValuesAtRefCoordsOriented, numCells, basisCardinality, numRefCoords);
DynRankView basisValuesAtRefCoordsCells("inValues", numCells, basisCardinality, numRefCoords);

DynRankView ConstructWithLabel(basisValuesAtRefCoords, basisCardinality, numRefCoords);
basis.getValues(basisValuesAtRefCoords, refPoints);
rst::clone(basisValuesAtRefCoordsCells,basisValuesAtRefCoords);

// modify basis values to account for orientations
ots::modifyBasisByOrientation(basisValuesAtRefCoordsOriented,
basisValuesAtRefCoordsCells,
elemOrts,
&basis);
basisValuesAtRefCoords,
elemOrts,
&basis);

// transform basis values
deep_copy(transformedBasisValuesAtRefCoordsOriented,
Expand Down
36 changes: 18 additions & 18 deletions packages/intrepid2/unit-test/Orientation/test_orientation_TRI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,25 +362,27 @@ int OrientationTri(const bool verbose) {

//Testing Kronecker property of basis functions
{
DynRankView ConstructWithLabel(basisValuesAtDofCoords, numCells, basisCardinality, basisCardinality);
DynRankView ConstructWithLabel(basisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality);
DynRankView ConstructWithLabel(transformedBasisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality);

for(ordinal_type i=0; i<numCells; ++i) {
DynRankView ConstructWithLabel(basisValuesAtDofCoords, numCells, basisCardinality, basisCardinality);
DynRankView ConstructWithLabel(basisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality);
DynRankView ConstructWithLabel(transformedBasisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality);
auto inView = Kokkos::subview( dofCoordsOriented,i,Kokkos::ALL(),Kokkos::ALL());
auto outView =Kokkos::subview( basisValuesAtDofCoords,i,Kokkos::ALL(),Kokkos::ALL());
basis.getValues(outView, inView);
}

// modify basis values to account for orientations
ots::modifyBasisByOrientation(basisValuesAtDofCoordsOriented,
basisValuesAtDofCoords,
elemOrts,
&basis);

// transform basis values
deep_copy(transformedBasisValuesAtDofCoordsOriented,
basisValuesAtDofCoordsOriented);
// modify basis values to account for orientations
ots::modifyBasisByOrientation(basisValuesAtDofCoordsOriented,
basisValuesAtDofCoords,
elemOrts,
&basis);

// transform basis values
deep_copy(transformedBasisValuesAtDofCoordsOriented,
basisValuesAtDofCoordsOriented);

for(ordinal_type i=0; i<numCells; ++i) {
for(ordinal_type k=0; k<basisCardinality; ++k) {
for(ordinal_type j=0; j<basisCardinality; ++j){
ValueType dofValue = transformedBasisValuesAtDofCoordsOriented(i,k,j) * dofCoeffsPhys(i,j);
Expand Down Expand Up @@ -437,21 +439,19 @@ int OrientationTri(const bool verbose) {
//check that fun values at reference points coincide with those computed using basis functions
DynRankView ConstructWithLabel(basisValuesAtRefCoordsOriented, numCells, basisCardinality, numRefCoords);
DynRankView ConstructWithLabel(transformedBasisValuesAtRefCoordsOriented, numCells, basisCardinality, numRefCoords);
DynRankView basisValuesAtRefCoordsCells("inValues", numCells, basisCardinality, numRefCoords);

DynRankView ConstructWithLabel(basisValuesAtRefCoords, basisCardinality, numRefCoords);
basis.getValues(basisValuesAtRefCoords, refPoints);
rst::clone(basisValuesAtRefCoordsCells,basisValuesAtRefCoords);

// modify basis values to account for orientations
ots::modifyBasisByOrientation(basisValuesAtRefCoordsOriented,
basisValuesAtRefCoordsCells,
elemOrts,
&basis);
basisValuesAtRefCoords,
elemOrts,
&basis);

// transform basis values
deep_copy(transformedBasisValuesAtRefCoordsOriented,
basisValuesAtRefCoordsOriented);
basisValuesAtRefCoordsOriented);

DynRankView ConstructWithLabel(funAtRefCoordsOriented, numCells, numRefCoords);
for(ordinal_type i=0; i<numCells; ++i) {
Expand Down

0 comments on commit 98104b0

Please sign in to comment.