本文整理汇总了C++中DofManager::giveDofWithID方法的典型用法代码示例。如果您正苦于以下问题:C++ DofManager::giveDofWithID方法的具体用法?C++ DofManager::giveDofWithID怎么用?C++ DofManager::giveDofWithID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DofManager
的用法示例。
在下文中一共展示了DofManager::giveDofWithID方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: giveUnknown
double TransportGradientPeriodic :: giveUnknown(ValueModeType mode, TimeStep *tStep, ActiveDof *dof)
{
if ( this->isGradDof(dof) ) {
int ind = grad_ids.findFirstIndexOf(dof->giveDofID()) - 1;
return this->mGradient(ind) * this->giveTimeFunction()->evaluateAtTime(tStep->giveTargetTime());
}
DofManager *master = this->domain->giveDofManager(this->slavemap[dof->giveDofManager()->giveNumber()]);
if ( mode == VM_Incremental ) {
double val = master->giveDofWithID(dof->giveDofID())->giveUnknown(mode, tStep);
return this->giveUnknown(val, mode, tStep, dof);
}
double val = master->giveDofWithID(dof->giveDofID())->giveUnknown(mode, tStep);
return this->giveUnknown(val, mode, tStep, dof);
}
示例2: check
bool
NodeErrorCheckingRule :: check(Domain *domain, TimeStep *tStep)
{
// Rule doesn't apply yet.
if ( tStep->giveNumber() != tstep ) {
return true;
}
DofManager *dman = domain->giveGlobalDofManager(number);
if ( !dman ) {
if ( domain->giveEngngModel()->isParallel() ) {
return true;
} else {
OOFEM_WARNING("Dof manager %d not found.", number);
return false;
}
}
if ( dman->giveParallelMode() == DofManager_remote || dman->giveParallelMode() == DofManager_null ) {
return true;
}
Dof *dof = dman->giveDofWithID(dofid);
double dmanValue = dof->giveUnknown(mode, tStep);
bool check = checkValue(dmanValue);
if ( !check ) {
OOFEM_WARNING("Check failed in: tstep %d, node %d, dof %d, mode %d:\n"
"value is %.8e, but should be %.8e ( error is %e but tolerance is %e )",
tstep, number, dofid, mode,
dmanValue, value, fabs(dmanValue-value), tolerance );
}
return check;
}
示例3: copyDofManagersToSurfaceData
void
SolutionbasedShapeFunction :: copyDofManagersToSurfaceData(modeStruct *mode, IntArray nodeList, bool isPlus, bool isMinus, bool isZeroBoundary)
{
for ( int i = 1; i <= nodeList.giveSize(); i++ ) {
FloatArray values;
DofManager *dman = mode->myEngngModel->giveDomain(1)->giveDofManager( nodeList.at(i) );
computeBaseFunctionValueAt(values, * dman->giveCoordinates(), this->dofs, * mode->myEngngModel);
for ( int j = 1; j <= this->dofs.giveSize(); j++ ) {
SurfaceDataStruct *surfaceData = new(SurfaceDataStruct);
Dof *d = dman->giveDofWithID( dofs.at(j) );
surfaceData->DofID = ( DofIDItem ) this->dofs.at(j);
surfaceData->DofMan = dman;
surfaceData->isPlus = isPlus;
surfaceData->isMinus = isMinus;
surfaceData->isZeroBoundary = isZeroBoundary;
surfaceData->isFree = d->giveBcId() == 0;
surfaceData->value = values.at(j);
mode->SurfaceData.push_back(surfaceData);
}
}
}
示例4: updateModelWithFactors
void
SolutionbasedShapeFunction :: updateModelWithFactors(modeStruct *m)
{
//Update values with correction factors
for ( size_t j = 0; j < m->SurfaceData.size(); j++ ) {
SurfaceDataStruct *sd = m->SurfaceData.at(j);
DofManager *dman = sd->DofMan;
Dof *d = dman->giveDofWithID(sd->DofID);
double factor = 1.0;
factor = m->SurfaceData.at(j)->isPlus ? m->ap : factor;
factor = m->SurfaceData.at(j)->isMinus ? m->am : factor;
factor = m->SurfaceData.at(j)->isZeroBoundary ? 1.0 : factor;
if ( dynamic_cast< MasterDof * >(d) && m->SurfaceData.at(j)->isFree ) {
double u = m->SurfaceData.at(j)->value;
this->setBoundaryConditionOnDof(dman->giveDofWithID(m->SurfaceData.at(j)->DofID), u * factor);
}
}
}
示例5: giveUnknown
double PrescribedGradientBCPeriodic :: giveUnknown(PrimaryField &field, ValueModeType mode, TimeStep *tStep, ActiveDof *dof)
{
if ( this->isStrainDof(dof) ) {
int ind = strain_id.findFirstIndexOf(dof->giveDofID()) - 1;
return this->mGradient(ind % 3, ind / 3) * this->giveTimeFunction()->evaluateAtTime(tStep->giveTargetTime());
}
DofManager *master = this->domain->giveDofManager(this->slavemap[dof->giveDofManager()->giveNumber()]);
double val = master->giveDofWithID(dof->giveDofID())->giveUnknown(field, mode, tStep);
return this->giveUnknown(val, mode, tStep, dof);
}
示例6: computeLocationArrayOfDofIDs
void
PhaseFieldElement :: computeLocationArrayOfDofIDs( const IntArray &dofIdArray, IntArray &answer )
{
// Routine to extract compute the location array an element given an dofid array.
answer.clear();
NLStructuralElement *el = this->giveElement();
int k = 0;
for ( int i = 1; i <= el->giveNumberOfDofManagers(); i++ ) {
DofManager *dMan = el->giveDofManager( i );
for ( int j = 1; j <= dofIdArray.giveSize( ); j++ ) {
if ( dMan->hasDofID( (DofIDItem) dofIdArray.at( j ) ) ) {
Dof *d = dMan->giveDofWithID( dofIdArray.at( j ) );
answer.followedBy( k + d->giveNumber( ) );
}
}
k += dMan->giveNumberOfDofs( );
}
}
示例7: computeLocationArrayOfDofIDs
void
CoupledFieldsElement :: computeLocationArrayOfDofIDs(const IntArray &dofIdArray, IntArray &answer)
{
// Routine to extract compute the location array an element given an dofid array.
answer.resize(0);
int k = 0;
for ( int i = 1; i <= numberOfDofMans; i++ ) {
DofManager *dMan = this->giveDofManager(i);
for (int j = 1; j <= dofIdArray.giveSize(); j++ ) {
if ( dMan->hasDofID( (DofIDItem) dofIdArray.at(j) ) ) {
Dof *d = dMan->giveDofWithID( dofIdArray.at(j) );
answer.followedBy( k + d->giveNumber() );
//answer.followedBy( k + j );
}
}
k += dMan->giveNumberOfDofs( );
}
}
示例8: computeVectorOfDofIDs
void
CoupledFieldsElement :: computeVectorOfDofIDs(const IntArray &dofIdArray, ValueModeType valueMode, TimeStep *stepN, FloatArray &answer)
{
// Routine to extract the solution vector for an element given an dofid array.
// Size will be numberOfDofs and if a certain dofId does not exist a zero is used as value.
answer.resize( numberOfDofMans * dofIdArray.giveSize() ); // equal number of nodes for all fields
answer.zero();
int k = 1;
for ( int i = 1; i <= numberOfDofMans; i++ ) {
DofManager *dMan = this->giveDofManager(i);
for (int j = 1; j <= dofIdArray.giveSize(); j++ ) {
if ( dMan->hasDofID( (DofIDItem) dofIdArray.at(j) ) ) {
Dof *d = dMan->giveDofWithID( dofIdArray.at(j) );
answer.at(k) = d->giveUnknown(valueMode, stepN);
}
k++;
}
}
}
示例9: outputBoundaryCondition
//.........这里部分代码省略.........
for(size_t i = 0; i < numTracEl; i++) {
std::vector<FloatArray> arcPos;
double xiS = 0.0, xiE = 0.0;
iBC.giveTractionElArcPos(i, xiS, xiE);
arcPos.push_back( FloatArray{xiS} );
arcPos.push_back( FloatArray{xiE} );
arcPosArray.push_back(arcPos);
}
std :: stringstream strArcPos;
strArcPos << "ArcPosGnuplotTime" << time << ".dat";
std :: string nameArcPos = strArcPos.str();
WritePointsToGnuplot(nameArcPos, arcPosArray);
// Traction (normal, tangent)
std::vector< std::vector<FloatArray> > nodeTractionNTArray;
for(size_t i = 0; i < numTracEl; i++) {
std::vector<FloatArray> tractions;
FloatArray tS, tE;
iBC.giveTraction(i, tS, tE, VM_Total, tStep);
FloatArray n,t;
iBC.giveTractionElNormal(i, n, t);
double tSn = tS.dotProduct(n,2);
double tSt = tS.dotProduct(t,2);
tractions.push_back( {tSn ,tSt} );
double tEn = tE.dotProduct(n,2);
double tEt = tE.dotProduct(t,2);
tractions.push_back( {tEn, tEt} );
nodeTractionNTArray.push_back(tractions);
}
std :: stringstream strTractionsNT;
strTractionsNT << "TractionsNormalTangentGnuplotTime" << time << ".dat";
std :: string nameTractionsNT = strTractionsNT.str();
WritePointsToGnuplot(nameTractionsNT, nodeTractionNTArray);
// Boundary points and displacements
IntArray boundaries, bNodes;
iBC.giveBoundaries(boundaries);
std::vector< std::vector<FloatArray> > bndNodes;
for ( int pos = 1; pos <= boundaries.giveSize() / 2; ++pos ) {
Element *e = iBC.giveDomain()->giveElement( boundaries.at(pos * 2 - 1) );
int boundary = boundaries.at(pos * 2);
e->giveInterpolation()->boundaryGiveNodes(bNodes, boundary);
std::vector<FloatArray> bndSegNodes;
// Add the start and end nodes of the segment
DofManager *startNode = e->giveDofManager( bNodes[0] );
FloatArray xS = *(startNode->giveCoordinates());
Dof *dSu = startNode->giveDofWithID(D_u);
double dU = dSu->giveUnknown(VM_Total, tStep);
xS.push_back(dU);
Dof *dSv = startNode->giveDofWithID(D_v);
double dV = dSv->giveUnknown(VM_Total, tStep);
xS.push_back(dV);
bndSegNodes.push_back(xS);
DofManager *endNode = e->giveDofManager( bNodes[1] );
FloatArray xE = *(endNode->giveCoordinates());
Dof *dEu = endNode->giveDofWithID(D_u);
dU = dEu->giveUnknown(VM_Total, tStep);
xE.push_back(dU);
Dof *dEv = endNode->giveDofWithID(D_v);
dV = dEv->giveUnknown(VM_Total, tStep);
xE.push_back(dV);
bndSegNodes.push_back(xE);
bndNodes.push_back(bndSegNodes);
}
std :: stringstream strBndNodes;
strBndNodes << "BndNodesGnuplotTime" << time << ".dat";
std :: string nameBndNodes = strBndNodes.str();
WritePointsToGnuplot(nameBndNodes, bndNodes);
}
}
示例10: outputReactionForces
/////////////////////////////////////////////////
// Help functions
void GnuplotExportModule::outputReactionForces(TimeStep *tStep)
{
// Add sum of reaction forces to arrays
// Compute sum of reaction forces for each BC number
Domain *domain = emodel->giveDomain(1);
StructuralEngngModel *seMod = dynamic_cast<StructuralEngngModel* >(emodel);
if(seMod == NULL) {
OOFEM_ERROR("failed to cast to StructuralEngngModel.");
}
IntArray ielemDofMask;
FloatArray reactions;
IntArray dofManMap, dofidMap, eqnMap;
// test if solution step output is active
if ( !testTimeStepOutput(tStep) ) {
return;
}
// map contains corresponding dofmanager and dofs numbers corresponding to prescribed equations
// sorted according to dofmanger number and as a minor crit. according to dof number
// this is necessary for extractor, since the sorted output is expected
seMod->buildReactionTable(dofManMap, dofidMap, eqnMap, tStep, 1);
// compute reaction forces
seMod->computeReaction(reactions, tStep, 1);
// Find highest index of prescribed dofs
int maxIndPresDof = 0;
for ( int i = 1; i <= dofManMap.giveSize(); i++ ) {
maxIndPresDof = std::max(maxIndPresDof, dofidMap.at(i));
}
int numBC = domain->giveNumberOfBoundaryConditions();
while ( mReactionForceHistory.size() < size_t(numBC) ) {
std::vector<FloatArray> emptyArray;
mReactionForceHistory.push_back( emptyArray );
}
maxIndPresDof = domain->giveNumberOfSpatialDimensions();
while ( mDispHist.size() < size_t(numBC) ) {
std::vector<double> emptyArray;
mDispHist.push_back( emptyArray );
}
for(int bcInd = 0; bcInd < numBC; bcInd++) {
FloatArray fR(maxIndPresDof), disp(numBC);
fR.zero();
for ( int i = 1; i <= dofManMap.giveSize(); i++ ) {
DofManager *dMan = domain->giveDofManager( dofManMap.at(i) );
Dof *dof = dMan->giveDofWithID( dofidMap.at(i) );
if ( dof->giveBcId() == bcInd+1 ) {
fR.at( dofidMap.at(i) ) += reactions.at( eqnMap.at(i) );
// Slightly dirty
BoundaryCondition *bc = dynamic_cast<BoundaryCondition*> (domain->giveBc(bcInd+1));
if ( bc != NULL ) {
disp.at(bcInd+1) = bc->give(dof, VM_Total, tStep->giveTargetTime());
}
///@todo This function should be using the primaryfield instead of asking BCs directly. / Mikael
}
}
mDispHist[bcInd].push_back(disp.at(bcInd+1));
mReactionForceHistory[bcInd].push_back(fR);
// X
FILE * pFileX;
char fileNameX[100];
sprintf(fileNameX, "ReactionForceGnuplotBC%dX.dat", bcInd+1);
pFileX = fopen ( fileNameX , "wb" );
fprintf(pFileX, "#u Fx\n");
for ( size_t j = 0; j < mDispHist[bcInd].size(); j++ ) {
fprintf(pFileX, "%e %e\n", mDispHist[bcInd][j], mReactionForceHistory[bcInd][j].at(1) );
}
fclose(pFileX);
// Y
FILE * pFileY;
char fileNameY[100];
sprintf(fileNameY, "ReactionForceGnuplotBC%dY.dat", bcInd+1);
pFileY = fopen ( fileNameY , "wb" );
fprintf(pFileY, "#u Fx\n");
for ( size_t j = 0; j < mDispHist[bcInd].size(); j++ ) {
if( mReactionForceHistory[bcInd][j].giveSize() >= 2 ) {
fprintf(pFileY, "%e %e\n", mDispHist[bcInd][j], mReactionForceHistory[bcInd][j].at(2) );
}
}
//.........这里部分代码省略.........