9#include <unordered_set>
13#include <nanoflann.hpp>
16#ifdef DNDS_USE_SUPERLU
17# include <superlu_ddefs.h>
43 std::vector<Eigen::Vector<real, 3>>
newCoords;
78 std::vector<NodePeriodicBits> pbi;
79 pbi.resize(
eSpan.GetNumNodes());
129 log() << fmt::format(
"=== Mesh Elevation: Num NewNode {} ",
numNewNode) << std::endl;
214 cell2node.InitPair(
"BuildO2FromO1Elevation::cell2node",
mpi);
274 std::array<index, Elem::CellNumNodeMax>
spanNodes{};
290 std::vector<NodePeriodicBits> pbi;
291 pbi.resize(
eSpan.GetNumNodes());
295 for (
auto pbie : pbi)
344 bnd2node.InitPair(
"BuildO2FromO1Elevation::bnd2node",
mpi);
530 std::vector<index>
c2nSub;
550 cell2node.InitPair(
"BuildBisectO1FormO2::cell2node",
mpi);
586 std::vector<std::vector<index>>
bnd2nodeV;
587 std::vector<std::vector<NodePeriodicBits>>
bnd2nodePbiV;
597 DNDS_assert_info(
iCell >= 0,
"bnd's main cell is not in current process main, need reordering of bnd");
612 int nBi =
eBnd.GetO2NumBisect();
617 std::vector<index>
b2nSub;
633 bnd2node.InitPair(
"BuildBisectO1FormO2::bnd2node",
mpi);
646 bnd2node.father->createGlobalMapping();
666 bnd2cell.InitPair(
"BuildBisectO1FormO2::bnd2cell",
mpi);
667 cell2cell.InitPair(
"BuildBisectO1FormO2::cell2cell",
mpi);
673 tPoint c01U = c01.stableNormalized();
674 real c01Len = c01.stableNorm();
675 tPoint t0 = -c01U.cross(n0).cross(n0);
676 tPoint t1 = -c01U.cross(n1).cross(n1);
677 t0 = t0.stableNormalized() * c01Len;
678 t1 = t1.stableNormalized() * c01Len;
679 if (n0.norm() == 0 && n1.norm() != 0)
680 return 0.25 * c0 + 0.75 * c1 - 0.25 * t1;
681 if (n0.norm() != 0 && n1.norm() == 0)
682 return 0.75 * c0 + 0.25 * c1 + 0.25 * t0;
683 if (n0.norm() == 0 && n1.norm() == 0)
684 return 0.5 * (c0 + c1);
685 return 0.5 * (c0 + c1) + 0.125 * (t0 - t1);
688 static tPoint HermiteInterpolateMidPointOnQuad4WithNorm(
692 tPoint c01 = HermiteInterpolateMidPointOnLine2WithNorm(c0, c1, n0, n1);
693 tPoint c12 = HermiteInterpolateMidPointOnLine2WithNorm(c1, c2, n1, n2);
694 tPoint c23 = HermiteInterpolateMidPointOnLine2WithNorm(c2, c3, n2, n3);
695 tPoint c30 = HermiteInterpolateMidPointOnLine2WithNorm(c3, c0, n3, n0);
696 return 0.5 * (c01 + c12 + c23 + c30) - 0.25 * (c0 + c1 + c2 + c3);
937 std::unordered_set<index>
moveds;
969 np.stableNormalize();
978 for (
int i = 0;
i <
f2n.size();
i++)
1007 std::vector<tPoint>
edges;
1022 Eigen::Matrix<real, 3, 4>
norms;
1023 Eigen::Vector<real, 4>
nAdd;
1060 norms.colwise().normalize();
1064 norms(EigenAll,
iN).setZero();
1072 cooSmooth = HermiteInterpolateMidPointOnLine2WithNorm(
1094 cooSmooth = HermiteInterpolateMidPointOnQuad4WithNorm(
1122 log() << fmt::format(
1123 "UnstructuredMesh === ElevatedNodesGetBoundarySmooth: Smoothing Complete, total Moved [{}], moving Vec Bnd {:.2g},{:.2g},{:.2g}",
Batch of uniform-sized Eigen matrices per row, with variable batch count.
Core type aliases, constants, and metaprogramming utilities for the DNDS framework.
Pre-compiled-header style shim that includes the heavy Eigen headers under DNDSR's warning suppressio...
#define DNDS_assert_info(expr, info)
Debug-only assertion with an extra std::string info message.
#define DNDS_assert(expr)
Debug-only assertion (compiled out when DNDS_NDEBUG is defined). Prints the expression + file/line + ...
tJacobi ShapeJacobianCoordD01Nj(const tCoordsIn &cs, Eigen::Ref< const tD01Nj > DiNj)
Eigen::Matrix< t_real, 4, Eigen::Dynamic > tD01Nj
tPoint PPhysicsCoordD01Nj(const tCoordsIn &cs, Eigen::Ref< const tD01Nj > DiNj)
DNDS_DEVICE_CALLABLE bool FaceIDIsInternal(t_index id)
Eigen::Matrix< real, 3, Eigen::Dynamic > tSmallCoords
MPI_int Scan(const void *sendbuf, void *recvbuf, MPI_int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
Wrapper over MPI_Scan (inclusive prefix reduction).
MPI_int Allreduce(const void *sendbuf, void *recvbuf, MPI_int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
Wrapper over MPI_Allreduce.
MPI_int Barrier(MPI_Comm comm)
Wrapper over MPI_Barrier.
const MPI_Datatype DNDS_MPI_INDEX
MPI datatype matching index (= MPI_INT64_T).
DNDS_CONSTANT const index UnInitIndex
Sentinel "not initialised" index value (= INT64_MIN).
int32_t rowsize
Row-width / per-row element-count type (signed 32-bit).
DNDS_CONSTANT const real pi
π in double precision (matches DNDS_E_PI macro).
constexpr MPI_int UnInitMPIInt
Sentinel "not initialised" MPI_int value (= -1, invalid rank).
DNDS_CONSTANT const real largeReal
Loose upper bound (e.g., for non-dimensional limits).
int64_t index
Global row / DOF index type (signed 64-bit; handles multi-billion-cell meshes).
constexpr T sqr(const T &a)
a * a, constexpr. Works for all arithmetic types.
double real
Canonical floating-point scalar used throughout DNDSR (double precision).
ssp< T > make_ssp(Args &&...args)
Type-safe replacement for DNDS_MAKE_SSP. Creates ssp<T> with forwarded args.
std::ostream & log()
Return the current DNDSR log stream (either std::cout or the installed file).
DNDS_CONSTANT const real veryLargeReal
Catch-all upper bound ("practically infinity") for physical scalars.
int MPI_int
MPI counterpart type for MPI_int (= C int). Used for counts and ranks in MPI calls.
const MPI_Datatype DNDS_MPI_REAL
MPI datatype matching real (= MPI_REAL8).
DNDS_DEVICE_CALLABLE auto RowSize() const
Uniform row width (delegates to father; father/son share it).
DNDS_DEVICE_CALLABLE index Size() const
Combined father + son row count.
Convenience bundle of a father, son, and attached ArrayTransformer.
void TransAttach()
Bind the transformer to the current father / son pointers.
ssp< TArray > father
Owned-side array (must be resized before ghost setup).
index Size() const
Combined row count (father->Size() + son->Size()).
void InitPair(const std::string &name, Args &&...args)
Allocate both father and son arrays, forwarding all args to TArray constructor.
ssp< TArray > son
Ghost-side array (sized automatically by createMPITypes / BorrowAndPull).
TTrans trans
Ghost-communication engine bound to father and son.
static MPI_Datatype CommType()
static MPI_Datatype CommType()
DNDS_DEVICE_CALLABLE tPoint GetCoordBackByBits(const tPoint &c, const NodePeriodicBits &bits) const
DNDS_DEVICE_CALLABLE auto GetVectorByBits(const Eigen::Matrix< real, dim, nVec > &v, const NodePeriodicBits &bits)
DNDS_DEVICE_CALLABLE auto GetVectorBackByBits(const Eigen::Matrix< real, dim, nVec > &v, const NodePeriodicBits &bits)
AdjPairTrackedDeviceView< B, tAdjPair::t_arr > bnd2node
tCoordPair::t_deviceView< B > coords
reader
DNDS_DEVICE_CALLABLE Elem::Element GetBndElement(index iB)
AdjPairTrackedDeviceView< B, tAdjPair::t_arr > cell2cell
tElemInfoArrayPair::t_deviceView< B > cellElemInfo
tPbiPair::t_deviceView< B > cell2nodePbi
periodic only, after reader
AdjPairTrackedDeviceView< B, tAdj2Pair::t_arr > bnd2cell
MeshAdjState adjPrimaryState
DNDS_DEVICE_CALLABLE void GetCoordsOnCell(index iCell, tSmallCoords &cs)
tPbiPair::t_deviceView< B > bnd2nodePbi
DNDS_DEVICE_CALLABLE Elem::Element GetCellElement(index iC)
tElemInfoArrayPair::t_deviceView< B > bndElemInfo
AdjPairTrackedDeviceView< B, tAdjPair::t_arr > cell2node
UnstructuredMeshDeviceView< B > t_deviceView
Elem::Element GetCellElement(index iC)
tPbiPair cell2nodePbi
periodic only, after reader
tCoordPair coordsElevDisp
only elevation
tPbiPair face2nodePbi
periodic only, after interpolated
void AdjLocal2GlobalC2F()
AdjPairTracked< tAdj2Pair > face2cell
void AdjLocal2GlobalFacial()
index NodeIndexGlobal2Local(DNDS::index i)
void _detail_GetCoordsOnElem(const tC2n &c2n, const tC2nPbi &c2nPbi, tSmallCoords &cs)
specially for periodicity
void ElevatedNodesGetBoundarySmooth(const std::function< bool(t_index)> &FiFBndIdNeedSmooth)
AdjPairTracked< tAdjPair > cell2face
interpolated
void AdjGlobal2LocalC2F()
void BuildBisectO1FormO2(UnstructuredMesh &meshO2)
auto getCell2NodeIndexPbiRow(index iCell)
AdjPairTracked< tAdjPair > cell2cell
void _detail_GetCoords(const tC2n &c2n, tSmallCoords &cs)
directly load coords; gets faulty if isPeriodic!
AdjPairTracked< tAdjPair > face2node
MeshAdjState adjPrimaryState
AdjPairTracked< tAdj1Pair > bnd2face
tElemInfoArrayPair faceElemInfo
struct DNDS::Geom::UnstructuredMesh::ElevationInfo elevationInfo
MeshAdjState adjFacialState
void BuildO2FromO1Elevation(UnstructuredMesh &meshO1)
AdjPairTracked< tAdjPair > cell2node
tElemInfoArrayPair cellElemInfo
AdjPairTracked< tAdjPair > bnd2node
void AdjGlobal2LocalFacial()
tElemInfoArrayPair bndElemInfo
MeshElevationState elevState
AdjPairTracked< tAdj2Pair > bnd2cell
int size
Number of ranks in comm (-1 until initialised).
int rank
This rank's 0-based index within comm (-1 until initialised).
MPI_Comm comm
The underlying MPI communicator handle.
Tag type for naming objects created via make_ssp.
Eigen::Matrix< real, 5, 1 > v