Skip to content

Commit 628f688

Browse files
committed
tutorials 3 to 13
1 parent e6fa5e2 commit 628f688

11 files changed

Lines changed: 34 additions & 21 deletions

src/advection_diffusion.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,11 @@ uh_non_zero = Gridap.Algebra.solve(op_non_zero)
162162

163163
# Ouput the result as a `.vtk` file.
164164

165-
writevtk(Ω,"results_zero",cellfields=["uh_zero"=>uh_zero])
165+
mkpath("output_path")
166166

167-
writevtk(Ω,"results_non_zero",cellfields=["uh_non_zero"=>uh_non_zero])
167+
writevtk(Ω,"output_path/results_zero",cellfields=["uh_zero"=>uh_zero])
168+
169+
writevtk(Ω,"output_path/results_non_zero",cellfields=["uh_non_zero"=>uh_non_zero])
168170

169171
# ## Visualization
170172

src/darcy.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ uh, ph = xh
136136

137137
# Since this is a multi-field example, the `solve` function returns a multi-field solution `xh`, which can be unpacked in order to finally recover each field of the problem. The resulting single-field objects can be visualized as in previous tutorials (see next figure).
138138

139-
writevtk(trian,"darcyresults",cellfields=["uh"=>uh,"ph"=>ph])
139+
mkpath("output_path")
140+
writevtk(trian,"output_path/darcyresults",cellfields=["uh"=>uh,"ph"=>ph])
140141

141142
# ![](../assets/darcy/darcy_results.png)
142143
#

src/dg_discretization.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ model = CartesianDiscreteModel(domain,partition)
162162
# to be generated in each direction (here $4\times4\times4$ cells). You can
163163
# write the model in vtk format to visualize it (see next figure).
164164

165-
writevtk(model,"model")
165+
mkpath("output_path")
166+
writevtk(model,"output_path/model")
166167

167168
# ![](../assets/dg_discretization/model.png)
168169
#
@@ -240,7 +241,7 @@ U = TrialFESpace(V)
240241
# written into a vtk file for its visualization (see next figure, where the
241242
# interior facets $\mathcal{F}_\Lambda$ are clearly observed).
242243

243-
writevtk(Λ,"strian")
244+
writevtk(Λ,"output_path/strian")
244245

245246
# ![](../assets/dg_discretization/skeleton_trian.png)
246247
#
@@ -329,7 +330,7 @@ uh = solve(op)
329330
# faces. We compute and visualize the jump of these values as follows (see next
330331
# figure):
331332

332-
writevtk(Λ,"jumps",cellfields=["jump_u"=>jump(uh)])
333+
writevtk(Λ,"output_path/jumps",cellfields=["jump_u"=>jump(uh)])
333334

334335
# Note that the jump of the numerical solution is very small, close to the
335336
# machine precision (as expected in this example with manufactured solution).

src/elasticity.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ model = DiscreteModelFromFile("../models/solid.json")
4949

5050
# In order to inspect it, write the model to vtk
5151

52-
writevtk(model,"model")
52+
mkpath("output_path")
53+
writevtk(model,"output_path/model")
5354

5455
# and open the resulting files with Paraview. The boundaries $\Gamma_{\rm B}$ and $\Gamma_{\rm G}$ are identified with the names `"surface_1"` and `"surface_2"` respectively. For instance, if you visualize the faces of the model and color them by the field `"surface_2"` (see next figure), you will see that only the faces on $\Gamma_{\rm G}$ have a value different from zero.
5556
#
@@ -118,7 +119,7 @@ uh = solve(op)
118119
#
119120
# Finally, we write the results to a file. Note that we also include the strain and stress tensors into the results file.
120121

121-
writevtk(Ω,"results",cellfields=["uh"=>uh,"epsi"=>ε(uh),"sigma"=>σε(uh)])
122+
writevtk(Ω,"output_path/results",cellfields=["uh"=>uh,"epsi"=>ε(uh),"sigma"=>σε(uh)])
122123

123124
# It can be clearly observed (see next figure) that the surface $\Gamma_{\rm B}$ is pulled in $x_1$-direction and that the solid deforms accordingly.
124125
#
@@ -186,7 +187,7 @@ uh = solve(op)
186187

187188
# Once the solution is computed, we can store the results in a file for visualization. Note that, we are including the stress tensor in the file (computed with the bi-material law).
188189

189-
writevtk(Ω,"results_bimat",cellfields=
190+
writevtk(Ω,"output_path/results_bimat",cellfields=
190191
["uh"=>uh,"epsi"=>ε(uh),"sigma"=>σ_bimat(ε(uh),tags)])
191192

192193
# #### Constant multi-material law
@@ -200,6 +201,6 @@ tags_field = CellField(tags, Ω)
200201
# `tags_field` is a field which value at $x$ is the tag of the cell containing $x$. `σ_bimat_cst` is used like a constant in (bi)linear form definition and solution export:
201202

202203
a(u,v) = ( σ_bimat_cst * (u)(v))*
203-
writevtk(Ω,"const_law",cellfields= ["sigma"=>σ_bimat_cst])
204+
writevtk(Ω,"output_path/const_law",cellfields= ["sigma"=>σ_bimat_cst])
204205

205206
# Tutorial done!

src/emscatter.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ uh_t = CellField(x->H_t(x,xc,r,ϵ₁,λ),Ω)
291291
# ![](../assets/emscatter/Results.png)
292292

293293
# ### Save to file and view
294-
writevtk(Ω,"demo",cellfields=["Real"=>real(uh),
294+
mkpath("output_path")
295+
writevtk(Ω,"output_path/demo",cellfields=["Real"=>real(uh),
295296
"Imag"=>imag(uh),
296297
"Norm"=>abs2(uh),
297298
"Real_t"=>real(uh_t),

src/fsi_tutorial.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ using Gridap
7676
model = DiscreteModelFromFile("../models/elasticFlag.json")
7777

7878
# We can inspect the loaded geometry and associated parts by printing to a `vtk` file:
79-
writevtk(model,"model")
79+
mkpath("output_path")
80+
writevtk(model,"output_path/model")
8081

8182
# This will produce an output in which we can identify the different parts of the domain, with the associated labels and tags.
8283
#
@@ -357,12 +358,12 @@ uhs, uhf, ph = solve(op)
357358
# ```
358359
# ### Visualization
359360
# The solution fields $[\mathbf{U}^h_{\rm S},\mathbf{U}^h_{\rm F},\mathbf{P}^h_{\rm F}]^T$ are defined over all the domain, extended with zeros on the inactive part. Calling the function `writevtk` passing the global triangulation, we will output the global fields.
360-
writevtk(Ω,"trian", cellfields=["uhs" => uhs, "uhf" => uhf, "ph" => ph])
361+
writevtk(Ω,"output_path/trian", cellfields=["uhs" => uhs, "uhf" => uhf, "ph" => ph])
361362
# ![](../assets/fsi/Global_solution.png)
362363

363364
# However, we can also restrict the fields to the active part by calling the function `restrict` with the field along with the respective active triangulation.
364-
writevtk(Ω_s,"trian_solid",cellfields=["uhs"=>uhs])
365-
writevtk(Ω_f,"trian_fluid",cellfields=["ph"=>ph,"uhf"=>uhf])
365+
writevtk(Ω_s,"output_path/trian_solid",cellfields=["uhs"=>uhs])
366+
writevtk(Ω_f,"output_path/trian_fluid",cellfields=["ph"=>ph,"uhf"=>uhf])
366367
# ![](../assets/fsi/Local_solution.png)
367368

368369
# ```@raw HTML

src/hyperelasticity.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ function run(x0,disp_x,step,nsteps,cache)
9696

9797
uh, cache = solve!(uh,solver,op,cache)
9898

99-
writevtk(Ω,"results_$(lpad(step,3,'0'))",cellfields=["uh"=>uh,"sigma"=>σ(uh)])
99+
mkpath("output_path")
100+
writevtk(Ω,"output_path/results_$(lpad(step,3,'0'))",cellfields=["uh"=>uh,"sigma"=>σ(uh)])
100101

101102
return get_free_dof_values(uh), cache
102103

src/inc_navier_stokes.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ uh, ph = solve(solver,op)
151151

152152
# Finally, we write the results for visualization (see next figure).
153153

154-
writevtk(Ωₕ,"ins-results",cellfields=["uh"=>uh,"ph"=>ph])
154+
mkpath("output_path")
155+
writevtk(Ωₕ,"output_path/ins-results",cellfields=["uh"=>uh,"ph"=>ph])
155156

156157
# ![](../assets/inc_navier_stokes/ins_solution.png)
157158
#

src/isotropic_damage.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ function main(;n,nsteps)
120120
uh = zero(V)
121121
cache = nothing
122122

123+
mkpath("output_path")
124+
123125
for (istep,factor) in enumerate(factors)
124126

125127
println("\n+++ Solving for load factor $factor in step $istep of $nsteps +++\n")
@@ -129,7 +131,7 @@ function main(;n,nsteps)
129131
rh = project(r,model,dΩ,order)
130132

131133
writevtk(
132-
Ω,"results_$(lpad(istep,3,'0'))",
134+
Ω,"output_path/results_$(lpad(istep,3,'0'))",
133135
cellfields=["uh"=>uh,"epsi"=>ε(uh),"damage"=>dh,
134136
"threshold"=>rh,"sigma_elast"=>σeε(uh)])
135137

src/p_laplacian.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ model = DiscreteModelFromFile("../models/model.json")
4848

4949
# As stated before, we want to impose Dirichlet boundary conditions on $\Gamma_0$ and $\Gamma_g$, but none of these boundaries is identified in the model. E.g., you can easily see by writing the model in vtk format
5050

51-
writevtk(model,"model")
51+
mkpath("output_path")
52+
writevtk(model,"output_path/model")
5253

5354
# and by opening the file `"model_0"` in Paraview that the boundary identified as `"sides"` only includes the vertices in the interior of $\Gamma_0$, but here we want to impose Dirichlet boundary conditions in the closure of $\Gamma_0$, i.e., also on the vertices on the contour of $\Gamma_0$. Fortunately, the objects on the contour of $\Gamma_0$ are identified with the tag `"sides_c"` (see next figure). Thus, the Dirichlet boundary $\Gamma_0$ can be built as the union of the objects identified as `"sides"` and `"sides_c"`.
5455
#
@@ -134,7 +135,7 @@ uh, = solve!(uh0,solver,op)
134135

135136
# We finish this tutorial by writing the computed solution for visualization (see next figure).
136137

137-
writevtk(Ω,"results",cellfields=["uh"=>uh])
138+
writevtk(Ω,"output_path/results",cellfields=["uh"=>uh])
138139

139140
# ![](../assets/p_laplacian/sol-plap.png)
140141
#

0 commit comments

Comments
 (0)