unit BasicUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Spin, ComCtrls, ShellCtrls, DBCtrls, FileCtrl,
  Math, HCArrays, HCConduct, HCMaterial, HCModel, UPohMath, UPohStrConv;


function InitMat(var MatDtb: tMatDB; str:string):integer;
procedure ReadData(var DataFile:TextFile; var pom_temp: array of double; var n:integer);
procedure InitModel(var model:tHCModel; L:double; InitTemp:double; MatID:integer; max_volL:double);

const
  mm=0.001;
  Cel_Kel=273.15;

implementation

function InitMat(var MatDtb: tMatDB; str:string):integer;
begin
  fHC_Init(MatDtb);                                                                                 // material database initialization
	fHC_LoadMatDB(MatDtb, PChar(ExtractFilePath(Application.ExeName) + 'MaterialDB.TXT'));            // load material database
	fHC_Prepare(MatDtb);
  result := fHC_Find(MatDtb, PChar(str));
end;

procedure ReadData(var DataFile:TextFile; var pom_temp: array of double; var n:integer);
begin
  n:=-1;
  while not Eof(DataFile) do begin
    n:=n+1;
    Readln(DataFile, pom_temp[n]);
  end;
end;

procedure InitModel(var model:tHCModel; L:double; InitTemp:double; MatID:integer; max_volL:double);
begin
  fHC_Init(model);                                                                                  // model initialization
	fHC_SetModelAccuracy(0.01 * mm);
  fHC_Create1D(model, 0, L, InitTemp+Cel_Kel, MatID, 0);                                              // model definition
  fHC_ReduceVolSizeX(model, max_volL, 1, model.vBorderX.n - 1);                                       // mesh refinement
  fHC_PrepareModel(model);
end;

end.

