aboutsummaryrefslogtreecommitdiff
path: root/src/ParseGeometry.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ParseGeometry.c')
-rw-r--r--src/ParseGeometry.c142
1 files changed, 142 insertions, 0 deletions
diff --git a/src/ParseGeometry.c b/src/ParseGeometry.c
new file mode 100644
index 0000000..b060708
--- /dev/null
+++ b/src/ParseGeometry.c
@@ -0,0 +1,142 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+
+#include "util_String.h"
+#include "IOJpeg.h"
+#include "CactusBase/IOASCII/src/ioASCIIGH.h"
+
+void IOJpeg_DefaultGeo(cGH *GH, int sdim, IOJpegGeo_t *geo) {
+ DECLARE_CCTK_PARAMETERS
+
+ asciiioGH *asGH;
+ int idim,ti;
+ const char *tmp_origin, *tmp_downs, *tmp_length;
+ const char *token;
+
+ asGH = (asciiioGH *) GH->extensions
+ [CCTK_GHExtensionHandle ("IOASCII")];
+
+ geo->vdim = -1;
+ geo->sdim = -1;
+
+ for (idim=0;idim<SLABSKEL_MAXDIM;idim++) {
+ geo->direction[idim] = idim;
+ geo->slab_start[idim]= 0;
+ geo->length[idim] =-1;
+ geo->actlen[idim] =-1;
+ geo->downs[idim] = 1;
+ }
+
+ /* FIXME: we use spxyz, which is hardcoded to 3D */
+ for (idim=0;idim<3;idim++)
+ geo->slab_start[idim]=asGH->spxyz[2][(idim+1)%3][idim];
+
+ /* Parse the parameter of the requested dimension */
+ switch (sdim) {
+ case 2:
+ tmp_origin = origin2D;
+ tmp_downs = downsampling2D;
+ tmp_length = length2D;
+ break;
+ default:
+ tmp_origin = origin2D;
+ tmp_downs = downsampling2D;
+ tmp_length = length2D;
+ break;
+ }
+
+ /* Origin, set from parameter only if parameter value .ne. -1 */
+ idim=0;
+ while((token = Util_StrSep(&tmp_origin,","))) {
+ ti=atoi(token);
+ if (ti>-1) geo->slab_start[idim++] = ti;
+ }
+ ti = atoi(tmp_origin);
+ if (ti>-1) geo->slab_start[idim] = ti;
+
+ /* Downsample */
+ idim=0;
+ while((token = Util_StrSep(&tmp_downs,","))) {
+ geo->downs[idim++]=atoi(token);
+ }
+ geo->downs[idim] = atoi(tmp_downs);
+
+ /* Length */
+ idim=0;
+ while((token = Util_StrSep(&tmp_length,","))) {
+ geo->length[idim++]=atoi(token);
+ }
+ geo->length[idim] = atoi(tmp_length);
+}
+
+
+int IOJpeg_NumDirection(int sdim, int vdim)
+{
+ int numdir=-1;
+ if (vdim==3) {
+ switch (sdim) {
+ case 1: return(3);
+ case 2: return(3);
+ case 3: return(1);
+ }
+ } else if (vdim==2) {
+ switch (sdim) {
+ case 1: return(2);
+ case 2: return(1);
+ }
+ }
+ else if (vdim==1) {
+ switch (sdim) {
+ case 1: return(1);
+ }
+ }
+ else printf("Bad dimension: %d \n",vdim);
+ return(numdir);
+}
+
+int IOJpeg_SetDirection(int vdim, int sdim, int ci, int *direction)
+{
+ int retval=0;
+
+ if (sdim>vdim) {
+ printf("SetDirection: slabdim gt vdim");
+ return(-1);
+ }
+
+ if (vdim==3) {
+ if (sdim==2) {
+ switch (ci) {
+ case 0: direction[0]=0; direction[1]=1; break;
+ case 1: direction[0]=0; direction[1]=2; break;
+ case 2: direction[0]=1; direction[1]=2; break;
+ }
+ }
+ else if (sdim==1) {
+ switch (ci) {
+ case 0: direction[0]=0; break;
+ case 1: direction[0]=1; break;
+ case 2: direction[0]=2; break;
+ }
+ }
+ }
+ else if (vdim==2) {
+ if (sdim==2) {
+ direction[0]=0; direction[1]=1;
+ } else if (sdim==1) {
+ switch (ci) {
+ case 0: direction[0]=0; break;
+ case 1: direction[0]=1; break;
+ }
+ }
+ } else retval = -1;
+ return(retval);
+}
+
+
+
+