VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
ActuatorFarmStandalone.h
Go to the documentation of this file.
1//=======================================================================================
2// ____ ____ __ ______ __________ __ __ __ __
3// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
4// \ \ | | | | | |_) | | | | | | | / \ | |
5// \ \ | | | | | _ / | | | | | | / /\ \ | |
6// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
7// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
8// \ \ | | ________________________________________________________________
9// \ \ | | | ______________________________________________________________|
10// \ \| | | | __ __ __ __ ______ _______
11// \ | | |_____ | | | | | | | | | _ \ / _____)
12// \ | | _____| | | | | | | | | | | \ \ \_______
13// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
14// \ _____| |__| |________| \_______/ |__| |______/ (_______/
15//
16// This file is part of VirtualFluids. VirtualFluids is free software: you can
17// redistribute it and/or modify it under the terms of the GNU General Public
18// License as published by the Free Software Foundation, either version 3 of
19// the License, or (at your option) any later version.
20//
21// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
22// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24// for more details.
25//
26// SPDX-License-Identifier: GPL-3.0-or-later
27// SPDX-FileCopyrightText: Copyright © VirtualFluids Project contributors, see AUTHORS.md in root folder
28//
32#ifndef ActuatorFarmStandalone_H
33#define ActuatorFarmStandalone_H
34
35#include "ActuatorFarm.h"
36#include "basics/DataTypes.h"
37
38namespace vf::gpu {
39
41{
42public:
44 const uint numberOfPointsPerBlade, const std::vector<real>& turbinePositionsX,
45 const std::vector<real>& turbinePositionsY, const std::vector<real>& turbinePositionsZ,
46 const std::vector<real>& rotorSpeeds, const real smearingWidth, const int level,
47 const std::optional<HubConfig>& hubConfig = std::nullopt,
48 const std::optional<TowerConfig>& towerConfig = std::nullopt,
49 const std::optional<FloatingConfig>& floatingConfig = std::nullopt,
50 const std::optional<real> hubDragCoeff = std::nullopt,
51 const std::optional<real> hubSkinFrictionCoeff = std::nullopt,
52 const std::optional<real> towerDragCoeff = std::nullopt,
53 const uint numberOfBlades = 3,
54 const std::optional<std::vector<real>>& bladeNormalCoefficients = std::nullopt)
55 : rotorSpeeds(rotorSpeeds),
56 hubDragCoeff(hubDragCoeff),
57 hubSkinFrictionCoeff(hubSkinFrictionCoeff),
58 towerDragCoeff(towerDragCoeff),
59 bladeNormalCoefficients(bladeNormalCoefficients),
63 {
64 if (numberOfTurbines != rotorSpeeds.size())
65 throw std::runtime_error("ActuatorFarmStandalone::ActuatorFarmStandalone: rotor speeds need to have same length "
66 "as turbine positions!");
67 if (bladeNormalCoefficients.has_value() && bladeNormalCoefficients->size() != numberOfPointsPerBlade)
68 throw std::runtime_error("ActuatorFarmStandalone::ActuatorFarmStandalone: bladeNormalCoefficients need to have "
69 "same length as numberOfPointsPerBlade.");
70
71 if (numberOfTowerPointsPerTurbine > 0 && !towerDragCoeff.has_value())
72 throw std::runtime_error(
73 "Tower geometry is defined (tower points per turbine > 0), but towerDragCoeff is not provided!");
74
76 {
77 if (!hubDragCoeff.has_value())
78 throw std::runtime_error(
79 "Hub geometry is defined (hub points per turbine > 0), but hubDragCoeff is not provided!");
80
81 if (!hubSkinFrictionCoeff.has_value())
82 throw std::runtime_error("Hub geometry is defined (hub points per turbine > 0), but hubSkinFrictionCoeff is "
83 "not provided!");
84 }
85
86 if (towerDragCoeff.has_value() && towerDragCoeff.value() > 0.0 && numberOfTowerPointsPerTurbine == 0)
87 VF_LOG_WARNING("towerDragCoeff > 0 was provided, but no tower points per turbine exist → no tower forces will be applied.");
88
89 if (hubDragCoeff.has_value() && hubDragCoeff.value() > 0.0 && numberOfHubPointsPerTurbine == 0)
90 VF_LOG_WARNING("hubDragCoeff > 0 was provided, but no hub points per turbine exist → no hub forces will be applied.");
91
92 if (hubSkinFrictionCoeff.has_value() && hubSkinFrictionCoeff.value() > 0.0 && numberOfHubPointsPerTurbine == 0)
93 VF_LOG_WARNING("hubSkinFrictionCoeff > 0 was provided, but no hub points per turbine exist → no hub forces will be applied.");
94
95 if (numberOfTowerPointsPerTurbine > 0 && towerDragCoeff.has_value() && towerDragCoeff.value() == 0.0)
96 VF_LOG_WARNING("towerDragCoeff is set to 0 → no tower drag forces will be applied despite existing tower geometry.");
97
99 {
100 if (hubDragCoeff.has_value() && hubDragCoeff.value() == 0.0)
101 VF_LOG_WARNING("hubDragCoeff is set to 0 → no hub drag forces will be applied despite existing hub geometry.");
102
103 if (hubSkinFrictionCoeff.has_value() && hubSkinFrictionCoeff.value() == 0.0)
104 VF_LOG_WARNING("hubSkinFrictionCoeff is set to 0 → no hub skin friction forces will be applied despite existing hub geometry.");
105 }
106
107 VF_LOG_INFO("rotor speed [rad/s] = {}", this->rotorSpeeds[0]);
108
110 VF_LOG_INFO("tower drag coefficient = {}", this->towerDragCoeff.value());
111
113 {
114 VF_LOG_INFO("hub drag coefficient = {}", this->hubDragCoeff.value());
115 VF_LOG_INFO("hub skin friction coefficient = {}", this->hubSkinFrictionCoeff.value());
116 }
117
118 }
119
120 // ActuatorFarmStandalone(SPtr<Parameter> para, SPtr<CudaMemoryManager> cudaMemoryManager, const real diameter,
121 // const uint numberOfPointsPerBlade, const std::vector<real>& turbinePositionsX,
122 // const std::vector<real>& turbinePositionsY, const std::vector<real>& turbinePositionsZ,
123 // const std::vector<real>& rotorSpeeds, const real smearingWidth, const int level,
124 // const uint numberOfBlades,
125 // const std::optional<HubConfig>& hubConfig = std::nullopt,
126 // const std::optional<TowerConfig>& towerConfig = std::nullopt,
127 // const std::optional<real> hubDragCoeff = std::nullopt,
128 // const std::optional<real> hubSkinFrictionCoeff = std::nullopt,
129 // const std::optional<real> towerDragCoeff = std::nullopt)
130 // : ActuatorFarmStandalone(std::move(para), std::move(cudaMemoryManager), diameter, numberOfPointsPerBlade,
131 // turbinePositionsX, turbinePositionsY, turbinePositionsZ, rotorSpeeds, smearingWidth,
132 // level, hubConfig, towerConfig, hubDragCoeff, hubSkinFrictionCoeff, towerDragCoeff,
133 // numberOfBlades)
134 // {
135 // }
136
137 ~ActuatorFarmStandalone() override = default;
138
139 void updateForcesAndCoordinates(real time, real deltaT) override;
141
142private:
143 void updateBladeForcesAndCoordinates(real deltaT);
144 void updateHubForces();
145 void updateTowerForces();
146 std::vector<real> rotorSpeeds;
147 std::optional<real> hubDragCoeff;
148 std::optional<real> hubSkinFrictionCoeff;
149 std::optional<real> towerDragCoeff;
150 std::optional<std::vector<real>> bladeNormalCoefficients;
151};
152
153}
154
155#endif
156
#define VF_LOG_INFO(...)
Definition Logger.h:50
#define VF_LOG_WARNING(...)
Definition Logger.h:51
const uint numberOfTowerPointsPerTurbine
const uint numberOfHubPointsPerTurbine
const uint numberOfPointsPerBlade
const uint numberOfTurbines
static std::vector< real > computeBladeRadii(real diameter, uint numberOfPointsPerBlade)
ActuatorFarmStandalone(SPtr< Parameter > para, SPtr< CudaMemoryManager > cudaMemoryManager, const real diameter, const uint numberOfPointsPerBlade, const std::vector< real > &turbinePositionsX, const std::vector< real > &turbinePositionsY, const std::vector< real > &turbinePositionsZ, const std::vector< real > &rotorSpeeds, const real smearingWidth, const int level, const std::optional< HubConfig > &hubConfig=std::nullopt, const std::optional< TowerConfig > &towerConfig=std::nullopt, const std::optional< FloatingConfig > &floatingConfig=std::nullopt, const std::optional< real > hubDragCoeff=std::nullopt, const std::optional< real > hubSkinFrictionCoeff=std::nullopt, const std::optional< real > towerDragCoeff=std::nullopt, const uint numberOfBlades=3, const std::optional< std::vector< real > > &bladeNormalCoefficients=std::nullopt)
~ActuatorFarmStandalone() override=default
void updateForcesAndCoordinates(real time, real deltaT) override
SPtr< CudaMemoryManager > cudaMemoryManager
std::shared_ptr< T > SPtr
float real
Definition DataTypes.h:42
unsigned int uint
Definition DataTypes.h:47