void BlockDef::createFace(World * world, Position & camPosition, Vector3d pos, Dir face, FloatArray & vertices, IntArray & indexes) { int v0 = vertices.length() / VERTEX_COMPONENTS; float * vptr = vertices.append(0.0f, VERTEX_COMPONENTS * 4); int * iptr = indexes.append(0, 6); createFaceMesh(vptr, face, pos.x + 0.5f, pos.y + 0.5f, pos.z + 0.5f, txIndex); for (int i = 0; i < 6; i++) iptr[i] = v0 + face_indexes[i]; if (HIGHLIGHT_GRID && ((pos.x & 7) == 0 || (pos.z & 7) == 0)) { for (int i = 0; i < 4; i++) { vptr[11 * i + 6 + 0] = 1.4f; vptr[11 * i + 6 + 1] = 1.4f; vptr[11 * i + 6 + 2] = 1.4f; } } }
void PrescribedGradientBCWeak :: computeIntForceGPContrib(FloatArray &oContrib_disp, IntArray &oDisp_loc_array, FloatArray &oContrib_trac, IntArray &oTrac_loc_array,TracSegArray &iEl, GaussPoint &iGP, int iDim, TimeStep *tStep, const FloatArray &iBndCoord, const double &iScaleFac, ValueModeType mode, CharType type, const UnknownNumberingScheme &s) { SpatialLocalizer *localizer = domain->giveSpatialLocalizer(); FloatMatrix contrib; assembleTangentGPContributionNew(contrib, iEl, iGP, iScaleFac, iBndCoord); // Compute vector of traction unknowns FloatArray tracUnknowns; iEl.mFirstNode->giveUnknownVector(tracUnknowns, giveTracDofIDs(), mode, tStep); iEl.giveTractionLocationArray(oTrac_loc_array, type, s); FloatArray dispElLocCoord, closestPoint; Element *dispEl = localizer->giveElementClosestToPoint(dispElLocCoord, closestPoint, iBndCoord ); // Compute vector of displacement unknowns FloatArray dispUnknowns; int numDMan = dispEl->giveNumberOfDofManagers(); for(int i = 1; i <= numDMan; i++) { FloatArray nodeUnknowns; DofManager *dMan = dispEl->giveDofManager(i); IntArray dispIDs = giveRegularDispDofIDs(); if(domain->hasXfemManager()) { XfemManager *xMan = domain->giveXfemManager(); dispIDs.followedBy(xMan->giveEnrichedDofIDs(*dMan)); } dMan->giveUnknownVector(nodeUnknowns, dispIDs,mode, tStep); dispUnknowns.append(nodeUnknowns); } dispEl->giveLocationArray(oDisp_loc_array, s); oContrib_disp.beTProductOf(contrib, tracUnknowns); oContrib_disp.negated(); oContrib_trac.beProductOf(contrib, dispUnknowns); oContrib_trac.negated(); }
IRResultType Delamination :: initializeFrom(InputRecord *ir) { IRResultType result; // Required by IR_GIVE_FIELD macro result = EnrichmentItem :: initializeFrom(ir); if ( result != IRRT_OK ) return result; // Compute the delamination xi-coord IR_GIVE_FIELD(ir, this->interfaceNum, _IFT_Delamination_interfacenum); // interface number from the bottom IR_GIVE_FIELD(ir, this->crossSectionNum, _IFT_Delamination_csnum); if ( ir->hasField(_IFT_Delamination_averageStresses) ) { this->recoverStresses = false; //printf("averageStresses"); } #if 1 // update: csnum is now an IntArray of cross sections viable for delamination bool checkCS = false; double totalThickness(0.0); FloatArray layerThicknesses; int numberOfLayers(0); for (int iCS : this->crossSectionNum) { LayeredCrossSection *layeredCS = dynamic_cast< LayeredCrossSection * >( this->giveDomain()->giveCrossSection(iCS) ); if ( layeredCS == NULL ) { OOFEM_WARNING("Delamination EI requires a valid layered cross section number input: see record '%s'.", _IFT_Delamination_csnum); return IRRT_BAD_FORMAT; } else if ( this->interfaceNum.giveSize() < 1 || this->interfaceNum.giveSize() > 2 ) { OOFEM_WARNING("Size of record 'interfacenum' must be 1 or 2"); return IRRT_BAD_FORMAT; } // check that interface numbers are valid //interfaceNum.printYourself("interface num"); for ( int i = 1; i <= this->interfaceNum.giveSize(); i++ ) { if ( this->interfaceNum.at(i) < 1 || this->interfaceNum.at(i) >= layeredCS->giveNumberOfLayers() ) { OOFEM_WARNING( "Cross section does not contain the interface number (%d) specified in the record '%s' since number of layers is %d.", this->interfaceNum.at(i), _IFT_Delamination_interfacenum, layeredCS->giveNumberOfLayers() ); return IRRT_BAD_FORMAT; } } if (checkCS) { if ( layeredCS->give(CS_Thickness, FloatArray(), NULL, false) != totalThickness ) { OOFEM_WARNING("Delamination cross section have different totalThickness: see record '%s'.", _IFT_Delamination_csnum); return IRRT_BAD_FORMAT; } if ( layeredCS->giveNumberOfLayers() != numberOfLayers ) { OOFEM_WARNING("Delamination cross section have different number of layers: see record '%s'.", _IFT_Delamination_csnum); return IRRT_BAD_FORMAT; } } else numberOfLayers = layeredCS->giveNumberOfLayers(); totalThickness = layeredCS->give(CS_Thickness, FloatArray(), NULL, false); // no position available for ( int i = 1 ; i <= numberOfLayers ; i++) { double layerThickness = layeredCS->giveLayerThickness(i); if (checkCS) { if ( layerThickness != layerThicknesses.at(i) ) { OOFEM_WARNING("Delamination cross section have different layer thicknesses: see record '%s'.", _IFT_Delamination_csnum); return IRRT_BAD_FORMAT; } layerThicknesses.at(i) = layerThickness; } else { layerThicknesses.append(layeredCS->giveLayerThickness(i)); } } // compute xi-coord of the delamination this->delamXiCoord = -1.0; this->xiBottom = -1.0; for ( int i = 1; i <= this->interfaceNum.at(1); i++ ) { this->delamXiCoord += layeredCS->giveLayerThickness(i) / totalThickness * 2.0; this->xiBottom += layeredCS->giveLayerThickness(i) / totalThickness * 2.0; } if ( this->interfaceNum.giveSize() == 2 ) { if ( this->interfaceNum.at(1) >= this->interfaceNum.at(2) ) { OOFEM_WARNING("second intercfacenum must be greater than the first one"); return IRRT_BAD_FORMAT; } this->xiTop = -1.0; for ( int i = 1; i <= this->interfaceNum.at(2); i++ ) { this->xiTop += layeredCS->giveLayerThickness(i) / totalThickness * 2.0; } } else { this->xiTop = 1.0; // default is the top surface } checkCS = true; } #else // old csnum (int version). NB: this was a bug since element nodes that where not part of the cross section could be enriched. LayeredCrossSection *layeredCS = dynamic_cast< LayeredCrossSection * >( this->giveDomain()->giveCrossSection(this->crossSectionNum) ); if ( layeredCS == NULL ) { OOFEM_WARNING("Delamination EI requires a valid layered cross section number input: see record '%s'.", _IFT_Delamination_csnum); return IRRT_BAD_FORMAT; } else if ( this->interfaceNum.giveSize() < 1 || this->interfaceNum.giveSize() > 2 ) { OOFEM_WARNING("Size of record 'interfacenum' must be 1 or 2"); return IRRT_BAD_FORMAT; } // check that interface numbers are valid //interfaceNum.printYourself("interface num"); for ( int i = 1; i <= this->interfaceNum.giveSize(); i++ ) { if ( this->interfaceNum.at(i) < 1 || this->interfaceNum.at(i) >= layeredCS->giveNumberOfLayers() ) { OOFEM_WARNING( "Cross section does not contain the interface number (%d) specified in the record '%s' since number of layers is %d.", this->interfaceNum.at(i), _IFT_Delamination_interfacenum, layeredCS->giveNumberOfLayers() ); return IRRT_BAD_FORMAT; } } // compute xi-coord of the delamination this->delamXiCoord = -1.0; double totalThickness = layeredCS->give(CS_Thickness, FloatArray(), NULL, false); // no position available for ( int i = 1; i <= this->interfaceNum.at(1); i++ ) { this->delamXiCoord += layeredCS->giveLayerThickness(i) / totalThickness * 2.0; this->xiBottom += layeredCS->giveLayerThickness(i) / totalThickness * 2.0; } if ( this->interfaceNum.giveSize() == 2 ) { if ( this->interfaceNum.at(1) >= this->interfaceNum.at(2) ) { OOFEM_WARNING("second intercfacenum must be greater than the first one"); return IRRT_BAD_FORMAT; } for ( int i = 1; i <= this->interfaceNum.at(2); i++ ) { this->xiTop += layeredCS->giveLayerThickness(i) / totalThickness * 2.0; } } else { this->xiTop = 1.0; // default is the top surface } #endif IR_GIVE_OPTIONAL_FIELD(ir, this->matNum, _IFT_Delamination_CohesiveZoneMaterial); if ( this->matNum > 0 ) { this->mat = this->giveDomain()->giveMaterial(this->matNum); } IR_GIVE_OPTIONAL_FIELD(ir, this->initiationFactor, _IFT_Delamination_initiationFactor); if ( this->initiationFactor <= 0 ) { OOFEM_ERROR("initiation scale factor must be greater than 0."); return IRRT_BAD_FORMAT; } IR_GIVE_OPTIONAL_FIELD(ir, this->initiationRadius, _IFT_Delamination_initiationRadius); if ( this->initiationRadius < 0 ) { OOFEM_ERROR("initiation radius must be greater or equal than 0."); return IRRT_BAD_FORMAT; } return IRRT_OK; }