#include #include #include using namespace amrex; using namespace Gpu; /* \brief Initialize k space object. * * \param realspace_ba Box array that corresponds to the decomposition * of the fields in real space (cell-centered ; includes guard cells) * \param dm Indicates which MPI proc owns which box, in realspace_ba. * \param realspace_dx Cell size of the grid in real space */ SpectralKSpace::SpectralKSpace( const BoxArray& realspace_ba, const DistributionMapping& dm, const RealVect realspace_dx ) : dx(realspace_dx) // Store the cell size as member `dx` { AMREX_ALWAYS_ASSERT_WITH_MESSAGE( realspace_ba.ixType()==IndexType::TheCellType(), "SpectralKSpace expects a cell-centered box."); // Create the box array that corresponds to spectral space BoxList spectral_bl; // Create empty box list // Loop over boxes and fill the box list for (int i=0; i < realspace_ba.size(); i++ ) { // For local FFTs, boxes in spectral space start at 0 in // each direction and have the same number of points as the // (cell-centered) real space box // TODO: this will be different for the hybrid FFT scheme Box realspace_bx = realspace_ba[i]; IntVect fft_size = realspace_bx.length(); // Because the spectral solver uses real-to-complex FFTs, we only // need the positive k values along the fastest axis // (first axis for AMReX Fortran-order arrays) in spectral space. // This effectively reduces the size of the spectral space by half // see e.g. the FFTW documentation for real-to-complex FFTs IntVect spectral_bx_size = fft_size; spectral_bx_size[0] = fft_size[0]/2 + 1; // Define the corresponding box Box spectral_bx = Box( IntVect::TheZeroVector(), spectral_bx_size - IntVect::TheUnitVector() ); spectral_bl.push_back( spectral_bx ); } spectralspace_ba.define( spectral_bl ); // Allocate the components of the k vector: kx, ky (only in 3D), kz bool only_positive_k; for (int i_dim=0; i_dim& k = k_comp[mfi]; // Allocate k to the right size int N = bx.length( i_dim ); k.resize( N ); // Fill the k vector IntVect fft_size = realspace_ba[mfi].length(); const Real dk = 2*MathConst::pi/(fft_size[i_dim]*dx[i_dim]); AMREX_ALWAYS_ASSERT_WITH_MESSAGE( bx.smallEnd(i_dim) == 0, "Expected box to start at 0, in spectral space."); AMREX_ALWAYS_ASSERT_WITH_MESSAGE( bx.bigEnd(i_dim) == N-1, "Expected different box end index in spectral space."); if (only_positive_k){ // Fill the full axis with positive k values // (typically: first axis, in a real-to-complex FFT) for (int i=0; i& k = k_vec[i_dim][mfi]; ManagedVector& shift = shift_factor[mfi]; // Allocate shift coefficients shift.resize( k.size() ); // Fill the shift coefficients Real sign = 0; switch (shift_type){ case ShiftType::TransformFromCellCentered: sign = -1.; break; case ShiftType::TransformToCellCentered: sign = 1.; } const Complex I{0,1}; for (int i=0; i stencil_coef = getFonbergStencilCoefficients(n_order, nodal); // Loop over boxes and allocate the corresponding ManagedVector // for each box owned by the local MPI proc for ( MFIter mfi(spectralspace_ba, dm); mfi.isValid(); ++mfi ){ Real delta_x = dx[i_dim]; const ManagedVector& k = k_vec[i_dim][mfi]; ManagedVector& modified_k = modified_k_comp[mfi]; // Allocate modified_k to the same size as k modified_k.resize( k.size() ); // Fill the modified k vector for (int i=0; i getFonbergStencilCoefficients( const int n_order, const bool nodal ) { AMREX_ALWAYS_ASSERT_WITH_MESSAGE( n_order%2 == 0, "n_order should be even."); const int m = n_order/2; Vector coefs; coefs.resize( m+1 ); // Note: there are closed-form formula for these coefficients, // but they result in an overflow when evaluated numerically. // One way to avoid the overflow is to calculate the coefficients // by recurrence. // Coefficients for nodal (a.k.a. centered) finite-difference if (nodal == true) { coefs[0] = -2.; // First coefficient for (int n=1; njarred/redo-zigstring-for-utf16 Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-08-15res.thenGravatar Dylan Conway 2-4/+4
2023-08-15fix this page (#4172)Gravatar dave caruso 1-5/+5
2023-08-15disable domjit for `Buffer.alloc`Gravatar Dylan Conway 1-5/+5
2023-08-15Fix event loop issue with `Bun.connect` (#4157)Gravatar dave caruso 3-3/+73
* Fix event loop issue with Bun.connect * sorry * add test and fix another edge case
2023-08-15fix make headersGravatar Dylan Conway 3-9/+38
2023-08-15fix buildGravatar Dylan Conway 2-0/+4
2023-08-15chore: fix method name typo (#4162)Gravatar Ai Hoshino 1-1/+1
2023-08-15fix importing too long of strings (#4155)Gravatar dave caruso 3-3/+45
2023-08-14Make builtins' source origin use a valid url (#4152)Gravatar dave caruso 4-275/+284
* Make source origin use a valid url * disable minifyWhiteSpace * the change
2023-08-14Small docs changeGravatar Colin McDonnell 1-2/+2
2023-08-13fix makefile (#4148)Gravatar dave caruso 1-1/+1
2023-08-12Update Stric guides (#4137)Gravatar Revenity 1-4/+6
2023-08-12Fix worker event loop ref/unref + leak (#4114)Gravatar dave caruso 35-263/+465
* make more tests pass * worker changes * fix some bugs * remove this * progress * uh * okay * remove console log * a * comment assert for later * mergable state * remove test * remove test
2023-08-11Fix using uninitialized variable when formatting `config_path`. (#4129)Gravatar Ai Hoshino 2-1/+21
Close: #4128
2023-08-11Deprecate loading `node_modules.bun` (#4131)Gravatar Jarred Sumner 34-2204/+222
* Deprecate loading `node_modules.bun` * realpath * regenerate schema * More * more * Update cli.zig --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-08-11`bun-wasm` fixes & improvements (#4126)Gravatar jhmaster 14-44/+252
* automate Bun.version & revision polyfills * polyfill Bun.gc * bun:jsc module initial polyfills * fixes & improvements to bun-wasm
2023-08-11Support TypeScript's `export type * as Foo from 'bar'` (#4125)Gravatar Jarred Sumner 2-9/+42
* [TypeScript] Support `export type * as Foo from 'bar'` * Update js_parser.zig --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-08-11Fix wasm buildGravatar Jarred Sumner 1-1/+5
2023-08-10async realpath (#4117)Gravatar Jarred Sumner 6-58/+184
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-08-10Remove assertionGravatar Jarred Sumner 1-3/+0
2023-08-10More lazily initialize these static stringsGravatar Jarred Sumner 1-5/+7
2023-08-10don't check for trailing slash, var streamGravatar Dylan Conway 3-9/+9
2023-08-10run files without extensions (#4113)Gravatar Dylan Conway 4-11/+46
* run script without extension * process stdio write fix
2023-08-10Fix memory leak in base64url (#4111)Gravatar Jarred Sumner 1-2/+2
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-08-10Handle thundering herd of setInterval (#4109)Gravatar Jarred Sumner 1-2/+17
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-08-10fs.zig: create temp files with 0o700, not 0o007 (#4107)Gravatar Adhityaa Chandrasekar 1-1/+1
2023-08-10Update remix guideGravatar Colin McDonnell 1-2/+4
2023-08-10zig fmtGravatar Jarred Sumner 1-4/+4
2023-08-10Fixes #4062 (#4106)Gravatar Jarred Sumner 8-26/+87
* Fixes #4062 * Update encoding.zig * Use faster C++ impl * Update wtf-bindings.cpp * undo * Fixup --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-08-10bun test: format description of test.each (#4092)Gravatar Jacques 3-13/+311
* bun test: format description * add tests for tests * only --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-08-10add util.formatWithOptions (#4090)Gravatar dave caruso 3-9/+30
* Add formatWithOptions * tests and tweaks * adjust --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-08-10Fix titleGravatar Colin McDonnell 1-1/+1