aboutsummaryrefslogtreecommitdiff
path: root/src/SpaceMask.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/SpaceMask.h')
-rw-r--r--src/SpaceMask.h113
1 files changed, 113 insertions, 0 deletions
diff --git a/src/SpaceMask.h b/src/SpaceMask.h
new file mode 100644
index 0000000..bbcecdf
--- /dev/null
+++ b/src/SpaceMask.h
@@ -0,0 +1,113 @@
+/*@@
+ @file MaskUtils.c
+ @date October 2002
+ @author Denis Pollney
+ @desc
+ Function prototypes and macros mask utilities.
+ @desc
+ @version $Header$
+@@*/
+
+#ifndef __CACTUSEINSTEIN_SPACEMASK_H__
+#define __CACTUSEINSTEIN_SPACEMASK_H__
+
+#define DEBUG 0
+
+/********************************************************************
+ ********************* Routine Prototypes *************************
+ ********************************************************************/
+#ifdef CCODE
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+int SpaceMask_RegisterType(char*, int, char**);
+int SpaceMask_AppendStatesToType(char*, int, char**);
+void SpaceMask_SetState(CCTK_INT8*, int, char*, char*);
+int SpaceMask_CheckState(CCTK_INT8*, int, char*, char*);
+CCTK_INT8 SpaceMask_GetTypeBits(char*);
+CCTK_INT8 SpaceMask_GetStateBits(char*, char*);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/********************************************************************
+ ********************* Local Data Types **********************
+ ********************************************************************/
+
+#ifdef CCODE
+
+typedef struct
+{
+ char* name;
+ CCTK_INT8 bitmask;
+} SpaceMask_State;
+
+typedef struct
+{
+ char* name;
+ int nstates;
+ CCTK_INT8 bitmask;
+ SpaceMask_State** state_list;
+} SpaceMask_Type;
+
+typedef struct
+{
+ int ntypes;
+ SpaceMask_Type** type_list;
+} SpaceMask_Registry;
+
+extern SpaceMask_Registry* spacemask_Registry;
+
+#endif
+
+/********************************************************************
+ ********************* Macros ******************************
+ ********************************************************************/
+
+/*@@
+ @routine SpaceMask_SetStateBits
+ @author Denis Pollney
+ @date 15 October 2002
+ @desc
+ Sets the mask at a point to the given state, as specified
+ using a bitmask.
+ @enddesc
+@@*/
+
+#ifdef FCODE
+#define SpaceMask_SetStateBitsF90(mask, i, j, k, type_bits, state_bits) \
+ mask(i,j,k) = ior(iand(mask(i,j,k), not(type_bits)), state_bits)
+#endif
+
+#ifdef CCODE
+#define SpaceMask_SetStateBits(mask, ijk, type_bits, state_bits) \
+ mask[ijk] = (mask[ijk] & ~type_bits) | state_bits;
+#endif
+
+/*@@
+ @routine SpaceMask_CheckStateBits
+ @author Denis Pollney
+ @date 15 October 2002
+ @desc
+ Checks that the mask at a point has the specified state,
+ in which case return 1, otherwise return 0.
+ @enddesc
+@@*/
+
+#ifdef FCODE
+#define SpaceMask_CheckStateBitsF90(mask, i, j, k, type_bits, state_bits) \
+ (iand(mask(i,j,k), type_bits) .eq. state_bits)
+#endif
+
+#ifdef CCODE
+#define SpaceMask_CheckStateBits(mask, ijk, type_bits, state_bits) \
+ (mask[ijk] & type_bits) == state_bits
+#endif
+
+#endif /* __CACTUSEINSTEIN_SPACEMASK_H__ */