GridapDistributed.jl icon indicating copy to clipboard operation
GridapDistributed.jl copied to clipboard

Allow access to physical groups in distributed fashion

Open jellejurre opened this issue 3 years ago • 1 comments

Maybe this is possible, but I haven't found a way to do this in a parallel way, but I'm trying to adapt some parts of Tutorial 3 to a distributed fashion.

In there, the parts I want to copy is:

model = GmshDiscreteModel(parts, "./geometry.msh")
labels = get_face_labeling(model)
tags = get_face_tag(labels,dimension)

function σ_bimat(ε,tag)
  if tag == alu_tag
    return λ_alu*tr(ε)*one(ε) + 2*μ_alu*ε
  else
    return λ_steel*tr(ε)*one(ε) + 2*μ_steel*ε
  end
end

a(u,v) = ∫( ε(v) ⊙ (σ_bimat∘(ε(u),tags)) )*dΩ

So I want to use different parameters depending on the 3d physical group of the element. I was wondering if and how this is possible in a distributed fashion, since with this direct code I get:

ERROR: LoadError: MethodError: no method matching get_face_tag(::GridapDistributed.DistributedFaceLabeling{MPIData{FaceLabeling, 1}}, ::Int64)

jellejurre avatar Dec 22 '22 11:12 jellejurre

@jellejurre It is possible, but you should use the map_parts functionality to extract the FaceLabeling in each processor.

Something along the lines of

tags = map_parts(local_views(labels)) do labels
    get_face_tag(labels,dimension)
end

This will return an AbstractPData with the tags in each part. You can then create a parallel version of your σ_bimat function, which takes ε as a DistributedCellField and tag as AbstractPData. Something like

function σ_bimat(ε::DsitributedCellField,tag::AbstractPData)
  fields = map_parts(local_views(ε),tag) do ε,tag
    σ_bimat(ε,tag)
  end
  return DistributedCellField(fields)
end

This calls the serial version of σ_bimat(ε,tag) in each processor, which returns a CellField in each part. Then you return a DistributedCellField with those serial cellfields as parts.

JordiManyer avatar Mar 02 '23 23:03 JordiManyer