Skip to content

Commit

Permalink
Intrepid2: Removing Experimental namespace used for projections (part…
Browse files Browse the repository at this point in the history
…2) (#12229)

* Intrepid2: Remove Experimental namespace

* Intrepid2: Further improvements to Projections method. 
Now we are fully working in the reference element and map back to the oriented frame at the end of the projection. This allows significant savings.
  • Loading branch information
mperego authored Nov 20, 2023
1 parent 849b203 commit 392a536
Show file tree
Hide file tree
Showing 38 changed files with 662 additions and 1,605 deletions.
7 changes: 0 additions & 7 deletions packages/intrepid2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ ELSE()
OFF)
ENDIF()

# temporary flag
TRIBITS_ADD_OPTION_AND_DEFINE(${PACKAGE_NAME}_KEEP_EXPERIMENTAL_NAMESPACE
HAVE_INTREPID2_EXPERIMENTAL_NAMESPACE
"Whether Intrepid2 keeps experimentatl namespace for projections."
ON
)

#
# C) Add the libraries, tests, and examples
#
Expand Down
4 changes: 0 additions & 4 deletions packages/intrepid2/cmake/Intrepid2_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,3 @@

/* Define if want to build with KokkosKernels enabled */
#cmakedefine HAVE_INTREPID2_KOKKOSKERNELS

/* Temporary flag */
#cmakedefine HAVE_INTREPID2_EXPERIMENTAL_NAMESPACE

5 changes: 0 additions & 5 deletions packages/intrepid2/src/Cell/Intrepid2_ProjectedGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,8 @@ namespace Intrepid2
INTREPID2_TEST_FOR_EXCEPTION(projectedBasisNodes.extent_int(2) != spaceDim, std::invalid_argument, "projectedBasisNodes must have shape (C,F,D)");

using ExecutionSpace = typename DeviceType::execution_space;
#ifdef HAVE_INTREPID2_EXPERIMENTAL_NAMESPACE
using ProjectionTools = Experimental::ProjectionTools<DeviceType>;
using ProjectionStruct = Experimental::ProjectionStruct<DeviceType,PointScalar>;
#else
using ProjectionTools = ProjectionTools<DeviceType>;
using ProjectionStruct = ProjectionStruct<DeviceType,PointScalar>;
#endif

ProjectionStruct projectionStruct;
ordinal_type targetQuadratureDegree(targetHGradBasis->getDegree()), targetDerivativeQuadratureDegree(targetHGradBasis->getDegree());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ namespace Intrepid2 {
">>> ERROR (FunctionSpaceTools::computeFaceMeasure): Input Jacobian container must have rank 4.");
INTREPID2_TEST_FOR_EXCEPTION( scratch.rank() != 1, std::invalid_argument,
">>> ERROR (FunctionSpaceTools::computeFaceMeasure): Scratch view imust have rank 1.");
INTREPID2_TEST_FOR_EXCEPTION( scratch.span() < inputJac.span(), std::invalid_argument,
INTREPID2_TEST_FOR_EXCEPTION( scratch.size() < inputJac.size(), std::invalid_argument,
">>> ERROR (FunctionSpaceTools::computeFaceMeasure): Scratch storage must be greater than or equal to inputJac's one.");
#endif

Expand Down Expand Up @@ -671,7 +671,7 @@ namespace Intrepid2 {
">>> ERROR (FunctionSpaceTools::computeEdgeMeasure): Input Jacobian container must have rank 4.");
INTREPID2_TEST_FOR_EXCEPTION( scratch.rank() != 1, std::invalid_argument,
">>> ERROR (FunctionSpaceTools::computeEdgeMeasure): Scratch view must have a rank 1.");
INTREPID2_TEST_FOR_EXCEPTION( scratch.span() < inputJac.span(), std::invalid_argument,
INTREPID2_TEST_FOR_EXCEPTION( scratch.size() < inputJac.size(), std::invalid_argument,
">>> ERROR (FunctionSpaceTools::computeEdgeMeasure): Scratch storage must be greater than or equal to inputJac'one.");
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
// @HEADER

/** \file Intrepid2_LagrangianInterpolation.hpp
\brief Header file for the Intrepid2::Experimental::LagrangianInterpolation class.
\brief Header file for the Intrepid2::LagrangianInterpolation class.
\author Created by Mauro Perego
*/
#ifndef __INTREPID2_LAGRANGIANINTERPOLATION_HPP__
Expand Down Expand Up @@ -103,11 +103,7 @@

namespace Intrepid2 {

#ifdef HAVE_INTREPID2_EXPERIMENTAL_NAMESPACE
namespace Experimental {
#endif

/** \class Intrepid2::Experimental::LagrangianInterpolation
/** \class Intrepid2::LagrangianInterpolation and LagrangianTools classes
\brief A class providing static members to perform Lagrangian interpolation on a finite element.
Expand All @@ -134,64 +130,6 @@ template<typename DeviceType>
class LagrangianInterpolation {
public:

#ifdef HAVE_INTREPID2_EXPERIMENTAL_NAMESPACE
/** \brief Computes the points and coefficients associated with the basis DOFs for the reference oriented element
* WARNING: this method will probably be removed when the class will be moved out of the Experimental namespace.
\code
C - num. cells
F - num. fields
D - spatial dimension
\endcode
\param dofCoords [out] - rank-3 view (C,F,D), that will contain coordinates associated with the basis DOFs.
\param dofCoeffs [out] - variable rank view that will contain coefficients associated with the basis DOFs.
\param cellBasis [in] - pointer to the basis for the interpolation
\param cellOrientations [in] - rank-1 view (C) containing the Orientation objects at each cell
\remark the output views need to be pre-allocated. <var><b>dofCoeffs</b></var> has rank 2, (C,F) for scalar basis and 3,
(C,F,D) for vector basis.
*/
template<typename BasisType,
class ...coordsProperties, class ...coeffsProperties,
typename ortValueType, class ...ortProperties>
static void
getDofCoordsAndCoeffs(
Kokkos::DynRankView<typename BasisType::scalarType, coordsProperties...> dofCoords,
Kokkos::DynRankView<typename BasisType::scalarType, coeffsProperties...> dofCoeffs,
const BasisType* cellBasis,
const Kokkos::DynRankView<ortValueType, ortProperties...> cellOrientations
);

/** \brief Computes the basis weights of the function interpolation
* WARNING: this method will be removed when the class will be moved out of the Experimental namespace.
\code
C - num. cells
F - num. fields
D - spatial dimension
\endcode
\param basisCoeffs [out] - rank-2 view (C,F) that will contain the basis coefficients of the interpolation.
\param functionAtDofCoords [in] - variable rank view that contains the function evaluated at DOF coordinates.
\param dofCoeffs [in] - variable rank view that contains coefficients associated with the basis DOFs.
\remark The output views need to be pre-allocated. <var><b>dofCoeffs</b></var> and <var><b>functionAtDofCoords</b></var> have
rank 2, (C,F) for scalar basis and 3, (C,F,D) for vector basis.
<var><b>functValsAtDofCoords</b></var> contains the function evaluated at the dofCoords and contravariantly transformed
to the reference eleemnt.
<var><b>dofCoeffs</b></var> are as returned by <var><b>getDofCoordsAndCoeffs</b></var>.
*/
template<typename basisCoeffsViewType,
typename funcViewType,
typename dofCoeffViewType>
static void
getBasisCoeffs(basisCoeffsViewType basisCoeffs,
const funcViewType functionAtDofCoords,
const dofCoeffViewType dofCoeffs);
#endif


/** \brief Computes the basis weights of the function interpolation.
\code
Expand Down Expand Up @@ -221,10 +159,6 @@ class LagrangianInterpolation {
const ortViewType orts);
};

#ifdef HAVE_INTREPID2_EXPERIMENTAL_NAMESPACE
}
#endif

/** \class Intrepid2::LagrangianTools
\brief A class providing tools for Lagrangian elements as static members.
Expand Down Expand Up @@ -290,6 +224,13 @@ class LagrangianTools {
const Kokkos::DynRankView<ortValueType, ortProperties...> cellOrientations
);
};

// temporary fix to allow applications keep using the Experimental namespace. It will be removed soon.
namespace Experimental {
template<typename DeviceType>
class LagrangianInterpolation: public Intrepid2::LagrangianInterpolation<DeviceType>{};
}

}

// include templated function definitions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
// @HEADER

/** \file Intrepid2_LagrangianInterpolationDef.hpp
\brief Header file for the Intrepid2::Experimental::LagrangianInterpolation containing definitions.
\brief Header file for the Intrepid2::LagrangianInterpolation containing definitions.
\author Created by Mauro Perego
*/

Expand Down Expand Up @@ -333,40 +333,6 @@ LagrangianTools<DeviceType>::getOrientedDofCoeffs(
}


#ifdef HAVE_INTREPID2_EXPERIMENTAL_NAMESPACE
namespace Experimental {
#endif


#ifdef HAVE_INTREPID2_EXPERIMENTAL_NAMESPACE
template<typename DeviceType>
template<typename BasisType,
class ...coordsProperties, class ...coeffsProperties,
typename ortValueType, class ...ortProperties>
void
LagrangianInterpolation<DeviceType>::getDofCoordsAndCoeffs(
Kokkos::DynRankView<typename BasisType::scalarType, coordsProperties...> dofCoords,
Kokkos::DynRankView<typename BasisType::scalarType, coeffsProperties...> dofCoeffs,
const BasisType* basis,
const Kokkos::DynRankView<ortValueType, ortProperties...> orts) {
LagrangianTools<DeviceType>::getOrientedDofCoords(dofCoords, basis, orts);
LagrangianTools<DeviceType>::getOrientedDofCoeffs(dofCoeffs, basis, orts);
}


template<typename DeviceType>
template<typename basisCoeffsViewType,
typename funcViewType,
typename dofCoeffViewType>
void
LagrangianInterpolation<DeviceType>::getBasisCoeffs(basisCoeffsViewType basisCoeffs,
const funcViewType functionValsAtDofCoords,
const dofCoeffViewType dofCoeffs){
ArrayTools<DeviceType>::dotMultiplyDataData(basisCoeffs,functionValsAtDofCoords,dofCoeffs);
}
#endif


template<typename DeviceType>
template<typename basisCoeffsViewType,
typename funcViewType,
Expand All @@ -390,9 +356,6 @@ LagrangianInterpolation<DeviceType>::getBasisCoeffs(basisCoeffsViewType basisCoe
OrientationTools<DeviceType>::modifyBasisByOrientationInverse(basisCoeffs, basisCoeffsRef, orts, cellBasis, true);
}

#ifdef HAVE_INTREPID2_EXPERIMENTAL_NAMESPACE
}
#endif
} // Intrepid2 namespace

#endif
Expand Down
15 changes: 8 additions & 7 deletions packages/intrepid2/src/Projection/Intrepid2_ProjectionStruct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
// @HEADER

/** \file Intrepid2_ProjectionStruct.hpp
\brief Header file for the Intrepid2::Experimental::ProjectionStruct.
\brief Header file for the Intrepid2::ProjectionStruct.
\author Created by Mauro Perego
*/
#ifndef __INTREPID2_PROJECTIONSTRUCT_HPP__
Expand All @@ -56,11 +56,8 @@
#include <array>

namespace Intrepid2 {
#ifdef HAVE_INTREPID2_EXPERIMENTAL_NAMESPACE
namespace Experimental {
#endif

/** \class Intrepid2::Experimental::ProjectionStruct
/** \class Intrepid2::ProjectionStruct
\brief An helper class to compute the evaluation points and weights needed for performing projections
In order to perform projections, the basis functions and the target function need to be evaluated
Expand Down Expand Up @@ -528,9 +525,13 @@ class ProjectionStruct {
ordinal_type maxNumBasisDerivEvalPoints;
ordinal_type maxNumTargetDerivEvalPoints;
};
#ifdef HAVE_INTREPID2_EXPERIMENTAL_NAMESPACE

//Temporary fix, to allow application keep using the Experimental namespace. It will be removed soon.
namespace Experimental {
template<typename DeviceType, typename ValueType>
class ProjectionStruct: public Intrepid2::ProjectionStruct<DeviceType, ValueType>{};
}
#endif

} // Intrepid2 namespace
#include "Intrepid2_ProjectionStructDef.hpp"
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
// @HEADER

/** \file Intrepid2_ProjectionStructDef.hpp
\brief Header file for the Intrepid2::Experimental::ProjectionStruct containing definitions.
\brief Header file for the Intrepid2::ProjectionStruct containing definitions.
\author Created by Mauro Perego
*/
#ifndef __INTREPID2_PROJECTIONSTRUCTDEF_HPP__
Expand All @@ -61,10 +61,6 @@

namespace Intrepid2 {

#ifdef HAVE_INTREPID2_EXPERIMENTAL_NAMESPACE
namespace Experimental {
#endif

template<typename DeviceType, typename ValueType>
template<typename BasisPtrType>
void ProjectionStruct<DeviceType,ValueType>::createL2ProjectionStruct(const BasisPtrType cellBasis,
Expand Down Expand Up @@ -767,9 +763,7 @@ void ProjectionStruct<DeviceType,ValueType>::createHVolProjectionStruct(const Ba
allBasisDerivEPoints = view_type("allBasisDerivPoints", numBasisDerivEvalPoints, dim);
allTargetDerivEPoints = view_type("allTargetDerivPoints", numTargetDerivEvalPoints, dim);
}
#ifdef HAVE_INTREPID2_EXPERIMENTAL_NAMESPACE
}
#endif

} // Intrepid2 namespace
#endif

Expand Down
Loading

0 comments on commit 392a536

Please sign in to comment.