Skip to content

Instantly share code, notes, and snippets.

@selimb
Created August 12, 2015 19:02
Show Gist options
  • Save selimb/9ec1a723a46fdbccba3a to your computer and use it in GitHub Desktop.
Save selimb/9ec1a723a46fdbccba3a to your computer and use it in GitHub Desktop.
public void DoIt()
{
NXOpen.CAE.Iteration iteration;
NXOpen.CAE.BaseResultType[] resultTypes;
NXOpen.CAE.BaseResultType velocity, shStress, turbEnergy, turbDiss;
// NXOpen.CAE.Result.Quantity qtt;
iteration = (Iteration)this.solutionResult.GetLoadcases()[0].GetIterations()[0];
resultTypes = iteration.GetResultTypes();
foreach (NXOpen.CAE.BaseResultType resultType in resultTypes)
{
// this.WriteLine("Result Type: " + resultType.ToString());
// this.WriteLine("Quantity: " + resultType.Quantity.ToString());
if (resultType.Quantity == QTT.Velocity)
{
this.CreateVelocityGraph(resultType);
}
if (resultType.Quantity == QTT.ShearStressOnPositiveSide)
{
this.CreateShStressGraph(resultType);
}
if (resultType.Quantity == QTT.TurbulenceEnergy)
{
this.CreateTurbEnergyGraph(resultType);
}
if (resultType.Quantity == QTT.TurbulentSpecificDissipation)
{
this.CreateTurbDissGraph(resultType);
}
}
}
private void CreateVelocityGraph(NXOpen.CAE.BaseResultType resultType)
{
NXOpen.CAE.CaeGroup groupe;
NXOpen.CAE.ResultParameters resultParams;
NXOpen.CAE.PostGraph postGraph;
NXOpen.Point3d origin, unitVector;
this.WriteLine("Creating Velocity Profile...");
origin = new NXOpen.Point3d(0.0, 0.0, 0.0);
unitVector = new NXOpen.Point3d(0.0, 0.0, 1.0);
groupe = this.GetGroupByName("x097");
resultParams = this.resultMgr.CreateResultParameters();
resultParams.SetResultComponent(NXOpen.CAE.Result.Component.X);
resultParams.SetGenericResultType(resultType);
resultParams.SetUnit(this.unitCollection.GetBase("Velocity"));
string title = "Velocity profile";
this.WriteLine(" Graph Title: " + title);
this.WriteLine(" Unit: " + resultParams.GetUnit().Abbreviation);
postGraph = (NXOpen.CAE.PostGraph)this.CreateGraph(
resultParams,
title,
origin,
unitVector,
groupe
);
}
private void CreateShStressGraph(NXOpen.CAE.BaseResultType resultType)
{
NXOpen.CAE.CaeGroup groupe;
NXOpen.CAE.ResultParameters resultParams;
NXOpen.CAE.PostGraph postGraph;
NXOpen.Point3d origin, unitVector;
this.WriteLine("Creating Shear Stress on +ve side Graph...");
origin = new NXOpen.Point3d(0.0, 0.0, 0.0);
unitVector = new NXOpen.Point3d(1.0, 0.0, 0.0);
groupe = this.GetGroupByName("PlateCenter");
resultParams = this.resultMgr.CreateResultParameters();
resultParams.SetGenericResultType(resultType);
resultParams.SetResultComponent(NXOpen.CAE.Result.Component.Scalar);
resultParams.SetUnit(this.unitCollection.GetBase("Stress"));
this.WriteLine(" Unit: " + resultParams.GetUnit().Abbreviation);
string title = "Shear Stress on wall";
this.WriteLine(" Title: " + title);
postGraph = (NXOpen.CAE.PostGraph)this.CreateGraph(
resultParams,
title,
origin,
unitVector,
groupe
);
}
private void CreateTurbEnergyGraph(NXOpen.CAE.BaseResultType resultType)
{
NXOpen.CAE.CaeGroup groupe;
NXOpen.CAE.ResultParameters resultParams;
NXOpen.CAE.PostGraph postGraph;
NXOpen.Point3d origin, unitVector;
this.WriteLine("Creating Turbulence Energy Graph...");
origin = new NXOpen.Point3d(0.0, 0.0, 0.0);
unitVector = new NXOpen.Point3d(0.0, 0.0, 1.0);
groupe = this.GetGroupByName("x097");
resultParams = this.resultMgr.CreateResultParameters();
resultParams.SetGenericResultType(resultType);
resultParams.SetResultComponent(NXOpen.CAE.Result.Component.Scalar);
resultParams.SetUnit(
this.unitCollection.GetBase("Energy per Unit Mass")
);
// Testing
NXOpen.CAE.ResultAccess resAc = this.resultMgr.CreateResultAccess(this.solutionResult, resultParams);
this.resultMgr.DeleteResultAccess(resAc);
// Testing
this.WriteLine(" Unit: " + resultParams.GetUnit().Abbreviation);
string title = "Turbulence energy profile";
this.WriteLine(" Title: " + title);
postGraph = (NXOpen.CAE.PostGraph)this.CreateGraph(
resultParams,
title,
origin,
unitVector,
groupe
);
}
private void CreateTurbDissGraph(NXOpen.CAE.BaseResultType resultType)
{
NXOpen.CAE.CaeGroup groupe;
NXOpen.CAE.ResultParameters resultParams;
NXOpen.CAE.PostGraph postGraph;
NXOpen.Point3d origin, unitVector;
this.WriteLine("Creating Turbulence Dissipation Graph...");
origin = new NXOpen.Point3d(0.0, 0.0, 0.0);
unitVector = new NXOpen.Point3d(0.0, 0.0, 1.0);
groupe = this.GetGroupByName("x097");
resultParams = this.resultMgr.CreateResultParameters();
resultParams.SetGenericResultType(resultType);
resultParams.SetResultComponent(NXOpen.CAE.Result.Component.Scalar);
resultParams.SetUnit(this.unitCollection.GetBase("Frequency"));
this.WriteLine(" Unit: " + resultParams.GetUnit().Abbreviation);
string title = "Turbulence Dissipation Profile";
this.WriteLine(" Title: " + title);
postGraph = (NXOpen.CAE.PostGraph)this.CreateGraph(
resultParams,
title,
origin,
unitVector,
groupe
);
}
@micampbell
Copy link

thanks for getting back to me. I'll have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment