Skip to content

Commit

Permalink
Worked on importing Lkt from MF6 into ModelMuse.
Browse files Browse the repository at this point in the history
  • Loading branch information
rbwinst-usgs committed May 9, 2024
1 parent 0a14235 commit f46e6dd
Show file tree
Hide file tree
Showing 13 changed files with 971 additions and 245 deletions.
19 changes: 18 additions & 1 deletion MF6InputReader/Mf6.CustomMf6PersistentUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ TNumberedItemList = class(TList<TNumberedItem>)
procedure Sort;
end;

TNumberedItemLists = TObjectList<TNumberedItemList>;
TNumberedItemLists = class(TObjectList<TNumberedItemList>)
function HasData: boolean;
end;

TExtendedList = TList<Extended>;

Expand Down Expand Up @@ -1828,4 +1830,19 @@ procedure TNumberedItemList.Sort;
));
end;

{ TNumberedItemLists }

function TNumberedItemLists.HasData: boolean;
begin
result := False;
for var Index := 0 to Count - 1 do
begin
result := Items[Index].Count > 0;
if Result then
begin
Exit;
end;
end;
end;

end.
163 changes: 125 additions & 38 deletions MF6InputReader/Mf6.LktFileReaderUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ interface
type
TLktOptions = class(TCustomMf6Persistent)
private
FLOW_PACKAGE_NAME: string;
FFLOW_PACKAGE_NAME: string;
AUXILIARY: TStringList;
FLOW_PACKAGE_AUXILIARY_NAME: string;
BOUNDNAMES: Boolean;
PRINT_INPUT: Boolean;
PRINT_CONCENTRATION: Boolean;
PRINT_FLOWS: Boolean;
SAVE_FLOWS: Boolean;
CONCENTRATION: Boolean;
BUDGET: Boolean;
BUDGETCSV: Boolean;
FPRINT_INPUT: Boolean;
FPRINT_CONCENTRATION: Boolean;
FPRINT_FLOWS: Boolean;
FSAVE_FLOWS: Boolean;
FCONCENTRATION: Boolean;
FBUDGET: Boolean;
FBUDGETCSV: Boolean;
TS6_FileNames: TStringList;
Obs6_FileNames: TStringList;
procedure Read(Stream: TStreamReader; Unhandled: TStreamWriter);
Expand All @@ -28,17 +28,28 @@ TLktOptions = class(TCustomMf6Persistent)
public
constructor Create(PackageType: string); override;
destructor Destroy; override;
property FLOW_PACKAGE_NAME: string read FFLOW_PACKAGE_NAME;
property PRINT_INPUT: Boolean read FPRINT_INPUT;
property PRINT_CONCENTRATION: Boolean read FPRINT_CONCENTRATION;
property PRINT_FLOWS: Boolean read FPRINT_FLOWS;
property SAVE_FLOWS: Boolean read FSAVE_FLOWS;
property CONCENTRATION: Boolean read FCONCENTRATION;
property BUDGET: Boolean read FBUDGET;
property BUDGETCSV: Boolean read FBUDGETCSV;
end;

TLktPackageItem = class(TObject)
private
lakeno: Integer;
strt: TMf6BoundaryValue;
Flakeno: Integer;
Fstrt: TMf6BoundaryValue;
aux: TBoundaryValueList;
boundname: string;
Fboundname: string;
public
constructor Create;
destructor Destroy; override;
property lakeno: Integer read Flakeno;
property strt: TMf6BoundaryValue read Fstrt;
property boundname: string read Fboundname;
end;

TLktPackageItemList= TObjectList<TLktPackageItem>;
Expand All @@ -48,26 +59,36 @@ TLktPackageData = class(TCustomMf6Persistent)
FItems: TLktPackageItemList;
procedure Read(Stream: TStreamReader; Unhandled: TStreamWriter; naux: Integer;
BOUNDNAMES: Boolean);
function GetCount: Integer;
function GetItem(Index: Integer): TLktPackageItem;
protected
procedure Initialize; override;
public
constructor Create(PackageType: string); override;
destructor Destroy; override;
property Count: Integer read GetCount;
property Items[Index: Integer]: TLktPackageItem read GetItem; default;
end;

TLktPeriod = class(TCustomMf6Persistent)
private
IPER: Integer;
FItems: TNumberedItemList;
procedure Read(Stream: TStreamReader; Unhandled: TStreamWriter);
function GetCount: Integer;
function GetItem(Index: Integer): TNumberedItem;
protected
procedure Initialize; override;
public
constructor Create(PackageType: string); override;
destructor Destroy; override;
property Period: Integer read IPER;
property Count: Integer read GetCount;
property Items[Index: Integer]: TNumberedItem read GetItem; default;
end;

TLktPeriodList = TObjectList<TLktPeriod>;
TLktPeriodArray = TArray<TLktPeriod>;

TLkt = class(TDimensionedPackageReader)
private
Expand All @@ -76,12 +97,28 @@ TLkt = class(TDimensionedPackageReader)
FPeriods: TLktPeriodList;
FTimeSeriesPackages: TPackageList;
FObservationsPackages: TPackageList;
function GetObservation(Index: Integer): TPackage;
function GetObservationCount: Integer;
function GetPeriod(Index: Integer): TLktPeriod;
function GetPeriodCount: Integer;
function GetTimeSeries(Index: Integer): TPackage;
function GetTimeSeriesCount: Integer;
public
constructor Create(PackageType: string); override;
destructor Destroy; override;
procedure Read(Stream: TStreamReader; Unhandled: TStreamWriter; const NPER: Integer); override;
procedure Read(Stream: TStreamReader; Unhandled: TStreamWriter;
const NPER: Integer); override;
property Options: TLktOptions read FOptions;
property PackageData: TLktPackageData read FPackageData;
property PeriodCount: Integer read GetPeriodCount;
property Periods[Index: Integer]: TLktPeriod read GetPeriod;
property TimeSeriesCount: Integer read GetTimeSeriesCount;
property TimeSeries[Index: Integer]: TPackage read GetTimeSeries;
property ObservationCount: Integer read GetObservationCount;
property Observations[Index: Integer]: TPackage read GetObservation;
end;

TLktList = TList<TLkt>;

implementation

Expand Down Expand Up @@ -111,17 +148,17 @@ destructor TLktOptions.Destroy;
procedure TLktOptions.Initialize;
begin
inherited;
FLOW_PACKAGE_NAME := '';
FFLOW_PACKAGE_NAME := '';
AUXILIARY.Clear;
FLOW_PACKAGE_AUXILIARY_NAME := '';
BOUNDNAMES := False;
PRINT_INPUT := False;
PRINT_CONCENTRATION := False;
PRINT_FLOWS := False;
SAVE_FLOWS := False;
CONCENTRATION := False;
BUDGET := False;
BUDGETCSV := False;
FPRINT_INPUT := False;
FPRINT_CONCENTRATION := False;
FPRINT_FLOWS := False;
FSAVE_FLOWS := False;
FCONCENTRATION := False;
FBUDGET := False;
FBUDGETCSV := False;
TS6_FileNames.Clear;
Obs6_FileNames.Clear;
end;
Expand Down Expand Up @@ -161,7 +198,7 @@ procedure TLktOptions.Read(Stream: TStreamReader; Unhandled: TStreamWriter);
and (FSplitter.Count >= 2) then
begin
FSplitter.DelimitedText := CaseSensitiveLine;
FLOW_PACKAGE_NAME := FSplitter[1];
FFLOW_PACKAGE_NAME := FSplitter[1];
end
else if (FSplitter[0] = 'AUXILIARY')
and (FSplitter.Count >= 2) then
Expand All @@ -185,37 +222,37 @@ procedure TLktOptions.Read(Stream: TStreamReader; Unhandled: TStreamWriter);
end
else if FSplitter[0] = 'PRINT_INPUT' then
begin
PRINT_INPUT := True;
FPRINT_INPUT := True;
end
else if FSplitter[0] = 'PRINT_CONCENTRATION' then
begin
PRINT_CONCENTRATION := True;
FPRINT_CONCENTRATION := True;
end
else if FSplitter[0] = 'PRINT_FLOWS' then
begin
PRINT_FLOWS := True;
FPRINT_FLOWS := True;
end
else if FSplitter[0] = 'SAVE_FLOWS' then
begin
SAVE_FLOWS := True;
FSAVE_FLOWS := True;
end
else if (FSplitter[0] = 'CONCENTRATION')
and (FSplitter.Count >= 3)
and (FSplitter[1] = 'FILEOUT') then
begin
CONCENTRATION := True;
FCONCENTRATION := True;
end
else if (FSplitter[0] = 'BUDGET')
and (FSplitter.Count >= 3)
and (FSplitter[1] = 'FILEOUT') then
begin
BUDGET := True;
FBUDGET := True;
end
else if (FSplitter[0] = 'BUDGETCSV')
and (FSplitter.Count >= 3)
and (FSplitter[1] = 'FILEOUT') then
begin
BUDGETCSV := True;
FBUDGETCSV := True;
end
else if (FSplitter[0] = 'TS6')
and (FSplitter.Count >= 3)
Expand Down Expand Up @@ -245,10 +282,10 @@ procedure TLktOptions.Read(Stream: TStreamReader; Unhandled: TStreamWriter);

constructor TLktPackageItem.Create;
begin
lakeno := 0;
strt.Initialize;
Flakeno := 0;
Fstrt.Initialize;
aux := TBoundaryValueList.Create;
boundname := ''
Fboundname := ''
end;

destructor TLktPackageItem.Destroy;
Expand All @@ -272,6 +309,16 @@ destructor TLktPackageData.Destroy;
inherited;
end;

function TLktPackageData.GetCount: Integer;
begin
result := FItems.Count;
end;

function TLktPackageData.GetItem(Index: Integer): TLktPackageItem;
begin
result := FItems[Index];
end;

procedure TLktPackageData.Initialize;
begin
inherited;
Expand Down Expand Up @@ -309,7 +356,7 @@ procedure TLktPackageData.Read(Stream: TStreamReader; Unhandled: TStreamWriter;
TComparer<TLktPackageItem>.Construct(
function(const Left, Right: TLktPackageItem): Integer
begin
Result := Left.lakeno - Right.lakeno;
Result := Left.Flakeno - Right.Flakeno;
end
));
Exit;
Expand All @@ -323,17 +370,17 @@ procedure TLktPackageData.Read(Stream: TStreamReader; Unhandled: TStreamWriter;
// do nothing
end
else if (FSplitter.Count >= NumberOfItems)
and TryStrToInt(FSplitter[0],Item.lakeno)
and TryStrToInt(FSplitter[0],Item.Flakeno)
then
begin
if TryFortranStrToFloat(FSplitter[1],Item.strt.NumericValue) then
if TryFortranStrToFloat(FSplitter[1],Item.Fstrt.NumericValue) then
begin
Item.strt.ValueType := vtNumeric;
Item.Fstrt.ValueType := vtNumeric;
end
else
begin
Item.strt.ValueType := vtString;
Item.strt.StringValue := FSplitter[1];
Item.Fstrt.ValueType := vtString;
Item.Fstrt.StringValue := FSplitter[1];
end;

ItemStart := 2;
Expand All @@ -356,7 +403,7 @@ procedure TLktPackageData.Read(Stream: TStreamReader; Unhandled: TStreamWriter;
if BOUNDNAMES and (FSplitter.Count >= NumberOfItems+1) then
begin
FSplitter.DelimitedText := CaseSensitiveLine;
Item.boundname := FSplitter[ItemStart];
Item.Fboundname := FSplitter[ItemStart];
end;
FItems.Add(Item);
Item := nil;
Expand Down Expand Up @@ -386,6 +433,16 @@ destructor TLktPeriod.Destroy;
inherited;
end;

function TLktPeriod.GetCount: Integer;
begin
result := FItems.Count;
end;

function TLktPeriod.GetItem(Index: Integer): TNumberedItem;
begin
result := FItems[Index];
end;

procedure TLktPeriod.Initialize;
begin
inherited;
Expand Down Expand Up @@ -506,6 +563,36 @@ destructor TLkt.Destroy;
inherited;
end;

function TLkt.GetObservation(Index: Integer): TPackage;
begin
result := FObservationsPackages[Index];
end;

function TLkt.GetObservationCount: Integer;
begin
result := FObservationsPackages.Count
end;

function TLkt.GetPeriod(Index: Integer): TLktPeriod;
begin
result := FPeriods[Index];
end;

function TLkt.GetPeriodCount: Integer;
begin
result := FPeriods.Count;
end;

function TLkt.GetTimeSeries(Index: Integer): TPackage;
begin
result := FTimeSeriesPackages[Index];
end;

function TLkt.GetTimeSeriesCount: Integer;
begin
result := FTimeSeriesPackages.Count;
end;

procedure TLkt.Read(Stream: TStreamReader; Unhandled: TStreamWriter; const NPER: Integer);
var
ALine: string;
Expand Down
6 changes: 6 additions & 0 deletions ModelMuse/GwtStatusUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ TGwtBoundaryStatusCollection = class(TCollection)
write SetItems; default;
function IsSame(OtherCollection: TGwtBoundaryStatusCollection): Boolean;
property Count: Integer read GetCount write SetCount;
function Add: TGwtBoundaryStatusItem;
end;


Expand Down Expand Up @@ -68,6 +69,11 @@ procedure TGwtBoundaryStatusItem.SetGwtBoundaryStatus(

{ TGwtBoundaryStatusCollection }

function TGwtBoundaryStatusCollection.Add: TGwtBoundaryStatusItem;
begin
result := inherited Add as TGwtBoundaryStatusItem;
end;

procedure TGwtBoundaryStatusCollection.Assign(Source: TPersistent);
begin
if Source is TGwtBoundaryStatusCollection then
Expand Down
Loading

0 comments on commit f46e6dd

Please sign in to comment.