我发现这些链接与我的问题相似。但是它们是作为插件的一部分运行的。
Standalone application with Petrel and Ocean
How to run a simulation case using CaseRunner function?
我的要求是调用Ocean Petrel API来运行eclipse并将结果返回到我的应用程序中。
有人有什么主意吗?
我已经检查了此链接,但这是作为插件的一部分而不是在Petrel之外运行的。
我尝试了以下代码。我在SimulationRoot上遇到空引用异常simroot = SimulationRoot.Get(PetrelProject.PrimaryProject);
class Program
{
static void Main(string[] args)
{
try
{
Case MyTest;
CustomCaseRunnerMonitor monit5 = new CustomCaseRunnerMonitor();
SimulationRoot simroot = SimulationRoot.Get(PetrelProject.PrimaryProject);
using (ITransaction trans = DataManager.NewTransaction())
{
trans.Lock(simroot);
MyTest = simroot.Cases.FirstOrDefault();
trans.Commit();
}
CaseRunner cRun = SimulationSystem.GetCaseRunner(MyTest);
cRun.Export();
cRun.Run(monit5);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message.ToString());
}
finally
{
Console.ReadKey();
}
}
}
public class CustomCaseRunnerMonitor : CaseRunnerMonitor
{
//...
public override void RunCompleted()
{
PetrelLogger.InfoOutputWindow("CustomCaseRunnerMonitor is completed!");
}
public override void RunAborted()
{
PetrelLogger.InfoOutputWindow("CustomCaseRunnerMonitor is abroted!");
}
public override void SimulationProgressChanged(int progress)
{
PetrelLogger.InfoOutputWindow("SimulationProgressChanged: " + progress);
}
}