int XfemManager :: instanciateYourself(DataReader &dr) { IRResultType result; // Required by IR_GIVE_FIELD macro std :: string name; enrichmentItemList.resize(numberOfEnrichmentItems); for ( int i = 1; i <= numberOfEnrichmentItems; i++ ) { InputRecord *mir = dr.giveInputRecord(DataReader :: IR_enrichItemRec, i); result = mir->giveRecordKeywordField(name); if ( result != IRRT_OK ) { mir->report_error(this->giveClassName(), __func__, "", result, __FILE__, __LINE__); } std :: unique_ptr< EnrichmentItem >ei( classFactory.createEnrichmentItem( name.c_str(), i, this, this->giveDomain() ) ); if ( ei.get() == NULL ) { OOFEM_ERROR( "unknown enrichment item (%s)", name.c_str() ); } ei->initializeFrom(mir); ei->instanciateYourself(dr); this->enrichmentItemList [ i - 1 ] = std :: move(ei); } mNucleationCriteria.resize(numberOfNucleationCriteria); for ( int i = 1; i <= numberOfNucleationCriteria; i++ ) { InputRecord *mir = dr.giveInputRecord(DataReader :: IR_crackNucleationRec, i); result = mir->giveRecordKeywordField(name); if ( result != IRRT_OK ) { mir->report_error(this->giveClassName(), __func__, "", result, __FILE__, __LINE__); } std :: unique_ptr< NucleationCriterion >nc( classFactory.createNucleationCriterion( name.c_str(), this->giveDomain() ) ); if ( nc.get() == NULL ) { OOFEM_ERROR( "Unknown nucleation criterion: (%s)", name.c_str() ); } nc->initializeFrom(mir); nc->instanciateYourself(dr); this->mNucleationCriteria [ i - 1 ] = std :: move(nc); } updateNodeEnrichmentItemMap(); return 1; }
int ContactManager :: instanciateYourself(DataReader *dr) { IRResultType result = IRRT_OK; // Required by IR_GIVE_FIELD macro std :: string name; // Create and instantiate contact definitions for ( int i = 1; i <= this->giveNumberOfContactDefinitions(); i++ ) { InputRecord *ir = dr->giveInputRecord(DataReader :: IR_contactDefRec, i); result = ir->giveRecordKeywordField(name); this->contactDefinitionList[i-1].reset( classFactory.createContactDefinition( name.c_str(), this ) ); if ( this->contactDefinitionList[i-1] ) { this->contactDefinitionList[i-1]->initializeFrom(ir); this->contactDefinitionList[i-1]->instanciateYourself(dr); } else { OOFEM_ERROR("Failed to create contact definition (%s)", name.c_str() ); } } return result; }
EngngModel *InstanciateProblem(DataReader *dr, problemMode mode, int contextFlag, EngngModel *_master, bool parallelFlag) { const char *__proc = "InstanciateProblem"; // Required by IR_GIVE_FIELD macro IRResultType result; // Required by IR_GIVE_FIELD macro EngngModel *problem; std::string problemName, dataOutputFileName, desc; dataOutputFileName = dr->giveOutputFileName(); desc = dr->giveDescription(); /* here we need copy of input record. The pointer returned by dr->giveInputRecord can (and will) * be updated as reading e-model components (nodes, etc). But we need this record being available * through the whole e-model instanciation */ InputRecord *emodelir = dr->giveInputRecord(DataReader :: IR_emodelRec, 1)->GiveCopy(); result = emodelir->giveRecordKeywordField(problemName); ///@todo Make this function robust, it can't be allowed to fail (the record keyword is not a normal field-id) if ( result != IRRT_OK ) { IR_IOERR("", __proc, "", emodelir, result); } problem = classFactory.createEngngModel(problemName.c_str(), 1, _master); if (!problem) { OOFEM_ERROR2("EngngModel::InstanciateProblem - Failed to construct engineering model if type \"%s\".\n", problemName.c_str()); } problem->setProblemMode(mode); problem->setParallelMode(parallelFlag); if ( contextFlag ) { problem->setContextOutputMode(COM_Always); } problem->instanciateYourself(dr, emodelir, dataOutputFileName.c_str(), desc.c_str()); delete emodelir; return problem; }
int Delamination :: instanciateYourself(DataReader *dr) { IRResultType result; // Required by IR_GIVE_FIELD macro std :: string name; // Instantiate enrichment function InputRecord *mir = dr->giveInputRecord(DataReader :: IR_enrichFuncRec, 1); result = mir->giveRecordKeywordField(name); if ( result != IRRT_OK ) { mir->report_error(this->giveClassName(), __func__, "", result, __FILE__, __LINE__); } mpEnrichmentFunc = classFactory.createEnrichmentFunction( name.c_str(), 1, this->giveDomain() ); if ( mpEnrichmentFunc != NULL ) { mpEnrichmentFunc->initializeFrom(mir); } else { OOFEM_ERROR( "failed to create enrichment function (%s)", name.c_str() ); } // Instantiate enrichment domain mir = dr->giveInputRecord(DataReader :: IR_geoRec, 1); result = mir->giveRecordKeywordField(name); if ( result != IRRT_OK ) { mir->report_error(this->giveClassName(), __func__, "", result, __FILE__, __LINE__); } IntArray idList; IR_GIVE_FIELD(mir, idList, _IFT_ListBasedEI_list); for ( int i = 1; i <= idList.giveSize(); i++ ) { this->dofManList.push_back( idList.at(i) ); } std :: sort( dofManList.begin(), this->dofManList.end() ); //IR_GIVE_FIELD(ir, this->xi, _IFT_DofManList_DelaminationLevel); // Instantiate EnrichmentFront if ( mEnrFrontIndex == 0 ) { mpEnrichmentFrontStart = new EnrFrontDoNothing(); mpEnrichmentFrontEnd = new EnrFrontDoNothing(); } else { std :: string enrFrontNameStart, enrFrontNameEnd; InputRecord *enrFrontStartIr = dr->giveInputRecord(DataReader :: IR_enrichFrontRec, mEnrFrontIndex); result = enrFrontStartIr->giveRecordKeywordField(enrFrontNameStart); mpEnrichmentFrontStart = classFactory.createEnrichmentFront( enrFrontNameStart.c_str() ); if ( mpEnrichmentFrontStart != NULL ) { mpEnrichmentFrontStart->initializeFrom(enrFrontStartIr); } else { OOFEM_ERROR( "Failed to create enrichment front (%s)", enrFrontNameStart.c_str() ); } InputRecord *enrFrontEndIr = dr->giveInputRecord(DataReader :: IR_enrichFrontRec, mEnrFrontIndex); result = enrFrontEndIr->giveRecordKeywordField(enrFrontNameEnd); mpEnrichmentFrontEnd = classFactory.createEnrichmentFront( enrFrontNameEnd.c_str() ); if ( mpEnrichmentFrontEnd != NULL ) { mpEnrichmentFrontEnd->initializeFrom(enrFrontEndIr); } else { OOFEM_ERROR( "Failed to create enrichment front (%s)", enrFrontNameEnd.c_str() ); } } // Instantiate PropagationLaw if ( mPropLawIndex == 0 ) { mpPropagationLaw = new PLDoNothing(); } else { std :: string propLawName; InputRecord *propLawir = dr->giveInputRecord(DataReader :: IR_propagationLawRec, mPropLawIndex); result = propLawir->giveRecordKeywordField(propLawName); mpPropagationLaw = classFactory.createPropagationLaw( propLawName.c_str() ); if ( mpPropagationLaw != NULL ) { mpPropagationLaw->initializeFrom(propLawir); } else { OOFEM_ERROR( "Failed to create propagation law (%s)", propLawName.c_str() ); } } // Set start of the enrichment dof pool for the given EI int xDofPoolAllocSize = this->giveDofPoolSize(); this->startOfDofIdPool = this->giveDomain()->giveNextFreeDofID(xDofPoolAllocSize); this->endOfDofIdPool = this->startOfDofIdPool + xDofPoolAllocSize - 1; XfemManager *xMan = this->giveDomain()->giveXfemManager(); // mpEnrichmentDomain->CallNodeEnrMarkerUpdate(* this, * xMan); this->updateNodeEnrMarker(* xMan); writeVtkDebug(); return 1; }
void StructuralFE2MaterialStatus :: copyStateVariables(const MaterialStatus &iStatus) { //static int num = 0; //printf("Entering StructuralFE2MaterialStatus :: copyStateVariables.\n"); this->oldTangent = true; // if ( !this->createRVE(this->giveNumber(), gp, mInputFile) ) { // OOFEM_ERROR("Couldn't create RVE"); // } StructuralMaterialStatus :: copyStateVariables(iStatus); ////////////////////////////// MaterialStatus &tmpStat = const_cast< MaterialStatus & >(iStatus); StructuralFE2MaterialStatus *fe2ms = dynamic_cast<StructuralFE2MaterialStatus*>(&tmpStat); if ( !fe2ms ) { OOFEM_ERROR("Failed to cast StructuralFE2MaterialStatus.") } this->mNewlyInitialized = fe2ms->mNewlyInitialized; // The proper way to do this would be to clone the RVE from iStatus. // However, this is a mess due to all pointers that need to be tracked. // Therefore, we consider a simplified version: copy only the enrichment items. Domain *ext_domain = fe2ms->giveRVE()->giveDomain(1); if ( ext_domain->hasXfemManager() ) { Domain *rve_domain = rve->giveDomain(1); XfemManager *ext_xMan = ext_domain->giveXfemManager(); XfemManager *this_xMan = rve->giveDomain(1)->giveXfemManager(); DynamicDataReader dataReader("fe2"); if ( ext_xMan != NULL ) { IRResultType result; // Required by IR_GIVE_FIELD macro std::vector<std::unique_ptr<EnrichmentItem>> eiList; //DynamicInputRecord *xmanRec = new DynamicInputRecord(); //ext_xMan->giveInputRecord(* xmanRec); //dataReader.insertInputRecord(DataReader :: IR_xfemManRec, xmanRec); // Enrichment items int nEI = ext_xMan->giveNumberOfEnrichmentItems(); for ( int i = 1; i <= nEI; i++ ) { EnrichmentItem *ext_ei = ext_xMan->giveEnrichmentItem(i); ext_ei->appendInputRecords(dataReader); InputRecord *mir = dataReader.giveInputRecord(DataReader :: IR_enrichItemRec, i); std :: string name; result = mir->giveRecordKeywordField(name); if ( result != IRRT_OK ) { mir->report_error(this->giveClassName(), __func__, "", result, __FILE__, __LINE__); } std :: unique_ptr< EnrichmentItem >ei( classFactory.createEnrichmentItem( name.c_str(), i, this_xMan, rve_domain ) ); if ( ei.get() == NULL ) { OOFEM_ERROR( "unknown enrichment item (%s)", name.c_str() ); } ei->initializeFrom(mir); ei->instanciateYourself(dataReader); eiList.push_back( std :: move(ei) ); } this_xMan->clearEnrichmentItems(); this_xMan->appendEnrichmentItems(eiList); rve_domain->postInitialize(); rve->forceEquationNumbering(); } } //printf("done.\n"); #if 0 Domain *newDomain = fe2ms->giveRVE()->giveDomain(1)->Clone(); newDomain->SetEngngModel(rve.get()); bool deallocateOld = true; rve->setDomain(1, newDomain, deallocateOld); //rve->giveDomain(1)->postInitialize(); rve->giveNumericalMethod(NULL)->setDomain(newDomain); rve->postInitialize(); //rve->forceEquationNumbering(); rve->initMetaStepAttributes( rve->giveMetaStep(1) ); rve->giveNextStep(); // Makes sure there is a timestep (which we will modify before solving a step) rve->init(); // std :: ostringstream name; // name << this->rve->giveOutputBaseFileName() << "-gp" << n; // this->rve->letOutputBaseFileNameBe( name.str() ); // n++; double crackLength = 0.0; XfemStructureManager *xMan = dynamic_cast<XfemStructureManager*>( rve->giveDomain(1)->giveXfemManager() ); if ( xMan ) { crackLength = xMan->computeTotalCrackLength(); } std :: ostringstream name; name << this->rve->giveOutputBaseFileName() << "-gp" << num << "crackLength" << crackLength; if ( this->domain->giveEngngModel()->isParallel() && this->domain->giveEngngModel()->giveNumberOfProcesses() > 1 ) { name << "." << this->domain->giveEngngModel()->giveRank(); } num++; this->rve->letOutputBaseFileNameBe( name.str() ); // Update BC this->bc = dynamic_cast< PrescribedGradientHomogenization * >( this->rve->giveDomain(1)->giveBc(1) ); #if 1 XfemSolverInterface *xfemSolInt = dynamic_cast<XfemSolverInterface*>(rve.get()); StaticStructural *statStruct = dynamic_cast<StaticStructural*>(rve.get()); if ( xfemSolInt && statStruct ) { //printf("Successfully casted to XfemSolverInterface.\n"); TimeStep *tStep = rve->giveCurrentStep(); EModelDefaultEquationNumbering num; int numDofsNew = rve->giveNumberOfDomainEquations( 1, num ); FloatArray u; u.resize(numDofsNew); u.zero(); xfemSolInt->xfemUpdatePrimaryField(*statStruct, tStep, u); // Set domain pointer to various components ... rve->giveNumericalMethod(NULL)->setDomain(newDomain); //ioEngngModel.nMethod->setDomain(domain); } // TimeStep *tStep = rve->giveNextStep(); // setTimeStep(tStep); // rve->solveYourselfAt(tStep); int numExpModules = rve->giveExportModuleManager()->giveNumberOfModules(); for ( int i = 1; i <= numExpModules; i++ ) { // ... by diving deep into the hierarchies ... :-/ VTKXMLExportModule *vtkxmlMod = dynamic_cast< VTKXMLExportModule * >( rve->giveExportModuleManager()->giveModule(i) ); if ( vtkxmlMod != NULL ) { vtkxmlMod->giveSmoother()->setDomain(newDomain); vtkxmlMod->givePrimVarSmoother()->setDomain(newDomain); } } #endif #endif }