Example #1
0
namespace Electrostatic2Dauxiliaries
{
//static variables
//boost::numeric::ublas::bounded_matrix<double,3,2> Electrostatic2D::msDN_DX;
boost::numeric::ublas::bounded_matrix<double,3,2> msDN_DX = ZeroMatrix(3,2);
#pragma omp threadprivate(msDN_DX)
//boost::numeric::ublas::bounded_matrix<double,2,3> Electrostatic2D::msB;
boost::numeric::ublas::bounded_matrix<double,2,3> msB = ZeroMatrix(2,3);
#pragma omp threadprivate(msB)
//boost::numeric::ublas::bounded_matrix<double,2,2> Electrostatic2D::msD;
boost::numeric::ublas::bounded_matrix<double,2,2> msD = ZeroMatrix(2,2);
#pragma omp threadprivate(msD)

//array_1d<double,3> Electrostatic2D::msN; //dimension = number of nodes
array_1d<double,3> msN = ZeroVector(3); //dimension = number of nodes
#pragma omp threadprivate(msN)
//array_1d<double,3> Electrostatic2D::ms_temp; //dimension = number of nodes
array_1d<double,3> ms_temp = ZeroVector(3); //dimension = number of nodes
#pragma omp threadprivate(ms_temp)
//array_1d<double,3> Electrostatic2D::point_sources; //dimension = number of nodes
array_1d<double,3> point_sources = ZeroVector(3); //dimension = number of nodes
#pragma omp threadprivate(point_sources)

array_1d<double,3> surface_sources = ZeroVector(3); //dimension = number of nodes
#pragma omp threadprivate(surface_sources)
}
Example #2
0
void DruckerPrager::InitializeMaterial( const Properties& props,
                                        const GeometryType& geom, const Vector& ShapeFunctionsValues )
{
    mOldStress.resize( 6 );
    mOldStress = ZeroVector( 6 );
    mCtangent.resize(6, 6);
    mCtangent = ZeroMatrix( 6, 6 );
    mCtangentInv.resize(6, 6);
    mCtangentInv = ZeroMatrix(6, 6);
    mOldStrain.resize( 6 );
    mOldStrain = ZeroVector( 6 );
    mCurrentStrain.resize( 6 );
    mCurrentStrain = ZeroVector( 6 );
//     mCurrentStrainInc.resize( 6 );
//     mCurrentStrainInc = ZeroVector( 6 );
    mCurrentStress.resize( 6 );
    mCurrentStress = ZeroVector( 6 );
    mCurrentPlasticStrains.resize( 6 );
    mCurrentPlasticStrains = ZeroVector( 6 );
    mOldSElasticStrain.resize( 6 );
    mOldSElasticStrain = ZeroVector( 6 );
    mCurrentElasticStrain.resize( 6 );
    mCurrentElasticStrain = ZeroVector( 6 );
    mOldPlasticStrains.resize( 6 );
    mOldPlasticStrains = ZeroVector( 6 );
    mPrestress.resize( 6 );
    mPrestress = ZeroVector( 6 );
    mPrestressFactor = 1.0;

//     mdGamma = 0.0;
    mAlpha = 0.0;
    mOldAlpha = 0.0;
//     mIsYielded = false;
//     mIsApex = false;

    mE = props[YOUNG_MODULUS];
    mNU = props[POISSON_RATIO];
    mCohesion = props[COHESION];
    mHardening = props[ISOTROPIC_HARDENING_MODULUS];

    double tan_phi = tan(( props[INTERNAL_FRICTION_ANGLE] ) * PI / 180 );
    mEta = 3.0 * tan_phi / ( sqrt( 9.0 + 12.0 * tan_phi * tan_phi ) );
    mXi = 3.0 / ( sqrt( 9.0 + 12.0 * tan_phi * tan_phi ) );

    
//     ResetMaterial( props, geom, ShapeFunctionsValues );

//     mG = mE / ( 2.0 * ( 1.0 + mNU ) );
//     mK = mE / ( 3.0 * ( 1.0 - 2.0 * mNU ) );

//     CalculateUnit4thSym3D();

//     CalculateUnit2nd3D();
    
    ResetMaterial( props, geom, ShapeFunctionsValues );

}
void UpdatedLagrangianFluid3Dinc::CalculateMassMatrix(MatrixType& rMassMatrix, ProcessInfo& rCurrentProcessInfo)
{
    KRATOS_TRY

    const double& density = 0.25*(GetGeometry()[0].FastGetSolutionStepValue(DENSITY)+
                                  GetGeometry()[1].FastGetSolutionStepValue(DENSITY) +
                                  GetGeometry()[2].FastGetSolutionStepValue(DENSITY)+
                                  GetGeometry()[3].FastGetSolutionStepValue(DENSITY));
    //lumped
    unsigned int dimension = GetGeometry().WorkingSpaceDimension();
    unsigned int NumberOfNodes = GetGeometry().size();
    unsigned int MatSize = dimension * NumberOfNodes;

    if(rMassMatrix.size1() != MatSize)
        rMassMatrix.resize(MatSize,MatSize,false);

    noalias(rMassMatrix) = ZeroMatrix(MatSize,MatSize);

    double nodal_mass = mA0 * density * 0.25;

    for(unsigned int i=0; i<NumberOfNodes; i++)
    {
        for(unsigned int j=0; j<dimension; j++)
        {
            unsigned int index = i*dimension + j;
            rMassMatrix(index,index) = nodal_mass;
        }
    }

    KRATOS_CATCH("")
}
void Isotropic_Rankine_Yield_Function::GetValue(Matrix& Result)
{
    m_inv_DeltaF.resize(3,3, false);
    noalias(m_inv_DeltaF) = ZeroMatrix(3,3);
    switch(mState)
    {
    case Plane_Stress:
    {
        KRATOS_THROW_ERROR(std::logic_error,  "PLANE STRESS NOT IMPLEMENTED" , "");
        break;
    }
    case Plane_Strain:
    {
        m_inv_DeltaF(0,0)    = Result(0,0);
        m_inv_DeltaF(0,1)    = Result(0,1);
        m_inv_DeltaF(1,0)    = Result(1,0);
        m_inv_DeltaF(1,1)    = Result(1,1);
        m_inv_DeltaF(2,2)    = 1.00;
        break;
    }

    case Tri_D:
    {
        noalias(m_inv_DeltaF) = Result;
        break;
    }

    }
}
Example #5
0
//************************************************************************************
//************************************************************************************
void ThermalFace2D::CalculateAll(MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, ProcessInfo& rCurrentProcessInfo, bool CalculateStiffnessMatrixFlag, bool CalculateResidualVectorFlag)
{
    KRATOS_TRY

    unsigned int number_of_nodes = GetGeometry().size();

    //resizing as needed the LHS
    unsigned int MatSize=number_of_nodes;

    ConvectionDiffusionSettings::Pointer my_settings = rCurrentProcessInfo.GetValue(CONVECTION_DIFFUSION_SETTINGS);

    const Variable<double>& rUnknownVar = my_settings->GetUnknownVariable();

    const Variable<double>& rSurfaceSourceVar = my_settings->GetSurfaceSourceVariable();

    //calculate lenght
    double x21 = GetGeometry()[1].X() - GetGeometry()[0].X();
    double y21 = GetGeometry()[1].Y() - GetGeometry()[0].Y();
    double lenght = x21*x21 + y21*y21;
    lenght = sqrt(lenght);

    const Properties& ConstProp = GetProperties();
    const double& ambient_temperature = ConstProp[AMBIENT_TEMPERATURE];
    double StefenBoltzmann = 5.67e-8;
    double emissivity = ConstProp[EMISSIVITY];
    double convection_coefficient = ConstProp[CONVECTION_COEFFICIENT];

    const double& T0 = GetGeometry()[0].FastGetSolutionStepValue(rUnknownVar);
    const double& T1 = GetGeometry()[1].FastGetSolutionStepValue(rUnknownVar);

    const double& q0 =GetGeometry()[0].FastGetSolutionStepValue(rSurfaceSourceVar);
    const double& q1 =GetGeometry()[1].FastGetSolutionStepValue(rSurfaceSourceVar);

    if (CalculateStiffnessMatrixFlag == true) //calculation of the matrix is required
    {
        if(rLeftHandSideMatrix.size1() != MatSize )
            rLeftHandSideMatrix.resize(MatSize,MatSize,false);
        noalias(rLeftHandSideMatrix) = ZeroMatrix(MatSize,MatSize);

        rLeftHandSideMatrix(0,0) = ( convection_coefficient + emissivity*StefenBoltzmann*4.0*pow(T0,3)  )* 0.5 * lenght;
        rLeftHandSideMatrix(1,1) = ( convection_coefficient + emissivity*StefenBoltzmann*4.0*pow(T1,3)  )* 0.5 * lenght;
    }

    //resizing as needed the RHS
    double aux = pow(ambient_temperature,4);
    if (CalculateResidualVectorFlag == true) //calculation of the matrix is required
    {
        if(rRightHandSideVector.size() != MatSize )
            rRightHandSideVector.resize(MatSize,false);

        rRightHandSideVector[0] =  q0 - emissivity*StefenBoltzmann*(pow(T0,4) - aux)  -  convection_coefficient * ( T0 - ambient_temperature);

        rRightHandSideVector[1] =  q1   - emissivity*StefenBoltzmann*(pow(T1,4) - aux) -  convection_coefficient * ( T1 - ambient_temperature);

        rRightHandSideVector *= 0.5*lenght;

    }

    KRATOS_CATCH("")
}
Example #6
0
Matrix DruckerPrager::InverseC(Matrix& InvC) {
    if (InvC.size1() != 6 || InvC.size2() != 6)
        InvC.resize(6, 6);

    noalias(InvC) = ZeroMatrix(6, 6);

    double lambda = mNU * mE / ((1
                    + mNU) * (1 - 2 * mNU));
    double mu = mE / (2 * (1 + mNU));

    double a = (4 * mu * mu + 4 * mu * lambda) / (8 * mu * mu * mu + 12 * mu
               * mu * lambda);
    double b = -(2 * mu * lambda) / (8 * mu * mu * mu + 12 * mu * mu * lambda);

    InvC(0, 0) = a;
    InvC(0, 1) = b;
    InvC(0, 2) = b;
    InvC(1, 0) = b;
    InvC(1, 1) = a;
    InvC(1, 2) = b;
    InvC(2, 0) = b;
    InvC(2, 1) = b;
    InvC(2, 2) = a;
    InvC(3, 3) = 1 / (2 * mu);
    InvC(4, 4) = 1 / (2 * mu);
    InvC(5, 5) = 1 / (2 * mu);
    return InvC;
}
Example #7
0
//************************************************************************************
void MeshlessBaseElement::Hessian(Matrix& Hessian, const Matrix DN_De)
{
	const unsigned int number_of_points = GetGeometry().size();
	const unsigned int working_space_dimension = 3;// GetValue(SHAPE_FUNCTION_LOCAL_DERIVATIVES).size2();// GetGeometry().WorkingSpaceDimension();

	Hessian.resize(working_space_dimension, working_space_dimension);
	Hessian = ZeroMatrix(working_space_dimension, working_space_dimension);

	for (size_t k = 0; k<number_of_points; k++)
	{
		const array_1d<double, 3> coords = GetGeometry()[k].Coordinates();

		Hessian(0, 0) += DN_De(k, 2)*coords[0];
		Hessian(0, 1) += DN_De(k, 3)*coords[0];
		Hessian(0, 2) += DN_De(k, 4)*coords[0];

		Hessian(1, 0) += DN_De(k, 2)*coords[1];
		Hessian(1, 1) += DN_De(k, 3)*coords[1];
		Hessian(1, 2) += DN_De(k, 4)*coords[1];

		Hessian(2, 0) += DN_De(k, 2)*coords[2];
		Hessian(2, 1) += DN_De(k, 3)*coords[2];
		Hessian(2, 2) += DN_De(k, 4)*coords[2];
	}
}
void Tresca_Yield_Function::CalculateEquivalentUniaxialStressViaPrincipalStress(
    const Vector& StressVector,double& Result)
{

    double crit      = 1E-10;
    double zero      = 1E-10;
    double max       = 0.00;
    unsigned int dim = 3;

    Matrix StressTensor     = ZeroMatrix(dim,dim);
    Vector PrincipalStress  = ZeroVector(dim);
    Vector Aux_Vector       = ZeroVector(dim);

    this->State_Tensor(StressVector,StressTensor);
    this->Comprobate_State_Tensor(StressTensor, StressVector); // funcion definida en clase base;
    PrincipalStress         = SD_MathUtils<double>::EigenValues(StressTensor,crit, zero);

    Aux_Vector(0) =  fabs(PrincipalStress(0)-PrincipalStress(1));
    Aux_Vector(1) =  fabs(PrincipalStress(0)-PrincipalStress(2));
    Aux_Vector(2) =  fabs(PrincipalStress(1)-PrincipalStress(2));

    max = (*std::max_element(Aux_Vector.begin(),Aux_Vector.end()));

    Result = 0.50*max; // - msigma_max;
    //KRATOS_WATCH(Result)
}
Example #9
0
void BeamElement::CalculateMassMatrix(MatrixType& rMassMatrix, ProcessInfo& rCurrentProcessInfo)
{

    KRATOS_TRY
    unsigned int dimension = GetGeometry().WorkingSpaceDimension();
    unsigned int NumberOfNodes = GetGeometry().size();
    unsigned int MatSize = dimension * NumberOfNodes;
    if(rMassMatrix.size1() != MatSize)
        rMassMatrix.resize(MatSize,MatSize,false);

    rMassMatrix = ZeroMatrix(MatSize,MatSize);
    //const double& mlength = GetGeometry().Length();

    double TotalMass = mArea*mlength*GetProperties()[DENSITY];

    Vector LumpFact;
    LumpFact = GetGeometry().LumpingFactors(LumpFact);

    for(unsigned int i=0; i<NumberOfNodes; i++)
    {
        double temp = LumpFact[i]*TotalMass;
        for(unsigned int j=0; j<dimension; j++)
        {
            unsigned int index = i*dimension + j;
            rMassMatrix(index,index) = temp;
            if (index==3 || index==4 || index==5)
                rMassMatrix(index,index) = 0.00;

        }
    }
    KRATOS_CATCH("")
}
 void BeamPointPressureCondition::InitializeSystemMatrices( MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector) {
     
       rLeftHandSideMatrix.resize( 6, 6, false );
       noalias( rLeftHandSideMatrix ) = ZeroMatrix( 6, 6 ); //resetting LHS
       rRightHandSideVector.resize( 6, false );
       rRightHandSideVector = ZeroVector( 6 ); //resetting RHS
 }
Example #11
0
void Scale3D(float sx, float sy, float sz, Matx4x4 A)
{
  ZeroMatrix(A);
  A[0][0]=sx;
  A[1][1]=sy;
  A[2][2]=sz;
  A[3][3]=1.0;
}
void TrescaExplicitFlowRule::CalculatePlasticPotentialDerivatives(const Vector& rStressVector, Vector& rFirstDerivative, Matrix& rSecondDerivative)
{
     //double YieldStress = mpYieldCriterion->GetHardeningLaw().GetProperties()[YIELD_STRESS];
     rFirstDerivative = ZeroVector(1);
     rSecondDerivative = ZeroMatrix(1,1);
     return;

}
Example #13
0
Matrix *Matrix::IdentityMatrix(int iRows, int iCols)
{
	Matrix *matrix = ZeroMatrix(iRows, iCols);
	for (int i = 0; i < std::min(iRows, iCols); i++)
	{
		(*matrix)(i,i) = 1;
	}
	return matrix;
}
Example #14
0
//***********************************************************************************
//***********************************************************************************
void LineForce::CalculateLocalSystem( MatrixType& rLeftHandSideMatrix,
                                        VectorType& rRightHandSideVector,
                                        ProcessInfo& rCurrentProcessInfo )
{
    const unsigned int number_of_nodes = GetGeometry().size();
    const unsigned int dim = GetGeometry().WorkingSpaceDimension();
    rLeftHandSideMatrix = ZeroMatrix( dim * number_of_nodes, dim * number_of_nodes );
    CalculateRightHandSide( rRightHandSideVector, rCurrentProcessInfo);
}
Matrix SlaveContactFace3DNewmark::TangentialVectors_inOrigin( const GeometryType::CoordinatesArrayType& rPoint )
{
    //setting up result matrix
    Matrix T = ZeroMatrix( 2, 3 );
    //shape function gradients
    Matrix DN = ZeroMatrix( this->GetGeometry().PointsNumber(),2);
    this->GetGeometry().ShapeFunctionsLocalGradients( DN, rPoint );
    //calculating tangential vectors
    for( unsigned int n=0; n<this->GetGeometry().PointsNumber(); n++ )
    {
        T(0,0) += this->GetGeometry().GetPoint(n).X0()*DN(n,0);
        T(0,1) += this->GetGeometry().GetPoint(n).Y0()*DN(n,0);
        T(0,2) += this->GetGeometry().GetPoint(n).Z0()*DN(n,0);
        T(1,0) += this->GetGeometry().GetPoint(n).X0()*DN(n,1);
        T(1,1) += this->GetGeometry().GetPoint(n).Y0()*DN(n,1);
        T(1,2) += this->GetGeometry().GetPoint(n).Z0()*DN(n,1);
    }
    return( T );
}
Example #16
0
void Translate3D(float tx, float ty, float tz, Matx4x4 A)
{
  int i;

  ZeroMatrix(A);
  for(i=0; i<4; i++)
    A[i][i]=1.0;
  A[0][3]=-tx;
  A[1][3]=-ty;
  A[2][3]=-tz;
}
void Tresca_Yield_Function::CalculateDerivateFluencyCriteria(const Vector& StressVector, Vector& DerivateFluencyCriteria)
{
    Second_Order_Tensor a;
    Vector C = ZeroVector(3);
    DerivateFluencyCriteria = ZeroVector(6);

    double tetha_Lode = 0.00;
    Vector I          = ZeroVector(3);
    Vector J          = ZeroVector(3);
    Vector J_des      = ZeroVector(3);

    Matrix StressTensor     = ZeroMatrix(3,3);
    Vector PrincipalStress  = ZeroVector(3);


    this->State_Tensor(StressVector,StressTensor);
    this->Comprobate_State_Tensor(StressTensor, StressVector); // funcion definida en clase base;
    Tensor_Utils<double>::TensorialInvariants(StressTensor, I, J, J_des);

    if (J_des(1)==0.00 && J_des(2)==0.00)
    {
        tetha_Lode = PI/2.00;
    }
    else
    {
        tetha_Lode = -(3.00*sqrt(3.00)*J_des(2))/(2.00*pow(J_des(1), 1.50));
        if(fabs(tetha_Lode) > 1.00)
        {
            tetha_Lode = 1.00;
        }
        tetha_Lode = asin(tetha_Lode)/3.00;
    }

    if(fabs((fabs(tetha_Lode) - 0.523599)) < 1E-5)  // Angulo de  +-30.00
    {
        C(0) = 0.00;
        C(1) = sqrt(3.00);
        C(2) = 0.00;
    }
    else
    {
        C(0) = 0.00;
        C(1) = 2.00*cos(tetha_Lode)*(1.00 + tan(tetha_Lode)*tan(3.00*tetha_Lode));
        C(2) = sqrt(3.00)*sin(tetha_Lode)/(J_des(1)*cos(3.00*tetha_Lode));
    }
    this->CalculateVectorFlowDerivate(StressVector, a);
    for(unsigned  int i=0; i<3; i++)
    {
        noalias(DerivateFluencyCriteria) = DerivateFluencyCriteria + a(i)*C(i);
    }

}
Example #18
0
/**
 * Memory allocation based on the total number of elements. \n
 * Memory is aligned by the SSE_ALIGNMENT and all elements are zeroed.
 */
void TBaseLongMatrix::AllocateMemory(){
    /* No memory allocated before this function*/

    pMatrixData = (long *) memalign(SSE_ALIGNMENT,pTotalAllocatedElementCount * sizeof (long));
    
    if (!pMatrixData) {
        fprintf(stderr,Matrix_ERR_FMT_NotEnoughMemory, "TBaseLongMatrix");
        throw bad_alloc();   
    }    

    ZeroMatrix();
    
}// end of AllocateMemory
void _SPR_StrainRate_AssembleSolveLocalPatchs( void* sprVar ) {
   SPR_StrainRate*    self = (SPR_StrainRate*)sprVar;
   OperatorFeVariable*        rawField = self->rawField;
   BoundaryNodesInfo* bninfo = self->bninfo;
   Index              dofThatExist = rawField->fieldComponentCount;
   Index              orderOfInterpolation = self->orderOfInterpolation;
   Index              dof_I, nLocalNodes, node_I;
   double             **AMatrix; /* holds the AMatrix */     
   double             **bVector; /* holds bVec for each dof */
   double             *patchCoeff;
   
   /* Allocate memory to AMatrix and bVectors */
   AMatrix = Memory_Alloc_2DArray( double, orderOfInterpolation, orderOfInterpolation, (Name)"A matrix"  );
   /* multiple bVectors are needed for each dof */
   bVector = Memory_Alloc_2DArray( double, dofThatExist, orderOfInterpolation, (Name)"b Vector * dof"  );
   patchCoeff = Memory_Alloc_Array( double, orderOfInterpolation * dofThatExist, "tmp coefficient array" );
   nLocalNodes = FeMesh_GetNodeLocalSize( self->rawField->feMesh );

   /* loop through patchable nodes assembling AMatrix and bVectors and solving for patch coefficients */
   for( node_I = 0 ; node_I < nLocalNodes ; node_I++ ) {
      if( bninfo[node_I].onMeshBoundary )
         continue;
      ZeroMatrix( AMatrix, orderOfInterpolation, orderOfInterpolation );
      ZeroMatrix( bVector, dofThatExist, orderOfInterpolation );

      _SPR_StrainRate_AssemblePatch( self, node_I, AMatrix, bVector);

      for( dof_I = 0 ; dof_I < dofThatExist ; dof_I++ ) {
         _REP_Algorithm_Solver( AMatrix, bVector[dof_I], orderOfInterpolation );
         /* copy bVector into the corresponding patchCoeff array */
         memcpy( &patchCoeff[dof_I*orderOfInterpolation], bVector[dof_I], orderOfInterpolation*sizeof(double) );
      }
      /* write all dof patch coefficients on the node */
      FeVariable_SetValueAtNode( self, node_I , patchCoeff );
   }
   Memory_Free( AMatrix );
   Memory_Free( bVector );
   Memory_Free( patchCoeff );
}
/**
 * calculates this contact element's local contributions
 */
void MasterContactPoint2D::CalculateLocalSystem( MatrixType& rLeftHandSideMatrix,
        VectorType& rRightHandSideVector,
        ProcessInfo& rCurrentProcessInfo)
{
    unsigned int ndof = GetGeometry().size()*2;
    if( rRightHandSideVector.size() != ndof )
        rRightHandSideVector.resize(ndof,false);
    rRightHandSideVector = ZeroVector(ndof);
    if( rLeftHandSideMatrix.size1() != ndof )
        rLeftHandSideMatrix(ndof,ndof);
    rLeftHandSideMatrix = ZeroMatrix(ndof,ndof);

}
//************************************************************************************
//**** life cycle ********************************************************************
//************************************************************************************
SlaveContactFace3DNewmark::SlaveContactFace3DNewmark( IndexType NewId, GeometryType::Pointer pGeometry,
        PropertiesType::Pointer pProperties) :
    Condition( NewId, pGeometry, pProperties )
{
//         for(unsigned int i = 0 ; i != GetGeometry().size() ; ++i)
//         {
//             (GetGeometry()[i].pAddDof(DISPLACEMENT_X));
//             (GetGeometry()[i].pAddDof(DISPLACEMENT_Y));
//             (GetGeometry()[i].pAddDof(DISPLACEMENT_Z));
//         }
    mpMasterElements = ContactMasterContainerType::Pointer( new ContactMasterContainerType() );
    GetValue( LAMBDAS ).resize(GetGeometry().IntegrationPoints().size(),false);
    noalias(GetValue( LAMBDAS )) = ZeroVector( GetGeometry().IntegrationPoints().size());
    GetValue( LAMBDAS_T ).resize( GetGeometry().IntegrationPoints().size(), 2,false );
    noalias(GetValue( LAMBDAS_T )) = ZeroMatrix( GetGeometry().IntegrationPoints().size(), 2 );
    GetValue( GAPS ).resize( GetGeometry().IntegrationPoints().size(),false);
    noalias(GetValue( GAPS )) = ZeroVector( GetGeometry().IntegrationPoints().size());
    GetValue( DELTA_LAMBDAS ).resize( GetGeometry().IntegrationPoints().size() ,false);
    noalias(GetValue( DELTA_LAMBDAS )) = ZeroVector( GetGeometry().IntegrationPoints().size() );
    GetValue( DELTA_LAMBDAS_T ).resize( GetGeometry().IntegrationPoints().size(), 2 ,false);
    noalias(GetValue( DELTA_LAMBDAS_T )) = ZeroMatrix( GetGeometry().IntegrationPoints().size(), 2 );
    GetValue( PENALTY ).resize( GetGeometry().IntegrationPoints().size(),false );
    noalias(GetValue( PENALTY )) =  ZeroVector( GetGeometry().IntegrationPoints().size() );
    GetValue( PENALTY_T ).resize( GetGeometry().IntegrationPoints().size(),false );
    noalias(GetValue( PENALTY_T )) = ZeroVector( GetGeometry().IntegrationPoints().size() );
    GetValue( IS_CONTACT_SLAVE ) = 1;
    GetValue( IS_CONTACT_MASTER ) = 0;
    GetValue(NORMAL_STRESS).resize(GetGeometry().IntegrationPoints().size(),false);
    GetValue(NORMAL_STRESS)=ZeroVector( GetGeometry().IntegrationPoints().size());
    GetValue(TANGENTIAL_STRESS).resize(GetGeometry().IntegrationPoints().size(),false);
    GetValue(TANGENTIAL_STRESS)=ZeroVector( GetGeometry().IntegrationPoints().size());
    GetValue(STICK).resize(GetGeometry().IntegrationPoints().size(),false);
    GetValue(STICK)=ZeroVector( GetGeometry().IntegrationPoints().size());

    GetValue(NORMAL_CONTACT_STRESS) = 0.0;
    GetValue(TANGENTIAL_CONTACT_STRESS) = 0.0;
    GetValue(CONTACT_STICK) = 0.0;
}
Example #22
0
Matrix *Matrix::GetP()
{
	if (L == NULL)
	{
		MakeLU();
	}

	Matrix *matrix = ZeroMatrix(rows, cols);
	for (int i = 0; i < rows; i++)
	{
		(*matrix)(i,pi[i]) = 1;
	}
	return matrix;
}
Example #23
0
MatBiLM *CreateMatBigram(LModel *lm,int nw)
{
   MatBiLM *matbi;
  
   matbi = (MatBiLM *) New(lm->heap,sizeof(MatBiLM));
   lm->data.matbi = matbi;
   matbi->heap = lm->heap;
   
   matbi->numWords = nw;
   matbi->wdlist = (LabId *) New(lm->heap,sizeof(LabId)*(nw+1));
   matbi->bigMat = CreateMatrix(lm->heap,nw,nw);
   ZeroMatrix(matbi->bigMat);
   return(matbi);
}
Example #24
0
void InfiniteDomainCondition<TDim,TNumNodes>::CalculateLHS( MatrixType& rLeftHandSideMatrix, const ProcessInfo& CurrentProcessInfo )
{    
        
        KRATOS_TRY
		
		//const PropertiesType& Prop = this->GetProperties();
		const GeometryType& Geom = this->GetGeometry();
		const unsigned int element_size = TNumNodes;
		const GeometryType::IntegrationPointsArrayType& integration_points = Geom.IntegrationPoints( mThisIntegrationMethod );
		const unsigned int NumGPoints = integration_points.size();
        const unsigned int LocalDim = Geom.LocalSpaceDimension();

		
		//Resetting the LHS
		if ( rLeftHandSideMatrix.size1() != element_size )
			rLeftHandSideMatrix.resize( element_size, element_size, false );
		noalias( rLeftHandSideMatrix ) = ZeroMatrix( element_size, element_size );
		
		 //Defining the shape functions, the jacobian and the shape functions local gradients Containers
		array_1d<double,TNumNodes> Np;
        const Matrix& NContainer = Geom.ShapeFunctionsValues( mThisIntegrationMethod );
		GeometryType::JacobiansType JContainer(NumGPoints);
		for(unsigned int i = 0; i<NumGPoints; i++)
			(JContainer[i]).resize(TDim,LocalDim,false);
		Geom.Jacobian( JContainer, mThisIntegrationMethod );

		double IntegrationCoefficient;
		
		// Definition of the speed in the fluid
        //~ const double BulkModulus = Prop[BULK_MODULUS_FLUID];
        //~ const double Water_density = Prop[DENSITY_WATER];
        const double BulkModulus = 2.21e9;
        const double Water_density = 1000.0;
        const double inv_c_speed = 1.0 /sqrt(BulkModulus/Water_density);
               
        for ( unsigned int igauss = 0; igauss < NumGPoints; igauss++ )
        {	
			noalias(Np) = row(NContainer,igauss);
								
			//calculating weighting coefficient for integration
			this->CalculateIntegrationCoefficient( IntegrationCoefficient, JContainer[igauss], integration_points[igauss].Weight() );

			// Mass matrix contribution
			noalias(rLeftHandSideMatrix) += CurrentProcessInfo[VELOCITY_PRESSURE_COEFFICIENT]*(inv_c_speed)*outer_prod(Np,Np)*IntegrationCoefficient;
		}
        
				
		KRATOS_CATCH( "" )
}
/* CalcCovs: calculate covariance of speech data */
void CalcCovs(void)
{
   int x,y,s,V;
   float meanx,meany,varxy,n;
   Matrix fullMat;
   
   if (totalCount<2)
      HError(2021,"CalcCovs: Only %d speech frames accumulated",totalCount);
   if (trace&T_TOP)
      printf("%ld speech frames accumulated\n", totalCount);
   n = (float)totalCount;     /* to prevent rounding to integer below */
   for (s=1; s<=hset.swidth[0]; s++){  /* For each stream   */
      V = hset.swidth[s];
      for (x=1; x<=V; x++)            /* For each coefficient ... */
         accs[s].meanSum[x] /= n;         /* ... calculate mean */
      for (x=1;x<=V;x++) {
         meanx = accs[s].meanSum[x];      /* ... and [co]variance */
         if (fullcNeeded[s]) {
            for (y=1; y<=x; y++) {
               meany = accs[s].meanSum[y];
               varxy = accs[s].squareSum.inv[x][y]/n - meanx*meany;
               accs[s].squareSum.inv[x][y] =
                  (x != y || varxy > minVar) ? varxy : minVar;    
            }
         }
         else {
            varxy = accs[s].squareSum.var[x]/n - meanx*meanx;
            accs[s].fixed.var[x] = (varxy > minVar) ? varxy :minVar;
         }
      }
      if (fullcNeeded[s]) { /* invert covariance matrix */
         fullMat=CreateMatrix(&gstack,V,V);
         ZeroMatrix(fullMat); 
         CovInvert(accs[s].squareSum.inv,fullMat);
         Mat2Tri(fullMat,accs[s].fixed.inv);
         FreeMatrix(&gstack,fullMat);
      }
      if (trace&T_COVS) {
         printf("Stream %d\n",s);
         if (meanUpdate)
            ShowVector(" Mean Vector ", accs[s].meanSum,12);
         if (fullcNeeded[s]) {
            ShowTriMat(" Covariance Matrix ",accs[s].squareSum.inv,12,12);
         } else
            ShowVector(" Variance Vector ", accs[s].fixed.var,12);
      }
   }
}
void Tresca_Yield_Function::ReturnMapping(const Vector& StressVector,
        const Vector& StrainVector,
        Vector& delta_lamda,
        array_1d<double,3>& Result)


{


    double p_trial = 0.00;
    Matrix Sigma_Tensor        = ZeroMatrix(3,3);
    State_Tensor(StressVector, Sigma_Tensor);
    p_trial = (Sigma_Tensor(0,0) + Sigma_Tensor(1,1) + Sigma_Tensor(2,2))/3.00 ;
    array_1d<double,3> Trial_Stress_Vector     = ZeroVector(3);
    array_1d<double,3> Aux_Trial_Stress_Vector = ZeroVector(3);
    CalculatePrincipalStressVector(StressVector, Trial_Stress_Vector);
    Trial_Stress_Vector[0] = Trial_Stress_Vector[0] - p_trial;
    Trial_Stress_Vector[1] = Trial_Stress_Vector[1] - p_trial;
    Trial_Stress_Vector[2] = Trial_Stress_Vector[2] - p_trial;
    noalias(Aux_Trial_Stress_Vector) = Trial_Stress_Vector;

    ///* return to main plane
    One_Vector_Return_Mapping_To_Main_Plane(StressVector, delta_lamda,  Trial_Stress_Vector);

    ///*check validty
    bool check = false;
    check = CheckValidity(Trial_Stress_Vector);
    if( check==false)
    {
        ///*return to corner
        noalias(Trial_Stress_Vector) =  Aux_Trial_Stress_Vector;
        double proof = Trial_Stress_Vector[0] + Trial_Stress_Vector[2] - 2.00 * Trial_Stress_Vector[1];
        if(proof > 0.00 )
        {
            mCases = right;
        }
        else
        {
            mCases = left;
        }
        Two_Vector_Return_Mapping_To_Corner(StressVector,delta_lamda,  Trial_Stress_Vector);
    }

    Result[0] =  Trial_Stress_Vector[0] +  p_trial;
    Result[1] =  Trial_Stress_Vector[1] +  p_trial;
    Result[2] =  Trial_Stress_Vector[2] +  p_trial;

}
Example #27
0
void Monolithic2DNeumann::CalculateLocalVelocityContribution(MatrixType& rDampingMatrix,VectorType& rRightHandSideVector,ProcessInfo& rCurrentProcessInfo)
{
    KRATOS_TRY

    int nodes_number = 2;
    int dim = 2;
    unsigned int matsize = nodes_number*(dim);

    if(rDampingMatrix.size1() != matsize)
        rDampingMatrix.resize(matsize,matsize,false); //false says not to preserve existing storage!!


    noalias(rDampingMatrix) = ZeroMatrix(matsize,matsize);

    KRATOS_CATCH("")
}
Example #28
0
void Rotate3D(int m, float Theta, Matx4x4 A)
{
  int   m1,m2;
  float c,s;

  ZeroMatrix(A);
  A[m-1][m-1]=1.0;
  A[3][3]=1.0;
  m1=(m % 3)+1;
  m2=(m1 % 3);
  m1-=1;
  c=CosD(Theta);
  s=SinD(Theta);
  A[m1][m1]=c;
  A[m1][m2]=s;
  A[m2][m2]=c;
  A[m2][m1]=-s;
}
Example #29
0
    void DEM_Dempack_dev::AddPoissonContribution(const double equiv_poisson, double LocalCoordSystem[3][3], double& normal_force,
                                          double calculation_area, Matrix* mSymmStressTensor, SphericContinuumParticle* element1,
                                          SphericContinuumParticle* element2, const ProcessInfo& r_process_info, const int i_neighbor_count, const double indentation) {

        if (!r_process_info[POISSON_EFFECT_OPTION]) return;
        if (element1->mIniNeighbourFailureId[i_neighbor_count] > 0  &&  indentation < 0.0) return;

        double force[3];
        Matrix average_stress_tensor = ZeroMatrix(3,3);

        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                average_stress_tensor(i,j) = 0.5 * ((*mSymmStressTensor)(i,j) + (*(element2->mSymmStressTensor))(i,j));
            }
        }

        for (int i = 0; i < 3; i++) {

            force[i] = (average_stress_tensor)(i,0) * LocalCoordSystem[0][0] +
                       (average_stress_tensor)(i,1) * LocalCoordSystem[0][1] +
                       (average_stress_tensor)(i,2) * LocalCoordSystem[0][2]; // StressTensor*unitaryNormal0
        }

        double sigma_x = force[0] * LocalCoordSystem[0][0] +
                         force[1] * LocalCoordSystem[0][1] +
                         force[2] * LocalCoordSystem[0][2]; // projection to normal to obtain value of the normal stress

        for (int i = 0; i < 3; i++) {

            force[i] = (average_stress_tensor)(i,0) * LocalCoordSystem[1][0] +
                       (average_stress_tensor)(i,1) * LocalCoordSystem[1][1] +
                       (average_stress_tensor)(i,2) * LocalCoordSystem[1][2]; // StressTensor*unitaryNormal1
        }

        double sigma_y = force[0] * LocalCoordSystem[1][0] +
                         force[1] * LocalCoordSystem[1][1] +
                         force[2] * LocalCoordSystem[1][2]; // projection to normal to obtain value of the normal stress

        double poisson_force = calculation_area * equiv_poisson * (sigma_x + sigma_y);

        normal_force -= poisson_force;

    } //AddPoissonContribution
Example #30
0
Matrix *Matrix::Multiply(Matrix *m1, Matrix *m2)
{
	if (m1->cols != m2->rows)
	{
		throw MException(L"Wrong dimensions of matrix!");
	}

	Matrix *result = ZeroMatrix(m1->rows, m2->cols);
	for (int i = 0; i < result->rows; i++)
	{
		for (int j = 0; j < result->cols; j++)
		{
			for (int k = 0; k < m1->cols; k++)
			{
				result->operator ()(i,j) += m1->operator ()(i,k) * m2->operator ()(k,j);
			}
		}
	}
	return result;
}