Modules and files

Hi all,

I have this code with 3 files: MaterialPoint.jl for module MaterialPoint as follows

   module MaterialPoint
   using LinearAlgebra
   export mpmMaterialPoint_2D_Classic,createMaterialDomain_Circle
   	mutable struct mpmMaterialPoint_2D_Classic
       end
       function createMaterialDomain_Circle(fCenter::Array{Float64}, fRadius::Float64, fOffset::Float64)
      end
end

And file Grid.jl implements the module Grid as

module Grid
using MaterialPoint 
struct mpmGrid
end
function getAdjacentGridPoints(thisMaterialPoint::mpmMaterialPoint_2D_Classic,
                                   thisGrid::mpmGrid)
end
 export getAdjacentGridPoints
 export mpmGrid
end

And the final file, Main.jl, uses modules Grid and MaterialPoint:

push!(LOAD_PATH,"/Users/vingu/Dropbox/JuliaCodes/Classic_2D_2Disk/")
using Printf
using Grid
using MaterialPoint
using Basis

function mpmMain()
   thisGrid = Grid.mpmGrid(1.0, 1.0, 21, 21)
   thisMaterialDomain_01 = MaterialPoint.createMaterialDomain_Circle([0.2; 0.2], 0.2, fOffset)
   thisAdjacentGridPoints = getAdjacentGridPoints(thisMaterialPoint, thisGrid)
end

My question is: why I had to write Grid.mpmGrid(1.0, 1.0, 21, 21), not mpmGrid(1.0, 1.0, 21, 21) as I exported mpmGrid???

Note that thisAdjacentGridPoints = getAdjacentGridPoints(thisMaterialPoint, thisGrid) works fine without explicitly using Grid.getAdjacent…

Thanks,
P

Please quote your code (you can edit your post).

1 Like

Thanks a lot. I edited my post.

This should work — eg consider this MWE:

julia> push!(LOAD_PATH, pwd());

julia> using Grid
[ Info: Precompiling Grid [top-level]

julia> mpmGrid()
mpmGrid()

shell> cat Grid.jl
module Grid
export mpmGrid
struct mpmGrid end
end

I am wondering if this is a workflow problem: did you save Grid.jl before loading (if you worked on it), if or whether you are using Revise.jl.

1 Like

Yes, it works. Probably due to Juno as I am new to it. Thanks.