Ejemplo n.º 1
0
int main(int argc, char **argv) {
    if (argc > 1 && strcmp(argv[1], "-n") == 0) {
        cpu_force_no_simd( );
    }

    build_lookup_tables( );

    /* Read 1080p UYVY422 frames on stdin. Dump M-JPEG stream on stdout. */
    RawFrame frame(720, 480, RawFrame::CbYCrY8422);

    ssize_t ret;


    for (;;) {
        ret = frame.read_from_fd(STDIN_FILENO);

        if (ret < 0) {
            perror("frame.read_from_fd");
            exit(1);
        } else if (ret == 0) {
            break;
        } else {
            RawFrame *out = upscale(&frame);

            if (out->write_to_fd(STDOUT_FILENO) < 0) {
                perror("write_to_fd");
                break;
            }
            delete out;
        }            
    }
}
Ejemplo n.º 2
0
		void cudnn_util::set_convolution_descriptor(
			cudnnConvolutionDescriptor_t convolution_desc,
			const std::vector<unsigned int> zero_padding)
		{
			std::vector<int> conv_padding(zero_padding.rbegin(), zero_padding.rend());
			std::vector<int> filter_stride(zero_padding.size(), 1);
			std::vector<int> upscale(zero_padding.size(), 1);
			cudnn_safe_call(cudnnSetConvolutionNdDescriptor_v3(
				convolution_desc,
				static_cast<int>(zero_padding.size()),
				&conv_padding[0],
				&filter_stride[0],
				&upscale[0],
				CUDNN_CROSS_CORRELATION,
				CUDNN_DATA_FLOAT));
		}
Ejemplo n.º 3
0
IPTR Prop__OM_GET(struct IClass *cl, Object *obj, struct opGet *msg)
{
    struct Prop_DATA *data = INST_DATA(cl, obj);
    switch (msg->opg_AttrID)
    {
    	case    MUIA_Prop_First:
		{
		    if (data->prop_object)
		    {
		    	IPTR v;
			/* So we can get a more current value */
		        GetAttr(PGA_Top,data->prop_object,&v);
			data->first = upscale(data, v);
		    }
		    STORE = data->first;
		    return 1;
		}
    	case    MUIA_Prop_Entries: STORE = data->entries; return 1;
    	case    MUIA_Prop_Visible: STORE = data->visible; return 1;
	    
	/* CHECKME: MUIA_Prop_Release
	
	   TextEditor.mcc sets up notification on slider obj which is subclass
	   of group and notification on group children (the prop object) will be
	   dropped if the child does not return TRUE on OM_GET.
	   
	   It may be that MUI handles this differently, because a quick check
	   with UAE/MUI showed that a GetAttr() of MUIA_Prop_Release on alider
	   object does not work (returns FALSE). Maybe MUI slider class is
	   similiar to for exampe NListview.mcc which overrides MUIM_Notify where
	   it checks for known attributes and forwards the Method to the correct child
	   of the group.	 	   
	*/
	case	MUIA_Prop_Release: STORE = 0; return 1;
    	default:
    	        return DoSuperMethodA(cl,obj,(Msg)msg);
    }

    return 1;
}
Ejemplo n.º 4
0
//! \brief Main driver
int main(int argc, char** argv)
try
{
    try {
        static const int dim = 3;

        typedef Dune::CpGrid GridType;

        if (argc < 2 || strcmp(argv[1],"-h") == 0
                || strcmp(argv[1],"--help") == 0
                || strcmp(argv[1],"-?") == 0) {
            syntax(argv);
            exit(1);
        }
        Params p;
        parseCommandLine(argc,argv,p);

        Opm::time::StopWatch watch;
        watch.start();

        GridType grid;
        if (p.file == "uniform") {
            std::array<int,3> cells;
            cells[0] = p.cellsx;
            cells[1] = p.cellsy;
            cells[2] = p.cellsz;
            std::array<double,3> cellsize;
            cellsize[0] = cellsize[1] = cellsize[2] = 1.f;
            grid.createCartesian(cells,cellsize);
        } else
            grid.readEclipseFormat(p.file,p.ctol,false);

        typedef GridType::ctype ctype;
        Opm::Elasticity::ElasticityUpscale<GridType> upscale(grid, p.ctol,
                p.Emin, p.file,
                p.rocklist,
                p.verbose);
        if (p.max[0] < 0 || p.min[0] < 0) {
            std::cout << "determine side coordinates..." << std::endl;
            upscale.findBoundaries(p.min,p.max);
            std::cout << "  min " << p.min[0] << " " << p.min[1] << " " << p.min[2] << std::endl;
            std::cout << "  max " << p.max[0] << " " << p.max[1] << " " << p.max[2] << std::endl;
        }
        if (p.n1 == -1 || p.n2 == -1) {
            p.n1 = grid.logicalCartesianSize()[0];
            p.n2 = grid.logicalCartesianSize()[1];
        }
        if (p.linsolver.zcells == -1) {
            double lz = p.max[2]-p.min[2];
            int nz = grid.logicalCartesianSize()[2];
            double hz = lz/nz;
            double lp = sqrt((double)(p.max[0]-p.min[0])*(p.max[1]-p.min[1]));
            int np = std::max(grid.logicalCartesianSize()[0],
                              grid.logicalCartesianSize()[1]);
            double hp = lp/np;
            p.linsolver.zcells = (int)(2*hp/hz+0.5);
        }
        std::cout << "logical dimension: " << grid.logicalCartesianSize()[0]
                  << "x"                   << grid.logicalCartesianSize()[1]
                  << "x"                   << grid.logicalCartesianSize()[2]
                  << std::endl;

        if (p.method == UPSCALE_MPC) {
            std::cout << "using MPC couplings in all directions..." << std::endl;
            upscale.periodicBCs(p.min, p.max);
            std::cout << "preprocessing grid..." << std::endl;
            upscale.A.initForAssembly();
        } else if (p.method == UPSCALE_MORTAR) {
            std::cout << "using Mortar couplings.." << std::endl;
            upscale.periodicBCsMortar(p.min, p.max, p.n1, p.n2,
                                      p.lambda[0], p.lambda[1]);
        } else if (p.method == UPSCALE_NONE) {
            std::cout << "no periodicity approach applied.." << std::endl;
            upscale.fixCorners(p.min, p.max);
            upscale.A.initForAssembly();
        }
        Dune::FieldMatrix<double,6,6> C;
        Dune::VTKWriter<GridType::LeafGridView>* vtkwriter=0;
        if (!p.vtufile.empty())
            vtkwriter = new Dune::VTKWriter<GridType::LeafGridView>(grid.leafView());
        Opm::Elasticity::Vector field[6];
        std::cout << "assembling elasticity operator..." << "\n";
        upscale.assemble(-1,true);
        std::cout << "setting up linear solver..." << std::endl;
        upscale.setupSolvers(p.linsolver);

//#pragma omp parallel for schedule(static)
        for (int i=0; i<6; ++i) {
            std::cout << "processing case " << i+1 << "..." << std::endl;
            std::cout << "\tassembling load vector..." << std::endl;
            upscale.assemble(i,false);
            std::cout << "\tsolving..." << std::endl;
            upscale.solve(i);
            upscale.A.expandSolution(field[i],upscale.u[i]);
#define CLAMP(x) (fabs(x)<1.e-4?0.0:x)
            for (size_t j=0; j<field[i].size(); ++j) {
                double val = field[i][j];
                field[i][j] = CLAMP(val);
            }
            Dune::FieldVector<double,6> v;
            upscale.averageStress(v,upscale.u[i],i);
            for (int j=0; j<6; ++j)
                C[i][j] = CLAMP(v[j]);
        }
        for (int i=0; i<6; ++i) {
            std::stringstream str;
            str << "sol " << i+1;
            if (vtkwriter)
                vtkwriter->addVertexData(field[i], str.str().c_str(), dim);
        }
        if (vtkwriter) {
            vtkwriter->write(p.vtufile);
            delete vtkwriter;
        }
        // voigt notation
        for (int j=0; j<6; ++j)
            std::swap(C[3][j],C[5][j]);
        for (int j=0; j<6; ++j)
            std::swap(C[j][3],C[j][5]);
        std::cout << "---------" << std::endl;
        std::cout << C << std::endl;
        if (!p.output.empty()) {
            writeOutput(p,watch,grid.size(0),upscale.volumeFractions,C);
        }

        return 0;
    }
    catch (Dune::Exception &e) {
        std::cerr << "Dune reported error: " << e << std::endl;
    }
    catch (...) {
        std::cerr << "Unknown exception thrown!" << std::endl;
    }
    return 1;
}
catch (const std::exception &e) {
    std::cerr << "Program threw an exception: " << e.what() << "\n";
    throw;
}