// Proto file representing hfss simulation setup settings 

syntax = "proto3";

package ansys.api.edb.v1;

import "ansys/api/edb/v1/edb_messages.proto";
import "ansys/api/edb/v1/simulation_setup.proto";

enum BasisFunctionOrder {
  ZERO_ORDER = 0;
  FIRST_ORDER = 1;
  SECOND_ORDER = 2;
  MIXED_ORDER = 3;
}

enum SolverType {
  AUTO_SOLVER = 0;
  DIRECT_SOLVER = 1;
  ITERATIVE_SOLVER = 2;
  NUM_SOLVER_TYPES = 3;
}

enum AdaptType
{
  SINGLE = 0;
  MULTI_FREQUENCIES = 1;
  BROADBAND = 2;
  NUM_ADAPT_TYPE = 3;
};

// General settings
service HFSSGeneralSettingsService {
  rpc GetSingleFrequencyAdaptiveSolution(EDBObjMessage) returns (SingleFrequencyAdaptiveSolutionMessage) {}
  rpc SetSingleFrequencyAdaptiveSolution(SingleFrequencyAdaptiveSolutionPropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetMultiFrequencyAdaptiveSolution(EDBObjMessage) returns (MultiFrequencyAdaptiveSolutionMessage) {}
  rpc SetMultiFrequencyAdaptiveSolution(MultiFrequencyAdaptiveSolutionPropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetBroadbandFrequencyAdaptiveSolution(EDBObjMessage) returns (BroadbandFrequencyAdaptiveSolutionMessage) {}
  rpc SetBroadbandFrequencyAdaptiveSolution(BroadbandFrequencyAdaptiveSolutionPropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetSaveFieldsFlag(EDBObjMessage) returns (google.protobuf.BoolValue) {}
  rpc SetSaveFieldsFlag(BoolPropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetUseMeshRegion(EDBObjMessage) returns (google.protobuf.BoolValue) {}
  rpc SetUseMeshRegion(BoolPropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetMeshRegionName(EDBObjMessage) returns (google.protobuf.StringValue) {}
  rpc SetMeshRegionName(StringPropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetUseParallelRefinement(EDBObjMessage) returns (google.protobuf.BoolValue) {}
  rpc SetUseParallelRefinement(BoolPropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetAdaptType(EDBObjMessage) returns (AdaptTypeMessage) {}
  rpc SetAdaptType(AdaptTypePropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetSaveRadFieldsOnlyFlag(EDBObjMessage) returns (google.protobuf.BoolValue) {}
  rpc SetSaveRadFieldsOnlyFlag(BoolPropertyMessage) returns (google.protobuf.Empty) {}
}

message AdaptTypeMessage {
  AdaptType adapt_type = 1;
}

message AdaptTypePropertyMessage {
  EDBObjMessage target = 1;
  AdaptType adapt_type = 2;
}

message AdaptiveFrequencyDataMessage {
  string adaptive_frequency = 1;
  string max_delta = 2;
}

message MatrixConvergenceDataMessage {
  bool all_are_constant = 1;
  bool all_diag_are_constant = 2;
  bool all_off_diag_are_constant = 3;
  double mag_min_threashold = 4;
  repeated MatrixConvergenceEntryMessage entries = 5;
}

message SingleFrequencyAdaptiveSolutionMessage {
  AdaptiveFrequencyDataMessage adaptive_frequency = 1;
  uint64 max_passes = 2;
  MatrixConvergenceDataMessage matrix_conv_data = 3;
  bool use_matrix_conv_data = 4;
}

message SingleFrequencyAdaptiveSolutionPropertyMessage {
  EDBObjMessage target = 1;
  SingleFrequencyAdaptiveSolutionMessage adaptive_frequency = 2;
}

message AdaptiveMultiFrequencyDataMessage {
  AdaptiveFrequencyDataMessage adaptive_frequency = 1;
  map<string, string> output_variables = 2;
}

message MultiFrequencyAdaptiveSolutionMessage {
  repeated AdaptiveMultiFrequencyDataMessage adaptive_frequencies = 1;
  uint64 max_passes = 2;
}

message MultiFrequencyAdaptiveSolutionPropertyMessage {
  EDBObjMessage	target = 1;
  MultiFrequencyAdaptiveSolutionMessage adaptive_frequency = 2;
}

message BroadbandFrequencyAdaptiveSolutionMessage {
  string max_delta = 1;
  uint64 max_passes = 2;
  string low_frequency = 3;
  string high_frequency = 4;
}

message BroadbandFrequencyAdaptiveSolutionPropertyMessage {
  EDBObjMessage	target = 1;
  BroadbandFrequencyAdaptiveSolutionMessage adaptive_frequency = 2;
}

// HFSS Options
service HFSSOptionsSettingsService {
  rpc GetMaxRefinementPerPass(EDBObjMessage) returns (google.protobuf.UInt64Value) {}
  rpc SetMaxRefinementPerPass(UInt64PropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetMinPasses(EDBObjMessage) returns (google.protobuf.UInt64Value) {}
  rpc SetMinPasses(UInt64PropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetMinConvergedPasses(EDBObjMessage) returns (google.protobuf.UInt64Value) {}
  rpc SetMinConvergedPasses(UInt64PropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetUseMaxRefinement(EDBObjMessage) returns (google.protobuf.BoolValue) {}
  rpc SetUseMaxRefinement(BoolPropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetBasisFunctionOrder(EDBObjMessage) returns (BasisFunctionOrderMessage) {}
  rpc SetBasisFunctionOrder(BasisFunctionOrderPropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetSolverTypeOrder(EDBObjMessage) returns (SolverTypeMessage) {}
  rpc SetSolverTypeOrder(SolverTypePropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetRelativeResidual(EDBObjMessage) returns (google.protobuf.DoubleValue) {}
  rpc SetRelativeResidual(DoublePropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetUseShellElements(EDBObjMessage) returns (google.protobuf.BoolValue) {}
  rpc SetUseShellElements(BoolPropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetEnhancedLowFrequencyAccuracy(EDBObjMessage) returns (google.protobuf.BoolValue) {}
  rpc SetEnhancedLowFrequencyAccuracy(BoolPropertyMessage) returns (google.protobuf.Empty) {}
}

message BasisFunctionOrderMessage {
  BasisFunctionOrder basis_function_order = 1;
}

message BasisFunctionOrderPropertyMessage {
  EDBObjMessage target = 1;
  BasisFunctionOrder basis_function_order = 2;
}

message SolverTypeMessage {
  SolverType solver_type = 1;
}

message SolverTypePropertyMessage {
  EDBObjMessage target = 1;
  SolverType solver_type = 2;
}

// HFSS Advanced
service HFSSAdvancedSettingsService {
  rpc GetICModeAutoResolution(EDBObjMessage) returns (google.protobuf.BoolValue) {}
  rpc SetICModeAutoResolution(BoolPropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetICModeLength(EDBObjMessage) returns (google.protobuf.StringValue) {}
  rpc SetICModeLength(StringPropertyMessage) returns (google.protobuf.Empty) {}
}

// HFSS Advanced Meshing
service HFSSAdvancedMeshingSettingsService {
  rpc GetLayerAlignment(EDBObjMessage) returns (google.protobuf.StringValue) {}
  rpc SetLayerAlignment(StringPropertyMessage) returns (google.protobuf.Empty) {}
}

// Solver settings
service HFSSSolverSettingsService {
  rpc GetMaxDeltaZ0(EDBObjMessage) returns (google.protobuf.DoubleValue) {}
  rpc SetMaxDeltaZ0(DoublePropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetSetTrianglesForWaveport(EDBObjMessage) returns (google.protobuf.BoolValue) {}
  rpc SetSetTrianglesForWaveport(BoolPropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetMinTrianglesForWavePort(EDBObjMessage) returns (google.protobuf.UInt64Value) {}
  rpc SetMinTrianglesForWavePort(UInt64PropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetMaxTrianglesForWavePort(EDBObjMessage) returns (google.protobuf.UInt64Value) {}
  rpc SetMaxTrianglesForWavePort(UInt64PropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetIntraPlaneCouplingEnabled(EDBObjMessage) returns (google.protobuf.BoolValue) {}
  rpc SetIntraPlaneCouplingEnabled(BoolPropertyMessage) returns (google.protobuf.Empty) {}
}

// HFSS DCR
service DCRSettingsService {
  rpc GetMaxPasses(EDBObjMessage) returns (google.protobuf.UInt64Value) {}
  rpc SetMaxPasses(UInt64PropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetMinPasses(EDBObjMessage) returns (google.protobuf.UInt64Value) {}
  rpc SetMinPasses(UInt64PropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetMinConvergedPasses(EDBObjMessage) returns (google.protobuf.UInt64Value) {}
  rpc SetMinConvergedPasses(UInt64PropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetPercentError(EDBObjMessage) returns (google.protobuf.DoubleValue) {}
  rpc SetPercentError(DoublePropertyMessage) returns (google.protobuf.Empty) {}

  rpc GetPercentRefinementPerPass(EDBObjMessage) returns (google.protobuf.DoubleValue) {}
  rpc SetPercentRefinementPerPass(DoublePropertyMessage) returns (google.protobuf.Empty) {}
}
