64SUPGInternalForceAssembler :: SUPGInternalForceAssembler(
double l,
double d,
double u) :
147SUPGTangentAssembler :: SUPGTangentAssembler(MatResponseMode m,
double l,
double d,
double u,
double a) :
160 answer.
resize(size, size);
230 FluidModel :: initializeFrom(ir);
274 VelocityPressureField = std::make_unique<DofDistributedPrimaryField>(
this, 1, FT_VelocityPressure, 1);
288 std :: shared_ptr< Field > _velocityField = std::make_shared<MaskedPrimaryField>( FT_Velocity, this->
VelocityPressureField.get(), mask );
293 }
else if ( val == 2 ) {
311 OOFEM_ERROR(
"Dof unknowns dictionary does not contain unknown of value mode (%s)", __ValueModeTypeToString(mode));
319 if ( mode == VM_Acceleration ) {
328 }
else if ( mode == VM_Velocity ) {
401SUPG :: giveReynoldsNumber()
412SUPG :: giveSolutionStepWhenIcApply(
bool force)
414 if (
master && (!force)) {
415 return master->giveSolutionStepWhenIcApply();
428SUPG :: giveNextStep()
469 FloatArray *solutionVector = NULL, *prevSolutionVector = NULL;
480 this->
applyIC(_stepWhenIcApply);
494 solutionVector->
resize(neq);
495 prevSolutionVector->resize(neq);
520 *solutionVector = *prevSolutionVector;
541#ifdef SUPG_IMPLICIT_INTERFACE
550 OOFEM_LOG_INFO(
"SUPG info: user time consumed by updating interfaces: %.2fs\n",
timer.getUtime();
566 externalForces.
zero();
576 int currentIterations=0;
586 SparseNonLinearSystemNM :: rlm_total,
596 double _absErrResid, err, avn = 0.0, aivn = 0.0, rnorm;
597 int jj, nnodes = this->
giveDomain(1)->giveNumberOfDofManagers();
613 OOFEM_LOG_INFO(
"Iteration IncrSolErr RelResidErr (Rel_MB ,Rel_MC ) AbsResidErr\n__________________________________________________________________________________\n");
637 auto lhs_copy =
lhs->clone();
643 double __absErr = 0., __relErr = 0.;
645 for (
int i = 1; i <= neq; i++ ) {
646 if ( fabs( __rhs.
at(i) - rhs.
at(i) ) > __absErr ) {
647 __absErr = fabs( __rhs.
at(i) - rhs.
at(i) );
650 if ( fabs( ( __rhs.
at(i) - rhs.
at(i) ) / rhs.
at(i) ) > __relErr ) {
651 __relErr = fabs( ( __rhs.
at(i) - rhs.
at(i) ) / rhs.
at(i) );
655 OOFEM_LOG_INFO(
"SUPG: solver check: absoluteError %e, relativeError %e\n", __absErr, __relErr);
671 #ifdef SUPG_IMPLICIT_INTERFACE
682 OOFEM_LOG_INFO(
"SUPG info: user time consumed by updating interfaces: %.2fs\n",
timer.getUtime() );
697 if ( avn < 1.e-12 ) {
700 err = sqrt(aivn / avn);
713 double rnorm_mb = 0.0, rnorm_mc = 0.0;
714 for (
int i = 1; i <= nnodes; i++ ) {
716 for (
Dof *dof: *inode ) {
717 if ( ( jj = dof->__giveEquationNumber() ) ) {
719 double val = rhs.
at(jj);
720 if ( ( type == V_u ) || ( type == V_v ) || ( type == V_w ) ) {
721 rnorm_mb += val * val;
723 rnorm_mc += val * val;
729 rnorm_mb = sqrt(rnorm_mb);
730 rnorm_mc = sqrt(rnorm_mc);
735 for (
int i = 1; i <= neq; i++ ) {
736 _absErrResid =
max( _absErrResid, fabs( rhs.
at(i) ) );
742 OOFEM_LOG_INFO(
"%-10d %-15e %-15e (%-10e,%-10e) %-15e\n", nite, err, rnorm, rnorm_mb, rnorm_mc, _absErrResid);
757 }
while ( ( rnorm >
rtolv ) && ( _absErrResid >
atolv ) && ( nite <=
maxiter ) );
763 OOFEM_WARNING(
"Convergence not reached, number of iterations: %d\n", nite);
771#ifndef SUPG_IMPLICIT_INTERFACE
798 EngngModel :: updateYourself(tStep);
812 for (
auto &dman : domain->giveDofManagers() ) {
817 for (
auto &elem : domain->giveElements() ) {
818 elem->updateInternalState(tStep);
827 EngngModel :: saveContext(stream, mode);
845 EngngModel :: restoreContext(stream, mode);
861SUPG :: checkConsistency()
869 if (
dynamic_cast< SUPGElement *
>( elem.get() ) == NULL ) {
870 OOFEM_WARNING(
"Element %d has no SUPG base", elem->giveLabel());
875 int ret = EngngModel :: checkConsistency();
883 for (
auto &bc : domain->
giveBcs() ) {
895 for (
auto &ic : domain->
giveIcs() ) {
897 ic->scale(VM_Total, 1. /
uscale);
911SUPG :: updateDomainLinks()
913 EngngModel :: updateDomainLinks();
924 if ( ( type == V_u ) || ( type == V_v ) || ( type == V_w ) ) {
926 }
else if ( type == P_f ) {
954 for (
int j = 1; j <= nman; j++ ) {
957 for (
Dof *dof: *node ) {
960 if ( !dof->isPrimaryDof() ) {
964 int jj = dof->__giveEquationNumber();
967 if ( ( type == V_u ) || ( type == V_v ) || ( type == V_w ) ) {
968 vp_vector->
at(jj) = dof->giveUnknown(VM_Total, _stepWhenIcApply);
970 vp_vector->
at(jj) = dof->giveUnknown(VM_Total, _stepWhenIcApply);
1019SUPG :: evaluateElementStabilizationCoeffs(
TimeStep *tStep)
1030SUPG :: updateElementsForNewInterfacePosition(
TimeStep *tStep)
1034 OOFEM_LOG_DEBUG(
"SUPG :: updateElements - updating elements for interface position");
1059SUPG :: updateDofUnknownsDictionary_predictor(
TimeStep *tStep)
1067 for (
int j = 1; j <= nnodes; j++ ) {
1069 for (
Dof *dof: *inode ) {
1070 double val, prev_val, accel;
1072 if ( !dof->hasBc(tStep) ) {
1075 if ( ( type == V_u ) || ( type == V_v ) || ( type == V_w ) ) {
1076 val = prev_val + dt * accel;
1081 dof->updateUnknownsDictionary(tStep, VM_Total, val);
1082 dof->updateUnknownsDictionary(tStep, VM_Acceleration, accel);
1084 val = dof->giveBcValue(VM_Total, tStep);
1085 dof->updateUnknownsDictionary(tStep, VM_Total, val);
1086 dof->updateUnknownsDictionary(tStep, VM_Acceleration, 0.0);
1095SUPG :: updateDofUnknownsDictionary_corrector(
TimeStep *tStep)
1102 for (
int j = 1; j <= nnodes; j++ ) {
1104 for (
Dof *iDof: *inode ) {
1106 if ( !iDof->hasBc(tStep) ) {
1107 double val, prev_val;
1108 prev_val = iDof->giveUnknown(VM_Total, tStep);
1109 if ( ( type == V_u ) || ( type == V_v ) || ( type == V_w ) ) {
1115 iDof->updateUnknownsDictionary(tStep, VM_Total, val);
1117 prev_val = iDof->giveUnknown(VM_Acceleration, tStep);
1119 iDof->updateUnknownsDictionary(tStep, VM_Acceleration, val);
1127SUPG :: giveUnknownDictHashIndx(ValueModeType mode,
TimeStep *tStep)
1130 return ( tStep->
giveNumber() % 2 ) * 100 + mode;
1143 for (
Dof *iDof: *node ) {
1144 if ( !iDof->isPrimaryDof() ) {
1148 int jj = iDof->__giveEquationNumber();
1152 if ( ( type == V_u ) || ( type == V_v ) || ( type == V_w ) ) {
1153 solutionVector.
at(jj) += dt * _accelerationVector.
at(jj);
1160 int ndofman = elem->giveNumberOfInternalDofManagers();
1161 for (
int ji = 1; ji <= ndofman; ji++ ) {
1162 DofManager *dofman = elem->giveInternalDofManager(ji);
1163 for (
Dof *iDof: *dofman ) {
1164 if ( !iDof->isPrimaryDof() ) {
1168 int jj = iDof->__giveEquationNumber();
1172 if ( ( type == V_u ) || ( type == V_v ) || ( type == V_w ) ) {
1173 solutionVector.
at(jj) += dt * _accelerationVector.
at(jj);
1192 for (
Dof *iDof: *node ) {
1193 if ( !iDof->isPrimaryDof() ) {
1197 int jj = iDof->__giveEquationNumber();
1201 if ( ( type == V_u ) || ( type == V_v ) || ( type == V_w ) ) {
1211 int ndofman = elem->giveNumberOfInternalDofManagers();
1212 for (
int ji = 1; ji <= ndofman; ji++ ) {
1213 DofManager *dofman = elem->giveInternalDofManager(ji);
1214 for (
Dof *iDof: *dofman ) {
1215 if ( !iDof->isPrimaryDof() ) {
1219 int jj = iDof->__giveEquationNumber();
1223 if ( ( type == V_u ) || ( type == V_v ) || ( type == V_w ) ) {
1235#define __VOF_TRESHOLD 1.e-5
1239#define __NODE_OUT_ACTIVE 2
1240#define __NODE_INTERPOL_CANDIDATE 3
#define REGISTER_EngngModel(class)
DofIDItem giveDofID() const
virtual int __giveEquationNumber() const =0
virtual void giveUnknowns(FloatArray &masterUnknowns, ValueModeType mode, TimeStep *tStep)
virtual void printSingleOutputAt(FILE *file, TimeStep *tStep, char ch, ValueModeType mode, double scale=1.0)
std ::vector< std ::unique_ptr< DofManager > > & giveDofManagers()
int giveNumberOfDofManagers() const
Returns number of dof managers in domain.
Function * giveFunction(int n)
std ::vector< std ::unique_ptr< GeneralBoundaryCondition > > & giveBcs()
DofManager * giveDofManager(int n)
std ::vector< std ::unique_ptr< Element > > & giveElements()
std ::vector< std ::unique_ptr< InitialCondition > > & giveIcs()
virtual void updateYourself(TimeStep *tStep)
virtual int computeNumberOfDofs()
int giveNumberOfTimeStepWhenIcApply()
Returns the time step number, when initial conditions should apply.
std ::vector< std ::unique_ptr< Domain > > domainList
List of problem domains.
virtual TimeStep * giveCurrentStep(bool force=false)
virtual int giveNumberOfDomainEquations(int di, const UnknownNumberingScheme &num)
EngngModelContext * giveContext()
Context requesting service.
std ::unique_ptr< TimeStep > previousStep
Previous time step.
MetaStep * giveCurrentMetaStep()
Returns current meta step.
int ndomains
Number of receiver domains.
Domain * giveDomain(int n)
std ::unique_ptr< TimeStep > currentStep
Current time step.
EngngModelTimer timer
E-model timer.
@ InternalForcesExchangeTag
virtual TimeStep * givePreviousStep(bool force=false)
EngngModel * master
Master e-model; if defined receiver is in maintained (slave) mode.
void initMetaStepAttributes(MetaStep *mStep)
int updateSharedDofManagers(FloatArray &answer, const UnknownNumberingScheme &s, int ExchangeTag)
std ::unique_ptr< TimeStep > stepWhenIcApply
Solution step when IC (initial conditions) apply.
void assembleVector(FloatArray &answer, TimeStep *tStep, const VectorAssembler &va, ValueModeType mode, const UnknownNumberingScheme &s, Domain *domain, FloatArray *eNorms=NULL)
void computeVectorOfPressures(ValueModeType mode, TimeStep *tStep, FloatArray &pressures)
virtual void updateStabilizationCoeffs(TimeStep *tStep)
void computeVectorOfVelocities(ValueModeType mode, TimeStep *tStep, FloatArray &velocities)
void registerField(FieldPtr eField, FieldType key)
double computeNorm() const
void assemble(const FloatArray &fe, const IntArray &loc)
void beDifferenceOf(const FloatArray &a, const FloatArray &b)
void zero()
Zeroes all coefficients of receiver.
void beProductOf(const FloatMatrix &aMatrix, const FloatArray &anArray)
void add(const FloatArray &src)
void resize(Index rows, Index cols)
void zero()
Zeroes all coefficient of receiver.
bool isNotEmpty() const
Tests for empty matrix.
void assemble(const FloatMatrix &src, const IntArray &loc)
FluidModel(int i, EngngModel *master)
virtual double evaluateAtTime(double t)
virtual void computeAdvectionDerivativeTerm_MC(FloatMatrix &answer, TimeStep *tStep)=0
virtual void computeLSICStabilizationTerm_MB(FloatMatrix &answer, TimeStep *tStep)=0
virtual void computeDiffusionDerivativeTerm_MB(FloatMatrix &answer, MatResponseMode mode, TimeStep *tStep)=0
virtual void giveLocalPressureDofMap(IntArray &map)
virtual void computeBCLhsPressureTerm_MB(FloatMatrix &answer, TimeStep *tStep)
virtual void computeAdvectionTerm_MB(FloatArray &answer, TimeStep *tStep)=0
virtual void computeAdvectionTerm_MC(FloatArray &answer, TimeStep *tStep)=0
virtual void updateElementForNewInterfacePosition(TimeStep *tStep)
virtual void computeDiffusionTerm_MB(FloatArray &answer, TimeStep *tStep)=0
virtual void computeAdvectionDerivativeTerm_MB(FloatMatrix &answer, TimeStep *tStep)=0
virtual void computeDiffusionDerivativeTerm_MC(FloatMatrix &answer, TimeStep *tStep)=0
virtual void computeLinearAdvectionTerm_MC(FloatMatrix &answer, TimeStep *tStep)=0
virtual void computeBCLhsTerm_MB(FloatMatrix &answer, TimeStep *tStep)
virtual void computeBCLhsPressureTerm_MC(FloatMatrix &answer, TimeStep *tStep)
virtual void computeDiffusionTerm_MC(FloatArray &answer, TimeStep *tStep)=0
virtual void computeAccelerationTerm_MC(FloatMatrix &answer, TimeStep *tStep)=0
virtual void giveLocalVelocityDofMap(IntArray &map)
virtual double computeCriticalTimeStep(TimeStep *tStep)=0
Computes the critical time increment.
virtual void computePressureTerm_MC(FloatMatrix &answer, TimeStep *tStep)=0
virtual void computePressureTerm_MB(FloatMatrix &answer, TimeStep *tStep)=0
virtual void computeAccelerationTerm_MB(FloatMatrix &answer, TimeStep *tStep)=0
void updateInternalState(TimeStep *tStep) override
int maxiter
Max number of iterations.
TimeStep * giveSolutionStepWhenIcApply(bool force=false) override
void updateInternalState(TimeStep *tStep)
std ::unique_ptr< SparseLinearSystemNM > nMethod
Numerical method used to solve the problem.
int requiresUnknownsDictionaryUpdate() override
std ::unique_ptr< SparseMtrx > lhs
void updateInternalRHS(FloatArray &answer, TimeStep *tStep, Domain *d, FloatArray *eNorm) override
SparseMtrxType sparseMtrxType
double Re
Reynolds number.
int giveUnknownDictHashIndx(ValueModeType mode, TimeStep *tStep) override
std ::unique_ptr< MaterialInterface > materialInterface
std ::unique_ptr< PrimaryField > VelocityPressureField
void updateSolutionVectors(FloatArray &solutionVector, FloatArray &accelerationVector, FloatArray &incrementalSolutionVector, TimeStep *tStep)
void updateElementsForNewInterfacePosition(TimeStep *tStep)
LinSystSolverType solverType
double alpha
Integration constant.
FloatArray incrementalSolutionVector
FloatArray accelerationVector
void updateDofUnknownsDictionary(DofManager *dman, TimeStep *tStep) override
NumericalMethod * giveNumericalMethod(MetaStep *mStep) override
Returns reference to receiver's numerical method.
FloatArray internalForces
double atolv
Convergence tolerance.
void updateDofUnknownsDictionary_predictor(TimeStep *tStep)
void evaluateElementStabilizationCoeffs(TimeStep *tStep)
double giveVariableScale(VarScaleType varId) override
Returns the scale factor for given variable type.
void updateSolutionVectors_predictor(FloatArray &solutionVector, FloatArray &accelerationVector, TimeStep *tStep)
void updateDofUnknownsDictionary_corrector(TimeStep *tStep)
void applyIC(TimeStep *tStep)
virtual void zero()=0
Zeroes the receiver.
void incrementStateCounter()
Updates solution state counter.
ConvergedReason convergedReason
Status of solution step (Converged,.
double giveTimeIncrement()
Returns solution step associated time increment.
int giveNumber()
Returns receiver's number.
TimeStep * givePreviousStep()
Returns pointer to previous solution step.
double getUtime()
Returns total user time elapsed in seconds.
#define _IFT_EngngModel_lstype
#define _IFT_EngngModel_smtype
#define OOFEM_WARNING(...)
#define OOFEM_LOG_INFO(...)
#define OOFEM_LOG_DEBUG(...)
FloatArrayF< N > min(const FloatArrayF< N > &a, const FloatArrayF< N > &b)
VarScaleType
Type determining the scale corresponding to particular variable.
FloatArrayF< N > assemble(const FloatArrayF< M > &x, int const (&c)[M])
Assemble components into zero matrix.
FloatArrayF< N > max(const FloatArrayF< N > &a, const FloatArrayF< N > &b)
ClassFactory & classFactory
#define _IFT_SUPG_stopmaxiter
#define _IFT_SUPG_deltatFunction
#define _IFT_SUPG_maxiter
#define _IFT_SUPG_scaleflag