using FeMM.Common.Helpers;
using FeMM.Common.Models;
using FeMM.Grasshopper.DataTypes.FeMM;
using FeMM.Grasshopper.Helpers;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Parameters;
using System;
using System.Collections.Generic;
namespace FeMM.Grasshopper.Components.Functions
{
public class ModalRitzLoadComponent : GH_Component
{
/// <summary>
/// Initializes a new instance of the SuperElementComponent class.
/// </summary>
public ModalRitzLoadComponent()
: base("Modal Ritz Load", "MRL", "Defines modal ritz acceleration load in SAP", CategoryNameConstants.CATEGORY_FEMM, CategoryNameConstants.SUBCATEGORY_DEFINITIONS)
{
}
/// <summary>
/// Registers all the input parameters for this component.
/// </summary>
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
int i = pManager.AddIntegerParameter("Load Direction", "LD", "This is an array that includes UX, UY, UZ, RX, RY or RZ, indicating the direction of the load", GH_ParamAccess.item);
Param_Integer type_param = (Param_Integer)pManager[i];
Array values = Enum.GetValues(typeof(ModalTargetLoadModel.LoadDirections));
foreach (ModalTargetLoadModel.LoadDirections val in values)
type_param.AddNamedValue(val.GetDescription(), (int)val);
pManager.AddIntegerParameter("Target Mass Participation Ratio", "TMP", "This is an array that includes the target mass participation ratio", GH_ParamAccess.item, 99);
pManager.AddIntegerParameter("Maximum number of Cycles ", "MC", "This is an array that includes the maximum number of generation cycles to be performed for the " +
"specified ritz starting vector. A value of 0 means there is no limit on the number of cycles", GH_ParamAccess.item, 0);
}
/// <summary>
/// Registers all the output parameters for this component.
/// </summary>
protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddGenericParameter("Ritz Modal", "RM", "The Ritz Modal", GH_ParamAccess.item);
}
/// <summary>
/// This is the method that actually does the work.
/// </summary>
/// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
protected override void SolveInstance(IGH_DataAccess DA)
{
int loadDirection = 0;
int targetMass = 0;
int ritzMaxCyc = 0;
if (!DA.GetData(0, ref loadDirection))
return;
DA.GetData(1, ref targetMass);
DA.GetData(2, ref ritzMaxCyc);
var data = new ModalTargetLoadModel()
{
Name = "",
LoadType = ModalTargetLoadModel.LoadTypes.Accel,
LoadDirection = (ModalTargetLoadModel.LoadDirections)loadDirection,
TagetMassParticipationRatio = targetMass,
RitzMaxCyc = ritzMaxCyc,
};
var gH_Function = new GH_FunctionDefinition(data);
Message = $"{data.LoadType.ToString()}: {data.LoadDirection.ToString()}";
DA.SetData(0, gH_Function);
}
public override GH_Exposure Exposure => GH_Exposure.tertiary;
/// <summary>
/// Provides an Icon for the component.
/// </summary>
protected override System.Drawing.Bitmap Icon => Properties.Resources.ModalRitzComponentIcon;
/// <summary>
/// Gets the unique ID for this component. Do not change this ID after release.
/// </summary>
public override Guid ComponentGuid => new("87da5254-e278-4f78-914e-26402daa051d");
}
}