Comments (3)
The idea is that the Field only holds an Array, Metadata and a reference to the FunctionSpace.
Anything like field.levels()
is just a shorthand for getting it out of the Metadata via field.metadata().getInt("levels")
.
It should indeed be noted that this is not a cheap operation and that you may instead like to:
const idx_t levels = field.levels();
and use levels
inside the computational loop, or you can use the array-view's shape
function. Even if it was stored as an extra variable, Field contains a FieldImpl* pointer and such indirection will also not be good for performance.
It is also possibly better to extract loop bounds before the computational loop for compilers to have a better chance at optimising.
@odlomax , w.r.t. horizontal indices, this is indeed also in the metadata, and there's a short-hand to get it out:
std::vector<idx_t> Field::horizontal_dimensions() const {
std::vector<idx_t> h_dim{0};
metadata().get("horizontal_dimension", h_dim);
return h_dim;
}
Note that there could be more than 1 horizontal dimension.
from atlas.
I think the difficulty with having a member variable is that you now have two unsynchronised values which represent levels
, i.e. metadata.getInt("levels")
and an int
in the field object.
Perhaps the performant yet readable solution is to have metadata which defines the horizontal and vertical dimensions of the field, i.e.,
const auto horizDim = metadata.getInt("horizontal dimension", 0);
const auto vertDim = metadata.getInt("vertical dimension", 1);
// could implement `Field::horizontalDim()` and `Field::verticalDim()` to simplify
for (auto horiz = idx_t{0}; horiz < fieldView.shape(horizDim); ++horiz) {
for (auto vert = idx_t{0}; vert < fieldView.shape(vertDim); ++vert) {
// some stuff with fieldView(horiz, vert)...
}
}
@wdeconinck, I think this is something that was discussed last year in Boulder, right?
from atlas.
Thank you for the comprehensive response @wdeconinck.
Even if it was stored as an extra variable, Field contains a FieldImpl* pointer and such indirection will also not be good for performance.
I hadn't considered this.. In general then it is best to pull this information out of a field prior to looping.
I'll close this issue for now as it's clear that this was the intended design.
from atlas.
Related Issues (20)
- Regional matching mesh partitioning HOT 2
- Set UnstructuredGrid in meshes built by MeshBuilder HOT 9
- Ctest failure in atlas_fctest_trans HOT 1
- Adding robust vector-field interpolation functionality (current PR and further work). HOT 1
- Interpolation::NonLinear datatype incompatible with atlas::Fieldsets of heterogeneous types HOT 1
- StructuredColumns `FixupHaloForVectors` method interferes with `SphericalVector` interpolation HOT 7
- Cannot find ectrans header HOT 4
- Improve performance of missing-values-containing field interpolation
- Outermost mpi::Scope does not restore prior communicator HOT 8
- Using serial Partitioner on multiple ranks leads to unexpected duplication of FunctionSpace HOT 3
- Failed to find nvcc. HOT 2
- Compile failure with NAG HOT 1
- Risk of surprising behavior when adding multiple Fields of same name into FieldSet HOT 10
- Missing halos after calling build_halo on a "structured" mesh HOT 2
- Failure in atlas_test_trans HOT 1
- Some interpolators fail with zero-sized target functionspace.
- Some issues with NAG compiler
- The test "atlas_fctest_field_host" fails with "ENABLE_CUDA" build option HOT 2
- Allow vector interpolation methods to pack and unpack vector fields.
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 atlas.