Skip to content

Commit

Permalink
Merging to single generic loop over coarse search and adding distance…
Browse files Browse the repository at this point in the history
… check before evaluating exponentials
  • Loading branch information
gyalla committed Jul 10, 2024
1 parent 787677d commit f38cfca
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 184 deletions.
2 changes: 1 addition & 1 deletion include/aero/actuator/ActuatorBulk.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ struct ActuatorMeta
stk::search::SearchMethod searchMethod_;
ActScalarIntDv numPointsTurbine_;
bool useFLLC_ = false;
bool turbineLevelSearch_ = false; //Adding turbine level search option to meta.
ActVectorDblDv epsilonChord_;
ActVectorDblDv epsilon_;
ActFixScalarBool entityFLLC_;
Expand Down Expand Up @@ -103,6 +102,7 @@ struct ActuatorBulk
ActFixElemIds elemContainingPoint_;

const int localTurbineId_;
bool singlePointCoarseSearch_ = false;
};

} // namespace nalu
Expand Down
3 changes: 0 additions & 3 deletions include/aero/actuator/ActuatorFunctors.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ struct SpreadForceInnerLoop
using SpreadActuatorForce =
GenericLoopOverCoarseSearchResults<ActuatorBulk, SpreadForceInnerLoop>;

using SpreadActuatorForceTurbineSearch =
GenericLoopOverCoarseTurbineSearchResults<ActuatorBulk, SpreadForceInnerLoop>;

} /* namespace nalu */
} /* namespace sierra */

Expand Down
8 changes: 0 additions & 8 deletions include/aero/actuator/ActuatorFunctorsFAST.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,6 @@ using ActFastSpreadForceWhProjection = GenericLoopOverCoarseSearchResults<
ActuatorBulkFAST,
ActFastSpreadForceWhProjInnerLoop>;

using ActFastComputeThrustTurbineSearch = GenericLoopOverCoarseTurbineSearchResults<
ActuatorBulkFAST,
ActFastComputeThrustInnerLoop>;

using ActFastSpreadForceWhProjectionTurbineSearch = GenericLoopOverCoarseTurbineSearchResults<
ActuatorBulkFAST,
ActFastSpreadForceWhProjInnerLoop>;

} /* namespace nalu */
} /* namespace sierra */

Expand Down
17 changes: 15 additions & 2 deletions include/aero/actuator/ActuatorGenericSearchFunctor.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct GenericLoopOverCoarseSearchResults
actBulk_.coarseSearchElemIds_.sync_host();
actBulk_.coarseSearchPointIds_.sync_host();
innerLoopFunctor_.preloop();
//innerLoopExtent_ = actBulk_.singlePointCoarseSearch ? 1 : actBulk_.pointCentroid_.extent(0)
}

// ctor for functor constructor taking multiple args
Expand All @@ -67,6 +68,7 @@ struct GenericLoopOverCoarseSearchResults
actBulk_.coarseSearchElemIds_.sync_host();
actBulk_.coarseSearchPointIds_.sync_host();
innerLoopFunctor_.preloop();
//innerLoopExtent_ = actBulk_.singlePointCoarseSearch ? 1 : actBulk_.pointCentroid_.extent(0)
}

// see ActuatorExecutorFASTSngp.C line 58
Expand Down Expand Up @@ -124,9 +126,19 @@ struct GenericLoopOverCoarseSearchResults
// during functor construction i.e. ActuatorBulk, flags, ActuatorMeta,
// etc.
//
// pointID helps look up data from openfast
//
innerLoopFunctor_(pointId, nodeCoords, sourceTerm, dual_vol, scvIp[nIp]);
// for (int actPtInd = 0; actPtInd < innerLoopExtent_; actPtInd ++){
// innerLoopFunctor_(actPtInd, nodeCoords, sourceTerm, dual_vol, scvIp[nIp]);
// }
//
if (actBulk_.singlePointCoarseSearch_) {
innerLoopFunctor_(pointId, nodeCoords, sourceTerm, dual_vol, scvIp[nIp]);
} else {
for (int actPtInd = 0; actPtInd < actBulk_.pointCentroid_.extent(0); actPtInd ++){
innerLoopFunctor_(actPtInd, nodeCoords, sourceTerm, dual_vol, scvIp[nIp]);
}
}

}
}

Expand All @@ -136,6 +148,7 @@ struct GenericLoopOverCoarseSearchResults
VectorFieldType* actuatorSource_;
ScalarFieldType* dualNodalVolume_;
functor innerLoopFunctor_;
//const size_t innerLoopExtent_;
};

} // namespace nalu
Expand Down
147 changes: 0 additions & 147 deletions include/aero/actuator/ActuatorGenericTurbineSearchFunctor.h

This file was deleted.

10 changes: 5 additions & 5 deletions src/aero/actuator/ActuatorBulkFAST.C
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,14 @@ void
ActuatorBulkFAST::stk_search(
const ActuatorMeta& actMeta, stk::mesh::BulkData& stkBulk, bool onlyFine /* = false */)
{
if (actMeta.turbineLevelSearch_){
// perform turbine level search and cache to the bulk data
stk_turbine_search(actMeta, stkBulk,onlyFine);
}
else{
if (singlePointCoarseSearch_){
//TODO: Does it make sense for actuator point search to have onlyFine option?
stk_search_act_pnts(actMeta, stkBulk);
}
else{
// perform turbine level search and cache to the bulk data
stk_turbine_search(actMeta, stkBulk,onlyFine);
}
}


Expand Down
13 changes: 3 additions & 10 deletions src/aero/actuator/ActuatorExecutorsFASTNgp.C
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,9 @@ ActuatorDiskFastNGP::operator()()
const int localSizeCoarseSearch =
actBulk_.coarseSearchElemIds_.view_host().extent_int(0);

if (actMeta_.turbineLevelSearch_) {
Kokkos::parallel_for(
"spreadForcesActuatorNgpFAST", HostRangePolicy(0, localSizeCoarseSearch),
SpreadActuatorForceTurbineSearch(actBulk_, stkBulk_));
}
else {
Kokkos::parallel_for(
"spreadForcesActuatorNgpFAST", HostRangePolicy(0, localSizeCoarseSearch),
SpreadActuatorForce(actBulk_, stkBulk_));
}
Kokkos::parallel_for(
"spreadForcesActuatorNgpFAST", HostRangePolicy(0, localSizeCoarseSearch),
SpreadActuatorForce(actBulk_, stkBulk_));

actBulk_.parallel_sum_source_term(stkBulk_);

Expand Down
22 changes: 14 additions & 8 deletions src/aero/actuator/ActuatorFunctors.C
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,21 @@ SpreadForceInnerLoop::operator()(
actuator_utils::compute_distance(
3, nodeCoords, pointCoords.data(), &distance[0]);

const double gauss =
actuator_utils::Gaussian_projection(3, &distance[0], epsilon.data());

for (int j = 0; j < 3; j++) {
projectedForce[j] = gauss * pointForce(j);
}
//Check distance between actuator point and element centroid. Only needed if singlePointCoarseSearch_==False
//auto epsilonRadius =
// Kokkos::subview(actBulk_.searchRadius_.view_host(), pointId, Kokkos::ALL);
auto epsilonRadius = actBulk_.searchRadius_.h_view(pointId);
if (std::sqrt(distance[0]*distance[0] + distance[1]*distance[1] + distance[2]*distance[2]) < epsilonRadius) {
const double gauss =
actuator_utils::Gaussian_projection(3, &distance[0], epsilon.data());

for (int j = 0; j < 3; j++) {
projectedForce[j] = gauss * pointForce(j);
}

for (int j = 0; j < 3; j++) {
sourceTerm[j] += projectedForce[j] * scvIp / dual_vol;
for (int j = 0; j < 3; j++) {
sourceTerm[j] += projectedForce[j] * scvIp / dual_vol;
}
}
}

Expand Down

0 comments on commit f38cfca

Please sign in to comment.