Skip to content

Commit

Permalink
(Work in progress) Fixing compiling errors with turbine level coarse …
Browse files Browse the repository at this point in the history
…search.
  • Loading branch information
gyalla committed Jun 13, 2024
1 parent 2f4d754 commit 3542285
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 37 deletions.
10 changes: 10 additions & 0 deletions include/aero/actuator/ActuatorBulk.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ struct ActuatorBulk

void stk_search_act_pnts(
const ActuatorMeta& actMeta, stk::mesh::BulkData& stkBulk);

//Generic stk search
void stk_search(
const ActuatorMeta& actMeta, stk::mesh::BulkData& stkBulk, bool onlyFine = false);

//do I need this to be virtual function so the generic stk_search can call it, even though
//the turbine search only makes sense in the ActuatorBulkFast context as implemented?
virtual void stk_turbine_search(
const ActuatorMeta& actMeta, stk::mesh::BulkData& stkBulk, bool onlyFine = false);

void zero_source_terms(stk::mesh::BulkData& stkBulk);
void parallel_sum_source_term(stk::mesh::BulkData& stkBulk);
void compute_offsets(const ActuatorMeta& actMeta);
Expand Down
4 changes: 2 additions & 2 deletions include/aero/actuator/ActuatorBulkFAST.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ struct ActuatorBulkFAST : public ActuatorBulk
const double fastTimeStep, const double naluTimeStep);

// This is placed in ActuatorBulkFAST instead of ActuatorBulk because hublocations are needed
void stk_turbine_search(
const ActuatorMeta& actMeta, stk::mesh::BulkData& stkBulk);
void stk_turbine_search (
const ActuatorMeta& actMeta, stk::mesh::BulkData& stkBulk,bool onlyFine = false) override;

virtual ~ActuatorBulkFAST();

Expand Down
22 changes: 21 additions & 1 deletion src/aero/actuator/ActuatorBulk.C
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ ActuatorBulk::stk_search_act_pnts(
const ActuatorMeta& actMeta, stk::mesh::BulkData& stkBulk)
{
auto points = pointCentroid_.template view<ActuatorFixedMemSpace>();
auto radius = searchRadius_.template view<ActuatorFixedMemSpace>();

auto radius = searchRadius_.template view<ActuatorFixedMemSpace>();
auto boundSpheres = CreateBoundingSpheres(points, radius);
auto elemBoxes = CreateElementBoxes(stkBulk, actMeta.searchTargetNames_);

Expand All @@ -105,6 +105,26 @@ ActuatorBulk::stk_search_act_pnts(
actuator_utils::reduce_view_on_host(localParallelRedundancy_);
}

void stk_turbine_search(
const ActuatorMeta& actMeta, stk::mesh::BulkData& stkBulk, bool onlyFine /*= false*/)
{
STK_ThrowErrorMsg("Turbine Search Requires ActuatorBulkFAST data");
}

void
ActuatorBulk::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.get(), stkBulk,onlyFine);
}
else{
//TODO: Does it make sense for actuator point search to have onlyFine option?
stk_search_act_pnts(actMeta.get(), stkBulk);
}
}


void
ActuatorBulk::zero_source_terms(stk::mesh::BulkData& stkBulk)
Expand Down
38 changes: 19 additions & 19 deletions src/aero/actuator/ActuatorBulkFAST.C
Original file line number Diff line number Diff line change
Expand Up @@ -247,50 +247,50 @@ ActuatorBulkFAST::init_epsilon(const ActuatorMetaFAST& actMeta)

void
ActuatorBulkFAST::stk_turbine_search(
const ActuatorMeta& actMeta, stk::mesh::BulkData& stkBulk, bool onlyFineSearch=False)
const ActuatorMeta& actMeta, stk::mesh::BulkData& stkBulk, bool onlyFine /* = false */)
{
//It seems point_centroids includes all actuator points across all turbines. TODO: Is that right?
//If so, we need to build a similar list here that will be of size numberofActuators
//that includes all hublocations. The search radius also needs to be of the same size

// create bounding sphere and element boxes based on turbine location and search radius
auto points = hubLocations_.template view<ActuatorFixedMemSpace>();

if (!onlyFine) {
// Loop over all turbines to initialize the search radius
turbineSearchRadius_.modify_host();
for (int iTurb = 0; iTurb < openFast_.get_nTurbinesGlob(); ++iTurb) {
// if my process contains the turbine?
// if my process contains the turbine
if (NaluEnv::self().parallel_rank() == openFast_.get_procNo(iTurb)) {
const int nbfp = openFast_.get_numForcePtsBlade(iTurb);

auto hubLoc = Kokkos::subview(actBulk_.hubLocations_, iTurb, Kokkos::ALL);
double turbineRadius = 0.0;
// Approximate turbine radius to define search radius
//
// TODO: is there an easier way to get this information. Is nbfp actually at the blade tip?
Point bladeTip = actuator_utils::get_fast_point(openFast_, iTurb, fast::BLADE, nbfp, 0);
double turbineRadius = 0.0;
for (int i = 0; i < 3; ++i) {
turbineRadius += std::pow(bladeTip[i] - hubLoc[i], 2.0);
}
turbineRadius = std::sqrt(turbineRadius);
searchRadius_.h_view(iTurb) = 1.25 * turbineRadius * std::sqrt(2);
/* const int nbfp = openFast_.get_numForcePtsBlade(iTurb); */
/* Point bladeTip = actuator_utils::get_fast_point(openFast_, iTurb, fast::BLADE, nbfp, 0); */
/* for (int i = 0; i < 3; ++i) { */
/* turbineRadius += std::pow(bladeTip[i] - hubLoc[i], 2.0); */
/* } */
//use the hub height as a surrogate for turbineRadius
turbineRadius = hubLoc[2] //TODO: 1 or 2?
turbineSearchRadius_.h_view(iTurb) = 1.25 * turbineRadius * std::sqrt(2); //TODO: Could switch to bounding boxes here instead

}
}
//TODO: Are we interacting with Kokkos views correctly?
actuator_utils::reduce_view_on_host(searchTurbineRadius_.view_host());
searchTurbineRadius_.sync_host();
actuator_utils::reduce_view_on_host(turbineSearchRadius_.view_host());
turbineSearchRadius_.sync_host();

// create bounding sphere and element boxes based on turbine location and search radius
auto points = hubLocations_.template view<ActuatorFixedMemSpace>();
auto radius = turbineSearchRadius_.template view<ActuatorFixedMemSpace>();

auto boundSpheres = CreateBoundingSpheres(points,radius);
auto elemBoxes = CreateElementBoxes(stkBulk, actMeta.searchTargetNames_);

// need conditional behavior for executing coarse or fine search
//

// the coarse search now associates element boxes with turbines
ExecuteCoarseSearch(
boundSpheres, elemBoxes, coarseSearchPointIds_, coarseSearchElemIds_,
actMeta.searchMethod_);
}

// The fine search may be slower now because the number of element boxes are much larger than needed.
// However, we don't need to do another fine search. If it's too slow, we could do a smaller fine search
Expand Down
7 changes: 2 additions & 5 deletions src/aero/actuator/ActuatorExecutorsFASTNgp.C
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ ActuatorLineFastNGP::operator()()
RunActFastUpdatePoints(actBulk_);

// Execute fine and coarse search given point centroids (see next slides)
// Do not need to update fine and coarse search when performing turbine level search
if !(actMeta_->turbineLevelSearch_) {
actBulk_.stk_search_act_pnts(actMeta_, stkBulk_); // this is the fine and coarse searching.
}
actBulk_.stk_search(actMeta_, stkBulk_); // this is the fine and coarse searching.

// call openfast and step
actBulk_.step_fast();
Expand Down Expand Up @@ -130,7 +127,7 @@ ActuatorDiskFastNGP::operator()()

actBulk_.update_ADM_points(actMeta_);

actBulk_.stk_search_act_pnts(actMeta_, stkBulk_);
actBulk_.stk_search(actMeta_, stkBulk_,true);
}

actBulk_.step_fast();
Expand Down
12 changes: 2 additions & 10 deletions src/aero/actuator/ActuatorModel.C
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,8 @@ ActuatorModel::init(stk::mesh::BulkData& stkBulk)
break;
#endif
#else

if (actMeta_->turbineLevelSearch_){
// perform turbine level search and cache to the bulk data
actBulk_->stk_turbine_search(*actMeta_.get(), stkBulk);
}
else{
// perform search for actline and actdisk
actBulk_->stk_search_act_pnts(*actMeta_.get(), stkBulk);
}

//perform stk_search (coarse + fine search)
actBulk_->stk_search(*actMeta_.get(), stkBulk);
break;
#endif
}
Expand Down

0 comments on commit 3542285

Please sign in to comment.