9#include <unordered_set>
13#include <nanoflann.hpp>
16#ifdef DNDS_USE_SUPERLU
17# include <superlu_ddefs.h>
42 std::vector<Eigen::Vector<real, 3>>
newCoords;
63 std::array<index, Elem::CellNumNodeMax>
spanNodes;
77 std::vector<NodePeriodicBits> pbi;
78 pbi.resize(
eSpan.GetNumNodes());
128 log() << fmt::format(
"=== Mesh Elevation: Num NewNode {} ",
numNewNode) << std::endl;
273 std::array<index, Elem::CellNumNodeMax>
spanNodes;
289 std::vector<NodePeriodicBits> pbi;
290 pbi.resize(
eSpan.GetNumNodes());
294 for (
auto pbie : pbi)
524 std::vector<index>
c2nSub;
580 std::vector<std::vector<index>>
bnd2nodeV;
581 std::vector<std::vector<NodePeriodicBits>>
bnd2nodePbiV;
591 DNDS_assert_info(
iCell >= 0,
"bnd's main cell is not in current process main, need reordering of bnd");
606 int nBi =
eBnd.GetO2NumBisect();
611 std::vector<index>
b2nSub;
667 tPoint c01U = c01.stableNormalized();
668 real c01Len = c01.stableNorm();
669 tPoint t0 = -c01U.cross(n0).cross(n0);
670 tPoint t1 = -c01U.cross(n1).cross(n1);
671 t0 = t0.stableNormalized() * c01Len;
672 t1 = t1.stableNormalized() * c01Len;
673 if (n0.norm() == 0 && n1.norm() != 0)
674 return 0.25 * c0 + 0.75 * c1 - 0.25 * t1;
675 if (n0.norm() != 0 && n1.norm() == 0)
676 return 0.75 * c0 + 0.25 * c1 + 0.25 * t0;
677 if (n0.norm() == 0 && n1.norm() == 0)
678 return 0.5 * (c0 + c1);
679 return 0.5 * (c0 + c1) + 0.125 * (t0 - t1);
682 static tPoint HermiteInterpolateMidPointOnQuad4WithNorm(
686 tPoint c01 = HermiteInterpolateMidPointOnLine2WithNorm(c0, c1, n0, n1);
687 tPoint c12 = HermiteInterpolateMidPointOnLine2WithNorm(c1, c2, n1, n2);
688 tPoint c23 = HermiteInterpolateMidPointOnLine2WithNorm(c2, c3, n2, n3);
689 tPoint c30 = HermiteInterpolateMidPointOnLine2WithNorm(c3, c0, n3, n0);
690 return 0.5 * (c01 + c12 + c23 + c30) - 0.25 * (c0 + c1 + c2 + c3);
928 std::unordered_set<index>
moveds;
960 np.stableNormalize();
969 for (
int i = 0; i <
f2n.size(); i++)
998 std::vector<tPoint>
edges;
1013 Eigen::Matrix<real, 3, 4>
norms;
1014 Eigen::Vector<real, 4>
nAdd;
1051 norms.colwise().normalize();
1055 norms(EigenAll,
iN).setZero();
1063 cooSmooth = HermiteInterpolateMidPointOnLine2WithNorm(
1085 cooSmooth = HermiteInterpolateMidPointOnQuad4WithNorm(
1113 log() << fmt::format(
1114 "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).
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)
tAdjPair::t_deviceView< B > cell2node
tAdj2Pair::t_deviceView< B > bnd2cell
tAdjPair::t_deviceView< B > bnd2node
tCoordPair::t_deviceView< B > coords
reader
DNDS_DEVICE_CALLABLE Elem::Element GetBndElement(index iB)
tElemInfoArrayPair::t_deviceView< B > cellElemInfo
tPbiPair::t_deviceView< B > cell2nodePbi
periodic only, after reader
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
tAdjPair::t_deviceView< B > cell2cell
UnstructuredMeshDeviceView< B > t_deviceView
void __GetCoordsOnElem(const tC2n &c2n, const tC2nPbi &c2nPbi, tSmallCoords &cs)
specially for periodicity
Elem::Element GetCellElement(index iC)
tPbiPair cell2nodePbi
periodic only, after reader
tCoordPair coordsElevDisp
only elevation
void __GetCoords(const tC2n &c2n, tSmallCoords &cs)
directly load coords; gets faulty if isPeriodic!
tPbiPair face2nodePbi
periodic only, after interpolated
void AdjLocal2GlobalC2F()
void AdjLocal2GlobalFacial()
index NodeIndexGlobal2Local(DNDS::index i)
void ElevatedNodesGetBoundarySmooth(const std::function< bool(t_index)> &FiFBndIdNeedSmooth)
void AdjGlobal2LocalC2F()
void BuildBisectO1FormO2(UnstructuredMesh &meshO2)
auto getCell2NodeIndexPbiRow(index iCell)
MeshAdjState adjPrimaryState
tElemInfoArrayPair faceElemInfo
struct DNDS::Geom::UnstructuredMesh::ElevationInfo elevationInfo
MeshAdjState adjFacialState
void BuildO2FromO1Elevation(UnstructuredMesh &meshO1)
tElemInfoArrayPair cellElemInfo
void AdjGlobal2LocalFacial()
tElemInfoArrayPair bndElemInfo
MeshElevationState elevState
tAdjPair cell2face
interpolated
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