void correct_for_exact_normal_gaussian_bump_T (struct Solver_Face_T*const s_face) { assert(DIM == 2); // Add support if needed. const struct Face*const face = (struct Face*) s_face; if (!face->boundary || face->bc < BC_CURVED_START) return; const struct const_Multiarray_T*const xyz_fc = s_face->xyz_fc; const struct const_Multiarray_T*const normals_fc = s_face->normals_fc; destructor_const_Multiarray_T(s_face->normals_fc_exact); struct Multiarray_T*const normals_fc_exact = constructor_copy_Multiarray_T((struct Multiarray_T*)normals_fc); // k const_constructor_move_Multiarray_T(&s_face->normals_fc_exact,normals_fc_exact); const Type*const xyz[] = ARRAY_DIM( get_col_const_Multiarray_T(0,xyz_fc), get_col_const_Multiarray_T(1,xyz_fc), get_col_const_Multiarray_T(2,xyz_fc) ); const ptrdiff_t n_n = xyz_fc->extents[0]; for (int n = 0; n < n_n; ++n) { const Real xyz_n[] = ARRAY_DIM( real_T(xyz[0][n]), real_T(xyz[1][n]), real_T(xyz[2][n]) ); struct Function_Data_GP f_data = { .scale = 1.0, }; const Real df_dx = f_gaussian_bump(xyz_n[0],1,&f_data); Real n_ex[] = { df_dx, -1.0, 0.0, }; const Real norm_n = sqrt(n_ex[0]*n_ex[0]+n_ex[1]*n_ex[1]); for (int i = 0; i < 2; ++i) n_ex[i] /= norm_n; Type*const n_fc = get_row_Multiarray_T(n,normals_fc_exact); const Real n_dot_n_ex = dot_R_from_RT(DIM,n_ex,n_fc); assert(n_dot_n_ex > 0.0); for (int d = 0; d < DIM; ++d) n_fc[d] = n_ex[d]; } correct_normals_fc(s_face); } // Static functions ************************************************************************************************* // // Level 0 ********************************************************************************************************** // static void correct_normals_fc (struct Solver_Face_T*const s_face) { if (!using_exact_normals()) return; set_Multiarray_T((struct Multiarray_T*)s_face->normals_fc,s_face->normals_fc_exact); }
void correct_for_exact_normal_cylinder_T (struct Solver_Face_T*const s_face) { assert(DIM >= 2); enum { d_max = 2, }; const struct Face*const face = (struct Face*) s_face; if (!face->boundary || face->bc < BC_CURVED_START) return; const struct const_Multiarray_T*const xyz_fc = s_face->xyz_fc; const struct const_Multiarray_T*const normals_fc = s_face->normals_fc; destructor_const_Multiarray_T(s_face->normals_fc_exact); struct Multiarray_T*const normals_fc_exact = constructor_copy_Multiarray_T((struct Multiarray_T*)normals_fc); // k const_constructor_move_Multiarray_T(&s_face->normals_fc_exact,normals_fc_exact); const Type*const xyz[] = ARRAY_DIM( get_col_const_Multiarray_T(0,xyz_fc), get_col_const_Multiarray_T(1,xyz_fc), get_col_const_Multiarray_T(2,xyz_fc) ); const ptrdiff_t n_n = xyz_fc->extents[0]; for (int n = 0; n < n_n; ++n) { const Real xyz_n[] = ARRAY_DIM( real_T(xyz[0][n]), real_T(xyz[1][n]), real_T(xyz[2][n]) ); const Real th = atan2(xyz_n[1],xyz_n[0]); const Real n_ex[] = { -cos(th), -sin(th), }; Type*const n_fc = get_row_Multiarray_T(n,normals_fc_exact); const Real n_dot_n_ex = dot_R_from_RT(d_max,n_ex,n_fc); for (int d = 0; d < d_max; ++d) n_fc[d] = n_ex[d]; if (n_dot_n_ex < 0.0) { for (int d = 0; d < d_max; ++d) n_fc[d] *= -1.0; } if (DIM > 2) { for (int d = 2; d < DIM; ++d) assert(equal_T(n_fc[d],0.0,EPS)); } } correct_normals_fc(s_face); }
/* perform some basic sanity checks on the given mysocket descriptor. if * comp_ctx is non-NULL, it is checked against the context found for the given * descriptor to make sure they match. */ static void verify_mysocket_descriptor(mysock_context_t *comp_ctx, mysocket_t my_sd) { mysock_context_t *ctx; assert(my_sd >= 0 && my_sd < (int)ARRAY_DIM(global_ctx)); ctx = global_ctx[my_sd]; assert(ctx); assert(ctx->my_sd == my_sd); assert(!comp_ctx || comp_ctx == ctx); }
/* obtain a pointer to the connection context for the given mysocket * descriptor. */ mysock_context_t *_mysock_get_context(mysocket_t sd) { ASSERT_VALID_MYSOCKET_DESCRIPTOR(NULL, sd); return (sd >= 0 && sd < (int)ARRAY_DIM(global_ctx)) ? global_ctx[sd] : NULL; }
L"CPU", L"CPUArch", L"CPUABI", L"CPUSpeed", L"DisplayXPixels", L"DisplayYPixels", L"DisplayXTwips", L"DisplayYTwips", L"LanguageIndex", L"SystemDrive", L"HeapSize", L"StackSize" }; const TInt KNumSpecialLogKeys = ARRAY_DIM(KSpecialLogKeyText); CSpecialLog::CSpecialLog() : iState(EInitializing), iLogSpecial(KNumSpecialLogKeys) { } CSpecialLog::~CSpecialLog() { // Need iLogSpecial.Reset() ? } TInt CSpecialLog::ConstructL(RFs & aFs) { iFs = & aFs;
static void TEST_URL_Encoding(void) { typedef struct { const char* src_buf; size_t src_size; size_t src_read; const char* dst_buf; size_t dst_size; size_t dst_written; int/*bool*/ ok; } STestArg; static const STestArg s_TestEncode[] = { { "", 0, 0, "", 0, 0, 1/*true*/ }, { "abc", 3, 3, "abc", 3, 3, 1/*true*/ }, { "_ _%_;_\n_", 7, 0, "", 0, 0, 1/*true*/ }, { "_ _%_;_\n_", 0, 0, "", 0, 0, 1/*true*/ }, { "_ _%_;_\n_", 0, 0, "", 7, 0, 1/*true*/ }, { "_ _%_;_\n_:_\\_\"_", 15, 15, "_+_%25_%3B_%0A_%3A_%5C_%22_", 27, 27, 1/*true*/ }, { "_ _%_;_\n_:_\\_\"_", 15, 13, "_+_%25_%3B_%0A_%3A_%5C_%22_", 25, 23, 1/*true*/ }, { "_%_", 3, 1, "_%25_", 2, 1, 1/*true*/ }, { "_ _%_;_\n_", 7, 7, "_+_%25_%3B_%0A", 100, 11, 1/*true*/ } }; static const STestArg s_TestDecode[] = { { "", 0, 0, "", 0, 0, 1/*true*/ }, { "%25", 1, 0, "", 0, 0, 1/*true*/ }, { "%25", 2, 0, "", 0, 0, 1/*true*/ }, { "%25", 3, 3, "%", 1, 1, 1/*true*/ }, { "%25", 3, 0, "%", 0, 0, 1/*true*/ }, { "%%%", 2, 0, "", 1, 0, 0/*false*/ }, { "%%%", 3, 0, "", 1, 0, 0/*false*/ }, { "%xy", 3, 0, "", 1, 0, 0/*false*/ }, { "\n", 1, 0, "", 1, 0, 0/*false*/ }, { "a\t", 2, 1, "a", 1, 1, 1/*true*/ }, { "#\n", 1, 0, "", 0, 0, 1/*true*/ }, { "%a-", 3, 0, "", 1, 0, 0/*false*/ }, { "%a-", 3, 0, "", 0, 0, 1/*true*/ }, { "_+_%25_%3B_%0A_%3A_%5C_%22_", 27, 27, "_ _%_;_\n_:_\\_\"_", 15, 15, 1/*true*/ }, { "_+_%25_%3B_%0A_%3A_%5C_%22_", 25, 23, "_ _%_;_\n_:_\\_\"_", 13, 13, 1/*true*/ }, { "_+_%25_%3B_%0A_%3A_%5C_%22_", 27, 23, "_ _%_;_\n_:_\\_\"_", 13, 13, 1/*true*/ } }; static const STestArg s_TestDecodeEx[] = { { "", 0, 0, "", 0, 0, 1/*true*/ }, { "%25", 3, 0, "%", 0, 0, 1/*true*/ }, { "%%%", 2, 0, "", 1, 0, 0/*false*/ }, { "%xy", 3, 0, "", 1, 0, 0/*false*/ }, { "\n", 1, 0, "", 1, 0, 0/*false*/ }, { ">>a", 3, 3, ">>a", 3, 3, 1/*true*/ }, { ">b[", 3, 3, ">b[", 4, 3, 1/*true*/ }, { ">b]", 3, 2, ">b", 3, 2, 1/*true*/ }, { "[b]", 3, 2, "[b", 3, 2, 1/*true*/ }, { "<b>", 3, 0, "", 3, 0, 0/*false*/ }, { "<e>", 3, 0, "", 5, 0, 0/*false*/ } }; size_t i; size_t src_read, dst_written; char dst[1024]; #define ARRAY_DIM(arr) (sizeof(arr)/sizeof((arr)[0])) CORE_LOG(eLOG_Note, "URL encoding test started"); for (i = 0; i < ARRAY_DIM(s_TestEncode); i++) { const STestArg* arg = &s_TestEncode[i]; URL_Encode(arg->src_buf, arg->src_size, &src_read, dst, arg->dst_size, &dst_written); assert(src_read == arg->src_read); assert(dst_written == arg->dst_written); assert(!dst_written || !memcmp(dst, arg->dst_buf, dst_written)); } for (i = 0; i < ARRAY_DIM(s_TestDecode); i++) { const STestArg* arg = &s_TestDecode[i]; int/*bool*/ ok = URL_Decode(arg->src_buf, arg->src_size, &src_read, dst, arg->dst_size, &dst_written); assert(ok == arg->ok); assert(src_read == arg->src_read); assert(dst_written == arg->dst_written); assert(!dst_written || !memcmp(dst, arg->dst_buf, dst_written)); } for (i = 0; i < ARRAY_DIM(s_TestDecodeEx); i++) { const STestArg* arg = &s_TestDecodeEx[i]; int/*bool*/ ok = URL_DecodeEx(arg->src_buf, arg->src_size, &src_read, dst, arg->dst_size, &dst_written, "[>"); assert(ok == arg->ok); assert(src_read == arg->src_read); assert(dst_written == arg->dst_written); assert(!dst_written || !memcmp(dst, arg->dst_buf, dst_written)); } CORE_LOG(eLOG_Note, "URL encoding test completed"); }