Comments (19)
Yes, this is one of the (at least 2 ingredients) I am aware of that are missing in order to implement the FE spaces and FE functions.
We have:
Type Iteration provides at each cell
========== ===================================
CellValue Number, FieldValue, etc.
CellArray Array
CellField Field (Missing)
It would be nice to be able to iterate on any CellField
directly (i.e., without evaluating it) in the same way we iterate on CellValues
or CellArrays
. That is, iterating over a CellField
would generate a Field for each cell. This Field
has to be evaluable at a given array of points.
Then, a new concrete implementation of CellField will be CellFieldFromAnalyticalFieldWithGeomap
. Iterating over an instance of CellFieldFromAnalyticalFieldWithGeomap
will produce a Field
for each cell, a Field
that is evaluated a the reference space of the corresponding cell.
What do you think?
EDIT:
The requested type already exists. It is called CellFieldFromCompose
. The only part missing it to make the CellFields
iterable.
from gridap.jl.
The second ingredient is the construction of a new CellArray
struct that given, the local to global dof info, the free dof values, and the Dirichlet dof values, provides the corresponding Vector
of dofs values at each cell. This is trivial. I'll do it now. For the case of no Dirichlet Boundary conditions it is already implemented in CellVectorFromLocalToGlobal
.
from gridap.jl.
OK, I will create a draft of CellField
and its concrete CellFieldFromAnalyticalFieldWithGeomap
Please, take a look at CellVectorByComposition
that I have added to Wrappers.jl
in order to express the composition of cell vectors. I have used to work with a NFace-based DOF info, and later compose it with the Cell-NFace info to have a Cell-based VEF info that is needed in the assembly process.
from gridap.jl.
It is not needed to create a concrete type. There is already one. It is called CellFieldFromCompose
(the name can be changed if needed). I will also think on how to make all CellField
types iterable. I think, it should not be very difficult.
from gridap.jl.
Not sure I understand
There is already one. It is called CellFieldFromCompose (the name can be changed if needed).
You say above
Then, a new concrete implementation of CellField will be CellFieldFromAnalyticalFieldWithGeomap. Iterating over an instance of CellFieldFromAnalyticalFieldWithGeomap will produce a Field for each cell, a Field that is evaluated a the reference space of the corresponding cell.
It seems CellFieldFromCompose
is a composition of a Function
and CellField
, not sure it is exactly what we need...
from gridap.jl.
I was thinking at the beginning to make all CellField
types iterable. In this scenario, CellFieldFromCompose
would be iterable as well and could be used for your needs.
Anyway, I have realized that this is not the way to go, since making all CellField
types iterable would require some work. Perhaps, the way to go (at least for the moment) is to make a new abstract type called IterCellField
or IndexCellFielld
(since the discretization used to build the FE space will be indexable). Then, implement the concrete struct CellFieldFromAnalyticalFieldWithGeomap
which is iterable, or iterable and indexable.
In the future, we can think if it pays off to make all CellField
types iterable as I was thinking at the beginning...
from gridap.jl.
I have put the following sketch of the code we need in CellFieldTests.jl
"""
Cell-wise field created from a `Field`
"""
struct CellFieldFromField{D,T,F<:Field{D,T}} <: CellField{D,T}
field::F
end
function evaluate(self::CellFieldFromField{D,T},points::CellPoints{D}) where D
CellFieldValuesFromField(self.field,points)
end
function gradient(self::CellFieldFromField)
gradfield = gradient(self.field)
CellFieldFromField(gradfield)
end
"""
Result of the lazy evaluation of a `CellFieldFromField` on a cell-wise array
of points `CellPoints{D}`
"""
struct CellFieldValuesFromField{D,T,F,C} # <: IndexCellArray{T,1,C}
# @santiagobadia : Not sure from where to extend
field::F
cellpoints::C
cv::CachedVector{T,Vector{T}}
end
function CellFieldValuesFromField(
field::Field{D,T},cellpoints::CellPoints{D}) where {D,T}
F = typeof(field)
C = typeof(cellpoints)
a = Vector{T}(undef,celllength(cellpoints))
cv = CachedArray(a)
CellFieldValuesFromField{D,T,F,C}(field,cellpoints,cv)
end
# @santiagobadia : I am probably missing interface methods
@propagate_inbounds function getindex(self::CellFieldValuesFromField,cell::Int)
points = self.cellpoints[cell]
setsize!(self.cv,(length(points),))
evaluate!(self.field,points,cv)
end
inputcellarray(self::CellFieldValuesFromField) = self.cellpoints
computesize(self::CellFieldValuesFromField, asize) = asize[1]
function computevals!(self::CellFieldValuesFromField, a, v)
evaluate!(self.field,a,v)
end
from gridap.jl.
As far as I understand, this is not the type you need. I think we are facing a fundamental limitation of the current design of CellField that requires some work. Tomorrow I’ll think on this and propose something
from gridap.jl.
I would say that the CellFieldFromField
will be needed. I am not sure about CellFieldValuesFromField
but it is reasonable to have it for the lazy evaluation of the first one. The first one is the counterpart of CellBasisWithSingleInterpolation
and the second one the same for values.
In fact, there is something that I don't like much. I believe that Basis
and Field
should be understood as a particular cases of Function{D,T,N}
with T <: FieldValue
and write their code only once, e.g., all the structs in the first paragraph would be only one.
On the other hand, I think we need type inheritance at the assembled type, i.e., the CellFunction
level, and the component level, e.g., the component of CellFunction{S,M,T,N}
must be a function with range S,M
and domain T,N
. This is the problem I am facing now for fields, the CellField
must provide a Field
. Again, if we define FunctionArray{S,M,T,N}
, the case I am interested in is a particular case, FunctionArray{Point{D},1,T<:FieldValue,1}
.
Finally, when you say I don't need the previous object, I believe you are thinking about something I need and not included in the previous sketch. I still need a "FE-function" that when restricted to a cell will provide me a Field
. It is what we need for interpolation, after composition with another "Fe-function" for the geomap as composition of cell-wise fields. When defined this object, the interpolation will be easy. Again, the composition method can be defined at CellFunction
level.
from gridap.jl.
For instance, to have this CellFunction instead of CellBasisWithSingleInterpolation
and CellFieldFromField
above (just define constants).
"""
Concrete implementation of CellFunction for the case of the same function on all cells
"""
struct ConstantCellFunction{S,M,T,N}
A::Function{S,M,T,N} # Or put an acceptable name here
end
function CellBasisFromSingleInterpolation(f::ConstantCellFunction{S,M,T,N}) where {S,M,T,N}
ConstantCellFunction{S,M,T,N}(f)
end
from gridap.jl.
I would say that the CellFieldFromField will be needed.
Yes, sure. It will be useful in some context and it makes sense to add it. My point was that this is not the precise type needed for the FE interpolation.
In fact, there is something that I don't like much. I believe that Basis and Field should be understood as a particular cases of Function{D,T,N} with T <: FieldValue and write their code only once, e.g., all the structs in the first paragraph would be only one.
I am also aware of this. We need an umbrella type for Field and Basis. Note that we cannot named it Function
since it is already defined in julia....
I still need a "FE-function" that when restricted to a cell will provide me a Field. It is what we need for interpolation, after composition with another "Fe-function" for the geomap as composition of cell-wise fields. When defined this object, the interpolation will be easy. Again, the composition method can be defined at CellFunction level.
Yes sure. This is what I was trying to explain with the table:
Type Iteration provides at each cell
========== ===================================
CellValue Number, FieldValue, etc.
CellArray Array
CellField Field (Missing)
Now we can iterate in a CellValue (and provides a e.g., FieldValue at the cell level). We can iterate a CellArray (and provides an Array at the cell level). however, now we cannot iterate a CellFunction/CellField/CellBasis. We can only evaluate it on a CellArray
. This is the missing part. We need to iterate CellFunction/CellField/CellBasis objects, which furnish a Function?/Field/Basis at the cell level.
My only concern is whether we need to iterate all CellFunction/CellField/CellBasis objects or only a subset of them... Making all of them iterable is the elegant way to go. Making iterable only a subset of them is a shortcut that can be useful for the moment.
from gridap.jl.
OK, I think we agree in the diagnostic.
I am not sure it has much sense to waste the time looking for shortcuts.
It is probably better to start thinking about the right solution.
I will create a list of things (I think) are needed.
from gridap.jl.
OK. Totally agree by doing things right from the beginning. I am now tiding up the geometry-related part.
from gridap.jl.
- Create a new object
Map{S,M,T,N}
that given anM
-dim array ofS
provides anN
-dim array ofT
- Define its constants for
Basis
andField
- Create an abstract type iterable
IterCellMap{S,M,T,N}
that returns initerate
and object of typeMap
. - Create an abstract type indexable
IndexCellMap{S,M,T,N,V<:Map{S,M,T,N}}<:AbstractVector{V}
that returns ingetindex
and object of typeV
and implements theiterate
methods. -
const CellMap{S,M,T,N} = Union{IterCellMap{S,M,T,N},indexCellMap{S,M,T,N}} where {S,M,T,N}
- Replace
CellBasisWithSingleInterpolation
with a structConstantCellMap{S,M,T,N,A<:Map{S,M,T,N}}<:IterCellMap{S,M,T,N,A}
, which will be useful to create, e.g., aCellField
with anAnalyticalField
. - Create an struct
IterCellMapValues{S,M,T,N,A<:CellMap{S,M,T,N},B<:CellArray{S,M}}<:IterCellArray{T,N}
where the result ofCellMap
is stored (lazy evaluation). Perhaps also forIndexCellMapValues{S,M,T,N,A<:IndexCellMap{S,M,T,N},B<:IndexCellArray{...}<:IndexCellArray{T,N,...}
TheCellBasisValues
objects and the not made yetCellFieldValues
not needed, particular cases - Create a
CellMapCompose
by composition of maps - Make the
CellFieldFromExtend
(i.e., a FE function) to fit in the previous setting
For the moment, I would create new objects, with new names, and next, replace CellFunction with CellMap (or the other way around). But I would like to use the same name in the aggregated object and object and now Function already in Julia.
from gridap.jl.
@fverdugo please take a look at the list and edit it if you want
from gridap.jl.
@santiagobadia I have edited a bit the list. The extra type parameters will be needed to have type stable structs... Remove the bold face markup once you agreed.
from gridap.jl.
Essentially, at the end CellMap
follows the same desing as CellValue
and CellArray
, which I find a good thing.
from gridap.jl.
OK, the only thing I don't get is why the indexable implements the iterate method. I thought that with getindex
and the fact that <:AbstractArray
the iterate is not needed, it is already provided by Julia. I will read in detain the interfaces for abstract iterators and arrays to understand this point.
from gridap.jl.
Yes of course. Its a typo. At the beginning, IndexCellMap was not extending AbstractVector but IterCellMap. So, it was required to implement the iterate interface...Now implementing getindex et al will be sufficient.
from gridap.jl.
Related Issues (20)
- Visualization of the solution of a multifield time dependant problem
- Implementation of MultiFieldStyle in TransientMultiFieldFESpaces HOT 5
- MultiFlield Boundary Condition Problem HOT 3
- Runge Kutta methods for linear operators only HOT 4
- Normal displacement boundary condition in linear elasticity problems HOT 3
- To-think: a less restrictive type for the type of the operator in `LinearSolver` abstract interface?
- Eigen-values and vectors of SymTensorValue HOT 3
- Refactoring of the ODE module
- Solving non-linear coupled PDEs HOT 2
- Gridap and solvers from DifferentialEquations.jl HOT 7
- Neumann boundary conditions and different geometries HOT 3
- Computing gradient wrt Dirichlet data
- confusion about vectors sizes HOT 4
- `MultiFieldFESpace` with complex numbers HOT 2
- Error with the function `_point_to_cell ` when using a triangular mesh
- Wrong result when multiplying integrand with scalar when using `InterfaceTriangulation`
- Incorrect Assertion on boundary faces integral HOT 3
- ode_start() in Generalized_Alpha results into singular system HOT 2
- Leftover ideas for ODEs
- `mean` operator + `SkeletonPair`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gridap.jl.