Skip to content

Commit

Permalink
Merge pull request #20 from PetrKryslUCSD/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
PetrKryslUCSD authored Aug 19, 2024
2 parents ec7ff0d + a09b8b4 commit 12d05c2
Show file tree
Hide file tree
Showing 20 changed files with 368 additions and 270 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FinEtoolsDDMethods"
uuid = "093fdad3-4fce-4574-aa49-c2a24de4f00d"
authors = ["Petr Krysl <[email protected]>"]
version = "0.4.0"
version = "0.4.1"

[deps]
CoNCMOR = "3a989f29-cff0-4f1c-87be-5dcdd41bd240"
Expand Down
4 changes: 2 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Note the folder where the executable is installed.

On Windows 11, the following would work:
```
mpiexec -n 3 julia --project=. .\conc\heat\Poisson2D_overlapped_mpi_examples.jl
mpiexec -n 3 julia --project=. .\conc\heat\Poisson2D_mpi_driver.jl
```


Expand Down Expand Up @@ -112,7 +112,7 @@ to see the available options.

At the moment only the heat conduction examples have been cast in this form. Try
```
mpiexec -n 5 julia --project=. .\conc\heat\Poisson2D_overlapped_mpi_examples.jl
mpiexec -n 5 julia --project=. .\conc\heat\Poisson2D_mpi_driver.jl
```

## To do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ http://www.codeproject.com/Articles/579983/Finite-Element-programming-in-Julia:
Unit cube, with known temperature distribution along the boundary,
and uniform heat generation rate inside.
Solution with domain decomposition.
Version: 08/16/2024
Solution with domain decomposition and MPI.
Version: 08/19/2024
"""
module Poisson2D_overlapped_mpi_examples
module Poisson2D_mpi_driver
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtools.AssemblyModule
Expand Down Expand Up @@ -72,24 +72,6 @@ function _execute(N, mesher, volrule, nelperpart, nbf1max, overlap, itmax, relre

material = MatHeatDiff(thermal_conductivity)

# fr = dofrange(Temp, DOF_KIND_FREE)
# dr = dofrange(Temp, DOF_KIND_DATA)
# rank == 0 && @info("Number of free degrees of freedom: $(nfreedofs(Temp)) ($(round(time() - t1, digits=3)) [s])")
# t1 = time()

# femm = FEMMHeatDiff(IntegDomain(fes, volrule, 1.0), material)
# K = conductivity(femm, geom, Temp)
# rank == 0 && @info("Conductivity ($(round(time() - t1, digits=3)) [s])")
# K_ff = K[fr, fr]
# t1 = time()
# fi = ForceIntensity(Float64[Q])
# F1 = distribloads(femm, geom, Temp, fi, 3)
# rank == 0 && @info("Internal heat generation ($(round(time() - t1, digits=3)) [s])")
# t1 = time()
# T_d = gathersysvec(Temp, DOF_KIND_DATA)
# F_f = (F1 .- K[:, dr] * T_d)[fr]
# rank == 0 && @info("Right hand side ($(round(time() - t1, digits=3)) [s])")

t1 = time()
cpartitioning, ncpartitions = FinEtoolsDDMethods.cluster_partitioning(fens, fes, fes.label, nelperpart)
rank == 0 && @info("Number of clusters (coarse grid partitions): $(ncpartitions)")
Expand Down Expand Up @@ -171,7 +153,7 @@ function _execute(N, mesher, volrule, nelperpart, nbf1max, overlap, itmax, relre
geometry = xyz3(fens)
geometry[:, 3] .= Temp.values
fens.xyz = geometry
File = "Poisson2D_overlapped_examples-sol.vtk"
File = "Poisson2D_examples-sol.vtk"
MeshExportModule.VTK.vtkexportmesh(File, fens, fes; scalars=[("Temp", Temp.values)])
end
end
Expand Down Expand Up @@ -200,4 +182,4 @@ end
test()

nothing
end # module Poisson2D_overlapped_examples
end # module Poisson2D_mpi_driver
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Unit cube, with known temperature distribution along the boundary,
and uniform heat generation rate inside.
Solution with domain decomposition. Sequential execution.
Version: 08/18/2024
Version: 08/19/2024
"""
module Poisson2D_overlapped_seq_examples
module Poisson2D_seq_examples
using FinEtools
using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtools.AssemblyModule
Expand Down Expand Up @@ -127,4 +127,4 @@ function test(; kind = "Q8", N = 25, nbf1max = 2, nelperpart = 2*(nbf1max+1)^2,
end

nothing
end # module Poisson2D_overlapped_examples
end # module Poisson2D_examples
6 changes: 3 additions & 3 deletions examples/conc/lindef/cc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ end

p = parse_commandline()

include(raw"fibers_overlapped_examples.jl")
using .fibers_overlapped_examples;
include(raw"fibers_examples.jl")
using .fibers_examples;

fibers_overlapped_examples.test("cc";
fibers_examples.test("cc";
kind=p["kind"],
Em=p["Em"], num=p["num"], Ef=p["Ef"], nuf=p["nuf"],
nelperpart=p["nelperpart"], nbf1max=p["nbf1max"],
Expand Down
6 changes: 3 additions & 3 deletions examples/conc/lindef/cni.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ end

p = parse_commandline()

include(raw"fibers_overlapped_examples.jl")
using .fibers_overlapped_examples;
include(raw"fibers_examples.jl")
using .fibers_examples;

fibers_overlapped_examples.test("cni";
fibers_examples.test("cni";
kind=p["kind"],
Em=p["Em"], num=p["num"], Ef=p["Ef"], nuf=p["nuf"],
nelperpart=p["nelperpart"], nbf1max=p["nbf1max"],
Expand Down
6 changes: 3 additions & 3 deletions examples/conc/lindef/css.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ end

p = parse_commandline()

include(raw"fibers_overlapped_examples.jl")
using .fibers_overlapped_examples;
include(raw"fibers_examples.jl")
using .fibers_examples;

fibers_overlapped_examples.test("css";
fibers_examples.test("css";
kind=p["kind"],
Em=p["Em"], num=p["num"], Ef=p["Ef"], nuf=p["nuf"],
nelperpart=p["nelperpart"], nbf1max=p["nbf1max"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module fibers_overlapped_condition_examples
module fibers_condition_examples
using FinEtools
using FinEtools.MeshExportModule: VTK
using FinEtools.MeshExportModule: CSV
Expand Down Expand Up @@ -343,7 +343,7 @@ function _execute(label, kind, Em, num, Ef, nuf, nelperpart, nbf1max, nfpartitio
scattersysvec!(u, v[:, i])
push!(vectors, ("Mode_$(i)_$(d[i])", deepcopy(u.values)))
end
File = "fibers_overlapped_condition-full" *
File = "fibers_condition-full" *
"-rf=$(ref)" *
".vtk"
vtkexportmesh(
Expand Down Expand Up @@ -374,7 +374,7 @@ function _execute(label, kind, Em, num, Ef, nuf, nelperpart, nbf1max, nfpartitio
scattersysvec!(u, Phi * v[:, i])
push!(vectors, ("Mode_$(i)_$(d[i])", deepcopy(u.values)))
end
File = "fibers_overlapped_condition-red" *
File = "fibers_condition-red" *
"-rf=$(ref)" *
"-ne=$(nelperpart)" *
"-n1=$(nbf1max)" *
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module fibers_overlapped_examples
module fibers_examples
using FinEtools
using FinEtools.MeshExportModule: VTK
using FinEtools.MeshExportModule: CSV
Expand Down Expand Up @@ -288,15 +288,15 @@ function _execute(label, kind, Em, num, Ef, nuf, nelperpart, nbf1max, nfpartitio
fr = dofrange(u, DOF_KIND_FREE)
dr = dofrange(u, DOF_KIND_DATA)

println("Kind: $(string(kind))")
println("Materials: $(Ef), $(nuf), $(Em), $(num)")
println("Refinement factor: $(ref)")
println("Number of elements per partition: $(nelperpart)")
println("Number of 1D basis functions: $(nbf1max)")
println("Number of fine grid partitions: $(nfpartitions)")
println("Overlap: $(overlap)")
println("Number of elements: $(count(fes))")
println("Number of free dofs = $(nfreedofs(u))")
@info("Kind: $(string(kind))")
@info("Materials: $(Ef), $(nuf), $(Em), $(num)")
@info("Refinement factor: $(ref)")
@info("Number of elements per partition: $(nelperpart)")
@info("Number of 1D basis functions: $(nbf1max)")
@info("Number of fine grid partitions: $(nfpartitions)")
@info("Overlap: $(overlap)")
@info("Number of elements: $(count(fes))")
@info("Number of free dofs = $(nfreedofs(u))")

fi = ForceIntensity(Float64, 3, getfrcL!)
el2femm = FEMMBase(IntegDomain(loadfes, boundary_rule))
Expand All @@ -316,13 +316,13 @@ function _execute(label, kind, Em, num, Ef, nuf, nelperpart, nbf1max, nfpartitio
# VTK.vtkexportmesh("fibers-tet-sol.vtk", fens, fes; vectors=[("u", deepcopy(u.values),)])

# cpartitioning, ncpartitions = coarse_grid_partitioning(fens, fes, nelperpart)
# println("Number coarse grid partitions: $(ncpartitions)")
# @info("Number coarse grid partitions: $(ncpartitions)")
# f = "fibers-partitioning-original"
# partitionsfes = FESetP1(reshape(1:count(fens), count(fens), 1))
# vtkexportmesh(f * ".vtk", fens, partitionsfes; scalars=[("partition", cpartitioning)])

cpartitioning, ncpartitions = FinEtoolsDDMethods.cluster_partitioning(fens, fes, fes.label, nelperpart)
println("Number of clusters (coarse grid partitions): $(ncpartitions)")
@info("Number of clusters (coarse grid partitions): $(ncpartitions)")
# f = "fibers-partitioning-new"
# partitionsfes = FESetP1(reshape(1:count(fens), count(fens), 1))
# vtkexportmesh(f * ".vtk", fens, partitionsfes; scalars=[("partition", cpartitioning)])
Expand All @@ -335,7 +335,7 @@ function _execute(label, kind, Em, num, Ef, nuf, nelperpart, nbf1max, nfpartitio
transfv(v, t, tT) = (tT * v)
PhiT = Phi'
Kr_ff = transfm(K_ff, Phi, PhiT)
println("Size of the reduced problem: $(size(Kr_ff))")
@info("Size of the reduced problem: $(size(Kr_ff))")
Krfactor = lu(Kr_ff)

# U_f = Phi * (Krfactor \ (PhiT * F_f))
Expand Down Expand Up @@ -364,7 +364,7 @@ function _execute(label, kind, Em, num, Ef, nuf, nelperpart, nbf1max, nfpartitio
end

meansize = mean([length(part.doflist) for part in partitions])
println("Mean fine partition size: $(meansize)")
@info("Mean fine partition size: $(meansize)")

function M!(q, p)
q .= Phi * (Krfactor \ (PhiT * p))
Expand All @@ -380,7 +380,7 @@ function _execute(label, kind, Em, num, Ef, nuf, nelperpart, nbf1max, nfpartitio
(M!)=(q, p) -> M!(q, p),
itmax=itmax, atol=relrestol * norm_F_f, rtol=0)
t1 = time()
println("Number of iterations: $(stats.niter)")
@info("Number of iterations: $(stats.niter)")
stats = (niter = stats.niter, residuals = stats.residuals ./ norm_F_f)
data = Dict(
"nfreedofs_u" => nfreedofs(u),
Expand Down
149 changes: 0 additions & 149 deletions examples/conc/lindef/stubby_corbel_examples.jl

This file was deleted.

Loading

0 comments on commit 12d05c2

Please sign in to comment.