void ConvDiffAnisotropic2DLaw::CalculateMaterialResponseCauchy (Parameters& rValues)
	{
		// get some references
		const Properties& props = rValues.GetMaterialProperties();
		Vector& strainVector = rValues.GetStrainVector();
		Vector& stressVector = rValues.GetStressVector();
		Matrix& constitutiveMatrix = rValues.GetConstitutiveMatrix();
		Flags& Options = rValues.GetOptions();
		bool compute_constitutive_tensor = Options.Is(COMPUTE_CONSTITUTIVE_TENSOR);
		bool compute_stress = Options.Is(COMPUTE_STRESS) || compute_constitutive_tensor;

		SizeType size = GetStrainSize();
		if (compute_stress)
			if (stressVector.size() != size)
				stressVector.resize(size, false);
		if (compute_constitutive_tensor)
			if (constitutiveMatrix.size1() != size || constitutiveMatrix.size2() != size)
				constitutiveMatrix.resize(size, size, false);

		if (compute_stress)
		{
			CalculateStress(props, strainVector, stressVector);
		}
		
		if (compute_constitutive_tensor)
		{
			CalculateConstitutiveMatrix(props, strainVector, stressVector, constitutiveMatrix);
		}
	}
    void ConvDiffInterface2DLaw::CalculateMaterialResponseCauchy (Parameters& rValues)
    {
        const Properties& props = rValues.GetMaterialProperties();
		Vector& strainVector = rValues.GetStrainVector();
		Vector& stressVector = rValues.GetStressVector();
		Matrix& constitutiveMatrix = rValues.GetConstitutiveMatrix();
		Flags& Options = rValues.GetOptions();
		bool compute_constitutive_tensor = Options.Is(COMPUTE_CONSTITUTIVE_TENSOR);
		bool compute_stress = Options.Is(COMPUTE_STRESS) || compute_constitutive_tensor;

		SizeType size = GetStrainSize();

		if(compute_stress) 
			if(stressVector.size() != size)
				stressVector.resize(size, false);
		if(compute_constitutive_tensor)
			if(constitutiveMatrix.size1() != size || constitutiveMatrix.size2() != size)
				constitutiveMatrix.resize(size, size, false);

		CalculationData data;
				
		InitializeCalculationData( props, rValues.GetElementGeometry(), strainVector, data );

		std::stringstream ss;
		//std::cout << "CalculateMaterialResponseCauchy -  strainVector = " << strainVector << std::endl;
		//std::cout << "CalculateMaterialResponseCauchy -  constitutiveMatrix = " << constitutiveMatrix << std::endl;
		
		if (data.ExpCurveTypeFlag)
		{
			CalculateElasticStressVector(data, strainVector);
			//std::cout << "CalculateMaterialResponseCauchy -  ElasticStressVector = " << data.ElasticStressVector << std::endl;
			CalculateEquivalentMeasure(data);
			UpdateDamage(data);
			CalculateContactConductivity(data);
		}
		else
		{
			CalculateEffectiveOpening(data);
			UpdateDamage(data);
			CalculateContactConductivity(data);
		}

		mD1 = data.D1; // Update the mK1 to the current value
		
		if( compute_stress )
		{
			CalculateStress(data, strainVector, stressVector);
		}
		//std::cout << "CalculateMaterialResponseCauchy -  CalculateStress = " << stressVector << std::endl;

		if( compute_constitutive_tensor )
		{
			CalculateConstitutiveMatrix( data, strainVector, stressVector, constitutiveMatrix );
		}

		std::cout << ss.str();
    }
Exemple #3
0
    void ScalarDamageInterface2DLaw::CalculateMaterialResponseCauchy (Parameters& rValues)
    {
        const Properties& props = rValues.GetMaterialProperties();
		const Vector& strainVector = rValues.GetStrainVector();
		Vector& stressVector = rValues.GetStressVector();
		Matrix& constitutiveMatrix = rValues.GetConstitutiveMatrix();
		Flags& Options = rValues.GetOptions();
		bool compute_constitutive_tensor = Options.Is(COMPUTE_CONSTITUTIVE_TENSOR);
		bool compute_stress = Options.Is(COMPUTE_STRESS) || compute_constitutive_tensor;

#ifdef INTERF_DAM_2D_IMPLEX
		this->m_strain = rValues.GetStrainVector();
#endif // INTERF_DAM_2D_IMPLEX

		SizeType size = GetStrainSize();
		if(compute_stress) 
			if(stressVector.size() != size)
				stressVector.resize(size, false);
		if(compute_constitutive_tensor)
			if(constitutiveMatrix.size1() != size || constitutiveMatrix.size2() != size)
				constitutiveMatrix.resize(size, size, false);

		CalculationData data;
		InitializeCalculationData( props, rValues.GetElementGeometry(), strainVector, rValues.GetProcessInfo(), data );
		CalculateElasticStressVector( data, strainVector );

#ifdef INTERF_DAM_2D_IMPLEX

		double time_factor = 0.0;
		if(m_dTime_n_converged>0.0) time_factor = data.dTime/m_dTime_n_converged;
		m_dTime_n = data.dTime;
		mK1 = mK1_converged + time_factor * (mK1_converged-mK1_converged_old);
		mK2 = mK2_converged + time_factor * (mK2_converged-mK2_converged_old);
		if(mK1 > 0.0)
		{
			data.D1 = 1.0 - data.Ft/(mK1+data.Ft) * std::exp( -data.Ft/(data.GI*data.Kn) * mK1 );
			data.D1 = std::max( std::min( data.D1, 1.0 ), 0.0 );
		}
		if(mK2 > 0.0)
		{
			data.D2 = 1.0 - data.C0/(mK2+data.C0) * std::exp( -data.C0/data.GII/data.Kt * mK2 );
			data.D2 = std::max( std::min( data.D2, 1.0 ), 0.0 );
		}
#ifdef USE_AS_BRICK_INTERFACE
		data.D2 = 0.0;
		if(data.D1 > 0.99)
			data.D2 = 1.0;
#endif // USE_AS_BRICK_INTERFACE
#else

		CalculateEquivalentMeasure( data );
		UpdateDamage( data );

#endif // INTERF_DAM_2D_IMPLEX

		mD1 = data.D1;
		mD2 = data.D2;
		
		if( compute_stress )
			CalculateStress( data, stressVector );

		//**********************************************
		double sig_n = stressVector(1);
		double sig_t = std::abs(stressVector(0));
		double C0_d = (1.0 - mD2)*data.C0;
		mYieldValue = sig_n*data.Fs + sig_t - C0_d;
		//**********************************************
		
		if( compute_constitutive_tensor )
		{
			if(data.ForceSecant) {
				constitutiveMatrix.clear();
				constitutiveMatrix(0,0) = data.Kt*(1.0-mD2);
				constitutiveMatrix(1,1) = data.Kn;
				if(stressVector(1) > 0.0) {
					constitutiveMatrix(1,1) *= (1.0-mD1);
				}
			}
			else {
				CalculateConstitutiveMatrix( data, strainVector, stressVector, constitutiveMatrix );
			}
		}
    }
void  HyperElasticUP3DLaw::CalculateMaterialResponsePK2 (Parameters& rValues)
{

    //-----------------------------//

    //a.-Check if the constitutive parameters are passed correctly to the law calculation
    CheckParameters(rValues);

    //b.- Get Values to compute the constitutive law:
    Flags &Options=rValues.GetOptions();

    const Properties& MaterialProperties  = rValues.GetMaterialProperties();
    const Matrix&   DeformationGradientF  = rValues.GetDeformationGradientF();
    const double&   DeterminantF          = rValues.GetDeterminantF();

    const GeometryType&  DomainGeometry   = rValues.GetElementGeometry ();
    const Vector&        ShapeFunctions   = rValues.GetShapeFunctionsValues ();

    Vector& StrainVector                  = rValues.GetStrainVector();
    Vector& StressVector                  = rValues.GetStressVector();
    Matrix& ConstitutiveMatrix            = rValues.GetConstitutiveMatrix();

    //-----------------------------//

    //0.- Initialize parameters
    MaterialResponseVariables ElasticVariables;
    ElasticVariables.Identity = identity_matrix<double> ( 3 );

    ElasticVariables.SetElementGeometry(DomainGeometry);
    ElasticVariables.SetShapeFunctionsValues(ShapeFunctions);

    // Initialize Splited Parts: Isochoric and Volumetric stresses and constitutive tensors
    double voigtsize = StressVector.size();
    VectorSplit SplitStressVector;
    MatrixSplit SplitConstitutiveMatrix;

    //1.- Lame constants
    const double& YoungModulus          = MaterialProperties[YOUNG_MODULUS];
    const double& PoissonCoefficient    = MaterialProperties[POISSON_RATIO];

    ElasticVariables.LameLambda      = (YoungModulus*PoissonCoefficient)/((1+PoissonCoefficient)*(1-2*PoissonCoefficient));
    ElasticVariables.LameMu          =  YoungModulus/(2*(1+PoissonCoefficient));

    //2.- Thermal constants
    if( MaterialProperties.Has(THERMAL_EXPANSION_COEFFICIENT) )
      ElasticVariables.ThermalExpansionCoefficient = MaterialProperties[THERMAL_EXPANSION_COEFFICIENT];
    else
      ElasticVariables.ThermalExpansionCoefficient = 0;

    if( MaterialProperties.Has(REFERENCE_TEMPERATURE) )
      ElasticVariables.ReferenceTemperature = MaterialProperties[REFERENCE_TEMPERATURE];
    else
      ElasticVariables.ReferenceTemperature = 0;

    //3.-DeformationGradient Tensor 3D
    ElasticVariables.DeformationGradientF = DeformationGradientF;
    ElasticVariables.DeformationGradientF = Transform2DTo3D( ElasticVariables.DeformationGradientF );

    //4.-Determinant of the Total Deformation Gradient
    ElasticVariables.DeterminantF = DeterminantF;

    //5.-Right Cauchy Green tensor C
    Matrix RightCauchyGreen = prod(trans(ElasticVariables.DeformationGradientF),ElasticVariables.DeformationGradientF);

    //6.-Inverse of the Right Cauchy-Green tensor C: (stored in the CauchyGreenMatrix)
    ElasticVariables.traceCG = 0;
    ElasticVariables.CauchyGreenMatrix( 3, 3 );
    MathUtils<double>::InvertMatrix( RightCauchyGreen, ElasticVariables.CauchyGreenMatrix, ElasticVariables.traceCG);


    //8.-Green-Lagrange Strain:
    if(Options.Is( ConstitutiveLaw::COMPUTE_STRAIN ))
      {
	this->CalculateGreenLagrangeStrain(RightCauchyGreen, StrainVector);
      }
    
    //9.-Calculate Total PK2 stress
    SplitStressVector.Isochoric = ZeroVector(voigtsize);

    if( Options.Is(ConstitutiveLaw::COMPUTE_STRESS ) || Options.Is(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR ) )
      this->CalculateIsochoricStress( ElasticVariables, StressMeasure_PK2, SplitStressVector.Isochoric );

    Vector IsochoricStressVector = SplitStressVector.Isochoric;

    if( Options.Is( ConstitutiveLaw::COMPUTE_STRESS ) )
      {

	SplitStressVector.Volumetric = ZeroVector(voigtsize);

	this->CalculateVolumetricStress ( ElasticVariables, SplitStressVector.Volumetric );

	//PK2 Stress:
	StressVector = SplitStressVector.Isochoric + SplitStressVector.Volumetric;
	
	if( Options.Is(ConstitutiveLaw::ISOCHORIC_TENSOR_ONLY ) )
	  {
	    StressVector = SplitStressVector.Isochoric;
	  }
	else if( Options.Is(ConstitutiveLaw::VOLUMETRIC_TENSOR_ONLY ) )
	  {
	    StressVector = SplitStressVector.Volumetric;
	  }
	
      }

    //10.-Calculate Constitutive Matrix related to Total PK2 stress    
    if( Options.Is( ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR ) )
      {

	//initialize constitutive tensors
	ConstitutiveMatrix.clear();
	SplitConstitutiveMatrix.Isochoric  = ConstitutiveMatrix;
	SplitConstitutiveMatrix.Volumetric = ConstitutiveMatrix;
	
	Matrix IsoStressMatrix = MathUtils<double>::StressVectorToTensor( IsochoricStressVector );

	this->CalculateIsochoricConstitutiveMatrix ( ElasticVariables, IsoStressMatrix, SplitConstitutiveMatrix.Isochoric );

	this->CalculateVolumetricConstitutiveMatrix ( ElasticVariables, SplitConstitutiveMatrix.Volumetric );

	//if( Options.Is(ConstitutiveLaw::TOTAL_TENSOR ) )
	ConstitutiveMatrix = SplitConstitutiveMatrix.Isochoric + SplitConstitutiveMatrix.Volumetric;

	if( Options.Is(ConstitutiveLaw::ISOCHORIC_TENSOR_ONLY ) )
	  {
	    ConstitutiveMatrix = SplitConstitutiveMatrix.Isochoric;
	  }
	else if( Options.Is(ConstitutiveLaw::VOLUMETRIC_TENSOR_ONLY ) )
	  {
	    ConstitutiveMatrix = SplitConstitutiveMatrix.Volumetric;
	  }
	
      }
    

    // std::cout<<" Constitutive "<<ConstitutiveMatrix<<std::endl;
    // std::cout<<" Stress "<<StressVector<<std::endl;

    //-----------------------------//
}
void LinearElastic3DLaw::CalculateMaterialResponseKirchhoff (Parameters& rValues)
{

    //-----------------------------//

    //a.-Check if the constitutive parameters are passed correctly to the law calculation
    //CheckParameters(rValues);

    //b.- Get Values to compute the constitutive law:
    Flags &Options=rValues.GetOptions();

    const Properties& MaterialProperties  = rValues.GetMaterialProperties();

    Vector& StrainVector                  = rValues.GetStrainVector();
    Vector& StressVector                  = rValues.GetStressVector();

    //-----------------------------//

    //1.- Lame constants
    const double& YoungModulus          = MaterialProperties[YOUNG_MODULUS];
    const double& PoissonCoefficient    = MaterialProperties[POISSON_RATIO];

    // //1.1- Thermal constants
    // double ThermalExpansionCoefficient = 0;
    // if( MaterialProperties.Has(THERMAL_EXPANSION_COEFFICIENT) )
    //   ThermalExpansionCoefficient = MaterialProperties[THERMAL_EXPANSION_COEFFICIENT];

    // double ReferenceTemperature = 0;
    // if( MaterialProperties.Has(REFERENCE_TEMPERATURE) )
    //   ReferenceTemperature = MaterialProperties[REFERENCE_TEMPERATURE];


    if(Options.Is( ConstitutiveLaw::COMPUTE_STRAIN )) //large strains
      {
	//1.-Compute total deformation gradient
        const Matrix& DeformationGradientF      = rValues.GetDeformationGradientF();

        //2.-Left Cauchy-Green tensor b
        Matrix LeftCauchyGreenMatrix = prod(DeformationGradientF,trans(DeformationGradientF));

        //3.-Almansi Strain:

        //e= 0.5*(1-invFT*invF)
        this->CalculateAlmansiStrain(LeftCauchyGreenMatrix,StrainVector);

	
	//LARGE STRAINS OBJECTIVE MESURE KIRCHHOFF MATERIAL:

	// Kirchhoff model is set with S = CE
	this->CalculateMaterialResponsePK2 (rValues);

	//1.- Obtain parameters
	const double& DeterminantF         = rValues.GetDeterminantF();

	//2.-Almansi Strain:
	// if(Options.Is( ConstitutiveLaw::COMPUTE_STRAIN ))
	//   {
	//     TransformStrains (StrainVector, DeformationGradientF, StrainMeasure_GreenLagrange, StrainMeasure_Almansi);
	//   }

	//3.-Calculate Total Kirchhoff stress
	if( Options.Is( ConstitutiveLaw::COMPUTE_STRESS ) )
	  {
	    TransformStresses(StressVector, DeformationGradientF, DeterminantF, StressMeasure_PK2, StressMeasure_Kirchhoff);
	  }

	// COMMENTED BECAUSE THE CONVERGENCE IS NOT IMPROVED AND IS TIME CONSUMING:
	//4.-Calculate Cauchy constitutive tensor
	// if( Options.Is( ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR ) )
	//   {
	//     Matrix& ConstitutiveMatrix  = rValues.GetConstitutiveMatrix();
	//     PushForwardConstitutiveMatrix(ConstitutiveMatrix, DeformationGradientF);
	//   }


	if( Options.Is( ConstitutiveLaw::COMPUTE_STRAIN_ENERGY ) )
	{
	  mStrainEnergy *= DeterminantF;
	}
      
      }
    else{ //small strains

      //7.-Calculate total Kirchhoff stress

      if( Options.Is( ConstitutiveLaw::COMPUTE_STRESS ) ){
      
	if( Options.Is( ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR ) ){
	
	  Matrix& ConstitutiveMatrix            = rValues.GetConstitutiveMatrix();

	  this->CalculateLinearElasticMatrix( ConstitutiveMatrix, YoungModulus, PoissonCoefficient );

	  this->CalculateStress( StrainVector, ConstitutiveMatrix, StressVector );

	}
	else {
	
	  Matrix ConstitutiveMatrix = ZeroMatrix( StrainVector.size() ,StrainVector.size());
	
	  this->CalculateLinearElasticMatrix( ConstitutiveMatrix, YoungModulus, PoissonCoefficient );
      
	  this->CalculateStress( StrainVector, ConstitutiveMatrix, StressVector );
      
	}
      
      }
      else if(  Options.IsNot( ConstitutiveLaw::COMPUTE_STRESS ) && Options.Is( ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR ) )
	{

	  Matrix& ConstitutiveMatrix            = rValues.GetConstitutiveMatrix();
	  this->CalculateLinearElasticMatrix( ConstitutiveMatrix, YoungModulus, PoissonCoefficient );

	}


      if( Options.Is( ConstitutiveLaw::COMPUTE_STRAIN_ENERGY ) )
	{
     
	  if( Options.IsNot( ConstitutiveLaw::COMPUTE_STRESS ) ){
	    
	    if(Options.Is( ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR )){	    
	      Matrix ConstitutiveMatrix = ZeroMatrix( StrainVector.size(), StrainVector.size());
	      this->CalculateLinearElasticMatrix( ConstitutiveMatrix, YoungModulus, PoissonCoefficient );
	      this->CalculateStress( StrainVector, ConstitutiveMatrix, StressVector );
	    }
	    else{
	      Matrix& ConstitutiveMatrix = rValues.GetConstitutiveMatrix();    
	      this->CalculateStress( StrainVector, ConstitutiveMatrix, StressVector );
	    }    
	    
	    
	  }
     
	  mStrainEnergy = 0.5 * inner_prod(StrainVector,StressVector); //Belytschko Nonlinear Finite Elements pag 226 (5.4.3) : w = 0.5*E:C:E
	}

    }
    
    //std::cout<<" Strain "<<StrainVector<<std::endl;
    //std::cout<<" Stress "<<StressVector<<std::endl;
    //Matrix& ConstitutiveMatrix = rValues.GetConstitutiveMatrix();
    //std::cout<<" Constitutive "<<ConstitutiveMatrix<<std::endl;

}
void  LinearElastic3DLaw::CalculateMaterialResponsePK2 (Parameters& rValues)
{

    //-----------------------------//

    //a.-Check if the constitutive parameters are passed correctly to the law calculation
    //CheckParameters(rValues);

    //b.- Get Values to compute the constitutive law:
    Flags &Options=rValues.GetOptions();
    mStrainEnergy = 0.0; //When it is not calculated, a zero will be returned
    
    const Properties& MaterialProperties  = rValues.GetMaterialProperties();    

    Vector& StrainVector                  = rValues.GetStrainVector();
    Vector& StressVector                  = rValues.GetStressVector();

    //-----------------------------//

    //1.- Lame constants
    const double& YoungModulus          = MaterialProperties[YOUNG_MODULUS];
    const double& PoissonCoefficient    = MaterialProperties[POISSON_RATIO];

    // //1.1- Thermal constants
    // double ThermalExpansionCoefficient = 0;
    // if( MaterialProperties.Has(THERMAL_EXPANSION_COEFFICIENT) )
    //   ThermalExpansionCoefficient = MaterialProperties[THERMAL_EXPANSION_COEFFICIENT];

    // double ReferenceTemperature = 0;
    // if( MaterialProperties.Has(REFERENCE_TEMPERATURE) )
    //   ReferenceTemperature = MaterialProperties[REFERENCE_TEMPERATURE];


    if(Options.Is( ConstitutiveLaw::COMPUTE_STRAIN )) //large strains
    {

        //1.-Compute total deformation gradient
        const Matrix& DeformationGradientF = rValues.GetDeformationGradientF();

        //2.-Right Cauchy-Green tensor C
        Matrix RightCauchyGreen = prod(trans(DeformationGradientF),DeformationGradientF);

        //3.-Green-Lagrange Strain:

        //E= 0.5*(FT*F-1)
        this->CalculateGreenLagrangeStrain(RightCauchyGreen,StrainVector);

    }

    //7.-Calculate Total PK2 stress

    if( Options.Is( ConstitutiveLaw::COMPUTE_STRESS ) )
    {
        if( Options.Is( ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR ) ){

          Matrix& ConstitutiveMatrix            = rValues.GetConstitutiveMatrix();
          this->CalculateLinearElasticMatrix( ConstitutiveMatrix, YoungModulus, PoissonCoefficient );
          this->CalculateStress( StrainVector, ConstitutiveMatrix, StressVector );

        }
        else {

          Matrix ConstitutiveMatrix = ZeroMatrix( StrainVector.size(), StrainVector.size() );
          this->CalculateLinearElasticMatrix( ConstitutiveMatrix, YoungModulus, PoissonCoefficient );
          this->CalculateStress( StrainVector, ConstitutiveMatrix, StressVector );
        }
      
    }
    else if(  Options.IsNot( ConstitutiveLaw::COMPUTE_STRESS ) && Options.Is( ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR ) )
    {

        Matrix& ConstitutiveMatrix            = rValues.GetConstitutiveMatrix();
        this->CalculateLinearElasticMatrix( ConstitutiveMatrix, YoungModulus, PoissonCoefficient );

    }
    
    if( Options.Is( ConstitutiveLaw::COMPUTE_STRAIN_ENERGY ) )
    {

        if( Options.IsNot( ConstitutiveLaw::COMPUTE_STRESS ) )
        {

            if(Options.Is( ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR ))
            {
	      Matrix ConstitutiveMatrix = ZeroMatrix( StrainVector.size(), StrainVector.size() );
               this->CalculateLinearElasticMatrix( ConstitutiveMatrix, YoungModulus, PoissonCoefficient );
               this->CalculateStress( StrainVector, ConstitutiveMatrix, StressVector );
            }
            else
            {
               Matrix& ConstitutiveMatrix = rValues.GetConstitutiveMatrix();
               this->CalculateStress( StrainVector, ConstitutiveMatrix, StressVector );
            }

        }

        mStrainEnergy = 0.5 * inner_prod(StrainVector,StressVector); //Belytschko Nonlinear Finite Elements pag 226 (5.4.3) : w = 0.5*E:C:E
    }

    //std::cout<<" Strain "<<StrainVector<<std::endl;
    //std::cout<<" Stress "<<StressVector<<std::endl;
    //Matrix& ConstitutiveMatrix = rValues.GetConstitutiveMatrix();
    //std::cout<<" Constitutive "<<ConstitutiveMatrix<<std::endl;
}