How to declare a type

I want to declare a type that describe a Well.

mutable struct Well
   Name::String
   Surv::Survey
   Perf::Array{Perf}
   end

I want to define if the well is either Injector or producer. How could I define it?

Injector::Bool

I think there is a way by setting a variable a Bool Type. but is there a way of telling Julia ::Producer or ::Injector???

What would be the struct of these types?

thank you

1 Like

you can use abstract types, maybe:

abstract type WellType end
struct Injector <: WellType end
struct Producer <: WellType end
mutable struct Well
   Name::String
   Surv::Survey
   Perf::Array{Perf}
   classification::WellType
  end

just to understand the context, are we talking about oil wells, right?

Yes they are Oil Wells. with that abstract type how you can introduce a new object?

I tryied but iā€™m a little confused

abstract type WellType end
struct Injector <: WellType end
struct Producer <: WellType end
mutable struct Well
   Name::String
   Surv::Int
   Perf::Int
   classification::WellType
  end

Well("Merlin-1",5,7,::Producer)??

Thank you

1 Like

you have to create an instance of the type first:

Well("Merlin-1",5,7,Producer())

as an alternative, you can create a variable holding the type and pass it to the constructor:

producer = Producer()
Well("Merlin-1",5,7,producer)

How about an @enum?

julia> @enum WellType Producer Injector

julia> Producer
Producer::WellType = 0

julia> mutable struct Well; x :: WellType; end

julia> w = Well(Producer)
Well(Producer)
1 Like