aboutsummaryrefslogtreecommitdiff
path: root/src/MaskUtils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/MaskUtils.c')
-rw-r--r--src/MaskUtils.c61
1 files changed, 56 insertions, 5 deletions
diff --git a/src/MaskUtils.c b/src/MaskUtils.c
index 784f5b0..1394267 100644
--- a/src/MaskUtils.c
+++ b/src/MaskUtils.c
@@ -229,9 +229,19 @@ SpaceMask_setup_new_type(CCTK_INT new_bits, const char* type_name,
new_type->state_list =
(SpaceMask_State**) malloc (nstates*sizeof(SpaceMask_State*));
- for (j=0; j<nstates; ++j)
- new_type->state_list[j] = SpaceMask_setup_new_state(state_mask[j],
- state_list[j]);
+ if (state_list==NULL)
+ {
+ for (j=0; j<nstates; ++j)
+ new_type->state_list[j] = SpaceMask_setup_new_state(state_mask[j],
+ NULL);
+ }
+ else
+ {
+ for (j=0; j<nstates; ++j)
+ new_type->state_list[j] = SpaceMask_setup_new_state(state_mask[j],
+ state_list[j]);
+ }
+
return new_type;
}
@@ -292,7 +302,7 @@ SpaceMask_RegisterType(const char* type_name, int nstates,
CCTK_INT new_bits;
CCTK_INT* state_mask;
int bit_nbr;
-
+
bit_nbr = SpaceMask_get_bit_nbr(nstates);
new_bits = SpaceMask_get_free_bits(bit_nbr);
@@ -454,6 +464,46 @@ SpaceMask_GetStateBits(const char* type_name, const char* state_name)
}
/*@@
+ @routine SpaceMask_GetStateBitsList
+ @author Denis Pollney
+ @date 25 May 2003
+ @desc
+ Returns a list of all of the state masks allocated
+ for a given type. The number of elements in the list
+ is equal to the number of states of the type.
+ If the type name is not recognised, NULL is returned.
+ @enddesc
+@@*/
+
+CCTK_INT*
+SpaceMask_GetStateBitsList(const char* type_name)
+{
+ SpaceMask_Type* type;
+ CCTK_INT* state_bits_list;
+ int i, j;
+
+ for (i=0; i<spacemask_registry->ntypes; ++i)
+ {
+ if (!strcmp(spacemask_registry->type_list[i]->name, type_name))
+ {
+ type = spacemask_registry->type_list[i];
+ state_bits_list = (CCTK_INT*)
+ malloc (sizeof(CCTK_INT)*(type->nstates));
+
+ for (j=0; j<type->nstates; ++j)
+ state_bits_list[j] = type->state_list[j]->bitmask;
+
+ return state_bits_list;
+ }
+ }
+
+ CCTK_VInfo (CCTK_THORNSTRING,
+ "Requested type \"%s\" could not be found\n", type_name);
+
+ return NULL;
+}
+
+/*@@
@routine SpaceMask_SetState
@author Denis Pollney
@date 15 October 2002
@@ -484,7 +534,7 @@ SpaceMask_SetState(CCTK_INT* mask, int point, const char* type_name, const char*
@enddesc
@@*/
-int
+CCTK_INT
SpaceMask_CheckState(const CCTK_INT* mask, int point, const char* type_name, const char* state)
{
CCTK_INT type_bits;
@@ -496,6 +546,7 @@ SpaceMask_CheckState(const CCTK_INT* mask, int point, const char* type_name, con
return SpaceMask_CheckStateBits(mask, point, type_bits, state_bits);
}
+
/********************************************************************
********************* Fortran Wrappers ***************************
********************************************************************/