Пример #1
0
  void AxisymmetricBoussinesqBuoyancy::read_input_options( const GetPot& input )
  {
    this->_T_FE_family =
      libMesh::Utility::string_to_enum<GRINSEnums::FEFamily>( input("Physics/"+axisymmetric_heat_transfer+"/FE_family", "LAGRANGE") );

    this->_T_order =
      libMesh::Utility::string_to_enum<GRINSEnums::Order>( input("Physics/"+axisymmetric_heat_transfer+"/T_order", "SECOND") );

    this->_V_FE_family =
      libMesh::Utility::string_to_enum<GRINSEnums::FEFamily>( input("Physics/"+incompressible_navier_stokes+"/FE_family", "LAGRANGE") );

    this->_V_order =
      libMesh::Utility::string_to_enum<GRINSEnums::Order>( input("Physics/"+incompressible_navier_stokes+"/V_order", "SECOND") );

    // Read variable naming info
    this->_u_r_var_name = input("Physics/VariableNames/r_velocity", u_r_var_name_default );
    this->_u_z_var_name = input("Physics/VariableNames/z_velocity", u_z_var_name_default );
    this->_T_var_name = input("Physics/VariableNames/Temperature", T_var_name_default );

    this->set_parameter
      (_rho_ref, input,
       "Physics/"+axisymmetric_boussinesq_buoyancy+"/rho_ref", 1.0);

    this->set_parameter
      (_T_ref, input, "Physics/"+axisymmetric_boussinesq_buoyancy+"/T_ref", 1.0);

    this->set_parameter
      (_beta_T, input, "Physics/"+axisymmetric_boussinesq_buoyancy+"/beta_T", 1.0);

    _g(0) = input("Physics/"+axisymmetric_boussinesq_buoyancy+"/g", 0.0, 0 );
    _g(1) = input("Physics/"+axisymmetric_boussinesq_buoyancy+"/g", 0.0, 1 );

    return;
  }
XMFLOAT4 TransferFunction::operator()(int isoValue) {
	float alp = _a(isoValue) < 0 ? 0 : (_a(isoValue) > 1 ? 1 : _a(isoValue));
	float red = _r(isoValue) < 0 ? 0 : (_r(isoValue) > 1 ? 1 : _r(isoValue));
	float gre = _g(isoValue) < 0 ? 0 : (_g(isoValue) > 1 ? 1 : _g(isoValue));
	float blu = _b(isoValue) < 0 ? 0 : (_b(isoValue) > 1 ? 1 : _b(isoValue));
	return XMFLOAT4(red, gre, blu, alp);
}
Пример #3
0
static void blend_single(image_t * frame, ASS_Image *img)
{
    int x, y;
    unsigned char opacity = 255 - _a(img->color);
    unsigned char r = _r(img->color);
    unsigned char g = _g(img->color);
    unsigned char b = _b(img->color);

    unsigned char *src;
    unsigned char *dst;

    src = img->bitmap;
    dst = frame->buffer + img->dst_y * frame->stride + img->dst_x * 3;
    for (y = 0; y < img->h; ++y) {
        for (x = 0; x < img->w; ++x) {
            unsigned k = ((unsigned) src[x]) * opacity / 255;
            // possible endianness problems
            dst[x * 3] = (k * b + (255 - k) * dst[x * 3]) / 255;
            dst[x * 3 + 1] = (k * g + (255 - k) * dst[x * 3 + 1]) / 255;
            dst[x * 3 + 2] = (k * r + (255 - k) * dst[x * 3 + 2]) / 255;
        }
        src += img->stride;
        dst += frame->stride;
    }
}
Пример #4
0
    vector<pair<int, int> > find_max_matching(vector<vector<int> > &v, int _n, int _k)
    {
        //v[i] is a list of adjacent vertices to vertex i, where i is from left part and v[i][j] is from right part
        n = _n;
        //n is number of vertices in left part of graph
        k = _k;
        //k is number of vertices in right part of graph

        g = vector<vector<int> >(n+k+2, vector<int>(n+k+2));
        //g[i][j] = 1 if there is edge between vertex i from left part
        //            			    and vertex j from right part
        for(int i = 0; i < v.size(); i++)
            for(int j = 0; j < v[i].size(); j++)
                g[i][v[i][j]] = 1;
        int S = n+k;
        int T = n+k+1;
        for(int i = 0; i < n; i++)
            g[S][i] = 1;
        for(int i = 0; i < k; i++)
            g[n+i][T] = 1;

        vector<vector<int> > _g(g);

        used = vector<bool> (n+k+2, false);
        while(find_path(S, T))
            fill(used.begin(), used.end(), false);

        vector<pair<int, int> > res;
        for(int i = 0; i < n; i++)
            for(int j = n; j < n+k; j++)
                if(g[i][j] < _g[i][j])
                    res.push_back(make_pair(i, j));

        return res;
    }
Пример #5
0
static void assRender(VSFrameRef *dst, VSFrameRef *alpha, const VSAPI *vsapi,
                      ASS_Image *img)
{
    uint8_t *planes[4];
    int strides[4], p;

    for(p = 0; p < 4; p++) {
        VSFrameRef *fr = p == 3 ? alpha : dst;

        planes[p] = vsapi->getWritePtr(fr, p % 3);
        strides[p] = vsapi->getStride(fr, p % 3);
        memset(planes[p], 0, strides[p] * vsapi->getFrameHeight(fr, p % 3));
    }

    while(img) {
        uint8_t *dstp[4], *alphap, *sp, color[4];
        uint16_t outa;
        int x, y, k;

        if(img->w == 0 || img->h == 0) {
            img = img->next;
            continue;
        }

        color[0] = _r(img->color);
        color[1] = _g(img->color);
        color[2] = _b(img->color);
        color[3] = _a(img->color);

        dstp[0] = planes[0] + (strides[0] * img->dst_y) + img->dst_x;
        dstp[1] = planes[1] + (strides[1] * img->dst_y) + img->dst_x;
        dstp[2] = planes[2] + (strides[2] * img->dst_y) + img->dst_x;
        dstp[3] = planes[3] + (strides[3] * img->dst_y) + img->dst_x;
        alphap = dstp[3];
        sp = img->bitmap;

        for(y = 0; y < img->h; y++) {
            for(x = 0; x < img->w; x++) {
                k = div255(sp[x] * color[3]);
                outa = k * 255 + (alphap[x] * (255 - k));

                if(outa != 0) {
                    dstp[0][x] = blend(k, color[0], alphap[x], dstp[0][x], outa);
                    dstp[1][x] = blend(k, color[1], alphap[x], dstp[1][x], outa);
                    dstp[2][x] = blend(k, color[2], alphap[x], dstp[2][x], outa);
                    dstp[3][x] = div255(outa);
                }
            }

            dstp[0] += strides[0];
            dstp[1] += strides[1];
            dstp[2] += strides[2];
            dstp[3] += strides[3];
            alphap += strides[3];
            sp += img->stride;
        }

        img = img->next;
    }
}
Пример #6
0
static void blend_single(SDL_Surface * frame, ASS_Image *img)
{
    int x, y;
    unsigned char opacity = 255 - _a(img->color);
    unsigned char r = _r(img->color);
    unsigned char g = _g(img->color);
    unsigned char b = _b(img->color);

    unsigned char *src;
    unsigned char *dst;

    src = img->bitmap;
    dst = frame->pixels;

    for (y = 0; y < img->h; ++y) {
        for (x = 0; x < img->w; ++x) {
            unsigned k = ((unsigned) src[x]) * opacity / 255;
            // possible endianness problems
            dst[x * 4] = (k * b + (255 - k) * dst[x * 4]) / 255;
            dst[x * 4 + 1] = (k * g + (255 - k) * dst[x * 4 + 1]) / 255;
            dst[x * 4 + 2] = (k * r + (255 - k) * dst[x * 4 + 2]) / 255;
            dst[x * 4 + 3] = k;
        }
        src += img->stride;
        dst += frame->pitch;
    }
}
Пример #7
0
/**
 * Replans the path.
 *
 * @return  bool   solution found
 */
bool Planner::replan()
{
	_path.clear();
	
	bool result = _compute();
	
	// Couldn't find a solution
	if ( ! result)
	  return false;

	Map::Cell* current = _start;
	_path.push_back(current);

	// Follow the path with the least cost until goal is reached
	while (current != _goal)
	{
		if (current == NULL || _g(current) == Math::INF)
			return false;

		current = _min_succ(current).first;

		_path.push_back(current);
	}

	return true;
}
Пример #8
0
/**
 * Finds the minimum successor cell.
 *
 * @param   Map::Cell*            root
 * @return  <Map::Cell*,double>   successor
 */
pair<Map::Cell*,double> Planner::_min_succ(Map::Cell* u)
{
	Map::Cell** nbrs = u->nbrs();

	double tmp_cost, tmp_g;
	
	Map::Cell* min_cell = NULL;
	double min_cost = Math::INF;

	for (unsigned int i = 0; i < Map::Cell::NUM_NBRS; i++)
	{
		if (nbrs[i] != NULL)
		{
			tmp_cost = _cost(u, nbrs[i]);
			tmp_g = _g(nbrs[i]);

			if (tmp_cost == Math::INF || tmp_g == Math::INF)
				continue;
			
			tmp_cost += tmp_g;

			if (tmp_cost < min_cost)
			{
				min_cell = nbrs[i];
				min_cost = tmp_cost;
			}
		}
	}

	return pair<Map::Cell*,double>(min_cell, min_cost);
}
Пример #9
0
/**
 * Calculates key value for cell.
 *
 * @param   Map::Cell*            cell to calculate for
 * @return  pair<double,double>   key value
 */
pair<double,double> Planner::_k(Map::Cell* u)
{
	double g = _g(u);
	double rhs = _rhs(u);
	double min = (g < rhs) ? g : rhs;
	return pair<double,double>((min + _h(_start, u) + _km), min);
}
Пример #10
0
int
main(int argc, char **argv)
{
    int		errflag = 0;
    int		sts;
    int		c;

    __pmSetProgname(argv[0]);

    indomp = (__pmInDom_int *)&indom;

    while ((c = getopt(argc, argv, "D:")) != EOF) {
	switch (c) {

#ifdef PCP_DEBUG
	case 'D':	/* debug flag */
	    sts = __pmParseDebug(optarg);
	    if (sts < 0) {
		fprintf(stderr, "%s: unrecognized debug flag specification (%s)\n",
		    pmProgname, optarg);
		errflag++;
	    }
	    else
		pmDebug |= sts;
	    break;
#endif

	case '?':
	default:
	    errflag++;
	    break;
	}
    }

    if (errflag) {
	fprintf(stderr, "Usage: %s [-D...] [a|b|c|d|...|i 1|2|3}\n", pmProgname);
	exit(1);
    }

    while (optind < argc) {
	if (strcmp(argv[optind], "a") == 0) _a(0, 1, 1);
	else if (strcmp(argv[optind], "b") == 0) _b();
	else if (strcmp(argv[optind], "c") == 0) _c();
	else if (strcmp(argv[optind], "d") == 0) _a(1, 0, 1);
	else if (strcmp(argv[optind], "e") == 0) _e(0);
	else if (strcmp(argv[optind], "f") == 0) _e(3600);
	else if (strcmp(argv[optind], "g") == 0) _g();
	else if (strcmp(argv[optind], "h") == 0) _h();
	else if (strcmp(argv[optind], "i") == 0) {
	    optind++;
	    _i(atoi(argv[optind]));
	}
	else if (strcmp(argv[optind], "j") == 0) _j();
	else
	    fprintf(stderr, "torture_cache: no idea what to do with option \"%s\"\n", argv[optind]);
	optind++;
    }

    exit(0);
}
Пример #11
0
  void AxisymmetricBoussinesqBuoyancy::read_input_options( const GetPot& input )
  {
    this->set_parameter
      (_rho, input,
       "Physics/"+axisymmetric_boussinesq_buoyancy+"/rho_ref", 1.0);

    this->set_parameter
      (_T_ref, input, "Physics/"+axisymmetric_boussinesq_buoyancy+"/T_ref", 1.0);

    this->set_parameter
      (_beta_T, input, "Physics/"+axisymmetric_boussinesq_buoyancy+"/beta_T", 1.0);

    _g(0) = input("Physics/"+axisymmetric_boussinesq_buoyancy+"/g", 0.0, 0 );
    _g(1) = input("Physics/"+axisymmetric_boussinesq_buoyancy+"/g", 0.0, 1 );

    return;
  }
/// @brief Draw subtitles
/// @param frame
/// @param time
/// @return
///
void LibassSubtitlesProvider::DrawSubtitles(AegiVideoFrame &frame,double time) {
	// Set size
	ass_set_frame_size(ass_renderer, frame.w, frame.h);

	// Get frame
	ASS_Image* img = ass_render_frame(ass_renderer, ass_track, int(time * 1000), NULL);

	// libass actually returns several alpha-masked monochrome images.
	// Here, we loop through their linked list, get the colour of the current, and blend into the frame.
	// This is repeated for all of them.
	while (img) {
		// Get colours
		unsigned int opacity = 255 - ((unsigned int)_a(img->color));
		unsigned int r = (unsigned int)_r(img->color);
		unsigned int g = (unsigned int)_g(img->color);
		unsigned int b = (unsigned int) _b(img->color);

		// Prepare copy
		int src_stride = img->stride;
		int dst_stride = frame.pitch;
		const unsigned char *src = img->bitmap;

		unsigned char *dst = frame.data;
		if (frame.flipped) {
			dst += dst_stride * (frame.h - 1);
			dst_stride *= -1;
		}
		dst += (img->dst_y * dst_stride + img->dst_x * 4);

		// Copy image to destination frame
		for (int y = 0; y < img->h; y++) {
			unsigned char *dstp = dst;

			for (int x = 0; x < img->w; ++x) {
				unsigned int k = ((unsigned)src[x]) * opacity / 255;
				unsigned int ck = 255 - k;

				*dstp = (k * b + ck * *dstp) / 255;
				++dstp;

				*dstp = (k * g + ck * *dstp) / 255;
				++dstp;

				*dstp = (k * r + ck * *dstp) / 255;
				++dstp;

				++dstp;
			}

			dst += dst_stride;
			src += src_stride;
		}

		// Next image
		img = img->next;
	}
}
Пример #13
0
 void _g(int d, int n, vector <int> &ret) {
     if (d == n) return;
     vector <int> tmp = ret;
     for (int i=(int)ret.size()-1; i>=0; --i) {
         tmp[i] ^= 1 << d;
     }
     reverse(begin(tmp), end(tmp));
     ret.insert(end(ret), begin(tmp), end(tmp));
     _g(d+1, n, ret);
 }
Пример #14
0
    lbfgsfloatval_t evaluate(
        const lbfgsfloatval_t *x,
        lbfgsfloatval_t *g,
        const int n,
        const lbfgsfloatval_t step
    )
    {
        Array _x((double*)x, n), _g(g, n);
        return _pot->get_energy_gradient(_x, _g);

    }
Пример #15
0
static int writeData(void* _call)
{
    unsigned char r;
    unsigned char g;
    unsigned char b;
    unsigned char a;
    int x,y;
    int res = 0;
    unsigned char* dst;
    
    WriterFBCallData_t* call = (WriterFBCallData_t*) _call;
    
    fb_printf(100, "\n");

    if (call == NULL)
    {
        fb_err("call data is NULL...\n");
        return 0;
    }

    if (call->destination == NULL)
    {
        fb_err("file pointer < 0. ignoring ...\n");
        return 0;
    }
    
    if (call->data != NULL)
    {
        unsigned int opacity = 255 - ((unsigned int)_a(call->color));
        unsigned int r = (unsigned int)_r(call->color);
        unsigned int g = (unsigned int)_g(call->color);
        unsigned int b = (unsigned int) _b(call->color);
        int src_stride = call->Stride;
        int dst_stride = call->destStride;
        int dst_delta  = dst_stride - call->Width*4;
        int x,y;
        const unsigned char *src = call->data;
        unsigned char *dst = call->destination + (call->y * dst_stride + call->x * 4);
	//uint32_t *dst = call->destination + call->y * dst_stride + call->x;
        unsigned int k,ck,t;

	static uint32_t last_color = 0, colortable[256];

	if (last_color != call->color) {
		// call->color is rgba, our spark frame buffer is argb
		uint32_t c = call->color >> 8, a = 255 - (call->color & 0xff);
		int i;
		for (i = 0; i < 256; i++) {
			uint32_t k = (a * i) >> 8;
			colortable[i] = k ? (c | (k << 24)) : 0;
		}
		last_color = call->color;
	}
Пример #16
0
// render 1 ass image into a 32bit QImage with alpha channel.
//use dstX, dstY instead of img->dst_x/y because image size is small then ass renderer size
void RenderASS(QImage *image, const SubImage& img, int dstX, int dstY)
{
    const quint8 a = 255 - _a(img.color);
    if (a == 0)
        return;
    const quint8 r = _r(img.color);
    const quint8 g = _g(img.color);
    const quint8 b = _b(img.color);
    const quint8 *src = (const quint8*)img.data.constData();
    // use QRgb to avoid endian issue
    QRgb *dst = (QRgb*)image->constBits() + dstY * image->width() + dstX;
    // k*src+(1-k)*dst
    for (int y = 0; y < img.height(); ++y) {
        for (int x = 0; x < img.width(); ++x) {
            const unsigned k = ((unsigned) src[x])*a/255;
#if USE_QRGBA
            const unsigned A = qAlpha(dst[x]);
#else
            quint8 *c = (quint8*)(&dst[x]);
            const unsigned A = ARGB32_A(c);
#endif
            if (A == 0) { // dst color can be ignored
#if USE_QRGBA
                 dst[x] = qRgba(r, g, b, k);
#else
                 ARGB32_SET(c, r, g, b, k);
#endif //USE_QRGBA
            } else if (k == 0) { //no change
                //dst[x] = qRgba(qRed(dst[x])), qGreen(dst[x]), qBlue(dst[x]), qAlpha(dst[x])) == dst[x];
            } else if (k == 255) {
#if USE_QRGBA
                dst[x] = qRgba(r, g, b, k);
#else
                ARGB32_SET(c, r, g, b, k);
#endif //USE_QRGBA
            } else {
                // c=k*dc/255=k*dc/256 * (1-1/256), -1<err(c) = k*dc/256^2<1, -1 is bad!
#if USE_QRGBA
                // no need to &0xff because always be 0~255
                dst[x] += qRgba2(k*(r-qRed(dst[x]))/255, k*(g-qGreen(dst[x]))/255, k*(b-qBlue(dst[x]))/255, k*(a-A)/255);
#else
                const unsigned R = ARGB32_R(c);
                const unsigned G = ARGB32_G(c);
                const unsigned B = ARGB32_B(c);
                ARGB32_ADD(c, r == R ? 0 : k*(r-R)/255, g == G ? 0 : k*(g-G)/255, b == B ? 0 : k*(b-B)/255, a == A ? 0 : k*(a-A)/255);
#endif
            }
        }
        src += img.stride();
        dst += image->width();
    }
}
Пример #17
0
// C[i] = C'[i] = (k*c[i]+(255-k)*C[i])/255 = C[i] + k*(c[i]-C[i])/255, min(c[i],C[i]) <= C'[i] <= max(c[i],C[i])
void SubtitleProcessorLibASS::renderASS32(QImage *image, ASS_Image *img, int dstX, int dstY)
{
    const quint8 a = 255 - _a(img->color);
    if (a == 0)
        return;
    const quint8 r = _r(img->color);
    const quint8 g = _g(img->color);
    const quint8 b = _b(img->color);
    quint8 *src = img->bitmap;
    // use QRgb to avoid endian issue
    QRgb *dst = (QRgb*)image->bits() + dstY * image->width() + dstX;
    for (int y = 0; y < img->h; ++y) {
        for (int x = 0; x < img->w; ++x) {
            const unsigned k = ((unsigned) src[x])*a/255;
#if USE_QRGBA
            const unsigned A = qAlpha(dst[x]);
#else
            quint8 *c = (quint8*)(&dst[x]);
            const unsigned A = ARGB32_A(c);
#endif
            if (A == 0) { // dst color can be ignored
#if USE_QRGBA
                 dst[x] = qRgba(r, g, b, k);
#else
                 ARGB32_SET(c, r, g, b, k);
#endif //USE_QRGBA
            } else if (k == 0) { //no change
                //dst[x] = qRgba(qRed(dst[x])), qGreen(dst[x]), qBlue(dst[x]), qAlpha(dst[x])) == dst[x];
            } else if (k == 255) {
#if USE_QRGBA
                dst[x] = qRgba(r, g, b, k);
#else
                ARGB32_SET(c, r, g, b, k);
#endif //USE_QRGBA
            } else {
#if USE_QRGBA
                // no need to &0xff because always be 0~255
                dst[x] += qRgba2(k*(r-qRed(dst[x]))/255, k*(g-qGreen(dst[x]))/255, k*(b-qBlue(dst[x]))/255, k*(a-A)/255);
#else
                const unsigned R = ARGB32_R(c);
                const unsigned G = ARGB32_G(c);
                const unsigned B = ARGB32_B(c);
                ARGB32_ADD(c, r == R ? 0 : k*(r-R)/255, g == G ? 0 : k*(g-G)/255, b == B ? 0 : k*(b-B)/255, a == A ? 0 : k*(a-A)/255);
#endif
            }
        }
        src += img->stride;
        dst += image->width();
    }
}
Пример #18
0
/**
 * Updates cell.
 *
 * @param   Map::Cell*   cell to update
 * @return  void
 */
void Planner::_update(Map::Cell* u)
{
	bool diff = _g(u) != _rhs(u);
	bool exists = (_open_hash.find(u) != _open_hash.end());

	if (diff && exists)
	{
		_list_update(u, _k(u));
	}
	else if (diff && ! exists)
	{
		_list_insert(u, _k(u));
	}
	else if ( ! diff && exists)
	{
		_list_remove(u);
	}
}
Пример #19
0
void 
FEM<METH>::assemble()
{
  	//Write values of dirichlet data:
    _updateDirichlet();
    
    flens::DenseVector<flens::Array<int> > 	I(9*_mesh.numElements);
    flens::DenseVector<flens::Array<int> > 	J(9*_mesh.numElements);
    flens::DenseVector<flens::Array<double> > val(9*_mesh.numElements);
    double c1[2], d21[2], d31[2];
    double area4, fval, a, b, c;
    
    for (int i=0; i<_mesh.numElements; ++i)
    {
  
        /*** Assemble stiffness matrix A ***/
        
        //Compute area of element: 
        // c1 = first vertex of element, 
        // d21 vector from first to second vertex, 
        // d31 vector from third to first vertex:
        c1[0]  = _mesh.coordinates( _mesh.elements(i+1,1),1 ); //<-----numbering starts at 1
        c1[1]  = _mesh.coordinates( _mesh.elements(i+1,1),2 );
        d21[0] = _mesh.coordinates( _mesh.elements(i+1,2),1 ) - c1[0];
        d21[1] = _mesh.coordinates( _mesh.elements(i+1,2),2 ) - c1[1];
        d31[0] = _mesh.coordinates( _mesh.elements(i+1,3),1 ) - c1[0];
        d31[1] = _mesh.coordinates( _mesh.elements(i+1,3),2 ) - c1[1];
        
        //Compute 4*|T_i| via 2-dimensional cross product:
        area4 = 2*(d21[0]*d31[1] - d21[1]*d31[0]);
        
        //Set I and J  (row and column index)
        for(int j=0; j<3; ++j) 
        {
        
            I(i*9+j  +1) = _mesh.elements(i+1,j+1);
            I(i*9+j+3+1) = _mesh.elements(i+1,j+1);
            I(i*9+j+6+1) = _mesh.elements(i+1,j+1);
        
            J(i*9+3*j  +1) = _mesh.elements(i+1,j+1);
            J(i*9+3*j+1+1) = _mesh.elements(i+1,j+1);
            J(i*9+3*j+2+1) = _mesh.elements(i+1,j+1);
            
        }
        
        //Set values for stiffness matrix A:
        a = (d21[0]*d31[0] + d21[1]*d31[1]) / area4;
        b = (d31[0]*d31[0] + d31[1]*d31[1]) / area4;
        c = (d21[0]*d21[0] + d21[1]*d21[1]) / area4;
    
        val(i*9  +1) = -2*a + b+c;
        val(i*9+1+1) = a-b;
        val(i*9+2+1) = a-c;
        val(i*9+3+1) = a-b;
        val(i*9+4+1) = b;
        val(i*9+5+1) = -a;
        val(i*9+6+1) = a-c;
        val(i*9+7+1) = -a;
        val(i*9+8+1) = c;
        
        
        /*** Assemble right-hand side ***/
        
        //Evaluate volume force f at center of mass of each element:
        fval = _f( c1[0] + (d21[0]+d31[0])/3., c1[1] + (d21[1]+d31[1])/3. ) / 12. * area4;
        _b( _mesh.elements(i+1,1)) += fval;
        _b( _mesh.elements(i+1,2)) += fval;
        _b( _mesh.elements(i+1,3)) += fval;
        
    }

    
    /*** Incorprate Neumann data ***/

    //Compute bj += int _{Gamma_N} g(x) phi_j(x) dx:
    for(int k=0; k<_mesh.numNeumann; ++k) {
    
        //Walk through all neumann edges:
        for(int j=1; j<=_mesh.neumann[k].length()-1; ++j) {
        
            double cn1[2],cn2[2], length2;
            cn1[0]  = _mesh.coordinates(_mesh.neumann[k](j),1);
            cn1[1]  = _mesh.coordinates(_mesh.neumann[k](j),2);
            cn2[0]  = _mesh.coordinates(_mesh.neumann[k](j+1),1);
            cn2[1]  = _mesh.coordinates(_mesh.neumann[k](j+1),2);
            length2 = sqrt( (cn1[0]-cn2[0])*(cn1[0]-cn2[0]) + (cn1[1]-cn2[1])*(cn1[1]-cn2[1]) ) / 2.;
            
            //Evaluate Neumann data g at midpoint of neumann edge and multiply with half length:
            double gmE = length2*_g(0.5*(cn1[0]+cn2[0]) , 0.5*(cn1[1]+cn2[1]));
            _b( _mesh.neumann[k](j)  ) += gmE;
            _b( _mesh.neumann[k](j+1)) += gmE;   
             
        }   
         
    }


    /*** Set stiffness matrix ***/
    
    //Build FLENS CRS matrix from I, J, vals (rows, cols, values):
    flens::GeCoordMatrix<flens::CoordStorage<double> > fl_A_coord(_uD.length(),_uD.length());

    // flens::CoordRowColCmp, flens::IndexBaseOne<int> 
    for (int i=1; i<=I.length(); ++i) {

        if (val(i)!=0) {
            fl_A_coord(I(i),J(i)) += val(i);
        }
    	
    }

    _A = fl_A_coord;


    /*** Set right-hand side vector b ***/    
    flens::FLENSDataVector<flens::FLvTypeII> fl_Au(_uD.length(), _mesh.coupling);
        

    /*** Incorporate Dirichlet-Data ***/
    flens::blas::mv(flens::NoTrans, 1., _A, _uD, 0., fl_Au);
    flens::blas::axpy(-1., fl_Au, _b);    

}
Пример #20
0
/**
 * Update map.
 *
 * @param   Map::Cell*   cell to update
 * @param   double       new cost of the cell
 * @return  void
 */
void Planner::update(Map::Cell* u, double cost)
{
	if (u == _goal)
		return;

	// Update km
	_km += _h(_last, _start);
	_last = _start;

	_cell(u);

	double cost_old = u->cost;
	double cost_new = cost;
	u->cost = cost;

	Map::Cell** nbrs = u->nbrs();

	double tmp_cost_old, tmp_cost_new;
	double tmp_rhs, tmp_g;

	// Update u
	for (unsigned int i = 0; i < Map::Cell::NUM_NBRS; i++)
	{
		if (nbrs[i] != NULL)
		{
			u->cost = cost_old;
			tmp_cost_old = _cost(u, nbrs[i]);
			u->cost = cost_new;
			tmp_cost_new = _cost(u, nbrs[i]);

			tmp_rhs = _rhs(u);
			tmp_g = _g(nbrs[i]);

			if (Math::greater(tmp_cost_old, tmp_cost_new))
			{
				if (u != _goal)
				{
					_rhs(u, min(tmp_rhs, (tmp_cost_new + tmp_g)));
				}
			}
			else if (Math::equals(tmp_rhs, (tmp_cost_old + tmp_g)))
			{
				if (u != _goal)
				{
					_rhs(u, _min_succ(u).second);
				}
			}
		}
	}

	_update(u);

	// Update neighbors
	for (unsigned int i = 0; i < Map::Cell::NUM_NBRS; i++)
	{
		if (nbrs[i] != NULL)
		{
			u->cost = cost_old;
			tmp_cost_old = _cost(u, nbrs[i]);
			u->cost = cost_new;
			tmp_cost_new = _cost(u, nbrs[i]);

			tmp_rhs = _rhs(nbrs[i]);
			tmp_g = _g(u);

			if (Math::greater(tmp_cost_old, tmp_cost_new))
			{
				if (nbrs[i] != _goal)
				{
					_rhs(nbrs[i], min(tmp_rhs, (tmp_cost_new + tmp_g)));
				}
			}
			else if (Math::equals(tmp_rhs, (tmp_cost_old + tmp_g)))
			{
				if (nbrs[i] != _goal)
				{
					_rhs(nbrs[i], _min_succ(nbrs[i]).second);
				}
			}

			_update(nbrs[i]);
		}
	}
}
Пример #21
0
  void AxisymmetricBoussinesqBuoyancy::element_time_derivative( bool compute_jacobian,
								AssemblyContext& context,
								CachedValues& /*cache*/ )
  {
#ifdef GRINS_USE_GRVY_TIMERS
    this->_timer->BeginTimer("AxisymmetricBoussinesqBuoyancy::element_time_derivative");
#endif

    // The number of local degrees of freedom in each variable.
    const unsigned int n_u_dofs = context.get_dof_indices(_flow_vars.u_var()).size();
    const unsigned int n_T_dofs = context.get_dof_indices(_temp_vars.T_var()).size();

    // Element Jacobian * quadrature weights for interior integration.
    const std::vector<libMesh::Real> &JxW =
      context.get_element_fe(_flow_vars.u_var())->get_JxW();

    // The velocity shape functions at interior quadrature points.
    const std::vector<std::vector<libMesh::Real> >& vel_phi =
      context.get_element_fe(_flow_vars.u_var())->get_phi();

    // The temperature shape functions at interior quadrature points.
    const std::vector<std::vector<libMesh::Real> >& T_phi =
      context.get_element_fe(_temp_vars.T_var())->get_phi();

    // Physical location of the quadrature points
    const std::vector<libMesh::Point>& u_qpoint =
      context.get_element_fe(_flow_vars.u_var())->get_xyz();

    // Get residuals
    libMesh::DenseSubVector<libMesh::Number> &Fr = context.get_elem_residual(_flow_vars.u_var()); // R_{r}
    libMesh::DenseSubVector<libMesh::Number> &Fz = context.get_elem_residual(_flow_vars.v_var()); // R_{z}

    // Get Jacobians
    libMesh::DenseSubMatrix<libMesh::Number> &KrT = context.get_elem_jacobian(_flow_vars.u_var(), _temp_vars.T_var()); // R_{r},{T}
    libMesh::DenseSubMatrix<libMesh::Number> &KzT = context.get_elem_jacobian(_flow_vars.v_var(), _temp_vars.T_var()); // R_{z},{T}

    // Now we will build the element Jacobian and residual.
    // Constructing the residual requires the solution and its
    // gradient from the previous timestep.  This must be
    // calculated at each quadrature point by summing the
    // solution degree-of-freedom values by the appropriate
    // weight functions.
    unsigned int n_qpoints = context.get_element_qrule().n_points();

    for (unsigned int qp=0; qp != n_qpoints; qp++)
      {
	const libMesh::Number r = u_qpoint[qp](0);

	// Compute the solution & its gradient at the old Newton iterate.
	libMesh::Number T;
	T = context.interior_value(_temp_vars.T_var(), qp);

	// First, an i-loop over the velocity degrees of freedom.
	// We know that n_u_dofs == n_v_dofs so we can compute contributions
	// for both at the same time.
	for (unsigned int i=0; i != n_u_dofs; i++)
	  {
	    Fr(i) += -_rho*_beta_T*(T - _T_ref)*_g(0)*vel_phi[i][qp]*r*JxW[qp];
	    Fz(i) += -_rho*_beta_T*(T - _T_ref)*_g(1)*vel_phi[i][qp]*r*JxW[qp];

	    if (compute_jacobian && context.get_elem_solution_derivative())
	      {
		for (unsigned int j=0; j != n_T_dofs; j++)
		  {
		    const libMesh::Number val =
                      -_rho*_beta_T*vel_phi[i][qp]*T_phi[j][qp]*r*JxW[qp]
                      * context.get_elem_solution_derivative();
		    KrT(i,j) += val*_g(0);
		    KzT(i,j) += val*_g(1);
		  } // End j dof loop
	      } // End compute_jacobian check

	  } // End i dof loop
      } // End quadrature loop

#ifdef GRINS_USE_GRVY_TIMERS
    this->_timer->EndTimer("AxisymmetricBoussinesqBuoyancy::element_time_derivative");
#endif

    return;
  }
Пример #22
0
/**
 * Computes shortest path.
 *
 * @return  bool   successful
 */
bool Planner::_compute()
{
	if (_open_list.empty())
		return false;

	KeyCompare key_compare;

	int attempts = 0;

	Map::Cell* u;
	pair<double,double> k_old;
	pair<double,double> k_new;
	Map::Cell** nbrs;
	double g_old;
	double tmp_g, tmp_rhs;

	while (( ! _open_list.empty() && key_compare(_open_list.begin()->first, _k(_start))) || ! Math::equals(_rhs(_start), _g(_start)))
	{
		// Reached max steps, quit
		if (++attempts > Planner::MAX_STEPS)
			return false;

		u = _open_list.begin()->second;
		k_old = _open_list.begin()->first;
		k_new = _k(u);

		tmp_rhs = _rhs(u);
		tmp_g = _g(u);
		
		if (key_compare(k_old, k_new))
		{
			_list_update(u, k_new);
		}
		else if (Math::greater(tmp_g, tmp_rhs))
		{
			_g(u, tmp_rhs);
			tmp_g = tmp_rhs;

			_list_remove(u);

			nbrs = u->nbrs();

			for (unsigned int i = 0; i < Map::Cell::NUM_NBRS; i++)
			{
				if (nbrs[i] != NULL)
				{
					if (nbrs[i] != _goal)
					{
						_rhs(nbrs[i], min(_rhs(nbrs[i]), _cost(nbrs[i], u) + tmp_g));
					}

					_update(nbrs[i]);
				}
			}
		}
		else
		{
			g_old = tmp_g;
			_g(u, Math::INF);

			// Perform action for u
			if (u != _goal)
			{
				_rhs(u, _min_succ(u).second);
			}

			_update(u);

			nbrs = u->nbrs();

			// Perform action for neighbors
			for (unsigned int i = 0; i < Map::Cell::NUM_NBRS; i++)
			{
				if (nbrs[i] != NULL)
				{
					if (Math::equals(_rhs(nbrs[i]), (_cost(nbrs[i], u) + g_old)))
					{
						if (nbrs[i] != _goal)
						{
							_rhs(nbrs[i], _min_succ(nbrs[i]).second);
						}
					}

					_update(nbrs[i]);
				}
			}
		}
	}

	return true;
}
static int writeData(void* _call)
{
    unsigned char r;
    unsigned char g;
    unsigned char b;
    unsigned char a;
    int x,y;
    int res = 0;
    unsigned char* dst;
    
    WriterFBCallData_t* call = (WriterFBCallData_t*) _call;
    
    fb_printf(100, "\n");

    if (call == NULL)
    {
        fb_err("call data is NULL...\n");
        return 0;
    }

    if (call->destination == NULL)
    {
        fb_err("file pointer < 0. ignoring ...\n");
        return 0;
    }
    
    if (call->data != NULL)
    {
        unsigned int opacity = 255 - ((unsigned int)_a(call->color));
        unsigned int r = (unsigned int)_r(call->color);
        unsigned int g = (unsigned int)_g(call->color);
        unsigned int b = (unsigned int) _b(call->color);
        int src_stride = call->Stride;
        int dst_stride = call->destStride;
        int dst_delta  = dst_stride - call->Width*4;
        int x,y;
        const unsigned char *src = call->data;
        unsigned char *dst = call->destination + (call->y * dst_stride + call->x * 4);
        unsigned int k,ck,t;

        fb_printf(100, "x           %d\n", call->x);
        fb_printf(100, "y           %d\n", call->y);
        fb_printf(100, "width       %d\n", call->Width);
        fb_printf(100, "height      %d\n", call->Height);
        fb_printf(100, "stride      %d\n", call->Stride);
        fb_printf(100, "color       %d\n", call->color);
        fb_printf(100, "data        %p\n", call->data);
        fb_printf(100, "dest        %p\n", call->destination);
        fb_printf(100, "dest.stride %d\n", call->destStride);

        fb_printf(100, "r 0x%hhx, g 0x%hhx, b 0x%hhx, a 0x%hhx, opacity %d\n", r, g, b, a, opacity);

        for (y=0;y<call->Height;y++)
        {
            for (x = 0; x < call->Width; x++)
            {
                k = ((unsigned)src[x]) * opacity / 255;
                ck = 255 - k;
                t = *dst;
                *dst++ = (k*b + ck*t) / 255;
                t = *dst;
                *dst++ = (k*g + ck*t) / 255;
                t = *dst;
                *dst++ = (k*r + ck*t) / 255;
                *dst++ = 0;
            }

            dst += dst_delta;
            src += src_stride;
        }
    } else
    {
         for (y = 0; y < call->Height; y++)
                memset(call->destination + ((call->y + y) * call->destStride) + call->x * 4, 0, call->Width * 4);
    }
 
    fb_printf(100, "< %d\n", res);
    return res;
}
Пример #24
0
unsigned __stdcall MatchThread(void *pParam)
{
    int FLEN;
    int n = 0, n1, i;
    dbQuery sql;
    ControlFlowGraph *target_cfg;

    db.attach();

    dbCursor<LibM> cursor1;
    int thread_id = (int)pParam;
    instruction_count[thread_id] = 0;
    fn[thread_id] = 0;

    while ((i = GetM()) != -1)
    {
        int startEA = f_info[i].startEA;
        FLEN = f_info[i].len;

        // disasm
        byte *bin = (byte *)RvaToPtr(pImageNtH, stMapFile.ImageBase, startEA - pOH->ImageBase);
        if (bin == NULL)
        {
            continue;
        }

        target_cfg = (ControlFlowGraph *)disasm(bin, FLEN, false, NULL);

        if (target_cfg == NULL || target_cfg->instructions.size() < MIN_INS_LENGTH)
        {
            clean(target_cfg);
            continue;
        }

        fn[thread_id]++;

        instruction_count[thread_id] += target_cfg->instructions.size();
        target_cfg->build();

        {
            sql = "MOV_COUNT<=", target_cfg->MOV_COUNT, " and CTI_COUNT<=", target_cfg->CTI_COUNT, " and ARITHMETIC_COUNT<=", target_cfg->ARITHMETIC_COUNT, " and LOGI_COUNT<=", target_cfg->LOGI_COUNT, " and STRING_COUNT<=", target_cfg->STRING_COUNT, " and ETC_COUNT<=", target_cfg->ETC_COUNT, " and instruction_size<=", target_cfg->instructions.size(), "and block_size<=", target_cfg->bb_len, "order by instruction_size desc";
        }

        n1 = cursor1.select(sql);
        if (n1 == 0)
        {
            clean(target_cfg);
            continue;
        }

        CBitSet lib_info(target_cfg->instructions.size());
        do
        {
            ControlFlowGraph *library_cfg = (ControlFlowGraph *)(cursor1->cfg);


            target_cfg->buildDepGraph(false);
            library_cfg->buildDepGraph(true);

            library_cfg->serialize();
            library_cfg->buildVLibGraph();

            target_cfg->serialize();
            target_cfg->buildVLibGraph();

            //r0[thread_id]++;
            Graph _g(&target_cfg->vlibARGEdit);
            Graph _m(&library_cfg->vlibARGEdit);
            _m.SetNodeComparator(new InstructionComparator3);

            VF2SubState s0(&_m, &_g);
            int d[4];
            d[0] = (int)target_cfg;
            d[1] = startEA;
            d[2] = (int)cursor1->lib_name;
            d[3] = (int)&lib_info;
            Match m(&s0, my_visitor2, &d);
            m.match_serial();
        }
        while (cursor1.next());

        clean(target_cfg);
    }
    db.detach();

    printf("#%d done.\n", thread_id);
    return 0;
}
Пример #25
0
//
// process thread
//
unsigned __stdcall MatchThreadForFull(void *pParam)
{
    int FLEN;
    int n = 0, n1, i;
    dbQuery sql;
    ControlFlowGraph *target_cfg;

    db.attach();

    dbCursor<LibM> cursor1;
    int thread_id = (int)pParam;
    instruction_count[thread_id] = 0;
    fn[thread_id] = 0;

    while ((i = GetM()) != -1)
    {
        int startEA = f_info[i].startEA;
        FLEN = f_info[i].len;

        // disasm
        byte *bin = (byte *)RvaToPtr(pImageNtH, stMapFile.ImageBase, startEA - pOH->ImageBase);
        if (bin == NULL)
        {
            continue;
        }

        target_cfg = (ControlFlowGraph *)disasm(bin, FLEN, false, NULL);

        if (target_cfg == NULL || target_cfg->instructions.size() < MIN_INS_LENGTH)
        {
            clean(target_cfg);
            continue;
        }

        fn[thread_id]++;

        instruction_count[thread_id] += target_cfg->instructions.size();
        target_cfg->build();

        {
            sql = "MOV_COUNT=", target_cfg->MOV_COUNT, " and CTI_COUNT=", target_cfg->CTI_COUNT, " and ARITHMETIC_COUNT=", target_cfg->ARITHMETIC_COUNT, " and LOGI_COUNT=", target_cfg->LOGI_COUNT, " and STRING_COUNT=", target_cfg->STRING_COUNT, " and ETC_COUNT=", target_cfg->ETC_COUNT, " and instruction_size=", target_cfg->instructions.size(), "and block_size=", target_cfg->bb_len, "order by instruction_size desc";
        }

        n1 = cursor1.select(sql);
        if (n1 == 0)
        {
            clean(target_cfg);
            continue;
        }

        CBitSet lib_info(target_cfg->instructions.size());
        do
        {
            ControlFlowGraph *library_cfg = (ControlFlowGraph *)(cursor1->cfg);

            // BBLR
            bitset<10240> t = target_cfg->bblen_set;
            t.flip();
            t &= library_cfg->bblen_set;
            if (t.any())
            {
                continue;
            }

            target_cfg->buildDepGraph(false);
            library_cfg->buildDepGraph(true);

            //if (bSerialize)
            {
                // rule5: BBSR
                if (!matchBBSF(target_cfg, library_cfg))
                {
                    //r5[thread_id]++;
                    continue;
                }
            }

            library_cfg->serialize();
            library_cfg->buildVLibGraph();

            target_cfg->serialize();
            target_cfg->buildVLibGraph();

            //r0[thread_id]++;
            Graph _g(&target_cfg->vlibARGEdit);
            Graph _m(&library_cfg->vlibARGEdit);
            _m.SetNodeComparator(new InstructionComparator3);

            VF2SubState s0(&_m, &_g);
            Match m(&s0, my_visitor1, &lib_info);
            m.match_par();
            if (m.foundFlg)
            {
                printf("%d\t1\t%X\t%s\n", thread_id, startEA, cursor1->lib_name);
            }
        }
        while (cursor1.next());

        clean(target_cfg);
    }
    db.detach();

    printf("#%d done.\n", thread_id);
    return 0;
}
Пример #26
0
/* Main function for simple tracy based applications */
int tracy_main(struct tracy *tracy) {
    struct tracy_event *e;

    /* Setup interrupt handler */
    main_loop_go_on = 1;
    signal(SIGINT, _main_interrupt_handler);

    while (main_loop_go_on) {
        e = tracy_wait_event(tracy, -1);
        if (!e) {
            fprintf(stderr, "tracy_main: tracy_wait_Event returned NULL\n");
            continue;
        }

        if (e->type == TRACY_EVENT_NONE) {
            break;
        } else if (e->type == TRACY_EVENT_INTERNAL) {
            /*
            printf("Internal event for syscall: %s\n",
                    get_syscall_name(e->syscall_num));
            */
        }
        if (e->type == TRACY_EVENT_SIGNAL) {
            if (TRACY_PRINT_SIGNALS(tracy)) {
                fprintf(stderr, _y("Signal %s (%ld) for child %d")"\n",
                    get_signal_name(e->signal_num), e->signal_num, e->child->pid);
            }
        } else

        if (e->type == TRACY_EVENT_SYSCALL) {
            /*
            if (TRACY_PRINT_SYSCALLS(tracy)) {
                printf(_y("%04d System call: %s (%ld) Pre: %d")"\n",
                        e->child->pid, get_syscall_name(e->syscall_num),
                        e->syscall_num, e->child->pre_syscall);
            }
            */
        } else

        if (e->type == TRACY_EVENT_QUIT) {
            if (tracy->opt & TRACY_VERBOSE)
                printf(_b("EVENT_QUIT from %d with signal %s (%ld)\n"),
                        e->child->pid, get_signal_name(e->signal_num),
                        e->signal_num);
            if (e->child->pid == tracy->fpid) {
                if (tracy->opt & TRACY_VERBOSE)
                    printf(_g("Our first child died.\n"));
            }

            tracy_remove_child(e->child);
            continue;
        }

        if (!tracy_children_count(tracy)) {
            break;
        }

        tracy_continue(e, 0);
    }

    /* Tear down interrupt handler */
    signal(SIGINT, SIG_DFL);

    return 0;
}
Пример #27
0
  void BoussinesqBuoyancy::element_time_derivative
  ( bool compute_jacobian,
    AssemblyContext & context )
  {
    // The number of local degrees of freedom in each variable.
    const unsigned int n_u_dofs = context.get_dof_indices(_flow_vars.u()).size();
    const unsigned int n_T_dofs = context.get_dof_indices(_temp_vars.T()).size();

    // Element Jacobian * quadrature weights for interior integration.
    const std::vector<libMesh::Real> &JxW =
      context.get_element_fe(_flow_vars.u())->get_JxW();

    // The velocity shape functions at interior quadrature points.
    const std::vector<std::vector<libMesh::Real> >& vel_phi =
      context.get_element_fe(_flow_vars.u())->get_phi();

    // The temperature shape functions at interior quadrature points.
    const std::vector<std::vector<libMesh::Real> >& T_phi =
      context.get_element_fe(_temp_vars.T())->get_phi();

    // Get residuals
    libMesh::DenseSubVector<libMesh::Number> &Fu = context.get_elem_residual(_flow_vars.u()); // R_{u}
    libMesh::DenseSubVector<libMesh::Number> &Fv = context.get_elem_residual(_flow_vars.v()); // R_{v}
    libMesh::DenseSubVector<libMesh::Number>* Fw = NULL;

    // Get Jacobians
    libMesh::DenseSubMatrix<libMesh::Number> &KuT = context.get_elem_jacobian(_flow_vars.u(), _temp_vars.T()); // R_{u},{T}
    libMesh::DenseSubMatrix<libMesh::Number> &KvT = context.get_elem_jacobian(_flow_vars.v(), _temp_vars.T()); // R_{v},{T}
    libMesh::DenseSubMatrix<libMesh::Number>* KwT = NULL;



    if( this->_flow_vars.dim() == 3 )
      {
        Fw  = &context.get_elem_residual(_flow_vars.w()); // R_{w}
        KwT = &context.get_elem_jacobian(_flow_vars.w(), _temp_vars.T()); // R_{w},{T}
      }

    // Now we will build the element Jacobian and residual.
    // Constructing the residual requires the solution and its
    // gradient from the previous timestep.  This must be
    // calculated at each quadrature point by summing the
    // solution degree-of-freedom values by the appropriate
    // weight functions.
    unsigned int n_qpoints = context.get_element_qrule().n_points();

    for (unsigned int qp=0; qp != n_qpoints; qp++)
      {
        // Compute the solution & its gradient at the old Newton iterate.
        libMesh::Number T;
        T = context.interior_value(_temp_vars.T(), qp);

        // First, an i-loop over the velocity degrees of freedom.
        // We know that n_u_dofs == n_v_dofs so we can compute contributions
        // for both at the same time.
        for (unsigned int i=0; i != n_u_dofs; i++)
          {
            Fu(i) += -_rho*_beta_T*(T - _T_ref)*_g(0)*vel_phi[i][qp]*JxW[qp];
            Fv(i) += -_rho*_beta_T*(T - _T_ref)*_g(1)*vel_phi[i][qp]*JxW[qp];

            if (this->_flow_vars.dim() == 3)
              (*Fw)(i) += -_rho*_beta_T*(T - _T_ref)*_g(2)*vel_phi[i][qp]*JxW[qp];

            if (compute_jacobian)
              {
                for (unsigned int j=0; j != n_T_dofs; j++)
                  {
                    KuT(i,j) += context.get_elem_solution_derivative() *
                      -_rho*_beta_T*_g(0)*vel_phi[i][qp]*T_phi[j][qp]*JxW[qp];
                    KvT(i,j) += context.get_elem_solution_derivative() *
                      -_rho*_beta_T*_g(1)*vel_phi[i][qp]*T_phi[j][qp]*JxW[qp];

                    if (this->_flow_vars.dim() == 3)
                      (*KwT)(i,j) += context.get_elem_solution_derivative() *
                        -_rho*_beta_T*_g(2)*vel_phi[i][qp]*T_phi[j][qp]*JxW[qp];

                  } // End j dof loop
              } // End compute_jacobian check

          } // End i dof loop
      } // End quadrature loop
  }
Пример #28
0
 vector<int> grayCode(int n) {
     vector <int> ret = {0};
     _g(0, n, ret);
     return ret;
 }