예제 #1
0
void ANCFBeamBE2D::GetH(Matrix& H)
{
	if (Hmatrix.Getrows() == SOS())
	{
		H = Hmatrix;
		return;
	}
	else
	{
		double A = this->GetMaterial().BeamRhoA() / this->GetMaterial().Density();

		H.SetSize(SOS(), Dim());
		H.SetAll(0);

		for (IntegrationPointsIterator ip(integrationRuleLoad); !ip.IsEnd(); ++ip)
		{
			double x = ip.Point2D().X();

			// jacobi determinant
			//Vector2D rx0 = GetRefPosx2D(x);
			double det = 0.5*GetLx(); //*rx0.Norm();

			double d = A * det * ip.Weight();

			for (int i = 1; i <= NS(); i++)
			{
				double s = GetS0(x, i);
				H(2*i-1, 1) += d * s;
				H(2*i,   2) += d * s; //H(2*i-1, 1);
			}	
		}
		Hmatrix = H;
	}
};
예제 #2
0
void ANCFBeamBE2D::EvalM(Matrix& m, double t)
{
	if (this->massmatrix.Getrows() != 0)	// mass matrix already computed
	{
		m = massmatrix;
		return;
	}
	
	Matrix H(Dim(), SOS());
	massmatrix.SetSize(SOS(), SOS());
	massmatrix.SetAll(0.);

	double rhoA = GetBeamRhoA();
	
	for (IntegrationPointsIterator ip(integrationRuleMass); !ip.IsEnd(); ++ip)
	{
		for (int i = 1; i <= NS(); i++)
		{
			H(1, 2*i-1) = GetS0(ip.Point2D().X(), i);
			H(2, 2*i) = H(1, 2*i-1);
		}
		H = (0.5*GetLx()*rhoA*ip.Weight()) * (H.GetTp() * H);
		massmatrix += H;
	}
	m = massmatrix;
};
예제 #3
0
void testSnappyStream()
{
	libmaus::autoarray::AutoArray<char> A = ::libmaus::aio::SynchronousGenericInput<char>::readArray("configure");
	std::string const message(A.begin(),A.end()) ;

	std::ostringstream ostr;
	::libmaus::lz::SnappyOutputStream<std::ostringstream> SOS(ostr,64*1024);
	SOS.write(A.begin(),A.size());
	SOS.flush();
	ostr.flush();
	
	std::string const & streamdata = ostr.str();
	::libmaus::lz::SnappyStringInputStream SIS(streamdata);
	
	std::ostringstream comp;
	int c = -1;
	while ( (c = SIS.get()) != -1 )
		comp.put(c);
		
	
	::libmaus::lz::SnappyStringInputStream SISB(streamdata);
	libmaus::autoarray::AutoArray<char> B(A.size(),false);
	char * p = B.begin();
	uint64_t d;
	while ( (d = SISB.read(p,64*1024)) != 0 )
		p += d;
	
	assert ( std::string(B.begin(),B.end()) == message );

	std::cerr << "block stream test " << ((comp.str()==message)?"ok":"FAILED") << std::endl;
}
예제 #4
0
void Constraint::LinkToElementsPenalty()
{
	if (IS()!=0 && SOS()!=0)
	{
		UO(UO_LVL_err) << "Error: Constraint::LinkToElementsPenalty() is not possible for mixed penalty/Lagrange elements\n";
	}
	LTGreset();

	// add all SOS dofs from the elements
	//Position(first SOS) 
	for (int k=1; k <= NE(); k++)
	{
		for (int i=1; i <= GetElem(k).SOS(); i++)
		{
			AddLTG(GetElem(k).LTG(i));
		}
	}
	//and Velocity (second SOS):
	for (int k=1; k <= NE(); k++)
	{
		for (int i=1; i <= GetElem(k).SOS(); i++)
		{
			AddLTG(GetElem(k).LTG(i+GetElem(k).SOS()));
		}
	}
}
예제 #5
0
void ANCFBeamBE2D::GetdPosdqT(const Vector2D& p_loc, Matrix& dpdqi)
{
	//p = S(p.x,p.y,p.z)*q; d(p)/dq
	dpdqi.SetSize(SOS(),Dim());
	dpdqi.FillWithZeros();
	//d = S + ...
	for (int i = 1; i <= NS(); i++)
	{
		double s = GetS0(p_loc.X(), i);
		dpdqi((i-1)*Dim()+1,1) = s;
		dpdqi((i-1)*Dim()+2,2) = s;
	}
	if (p_loc.Y() != 0)
	{
		double y = p_loc.Y();
		Vector2D rx = GetPosx2D(p_loc.X());
		Vector2D n(-rx.X(), rx.Y());
		n /= rx.Norm();

		for (int i = 1; i <= NS(); i++)
		{
			double sx = GetS0x(p_loc.X(), i) * 2./GetLx();
			//y/|n|*dn/dq
			dpdqi((i-1)*Dim()+1,2) +=  y*sx;
			dpdqi((i-1)*Dim()+2,1) += -y*sx;

			//y*n/|n|*(r_x1*S_x1 + r_x2*S_x2)
			dpdqi((i-1)*Dim()+1,1) +=  y*n.X()*(rx.X()*sx);
			dpdqi((i-1)*Dim()+1,2) +=  y*n.Y()*(rx.X()*sx);
			dpdqi((i-1)*Dim()+2,1) +=  y*n.X()*(rx.Y()*sx);
			dpdqi((i-1)*Dim()+2,2) +=  y*n.Y()*(rx.Y()*sx);
		}
	}
};
예제 #6
0
void ImageFilter<T>::SOS(ImageSize reconSize)
{
    SOS(m_associatedData, reconSize);

    for (auto &data : *m_associatedData.getChannelImage(0))
    {
        data = std::sqrt(data);
    }
}
예제 #7
0
//this function assigns default values to the element variables
void Mass1D::ElementDefaultConstructorInitialization()
{
	type = TBody;
	drawres = 8;
	x_init = Vector(2*SOS()); //zero initialized
	elementname = GetElementSpec();
	radius = 0.1;						// DR just some default value
	pref3D = Vector3D(0.);
	rotref3D  = Matrix3D(1.);
}
예제 #8
0
void _jn516_custom_exception_bus_error(uint32* pu32Stack, int type) {
  unsigned char TX_BUFFER[100];
  LED_INIT();
  UART_INIT(TX_BUFFER);
  while (TRUE) {
  	SOS();
  	BLINK(1);
    vDebug("Bus Error\n");
  	PRINT_ADDRESSES(pu32Stack);
  	LONG_OFF();
  }
}
예제 #9
0
void _jn516_custom_exception_stack_overflow(uint32* pu32Stack, int type) {
  unsigned char TX_BUFFER[100];
  LED_INIT();
  UART_INIT(TX_BUFFER);
  while (TRUE) {
  	SOS();
  	BLINK(7);
    vDebug("Stack Overflow\n");
  	PRINT_ADDRESSES(pu32Stack);
  	LONG_OFF();
  }
}
예제 #10
0
void _jn516_custom_exception_illegal_instruction(uint32* pu32Stack, int type) {
  unsigned char TX_BUFFER[100];
  LED_INIT();
  UART_INIT(TX_BUFFER);
  while (TRUE) {
  	SOS();
  	BLINK(3);
    vDebug("Illegal Instruction\n");
  	PRINT_ADDRESSES(pu32Stack);
  	LONG_OFF();
  }
}
예제 #11
0
void _jn516_custom_exception_unaligned_access(uint32* pu32Stack, int type) {
  unsigned char TX_BUFFER[100];
  LED_INIT();
  UART_INIT(TX_BUFFER);
  while (TRUE) {
  	SOS();
  	BLINK(2);
    vDebug("Unaligned Access\n");
  	PRINT_ADDRESSES(pu32Stack);
  	LONG_OFF();
  }
}
예제 #12
0
#define	KMZ_CREATEZONE		((void *)-2)
#define KMZ_LOOKUPZONE		((void *)-1)
#define KMZ_MALLOC			((void *)0)
#define	KMZ_SHAREZONE		((void *)1)

struct kmzones {
	size_t		kz_elemsize;
	void		*kz_zalloczone;
	boolean_t	kz_noencrypt;
} kmzones[M_LAST] = {
#define	SOS(sname)	sizeof (struct sname)
#define SOX(sname)	-1
	{ -1,		0, FALSE },			/* 0 M_FREE */
	{ MSIZE,	KMZ_CREATEZONE, FALSE },	/* 1 M_MBUF */
	{ 0,		KMZ_MALLOC, FALSE },		/* 2 M_DEVBUF */
	{ SOS(socket),	KMZ_CREATEZONE, TRUE },		/* 3 M_SOCKET */
	{ SOS(inpcb),	KMZ_LOOKUPZONE, TRUE },		/* 4 M_PCB */
	{ M_MBUF,	KMZ_SHAREZONE, FALSE },		/* 5 M_RTABLE */
	{ M_MBUF,	KMZ_SHAREZONE, FALSE },		/* 6 M_HTABLE */
	{ M_MBUF,	KMZ_SHAREZONE, FALSE },		/* 7 M_FTABLE */
	{ SOS(rusage),	KMZ_CREATEZONE, TRUE },		/* 8 M_ZOMBIE */
	{ 0,		KMZ_MALLOC, FALSE },		/* 9 M_IFADDR */
	{ M_MBUF,	KMZ_SHAREZONE, FALSE },		/* 10 M_SOOPTS */
	{ 0,		KMZ_MALLOC, FALSE },		/* 11 M_SONAME */
	{ MAXPATHLEN,	KMZ_CREATEZONE, FALSE },	/* 12 M_NAMEI */
	{ 0,		KMZ_MALLOC, FALSE },		/* 13 M_GPROF */
	{ 0,		KMZ_MALLOC, FALSE },		/* 14 M_IOCTLOPS */
	{ 0,		KMZ_MALLOC, FALSE },		/* 15 M_MAPMEM */
	{ SOS(ucred),	KMZ_CREATEZONE, FALSE },	/* 16 M_CRED */
	{ SOS(pgrp),	KMZ_CREATEZONE, FALSE },	/* 17 M_PGRP */
	{ SOS(session),	KMZ_CREATEZONE, FALSE },	/* 18 M_SESSION */
예제 #13
0
파일: Main.cpp 프로젝트: pengwg/fastrecon
int main(int argc, char *argv[])
{
    ProgramOptions options(argc, argv);
    options.showParameters();
    ReconParameters params = options.getReconParameters();

    // -------------- Load multi-channel data -----------------
    auto reconData = ReconData<float>::Create(params.samples, params.projections, options.isGPU());
    loadReconData(params, reconData.get());

    unsigned threads = std::min(reconData->channels(), omp_get_num_procs());

    QElapsedTimer timer0, timer;
    timer0.start();

    // -------------- Gridding -------------------------------
    timer.start();
    auto grid = GridLut<float>::Create(*reconData);

#ifdef BUILD_CUDA
    if (options.isGPU()) {
        dynamic_cast<cuGridLut<float> *>(grid.get())->setNumOfPartitions(25);
    }
#endif // BUILD_CUDA

    grid->setNumOfThreads(threads);
    grid->plan(params.rcxres, params.overgridding_factor, params.kernel_width, 512);
    auto imgData = grid->execute();
    std::cout << "Gridding total time " << timer.elapsed() << " ms" << std::endl;

    ImageData<float> imgMap;
    if (params.pils)
        imgMap = *imgData;

    auto filter = ImageFilter<float>::Create(*imgData);
    filter->setNumOfThreads(threads);

    // --------------- FFT ----------------------------------
    filter->fftPlan();
    
    timer.restart();
    filter->fftExecute();
    filter->fftShift();
    std::cout << "FFT total time " << timer.restart() << " ms" << std::endl;

    // -------------- Recon Methods -----------------------------------
    timer.restart();
    if (params.pils) {
        auto filterMap = ImageFilter<float>::Create(imgMap);
        std::cout << "\nRecon PILS... " << std::endl;
        filterMap->lowFilter(22);
        std::cout << "\nLow pass filtering | " << timer.restart() << " ms" << std::endl;

        std::cout << "\nFFT low res image... " << std::endl;
        filterMap->fftExecute();
        filterMap->fftShift();
        std::cout << "FFT total time " << timer.restart() << " ms" << std::endl;

        filterMap->normalize();

        std::cout << "\nSum of Square Field Map..." << std::flush;
        filter->SOS(imgMap, {params.rcxres, params.rcyres, params.rczres});
        std::cout << " | " << timer.elapsed() << " ms" << std::endl;
    }
    else
    {
        std::cout << "\nRecon SOS... " << std::flush;
        filter->SOS({params.rcxres, params.rcyres, params.rczres});
        std::cout << " | " << timer.elapsed() << " ms" << std::endl;
    }

    std::cout << "\nProgram total time excluding I/O: " << timer0.elapsed() / 1000.0 << " s" << std::endl;

    // -------------------------- Save Data ---------------------------
    QFile file(params.path + params.outFile);
    file.open(QIODevice::WriteOnly);
    for (const auto &data : *imgData->getChannelImage()) {
        auto value = std::abs(data);
        file.write((const char *)&value, sizeof(decltype(value)));
    }
    file.close();

    // -------------------------- Display Data -----------------------
    int n = 0;
    if (options.isDisplay())
    {
        QApplication app(argc, argv);
        for (int i = 0; i < imgData->channels(); i++)
        {
            auto data = imgData->getChannelImage(i);
            displayData(*data, imgData->imageSize(), QString("channel ") + QString::number(n++));
        }
        return app.exec();
    }
    else
        return 0;
}
예제 #14
0
/* for use with kmzones.kz_zalloczone */
#define	KMZ_CREATEZONE		((void *)-2)
#define KMZ_LOOKUPZONE		((void *)-1)
#define KMZ_MALLOC			((void *)0)
#define	KMZ_SHAREZONE		((void *)1)

struct kmzones {
	size_t		kz_elemsize;
	void		*kz_zalloczone;
} kmzones[M_LAST] = {
#define	SOS(sname)	sizeof (struct sname)
#define SOX(sname)	-1
	{ -1,		0 },			/* 0 M_FREE */
	{ MSIZE,	KMZ_CREATEZONE },	/* 1 M_MBUF */
	{ 0,		KMZ_MALLOC },		/* 2 M_DEVBUF */
	{ SOS(socket),	KMZ_CREATEZONE },	/* 3 M_SOCKET */
	{ SOS(inpcb),	KMZ_LOOKUPZONE },	/* 4 M_PCB */
	{ M_MBUF,	KMZ_SHAREZONE },	/* 5 M_RTABLE */
	{ M_MBUF,	KMZ_SHAREZONE },	/* 6 M_HTABLE */
	{ M_MBUF,	KMZ_SHAREZONE },	/* 7 M_FTABLE */
	{ SOS(rusage),	KMZ_CREATEZONE },	/* 8 M_ZOMBIE */
	{ 0,		KMZ_MALLOC },		/* 9 M_IFADDR */
	{ M_MBUF,	KMZ_SHAREZONE },		/* 10 M_SOOPTS */
	{ 0,		KMZ_MALLOC },		/* 11 M_SONAME */
	{ MAXPATHLEN,	KMZ_CREATEZONE },		/* 12 M_NAMEI */
	{ 0,		KMZ_MALLOC },		/* 13 M_GPROF */
	{ 0,		KMZ_MALLOC },		/* 14 M_IOCTLOPS */
	{ 0,		KMZ_MALLOC },		/* 15 M_MAPMEM */
	{ SOS(ucred),	KMZ_CREATEZONE },	/* 16 M_CRED */
	{ SOS(pgrp),	KMZ_CREATEZONE },	/* 17 M_PGRP */
	{ SOS(session),	KMZ_CREATEZONE },	/* 18 M_SESSION */