aboutsummaryrefslogtreecommitdiff
path: root/Source/Python
diff options
context:
space:
mode:
authorGravatar David Grote <grote1@llnl.gov> 2020-12-02 14:57:28 -0800
committerGravatar GitHub <noreply@github.com> 2020-12-02 14:57:28 -0800
commit7fe38c8d13d9a511ab8f2c1243a4c58ca393c813 (patch)
tree306e64ca69c22077a5fdc9ff698c833431dfd1e1 /Source/Python
parent16c404ec6918e8264b1def78e0ba3969d96cafad (diff)
downloadWarpX-7fe38c8d13d9a511ab8f2c1243a4c58ca393c813.tar.gz
WarpX-7fe38c8d13d9a511ab8f2c1243a4c58ca393c813.tar.zst
WarpX-7fe38c8d13d9a511ab8f2c1243a4c58ca393c813.zip
Fix python wrapper (#1532)
* Fixes to the Python interface for accessing field and particle data * In Python wrapper, cleaned up how ngrow is handled
Diffstat (limited to 'Source/Python')
-rw-r--r--Source/Python/WarpXWrappers.cpp39
1 files changed, 23 insertions, 16 deletions
diff --git a/Source/Python/WarpXWrappers.cpp b/Source/Python/WarpXWrappers.cpp
index ac0f60449..cc42f8cd7 100644
--- a/Source/Python/WarpXWrappers.cpp
+++ b/Source/Python/WarpXWrappers.cpp
@@ -19,12 +19,15 @@
namespace
{
- amrex::Real** getMultiFabPointers(const amrex::MultiFab& mf, int *num_boxes, int *ncomps, int *ngrow, int **shapes)
+ amrex::Real** getMultiFabPointers(const amrex::MultiFab& mf, int *num_boxes, int *ncomps, int **ngrowvect, int **shapes)
{
*ncomps = mf.nComp();
- *ngrow = mf.nGrow();
*num_boxes = mf.local_size();
int shapesize = AMREX_SPACEDIM;
+ *ngrowvect = static_cast<int*>(malloc(sizeof(int)*shapesize));
+ for (int j = 0; j < AMREX_SPACEDIM; ++j) {
+ (*ngrowvect)[j] = mf.nGrow(j);
+ }
if (mf.nComp() > 1) shapesize += 1;
*shapes = static_cast<int*>(malloc(sizeof(int)*shapesize * (*num_boxes)));
auto data =
@@ -43,9 +46,13 @@ namespace
}
return data;
}
- int* getMultiFabLoVects(const amrex::MultiFab& mf, int *num_boxes, int *ngrow)
+ int* getMultiFabLoVects(const amrex::MultiFab& mf, int *num_boxes, int **ngrowvect)
{
- *ngrow = mf.nGrow();
+ int shapesize = AMREX_SPACEDIM;
+ *ngrowvect = static_cast<int*>(malloc(sizeof(int)*shapesize));
+ for (int j = 0; j < AMREX_SPACEDIM; ++j) {
+ (*ngrowvect)[j] = mf.nGrow(j);
+ }
*num_boxes = mf.local_size();
int *loVects = (int*) malloc((*num_boxes)*AMREX_SPACEDIM * sizeof(int));
@@ -246,16 +253,16 @@ extern "C"
#define WARPX_GET_FIELD(FIELD, GETTER) \
amrex::Real** FIELD(int lev, int direction, \
- int *return_size, int *ncomps, int *ngrow, int **shapes) { \
+ int *return_size, int *ncomps, int **ngrowvect, int **shapes) { \
auto & mf = GETTER(lev, direction); \
- return getMultiFabPointers(mf, return_size, ncomps, ngrow, shapes); \
+ return getMultiFabPointers(mf, return_size, ncomps, ngrowvect, shapes); \
}
#define WARPX_GET_LOVECTS(FIELD, GETTER) \
int* FIELD(int lev, int direction, \
- int *return_size, int *ngrow) { \
+ int *return_size, int **ngrowvect) { \
auto & mf = GETTER(lev, direction); \
- return getMultiFabLoVects(mf, return_size, ngrow); \
+ return getMultiFabLoVects(mf, return_size, ngrowvect); \
}
WARPX_GET_FIELD(warpx_getEfield, WarpX::GetInstance().getEfield)
@@ -295,16 +302,16 @@ extern "C"
#define WARPX_GET_SCALAR(SCALAR, GETTER) \
amrex::Real** SCALAR(int lev, \
- int *return_size, int *ncomps, int *ngrow, int **shapes) { \
+ int *return_size, int *ncomps, int **ngrowvect, int **shapes) { \
auto & mf = GETTER(lev); \
- return getMultiFabPointers(mf, return_size, ncomps, ngrow, shapes); \
+ return getMultiFabPointers(mf, return_size, ncomps, ngrowvect, shapes); \
}
#define WARPX_GET_LOVECTS_SCALAR(SCALAR, GETTER) \
int* SCALAR(int lev, \
- int *return_size, int *ngrow) { \
+ int *return_size, int **ngrowvect) { \
auto & mf = GETTER(lev); \
- return getMultiFabLoVects(mf, return_size, ngrow); \
+ return getMultiFabLoVects(mf, return_size, ngrowvect); \
}
WARPX_GET_SCALAR(warpx_getChargeDensityCP, WarpX::GetInstance().getrho_cp)
@@ -315,11 +322,11 @@ extern "C"
#define WARPX_GET_FIELD_PML(FIELD, GETTER) \
amrex::Real** FIELD(int lev, int direction, \
- int *return_size, int *ncomps, int *ngrow, int **shapes) { \
+ int *return_size, int *ncomps, int **ngrowvect, int **shapes) { \
auto * pml = WarpX::GetInstance().GetPML(lev); \
if (pml) { \
auto & mf = *(pml->GETTER()[direction]); \
- return getMultiFabPointers(mf, return_size, ncomps, ngrow, shapes); \
+ return getMultiFabPointers(mf, return_size, ncomps, ngrowvect, shapes); \
} else { \
return nullptr; \
} \
@@ -327,11 +334,11 @@ extern "C"
#define WARPX_GET_LOVECTS_PML(FIELD, GETTER) \
int* FIELD(int lev, int direction, \
- int *return_size, int *ngrow) { \
+ int *return_size, int **ngrowvect) { \
auto * pml = WarpX::GetInstance().GetPML(lev); \
if (pml) { \
auto & mf = *(pml->GETTER()[direction]); \
- return getMultiFabLoVects(mf, return_size, ngrow); \
+ return getMultiFabLoVects(mf, return_size, ngrowvect); \
} else { \
return nullptr; \
} \
17-05-30 15:03:35 +0100'>2017-05-30Fix typos (#682)Gravatar Jonas Östanbäck 2-2/+2 2017-05-30Add k8s external service CNAMEs (#677)Gravatar Chris O'Haver 11-16/+293 * Add external service cnames * remove cruft * update CI k8s version * change CI k8s version * min k8s ver for ext services * trying k8s 1.5 * k8s 1.5 requires ports spec * remove kruft * update dns schema version 2017-05-26Update README.md (#668)Gravatar cricketliu 1-9/+9 * Update README.md Minor cosmetic fixes, including one broken comment in a sample Corefile. * Fix verb tense 2017-05-26middleware/file: add DNAME support (#651)Gravatar Eric Yan 4-2/+225 * Test DNAME handling If the DNAME itself matches the QTYPE, and the owner name matches QNAME, the relevant DNAME RR should be included in the answer section. Other parts of RFC 6672 are not implemented yet and hence left untested. * Implement the DNAME substitution As specified in RFC 6672, a DNAME substitution is performed by replacing the suffix labels of the name being sought matching the owner name of the DNAME resource record with the string of labels in the RDATA field. The matching labels end with the root label in all cases. Only whole labels are replaced. * Handle DNAME redirection A CNAME RR is created on-the-fly for the DNAME redirection. Be aware that we do not have all the edge cases covered yet. * Test DNAME owner name matching the QNAME A DNAME RR redirects DNS names subordinate to its owner name; the owner name of a DNAME is NOT redirected itself. * Ignore names next to and below a DNAME record According to RFC 6672, resource records MUST NOT exist at any subdomain of the owner of a DNAME RR. When loading a zone, those names below the DNAME RR will be quietly ignored. * Streamline DNAME processing Instead of checking DNAMEs during lookup, we use a preloaded list of DNAME RRs to streamline the process without any runtime performance penalty: * When loading the zone, keep a record of any DNAME RRs. * If there aren't any DNAMEs in the zone, just do the lookup as usual. * Only when the zone has one or more DNAME records, we look for the matching DNAME and ignore confronting subdomain(s) in the process. * Make it easier to trace back through test errors * Make DNAME handling part of lookup routine DNAME processing is invoked only if the zone has at least one DNAME RR. * Put DNAME resolution inside the searching of a hit We can drop some of the other ideas; we don't need to track if we have DNAMEs in the zone it just follows naturally from the current lookup code. See also: #664 2017-05-25Check that all the controllers are synced agains api server (#671)Gravatar Manuel Alejandro de Brito Fontes 1-1/+9 2017-05-25Some golint cleanup (#674)Gravatar Yong Tang 4-8/+8 This commit fixes some golint issues in `core/dnsserver` and `middleware/kubernetes`. Signed-off-by: Yong Tang <yong.tang.github@outlook.com> 2017-05-25fix docker build (#673)Gravatar Chris O'Haver 1-1/+1 2017-05-23Maintainer update (#670)Gravatar Miek Gieben 1-7/+5 Use @coredns.io were appropriate and clean up the list a little. 2017-05-22Handle K8s middleware NS record (#662)Gravatar Chris O'Haver 9-98/+538 * commit for testing in cluster * commit for testing in cluster * refactor and add ns.dns record * Release 007 * reduce heap allocations * gofmt * revert accidental Makefile commits * restore prior rcode for disabled pod mode * revert Makefile deltas * add unit tests * more unit tests * make isRequestInReverseRange easier to test * more unit tests * addressing review feedback * commit setup.go 2017-05-22middleware/chaos: fix version (#669)Gravatar Miek Gieben 4-14/+57 * middleware/chaos: fix version Move the version setting into a init function so it is done early. Then tweak the setup code for chaos a bit to correctly pick this version up. Add an integration test to pick this up in the toplevel test/ directory. Fixes #667 * Update tests 2017-05-12Makefile.release: bogus all target (#666)Gravatar Miek Gieben 1-7/+10 Make the default target do nothing and put the actual release under a 'release' target. Prevent accidentally committing unwanted commits to the repo. Tested with `make -f Makefile.release -n`. 2017-05-08Add License Scanning badge (#663)Gravatar Chris Aniszczyk 1-0/+1 In CNCF, we are experimenting with FOSSA for license scanning on all of our projects. https://app.fossa.io/reports/7d989803-8931-4221-a11f-330b7f333cdd 2017-05-05Don't check vendor code for gofmt, it takes forever (#661)Gravatar John Belamaric 1-1/+1 2017-05-03Release: fix docker pushGravatar Miek Gieben 1-0/+2 2017-05-03Release: fix MakefileGravatar Miek Gieben 1-0/+1 Latest refactoring fubar-ed Makefile.release. Fix the Linux build target. 2017-05-03Release 007v007Gravatar Miek Gieben 1-1/+1 2017-05-03middleware/file: correctly parse the stanza (#658)Gravatar Miek Gieben 3-34/+87 * middleware/file: correctly parse the stanza Parsing the file stanza would give precedence to 'transfer' and ignore other bits if it wasn't specified. This change fixes the parsing. The actually external CNAME retrieval is working fine (once the upstream is correctly parsed). This wasn't caught in tests, because we lack a parsing test for this. Fixes #657 * Add tests 2017-04-30Install: split build targets (#656)Gravatar Miek Gieben 1-3/+13 Allows one to use `make -f Makefile.release build-arm` to just get an Arm binary. 2017-04-30Remove annoying INFO from k8s middleware (#655)Gravatar John Belamaric 1-3/+1 2017-04-29middleware/cache: don't cache expired RRSIGs (#641)Gravatar Miek Gieben 7-62/+172 Check message for expired sig and don't cache those. Aside: This hack of caching entire messages is probably something we should stop doing at some point in the future and do this on a per RRset basis. Fixes #367 #635 2017-04-28Update vendor with `go dep`Gravatar Yong Tang 8408-13844/+2469780 This fix updates vendor with `go dep` Signed-off-by: Yong Tang <yong.tang.github@outlook.com> 2017-04-28Add vendor setup with `go dep`Gravatar Yong Tang 3-1/+443 This fix adds vendor setup with `go dep` Signed-off-by: Yong Tang <yong.tang.github@outlook.com> 2017-04-27update readme (#650)Gravatar Miek Gieben 1-3/+4 * update readme * Add slack Also add the slack channel. 2017-04-26middleware/proxy: Kill goroutines on stop (#646)Gravatar Miek Gieben 5-5/+112 * middleware/proxy: Kill goroutines on stop Ports caddy's https://github.com/mholt/caddy/commit/59bf71c2932c3b814a6a1211c492a1aa9f71d4a1 Excludes the proxy_test.go test part though. Fixes #644 * Add tests 2017-04-24Fix health race (#645)Gravatar Miek Gieben 6-28/+26 * Revert "middleware/proxy: Make Unhealthy a pointer (#615)" This reverts commit acbf522cebdcd53c26d153c1d9267d709ba75f64. * middleware/proxy: add proper locking This add the proper locking around `Unhealthy`. 2017-04-24Point users to deployment repo (#643)Gravatar John Belamaric 1-23/+3 2017-04-24Pprof listen (#639)Gravatar Chris O'Haver 4-9/+34 * add listen addr option * Add listen address option to pprof * There is configuration * code styling 2017-04-22msg.Service: add HostType() method (#627)Gravatar Miek Gieben 3-40/+114 This method parses the Host field in the service. It returns 1 or 3 things 1) it is a host 2) an IPv4 address or an 3) IPv6 address. This simplifies some code a bit and allows for 1 way of parsing the Host field. This *only* parse the Host field, Mail and/or Text values should be checked separately. We reuse the dns.TypeXXX values for this as to not invent anything new. 2017-04-21Fix go pprof lib link (#638)Gravatar Chris O'Haver 1-1/+1 2017-04-21Fix link to SkyDNS (#637)Gravatar Dominic 1-1/+1 Url was wrong 2017-04-20Fix TLS error message (#634)Gravatar Yue Ko 1-1/+1 Print corresponding error message when TLS initialization fails. 2017-04-20Add MAINTAINERS (#633)Gravatar Miek Gieben 2-0/+10 Add a MAINTAINERS file. It's not generated and not as elaborate (i.e. no focus areas) as the one prometheus uses. But it's a start. Generated with `git shortlog -s -n`, everyone with more than 5 commits. Docs are put in `Makefile.release`. Fixes #566 2017-04-19Clean up the tls middleware README (#631)Gravatar John Belamaric 1-4/+22 2017-04-19Update the various Kubernetes middleware README files. (#630)Gravatar John Belamaric 3-174/+21 2017-04-19Add fallthrough support for Kubernetes (#626)Gravatar John Belamaric 7-9/+122 * Add fallthrough support for Kubernetes This enables registering other services in the same zone as Kubernetes services. This also re-orders the middleware chain so that Kubernetes comes before other types, in order to make this work out-of-the-box. * Remove extra line 2017-04-18Tracing for gRPC Server (#619)Gravatar John Belamaric 6-11/+72 * Implements tracing in the native gRPC server * Undo some unnecessary changes * Properly revert trace/setup.go this time * Some very very basic tests * Remove warning for non-Trace middleware