Esempio n. 1
0
 /// @brief
 /// @todo Doc me!
 /// @param
 IndexSet(const CpGridData& grid)
     : grid_(grid)
 {
     GeometryType t;
     t.makeCube(3);
     geom_types_[0].push_back(t);
     t.makeCube(0);
     geom_types_[3].push_back(t);
 }
ElementVariant PiecewiseConstantDiscontinuousScalarSpaceBarycentric<
    BasisFunctionType>::elementVariant(const Entity<0> &element) const {
  GeometryType type = element.type();
  if (type.dim() == 1)
    return 2;
  if (type.isTriangle())
    return 3;
  else
    return 4;
}
Esempio n. 3
0
wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order)
{
    unsigned num_points = g.size();
    assert(num_points > 1);

    using point_type = std::pair<double,double>;
    using linear_ring = std::vector<point_type>;
    boost::ptr_vector<linear_ring> rings;

    double x = 0;
    double y = 0;
    std::size_t size = 1 + 4 + 4 ; // byteOrder + wkbType + numRings
    for (unsigned i=0; i< num_points; ++i)
    {
        unsigned command = g.vertex(i,&x,&y);
        if (command == SEG_MOVETO)
        {
            rings.push_back(new linear_ring); // start new loop
            rings.back().push_back(std::make_pair(x,y));
            size += 4; // num_points
            size += 2 * 8; // point
        }
        else if (command == SEG_LINETO)
        {
            rings.back().push_back(std::make_pair(x,y));
            size += 2 * 8; // point
        }
    }
    unsigned num_rings = rings.size();
    wkb_buffer_ptr wkb = std::make_unique<wkb_buffer>(size);
    wkb_stream ss(wkb->buffer(), wkb->size());
    ss.write(reinterpret_cast<char*>(&byte_order),1);
    int type = static_cast<int>(mapnik::geometry_type::types::Polygon);
    write(ss,type,4,byte_order);
    write(ss,num_rings,4,byte_order);

    for ( linear_ring const& ring : rings)
    {
        unsigned num_ring_points = ring.size();
        write(ss,num_ring_points,4,byte_order);
        for ( point_type const& pt : ring)
        {
            write(ss,pt.first,8,byte_order);
            write(ss,pt.second,8,byte_order);
        }
    }

    assert(ss.good());
    return std::move(wkb);
}
Esempio n. 4
0
wkb_buffer_ptr to_point_wkb( GeometryType const& g, wkbByteOrder byte_order)
{
    assert(g.size() == 1);
    std::size_t size = 1 + 4 + 8*2 ; // byteOrder + wkbType + Point
    wkb_buffer_ptr wkb = std::make_unique<wkb_buffer>(size);
    wkb_stream ss(wkb->buffer(), wkb->size());
    ss.write(reinterpret_cast<char*>(&byte_order),1);
    int type = static_cast<int>(mapnik::geometry_type::types::Point);
    write(ss,type,4,byte_order);
    double x = 0;
    double y = 0;
    g.vertex(0,&x,&y);
    write(ss,x,8,byte_order);
    write(ss,y,8,byte_order);
    assert(ss.good());
    return std::move(wkb);
}
Esempio n. 5
0
wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order)
{
    unsigned num_points = g.size();
    assert(num_points > 1);

    typedef std::pair<double,double> point_type;
    typedef std::vector<point_type> linear_ring;
    boost::ptr_vector<linear_ring> rings;

    double x = 0;
    double y = 0;
    std::size_t size = 1 + 4 + 4 ; // byteOrder + wkbType + numRings
    for (unsigned i=0; i< num_points; ++i)
    {
        unsigned command = g.vertex(i,&x,&y);
        if (command == SEG_MOVETO)
        {
            rings.push_back(new linear_ring); // start new loop
            rings.back().push_back(std::make_pair(x,y));
            size += 4; // num_points
            size += 2 * 8; // point
        }
        else if (command == SEG_LINETO)
        {
            rings.back().push_back(std::make_pair(x,y));
            size += 2 * 8; // point
        }
    }
    unsigned num_rings = rings.size();
    wkb_buffer_ptr wkb = boost::make_shared<wkb_buffer>(size);
    boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary);

    ss.write(reinterpret_cast<char*>(&byte_order),1);
    int type = static_cast<int>(mapnik::Polygon);
    write(ss,type,4,byte_order);
    write(ss,num_rings,4,byte_order);

    BOOST_FOREACH ( linear_ring const& ring, rings)
    {
        unsigned num_ring_points = ring.size();
        write(ss,num_ring_points,4,byte_order);
        BOOST_FOREACH ( point_type const& pt, ring)
        {
            write(ss,pt.first,8,byte_order);
            write(ss,pt.second,8,byte_order);
        }
Esempio n. 6
0
wkb_buffer_ptr to_point_wkb( GeometryType const& g, wkbByteOrder byte_order)
{
    assert(g.size() == 1);
    std::size_t size = 1 + 4 + 8*2 ; // byteOrder + wkbType + Point
    wkb_buffer_ptr wkb = boost::make_shared<wkb_buffer>(size);
    boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary);
    ss.write(reinterpret_cast<char*>(&byte_order),1);
    int type = static_cast<int>(mapnik::Point);
    write(ss,type,4,byte_order);
    double x = 0;
    double y = 0;
    g.vertex(0,&x,&y);
    write(ss,x,8,byte_order);
    write(ss,y,8,byte_order);
    assert(ss.good());
    return wkb;
}
Esempio n. 7
0
void Hyperelastic2D::CalculateMaterialResponse( const Vector& StrainVector,
        const Matrix& DeformationGradient,
        Vector& StressVector,
        Matrix& AlgorithmicTangent,
        const ProcessInfo& CurrentProcessInfo,
        const Properties& props,
        const GeometryType& geom,
        const Vector& ShapeFunctionsValues,
        bool CalculateStresses,
        int CalculateTangent,
        bool SaveInternalVariables)
{
    mA=geom.Area();//props[AREA]; // to check

    mcurrentThickness = (mA0*mThickness)/mA; // to check
    // RETRACTION ///////////////
    if (CurrentProcessInfo[TIME] >  mRetractionTime)
        //if (CurrentProcessInfo[TIME] > 0.1)   //0.01
    {
        mRetraction=mAlpha*CurrentProcessInfo[TIME]; // [DELTA_TIME]
        //KRATOS_WATCH("retraction");
    }
    else
    {
        mRetraction=0.0;
    }

//CalculateElasticMatrix(mCtangent, props[YOUNG_MODULUS], props[POISSON_RATIO]);
    CalculateStress(StrainVector, StressVector);
    CalculateConstitutiveMatrix(StrainVector, Ctang);  // nelson
    //CalculateConstitutiveMatrix(StrainVector, rResult);  // nelson
// 		mA=geom.Area();//props[AREA]; // to check
//
// 		mcurrentThickness = (mA0*mThickness)/mA; // to check
// 		// RETRACTION ///////////////
// 		if (CurrentProcessInfo[TIME] > 0.0000001)   //0.01
// 		{
// 		mRetraction=mAlpha*CurrentProcessInfo[TIME]; // [DELTA_TIME]
// 		//KRATOS_WATCH("retraction");
// 		}
// 		else
// 		{
// 		mRetraction=0.0;
// 	        }
// 		//KRATOS_WATCH(CurrentProcessInfo[TIME]);
// 		//KRATOS_WATCH(mRetraction);
// 		// RETRACTION ///////////////
// 		//KRATOS_WATCH(mA0);
// 		//KRATOS_WATCH(mA);
// 		//KRATOS_WATCH(mThickness);
// 		//KRATOS_WATCH(mcurrentThickness);

}
Esempio n. 8
0
/**
 *	TO BE TESTED!!!
 */
void Hyperelastic2D::InitializeMaterial( const Properties& props,
        const GeometryType& geom,
        const Vector& ShapeFunctionsValues )
{
    //mCurrentStress = ZeroVector(6);
    mMU = props[MU]; // shear modulus
    mK = props[BULK_MODULUS]; // bulk modulus
    mE = props[YOUNG_MODULUS];
    mNU = props[POISSON_RATIO];
    mThickness = props[THICKNESS]; // to check
    mA0= geom.Area();  //geom[A0]; // to check
    mA= geom.Area();  // JUST A TEST, need to check if it will be updated later!!!
    mAlpha=props[ALPHA];  // angle used for retraction
    mRetractionTime=props[RETRACTION_TIME];  // Time to start retraction
    /*mCtangent.resize(6,6,false);
    noalias(mCtangent) = ZeroMatrix(6,6);*/
    mMaterialParameters = props[MATERIAL_PARAMETERS];
    mInSituStress = ZeroVector(6);
    //CalculateElasticMatrix(mCtangent, props[YOUNG_MODULUS], props[POISSON_RATIO]);
//                 CalculateElasticMatrix(mCtangent, props[MATERIAL_PARAMETERS][0], props[MATERIAL_PARAMETERS][1]);
}
Esempio n. 9
0
wkb_buffer_ptr to_line_string_wkb( GeometryType const& g, wkbByteOrder byte_order)
{
    unsigned num_points = g.size();
    assert(num_points > 1);
    std::size_t size = 1 + 4 + 4 + 8*2*num_points ; // byteOrder + wkbType + numPoints + Point*numPoints
    wkb_buffer_ptr wkb = std::make_unique<wkb_buffer>(size);
    wkb_stream ss(wkb->buffer(), wkb->size());
    ss.write(reinterpret_cast<char*>(&byte_order),1);
    int type = static_cast<int>(mapnik::geometry_type::types::LineString);
    write(ss,type,4,byte_order);
    write(ss,num_points,4,byte_order);
    double x = 0;
    double y = 0;
    for (unsigned i=0; i< num_points; ++i)
    {
        g.vertex(i,&x,&y);
        write(ss,x,8,byte_order);
        write(ss,y,8,byte_order);
    }
    assert(ss.good());
    return std::move(wkb);
}
Esempio n. 10
0
void Plasticity2D::InitializeMaterial( const Properties& props,
                                       const GeometryType& geom,
                                       const Vector& ShapeFunctionsValues )

{
    mE   = (*mpProperties)[YOUNG_MODULUS];
    mNU  = (*mpProperties)[POISSON_RATIO];
    mDE  = (*mpProperties)[DENSITY];
    KRATOS_WATCH(mpFluencyCriteria)
    mpFluencyCriteria->InitializeMaterial(*mpProperties);
    double he = geom.Length();
    mpFluencyCriteria->GetValue(he);
}
Esempio n. 11
0
wkb_buffer_ptr to_wkb(GeometryType const& g, wkbByteOrder byte_order )
{
    wkb_buffer_ptr wkb;

    switch (g.type())
    {
    case mapnik::geometry_type::types::Point:
        wkb = to_point_wkb(g, byte_order);
        break;
    case mapnik::geometry_type::types::LineString:
        wkb = to_line_string_wkb(g, byte_order);
        break;
    case mapnik::geometry_type::types::Polygon:
        wkb = to_polygon_wkb(g, byte_order);
        break;
    default:
        break;
    }
    return wkb;
}
Esempio n. 12
0
bool observeOneFullSweep(
	IoInputType& io,
	const GeometryType& geometry,
	const ModelType& model,
	const PsimagLite::String& obsOptions,
	bool hasTimeEvolution)
{
	bool verbose = false;
	typedef typename SparseMatrixType::value_type FieldType;
	typedef Observer<FieldType,VectorWithOffsetType,ModelType,IoInputType> 
		ObserverType;
	typedef ObservableLibrary<ObserverType,TargettingType> ObservableLibraryType;
	SizeType n  = geometry.numberOfSites();
	//PsimagLite::String sSweeps = "sweeps=";
	//PsimagLite::String::SizeTypeype begin = obsOptions.find(sSweeps);
	//if (begin != PsimagLite::String::npos) {
	//	PsimagLite::String sTmp = obsOptions.substr(begin+sSweeps.length(),PsimagLite::String::npos);
		//std::cout<<"sTmp="<<sTmp<<"\n";
	//	n = atoi(sTmp.c_str());
	//}
	ObservableLibraryType observerLib(io,n,hasTimeEvolution,model,verbose);
	
	bool ot = false;
	if (obsOptions.find("ot")!=PsimagLite::String::npos || obsOptions.find("time")!=PsimagLite::String::npos) ot = true;
	if (hasTimeEvolution && ot) {
		observerLib.measureTime("superDensity");
		observerLib.measureTime("nupNdown");
		observerLib.measureTime("nup+ndown");
		if (obsOptions.find("sz")!=PsimagLite::String::npos) observerLib.measureTime("sz");
	}

	if (hasTimeEvolution) observerLib.setBrackets("time","time");

	const PsimagLite::String& modelName = model.params().model;
	SizeType rows = n; // could be n/2 if there's enough symmetry

	// Immm supports only onepoint:
	if (modelName=="Immm" && obsOptions!="onepoint") {
		PsimagLite::String str(__FILE__);
		str += " "  + ttos(__LINE__) + "\n";
		str += "Model Immm only supports onepoint\n";
		throw PsimagLite::RuntimeError(str.c_str());
	}

	SizeType numberOfDofs = dofsFromModelName(model);

	if (!hasTimeEvolution && obsOptions.find("onepoint")!=PsimagLite::String::npos) {
		observerLib.measureTheOnePoints(numberOfDofs);
	}

	if (modelName.find("Heisenberg")==PsimagLite::String::npos) {
		if (obsOptions.find("cc")!=PsimagLite::String::npos) {
			observerLib.measure("cc",rows,n);
		}

		if (obsOptions.find("nn")!=PsimagLite::String::npos) {
			observerLib.measure("nn",rows,n);
		}
	}
	if (obsOptions.find("szsz")!=PsimagLite::String::npos) {
		observerLib.measure("szsz",rows,n);
	}

	if (modelName.find("FeAsBasedSc")!=PsimagLite::String::npos ||
	    modelName.find("FeAsBasedScExtended")!=PsimagLite::String::npos ||
	    modelName.find("HubbardOneBand")!=PsimagLite::String::npos) {
		bool dd4 = (obsOptions.find("dd4")!=PsimagLite::String::npos);

		if (obsOptions.find("dd")!=PsimagLite::String::npos && !dd4) { // &&
			//geometry.label(0).find("ladder")!=PsimagLite::String::npos) {
			observerLib.measure("dd",rows,n);
		}

		// FOUR-POINT DELTA-DELTA^DAGGER:
		if (dd4 && geometry.label(0).find("ladder")!=PsimagLite::String::npos) {
			observerLib.measure("dd4",rows,n);
		} // if dd4
	}

	if (modelName.find("HubbardOneBand")!=PsimagLite::String::npos &&
	    obsOptions.find("multi")!=PsimagLite::String::npos) {
		observerLib.measure("multi",rows,n);
	}

	if (obsOptions.find("s+s-")!=PsimagLite::String::npos) {
		observerLib.measure("s+s-",rows,n);
	}

	if (obsOptions.find("ss")!=PsimagLite::String::npos) {
		observerLib.measure("ss",rows,n);
	}

	return observerLib.endOfData();
}
Esempio n. 13
0
 bool contains(GeometryType gt) { return gt.dim() == dim; }
void IsotropicRankineDamage2D::CalculateMaterialResponse(const Vector& StrainVector,
        const Matrix& DeformationGradient,
        Vector& StressVector,
        Matrix& AlgorithmicTangent,
        const ProcessInfo& CurrentProcessInfo,
        const Properties& props,
        const GeometryType& geom,
        const Vector& ShapeFunctionsValues,
        bool CalculateStresses,
        int CalculateTangent,
        bool SaveInternalVariables)
{

    //get material parameters
    const double E  = props[YOUNG_MODULUS];
    const double NU = props[POISSON_RATIO];
    const double Gf = props[FRACTURE_ENERGY]; //***************************
    const double sigma0 = props[YIELD_STRESS]; //***************************
    const double r0 = sigma0; //***************************
    const double retat = props[VISCOSITY];

    //compute elastic stress
    Matrix Cel(3,3);
    Vector stress(3);
    CalculateElasticMatrix(Cel, E, NU);
    noalias(stress) = prod(Cel,StrainVector);

    //compute stress max eigenvalue
    const double sigma_m = 0.5*(stress[0]+  stress[1]);
    const double R = sqrt(stress[2]*stress[2] + 0.25*(stress[0]-stress[1])*(stress[0]-stress[1]) );
    double smax = sigma_m + R;

    //compute tau
    double tau = smax;
    if(tau < 0) tau=0.0;

    //compute actualized damage indicator
    double r = mrold;
    if(tau > r)      
    {
      if(retat == 0) r=tau;
      else
      {
	  double dt = CurrentProcessInfo[DELTA_TIME];
	  double ratio = dt/retat;
	  r = std::max( r , (mrold + ratio*tau)/(1.0+ratio) );
      }
    }



    //compute element lenght
    double he=0.0;
    for(unsigned int i=0; i<geom.size(); i++)
    {
        const double hn = geom[i].GetSolutionStepValue(NODAL_H);
        he += hn*ShapeFunctionsValues[i];
    }

//        double A = geom.Area();
//        const double he = sqrt(2.0*A);

    const double lch=2.0*he;
    const double ls =2.0*E*Gf/(sigma0*sigma0);

    double Hs = lch/(ls -lch);
    if(Hs < 0.0) Hs=1.0e10;

//         KRATOS_WATCH(Hs);

    double d=0.0;
    if(r>=r0)
        d = 1.0 - r0/r*exp(-2.0*Hs*(r-r0)/r0);
    if(d > 0.9999)
        d = 0.9999;

//        KRATOS_WATCH(d);


    //write outputs as needed
    if(CalculateStresses == true)
        noalias(StressVector) = (1.0-d)*stress;
    if(CalculateTangent == 1)
        noalias(AlgorithmicTangent) = (1.0-d)*Cel;

    //keep trace of internal variables if allowed, otherwise reset them
    if(SaveInternalVariables == false)
        mr = mrold;
    else
    {
        mr = r;

        //save variable for output
        md=d;
    }

//        KRATOS_WATCH(md);
//std::cout << this  << " inside calculate md " << md << std::endl;

}
Esempio n. 15
0
void SimoJuNonlocalDamagePlaneStrain2DLaw::CalculateCharacteristicSize( double& rCharacteristicSize, const GeometryType& DomainGeometry )
{
    //rCharacteristicSize is the diameter of a circle with the same area as the element
    rCharacteristicSize = sqrt(4.0*DomainGeometry.Area()/KRATOS_M_PI);
}