Skip to content

Commit

Permalink
Rebase Multiphase_Dev and add VOF overset dpdx improvements (#1239)
Browse files Browse the repository at this point in the history
* Add Timers for FSI (#1221)

* Add Timers for FSI

* Style

* Add FSI section to Input File docs. (#1220)

* Add FSI section to Input File docs.

* Updating the FSI docs to incorporate PR comments.

* Relax projection for FSI mapping to account for curvature (#1223)

* Relax projection for FSI mapping to account for curvature

* Style

* Format again

* Add option to dump mesh on failed jacobian check (#1226)

* Add option to dump mesh on failed jacobian check

* Style

* Cleaner, parallel consistent impl

* Correctly set current_coordinates for restart (#1227)

* Actually set current_coordinates for restart

* Remove redundant call updating displacements

* Revert "Remove redundant call updating displacements"

This reverts commit dca015c.

* Fix restart issue for FSI simulations (#1228)

---------

Co-authored-by: Ganesh Vijayakumar <[email protected]>

* Update FieldRegistry.h (#1229)

missing std::.

* FSI: Set ramping defaults to false (#1231)

* FSI: Set ramping defaults to false

Since we are moving to split meshes as the current strategy setting
ramping defaults to `False`.

I have been investigating why the temporal ramping is causing
simulations to fail since the bug fixes regarding hub motion, and I
can't find any issues with it at the moment. So it seems best to keep
that turned off as well.

* Update real defaults

* add a string-function temperature IC/dirichlet bc (#1198)

* add a string-function temperature IC/dirichlet bc

* undo stk deprecation fixes

---------

Co-authored-by: psakievich <[email protected]>

* Converted to the new STK simple_fields workflow (#1233)

STK is migrating to a new strategy for registering and managing
Fields, where sizing information is purely specified at run-time
instead of the previous technique of specifying it in a confusing
blend of both compile-time and run-time information.  The compile-time
specification was just a suggestion, as it could be overridden
(possibly inconsistently) at run-time to support variable-length
Fields.  This made it unclear what the true size of a Field was
and where it should be specified.

As an example, registering a vector field on the entire mesh
previously looked like this:

  using VectorField = stk::mesh::Field<double, stk::mesh::Cartesian3d>;
  VectorField & field = meta.declare_field<VectorField>(stk::topology::NODE_RANK, "velocity");
  stk::mesh::put_field_on_mesh(field, meta.universal_part(), 3, nullptr);

and now, it looks like this:

  using VectorField = stk::mesh::Field<double>;
  VectorField & field = meta.declare_field<double>(stk::topology::NODE_RANK, "velocity");
  stk::mesh::put_field_on_mesh(field, meta.universal_part(), 3, nullptr);

  stk::io::set_field_output_type(field, stk::io::FieldOutputType::VECTOR_3D); // Optional

The only template parameter for a Field is now the datatype parameter.
Sizing information now exclusively comes from put_field_on_mesh() calls.
The optional set_field_output_type() function call registers with the
IO sub-system how a multi-component Field should be subscripted in
Exodus files.  If this call is left off, you will get the default
[_1, _2, _3] subscripting.  With the above call, you will instead get
[_x, _y, _z] subscripting.

The MetaData::use_simple_fields() flag is set everywhere possible in
the code to prevent accidental regressions before the old behavior
is formally deprecated and removed.  This will yield a run-time error
if the old-style extra template parameters are used anywhere.  These
calls to use_simple_fields() can be removed in the future once the
STK Mesh back-end has removed support for the old behavior.

This wasn't a completely straightforward conversion due to nalu-wind
making heavy use of various algorithm selections based on the
templated Field type.  The ScalarFieldType, VectorFieldType,
TensorFieldType, and GenericFieldType types are now all identical,
so different techniques had to be used to switch behaviors.

* Fixes errors in ghosting update for some overset mesh problems. (#1214)

Instead of trying to modify the ghosting for overset problems with
relative motion, we now just rebuild the ghosting from scratch.
This appears to fix errors such as those reported in #936

Co-authored-by: dcdemen <[email protected]>
Co-authored-by: psakievich <[email protected]>

* Revert "Converted to the new STK simple_fields workflow (#1233)" (#1234)

This reverts commit 8e8f4d5.

* Fixed the iblank inconsistency at shared nodes. The iblank field is returned to Tioga after the stk::mesh::copy_owned_to_shared operation, prior to field interpolation (#1238)

* Multiphase milestone (#1222)

* Divide through by density to get velocity form

* Fix VOF velocity flux to finalize

* Fix missing pressure gradient density norm and sharpen interfaces more

* Add diffusion term to VOF

* center droplet and provide velocity

* first version of sloshing tank

* sloshing tank case, can change parameters

* Mass-momentum consistency with initial vel scale and diffusion values

* Remove unused forced mass flux from pressure equation

* clean-up and safe settings for VOF advection

* Density face definition for minimized buoyancy noise

* rho_ref == initial density

* Change initial density to a specified function and introduce wall bcs for VOF

* sloshing tank pressure profile

* user function for generic flat water level in z

* Cleaning

* Balanced Buoyancy Forcing

* Complete milestone implementation

* Full implementation with fixed testing

* Fix allocation of fields

* Formatting

* Documentation of VOF advection scheme

---------

Co-authored-by: whorne <[email protected]>
Co-authored-by: Michael Kuhn <[email protected]>

* Rebase and pressure gradient improvements for VOF

* Fixed interface width work

* Allow slip of VOF at wall bcs

---------

Co-authored-by: psakievich <[email protected]>
Co-authored-by: neilmatula <[email protected]>
Co-authored-by: Ganesh Vijayakumar <[email protected]>
Co-authored-by: 四月是你的谎言 <[email protected]>
Co-authored-by: rcknaus <[email protected]>
Co-authored-by: djglaze <[email protected]>
Co-authored-by: ddement <[email protected]>
Co-authored-by: dcdemen <[email protected]>
Co-authored-by: Jon Rood <[email protected]>
Co-authored-by: itopcuoglu <[email protected]>
Co-authored-by: whorne <[email protected]>
Co-authored-by: Michael Kuhn <[email protected]>
  • Loading branch information
13 people authored Apr 30, 2024
1 parent 70f05e8 commit 003056d
Show file tree
Hide file tree
Showing 50 changed files with 1,532 additions and 230 deletions.
Binary file added docs/source/user/nalu_run/figures/ramp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
267 changes: 267 additions & 0 deletions docs/source/user/nalu_run/nalu_inp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,273 @@ Time-step Control Options

.. include:: ./turbine_modeling.rst

Fluid-Structure Interaction
```````````````````````````

.. inpfile:: openfast_fsi

The ``openfast_fsi`` subsection defines parameters used when
coupling with openfast for FSI simulations. A sample section
is shown below.

.. code-block:: yaml
openfast_fsi:
n_turbines_glob: 1
debug: False
sim_start: trueRestart
t_start: 4.958677685950414
t_max: 600.55
n_checkpoint: 1440
dt_FAST: 0.0008608815426997245
Turbine0:
turbine_base_pos: [1800, 1800, 0]
turbine_hub_pos: [1795, 1800, 90]
restart_filename: "nrel5mw.5760"
sim_type: "ext-loads"
blade_parts:
- ["blade1-HEX"]
- ["blade2-HEX"]
- ["blade3-HEX"]
blade_boundary_parts:
- ["blade1"]
- ["blade2"]
- ["blade3"]
az_blend_mean: 18.84955592 # radians
az_blend_delta: 1.570796327 # radians
vel_mean: 11.4
wind_dir: 240.0 # degrees
z_ref: 90.0
shear_exp: 0.0
deflection_ramping:
enable_temporal_ramping: true
enable_theta_ramping: false
enable_span_ramping: false
span_ramp_distance: 4.0
temporal_ramp_start: 0.0
temporal_ramp_end: 0.5
theta_ramp_span: 30.0 # degrees
zero_theta_ramp_angle: 58.0 # degrees
.. inpfile:: n_turbines_glob

An integer indicating the total number of turbines to be used with FSI.

.. inpfile:: debug

A boolean flag that controls additional checks and printing of
additional information, which is helpful when troubleshooting a
simulation.

.. inpfile:: sim_start

String indicating how OpenFAST should start. For FSI
simulations, we suggest that the user set this to
``trueRestart`` (no quotes).

.. inpfile:: t_start

The start time of the FSI simulation. This should be an
integer multiple of ``dt_FAST``, and should match ``t_end``
in the OpenFAST driver file. Note that OpenFAST and
Nalu-Wind record time differently, so this variable will
not necessarily fit with the parameters in the
``Time_Integrators`` section.

.. inpfile:: t_max

The FSI simulation will end if the simulation time exceeds
this value.

.. inpfile:: n_checkpoint

An integer indicating the frequency with which checkpoint files
will be written. That is, a checkpoint will be written every
``n_checkpoint`` timesteps. Commonly this is set to correspond
to the number of steps in one rotor revolution.

.. inpfile:: dt_FAST

The timestep used by OpenFAST for the FSI simulation. This should
match ``DT`` in the OpenFAST input file (with extension .fst).
Commonly, this is 1/4 of the driver/Nalu/AMR-Wind timestep.

.. inpfile:: turbine_name

This subsection includes parameters for a particular turbine. Any
name may be provided by the user. In the above example, the name
``Turbine0`` was provided. In the following, any variable appearing
in this subsection will be denoted ``turbine_name.variable_name`` for
clarity, but only the variable name should be included in the input
file.

.. inpfile:: turbine_name.turbine_base_pos

Real vector indicating the location of the base of the tower.
This should match the variable with the same name in the OpenFAST
driver input file (with extension .yaml).

.. inpfile:: turbine_name.turbine_hub_pos

Real vector indicating the location of the hub.
This should match the variable with the same name in the OpenFAST
driver input file (with extension .yaml). Note that any height
change due to rotor tilt should be included in this variable, but
the effect of yaw should not be included.

.. inpfile:: turbine_name.restart_filename

String indicating the OpenFAST checkpoint file
that the FSI simulation will start from. Do not include the
extension (.chkp). This variable will have the format
``"name.integer"``, where the ``integer`` is the number of steps taken
in the OpenFAST standalone simulation. This should be equal to
``t_end`` divided by ``dt_FAST`` from the OpenFAST standalone run.

.. inpfile:: turbine_name.sim_type

String indicating the type of OpenFAST simulation.
For FSI simulations, this should always be set to ``"ext-loads"``.

.. inpfile:: turbine_name.blade_parts

List of strings indicating the mesh element blocks
corresponding to each of the blades.

.. inpfile:: turbine_name.tower_parts

List of strings indicating the mesh element blocks
corresponding to the tower.

.. inpfile:: turbine_name.blade_boundary_parts

List of strings indicating the mesh sidesets
corresponding to the wall boundaries of each of the blades.

.. inpfile:: turbine_name.tower_boundary_parts

List of strings indicating the mesh sidesets
corresponding to the wall boundaries of the tower.

.. inpfile:: turbine_name.az_blend_mean

Real variable (in radians) indicating the mean angular position for the load blending.
The loads provided to BeamDyn are a weighted average of the loads
provided by AeroDyn and the true CFD loads provided by Nalu-Wind
during startup to help with stability while the CFD flow field develops around
the turbine structure.
The weight of the Nalu-Wind contribution takes the form
:math:`\frac{1}{2} \left[1+\text{tanh}\left(\left(\phi-\phi_\text{mean}\right)/\phi_\text{delta}\right)\right]`,
where :math:`\phi` is the angle that the turbine has rotated through
(including any initial OpenFAST runs),
:math:`\phi_\text{mean}` is the value of ``az_blend_mean``, and
:math:`\phi_\text{delta}` is the value of ``az_blend_delta``.

.. inpfile:: turbine_name.az_blend_delta

Real variable (in radians) indicating the width for load blending.
See the entry for ``az_blend_mean`` above for a complete definition.

.. inpfile:: turbine_name.vel_mean

Real variable indicating the mean wind speed at height ``z_ref``. This
should correspond to the variable with the same name in the OpenFAST
driver input file (with extension .yaml).

.. inpfile:: turbine_name.wind_dir

Real variable indicating the angle of the incoming wind in degrees. The direction
the wind is heading is measured clockwise from South. For example, wind
heading South is 0 degrees, and wind heading East is 270 degrees. By convention,
the x-axis points East, and the y-axis points North.
This should match the variable with the same name in the OpenFAST driver input
file (with extension .yaml). If the turbine is intended to be aligned with
the flow, the ``NacYaw`` variable found in the OpenFAST Elastodyn file
should be 270 degrees minus ``wind_dir``. For example, if the wind is heading East,
``NacYaw`` will be 0 degrees.

.. inpfile:: turbine_name.z_ref

Real variable indicating the reference height at which ``vel_mean`` and
``wind_dir`` apply. Often corresponds to the hub height of the turbine.

.. inpfile:: turbine_name.shear_exp

Real variable indicating the exponent used in a power-law approximation
of the incoming ABL. This variable should match the variable with the same
name in the OpenFAST driver input file (with extension .yaml).

.. inpfile:: turbine_name.deflection_ramping

The ``deflection_ramping`` sub-subsection controls the temporal and spatial
ramping of blade deflections applied in Nalu-Wind. The temporal ramping enables a smooth
transition for the blades from a rigid body motion based on the hub motion to the
full blade deflections, and improves the stability of the simulation
during startup. The span ramping enables the root section
of the blades (which are typically circular) to remain undeformed. The theta ramping
improves the quality of the elements near the mesh interface between blades.
Note that the total deflection ramping factor will be the product of the temporal,
theta, and span ramping factors. This sub-subsection should be provided for each turbine.

.. inpfile:: deflection_ramping.enable_temporal_ramping

Boolean variable indicating whether temporal deflection ramping should be used.

.. inpfile:: deflection_ramping.enable_theta_ramping

Boolean variable indicating whether spatial deflection ramping with respect to
the circumferential direction should be used.

.. inpfile:: deflection_ramping.enable_span_ramping

Boolean variable indicating whether spatial deflection ramping with respect to
the spanwise direction should be used.

.. inpfile:: deflection_ramping.span_ramp_distance

Real variable indicating the distance from the root over which to ramp deflections
if ``enable_span_ramping`` is set to true. Distance is measured in the same units
as the mesh (meters in most cases).

.. inpfile:: deflection_ramping.temporal_ramp_start

Real variable indicating the time at which temporal ramping should begin.
Prior to this time, zero blade deflections will be provided. Note that this
should correspond to time as recorded by Nalu-Wind and described in the
``Time_Integrators`` section, not as recorded by OpenFAST. Hence, this will
not correspond to ``t_start`` above.

.. inpfile:: deflection_ramping.temporal_ramp_end

Real variable indicating the time at which temporal ramping should end.
After this time, full blade deflections will be provided. Note that this
should correspond to time as recorded by Nalu-Wind and described in the
``Time_Integrators`` section, not as recorded by OpenFAST.

.. inpfile:: deflection_ramping.theta_ramp_span

Real variable (in degrees) indicating the span of the circumferenial sector over which
theta ramping is applied. See Figure 1 for an explanation of the theta
ramping parameters, where :math:`\alpha` is the weight coefficient for the theta
ramping. The total deflection ramping is the product of the theta, span,
and temporal ramping.

.. figure:: figures/ramp.png
:align: center

Explanation of the theta ramping parameters.

.. inpfile:: deflection_ramping.zero_theta_ramp_angle

Real variable (in degrees) indicating the location of the beginning of the
circumferential sector over which no deflections are applied,
and the end of the sector over which deflections are ramped.
See Figure 1 for an explanation of the theta ramping parameters,
where :math:`\alpha` is the weight coefficient for the theta ramping.
The total deflection ramping is the product of the theta, span,
and temporal ramping.

Turbulence averaging
````````````````````
Expand Down
10 changes: 7 additions & 3 deletions include/EnthalpyEquationSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,14 @@ class EnthalpyEquationSystem : public EquationSystem
void initialize();
void reinitialize_linear_system();

virtual void register_initial_condition_fcn(
void register_initial_condition_fcn(
stk::mesh::Part* /* part */,
const std::map<std::string, std::string>& /* theNames */,
const std::map<std::string, std::vector<double>>& /* theParams */) final;

void register_initial_condition_string_function(
stk::mesh::Part* part,
const std::map<std::string, std::string>& theNames,
const std::map<std::string, std::vector<double>>& theParams);
const std::map<std::string, std::string>& func) final;

void predict_state();

Expand Down
1 change: 1 addition & 0 deletions include/Enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ enum UserDataType {
CONSTANT_UD = 0,
FUNCTION_UD = 1,
USER_SUB_UD = 2,
STRING_FUNCTION_UD = 3,
UserDataType_END
};

Expand Down
6 changes: 6 additions & 0 deletions include/EquationSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ class EquationSystem
{
}

virtual void register_initial_condition_string_function(
stk::mesh::Part* /*part*/,
const std::map<std::string, std::string>& /*func*/)
{
}

// rip through the propertyAlg_
virtual void evaluate_properties();

Expand Down
3 changes: 3 additions & 0 deletions include/EquationSystems.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ class EquationSystems
void register_initial_condition_fcn(
stk::mesh::Part* part, const UserFunctionInitialConditionData& fcnIC);

void register_initial_condition_string_function(
stk::mesh::Part* part, const std::map<std::string, std::string>& func);

void initialize();
void reinitialize_linear_system();
void populate_derived_quantities();
Expand Down
4 changes: 2 additions & 2 deletions include/FieldRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class FieldRegistry
if (fieldDefIter == db->end()) {
std::string message = "Attempting to access an undefined field: '" +
name + "' with spatial dimension " +
to_string(numDim) + " and number of states " +
to_string(numStates);
std::to_string(numDim) + " and number of states " +
std::to_string(numStates);
throw std::runtime_error(message);
}
return fieldDefIter->second;
Expand Down
9 changes: 9 additions & 0 deletions include/NaluParsing.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct UserData
std::map<std::string, std::string> userFunctionMap_;
std::map<std::string, std::vector<double>> functionParams_;
std::map<std::string, std::vector<std::string>> functionStringParams_;
std::map<std::string, std::string> functions;

// FIXME: must elevate temperature due to the temperature_bc_setup method
Temperature temperature_;
Expand Down Expand Up @@ -112,6 +113,7 @@ struct InflowUserData : public UserData
bool mixFracSpec_;
bool massFractionSpec_;
bool gammaSpec_;

InflowUserData()
: UserData(),
uSpec_(false),
Expand Down Expand Up @@ -362,6 +364,11 @@ struct UserFunctionInitialConditionData : public InitialCondition
std::map<std::string, std::vector<double>> functionParams_;
};

struct StringFunctionInitialConditionData : public InitialCondition
{
std::map<std::string, std::string> functions_;
};

inline bool
string_represents_positive_integer(std::string v)
{
Expand Down Expand Up @@ -477,6 +484,8 @@ void operator>>(const YAML::Node& node, NonConformalBoundaryConditionData& rhs);
void operator>>(const YAML::Node& node, ConstantInitialConditionData& rhs);

void operator>>(const YAML::Node& node, UserFunctionInitialConditionData& rhs);
void
operator>>(const YAML::Node& node, StringFunctionInitialConditionData& rhs);

void operator>>(const YAML::Node& node, std::map<std::string, bool>& mapName);
void operator>>(const YAML::Node& node, std::map<std::string, double>& mapName);
Expand Down
3 changes: 2 additions & 1 deletion include/Realm.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class Realm
void compute_vrtm(const std::string& = "velocity");
void compute_l2_scaling();
void output_converged_results();
void provide_output();
void provide_output(bool forcedOutput = false);
void provide_restart_output();

void register_interior_algorithm(stk::mesh::Part* part);
Expand Down Expand Up @@ -481,6 +481,7 @@ class Realm

// check if there are negative Jacobians
bool checkJacobians_;
bool outputFailedJacobians_;

// types of physics
bool isothermalFlow_;
Expand Down
1 change: 1 addition & 0 deletions include/SolutionOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class SolutionOptions

bool use_balanced_buoyancy_force_{false};
bool realm_has_vof_{false};
double interface_width_{-1.0};

double hybridDefault_;
double alphaDefault_;
Expand Down
Loading

0 comments on commit 003056d

Please sign in to comment.