MCPcopy Create free account
hub / github.com/IBAMR/IBAMR / rotateArray

Method rotateArray

src/IB/CIBMethod.cpp:1621–1691  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1619} // constructGeometricMatrix
1620
1621void
1622CIBMethod::rotateArray(double* array,
1623 const std::vector<unsigned>& struct_ids,
1624 const bool use_transpose,
1625 const int managing_proc,
1626 const int depth)
1627{
1628 if (struct_ids.empty()) return;
1629
1630#if !defined(NDEBUG)
1631 if (!(depth == NDIM || depth == s_max_free_dofs))
1632 {
1633 TBOX_ERROR(
1634 "CIBMethod::rotateArray(). Data depth of the array to be "
1635 "rotated should either be "
1636 << NDIM << " (type nodal velocity) or " << s_max_free_dofs << " (type body free DOFs)." << std::endl);
1637 }
1638#endif
1639
1640 if (IBTK_MPI::getRank() == managing_proc)
1641 {
1642 const bool position_system = (depth % NDIM == 0);
1643 const bool force_system = (depth % s_max_free_dofs == 0);
1644 const auto num_structs = static_cast<unsigned>(struct_ids.size());
1645 unsigned offset = 0;
1646
1647 for (unsigned k = 0; k < num_structs; ++k)
1648 {
1649 unsigned structID = struct_ids[k];
1650 Eigen::Matrix3d R = use_transpose ? (d_quaternion_half[structID].toRotationMatrix()).transpose() :
1651 d_quaternion_half[structID].toRotationMatrix();
1652
1653 if (force_system)
1654 {
1655 Eigen::Vector3d F = Eigen::Vector3d::Zero();
1656 std::copy(array + offset, array + offset + NDIM, F.data());
1657 Eigen::Vector3d R_F = R * F;
1658 std::copy(R_F.data(), R_F.data() + NDIM, array + offset);
1659#if (NDIM == 3)
1660 Eigen::Vector3d T = Eigen::Vector3d::Zero();
1661 std::copy(array + offset + NDIM, array + offset + s_max_free_dofs, T.data());
1662 Eigen::Vector3d R_T = R * T;
1663 std::copy(R_T.data(), R_T.data() + NDIM, array + offset + NDIM);
1664#endif
1665 offset += s_max_free_dofs;
1666 }
1667 else if (position_system)
1668 {
1669 Eigen::Vector3d dr = Eigen::Vector3d::Zero();
1670 Eigen::Vector3d R_dr = Eigen::Vector3d::Zero();
1671 const unsigned number_of_nodes = getNumberOfNodes(structID);
1672
1673 for (unsigned node = 0; node < number_of_nodes; ++node)
1674 {
1675 std::copy(array + offset, array + offset + NDIM, dr.data());
1676 R_dr = R * dr;
1677 std::copy(R_dr.data(), R_dr.data() + NDIM, array + offset);
1678 offset += NDIM;

Callers 2

solveSystemMethod · 0.45
solveBodySystemMethod · 0.45

Calls 5

emptyMethod · 0.45
sizeMethod · 0.45
transposeMethod · 0.45
toRotationMatrixMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected