Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs tutorials #336

Merged
merged 57 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
171505a
implement
svchb Dec 16, 2023
b319288
Revert "implement"
svchb Dec 16, 2023
1452e5f
some improvements to the documentation
svchb Dec 17, 2023
094e38b
some more fixes
svchb Dec 17, 2023
7d847d2
add install documentation
svchb Dec 17, 2023
8d53e8d
add more info
svchb Dec 18, 2023
95756ea
update
svchb Dec 18, 2023
f4db396
Update get_started.md
svchb Dec 18, 2023
8d1cedf
add tutorial
svchb Dec 18, 2023
aef054b
fix
svchb Jan 11, 2024
e09fdcd
Merge branch 'main' into docs_tutorials
svchb Jan 11, 2024
916ca7a
add stubs
svchb Jan 11, 2024
933d5a3
update
svchb Jan 11, 2024
29b0c45
include the example files
svchb Jan 11, 2024
551b1c4
update
svchb Jan 11, 2024
d9f7222
update
svchb Jan 11, 2024
9c683d7
format
svchb Jan 11, 2024
17c2ec5
add more info to error message
svchb Jan 11, 2024
e3175dd
fix path
svchb Jan 11, 2024
c2e629c
Merge branch 'main' into docs_get_started
svchb Feb 2, 2024
b2f3013
Merge branch 'main' into docs_get_started
svchb Feb 5, 2024
5e2ff13
update
svchb Feb 5, 2024
95f6e4e
update
svchb Feb 5, 2024
a2eba1f
Merge branch 'main' into docs_get_started
svchb Feb 6, 2024
7f57614
review comments
svchb Feb 9, 2024
c5bfa4a
forgot one predefined
svchb Feb 9, 2024
c14cd14
Merge branch 'main' into docs_tutorials
svchb Feb 13, 2024
1ceaa93
update
svchb Feb 13, 2024
8b1d481
fix
svchb Feb 13, 2024
b8cd071
rm get_started.md
svchb Feb 13, 2024
9d17606
fix
svchb Feb 13, 2024
6bec0ca
rename rect_tank
svchb Feb 14, 2024
6f4ca5d
Merge branch 'main' into docs_get_started
svchb Feb 14, 2024
9aa8714
Merge branch 'docs_get_started' of github.com:svchb/TrixiParticles.jl…
svchb Feb 14, 2024
cf6dea8
review
svchb Feb 14, 2024
d644145
Merge branch 'docs_get_started'
svchb Feb 14, 2024
95a40b7
fix tests
svchb Feb 15, 2024
0f565b5
fix review
svchb Feb 16, 2024
0699ffa
format
svchb Feb 16, 2024
bff6d7a
Merge branch 'main' into docs_tutorials
svchb Feb 16, 2024
45d7069
remove unused line
svchb Feb 16, 2024
18dd241
revert changes
svchb Feb 16, 2024
217a5d6
revert more
svchb Feb 16, 2024
538acac
fix doc
svchb Feb 16, 2024
356542f
revert
svchb Feb 16, 2024
57f1ea8
fix naming
svchb Feb 16, 2024
bcfb09b
fix docs
svchb Feb 16, 2024
ed73e40
format
svchb Feb 16, 2024
bccfc09
fixes
svchb Feb 16, 2024
d4cdc0a
Merge branch 'main' into docs_tutorials
svchb Feb 16, 2024
accc74f
forgot one
svchb Feb 16, 2024
d754525
Merge branch 'docs_tutorials' of github.com:svchb/TrixiParticles.jl i…
svchb Feb 16, 2024
e0b4057
rm minimal
svchb Feb 16, 2024
9bab2e4
fix
svchb Feb 16, 2024
ef00e77
format
svchb Feb 16, 2024
289d9d7
fix docs
svchb Feb 16, 2024
f2716ae
Merge branch 'main' into docs_tutorials
efaulhaber Feb 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ docs/src/contributing.md
docs/src/license.md
docs/src/code_of_conduct.md
docs/src/news.md
*_replaced.md
run
*.json
*.png
Expand Down
48 changes: 46 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ using TrixiBase
trixiparticles_root_dir = dirname(@__DIR__)

# Copy files to not need to synchronize them manually
function copy_file(filename, replaces...)
function copy_file(filename, replaces...;
new_file=joinpath(@__DIR__, "src", lowercase(filename)))
source_path = joinpath(trixiparticles_root_dir, filename)

if !isfile(source_path)
Expand All @@ -24,9 +25,52 @@ function copy_file(filename, replaces...)
"""
content = header * content

write(joinpath(@__DIR__, "src", lowercase(filename)), content)
write(new_file, content)
end

function replace_with_code(filename)
if !isfile(filename)
cwd = pwd()
error("Markdown file not found: $filename in directory: $cwd")
return
end

# Define a regex pattern to match the include markers
pattern = r"!!include:([^\s!]+\.jl)!!"

function replace_include(match_::SubString{String})
# Extract the filename using regex
m = match(pattern, match_)
if m === nothing
error("Invalid include format in: $match")
end
file_to_include = joinpath(trixiparticles_root_dir, m.captures[1])

try
# Check if the Julia file exists
if !isfile(file_to_include)
error("File to include not found: $(file_to_include)")
end

# Read the content of the file to include
return read(file_to_include, String)
catch e
# In case of any error
error("Unable to include file $(file_to_include): $(e)")
end
end

# Replace all occurrences in the markdown content
filename_noext, extension = splitext(filename)
copy_file(filename, new_file="$(filename_noext)_replaced$extension",
pattern => replace_include)
end

replace_with_code("docs/src/tutorials/tut_setup.md")
replace_with_code("docs/src/tutorials/tut_dam_break.md")
replace_with_code("docs/src/tutorials/tut_beam.md")
replace_with_code("docs/src/tutorials/tut_falling.md")

copy_file("AUTHORS.md",
"in the [LICENSE.md](LICENSE.md) file" => "under [License](@ref)")
copy_file("CONTRIBUTING.md",
Expand Down
11 changes: 9 additions & 2 deletions docs/src/examples.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# Examples


## WCSPH
## Fluid


## TLSPH
## Structure Mechanics


## Fluid Structure Interaction


## Postprocessing

2 changes: 1 addition & 1 deletion docs/src/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ code from the cloned directory:
git clone [email protected]:trixi-framework/TrixiParticles.jl.git
cd TrixiParticles.jl
mkdir run
julia --project=run -e 'using Pkg; Pkg.develop(PackageSpec(path=".."))' # Install locally
julia --project=run -e 'using Pkg; Pkg.develop(PackageSpec(path="."))' # Install locally
julia --project=run -e 'using Pkg; Pkg.add("OrdinaryDiffEq")' # Add TrixiParticles.jl to `run` project
```

Expand Down
7 changes: 5 additions & 2 deletions docs/src/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@


## Fluid

- [Setting up your simulation from scratch](tutorials/tut_setup_replaced.md)
- [Setting up a dam break simulation](tutorials/tut_dam_break_replaced.md)

## Mechanics
- [Deforming a beam](tutorials/tut_beam_replaced.md)


## Fluid-Structure Interaction
## Fluid-Structure Interaction
- [Setting up a falling structure](tutorials/tut_falling_replaced.md)
5 changes: 5 additions & 0 deletions docs/src/tutorials/tut_beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Example file
```julia
!!include:examples/solid/oscillating_beam_2d.jl!!

```
5 changes: 5 additions & 0 deletions docs/src/tutorials/tut_dam_break.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Example file
```julia
!!include:examples/fluid/dam_break_2d.jl!!

```
5 changes: 5 additions & 0 deletions docs/src/tutorials/tut_falling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Example file
```julia
!!include:examples/fsi/falling_spheres_2d.jl!!

```
13 changes: 13 additions & 0 deletions docs/src/tutorials/tut_setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Setting up your simulation from scratch

## Hydrostatic tank




# Example file
```julia
!!include:examples/fluid/hydrostatic_water_column_2d.jl!!

```

3 changes: 1 addition & 2 deletions examples/fluid/hydrostatic_water_column_edac_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ saving_callback = SolutionSavingCallback(dt=0.02, prefix="")
callbacks = CallbackSet(info_callback, saving_callback)

# Use a Runge-Kutta method with automatic (error based) time step size control
sol = solve(ode, RDPK3SpFSAL35(),
save_everystep=false, callback=callbacks);
sol = solve(ode, RDPK3SpFSAL35(), save_everystep=false, callback=callbacks);
26 changes: 25 additions & 1 deletion src/general/semidiscretization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,33 @@ end
@inline foreach_system(f, systems) = foreach_noalloc(f, systems)

"""
semidiscretize(semi, tspan)
semidiscretize(semi, tspan; reset_threads=true)

Create an `ODEProblem` from the semidiscretization with the specified `tspan`.

# Arguments
- `semi`: A [`Semidiscretization`](@ref) holding the systems involved in the simulation.
- `tspan`: The time span over which the simulation will be run.

# Keywords
- `reset_threads`: A boolean flag to reset Polyester.jl threads before the simulation (default: `true`).
After an error within a threaded loop, threading might be disabled. Resetting the threads before the simulation
ensures that threading is enabled again for the simulation.
See also [trixi-framework/Trixi.jl#1583](https://github.com/trixi-framework/Trixi.jl/issues/1583).

# Returns
A `DynamicalODEProblem` (see [the OrdinaryDiffEq.jl docs](https://docs.sciml.ai/DiffEqDocs/stable/types/dynamical_types/))
to be integrated with [OrdinaryDiffEq.jl](https://github.com/SciML/OrdinaryDiffEq.jl).
Note that this is not a true `DynamicalODEProblem` where the acceleration does not depend on the velocity.
Therefore, not all integrators designed for `DynamicalODEProblems` will work properly.
However, all integrators designed for `ODEProblems` can be used.

# Examples
```julia
semi = Semidiscretization(fluid_system, boundary_system)
tspan = (0.0, 1.0)
ode_problem = semidiscretize(semi, tspan)
```
"""
function semidiscretize(semi, tspan; reset_threads=true)
(; systems) = semi
Expand Down
Loading