50DofDistributedPrimaryField :: DofDistributedPrimaryField(
EngngModel *a,
int idomain,
56DofDistributedPrimaryField :: ~DofDistributedPrimaryField()
60DofDistributedPrimaryField :: giveUnknownValue(Dof *dof, ValueModeType mode, TimeStep *tStep)
62 if ( mode == VM_Total ) {
63 return dof->giveUnknownsDictionaryValue(tStep, mode);
65 double val1 = dof->giveUnknownsDictionaryValue(tStep, VM_Total);
66 double val0 = dof->giveUnknownsDictionaryValue(tStep->givePreviousStep(), VM_Total);
67 if ( mode == VM_Velocity ) {
68 return (val1 - val0) / tStep->giveTimeIncrement();
69 }
else if ( mode == VM_Intermediate || mode == VM_TotalIntrinsic ) {
70 return this->alpha * val1 + (1-this->alpha) * val0;
71 }
else if ( mode == VM_Incremental ) {
82DofDistributedPrimaryField :: initialize(ValueModeType mode, TimeStep *tStep, FloatArray &answer,
const UnknownNumberingScheme &s)
84 Domain *d = emodel->giveDomain(domainIndx);
85 int neq = emodel->giveNumberOfDomainEquations(domainIndx, s);
90 for (
auto &node : d->giveDofManagers() ) {
91 for ( Dof *dof: *node ) {
92 if ( !dof->isPrimaryDof() )
continue;
93 int eqNum = dof->giveEquationNumber(s);
95 answer.at(eqNum) = dof->giveUnknownsDictionaryValue(tStep, mode);
100 for (
auto &elem : d->giveElements() ) {
101 int ndman = elem->giveNumberOfInternalDofManagers();
102 for (
int i = 1; i <= ndman; i++ ) {
103 for (
auto &dof : *elem->giveInternalDofManager(i) ) {
104 if ( !dof->isPrimaryDof() )
continue;
105 int eqNum = dof->giveEquationNumber(s);
107 answer.at(eqNum) = dof->giveUnknownsDictionaryValue(tStep, mode);
113 for (
auto &bc : d->giveBcs() ) {
114 int ndman = bc->giveNumberOfInternalDofManagers();
115 for (
int i = 1; i <= ndman; i++ ) {
116 for (
auto &dof : *bc->giveInternalDofManager(i) ) {
117 if ( !dof->isPrimaryDof() )
continue;
118 int eqNum = dof->giveEquationNumber(s);
120 answer.at(eqNum) = dof->giveUnknownsDictionaryValue(tStep, mode);
129DofDistributedPrimaryField :: update(ValueModeType mode, TimeStep *tStep,
const FloatArray &vectorToStore,
const UnknownNumberingScheme &s)
131 Domain *d = emodel->giveDomain(domainIndx);
133 auto set_values = [&mode, &tStep, &vectorToStore, &s](DofManager &dman) {
134 for ( Dof *dof: dman ) {
135 if ( !dof->isPrimaryDof() )
continue;
136 int eqNum = dof->giveEquationNumber(s);
138 dof->updateUnknownsDictionary(tStep, VM_Total, vectorToStore.at(eqNum));
143 for (
auto &node : d->giveDofManagers() ) {
147 for (
auto &elem : d->giveElements() ) {
148 int ndman = elem->giveNumberOfInternalDofManagers();
149 for (
int i = 1; i <= ndman; i++ ) {
150 set_values(*elem->giveInternalDofManager(i));
154 for (
auto &bc : d->giveBcs() ) {
155 int ndman = bc->giveNumberOfInternalDofManagers();
156 for (
int i = 1; i <= ndman; i++ ) {
157 set_values(*bc->giveInternalDofManager(i));
164DofDistributedPrimaryField :: applyDefaultInitialCondition()
166 Domain *d = emodel->giveDomain(domainIndx);
167 TimeStep *tStep = emodel->giveSolutionStepWhenIcApply();
169 for (
auto &dman : d->giveDofManagers() ) {
170 if ( dman->isNull() )
continue;
171 for (
auto &dof : *dman ) {
172 dof->updateUnknownsDictionary(tStep, VM_Total, 0.);
173 int icid = dof->giveIcId();
174 if ( icid > 0 && dof->isPrimaryDof() ) {
175 InitialCondition *ic = d->giveIc(icid);
176 if ( ic->hasConditionOn(VM_Total) ) {
177 FloatArray c = dman->giveCoordinates();
178 double val = ic->give(VM_Total, c);
179 dof->updateUnknownsDictionary(tStep, VM_Total, val);
185 for (
auto &elem : d->giveElements() ) {
186 if ( elem->giveParallelMode() == Element_remote )
continue;
187 int ndman = elem->giveNumberOfInternalDofManagers();
188 for (
int i = 1; i <= ndman; i++ ) {
189 for (
auto &dof : *elem->giveInternalDofManager(i) ) {
190 dof->updateUnknownsDictionary(tStep, VM_Total, 0.);
195 for (
auto &bc : d->giveBcs() ) {
196 int ndman = bc->giveNumberOfInternalDofManagers();
197 for (
int i = 1; i <= ndman; i++ ) {
198 if ( bc->giveInternalDofManager(i)->isNull() )
continue;
199 for (
auto &dof : *bc->giveInternalDofManager(i) ) {
200 dof->updateUnknownsDictionary(tStep, VM_Total, 0.);
206 for (
auto &ic : d->giveIcs() ) {
207 this->applyInitialCondition(*ic);
212DofDistributedPrimaryField :: applyInitialCondition(InitialCondition &ic)
214 if ( ic.giveSetNumber() == 0 ) {
218 Domain *d = ic.giveDomain();
219 Set *set = d->giveSet(ic.giveSetNumber());
220 TimeStep *tStep = emodel->giveSolutionStepWhenIcApply();
224 for (
int inode : set->giveNodeList() ) {
225 DofManager *dman = d->giveDofManager(inode);
226 if ( dman->isNull() )
continue;
228 if ( ic.hasConditionOn(VM_Total) ) {
229 FloatArray c = dman->giveCoordinates();
230 tot0 = ic.give(VM_Total, c);
233 Not relevant
for this time discretization
235 if ( ic.hasConditionOn(VM_Incremental) ) {
236 tot1 = tot0 - ic.give(VM_Incremental);
237 }
else if ( ic.hasConditionOn(VM_Velocity) ) {
238 tot1 = tot0 - ic.give(VM_Velocity) * tStep->giveTimeIncrement();
243 for (
int dofid : ic.giveDofIDs() ) {
244 if ( dman->findDofWithDofId((DofIDItem)dofid) != dman->end() ) {
245 Dof *dof = dman->giveDofWithID(dofid);
247 dof->updateUnknownsDictionary(tStep, VM_Total, tot0);
255DofDistributedPrimaryField :: applyBoundaryCondition(TimeStep *tStep)
257 Domain *d = emodel->giveDomain(domainIndx);
258 for (
auto &dman : d->giveDofManagers() ) {
259 if ( dman->isNull() )
continue;
260 for (
auto &dof : *dman ) {
261 if ( dof->hasBc(tStep) && dof->isPrimaryDof() ) {
262 int bcid = dof->giveBcId();
263 double val =
static_cast< BoundaryCondition*
>(d->giveBc(bcid))->give(dof, VM_Total, tStep->giveTargetTime());
264 dof->updateUnknownsDictionary(tStep, VM_Total, val);
269 for (
auto &bc : d->giveBcs() ) {
270 if ( bc->isImposed(tStep) ) {
271 BoundaryCondition *dbc =
dynamic_cast< BoundaryCondition*
>(bc.get());
272 ActiveBoundaryCondition *abc =
dynamic_cast< ActiveBoundaryCondition*
>(bc.get());
273 if ( dbc && dbc->isImposed(tStep) ) {
274 this->applyBoundaryCondition(*dbc, tStep);
276 for (
int i = 1; i <= abc->giveNumberOfInternalDofManagers(); i++ ) {
277 if ( abc->giveInternalDofManager(i)->isNull() )
continue;
278 for (
auto &dof : *abc->giveInternalDofManager(i) ) {
279 if ( dof->isPrimaryDof() && abc->hasBc(dof, tStep) ) {
280 dof->updateUnknownsDictionary( tStep, VM_Total, abc->giveBcValue(dof, VM_Total, tStep) );
291DofDistributedPrimaryField :: applyBoundaryCondition(BoundaryCondition &bc, TimeStep *tStep)
293 if ( bc.giveSetNumber() == 0 ) {
297 Domain *d = bc.giveDomain();
298 Set *set = d->giveSet(bc.giveSetNumber());
299 for (
int inode : set->giveNodeList() ) {
300 DofManager *dman = d->giveDofManager(inode);
301 if ( dman->isNull() )
continue;
302 for (
auto &dofid : bc.giveDofIDs() ) {
303 if ( !dman->hasDofID((DofIDItem)dofid) ) {
306 Dof *dof = dman->giveDofWithID(dofid);
307 if ( dof->isPrimaryDof() ) {
308 dof->updateUnknownsDictionary( tStep, VM_Total, bc.give(dof, VM_Total, tStep->giveTargetTime()) );
316DofDistributedPrimaryField :: setInitialGuess(DofManager &dman, TimeStep *tStep, TimeStep *prev)
318 for (
auto &dof : dman ) {
319 double val = dof->giveUnknownsDictionaryValue( prev, VM_Total );
320 dof->updateUnknownsDictionary( tStep, VM_Total, val );
325DofDistributedPrimaryField :: advanceSolution(TimeStep *tStep)
328 Domain *d = emodel->giveDomain(1);
329 TimeStep *prev = tStep->givePreviousStep();
330 for (
auto &dman : d->giveDofManagers() ) {
331 if ( dman->isNull() )
continue;
332 this->setInitialGuess(*dman, tStep, prev);
335 for (
auto &elem : d->giveElements() ) {
336 if ( elem->giveParallelMode() == Element_remote )
continue;
337 int ndman = elem->giveNumberOfInternalDofManagers();
338 for (
int i = 1; i <= ndman; i++ ) {
339 this->setInitialGuess(*elem->giveInternalDofManager(i), tStep, prev);
343 for (
auto &bc : d->giveBcs() ) {
344 int ndman = bc->giveNumberOfInternalDofManagers();
345 for (
int i = 1; i <= ndman; i++ ) {
346 if ( bc->giveInternalDofManager(i)->isNull() )
continue;
347 this->setInitialGuess(*bc->giveInternalDofManager(i), tStep, prev);
352 this->applyBoundaryCondition(tStep);
FieldType
Physical type of field.