Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CryoGrid.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CryoGrid
CryoGrid.jl
Commits
4b65f405
Commit
4b65f405
authored
4 months ago
by
Brian Groenke
Browse files
Options
Downloads
Patches
Plain Diff
Fix bug in FD cache handling for grid variables
parent
79580148
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
examples/heat_simple_autodiff_grad.jl
+1
-0
1 addition, 0 deletions
examples/heat_simple_autodiff_grad.jl
src/Numerics/caches.jl
+3
-3
3 additions, 3 deletions
src/Numerics/caches.jl
src/Numerics/grid.jl
+5
-5
5 additions, 5 deletions
src/Numerics/grid.jl
src/Tiles/tile.jl
+2
-2
2 additions, 2 deletions
src/Tiles/tile.jl
with
11 additions
and
10 deletions
examples/heat_simple_autodiff_grad.jl
+
1
−
0
View file @
4b65f405
...
@@ -8,6 +8,7 @@ using CryoGrid
...
@@ -8,6 +8,7 @@ using CryoGrid
# Set up forcings and boundary conditions similarly to other examples:
# Set up forcings and boundary conditions similarly to other examples:
forcings
=
loadforcings
(
CryoGrid
.
Forcings
.
Samoylov_ERA_obs_fitted_1979_2014_spinup_extended_2044
);
forcings
=
loadforcings
(
CryoGrid
.
Forcings
.
Samoylov_ERA_obs_fitted_1979_2014_spinup_extended_2044
);
soilprofile
,
tempprofile
=
CryoGrid
.
SamoylovDefault
soilprofile
,
tempprofile
=
CryoGrid
.
SamoylovDefault
soilprofile
=
SoilProfile
(
0.0
u
"m"
=>
SimpleSoil
())
grid
=
CryoGrid
.
DefaultGrid_5cm
grid
=
CryoGrid
.
DefaultGrid_5cm
initT
=
initializer
(
:
T
,
tempprofile
)
initT
=
initializer
(
:
T
,
tempprofile
)
tile
=
CryoGrid
.
SoilHeatTile
(
tile
=
CryoGrid
.
SoilHeatTile
(
...
...
This diff is collapsed.
Click to expand it.
src/Numerics/caches.jl
+
3
−
3
View file @
4b65f405
...
@@ -21,12 +21,12 @@ Base.show(io::IO, mime::MIME{Symbol("text/plain")}, cache::DiffCache) = show(io,
...
@@ -21,12 +21,12 @@ Base.show(io::IO, mime::MIME{Symbol("text/plain")}, cache::DiffCache) = show(io,
_retrieve
(
cache_var
::
AbstractArray
{
T
},
::
AbstractArray
{
T
})
where
{
T
}
=
cache_var
_retrieve
(
cache_var
::
AbstractArray
{
T
},
::
AbstractArray
{
T
})
where
{
T
}
=
cache_var
_retrieve
(
cache_var
::
AbstractArray
{
T
},
u
::
AbstractArray
{
U
})
where
{
T
,
U
}
=
copyto!
(
similar
(
u
,
length
(
cache_var
)),
cache_var
)
_retrieve
(
cache_var
::
AbstractArray
{
T
},
u
::
AbstractArray
{
U
})
where
{
T
,
U
}
=
copyto!
(
similar
(
u
,
length
(
cache_var
)),
cache_var
)
retrieve
(
dc
::
DiffCache
)
=
dc
.
cache
.
du
retrieve
(
dc
::
DiffCache
)
=
dc
.
cache
.
du
retrieve
(
dc
::
DiffCache
,
u
::
AbstractArray
{
T
})
where
{
T
<:
ForwardDiff
.
Dual
}
=
Prealloc
.
get_tmp
(
dc
.
cache
,
u
)
retrieve
(
dc
::
DiffCache
,
u
::
AbstractArray
{
T
})
where
{
T
<:
ForwardDiff
.
Dual
}
=
copyto!
(
Prealloc
.
get_tmp
(
dc
.
cache
,
u
)
,
dc
.
cache
.
du
)
retrieve
(
dc
::
DiffCache
,
u
::
AbstractArray
{
T
})
where
{
T
}
=
_retrieve
(
dc
.
cache
.
du
,
u
)
retrieve
(
dc
::
DiffCache
,
u
::
AbstractArray
{
T
})
where
{
T
}
=
_retrieve
(
dc
.
cache
.
du
,
u
)
retrieve
(
dc
::
DiffCache
,
u
::
AbstractArray
{
T
},
t
)
where
{
T
}
=
retrieve
(
dc
,
u
)
retrieve
(
dc
::
DiffCache
,
u
::
AbstractArray
{
T
},
t
)
where
{
T
}
=
retrieve
(
dc
,
u
)
# these cover cases for Rosenbrock solvers where only t has differentiable type
# these cover cases for Rosenbrock solvers where only t has differentiable type
retrieve
(
dc
::
DiffCache
,
u
::
AbstractArray
,
t
::
T
)
where
{
T
<:
ForwardDiff
.
Dual
}
=
Prealloc
.
get_tmp
(
dc
.
cache
,
t
)
retrieve
(
dc
::
DiffCache
,
u
::
AbstractArray
,
t
::
T
)
where
{
T
<:
ForwardDiff
.
Dual
}
=
copyto!
(
Prealloc
.
get_tmp
(
dc
.
cache
,
t
)
,
dc
.
cache
.
du
)
retrieve
(
dc
::
DiffCache
,
u
::
AbstractArray
{
T
},
t
::
T
)
where
{
T
<:
ForwardDiff
.
Dual
}
=
Prealloc
.
get_tmp
(
dc
.
cache
,
u
)
retrieve
(
dc
::
DiffCache
,
u
::
AbstractArray
{
T
},
t
::
T
)
where
{
T
<:
ForwardDiff
.
Dual
}
=
copyto!
(
Prealloc
.
get_tmp
(
dc
.
cache
,
u
)
,
dc
.
cache
.
du
)
"""
"""
ArrayCache{T,TA} <: StateVarCache
ArrayCache{T,TA} <: StateVarCache
...
...
This diff is collapsed.
Click to expand it.
src/Numerics/grid.jl
+
5
−
5
View file @
4b65f405
...
@@ -120,12 +120,12 @@ function updategrid!(grid::Grid{Edges}, z0, thick::AbstractVector)
...
@@ -120,12 +120,12 @@ function updategrid!(grid::Grid{Edges}, z0, thick::AbstractVector)
return
grid
return
grid
end
end
function
currentgrid
(
state
vars
::
NamedTuple
,
initialgrid
::
Grid
,
u
,
t
)
function
currentgrid
(
state
::
NamedTuple
,
initialgrid
::
Grid
,
u
,
t
)
# retrieve grid data from StateVars
# retrieve grid data from StateVars
midpoints
=
retrieve
(
state
vars
.
midpoints
,
u
,
t
)
midpoints
=
retrieve
(
state
.
midpoints
,
u
,
t
)
edges
=
retrieve
(
state
vars
.
edges
,
u
,
t
)
edges
=
retrieve
(
state
.
edges
,
u
,
t
)
cellthick
=
retrieve
(
state
vars
.
cellthick
,
u
,
t
)
cellthick
=
retrieve
(
state
.
cellthick
,
u
,
t
)
celldist
=
retrieve
(
state
vars
.
celldist
,
u
,
t
)
celldist
=
retrieve
(
state
.
celldist
,
u
,
t
)
return
Grid
(
Edges
,
(
edges
=
edges
,
cells
=
midpoints
),
(
edges
=
cellthick
,
cells
=
celldist
),
initialgrid
.
geometry
,
initialgrid
.
bounds
)
return
Grid
(
Edges
,
(
edges
=
edges
,
cells
=
midpoints
),
(
edges
=
cellthick
,
cells
=
celldist
),
initialgrid
.
geometry
,
initialgrid
.
bounds
)
end
end
...
...
This diff is collapsed.
Click to expand it.
src/Tiles/tile.jl
+
2
−
2
View file @
4b65f405
...
@@ -313,11 +313,11 @@ Returns a tuple of all variables defined in the tile.
...
@@ -313,11 +313,11 @@ Returns a tuple of all variables defined in the tile.
CryoGrid
.
variables
(
tile
::
Tile
)
=
Tuple
(
unique
(
Flatten
.
flatten
(
tile
.
state
.
vars
,
Flatten
.
flattenable
,
Var
)))
CryoGrid
.
variables
(
tile
::
Tile
)
=
Tuple
(
unique
(
Flatten
.
flatten
(
tile
.
state
.
vars
,
Flatten
.
flattenable
,
Var
)))
"""
"""
parameters(tile::Tile; kwargs...)
parameters(tile::Tile;
include_all=false,
kwargs...)
Extracts all parameters from `tile`.
Extracts all parameters from `tile`.
"""
"""
parameters
(
tile
::
Tile
;
kwargs
...
)
=
CryoGridParams
(
tile
;
kwargs
...
)
parameters
(
tile
::
Tile
;
include_all
=
true
,
kwargs
...
)
=
CryoGridParams
(
include_all
?
tile
:
stripparams
(
FixedParam
,
tile
)
;
kwargs
...
)
"""
"""
withaxes(u::AbstractArray, ::Tile)
withaxes(u::AbstractArray, ::Tile)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment