Exemple #1
0
// set function for grid damping
void BodyForce::SetGridDampingFunction(char *bcFunction,bool gridDamp)
{
	if(bcFunction==NULL)
		ThrowSAXException("Grid or particle damping function of time is missing");
	if(strlen(bcFunction)==0)
		ThrowSAXException("Grid or particle damping function of time is missing");
	if((gridDamp && gridfunction!=NULL) || (!gridDamp && pgridfunction!=NULL))
		ThrowSAXException("Duplicate grid or particle damping function of time");
	
	// create variable
	if(gTimeArray[0]==NULL)
	{	gTimeArray[0]=new RVar("t",&varTime);
	}
	
	// create the function and check it
    if(gridDamp)
	{   gridfunction=new ROperation(bcFunction,1,gTimeArray);
        if(gridfunction->HasError())
            ThrowSAXException("Grid damping function of time is not valid");
    }
    else
	{   pgridfunction=new ROperation(bcFunction,1,gTimeArray);
        if(pgridfunction->HasError())
            ThrowSAXException("Particle damping function of time is not valid");
    }
}
Exemple #2
0
// set target function for feedback damping
void BodyForce::SetTargetFunction(char *bcFunction,bool gridDamp)
{   
	if(bcFunction==NULL)
		ThrowSAXException("Target energy function of time is missing");
	if(strlen(bcFunction)==0)
		ThrowSAXException("Target energy function of time is missing");
	if((gridDamp && function!=NULL) || (!gridDamp && pfunction!=NULL))
		ThrowSAXException("Duplicate target energy function of time for grid or particle damping");
	
	// create variable
	if(keTimeArray[0]==NULL)
	{	keTimeArray[0]=new RVar("t",&varTime);
	}

	// create the function and check it
    if(gridDamp)
    {   function=new ROperation(bcFunction,1,keTimeArray);
        if(function->HasError())
            ThrowSAXException("Target energy function of time for grid damping is not valid");
    }
    else
    {   pfunction=new ROperation(bcFunction,1,keTimeArray);
        if(pfunction->HasError())
            ThrowSAXException("Target energy function of time for particle is not valid");
    }
}
// set function if needed
void BoundaryCondition::SetFunction(char *bcFunction)
{
	if(style!=FUNCTION_VALUE) return;
	if(bcFunction==NULL)
		ThrowSAXException("Boundary condition function of time and position is missing");
	if(strlen(bcFunction)==0)
		ThrowSAXException("Boundary condition function of time and position is missing");
	if(function!=NULL)
		ThrowSAXException("Duplicate boundary condition functions of time");
	
	// create variable
	if(varTimeArray[0]==NULL)
	{	varTimeArray[0]=new RVar("t",&varTime);
		varTimeArray[1]=new RVar("x",&varXValue);
		varTimeArray[2]=new RVar("y",&varYValue);
		varTimeArray[3]=new RVar("z",&varZValue);
		varTimeArray[4]=new RVar("q",&varRotValue);
	}
		
	// create the function and check it
	function=new ROperation(bcFunction,5,varTimeArray);
	if(function->HasError())
		ThrowSAXException("Boundary condition function of time and position is not valid");
	
	// keep value, which can option by + or - to tell visualization code the direction of the load
	// value=1.;
}
// Material that allow hardening laws must accept
// the final call and use if supported
// Newly created laws should be added here
void MaterialBase::SetHardeningLaw(char *lawName)
{
    HardeningLawBase *pLaw = NULL;
    int lawID = 0;
    
    // check options
    if(strcmp(lawName,"Linear")==0 || strcmp(lawName,"1")==0)
    {   pLaw = new LinearHardening(this);
        lawID = 1;
    }
    
    else if(strcmp(lawName,"Nonlinear")==0 || strcmp(lawName,"2")==0)
    {   pLaw = new NonlinearHardening(this);
        lawID = 2;
    }
    
    else if(strcmp(lawName,"Nonlinear2")==0 || strcmp(lawName,"6")==0)
    {   pLaw = new Nonlinear2Hardening(this);
        lawID = 6;
    }
    
    else if(strcmp(lawName,"JohnsonCook")==0 || strcmp(lawName,"3")==0)
    {   pLaw = new JohnsonCook(this);
        lawID = 3;
    }
    
    else if(strcmp(lawName,"SCGL")==0 || strcmp(lawName,"4")==0)
    {   pLaw = new SCGLHardening(this);
        lawID = 4;
    }

    else if(strcmp(lawName,"SL")==0 || strcmp(lawName,"5")==0)
    {   pLaw = new SLMaterial(this);
        lawID = 5;
    }
    
    else if(strcmp(lawName,"DDB-PPM")==0 || strcmp(lawName,"7")==0)
    {   pLaw = new DDBHardening(this);
      lawID = 7;
    }
    
    // was it found
    if(pLaw==NULL)
        ThrowSAXException("The hardening law '%s' is not valid",lawName);
    
    // pass on to the material
    if(!AcceptHardeningLaw(pLaw,lawID))
        ThrowSAXException("The hardening law '%s' is not allows by material",lawName);
}
Exemple #5
0
// set maximum alpha (units 1/sec)
void BodyForce::SetMaxAlpha(double theMax,bool gridDamp)
{   if(theMax<=0.)
        ThrowSAXException("Maximum feedback damping alpha must be positive");
    if(gridDamp)
        maxAlpha = theMax;
    else
        maxPAlpha = theMax;
}
// Read material properties
char *Viscoelastic::InputMaterialProperty(char *xName,int &input,double &gScaling)
{
    input=DOUBLE_NUM;
    
    if(strcmp(xName,"G0")==0)
        return((char *)&G0);
    
    else if(strcmp(xName,"K")==0)
        return((char *)&K);
    
    else if(strcmp(xName,"alpha")==0)
        return((char *)&aI);
    
    else if(strcmp(xName,"ntaus")==0)
    {	input=INT_NUM;
        return((char *)&ntaus);
    }
    
    else if(strcmp(xName,"Gk")==0)
    {	if(Gk==NULL)
        {   if(ntaus<=0)
				ThrowSAXException("Gk found before number of taus specified.");
            Gk=new double[ntaus];
        }
        currentGk++;
        if(currentGk>ntaus)
			ThrowSAXException("Too many Gk's given.");
        return((char *)&Gk[currentGk-1]);
    }
    
    else if(strcmp(xName,"tauk")==0)
    {	if(tauk==NULL)
        {   if(ntaus<=0)
				ThrowSAXException("tauk found before number of taus specified.");
            tauk=new double[ntaus];
        }
        currentTauk++;
        if(currentTauk>ntaus)
			ThrowSAXException("Too many tauk's given.");
        return((char *)&tauk[currentTauk-1]);
    }
    
    return(MaterialBase::InputMaterialProperty(xName,input,gScaling));
}
// setting function if needed
void PressureLaw::SetStressFunction(char *bcFunction)
{	
	// NULL or empty is an error
	if(bcFunction==NULL)
		ThrowSAXException("Stress setting function of time is missing");
	if(strlen(bcFunction)==0)
		ThrowSAXException("Stress setting function of time is missing");
	
	// create time variable if needed
	if(plTimeArray[0]==NULL)
	{	plTimeArray[0]=new RVar("t",&varTime);
	}
	
	if(function!=NULL)
		ThrowSAXException("Duplicate stress setting function");
	function=new ROperation(bcFunction,1,plTimeArray);
	if(function->HasError())
		ThrowSAXException("Stress setting function is not valid");
}
Exemple #8
0
// setting initial pressure function if needed
// Fuunction should evaulate to pressure
// For gravity, P0 = rho*g*depth
// throws std::bad_alloc, SAXException()
void TaitLiquid::SetPressureFunction(char *pFunction)
{
	// NULL or empty is an error
	if(pFunction==NULL)
		ThrowSAXException("Initial pressure function of position is missing");
	
	// create time variable if needed
	if(tlTimeArray[0]==NULL)
	{	tlTimeArray[0]=new RVar("x",&xPos);
		tlTimeArray[1]=new RVar("y",&yPos);
		tlTimeArray[2]=new RVar("z",&zPos);
	}
	
	// set the function
	if(function!=NULL)
		ThrowSAXException("Duplicate initial pressure function");
	function=new ROperation(pFunction,3,tlTimeArray);
	if(function->HasError())
		ThrowSAXException("Initial pressure function is not valid");
}
Exemple #9
0
// Implement fraction PIC by setting damping values
void BodyForce::SetFractionPIC(double fract)
{
	if(fract<0. || fract>1.)
		ThrowSAXException("Fraction PIC damping parameter must be from 0 to 1.");
	
	if(fract>0.)
	{	fractionPIC = fract;
		usePICDamping = true;
	}
	else
		usePICDamping = false;
}
Exemple #10
0
// Read material properties
char *Viscoelastic::InputMaterialProperty(char *xName,int &input,double &gScaling)
{
    input=DOUBLE_NUM;
    
    if(strcmp(xName,"G0")==0)
		return UnitsController::ScaledPtr((char *)&G0,gScaling,1.e6);
    
    else if(strcmp(xName,"K")==0)
		return UnitsController::ScaledPtr((char *)&K,gScaling,1.e6);
    
    else if(strcmp(xName,"alpha")==0)
        return((char *)&aI);
    
    else if(strcmp(xName,"ntaus")==0)
    {	input=INT_NUM;
        return((char *)&ntaus);
    }
    
    else if(strcmp(xName,"Gk")==0)
    {	if(Gk==NULL)
        {   if(ntaus<=0)
				ThrowSAXException("Gk found before number of taus specified.");
            Gk=new double[ntaus];
        }
        currentGk++;
        if(currentGk>ntaus)
			ThrowSAXException("Too many Gk's given.");
		return UnitsController::ScaledPtr((char *)&Gk[currentGk-1],gScaling,1.e6);
    }
    
    else if(strcmp(xName,"tauk")==0)
    {	if(tauk==NULL)
        {   if(ntaus<=0)
				ThrowSAXException("tauk found before number of taus specified.");
            tauk=new double[ntaus];
        }
        currentTauk++;
        if(currentTauk>ntaus)
			ThrowSAXException("Too many tauk's given.");
        return((char *)&tauk[currentTauk-1]);
    }
	
	// The follow allow use of MG-EOS law for pressure dependence
	
    else if(strcmp(xName,"pressureLaw")==0)
    {	input=INT_NUM;
        return((char *)&pressureLaw);
    }
    
    else if(strcmp(xName,"gamma0")==0)
    {	input=DOUBLE_NUM;
        return((char *)&gamma0);
    }
    
    else if(strcmp(xName,"C0")==0)
    {	input=DOUBLE_NUM;
        return UnitsController::ScaledPtr((char *)&C0,gScaling,1.e3);
    }
    
    else if(strcmp(xName,"S1")==0)
    {	input=DOUBLE_NUM;
        return((char *)&S1);
    }
	
    else if(strcmp(xName,"S2")==0)
    {	input=DOUBLE_NUM;
        return((char *)&S2);
    }
	
    else if(strcmp(xName,"S3")==0)
    {	input=DOUBLE_NUM;
        return((char *)&S3);
    }

    
    return(MaterialBase::InputMaterialProperty(xName,input,gScaling));
}