Skip to content

Commit

Permalink
Merge pull request #9 from dfvankomen/master
Browse files Browse the repository at this point in the history
feat: Functionality to get refinement flags from mesh object (useful for multi-refinement types)
  • Loading branch information
dfvankomen authored Aug 19, 2024
2 parents 07b5d37 + 1d71824 commit 667dc53
Show file tree
Hide file tree
Showing 26 changed files with 144 additions and 96 deletions.
2 changes: 1 addition & 1 deletion FEM/examples/src/dgVecTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int main(int argc, char** argv) {
Point pt_min(d_min, d_min, d_min);
Point pt_max(d_max, d_max, d_max);
//@note that based on how the functions are defined (f(x), dxf(x), etc) the
//compuatational domain is equivalent to the grid domain.
// compuatational domain is equivalent to the grid domain.
std::function<double(double, double, double)> func =
[d_min, d_max](const double x, const double y, const double z) {
double xx = (x / (1u << m_uiMaxDepth)) * (d_max - d_min) + d_min;
Expand Down
2 changes: 1 addition & 1 deletion ODE/examples/testLTSBlkVec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int main(int argc, char** argv) {
Point pt_min(d_min, d_min, d_min);
Point pt_max(d_max, d_max, d_max);
//@note that based on how the functions are defined (f(x), dxf(x), etc) the
//compuatational domain is equivalent to the grid domain.
// compuatational domain is equivalent to the grid domain.
std::function<double(double, double, double)> func =
[d_min, d_max](const double x, const double y, const double z) {
double xx = (x / (1u << m_uiMaxDepth)) * (d_max - d_min) + d_min;
Expand Down
2 changes: 1 addition & 1 deletion ODE/include/blkAsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class BlockAsyncVector {

public:
/**@brief: default constructor.*/
BlockAsyncVector(){};
BlockAsyncVector() {};

/**@brief: default destructor*/
~BlockAsyncVector() {
Expand Down
4 changes: 2 additions & 2 deletions ODE/include/ctx.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ class Ctx {

public:
/**@brief: default constructor*/
Ctx(){};
Ctx() {};

/**@brief: default destructor*/
~Ctx(){};
~Ctx() {};

/**@brief: derived class static cast*/
inline DerivedCtx& asLeaf() { return static_cast<DerivedCtx&>(*this); }
Expand Down
18 changes: 10 additions & 8 deletions ODE/include/enuts.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,14 +456,16 @@ class ExplicitNUTS : public ETS<T, Ctx> {

/**@brief: compute weight for a wpart. */
static unsigned int getOctWeight(const ot::TreeNode* pNode) {
const unsigned int finest_t =
wpart_meta.tfac(wpart_meta.lmax, wpart_meta.lmin,
wpart_meta.lmax); // m_uiAppCtx->getBlkTimestepFac(m_uiLevMax,m_uiLevMin,m_uiLevMax);
// // finest time level.
const unsigned int coarset_t =
wpart_meta.tfac(wpart_meta.lmin, wpart_meta.lmin,
wpart_meta.lmax); // m_uiAppCtx->getBlkTimestepFac(m_uiLevMin,m_uiLevMin,m_uiLevMax);
// // coarset time level.
const unsigned int finest_t = wpart_meta.tfac(
wpart_meta.lmax, wpart_meta.lmin,
wpart_meta
.lmax); // m_uiAppCtx->getBlkTimestepFac(m_uiLevMax,m_uiLevMin,m_uiLevMax);
// // finest time level.
const unsigned int coarset_t = wpart_meta.tfac(
wpart_meta.lmin, wpart_meta.lmin,
wpart_meta
.lmax); // m_uiAppCtx->getBlkTimestepFac(m_uiLevMin,m_uiLevMin,m_uiLevMax);
// // coarset time level.
const unsigned int weight =
((coarset_t - finest_t) /
(wpart_meta.tfac(pNode->getLevel(), wpart_meta.lmin,
Expand Down
2 changes: 1 addition & 1 deletion ODE/include/enutsOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ENUTSOp {
* @brief Destroy the ENUTSOp object
*
*/
~ENUTSOp(){};
~ENUTSOp() {};

/**
* @brief Diagonal op. of time scaling $P_{\Delta t}$ and its inverse
Expand Down
4 changes: 2 additions & 2 deletions ODE/include/inverseCtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class InverseCtx {
launcher::Launcher* m_uiJobLauncher = NULL;

public:
InverseCtx(){};
InverseCtx() {};

~InverseCtx(){};
~InverseCtx() {};

/**@brief: derived class static cast*/
DerivedInverseCtx& asLeaf() {
Expand Down
8 changes: 4 additions & 4 deletions ODE/include/rk.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ class RK {
// END UNUSED

/** One time step iteration iteration for RK45 update*/
virtual void performSingleIteration(){};
virtual void performSingleIteration() {};

/** apply intial conditions*/
virtual void applyInitialConditions(){};
virtual void applyInitialConditions() {};

/**function to apply boundary conditions. */
virtual void applyBoundaryConditions(){};
virtual void applyBoundaryConditions() {};

virtual void rkSolve(){};
virtual void rkSolve() {};

/**@brief free memeory of the mesh*/
inline void freeMesh() { delete m_uiMesh; };
Expand Down
2 changes: 1 addition & 1 deletion ODE/include/sdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class SDC {
/**
* @brief Construct a new SDC object
*/
SDC(){};
SDC() {};

/**
* @brief Destroy the SDC object
Expand Down
26 changes: 16 additions & 10 deletions examples/src/meshBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@ void meshBenchMark(char* ptsFile, bool genPts, unsigned int numPts,
SFC::parSort::SFC_treeSort(
pNodesConstructed, pNodesSorted, pNodesConstructed, pNodesBalanced,
tol, maxDepth, root, ROOT_ROT_ID, 1, TS_BALANCE_OCTREE, sf_k, comm);
t2 = MPI_Wtime(); // std::chrono::high_resolution_clock::now();
t_bal = t2 - t1; // std::chrono::duration_cast<std::chrono::milliseconds>(t2
// - t1).count();
t2 = MPI_Wtime(); // std::chrono::high_resolution_clock::now();
t_bal = t2 -
t1; // std::chrono::duration_cast<std::chrono::milliseconds>(t2
// - t1).count();
if (!rank) std::cout << RED << "2:1 balance end" << NRM << std::endl;
pNodesConstructed.clear();

Expand All @@ -184,8 +185,10 @@ void meshBenchMark(char* ptsFile, bool genPts, unsigned int numPts,
ot::Mesh mesh(pNodesBalanced, stencilSz, eleOrder, comm, false,
ot::FEM_CG);
t2 = MPI_Wtime(); // std::chrono::high_resolution_clock::now();
t_mesh = t2 - t1; // std::chrono::duration_cast<std::chrono::milliseconds>(t2
// - t1).count();
t_mesh =
t2 -
t1; // std::chrono::duration_cast<std::chrono::milliseconds>(t2
// - t1).count();
if (!rank)
std::cout << RED << "mesh generation end" << NRM << std::endl;

Expand Down Expand Up @@ -279,9 +282,10 @@ void meshBenchMark(char* ptsFile, bool genPts, unsigned int numPts,
&(*(pNodesConstructed.begin())), pNodesConstructed.size(),
pNodesSorted, pNodesConstructed, pNodesBalanced, maxDepth, maxDepth,
root, ROOT_ROT_ID, 1, TS_BALANCE_OCTREE);
t2 = MPI_Wtime(); // std::chrono::high_resolution_clock::now();
t_bal = t2 - t1; // std::chrono::duration_cast<std::chrono::milliseconds>(t2
// - t1).count();
t2 = MPI_Wtime(); // std::chrono::high_resolution_clock::now();
t_bal = t2 -
t1; // std::chrono::duration_cast<std::chrono::milliseconds>(t2
// - t1).count();
if (!rank) std::cout << RED << "2:1 balance end" << NRM << std::endl;

t_bal_g[0] = t_bal;
Expand Down Expand Up @@ -314,8 +318,10 @@ void meshBenchMark(char* ptsFile, bool genPts, unsigned int numPts,
cg_sz = mesh.getDegOfFreedom();
}
t2 = MPI_Wtime(); // std::chrono::high_resolution_clock::now();
t_mesh = t2 - t1; // std::chrono::duration_cast<std::chrono::milliseconds>(t2
// - t1).count();
t_mesh =
t2 -
t1; // std::chrono::duration_cast<std::chrono::milliseconds>(t2
// - t1).count();
if (!rank)
std::cout << RED << "mesh generation end" << NRM << std::endl;

Expand Down
13 changes: 8 additions & 5 deletions examples/src/meshE2NCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,10 @@ int main(int argc, char** argv) {
SFC::parSort::SFC_treeSort(
pNodesConstructed, pNodesSorted, pNodesConstructed, pNodesBalanced,
tol, maxDepth, root, ROOT_ROT_ID, 1, TS_BALANCE_OCTREE, sf_k, comm);
t2 = MPI_Wtime(); // std::chrono::high_resolution_clock::now();
t_bal = t2 - t1; // std::chrono::duration_cast<std::chrono::milliseconds>(t2
// - t1).count();
t2 = MPI_Wtime(); // std::chrono::high_resolution_clock::now();
t_bal = t2 -
t1; // std::chrono::duration_cast<std::chrono::milliseconds>(t2
// - t1).count();
if (!rank) std::cout << RED << "2:1 balance end" << NRM << std::endl;
pNodesConstructed.clear();

Expand Down Expand Up @@ -355,8 +356,10 @@ int main(int argc, char** argv) {
t1 = MPI_Wtime(); // std::chrono::high_resolution_clock::now();
ot::Mesh mesh(pNodesBalanced, stencilSz, 4, comm);
t2 = MPI_Wtime(); // std::chrono::high_resolution_clock::now();
t_mesh = t2 - t1; // std::chrono::duration_cast<std::chrono::milliseconds>(t2
// - t1).count();
t_mesh =
t2 -
t1; // std::chrono::duration_cast<std::chrono::milliseconds>(t2
// - t1).count();
if (!rank)
std::cout << RED << "mesh generation end" << NRM << std::endl;

Expand Down
22 changes: 14 additions & 8 deletions examples/src/meshLooping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ int main(int argc, char** argv) {
tmpNodes, pNodesSorted, pNodesConstructed, pNodesBalanced, tol,
maxDepth, root, ROOT_ROT_ID, 1, TS_BALANCE_OCTREE, sf_k, comm);
auto t2 = MPI_Wtime(); // std::chrono::high_resolution_clock::now();
t_bal = t2 - t1; // std::chrono::duration_cast<std::chrono::milliseconds>(t2
// - t1).count();
t_bal = t2 -
t1; // std::chrono::duration_cast<std::chrono::milliseconds>(t2
// - t1).count();
if (!rank) std::cout << RED << "2:1 balance end" << NRM << std::endl;
par::Mpi_Reduce(&t_bal, &t_g, 1, MPI_MAX, 0, comm);
DendroIntL localSz = pNodesBalanced.size();
Expand All @@ -131,8 +132,10 @@ int main(int argc, char** argv) {
t1 = MPI_Wtime(); // std::chrono::high_resolution_clock::now();
ot::Mesh mesh(pNodesBalanced, stencilSz, 1, comm);
t2 = MPI_Wtime(); // std::chrono::high_resolution_clock::now();
t_mesh = t2 - t1; // std::chrono::duration_cast<std::chrono::milliseconds>(t2
// - t1).count();
t_mesh =
t2 -
t1; // std::chrono::duration_cast<std::chrono::milliseconds>(t2
// - t1).count();
if (!rank)
std::cout << RED << "mesh generation end" << NRM << std::endl;
par::Mpi_Reduce(&t_mesh, &t_g, 1, MPI_MAX, 0, comm);
Expand All @@ -151,8 +154,9 @@ int main(int argc, char** argv) {
tmpNodes, pNodesSorted, pNodesConstructed, pNodesBalanced, tol,
maxDepth, root, ROOT_ROT_ID, 1, TS_BALANCE_OCTREE, sf_k, comm);
auto t2 = MPI_Wtime(); // std::chrono::high_resolution_clock::now();
t_bal = t2 - t1; // std::chrono::duration_cast<std::chrono::milliseconds>(t2
// - t1).count();
t_bal = t2 -
t1; // std::chrono::duration_cast<std::chrono::milliseconds>(t2
// - t1).count();
if (!rank) std::cout << RED << "2:1 balance end" << NRM << std::endl;
par::Mpi_Reduce(&t_bal, &t_g, 1, MPI_MAX, 0, comm);
DendroIntL localSz = pNodesBalanced.size();
Expand All @@ -174,8 +178,10 @@ int main(int argc, char** argv) {
t1 = MPI_Wtime(); // std::chrono::high_resolution_clock::now();
ot::Mesh mesh(pNodesBalanced, stencilSz, 1, comm);
t2 = MPI_Wtime(); // std::chrono::high_resolution_clock::now();
t_mesh = t2 - t1; // std::chrono::duration_cast<std::chrono::milliseconds>(t2
// - t1).count();
t_mesh =
t2 -
t1; // std::chrono::duration_cast<std::chrono::milliseconds>(t2
// - t1).count();
if (!rank)
std::cout << RED << "mesh generation end" << NRM << std::endl;
par::Mpi_Reduce(&t_mesh, &t_g, 1, MPI_MAX, 0, comm);
Expand Down
4 changes: 2 additions & 2 deletions examples/src/zoltan_hilbert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ void ZoltanHibertLBandSort(DendroIntL grainSz, unsigned int dim,

//}

auto zz_local_start = std::chrono::system_clock::now(); // MPI_Wtime();
auto zz_local_start = std::chrono::system_clock::now(); // MPI_Wtime();

ZOLTAN_ID_TYPE localPts = mesh.numLocalPts;
ZOLTAN_ID_TYPE localPts = mesh.numLocalPts;

ZOLTAN_ID_TYPE *permutedIds = new ZOLTAN_ID_TYPE[localPts];
Zoltan_Order(zz, NUM_GID_SIZE, mesh.numLocalPts, mesh.globalIds,
Expand Down
6 changes: 3 additions & 3 deletions include/TreeNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ class Mpi_datatype<ot::TreeNode> {
(static_cast<ot::TreeNode *>(inout))[i] =
(((first.getLevel()) > (second.getLevel())) ? first : second);
} // end for
} // end function
} // end function

static void Node_MAX(void *in, void *inout, int *len, MPI_Datatype *dptr) {
for (int i = 0; i < (*len); i++) {
Expand All @@ -961,7 +961,7 @@ class Mpi_datatype<ot::TreeNode> {
(static_cast<ot::TreeNode *>(inout))[i] =
((first > second) ? first : second);
} // end for
} // end function
} // end function

static void Node_MIN(void *in, void *inout, int *len, MPI_Datatype *dptr) {
for (int i = 0; i < (*len); i++) {
Expand All @@ -970,7 +970,7 @@ class Mpi_datatype<ot::TreeNode> {
(static_cast<ot::TreeNode *>(inout))[i] =
((first < second) ? first : second);
} // end for
} // end function
} // end function

/* static void Node_NCA(void *in, void *inout, int* len, MPI_Datatype *
dptr) { for(int i = 0; i < (*len); i++) { ot::TreeNode first =
Expand Down
4 changes: 2 additions & 2 deletions include/asyncExchangeContex.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AsyncExchangeContex {
/**@brief batched requests for recv */
std::vector<MPI_Request> m_recv_req;

AsyncExchangeContex(){};
AsyncExchangeContex() {};

/**@brief creates an async ghost exchange contex*/
AsyncExchangeContex(const void* var) {
Expand All @@ -51,7 +51,7 @@ class AsyncExchangeContex {
}

/**@brief : defaut destructor*/
~AsyncExchangeContex(){};
~AsyncExchangeContex() {};

/**@brief allocates send buffer for ghost exchange*/
inline void allocateSendBuffer(size_t bytes) {
Expand Down
4 changes: 2 additions & 2 deletions include/dtypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ class Mpi_datatype<bool> {
(((static_cast<bool *>(in))[i]) ||
((static_cast<bool *>(inout))[i]));
} // end for
} // end function
} // end function

static void bool_LAND(void *in, void *inout, int *len, MPI_Datatype *dptr) {
for (int i = 0; i < (*len); i++) {
((static_cast<bool *>(inout))[i]) =
(((static_cast<bool *>(in))[i]) &&
((static_cast<bool *>(inout))[i]));
} // end for
} // end function
} // end function

public:
/**
Expand Down
2 changes: 1 addition & 1 deletion include/launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Launcher {
m_uiCoresPerNode = cores_per_node;
}

~Launcher(){};
~Launcher() {};

int alloc_sub_communicator(unsigned int njobs) {
int rank_g, npes_g;
Expand Down
35 changes: 23 additions & 12 deletions include/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -2621,6 +2621,11 @@ class Mesh {
void getFinerFaceNeighbors(unsigned int ele, unsigned int dir,
unsigned int *child) const;

/**
* @brief Extract the raw refinement flags from all local elements
*/
std::vector<unsigned int> getAllRefinementFlags();

/**
* @brief Set the Mesh Refinement flags, for the local portion of the mesh.
Note that coarsening happens if all the children are
Expand Down Expand Up @@ -2826,24 +2831,30 @@ inline bool Mesh::computeOveralppingNodes(const ot::TreeNode &parent,

if (!(((child.getX() - parent.getX()) * dp * dc + k * Lc * dp) %
(Lp * dc)))
index[0] = ((child.getX() - parent.getX()) * dp * dc +
k * Lc * dp) /
(Lp * dc); //((child.getX()-parent.getX())*m_uiElementOrder
//+ k*Lc)/Lp;
index[0] =
((child.getX() - parent.getX()) * dp * dc +
k * Lc * dp) /
(Lp *
dc); //((child.getX()-parent.getX())*m_uiElementOrder
//+ k*Lc)/Lp;

if (!(((child.getY() - parent.getY()) * dp * dc + k * Lc * dp) %
(Lp * dc)))
index[1] = ((child.getY() - parent.getY()) * dp * dc +
k * Lc * dp) /
(Lp * dc); //((child.getY()-parent.getY())*m_uiElementOrder
//+ k*Lc)/Lp;
index[1] =
((child.getY() - parent.getY()) * dp * dc +
k * Lc * dp) /
(Lp *
dc); //((child.getY()-parent.getY())*m_uiElementOrder
//+ k*Lc)/Lp;

if (!(((child.getZ() - parent.getZ()) * dp * dc + k * Lc * dp) %
(Lp * dc)))
index[2] = ((child.getZ() - parent.getZ()) * dp * dc +
k * Lc * dp) /
(Lp * dc); //((child.getZ()-parent.getZ())*m_uiElementOrder
//+ k*Lc)/Lp;
index[2] =
((child.getZ() - parent.getZ()) * dp * dc +
k * Lc * dp) /
(Lp *
dc); //((child.getZ()-parent.getZ())*m_uiElementOrder
//+ k*Lc)/Lp;

if (!stateX && index[0] < (m_uiElementOrder + 1)) stateX = true;

Expand Down
2 changes: 1 addition & 1 deletion include/point.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class Mpi_datatype<Point> {
Point p2 = (static_cast<Point *>(inout))[i];
(static_cast<Point *>(inout))[i] += p1;
} // end for
} // end function
} // end function

public:
/**
Expand Down
Loading

0 comments on commit 667dc53

Please sign in to comment.