예제 #1
0
Field TriCubicHermite::scalarGradient( const Particles& aParticles ) const
{
	assert(data->nDim() == 1);
	Field result("n/a","n/a", 2, aParticles.N());
	if ( !allFacesReady ) 
	{
		OutputMessage statusMsg("interp coefficients not defined ", OutputMessage::errorPriority, "(Field) TriCubicHermite::scalarGradient");
		log->logMessage(statusMsg);
		return result;
	}
	
	for ( int i = 0; i < aParticles.N(); ++i )
	{
		xyzVector newGrad = scalarGradient( aParticles.physCoord(i) );
		result.insertVectorToField( i, newGrad );
	}
	return result;
};
예제 #2
0
Field TriCubicHermite::scalarLaplacian( const Particles& aParticles ) const
{
	assert(data->nDim() == 1);
	Field result("n/a","n/a", 1, aParticles.N());
	if ( !allFacesReady ) 
	{
		OutputMessage statusMsg("interp coefficients not defined ", OutputMessage::errorPriority, "(Field) TriCubicHermite::scalarLaplacian");
		log->logMessage(statusMsg);
		return result;
	}
	
	for ( int i = 0; i < aParticles.N(); ++i )
	{
		double newVal = scalarLaplacian( aParticles.physCoord(i) );
		result.insertScalarToField( i, newVal );
	}
	return result;
};
예제 #3
0
Field TriCubicHermite::scalarCurl2D( const Particles& aParticles ) const
{
	assert(data->nDim() == 2);
	Field result("n/a","n/a", 1, aParticles.N());
	return result;
};
예제 #4
0
Field TriCubicHermite::vectorDivergence( const Particles& aParticles ) const
{
	assert(data->nDim() == 2);
	Field result("n/a","n/a", 1, aParticles.N());
	return result;
};
예제 #5
0
파일: Field.cpp 프로젝트: pbosler/lpmCxx
void Field::outputForMatlab( const std::string filename, const Particles& particles ) const 
{
	std::ofstream file( filename.c_str() );
	if ( !file )
	{
		OutputMessage statusMsg("cannot open file.", OutputMessage::errorPriority, "Field::outputForMatlab");
		log->logMessage(statusMsg);
		return;
	}
	
	file << "Field_name = '" << _name << "'; " << std::endl;
	file << "units = '" << _units << "';" <<std::endl;
	
	const int n = particles.N();
	
	file << " x = [ ";
	for ( int i = 0; i < n-1; ++i)
	{
		file << particles.x[i] << " , ";
	}
	file << particles.x[n-1] << " ]; " << std::endl << std::endl;
	
	file << " y = [ ";
	for ( int i = 0; i < n-1; ++i)
	{
		file << particles.y[i] << " , ";
	}
	file << particles.y[n-1] << " ]; " << std::endl << std::endl;
	
	file << " x0 = [ ";
	for ( int i = 0; i < n-1; ++i)
	{
		file << particles.x0[i] << " , ";
	}
	file << particles.x0[n-1] << " ]; " << std::endl << std::endl;
	
	file << " y0 = [ ";
	for ( int i = 0; i < n-1; ++i)
	{
		file << particles.y0[i] << " , ";
	}
	file << particles.y0[n-1] << " ]; " << std::endl << std::endl;

	if ( particles.nDim() == 3 )
	{
		file << " z = [ ";
		for ( int i = 0; i < n-1; ++i)
		{
			file << particles.z[i] << " , ";
		}
		file << particles.z[n-1] << " ]; " << std::endl << std::endl;
		
		file << " z0 = [ ";
		for ( int i = 0; i < n-1; ++i)
		{
			file << particles.z0[i] << " , ";
		}
		file << particles.z0[n-1] << " ]; " << std::endl << std::endl;
	}
	
	if ( _nDim == 1 )
	{
		file << "scalarField = [ " ;
		for ( int i = 0; i < n-1; ++i )
		{
			file << scalar[i] << " , ";
		}
		file << scalar[n-1] << " ]; " << std::endl;
	}
	else
	{
		if ( _nDim == 2)
		{
			file << "vectorField = [ ";
			for ( int i = 0; i < n-1; ++i)
			{
				file << xComp[i] << " , " << yComp[i] << " ; " ;
			}
			file << xComp[n-1] << " , " << yComp[n-1] << " ];" << std::endl;
		}
		else
		{
			file << "vectorField = [ ";
			for ( int i = 0; i < n-1; ++i)
			{
				file << xComp[i] << " , " << yComp[i] << " , " << zComp[i] << " ; " ;
			}
			file << xComp[n-1] << " , " << yComp[n-1] << " , " << zComp[n-1] << " ];" << std::endl;
		}
	}
};