Changeset 8713
- Timestamp:
- Feb 22, 2013, 4:25:41 PM (12 years ago)
- Location:
- trunk/anuga_core
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/documentation/user_manual/demos/cairns/project.py
r8712 r8713 85 85 slide_origin = [451871, 8128376] # Assume to be on continental shelf 86 86 slide_depth = 500. 87 88 89 #------------------------------------------------------------------------------ 90 # Data for Tides 91 #------------------------------------------------------------------------------ 92 tide = 0.0 -
trunk/anuga_core/documentation/user_manual/demos/cairns/runcairns.py
r8712 r8713 68 68 # Setup initial conditions 69 69 #------------------------------------------------------------------------------ 70 tide = 0.070 tide = project.tide 71 71 domain.set_quantity('stage', tide) 72 72 domain.set_quantity('friction', 0.0) … … 146 146 if project.scenario == 'fixed_wave': 147 147 # Save every two mins leading up to wave approaching land 148 for t in domain.evolve(yieldstep= 120, finaltime=5000):148 for t in domain.evolve(yieldstep=2*60, finaltime=5000): 149 149 print domain.timestepping_statistics() 150 150 print domain.boundary_statistics(tags='ocean_east') 151 151 152 152 # Save every 30 secs as wave starts inundating ashore 153 for t in domain.evolve(yieldstep= 10, finaltime=10000,153 for t in domain.evolve(yieldstep=60*0.5, finaltime=10000, 154 154 skip_initial_step=True): 155 155 print domain.timestepping_statistics() -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/neighbour_mesh.py
r8708 r8713 926 926 927 927 # Check number of triangles per node 928 count = [0]*self.number_of_nodes 929 for triangle in self.triangles: 930 for i in triangle: 931 count[i] += 1 932 933 assert num.allclose(count, self.number_of_triangles_per_node) 934 935 936 # Check integrity of vertex_value_indices 937 current_node = 0 938 k = 0 # Track triangles touching on node 939 for index in self.vertex_value_indices: 940 941 if self.number_of_triangles_per_node[current_node] == 0: 942 # Node is lone - i.e. not part of the mesh 943 continue 944 945 k += 1 946 947 volume_id = index / 3 948 vertex_id = index % 3 949 950 msg = 'Triangle %d, vertex %d points to %d. Should have been %d'\ 951 %(volume_id, vertex_id, self.triangles[volume_id, vertex_id], current_node) 952 assert self.triangles[volume_id, vertex_id] == current_node, msg 953 954 if self.number_of_triangles_per_node[current_node] == k: 955 # Move on to next node 956 k = 0 957 current_node += 1 928 # count = [0]*self.number_of_nodes 929 # for triangle in self.triangles: 930 # for i in triangle: 931 # count[i] += 1 932 933 count = num.bincount(self.triangles.flat) 934 935 936 ncount = len(count) 937 #print len(count) 938 #print len(self.number_of_triangles_per_node) 939 940 941 number_of_lone_nodes = self.number_of_nodes - len(self.number_of_triangles_per_node) 942 943 944 assert num.allclose(count, self.number_of_triangles_per_node[:ncount]) 945 946 947 from neighbour_mesh_ext import check_integrity_c 948 949 950 #print self.vertex_value_indices.shape 951 #print self.triangles.shape 952 #print self.node_index.shape 953 #print self.number_of_triangles_per_node.shape 954 955 check_integrity_c(self.vertex_value_indices, 956 self.triangles, 957 self.node_index, 958 self.number_of_triangles_per_node) 959 960 961 962 # # Check integrity of vertex_value_indices 963 # current_node = 0 964 # k = 0 # Track triangles touching on node 965 # for index in self.vertex_value_indices: 966 # 967 # if self.number_of_triangles_per_node[current_node] == 0: 968 # # Node is lone - i.e. not part of the mesh 969 # continue 970 # 971 # k += 1 972 # 973 # volume_id = index / 3 974 # vertex_id = index % 3 975 # 976 # msg = 'Triangle %d, vertex %d points to %d. Should have been %d'\ 977 # %(volume_id, vertex_id, self.triangles[volume_id, vertex_id], current_node) 978 # assert self.triangles[volume_id, vertex_id] == current_node, msg 979 # 980 # if self.number_of_triangles_per_node[current_node] == k: 981 # # Move on to next node 982 # k = 0 983 # current_node += 1 958 984 959 985 -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/neighbour_mesh_ext.c
r8563 r8713 77 77 78 78 79 static PyObject *CheckIntegrity( PyObject *self, PyObject *args ) 80 { 81 int nt, nt3, tri, n_node, n_node_1; 82 int ok; 83 int current_node; 84 int k, i; 85 int index; 86 87 //char errorMsg[50]; 88 89 double cumsum; 90 91 long *vertex_value_indices; 92 long *triangles; 93 long *node_index; 94 long *number_of_triangles_per_node; 95 96 97 PyObject *pyobj_vertex_value_indices; 98 PyObject *pyobj_triangles; 99 PyObject *pyobj_node_index; 100 PyObject *pyobj_number_of_triangles_per_node; 101 102 //Py_ssize_t pos; 103 104 ok = PyArg_ParseTuple( args, "OOOO", 105 &pyobj_vertex_value_indices, 106 &pyobj_triangles, 107 &pyobj_node_index, 108 &pyobj_number_of_triangles_per_node 109 ); 110 if( !ok ){ 111 report_python_error(AT, "could not parse input arguments"); 112 return NULL; 113 } 114 115 vertex_value_indices = IDATA( pyobj_vertex_value_indices ); 116 nt3 = DIMENSHAPE( pyobj_vertex_value_indices, 0 ); 117 118 119 //printf(" n3 %d \n",nt3); 120 121 triangles = IDATA( pyobj_triangles ); 122 nt = DIMENSHAPE( pyobj_triangles, 0 ); 123 tri = DIMENSHAPE( pyobj_triangles, 1 ); 124 125 //printf(" nt %d tri %d \n",nt, tri); 126 127 node_index = IDATA( pyobj_node_index ); 128 n_node_1 = DIMENSHAPE( pyobj_node_index, 0 ); 129 130 131 //printf(" n_node_1 %d \n",n_node_1); 132 133 number_of_triangles_per_node = IDATA( pyobj_number_of_triangles_per_node ); 134 n_node = DIMENSHAPE( pyobj_number_of_triangles_per_node, 0 ); 135 136 137 //printf(" n_node %d \n",n_node); 138 139 //---------------------------------------------------------------------- 140 // Check that the arrays are consistent 141 //---------------------------------------------------------------------- 142 if ( nt3 != 3*nt) { 143 report_python_error(AT, "Mismatch in size of triangles and vertex_value_indices"); 144 return NULL; 145 } 146 147 if ( n_node_1 != n_node + 1 ) { 148 report_python_error(AT, "Mismatch in size of node_index and number_of_triangles_per_node"); 149 return NULL; 150 } 151 152 if ( tri != 3 ) { 153 report_python_error(AT, "Triangle array should be nt by 3"); 154 return NULL; 155 } 156 157 //---------------------------------------------------------------------- 158 // Check consistence between triangles, and node_index and 159 // number_of_triangles_per_node 160 //---------------------------------------------------------------------- 161 current_node = 0; 162 k = 0; //Track triangles touching on node 163 for (i=0; i<nt3 ; i++) { 164 index = vertex_value_indices[i]; 165 166 if (number_of_triangles_per_node[current_node] == 0) { 167 // Node is lone - i.e. not part of the mesh 168 continue; 169 } 170 171 k += 1; 172 173 if ( triangles[index] != current_node) { 174 report_python_error(AT, "Inconsistency between triangles and vertex_values_indices"); 175 return NULL; 176 } 177 178 if ( number_of_triangles_per_node[current_node] == k) { 179 // Move on to next node 180 k = 0; 181 current_node += 1; 182 } 183 } 184 185 cumsum = 0.0; 186 for (i=0; i<n_node; i++) { 187 cumsum += number_of_triangles_per_node[i]; 188 if ( cumsum != node_index[i+1]) { 189 report_python_error(AT, "Inconsistency between node_index and number_of_triangles_per_node"); 190 return NULL; 191 } 192 } 193 194 195 /* 196 pos = 0; 197 if( PyDict_Size( pyobj_boundary ) ){ 198 // iterate through dictionary entries 199 while( PyDict_Next( pyobj_boundary, &pos, &pyobj_dictKey, &pyobj_dictVal ) ){ 200 volID = PyLong_AsLong( PyTuple_GetItem( pyobj_dictKey, 0 ) ); 201 edgeID = PyLong_AsLong( PyTuple_GetItem( pyobj_dictKey, 1 ) ); 202 203 if (!(volID<aDimen && edgeID<bDimen)) { 204 sprintf(errorMsg, "Segment (%d, %d) does not exist", volID, edgeID); 205 report_python_error(AT, errorMsg); 206 return NULL; 207 } 208 } 209 } 210 211 for(volID=0; volID<numTriangle; volID++){ 212 for(edgeID=0; edgeID<3; edgeID++){ 213 if( neighbours[volID*3+edgeID] < 0 ){ 214 pyobj_dictKey = PyTuple_New( 2 ); 215 PyTuple_SetItem( pyobj_dictKey, 0, PyInt_FromLong( volID ) ); 216 PyTuple_SetItem( pyobj_dictKey, 1, PyInt_FromLong( edgeID ) ); 217 218 if( !PyDict_Contains( pyobj_boundary, pyobj_dictKey ) ) 219 PyDict_SetItem( pyobj_boundary, pyobj_dictKey, PyString_FromString( defaultTag ) ); 220 } 221 } 222 } 223 */ 224 225 return Py_BuildValue(""); 226 } 227 228 229 230 231 232 233 79 234 /* 80 235 static PyObject *BoundaryDictionaryConstruct( PyObject *self, PyObject *args ) … … 114 269 static PyMethodDef MF_module_methods[] = { 115 270 {"boundary_dictionary_construct", BoundaryDictionaryConstruct, METH_VARARGS}, 271 {"check_integrity_c", CheckIntegrity, METH_VARARGS}, 116 272 {NULL, NULL} //sentinel 117 273 };
Note: See TracChangeset
for help on using the changeset viewer.