160 answer.
resize(size, size);
301 mask = {V_u, V_v, V_w};
308 }
else if ( val == 2 ) {
336 if ( mode == VM_Acceleration ) {
345 }
else if ( mode == VM_Velocity ) {
361 static_cast< FMElement *
>( elem.get() )->updateStabilizationCoeffs(tStep);
400 if (
master && (!force)) {
434 dt =
min( dt, static_cast< SUPGElement & >( *elem ).computeCriticalTimeStep(
previousStep.get()) );
456 FloatArray *solutionVector = NULL, *prevSolutionVector = NULL;
466 this->
applyIC(stepWhenIcApply);
480 solutionVector->
resize(neq);
481 prevSolutionVector->resize(neq);
506 *solutionVector = *prevSolutionVector;
527 #ifdef SUPG_IMPLICIT_INTERFACE 552 externalForces.
zero();
562 int currentIterations;
582 double _absErrResid, err, avn = 0.0, aivn = 0.0, rnorm;
588 internalForces.
zero();
599 OOFEM_LOG_INFO(
"Iteration IncrSolErr RelResidErr (Rel_MB ,Rel_MC ) AbsResidErr\n__________________________________________________________________________________\n");
629 double __absErr = 0., __relErr = 0.;
631 for (
int i = 1; i <= neq; i++ ) {
632 if ( fabs( __rhs.
at(i) - rhs.
at(i) ) > __absErr ) {
633 __absErr = fabs( __rhs.
at(i) - rhs.
at(i) );
636 if ( fabs( ( __rhs.
at(i) - rhs.
at(i) ) / rhs.
at(i) ) > __relErr ) {
637 __relErr = fabs( ( __rhs.
at(i) - rhs.
at(i) ) / rhs.
at(i) );
641 OOFEM_LOG_INFO(
"SUPG: solver check: absoluteError %e, relativeError %e\n", __absErr, __relErr);
657 #ifdef SUPG_IMPLICIT_INTERFACE 683 if ( avn < 1.e-12 ) {
686 err = sqrt(aivn / avn);
692 internalForces.
zero();
699 double rnorm_mb = 0.0, rnorm_mc = 0.0;
700 for (
int i = 1; i <= nnodes; i++ ) {
702 for (
Dof *dof: *inode ) {
703 if ( ( jj = dof->__giveEquationNumber() ) ) {
705 double val = rhs.
at(jj);
706 if ( ( type == V_u ) || ( type == V_v ) || ( type == V_w ) ) {
707 rnorm_mb += val * val;
709 rnorm_mc += val * val;
715 rnorm_mb = sqrt(rnorm_mb);
716 rnorm_mc = sqrt(rnorm_mc);
721 for (
int i = 1; i <= neq; i++ ) {
722 _absErrResid =
max( _absErrResid, fabs( rhs.
at(i) ) );
728 OOFEM_LOG_INFO(
"%-10d %-15e %-15e (%-10e,%-10e) %-15e\n", nite, err, rnorm, rnorm_mb, rnorm_mc, _absErrResid);
737 internalForces.
zero();
743 }
while ( ( rnorm >
rtolv ) && ( _absErrResid >
atolv ) && ( nite <=
maxiter ) );
748 OOFEM_WARNING(
"Convergence not reached, number of iterations: %d\n", nite);
755 #ifndef SUPG_IMPLICIT_INTERFACE 795 for (
auto &dman : domain->giveDofManagers() ) {
800 for (
auto &elem : domain->giveElements() ) {
801 elem->updateInternalState(tStep);
870 if ( dynamic_cast< SUPGElement * >( elem.get() ) == NULL ) {
871 OOFEM_WARNING(
"Element %d has no SUPG base", elem->giveLabel());
884 for (
auto &bc : domain->
giveBcs() ) {
896 for (
auto &ic : domain->
giveIcs() ) {
898 ic->scale(VM_Total, 1. /
uscale);
925 if ( ( type == V_u ) || ( type == V_v ) || ( type == V_w ) ) {
927 }
else if ( type == P_f ) {
955 for (
int j = 1; j <= nman; j++ ) {
958 for (
Dof *dof: *node ) {
961 if ( !dof->isPrimaryDof() ) {
965 int jj = dof->__giveEquationNumber();
968 if ( ( type == V_u ) || ( type == V_v ) || ( type == V_w ) ) {
969 vp_vector->
at(jj) = dof->giveUnknown(VM_Total, stepWhenIcApply);
971 vp_vector->
at(jj) = dof->giveUnknown(VM_Total, stepWhenIcApply);
1035 OOFEM_LOG_DEBUG(
"SUPG :: updateElements - updating elements for interface position");
1068 for (
int j = 1; j <= nnodes; j++ ) {
1070 for (
Dof *dof: *inode ) {
1071 double val, prev_val, accel;
1073 if ( !dof->hasBc(tStep) ) {
1076 if ( ( type == V_u ) || ( type == V_v ) || ( type == V_w ) ) {
1077 val = prev_val + deltaT * accel;
1082 dof->updateUnknownsDictionary(tStep, VM_Total, val);
1083 dof->updateUnknownsDictionary(tStep, VM_Acceleration, accel);
1085 val = dof->giveBcValue(VM_Total, tStep);
1086 dof->updateUnknownsDictionary(tStep, VM_Total, val);
1087 dof->updateUnknownsDictionary(tStep, VM_Acceleration, 0.0);
1103 for (
int j = 1; j <= nnodes; j++ ) {
1105 for (
Dof *iDof: *inode ) {
1107 if ( !iDof->hasBc(tStep) ) {
1108 double val, prev_val;
1109 prev_val = iDof->giveUnknown(VM_Total, tStep);
1110 if ( ( type == V_u ) || ( type == V_v ) || ( type == V_w ) ) {
1116 iDof->updateUnknownsDictionary(tStep, VM_Total, val);
1118 prev_val = iDof->giveUnknown(VM_Acceleration, tStep);
1120 iDof->updateUnknownsDictionary(tStep, VM_Acceleration, val);
1131 return ( tStep->
giveNumber() % 2 ) * 100 + mode;
1147 if ( !iDof->isPrimaryDof() ) {
1151 int jj = iDof->__giveEquationNumber();
1155 if ( ( type == V_u ) || ( type == V_v ) || ( type == V_w ) ) {
1156 solutionVector.
at(jj) += deltaT * accelerationVector.
at(jj);
1163 int ndofman = elem->giveNumberOfInternalDofManagers();
1164 for (
int ji = 1; ji <= ndofman; ji++ ) {
1165 DofManager *dofman = elem->giveInternalDofManager(ji);
1166 for (
Dof *iDof: *dofman ) {
1167 if ( !iDof->isPrimaryDof() ) {
1171 int jj = iDof->__giveEquationNumber();
1175 if ( ( type == V_u ) || ( type == V_v ) || ( type == V_w ) ) {
1176 solutionVector.
at(jj) += deltaT * accelerationVector.
at(jj);
1191 accelerationVector.
add(incrementalSolutionVector);
1196 if ( !iDof->isPrimaryDof() ) {
1200 int jj = iDof->__giveEquationNumber();
1204 if ( ( type == V_u ) || ( type == V_v ) || ( type == V_w ) ) {
1205 solutionVector.
at(jj) += deltaT *
alpha * incrementalSolutionVector.
at(jj);
1207 solutionVector.
at(jj) += incrementalSolutionVector.
at(jj);
1214 int ndofman = elem->giveNumberOfInternalDofManagers();
1215 for (
int ji = 1; ji <= ndofman; ji++ ) {
1216 DofManager *dofman = elem->giveInternalDofManager(ji);
1217 for (
Dof *iDof: *dofman ) {
1218 if ( !iDof->isPrimaryDof() ) {
1222 int jj = iDof->__giveEquationNumber();
1226 if ( ( type == V_u ) || ( type == V_v ) || ( type == V_w ) ) {
1227 solutionVector.
at(jj) += deltaT *
alpha * incrementalSolutionVector.
at(jj);
1229 solutionVector.
at(jj) += incrementalSolutionVector.
at(jj);
1238 #define __VOF_TRESHOLD 1.e-5 1240 #define __NODE_OUT 0 1242 #define __NODE_OUT_ACTIVE 2 1243 #define __NODE_INTERPOL_CANDIDATE 3 EngngModelTimer timer
E-model timer.
virtual void updateDofUnknownsDictionary(DofManager *dman, TimeStep *tStep)
Updates necessary values in Dofs unknown dictionaries.
LinSystSolverType
The values of this type should be related not to specific solvers, but more to specific packages that...
The representation of EngngModel default unknown numbering.
#define NM_Success
Numerical method exited with success.
virtual double giveUnknownComponent(ValueModeType mode, TimeStep *tStep, Domain *d, Dof *dof)
Returns requested unknown.
virtual void printDofOutputAt(FILE *stream, Dof *iDof, TimeStep *tStep)
DOF printing routine.
std::unique_ptr< TimeStep > currentStep
Current time step.
virtual void computePressureTerm_MB(FloatMatrix &answer, TimeStep *tStep)=0
Computes pressure terms for momentum balance equations(s).
virtual void computeAdvectionDerivativeTerm_MC(FloatMatrix &answer, TimeStep *tStep)=0
Computes the derivative of advection terms for mass conservation equation with respect to nodal veloc...
void initMetaStepAttributes(MetaStep *mStep)
Update e-model attributes attributes according to step metaStep attributes.
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode)
Stores the state of model to output stream.
void updateElementsForNewInterfacePosition(TimeStep *tStep)
virtual int computeNumberOfDofs()
Computes or simply returns total number of element's local DOFs.
virtual int giveNumberOfDomainEquations(int di, const UnknownNumberingScheme &num)
Returns number of equations for given domain in active (current time step) time step.
Abstract class representing subset of DOFs (identified by DofId mask) of primary field.
virtual TimeStep * giveSolutionStepWhenIcApply(bool force=false)
Returns the solution step when Initial Conditions (IC) apply.
virtual TimeStep * giveNextStep()
Returns next time step (next to current step) of receiver.
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description in input reader.
virtual void updateDomainLinks()
Updates domain links after the domains of receiver have changed.
int giveNumberOfDofManagers() const
Returns number of dof managers in domain.
Base class for all matrices stored in sparse format.
SparseMtrxType sparseMtrxType
virtual void computeLSICStabilizationTerm_MB(FloatMatrix &answer, TimeStep *tStep)=0
Computes SLIC stabilization term for momentum balance equation(s).
LinSystSolverType solverType
SparseMtrx * createSparseMtrx(SparseMtrxType type)
Creates new instance of sparse matrix corresponding to given keyword.
Abstract class representing field of primary variables (those, which are unknown and are typically as...
virtual void computeLinearAdvectionTerm_MC(FloatMatrix &answer, TimeStep *tStep)=0
Computes the linear advection term for mass conservation equation.
The purpose of DataStream abstract class is to allow to store/restore context to different streams...
contextIOResultType storeYourself(DataStream &stream) const
FloatArray internalForces
std::vector< std::unique_ptr< Domain > > domainList
List of problem domains.
std::unique_ptr< TimeStep > previousStep
Previous time step.
virtual void updateInternalState(TimeStep *tStep)
Updates element state after equilibrium in time step has been reached.
double & at(int i)
Coefficient access function.
std::unique_ptr< SparseMtrx > lhs
int max(int i, int j)
Returns bigger value form two given decimals.
virtual void updateYourself(TimeStep *tStep)
Updates internal state after finishing time step.
virtual int requiresUnknownsDictionaryUpdate()
Indicates if EngngModel requires Dofs dictionaries to be updated.
ValueModeType
Type representing the mode of UnknownType or CharType, or similar types.
VarScaleType
Type determining the scale corresponding to particular variable.
Base class for fluid problems.
std::unique_ptr< SparseLinearSystemNM > nMethod
Numerical method used to solve the problem.
This base class is an abstraction for numerical algorithm.
virtual void updateElementForNewInterfacePosition(TimeStep *tStep)
std::unique_ptr< TimeStep > stepWhenIcApply
Solution step when IC (initial conditions) apply.
virtual void updateYourself(TimeStep *tStep)
Updates element state after equilibrium in time step has been reached.
#define _IFT_SUPG_deltatFunction
void incrementStateCounter()
Updates solution state counter.
Abstract base class for all finite elements.
virtual int checkConsistency()
Allows programmer to test some receiver's internal data, before computation begins.
Base class for dof managers.
std::vector< std::unique_ptr< DofManager > > & giveDofManagers()
virtual void giveLocalPressureDofMap(IntArray &map)
virtual int __giveEquationNumber() const =0
Returns equation number of receiver, usually assigned by emodel.
virtual void updateComponent(TimeStep *tStep, NumericalCmpn cmpn, Domain *d)
Updates components mapped to numerical method if necessary during solution process.
General stabilized SUPG/PSPG element for CFD analysis.
FieldManager * giveFieldManager()
SUPGTangentAssembler(MatResponseMode m, double l, double d, double u, double a)
REGISTER_EngngModel(ProblemSequence)
virtual void solveYourselfAt(TimeStep *tStep)
Solves problem for given time step.
unsigned long NM_Status
Mask defining NumMetod Status; which can be asked after finishing computation by Numerical Method...
#define OOFEM_LOG_DEBUG(...)
Class implementing an array of integers.
MatResponseMode
Describes the character of characteristic material matrix.
virtual void giveUnknowns(FloatArray &masterUnknowns, ValueModeType mode, TimeStep *tStep)
The key method of class Dof.
virtual void updateStabilizationCoeffs(TimeStep *tStep)
Updates the stabilization coefficients used for CBS and SUPG algorithms.
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description in input reader.
void beDifferenceOf(const FloatArray &a, const FloatArray &b)
Sets receiver to be a - b.
double giveTimeIncrement()
Returns solution step associated time increment.
int maxiter
Max number of iterations.
bool isTheFirstStep()
Check if receiver is first step.
Class representing field of primary variables, which are typically allocated on nodes.
bool isNotEmpty() const
Tests for empty matrix.
virtual void assemble(SparseMtrx &answer, TimeStep *tStep, const MatrixAssembler &ma, const UnknownNumberingScheme &s, Domain *domain)
Assembles characteristic matrix of required type into given sparse matrix.
virtual void computeVectorOfPressures(ValueModeType mode, TimeStep *tStep, FloatArray &pressures)
void updateSolutionVectors(FloatArray &solutionVector, FloatArray &accelerationVector, FloatArray &incrementalSolutionVector, TimeStep *tStep)
virtual void computeDiffusionTerm_MB(FloatArray &answer, TimeStep *tStep)=0
Computes diffusion terms for momentum balance equations(s).
MetaStep * giveCurrentMetaStep()
Returns current meta step.
std::vector< std::unique_ptr< GeneralBoundaryCondition > > & giveBcs()
int giveNumber()
Returns receiver's number.
#define OOFEM_LOG_INFO(...)
virtual void computeDiffusionTerm_MC(FloatArray &answer, TimeStep *tStep)=0
Computes diffusion terms for mass conservation equation.
Callback class for assembling specific types of vectors.
virtual void computeVectorOfVelocities(ValueModeType mode, TimeStep *tStep, FloatArray &velocities)
double Re
Reynolds number.
void updateDofUnknownsDictionary_corrector(TimeStep *tStep)
NumericalCmpn
Type representing numerical component.
#define _IFT_EngngModel_smtype
std::unique_ptr< PrimaryField > VelocityPressureField
EngngModelContext * giveContext()
Context requesting service.
Callback class for assembling specific types of matrices.
double computeSquaredNorm() const
Computes the square of the norm.
int ndomains
Number of receiver domains.
DofIDItem
Type representing particular dof type.
void updateSolutionVectors_predictor(FloatArray &solutionVector, FloatArray &accelerationVector, TimeStep *tStep)
int updateSharedDofManagers(FloatArray &answer, const UnknownNumberingScheme &s, int ExchangeTag)
Exchanges necessary remote DofManagers data.
SparseMtrxType
Enumerative type used to identify the sparse matrix type.
The reference incremental load vector is defined as totalLoadVector assembled at given time...
Implementation for assembling external forces vectors in standard monolithic FE-problems.
double atolv
Convergence tolerance.
void times(double f)
Multiplies receiver by factor f.
bool stopmaxiter
Flag if set to true (default), then when max number of iteration reached, computation stops otherwise...
contextIOResultType restoreYourself(DataStream &stream)
virtual void updateYourself(TimeStep *tStep)
Updates internal state after finishing time step.
DofIDItem giveDofID() const
Returns DofID value of receiver, which determines type of of unknown connected to receiver (e...
void beProductOf(const FloatMatrix &aMatrix, const FloatArray &anArray)
Receiver becomes the result of the product of aMatrix and anArray.
std::vector< std::unique_ptr< InitialCondition > > & giveIcs()
EngngModel * master
Master e-model; if defined receiver is in maintained (slave) mode.
FloatArray accelerationVector
Callback class for assembling SUPG tangent matrices.
virtual void matrixFromElement(FloatMatrix &mat, Element &element, TimeStep *tStep) const
TimeStep * givePreviousStep()
Returns pointer to previous solution step.
void updateInternalState(TimeStep *tStep)
virtual void computeDiffusionDerivativeTerm_MB(FloatMatrix &answer, MatResponseMode mode, TimeStep *tStep)=0
Computes the derivative of diffusion terms for momentum balance equations(s) with respect to nodal ve...
Callback class for assembling SUPG internal forces.
SUPG(int i, EngngModel *_master=NULL)
virtual void computeAccelerationTerm_MB(FloatMatrix &answer, TimeStep *tStep)=0
Computes acceleration terms (generalized mass matrix with stabilization terms) for momentum balance e...
virtual void giveLocalVelocityDofMap(IntArray &map)
Function * giveFunction(int n)
Service for accessing particular domain load time function.
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode)
Stores the state of model to output stream.
Abstract base class representing Lagrangian-Eulerian (moving) material interfaces.
virtual void computeAccelerationTerm_MC(FloatMatrix &answer, TimeStep *tStep)=0
Computes acceleration terms for mass conservation equation.
Initializes the variable VERBOSE, in order to get a few intermediate messages on screen: beginning an...
void registerField(FieldPtr eField, FieldType key)
Registers the given field (the receiver is not assumed to own given field).
Class representing vector of real numbers.
SparseLinearSystemNM * createSparseLinSolver(LinSystSolverType st, Domain *d, EngngModel *m)
Creates new instance of SparseLinearSystemNM corresponding to given type.
virtual int checkConsistency()
Allows programmer to test some receiver's internal data, before computation begins.
This abstract class represent a general base element class for fluid dynamic problems.
std::unique_ptr< MaterialInterface > materialInterface
virtual void computeBCLhsPressureTerm_MC(FloatMatrix &answer, TimeStep *tStep)
Computes Lhs terms due to boundary conditions - pressure.
Implementation of matrix containing floating point numbers.
#define _IFT_EngngModel_lstype
IRResultType
Type defining the return values of InputRecord reading operations.
void evaluateElementStabilizationCoeffs(TimeStep *tStep)
virtual void computeDiffusionDerivativeTerm_MC(FloatMatrix &answer, TimeStep *tStep)=0
Computes diffusion derivative terms for mass conservation equation.
virtual void computeBCLhsPressureTerm_MB(FloatMatrix &answer, TimeStep *tStep)
Computes Lhs terms due to boundary conditions - pressure.
Abstract base class representing Level Set representation of material interfaces. ...
void assemble(const FloatArray &fe, const IntArray &loc)
Assembles the array fe (typically, the load vector of a finite element) into the receiver, using loc as location array.
virtual void vectorFromElement(FloatArray &vec, Element &element, TimeStep *tStep, ValueModeType mode) const
int giveNumberOfTimeStepWhenIcApply()
Returns the time step number, when initial conditions should apply.
double computeNorm() const
Computes the norm (or length) of the vector.
void resize(int rows, int cols)
Checks size of receiver towards requested bounds.
virtual void reinitialize()
Reinitializes the receiver.
void updateDofUnknownsDictionary_predictor(TimeStep *tStep)
void zero()
Zeroes all coefficients of receiver.
virtual void computeAdvectionTerm_MB(FloatArray &answer, TimeStep *tStep)=0
Computes nonlinear advection terms for momentum balance equations(s).
Class implementing single timer, providing wall clock and user time capabilities. ...
#define _IFT_SUPG_scaleflag
ClassFactory & classFactory
long ContextMode
Context mode (mask), defining the type of information written/read to/from context.
#define _IFT_SUPG_stopmaxiter
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode)
Restores the state of model from output stream.
void zero()
Zeroes all coefficient of receiver.
virtual TimeStep * givePreviousStep(bool force=false)
Returns previous time step.
virtual int giveUnknownDictHashIndx(ValueModeType mode, TimeStep *tStep)
This method is responsible for computing unique dictionary id (ie hash value) from given valueModeTyp...
virtual TimeStep * giveSolutionStepWhenIcApply(bool force=false)
Returns the solution step when Initial Conditions (IC) apply.
virtual double giveVariableScale(VarScaleType varId)
Returns the scale factor for given variable type.
int min(int i, int j)
Returns smaller value from two given decimals.
std::vector< std::unique_ptr< Element > > & giveElements()
Abstract base class representing the "problem" under consideration.
virtual TimeStep * giveCurrentStep(bool force=false)
Returns current time step.
void applyIC(TimeStep *tStep)
virtual void times(const FloatArray &x, FloatArray &answer) const
Evaluates .
virtual void updateDomainLinks()
Updates domain links after the domains of receiver have changed.
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode)
Restores the state of model from output stream.
the oofem namespace is to define a context or scope in which all oofem names are defined.
void assemble(const FloatMatrix &src, const IntArray &loc)
Assembles the contribution using localization array into receiver.
Domain * giveDomain(int n)
Service for accessing particular problem domain.
virtual double giveReynoldsNumber()
Abstract class Dof represents Degree Of Freedom in finite element mesh.
DofManager * giveDofManager(int n)
Service for accessing particular domain dof manager.
double alpha
Integration constant.
virtual double evaluateAtTime(double t)
Returns the value of the function at given time.
double getUtime()
Returns total user time elapsed in seconds.
#define OOFEM_WARNING(...)
void assembleVector(FloatArray &answer, TimeStep *tStep, const VectorAssembler &va, ValueModeType mode, const UnknownNumberingScheme &s, Domain *domain, FloatArray *eNorms=NULL)
Assembles characteristic vector of required type from dofManagers, element, and active boundary condi...
virtual void computeAdvectionTerm_MC(FloatArray &answer, TimeStep *tStep)=0
Computes advection terms for mass conservation equation.
Class representing solution step.
virtual void computePressureTerm_MC(FloatMatrix &answer, TimeStep *tStep)=0
Computes pressure terms for mass conservation equation.
#define _IFT_SUPG_maxiter
void add(const FloatArray &src)
Adds array src to receiver.
virtual void printSingleOutputAt(FILE *file, TimeStep *tStep, char ch, ValueModeType mode, double scale=1.0)
Prints Dof output (it prints value of unknown related to dof at given timeStep).
SUPGInternalForceAssembler(double l, double d, double u)
virtual void computeBCLhsTerm_MB(FloatMatrix &answer, TimeStep *tStep)
Computes Lhs terms due to boundary conditions - velocity.
FloatArray incrementalSolutionVector
virtual NumericalMethod * giveNumericalMethod(MetaStep *mStep)
Returns reference to receiver's numerical method.
const char * __ValueModeTypeToString(ValueModeType _value)
void resize(int s)
Resizes receiver towards requested size.
virtual void computeAdvectionDerivativeTerm_MB(FloatMatrix &answer, TimeStep *tStep)=0
Computes the derivative of advection terms for momentum balance equations(s) with respect to nodal ve...