diff --git a/include/aero/actuator/ActuatorBulk.h b/include/aero/actuator/ActuatorBulk.h index fef601a10..3e3353017 100644 --- a/include/aero/actuator/ActuatorBulk.h +++ b/include/aero/actuator/ActuatorBulk.h @@ -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_; @@ -103,6 +102,7 @@ struct ActuatorBulk ActFixElemIds elemContainingPoint_; const int localTurbineId_; + bool singlePointCoarseSearch_ = false; }; } // namespace nalu diff --git a/include/aero/actuator/ActuatorFunctors.h b/include/aero/actuator/ActuatorFunctors.h index 22714e6f0..42b6a8b86 100644 --- a/include/aero/actuator/ActuatorFunctors.h +++ b/include/aero/actuator/ActuatorFunctors.h @@ -68,9 +68,6 @@ struct SpreadForceInnerLoop using SpreadActuatorForce = GenericLoopOverCoarseSearchResults; -using SpreadActuatorForceTurbineSearch = - GenericLoopOverCoarseTurbineSearchResults; - } /* namespace nalu */ } /* namespace sierra */ diff --git a/include/aero/actuator/ActuatorFunctorsFAST.h b/include/aero/actuator/ActuatorFunctorsFAST.h index c4d4157f6..fd926dc1a 100644 --- a/include/aero/actuator/ActuatorFunctorsFAST.h +++ b/include/aero/actuator/ActuatorFunctorsFAST.h @@ -164,14 +164,6 @@ using ActFastSpreadForceWhProjection = GenericLoopOverCoarseSearchResults< ActuatorBulkFAST, ActFastSpreadForceWhProjInnerLoop>; -using ActFastComputeThrustTurbineSearch = GenericLoopOverCoarseTurbineSearchResults< - ActuatorBulkFAST, - ActFastComputeThrustInnerLoop>; - -using ActFastSpreadForceWhProjectionTurbineSearch = GenericLoopOverCoarseTurbineSearchResults< - ActuatorBulkFAST, - ActFastSpreadForceWhProjInnerLoop>; - } /* namespace nalu */ } /* namespace sierra */ diff --git a/include/aero/actuator/ActuatorGenericSearchFunctor.h b/include/aero/actuator/ActuatorGenericSearchFunctor.h index 6354f4aa7..64a5098c6 100644 --- a/include/aero/actuator/ActuatorGenericSearchFunctor.h +++ b/include/aero/actuator/ActuatorGenericSearchFunctor.h @@ -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 @@ -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 @@ -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]); + } + } + } } @@ -136,6 +148,7 @@ struct GenericLoopOverCoarseSearchResults VectorFieldType* actuatorSource_; ScalarFieldType* dualNodalVolume_; functor innerLoopFunctor_; + //const size_t innerLoopExtent_; }; } // namespace nalu diff --git a/include/aero/actuator/ActuatorGenericTurbineSearchFunctor.h b/include/aero/actuator/ActuatorGenericTurbineSearchFunctor.h deleted file mode 100644 index cf97d7dcc..000000000 --- a/include/aero/actuator/ActuatorGenericTurbineSearchFunctor.h +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright 2017 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS), National Renewable Energy Laboratory, University of Texas Austin, -// Northwest Research Associates. Under the terms of Contract DE-NA0003525 -// with NTESS, the U.S. Government retains certain rights in this software. -// -// This software is released under the BSD 3-clause license. See LICENSE file -// for more details. -// -// Copyright 2017 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS), National Renewable Energy Laboratory, University of Texas Austin, -// Northwest Research Associates. Under the terms of Contract DE-NA0003525 -// with NTESS, the U.S. Government retains certain rights in this software. -// -// This software is released under the BSD 3-clause license. See LICENSE file -// for more details. -// -#ifndef ACTUATORGENERICTURBINESEARCHFUNCTOR_H_ -#define ACTUATORGENERICTURBINESEARCHFUNCTOR_H_ - -#include -#include -#include -#include - -namespace sierra { -namespace nalu { - -template - //coarse search actuatorbulk.c L96 -struct GenericLoopOverCoarseTurbineSearchResults -{ - using execution_space = ActuatorFixedExecutionSpace; - - // ctor if functor only requires actBulk for constructor - GenericLoopOverCoarseTurbineSearchResults( - ActuatorBulk& actBulk, stk::mesh::BulkData& stkBulk) - : actBulk_(actBulk), - stkBulk_(stkBulk), - coordinates_(stkBulk_.mesh_meta_data().template get_field( - stk::topology::NODE_RANK, "coordinates")), - actuatorSource_(stkBulk_.mesh_meta_data().template get_field( - stk::topology::NODE_RANK, "actuator_source")), - dualNodalVolume_(stkBulk_.mesh_meta_data().template get_field( - stk::topology::NODE_RANK, "dual_nodal_volume")), - innerLoopFunctor_(actBulk) - { - actBulk_.coarseSearchElemIds_.sync_host(); - actBulk_.coarseSearchPointIds_.sync_host(); - innerLoopFunctor_.preloop(); - } - - // ctor for functor constructor taking multiple args - GenericLoopOverCoarseTurbineSearchResults( - ActuatorBulk& actBulk, - stk::mesh::BulkData& stkBulk, - functor innerLoopFunctor) - : actBulk_(actBulk), - stkBulk_(stkBulk), - coordinates_(stkBulk_.mesh_meta_data().template get_field( - stk::topology::NODE_RANK, "coordinates")), - actuatorSource_(stkBulk_.mesh_meta_data().template get_field( - stk::topology::NODE_RANK, "actuator_source")), - dualNodalVolume_(stkBulk_.mesh_meta_data().template get_field( - stk::topology::NODE_RANK, "dual_nodal_volume")), - innerLoopFunctor_(innerLoopFunctor) - { - actBulk_.coarseSearchElemIds_.sync_host(); - actBulk_.coarseSearchPointIds_.sync_host(); - innerLoopFunctor_.preloop(); - } - - // see ActuatorExecutorFASTSngp.C line 58 - // index corresponds to turbines here - void operator()(int index) const - { - - auto pointId = actBulk_.coarseSearchPointIds_.h_view(index); - auto elemId = actBulk_.coarseSearchElemIds_.h_view(index); - - // get element topology - const stk::mesh::Entity elem = - stkBulk_.get_entity(stk::topology::ELEMENT_RANK, elemId); - const stk::topology& elemTopo = stkBulk_.bucket(elem).topology(); - MasterElement* meSCV = - MasterElementRepo::get_volume_master_element_on_host(elemTopo); - - // element number of nodes and integration points - const unsigned numNodes = stkBulk_.num_nodes(elem); - const int numIp = meSCV->num_integration_points(); - - // just allocate for largest expected size (hex27) - STK_ThrowAssert(numIp <= 216); - STK_ThrowAssert(numNodes <= 27); - - double scvip[216]; - double elemcoords[27 * 3]; - sierra::nalu::SharedMemView scvIp(&scvip[0], 216); - sierra::nalu::SharedMemView elemCoords(&elemcoords[0], 27, 3); - - stk::mesh::Entity const* elem_nod_rels = stkBulk_.begin_nodes(elem); - - // get element coordinates - for (unsigned i = 0; i < numNodes; i++) { - const double* coords = - stk::mesh::field_data(*coordinates_, elem_nod_rels[i]); - for (int j = 0; j < 3; j++) { - elemCoords(i, j) = coords[j]; - } - } - - meSCV->determinant(elemCoords, scvIp); - - // relationship of element nodes to integration points - const auto* ipNodeMap = meSCV->ipNodeMap(); - - // loop over integration points - for (int nIp = 0; nIp < numIp; nIp++) { - const int nodeIndex = ipNodeMap[nIp]; - stk::mesh::Entity node = elem_nod_rels[nodeIndex]; - const double* nodeCoords = stk::mesh::field_data(*coordinates_, node); - const double dual_vol = *stk::mesh::field_data(*dualNodalVolume_, node); - double* sourceTerm = stk::mesh::field_data(*actuatorSource_, node); - - // anything else that is required should be stashed on the functor - // during functor construction i.e. ActuatorBulk, flags, ActuatorMeta, - // etc. - // - // loop over actuator points. Don't need to change innerLoopFunctors - for (int actPtInd = 0; actPtInd < actBulk_.pointCentroid_.extent(0); actPtInd ++){ - innerLoopFunctor_(actPtInd, nodeCoords, sourceTerm, dual_vol, scvIp[nIp]); - } - } - } - - ActuatorBulk& actBulk_; - stk::mesh::BulkData& stkBulk_; - VectorFieldType* coordinates_; - VectorFieldType* actuatorSource_; - ScalarFieldType* dualNodalVolume_; - functor innerLoopFunctor_; -}; - -} // namespace nalu -} // namespace sierra - -#endif /* ACTUATORGENERICTURBINESEARCHFUNCTOR_H_ */ - diff --git a/src/aero/actuator/ActuatorBulkFAST.C b/src/aero/actuator/ActuatorBulkFAST.C index 61ca8a1d9..356f58c9e 100644 --- a/src/aero/actuator/ActuatorBulkFAST.C +++ b/src/aero/actuator/ActuatorBulkFAST.C @@ -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); + } } diff --git a/src/aero/actuator/ActuatorExecutorsFASTNgp.C b/src/aero/actuator/ActuatorExecutorsFASTNgp.C index 80a38eedc..f82c43657 100644 --- a/src/aero/actuator/ActuatorExecutorsFASTNgp.C +++ b/src/aero/actuator/ActuatorExecutorsFASTNgp.C @@ -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_); diff --git a/src/aero/actuator/ActuatorFunctors.C b/src/aero/actuator/ActuatorFunctors.C index ca55f0003..7065a34d9 100644 --- a/src/aero/actuator/ActuatorFunctors.C +++ b/src/aero/actuator/ActuatorFunctors.C @@ -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; + } } }