Skip to content

Commit

Permalink
[.NET] debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Aug 13, 2024
1 parent 76343e3 commit b4b41a9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
5 changes: 3 additions & 2 deletions interfaces/dotnet/Cantera/src/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ static void LogToConsole(object? sender, LogMessageEventArgs e)
/// looking up the given name.
/// </summary>
public static ThermoPhase CreateThermoPhase(string filename,
string? phaseName = null) =>
new ThermoPhase(filename, phaseName);
string? phaseName = null,
string? transModel = null) =>
new ThermoPhase(filename, phaseName, transModel);
}
12 changes: 5 additions & 7 deletions interfaces/dotnet/Cantera/src/SpeciesCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ namespace Cantera;
/// </summary>
public class SpeciesCollection : IReadOnlyList<Species>
{
readonly SolutionHandle _sol;

readonly ThermoPhaseHandle _handle;

// this collection should be eagerly-initialized because it depends on interop
Expand Down Expand Up @@ -53,7 +51,7 @@ public unsafe double[] MassFractions
set
{
var retval = LibCantera.thermo_setMassFractions(_handle,
(nuint) value.Length, value, InteropConsts.True);
value.Length, value, InteropConsts.True);

InteropUtil.CheckReturn(retval);
}
Expand All @@ -72,7 +70,7 @@ public unsafe double[] MoleFractions
set
{
var retval = LibCantera.thermo_setMoleFractions(_handle,
(nuint) value.Length, value, InteropConsts.True);
value.Length, value, InteropConsts.True);

InteropUtil.CheckReturn(retval);
}
Expand All @@ -98,7 +96,7 @@ internal unsafe SpeciesCollection(ThermoPhaseHandle handle)
for (var i = 0; i < count; i++)
{
int getName(int length, byte* buffer) => LibCantera
.thermo_getSpeciesName(handle, (nuint) i, (nuint) length, buffer);
.thermo_getSpeciesName(handle, i, length, buffer);

var name = InteropUtil.GetString(10, getName);

Expand Down Expand Up @@ -261,7 +259,7 @@ int EnsureIndexOf(string name)
public void SetUnnormalizedMassFractions(double[] fractions)
{
var retval = LibCantera.thermo_setMassFractions(_handle,
(nuint) fractions.Length, fractions, InteropConsts.False);
fractions.Length, fractions, InteropConsts.False);

InteropUtil.CheckReturn(retval);
}
Expand All @@ -274,7 +272,7 @@ public void SetUnnormalizedMassFractions(double[] fractions)
public void SetUnnormalizedMoleFractions(double[] fractions)
{
var retval = LibCantera.thermo_setMoleFractions(_handle,
(nuint) fractions.Length, fractions, InteropConsts.False);
fractions.Length, fractions, InteropConsts.False);

InteropUtil.CheckReturn(retval);
}
Expand Down
4 changes: 2 additions & 2 deletions interfaces/dotnet/Cantera/src/ThermoPhase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ static ThermoPhase()

internal ThermoPhase(string filename, string? phaseName, string? transModel)
{
_sol = LibCantera.soln_newSolution(
var sol = LibCantera.soln_newSolution(
filename, phaseName ?? "", transModel ?? "default");
_handle = LibCantera.soln_thermo(_sol);
_handle = LibCantera.soln_thermo(sol);

Check failure on line 58 in interfaces/dotnet/Cantera/src/ThermoPhase.cs

View workflow job for this annotation

GitHub Actions / .NET on ubuntu-22.04

Cannot implicitly convert type 'int' to 'Cantera.Interop.ThermoPhaseHandle'

Check failure on line 58 in interfaces/dotnet/Cantera/src/ThermoPhase.cs

View workflow job for this annotation

GitHub Actions / .NET on ubuntu-22.04

Cannot implicitly convert type 'int' to 'Cantera.Interop.ThermoPhaseHandle'
_handle.EnsureValid();

_species = new(() => new SpeciesCollection(_handle));
Expand Down

0 comments on commit b4b41a9

Please sign in to comment.