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

Refactor coordinates #2873

Open
wants to merge 504 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
504 commits
Select commit Hold shift + click to select a range
904546b
Update documentation.
tomchapman Dec 5, 2023
dc82c8b
Make parameters to Coordinates constructor const references.
tomchapman Dec 5, 2023
924618d
Prefer const.
tomchapman Dec 5, 2023
ab2e122
Remove unused setters for Christoffel symbol terms.
tomchapman Dec 5, 2023
07a2862
Make dx, dy, dz private.
tomchapman Dec 6, 2023
294737b
Make dx, dy, dz private in cython interface.
tomchapman Dec 6, 2023
84e108f
Update more tests and examples to use new dx, dy, dz getters and sett…
tomchapman Dec 6, 2023
54b343b
Add setter for dy that takes [x, y] indices. Update test_snb.
tomchapman Dec 7, 2023
41b0a5b
Corrected comment.
tomchapman Dec 7, 2023
0106a2c
Prefer const.
tomchapman Dec 6, 2023
0bf195b
Make d1_dx, d1_dy, d1_dz private.
tomchapman Dec 6, 2023
f248de9
Let DataFileFacade::add() take a const value.
tomchapman Dec 7, 2023
6528658
Make non_uniform private.
tomchapman Dec 7, 2023
3b3915e
Remove call to calculateGeometry() after setting metric tensor quanti…
tomchapman Dec 7, 2023
05ea951
Clang-Tidy: Constructors that are callable with a single argument mus…
tomchapman Dec 8, 2023
46a11ae
Make ShiftTorsion and IntShiftTorsion private.
tomchapman Dec 8, 2023
62d19fb
Clang-Tidy: Pass by value and use std::move().
tomchapman Dec 8, 2023
331eb1e
Rename calculateGeometry() to communicateAndCheckMeshSpacing().
tomchapman Dec 8, 2023
31c7640
Remove comments referring to obsolete method Coordinates::calculateGe…
tomchapman Dec 8, 2023
6fe1813
Extract class ChristoffelSymbols.
tomchapman Dec 9, 2023
2cf9453
Error handling: null check in Mesh::sourceHasYBoundaryGuards().
tomchapman Dec 9, 2023
3ccd720
Add a constructor for ChristoffelSymbols that takes no Mesh (because …
tomchapman Dec 9, 2023
83c5d72
Make 'function' parameter to map() and applyToComponents() methods a …
tomchapman Dec 9, 2023
8c06cd1
Make parameters to metric tensor setters const references.
tomchapman Dec 9, 2023
b8e192d
Rename getters (and private fields) for metric tensor components.
tomchapman Dec 9, 2023
aa42c9f
Clang-Tidy: Pass by value and use std::move().
tomchapman Dec 9, 2023
e44f1b7
Clang-Tidy: Pass by value and use std::move().
tomchapman Dec 11, 2023
721479d
Clang-Tidy: Single-argument constructors must be marked explicit to a…
tomchapman Dec 11, 2023
0d5c250
Remove redundant 'mesh' parameter from Geometry constructor.
tomchapman Dec 11, 2023
046a7ad
Formatting.
tomchapman Dec 11, 2023
f2dc950
Remove Geometry class, as now redundant.
tomchapman Dec 11, 2023
88e18b6
Corrected comment.
tomchapman Dec 11, 2023
0460b04
Need to call setter directly on contravariantMetricTensor and covaria…
tomchapman Dec 11, 2023
0c65aed
Ensure covariantMetricTensor is set.
tomchapman Dec 11, 2023
aa03305
Don't pass mesh to ChristoffelSymbols constructor in the Coordinates …
tomchapman Dec 11, 2023
25399d7
Null check differential_operators in ChristoffelSymbols constructor.
tomchapman Dec 11, 2023
3d81700
Ensure covariantMetricTensor is set.
tomchapman Dec 11, 2023
e8065ab
Pass (a reference to) Coordinates to CalculateChristoffelSymbols(), r…
tomchapman Jan 16, 2024
35402dd
Use same pattern as for invSg for lazy evaluation of Coordinates::chr…
tomchapman Jan 16, 2024
8f326fc
christoffel_symbols() return type should be reference.
tomchapman Jan 17, 2024
fad98bc
Remove unused ChristoffelSymbols constructor.
tomchapman Jan 17, 2024
1cc67e4
G1, G2, G3 not part of christoffel symbols.
tomchapman Jan 17, 2024
99683e4
interpolateAndExtrapolate G1, G2, G3.
tomchapman Jan 17, 2024
12cdafe
Prefer const.
tomchapman Jan 17, 2024
ecd60c9
Tidy.
tomchapman Jan 17, 2024
e08bd11
Refactor.
tomchapman Jan 19, 2024
f87f834
Formatting.
tomchapman Jan 23, 2024
f54a3e4
Refactor method 'setBoundaryCells' (remove getting dx and dy from the…
tomchapman Jan 23, 2024
529c253
Renaming to distinguish between 'options' variables.
tomchapman Jan 23, 2024
937094e
Make CalculateChristoffelSymbols() method just another ChristoffelSym…
tomchapman Jan 23, 2024
5f5d892
Extract variables for metric tensor components.
tomchapman Jan 23, 2024
f934687
Simplify case switching (reduce nesting) in Coordinates::setParallelT…
tomchapman Jan 24, 2024
f29ff3d
Extract method getDzFromOptionsFile().
tomchapman Jan 24, 2024
58c21eb
Remove 'getAtLoc' function overload that updates an in/out variable, …
tomchapman Jan 24, 2024
4f45142
Remove redundant initialisation of IntShiftTorsion, as it will alread…
tomchapman Jan 24, 2024
47666d0
Remove method 'getUnalignedAtLocationAndFillGuards'.
tomchapman Jan 24, 2024
44c87b3
Use member variables 'localmesh' and 'nz' in methods, rather than pas…
tomchapman Jan 24, 2024
cb86bd3
Rename private field J_ to jacobian_cache.
tomchapman Jan 28, 2024
888317e
Don't recalculate Jacobian and Bxy if read from file.
tomchapman Jan 28, 2024
9ffee2c
Don't recalculate Bxy if read from file.
tomchapman Jan 28, 2024
1bc3d8f
DRY - use existing method recalculateBxy().
tomchapman Jan 28, 2024
033c5df
Make recalculateBxy() const.
tomchapman Jan 28, 2024
e7ae4f3
No need to recalculate Bxy twice.
tomchapman Jan 28, 2024
2a3358f
Use extrapolate_x, extrapolate_y options if set.
tomchapman Jan 29, 2024
b08a27c
Reduce code duplication by moving call to interpolateAndExtrapolate()…
tomchapman Jan 29, 2024
34e6e37
Refactor to use sourceHasVar() and getAtLoc() for IntShiftTorsion, as…
tomchapman Jan 29, 2024
12423e2
No need to assign to a local variable before setting property.
tomchapman Jan 29, 2024
0ba9c00
Make jacobian_cache a std::unique_ptr.
tomchapman Jan 29, 2024
81b83e4
Bug fix: update existing value of jacobian when setting for specific …
tomchapman Jan 30, 2024
f9ec8dc
Remove ShiftTorsion setter (to avoid problems with it not being initi…
tomchapman Jan 30, 2024
b7ac99b
Extract class GValues to encapsulate G1, G2, G3 (needs renaming when …
tomchapman Feb 20, 2024
5538632
Extract methods Coordinates::communicateGValues() and Coordinates::ex…
tomchapman Feb 20, 2024
e254b98
Remove redundant MetricTensor::Allocate() method.
tomchapman Feb 20, 2024
9ef7b74
Fix additional strings after renaming "MetricTensor::CalculateOpposit…
tomchapman Feb 20, 2024
14887ff
Define two derived classes CovariantMetricTensor and CovariantMetricT…
tomchapman Feb 20, 2024
bb34560
Revert extracted functions on DifferentialOperators for those that ar…
tomchapman Feb 19, 2024
fb2266f
Fully revert extracting differential operator methods from Coordinate…
tomchapman Feb 21, 2024
4ba9669
Move trivial getters and setters of Coordinates class to header file.
tomchapman Feb 22, 2024
c14070a
Move trivial getters and setters of ChristoffelSymbols class to heade…
tomchapman Feb 22, 2024
e8d5a7e
Move trivial getters and setters of GValues class to header file.
tomchapman Feb 22, 2024
5ee546b
Move trivial getters and setters (and setLocation() method) of Metric…
tomchapman Feb 22, 2024
49378cd
No need to pre-assign values to explanatory variables before using to…
tomc271 Feb 23, 2024
f4cbb8c
Remove obsolete inverse() and jacobian() in boutcpp.pxd.jinja file.
tomchapman Mar 5, 2024
1293ff6
Restore semicolons after macros.
tomchapman Mar 5, 2024
8a003ef
Remove redundant `const`.
tomchapman Mar 5, 2024
315d739
Fix MetricTensor::inverse method (it was replacing each metric compon…
tomchapman Mar 5, 2024
eb58344
Restore commented-out code (Maximum error in diagonal/off-diagonal in…
tomchapman Mar 5, 2024
c1246bd
Use 'auto' when type name is obvious.
tomchapman Mar 5, 2024
b371136
Clang-tidy: "Use auto when initialising with a template cast to avoid…
tomchapman Mar 11, 2024
de146f1
Bug fix: Don't specify region when setting contravariant metric tenso…
tomchapman Mar 12, 2024
7ad4b39
Merge remote-tracking branch 'remotes/boutproject/next' into refactor…
tomchapman Mar 12, 2024
d1516db
Update petsc cases to use new getters.
tomchapman Mar 13, 2024
518672d
Remove calls to geometry().
tomchapman Mar 13, 2024
cf6df73
Set death_test_style to "threadsafe", to prevent timeout.
tomchapman Mar 13, 2024
3cddd46
Add [[maybe_unused]] attribute to 'J' parameter in Coordinates constr…
tomchapman Mar 14, 2024
99751c6
Revert expansion of COPY_STRIPE macro.
tomchapman Mar 14, 2024
5d0a696
Remove redundant function 'ChristoffelSymbols::map' (instead just cal…
tomchapman Mar 14, 2024
15815f4
Revert "Minor fixes."
tomchapman Mar 14, 2024
b8a2158
Apply clang-format changes
tomc271 Mar 14, 2024
c46d0ab
More updates to examples and tests to use dx setter.
tomchapman Mar 14, 2024
550a42d
Merge remote-tracking branch 'remotes/boutproject/refactor-coordinate…
tomchapman Mar 14, 2024
9466334
Rename file MetricTensor to use snake case.
tomchapman Mar 14, 2024
031fb4b
Updated another example (gravity_reduced) to use new metric tensor se…
tomchapman Mar 14, 2024
d259faf
Apply clang-format changes
tomc271 Mar 14, 2024
ad36b89
Remove obsolete comment.
tomchapman Mar 14, 2024
e7bdfcf
Make jacobian setter take a const reference.
tomchapman Mar 15, 2024
2e46100
Call communicateAndCheckMeshSpacing() in ChristoffelSymbols construct…
tomchapman Mar 15, 2024
92aaaa1
Remove unused #include.
tomchapman Mar 20, 2024
9adbfda
Clang-Tidy: Single-argument constructors must be marked explicit to a…
tomchapman Mar 20, 2024
62dcf21
Remove unused #include directives.
tomchapman Mar 20, 2024
77231a6
Prefer const.
tomchapman Mar 20, 2024
0235449
Add [[maybe_unused]] attributes.
tomchapman Mar 20, 2024
c967204
More unused #include directives.
tomchapman Mar 20, 2024
2718250
Clang-Tidy: The 'empty' method should be used to check for emptiness …
tomchapman Mar 20, 2024
c7b70a9
More [[maybe_unused]] attributes.
tomchapman Mar 20, 2024
07078ed
Clang-Tidy: Method can be made static.
tomchapman Mar 20, 2024
363223a
Clang-Tidy: Constructors that are callable with a single argument mus…
tomchapman Mar 20, 2024
1d36429
Another unused #include directive.
tomchapman Mar 20, 2024
9e651aa
More [[maybe_unused]] attributes and unused #include directives.
tomchapman Mar 21, 2024
ac9cad6
Use std::move() for constructor parameters.
tomchapman Mar 21, 2024
0dfafd4
More unused #include directives.
tomchapman Mar 21, 2024
7348598
Merge branch 'clang-tidy' into refactor-coordinates
tomchapman Mar 25, 2024
53b181e
No need to communicateAndCheckMeshSpacing() after creating Coordinates.
tomchapman Mar 23, 2024
1624876
Revert "Move interpolateAndExtrapolate() to Mesh class."
tomchapman Mar 23, 2024
5c1e0f5
Merge remote-tracking branch 'remotes/boutproject/next' into refactor…
tomchapman Mar 25, 2024
e998baa
Fix using FieldMetric = Field3D.
tomchapman Mar 23, 2024
b50a5e2
Fix Field3D Coordinates::interpolateAndExtrapolate method.
tomchapman Mar 23, 2024
1786e04
Add 3D version of setDy() for the BOUT_USE_METRIC_3D case.
tomchapman Mar 23, 2024
a837b72
d2z can't be const to work with Mesh::get().
tomchapman Mar 23, 2024
9966161
Update BOUT_USE_METRIC_3D case to use metric tensor getters.
tomchapman Mar 23, 2024
e7a8e77
Return type of Grad_par() and Vpar_Grad_par() should be FieldMetric, …
tomchapman Mar 23, 2024
4c33d86
Add 3D version of setJ() for the BOUT_USE_METRIC_3D case.
tomchapman Mar 23, 2024
44dff02
Return type of the std::function parameter to MetricTensor::map shoul…
tomchapman Mar 23, 2024
b46795e
Return type of Mesh::get() should be FieldMetric, not Field2D
tomchapman Mar 23, 2024
164660a
Bug fix: Mesh::get() should return a Field3D in the BOUT_USE_METRIC_3…
tomchapman Mar 25, 2024
4e296bd
Merge branch 'fix-for-3d' into refactor-coordinates
tomchapman Mar 25, 2024
3b09a2d
Fix updating of Bxy by splitParallelSlices().
tomchapman Mar 23, 2024
3e03b76
Fix updating of Bxy yup and ydown.
tomchapman Mar 23, 2024
e551211
Fix updating of Bxy by splitParallelSlices().
tomchapman Mar 23, 2024
3642d69
Fix updating of Bxy yup and ydown.
tomchapman Mar 23, 2024
a03362a
Merge branch 'fix-for-3d' into refactor-coordinates
tomchapman Mar 25, 2024
9df8bf8
G1, G2, G3 are now calculated in the GValues constructor, so no need …
tomchapman Mar 23, 2024
002539f
Remove call to obsolete method coords._setmembers().
tomchapman Mar 23, 2024
459e598
Refactoring to DRY up Mesh::createDefaultCoordinates().
tomchapman Mar 25, 2024
ce2066b
Add new coordinates object to coords_map before calling recalculateAn…
tomchapman Mar 25, 2024
a0fc687
Improve exception handling - ensure that transform is not null before…
tomchapman Mar 25, 2024
968497e
Ensure transform is set even when Coordinates is instantiated with th…
tomchapman Mar 25, 2024
cefb4ee
Need to ensure parallel transform is set before differential operator…
tomchapman Mar 26, 2024
b68f69d
Don't setLocation() of dz at this point, to avoid ASSERT1_FIELDS_COMP…
tomchapman Mar 26, 2024
dd0ee5c
Reorder to put the variable closer to its point of use.
tomchapman Mar 26, 2024
2ea7e27
Fix type of dJ_dy in LaplaceHypre3d::updateMatrix3D() (3D not 2D).
tomchapman Mar 26, 2024
c0b4e04
Disable "Laplacian solver in 2D (X-Y)" for the BOUT_USE_METRIC_3D case.
tomchapman Mar 29, 2024
cee7596
Fix test-laplacexz: Use a non-zero value for off-diagonal components …
tomchapman Mar 29, 2024
6232eb4
Apply clang-format changes
tomc271 Mar 28, 2024
9498ae1
Merge remote-tracking branch 'remotes/boutproject/next' into refactor…
tomchapman Apr 8, 2024
59faafd
Merge branch 'next' into refactor-coordinates
tomchapman May 2, 2024
17f7097
include <functional>
May 10, 2024
10d0fdb
Add Coordinates::setMetricTensor() method for setting both co- and co…
tomchapman May 11, 2024
834f11a
Call Mesh::communicate() rather than Coordinates::communicate() when …
tomchapman May 13, 2024
e045f2e
Add a version of Mesh::communicate<T>() that takes const-qualified pa…
tomchapman May 14, 2024
5ced89d
Allow FieldGroup to take const-qualified parameters.
tomchapman May 14, 2024
2f7a6af
Add a version of Coordinates::communicate<T>() that takes const-quali…
tomchapman May 14, 2024
22a6341
Replace variadic template with two methods: void communicate(const Fi…
tomchapman May 14, 2024
27b461b
This fixes the failure of tests `NotConstructableFromInt` and `NotCon…
tomchapman May 14, 2024
b53d092
Various Clang-Tidy suggestions.
tomchapman May 14, 2024
f1216b1
Do the copying in the method that calls communicate(), so that the co…
tomchapman May 14, 2024
736198b
Do the copying in the method that calls Mesh::communicate(), so that …
tomchapman May 15, 2024
b308f6c
Merge branch 'communicate-const-qualified' into refactor-coordinates
tomchapman May 15, 2024
3d17795
Add MetricTensor::communicate() method, since need to pass a non-cons…
tomchapman May 16, 2024
550c38f
Add ChristoffelSymbols::communicate() method.
tomchapman May 16, 2024
47017c6
Pass (const refs to) the actual d1_dx, d1_dy, d1_dz data to localmesh…
tomchapman May 16, 2024
fdc6c28
Add GValues::communicate() method.
tomchapman May 16, 2024
896a610
Remove redundant methods Coordinates::communicateChristoffelSymbolTer…
tomchapman May 16, 2024
545ede8
Coordinates::communicate() method needs to take a non-const parameter…
tomchapman May 17, 2024
e7df6bc
Fix copy-paste errors introduced during refactoring.
tomchapman May 16, 2024
04c9399
Restore #include "impls/bout/boutmesh.hxx"
tomchapman May 16, 2024
c703dd3
Merge branch 'communicate-fix' into fx01
tomchapman May 22, 2024
8194863
Revert "More [[maybe_unused]] attributes."
tomchapman May 22, 2024
3ce726c
Revert "Add [[maybe_unused]] attributes."
tomchapman May 22, 2024
53622ec
Revert "Prefer const."
tomchapman May 22, 2024
8650f4f
Add test CheckCovariantCalculatedFromContravariant to CoordinatesTest…
tomchapman May 22, 2024
d32f7a6
Add test CheckContravariantCalculatedFromCovariant to CoordinatesTest…
tomchapman May 22, 2024
fb181e9
Merge remote-tracking branch 'remotes/boutproject/next' into refactor…
tomchapman Jun 3, 2024
45abd74
Use new method Coordinates::setMetricTensor() when manually setting b…
tomchapman Jun 4, 2024
357601d
Define local variables on assignment (and using auto).
tomchapman Jun 4, 2024
e713a5e
Prefer const.
tomchapman Jun 4, 2024
1ad60a6
Fix copy-paste errors introduced during refactoring (more).
tomchapman Jun 4, 2024
de8abf3
Define local variables on assignment (and using auto).
tomchapman Jun 4, 2024
3928562
Revert "Clang-Tidy: Constructors that are callable with a single argu…
tomchapman Jun 4, 2024
3f4abe0
Revert "Use std::move() for constructor parameters."
tomchapman Jun 4, 2024
49deb09
Revert "Another unused #include directive."
tomchapman Jun 4, 2024
bf5e9e9
Revert "Clang-Tidy: Single-argument constructors must be marked expli…
tomchapman Jun 4, 2024
ec6b7d3
Revert "Remove redundant semicolons."
tomchapman Jun 4, 2024
68fa3a4
Revert "More [[maybe_unused]] attributes."
tomchapman Jun 4, 2024
e3cb84e
Revert "More unused #include directives."
tomchapman Jun 4, 2024
3d293c4
Revert "Clang-Tidy: The 'empty' method should be used to check for em…
tomchapman Jun 4, 2024
64ed06e
Apply clang-format changes
tomc271 Jun 6, 2024
5ff4df3
Restore semicolons after macros.
tomchapman Jun 6, 2024
187c081
Revert accidental renaming in docs.
tomchapman Jun 6, 2024
e5d1c77
Revert "Clang-Tidy: Method can be made static."
tomchapman Jun 6, 2024
12e769c
Revert "More unused #include directives."
tomchapman Jun 6, 2024
b692beb
Clang-Tidy: Static member accessed through instance.
tomchapman Jun 6, 2024
804d77a
Clang-Tidy: variable can be declared 'const'.
tomchapman Jun 6, 2024
ae29dc8
Apply clang-format changes
tomc271 Jun 6, 2024
77896a3
Rename setBoundaryCells() to readFromMesh(), and interpolateFieldsFro…
tomchapman Jun 7, 2024
7c68462
Bug fix: can't assign to a const ref - Use a temporary variable with …
tomchapman Jun 7, 2024
69eee97
Remove const qualifier from declaration of temporary copy of Bxy.
tomchapman Jun 7, 2024
541ff17
x, y, z are accessed through getters on BoundaryRegionPar.
tomchapman Jun 7, 2024
ec1e0ac
Bug fix: can't assign to a const ref - Use a temporary variable with …
tomchapman Jun 7, 2024
67e4c3d
Define local variables on assignment (and using auto).
tomchapman Jun 10, 2024
2e88073
Explicity setting the jacobian has to come after setting the metric t…
tomchapman Jun 10, 2024
33111b3
Apply clang-format changes
tomc271 Jun 10, 2024
2dfdb42
Add overload getters for dx, dy, and dz, that give the value at a par…
Jul 16, 2024
4c2a1d1
Use overloaded getters for dx, dy, and dz.
tomchapman Jul 16, 2024
dc2b0c3
Merge remote-tracking branch 'remotes/boutproject/next' into refactor…
tomchapman Jul 8, 2024
a5157ce
Merge remote-tracking branch 'remotes/boutproject/next' into refactor…
tomchapman Sep 23, 2024
fa24eb8
Add overloaded getters for d1_dx, d1_dy, and d1_dz, that give the val…
tomchapman Sep 23, 2024
541da12
The (x, y) indexing methods return a pointer when BOUT_USE_METRIC_3D …
tomchapman Sep 25, 2024
a2b9584
Add overloaded getters for metric tensor components, that give the va…
tomchapman Sep 24, 2024
4fb48ba
Use overloaded getters for metric tensor components.
tomchapman Sep 24, 2024
7041398
Getters for metric tensor components given (x, y) indices.
tomchapman Sep 24, 2024
f2e01ab
The (x, y) indexing methods return a pointer when BOUT_USE_METRIC_3D …
tomchapman Sep 25, 2024
35d0912
Disable metric tensor getter with (x, y) arguments when BOUT_USE_METR…
tomchapman Sep 25, 2024
4852b00
Use overloaded getters for metric tensor components.
tomchapman Sep 27, 2024
dca8598
Improve readability of preprocessor directive
tomchapman Oct 1, 2024
078a51b
Add overloaded getter for IntShiftTorsion that gives the value at a p…
tomchapman Oct 1, 2024
f49eb92
Add overloaded getter for J() that gives the value at a particular x,…
tomchapman Oct 1, 2024
8ad42cc
Add overloaded getter for zlength() that gives the value at a particu…
tomchapman Oct 1, 2024
10bf54a
Add overloaded getters for G1, G2, G3, that give the value at a parti…
tomchapman Oct 1, 2024
3d8198f
Apply clang-format changes
tomc271 Oct 2, 2024
cbce1b4
Revert "x, y, z are accessed through getters on BoundaryRegionPar."
ZedThree Oct 23, 2024
fa6663d
Fix clang-tidy const-correctness warnings
ZedThree Oct 23, 2024
c85f2ad
Merge branch 'next' into refactor-coordinates
ZedThree Oct 23, 2024
5b61d2b
Rename metric tensor component members
ZedThree Oct 23, 2024
e2d3c52
Use `std::array` instead of C array
ZedThree Oct 23, 2024
687f0c4
Fix some clang-tidy warnings in metric_tensor
ZedThree Oct 23, 2024
2411ab2
Reduce duplication in metric tensor between 2D/3D metric a little
ZedThree Oct 23, 2024
1213035
Inline metric tensor function application `map`
ZedThree Oct 23, 2024
e5010e4
Use free-function derivatives in metric tensor classes
ZedThree Oct 23, 2024
a926df1
Remove some unused ctors from metric tensor classes
ZedThree Oct 24, 2024
ff3fdef
Ensure metric derivatives are always communicated
ZedThree Oct 24, 2024
676f0a0
Remove `MetricTensor::setLocation`
ZedThree Oct 24, 2024
ff12e4a
Pull out duplicated region name
ZedThree Oct 24, 2024
8a1d040
Remove specialised `setDy`, `setJ` overloads
ZedThree Oct 24, 2024
0663ea8
Ensure grid spacings, Bxy, J, are always communicated
ZedThree Oct 24, 2024
a4fe574
Ensure metric terms are always communicated
ZedThree Oct 24, 2024
b276d74
Simplify `recalculateJacobian` a little
ZedThree Oct 24, 2024
61196bf
Eliminate some unnecessary local variables
ZedThree Oct 24, 2024
42dc6ee
Inline some single-use functions
ZedThree Oct 24, 2024
47cff9e
Fix wrong type in MMS/gbs
ZedThree Oct 24, 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
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,15 @@ set(BOUT_SOURCES
./src/sys/timer.cxx
./src/sys/type_name.cxx
./src/sys/utils.cxx
./include/bout/metric_tensor.hxx
./src/mesh/metric_tensor.cxx
./include/bout/christoffel_symbols.hxx
./src/mesh/christoffel_symbols.cxx
./include/bout/g_values.hxx
./src/mesh/g_values.cxx
${CMAKE_CURRENT_BINARY_DIR}/include/bout/revision.hxx
${CMAKE_CURRENT_BINARY_DIR}/include/bout/version.hxx
)
)


find_package(Python3)
Expand Down
43 changes: 22 additions & 21 deletions examples/6field-simple/elm_6f.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class Elm_6f : public PhysicsModel {
result.allocate();
for (auto i : result) {
result[i] =
(fp[i.yp()] - fm[i.ym()]) / (2. * coord->dy[i] * sqrt(coord->g_22[i]));
(fp[i.yp()] - fm[i.ym()]) / (2. * coord->dy()[i] * sqrt(coord->g_22()[i]));
}
} else {
result = Grad_par(f, loc);
Expand Down Expand Up @@ -705,7 +705,7 @@ class Elm_6f : public PhysicsModel {

if (mesh->IncIntShear) {
// BOUT-06 style, using d/dx = d/dpsi + I * d/dz
coord->IntShiftTorsion = I;
coord->setIntShiftTorsion(I);

} else {
// Dimits style, using local coordinate system
Expand Down Expand Up @@ -867,7 +867,7 @@ class Elm_6f : public PhysicsModel {
Btxy /= Bbar;
B0 /= Bbar;
hthe /= Lbar;
coord->dx /= Lbar * Lbar * Bbar;
coord->setDx(coord->dx() / (Lbar * Lbar * Bbar));
I *= Lbar * Lbar * Bbar;

if ((!T0_fake_prof) && n0_fake_prof) {
Expand Down Expand Up @@ -1051,24 +1051,25 @@ class Elm_6f : public PhysicsModel {

/**************** CALCULATE METRICS ******************/

coord->g11 = SQ(Rxy * Bpxy);
coord->g22 = 1.0 / SQ(hthe);
coord->g33 = SQ(I) * coord->g11 + SQ(B0) / coord->g11;
coord->g12 = 0.0;
coord->g13 = -I * coord->g11;
coord->g23 = -Btxy / (hthe * Bpxy * Rxy);
const auto g11 = SQ(Rxy * Bpxy);
const auto g22 = 1.0 / SQ(hthe);
const auto g33 = SQ(I) * g11 + SQ(B0) / g11;
const auto g12 = 0.0;
const auto g13 = -I * g11;
const auto g23 = -Btxy / (hthe * Bpxy * Rxy);

coord->J = hthe / Bpxy;
coord->Bxy = B0;
const auto g_11 = 1.0 / g11 + SQ(I * Rxy);
const auto g_22 = SQ(B0 * hthe / Bpxy);
const auto g_33 = Rxy * Rxy;
const auto g_12 = Btxy * hthe * I * Rxy / Bpxy;
const auto g_13 = I * Rxy * Rxy;
const auto g_23 = Btxy * hthe * Rxy / Bpxy;

coord->g_11 = 1.0 / coord->g11 + SQ(I * Rxy);
coord->g_22 = SQ(B0 * hthe / Bpxy);
coord->g_33 = Rxy * Rxy;
coord->g_12 = Btxy * hthe * I * Rxy / Bpxy;
coord->g_13 = I * Rxy * Rxy;
coord->g_23 = Btxy * hthe * Rxy / Bpxy;
coord->setMetricTensor(ContravariantMetricTensor(g11, g22, g33, g12, g13, g23),
CovariantMetricTensor(g_11, g_22, g_33, g_12, g_13, g_23));

coord->geometry(); // Calculate quantities from metric tensor
coord->setJ(hthe / Bpxy);
coord->setBxy(B0);

tomc271 marked this conversation as resolved.
Show resolved Hide resolved
// Set B field vector

Expand Down Expand Up @@ -1446,11 +1447,11 @@ class Elm_6f : public PhysicsModel {
if (hyperviscos > 0.0) {
// Calculate coefficient.

hyper_mu_x = hyperviscos * coord->g_11 * SQ(coord->dx)
* abs(coord->g11 * D2DX2(U)) / (abs(U) + 1e-3);
hyper_mu_x = hyperviscos * coord->g_11() * SQ(coord->dx())
* abs(coord->g11() * D2DX2(U)) / (abs(U) + 1e-3);
hyper_mu_x.applyBoundary("dirichlet"); // Set to zero on all boundaries

ddt(U) += hyper_mu_x * coord->g11 * D2DX2(U);
ddt(U) += hyper_mu_x * coord->g11() * D2DX2(U);

if (first_run) {
// Print out maximum values of viscosity used on this processor
Expand Down
2 changes: 1 addition & 1 deletion examples/IMEX/drift-wave-constraint/test-drift.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class DriftWave : public PhysicsModel {
// ddt(phi) = Delp2(phi) - Vort;

// This version uses central differencing for Delp2
ddt(phi) = (coord->g11 * D2DX2(phi) + coord->g33 * D2DZ2(phi)) - Vort;
ddt(phi) = (coord->g11() * D2DX2(phi) + coord->g33() * D2DZ2(phi)) - Vort;

return 0;
}
Expand Down
41 changes: 21 additions & 20 deletions examples/conducting-wall-mode/cwm.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class CWM : public PhysicsModel {

// Load metrics
GRID_LOAD(Rxy, Zxy, Bpxy, Btxy, hthe);
mesh->get(coord->dx, "dpsi");
coord->setDx(mesh->get("dpsi"));
mesh->get(I, "sinty");

// Load normalisation values
Expand Down Expand Up @@ -136,35 +136,36 @@ class CWM : public PhysicsModel {
Rxy /= rho_s;
hthe /= rho_s;
I *= rho_s * rho_s * (bmag / 1e4) * ShearFactor;
coord->dx /= rho_s * rho_s * (bmag / 1e4);
coord->setDx(coord->dx() / (rho_s * rho_s * (bmag / 1e4)));

// Normalise magnetic field
Bpxy /= (bmag / 1.e4);
Btxy /= (bmag / 1.e4);
coord->Bxy /= (bmag / 1.e4);
coord->setBxy(coord->Bxy() / (bmag / 1.e4));

// Set nu
nu = nu_hat * Ni0 / pow(Te0, 1.5);

/**************** CALCULATE METRICS ******************/

coord->g11 = SQ(Rxy * Bpxy);
coord->g22 = 1.0 / SQ(hthe);
coord->g33 = SQ(I) * coord->g11 + SQ(coord->Bxy) / coord->g11;
coord->g12 = 0.0;
coord->g13 = -I * coord->g11;
coord->g23 = -Btxy / (hthe * Bpxy * Rxy);
const auto g11 = SQ(Rxy * Bpxy);
const auto g22 = 1.0 / SQ(hthe);
const auto g33 = SQ(I) * g11 + SQ(coord->Bxy()) / g11;
const auto g12 = 0.0;
const auto g13 = -I * g11;
const auto g23 = -Btxy / (hthe * Bpxy * Rxy);

coord->J = hthe / Bpxy;
const auto g_11 = 1.0 / g11 + SQ(I * Rxy);
const auto g_22 = SQ(coord->Bxy() * hthe / Bpxy);
const auto g_33 = Rxy * Rxy;
const auto g_12 = Btxy * hthe * I * Rxy / Bpxy;
const auto g_13 = I * Rxy * Rxy;
const auto g_23 = Btxy * hthe * Rxy / Bpxy;

tomc271 marked this conversation as resolved.
Show resolved Hide resolved
coord->g_11 = 1.0 / coord->g11 + SQ(I * Rxy);
coord->g_22 = SQ(coord->Bxy * hthe / Bpxy);
coord->g_33 = Rxy * Rxy;
coord->g_12 = Btxy * hthe * I * Rxy / Bpxy;
coord->g_13 = I * Rxy * Rxy;
coord->g_23 = Btxy * hthe * Rxy / Bpxy;
coord->setMetricTensor(ContravariantMetricTensor(g11, g22, g33, g12, g13, g23),
CovariantMetricTensor(g_11, g_22, g_33, g_12, g_13, g_23));

coord->geometry();
coord->setJ(hthe / Bpxy);

/**************** SET EVOLVING VARIABLES *************/

Expand Down Expand Up @@ -349,7 +350,7 @@ class CWM : public PhysicsModel {
result = VDDX(DDZ(p), f);
} else {
// Use full expression with all terms
result = b0xGrad_dot_Grad(p, f) / coord->Bxy;
result = b0xGrad_dot_Grad(p, f) / coord->Bxy();
}
return result;
}
Expand All @@ -361,7 +362,7 @@ class CWM : public PhysicsModel {
result = VDDZ(-DDX(p), f);
} else {
// Use full expression with all terms
result = b0xGrad_dot_Grad(p, f) / coord->Bxy;
result = b0xGrad_dot_Grad(p, f) / coord->Bxy();
}
return result;
}
Expand All @@ -373,7 +374,7 @@ class CWM : public PhysicsModel {
result = VDDX(DDZ(p), f) + VDDZ(-DDX(p), f);
} else {
// Use full expression with all terms
result = b0xGrad_dot_Grad(p, f) / coord->Bxy;
result = b0xGrad_dot_Grad(p, f) / coord->Bxy();
}
return result;
}
Expand Down
35 changes: 18 additions & 17 deletions examples/constraints/alfven-wave/alfven.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class Alfven : public PhysicsModel {
Field2D dx;
if (!mesh->get(dx, "dpsi")) {
output << "\tUsing dpsi as the x grid spacing\n";
coord->dx = dx; // Only use dpsi if found
coord->setDx(dx); // Only use dpsi if found
} else {
// dx will have been read already from the grid
output << "\tUsing dx as the x grid spacing\n";
Expand All @@ -179,11 +179,11 @@ class Alfven : public PhysicsModel {
Rxy /= Lnorm;
hthe /= Lnorm;
sinty *= SQ(Lnorm) * Bnorm;
coord->dx /= SQ(Lnorm) * Bnorm;
coord->setDx(coord->dx() / (SQ(Lnorm) * Bnorm));

Bpxy /= Bnorm;
Btxy /= Bnorm;
coord->Bxy /= Bnorm;
coord->setBxy(coord->Bxy() / Bnorm);

// Check type of parallel transform
std::string ptstr =
Expand All @@ -201,23 +201,24 @@ class Alfven : public PhysicsModel {

// Calculate metric components

coord->g11 = SQ(Rxy * Bpxy);
coord->g22 = 1.0 / SQ(hthe);
coord->g33 = SQ(sinty) * coord->g11 + SQ(coord->Bxy) / coord->g11;
coord->g12 = 0.0;
coord->g13 = -sinty * coord->g11;
coord->g23 = -sbp * Btxy / (hthe * Bpxy * Rxy);
const auto g11 = SQ(Rxy * Bpxy);
const auto g22 = 1.0 / SQ(hthe);
const auto g33 = SQ(sinty) * g11 + SQ(coord->Bxy()) / g11;
const auto g12 = 0.0;
const auto g13 = -sinty * g11;
const auto g23 = -sbp * Btxy / (hthe * Bpxy * Rxy);

coord->J = hthe / Bpxy;
const auto g_11 = 1.0 / g11 + SQ(sinty * Rxy);
const auto g_22 = SQ(coord->Bxy() * hthe / Bpxy);
const auto g_33 = Rxy * Rxy;
const auto g_12 = sbp * Btxy * hthe * sinty * Rxy / Bpxy;
const auto g_13 = sinty * Rxy * Rxy;
const auto g_23 = sbp * Btxy * hthe * Rxy / Bpxy;

coord->g_11 = 1.0 / coord->g11 + SQ(sinty * Rxy);
coord->g_22 = SQ(coord->Bxy * hthe / Bpxy);
coord->g_33 = Rxy * Rxy;
coord->g_12 = sbp * Btxy * hthe * sinty * Rxy / Bpxy;
coord->g_13 = sinty * Rxy * Rxy;
coord->g_23 = sbp * Btxy * hthe * Rxy / Bpxy;
coord->setMetricTensor(ContravariantMetricTensor(g11, g22, g33, g12, g13, g23),
CovariantMetricTensor(g_11, g_22, g_33, g_12, g_13, g_23));

coord->geometry();
coord->setJ(hthe / Bpxy);
}
};

Expand Down
39 changes: 20 additions & 19 deletions examples/dalf3/dalf3.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -243,29 +243,30 @@ class DALF3 : public PhysicsModel {
Btxy /= Bnorm;
B0 /= Bnorm;

coord->dx /= rho_s * rho_s * Bnorm;
coord->setDx(coord->dx() / (rho_s * rho_s * Bnorm));

///////////////////////////////////////////////////
// CALCULATE METRICS

coord->g11 = SQ(Rxy * Bpxy);
coord->g22 = 1.0 / SQ(hthe);
coord->g33 = SQ(I) * coord->g11 + SQ(B0) / coord->g11;
coord->g12 = 0.0;
coord->g13 = -I * coord->g11;
coord->g23 = -Btxy / (hthe * Bpxy * Rxy);

coord->J = hthe / Bpxy;
coord->Bxy = B0;

coord->g_11 = 1.0 / coord->g11 + SQ(I * Rxy);
coord->g_22 = SQ(B0 * hthe / Bpxy);
coord->g_33 = Rxy * Rxy;
coord->g_12 = Btxy * hthe * I * Rxy / Bpxy;
coord->g_13 = I * Rxy * Rxy;
coord->g_23 = Btxy * hthe * Rxy / Bpxy;

coord->geometry(); // Calculate quantities from metric tensor
const auto g11 = SQ(Rxy * Bpxy);
const auto g22 = 1.0 / SQ(hthe);
const auto g33 = SQ(I) * g11 + SQ(B0) / g11;
const auto g12 = 0.0;
const auto g13 = -I * g11;
const auto g23 = -Btxy / (hthe * Bpxy * Rxy);

const auto g_11 = 1.0 / g11 + SQ(I * Rxy);
const auto g_22 = SQ(B0 * hthe / Bpxy);
const auto g_33 = Rxy * Rxy;
const auto g_12 = Btxy * hthe * I * Rxy / Bpxy;
const auto g_13 = I * Rxy * Rxy;
const auto g_23 = Btxy * hthe * Rxy / Bpxy;

coord->setMetricTensor(ContravariantMetricTensor(g11, g22, g33, g12, g13, g23),
CovariantMetricTensor(g_11, g_22, g_33, g_12, g_13, g_23));

coord->setJ(hthe / Bpxy);
coord->setBxy(B0);

SOLVE_FOR3(Vort, Pe, Vpar);
comms.add(Vort, Pe, Vpar);
Expand Down
43 changes: 22 additions & 21 deletions examples/elm-pb-outerloop/elm_pb_outerloop.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ class ELMpb : public PhysicsModel {

if (mesh->IncIntShear) {
// BOUT-06 style, using d/dx = d/dpsi + I * d/dz
metric->IntShiftTorsion = I;
metric->setIntShiftTorsion(I);

} else {
// Dimits style, using local coordinate system
Expand Down Expand Up @@ -962,7 +962,7 @@ class ELMpb : public PhysicsModel {
Btxy /= Bbar;
B0 /= Bbar;
hthe /= Lbar;
metric->dx /= Lbar * Lbar * Bbar;
metric->setDx(metric->dx() / (Lbar * Lbar * Bbar));
I *= Lbar * Lbar * Bbar;

if (constn0) {
Expand Down Expand Up @@ -1092,24 +1092,25 @@ class ELMpb : public PhysicsModel {

/**************** CALCULATE METRICS ******************/

metric->g11 = SQ(Rxy * Bpxy);
metric->g22 = 1.0 / SQ(hthe);
metric->g33 = SQ(I) * metric->g11 + SQ(B0) / metric->g11;
metric->g12 = 0.0;
metric->g13 = -I * metric->g11;
metric->g23 = -Btxy / (hthe * Bpxy * Rxy);
const auto g11 = SQ(Rxy * Bpxy);
const auto g22 = 1.0 / SQ(hthe);
const auto g33 = SQ(I) * g11 + SQ(B0) / g11;
const auto g12 = 0.0;
const auto g13 = -I * g11;
const auto g23 = -Btxy / (hthe * Bpxy * Rxy);

metric->J = hthe / Bpxy;
metric->Bxy = B0;
const auto g_11 = 1.0 / g11 + SQ(I * Rxy);
const auto g_22 = SQ(B0 * hthe / Bpxy);
const auto g_33 = Rxy * Rxy;
const auto g_12 = Btxy * hthe * I * Rxy / Bpxy;
const auto g_13 = I * Rxy * Rxy;
const auto g_23 = Btxy * hthe * Rxy / Bpxy;

metric->g_11 = 1.0 / metric->g11 + SQ(I * Rxy);
metric->g_22 = SQ(B0 * hthe / Bpxy);
metric->g_33 = Rxy * Rxy;
metric->g_12 = Btxy * hthe * I * Rxy / Bpxy;
metric->g_13 = I * Rxy * Rxy;
metric->g_23 = Btxy * hthe * Rxy / Bpxy;
metric->setMetricTensor(ContravariantMetricTensor(g11, g22, g33, g12, g13, g23),
CovariantMetricTensor(g_11, g_22, g_33, g_12, g_13, g_23));

metric->geometry(); // Calculate quantities from metric tensor
metric->setJ(hthe / Bpxy);
metric->setBxy(B0);

// Set B field vector

Expand Down Expand Up @@ -1792,11 +1793,11 @@ class ELMpb : public PhysicsModel {
if (hyperviscos > 0.0) {
// Calculate coefficient.

hyper_mu_x = hyperviscos * metric->g_11 * SQ(metric->dx)
* abs(metric->g11 * D2DX2(U)) / (abs(U) + 1e-3);
hyper_mu_x = hyperviscos * metric->g_11() * SQ(metric->dx())
* abs(metric->g11() * D2DX2(U)) / (abs(U) + 1e-3);
hyper_mu_x.applyBoundary("dirichlet"); // Set to zero on all boundaries

ddt(U) += hyper_mu_x * metric->g11 * D2DX2(U);
ddt(U) += hyper_mu_x * metric->g11() * D2DX2(U);

if (first_run) { // Print out maximum values of viscosity used on this processor
output.write(" Hyper-viscosity values:\n");
Expand Down Expand Up @@ -1907,7 +1908,7 @@ class ELMpb : public PhysicsModel {
BoutReal pnorm = P0(0, 0);
ddt(P) += heating_P * source_expx2(P0, 2. * hp_width, 0.5 * hp_length)
* (Tbar / pnorm); // heat source
ddt(P) += (100. * source_tanhx(P0, hp_width, hp_length) + 0.01) * metric->g11
ddt(P) += (100. * source_tanhx(P0, hp_width, hp_length) + 0.01) * metric->g11()
* D2DX2(P) * (Tbar / Lbar / Lbar); // radial diffusion
}

Expand Down
Loading
Loading