54 OOFEM_ERROR(
"size of levelSetValues does not match number of dof managers");
60 for (
int i = 1; i <= nnodes; i++ ) {
91 for (
int i = 1; i <= nvert; i++ ) {
127 OOFEM_ERROR(
"giveInputRecord not implemented yet");
135 int i, j, l, inodes, inode;
137 bool twostage =
true;
139 double help, dt, volume, gfi_norm;
150 int __step = 0, __nstep = 10;
161 for ( inode = 1; inode <= ndofman; inode++ ) {
162 if ( fabs( w.
at(inode) ) > 0.0 ) {
175 }
else if (
nsd == 3 ) {
176 mask = {V_u, V_v, V_w};
184 for ( l = 1; l <= elems->
giveSize(); l++ ) {
193 for ( i = 1; i <= inodes; i++ ) {
198 for ( j = 1; j <=
nsd; j++ ) {
200 for ( i = 1; i <= inodes; i++ ) {
201 gfi.at(j) += dN.
at(i, j) * fi.at(i);
206 gfi_norm = gfi.computeNorm();
207 if ( gfi_norm > 1.e-6 ) {
220 for ( inode = 1; inode <= ndofman; inode++ ) {
221 if ( w.
at(inode) > 0.0 ) {
225 0.5 *dt *fs.at(inode) / w.
at(inode);
231 }
while ( ++__step < __nstep );
268 for (
int i = 1; i <= inodes; i++ ) {
291 #ifdef LevelSetPCS_CACHE_ELEMENT_VOF 305 for (
int i = 1; i <= inodes; i++ ) {
324 for (
int i = 1; i <= inodes; i++ ) {
328 interface->LS_PCS_computeVOFFractions(answer, fi);
355 bool twostage =
false;
373 for (
int ie = 1; ie <= nelem; ie++ ) {
378 for (
int i = 1; i <= inodes; i++ ) {
388 for (
int i = 1; i <= inodes; i++ ) {
390 _boundary.
at(_node) = 1;
405 for (
int inode = 1; inode <= ndofman; inode++ ) {
406 if ( _boundary.
at(inode) ) {
410 if ( fabs( w.at(inode) ) > 0.0 ) {
411 c = dt * fs.at(inode) / w.at(inode);
422 for (
int inode = 1; inode <= ndofman; inode++ ) {
423 if ( _boundary.
at(inode) ) {
427 if ( fabs( w.at(inode) ) > 0.0 ) {
430 d.
at(inode) = 0.5 * ( d_old.
at(inode) + d.
at(inode) ) -
431 0.5 *dt *fs.at(inode) / w.at(inode);
432 cm =
max( cm, fabs( ( d.
at(inode) - d_old.
at(inode) ) / d_old.
at(inode) ) );
436 }
while ( ( cm > this->
reinit_err ) && ( ++nite < 2000 ) );
439 OOFEM_LOG_INFO(
"LevelSetPCS :: redistance - error %le in %d iterations", cm, nite);
449 double alpha, dfi, help, sumkn, F, f, volume, gfi_norm;
460 for (
int ie = 1; ie <= nelem; ie++ ) {
463 interface = static_cast< LevelSetPCSElementInterface * >
474 for (
int i = 1; i <= inodes; i++ ) {
484 for (
int i = 1; i <= inodes; i++ ) {
485 if ( gfi_norm > 1.e-12 ) {
487 for (
int j = 1; j <=
nsd; j++ ) {
488 n.at(j) =
nsd * dN.
at(i, j) * volume;
493 OOFEM_LOG_INFO(
"LevelSetPCS :: pcs_stage1 - zero gfi_norm for %d node", i);
498 dfi = fi.dotProduct(k);
499 for (
int i = 1; i <= inodes; i++ ) {
502 for (
int l = 1; l <= inodes; l++ ) {
503 help +=
negbra( k.at(l) ) * ( fi.at(i) - fi.at(l) );
504 sumkn +=
negbra( k.at(l) );
507 if ( fabs(sumkn) > 1.e-12 ) {
508 dfii.
at(i) =
macbra( k.at(i) ) * help / sumkn;
510 OOFEM_LOG_INFO(
"LevelSetPCS :: pcs_stage1 - zero sumkn for %d node", i);
517 for (
int l = 1; l <= inodes; l++ ) {
518 help +=
max(0.0, dfii.
at(l) / dfi);
521 for (
int i = 1; i <= inodes; i++ ) {
523 if ( fabs(help) > 0.0 ) {
524 alpha =
max(0.0, dfii.
at(i) / dfi) / help;
525 fs.
at(_ig) += alpha * ( dfi - f * volume );
526 w.
at(_ig) += alpha * volume;
530 OOFEM_ERROR(
"element %d does not implement LevelSetPCSElementInterfaceType", ie);
544 return interface->LS_PCS_computeS(
this, tStep);
574 std :: list< int >bcDofMans;
579 for (
int i = 1; i <= nelem; i++ ) {
584 for (
int j = 1; j <= enodes; j++ ) {
586 if ( _lsval > 0.0 ) {
590 if ( _lsval < 0.0 ) {
595 if ( ( __pos && __neg ) || ( __pos + __neg < enodes ) ) {
598 for (
int j = 1; j <= enodes; j++ ) {
602 bcDofMans.push_front(jnode);
604 bcDofMans.push_front(-jnode);
612 fmm.
solve(dmanValues, bcDofMans, 1.0);
614 for (
int &
node: bcDofMans ) {
619 fmm.
solve(dmanValues, bcDofMans, -1.0);
654 #ifdef LevelSetPCS_CACHE_ELEMENT_VOF
int nsd
number of spatial dimensions.
#define _IFT_LevelSetPCS_reinit_dt
virtual void reinitialization(TimeStep *tStep)
virtual double computeCriticalTimeStep(TimeStep *tStep)
Computes critical time step induced by receiver integration algorithm.
int giveDofManagerNumber(int i) const
Translates local to global indices for dof managers.
virtual double LS_PCS_computeF(LevelSetPCS *ls, TimeStep *tStep)=0
Evaluates F in level set equation of the form where for interface position driven by flow with speed...
double evalElemFContribution(PCSEqType t, int ie, TimeStep *tStep)
virtual void initialize()
Initializes receiver.
Domain * domain
Link to domain object, useful for communicating with other FEM components.
int giveNumberOfDofManagers() const
Returns number of dof managers in domain.
std::vector< FloatArray > elemVof
FloatArray levelSetValues
Array used to store value of level set function for each node.
Fast Marching Method for unstructured grids.
The purpose of DataStream abstract class is to allow to store/restore context to different streams...
contextIOResultType storeYourself(DataStream &stream) const
double & at(int i)
Coefficient access function.
double giveLevelSetDofManValue(int i)
Returns level set value in specific node.
double pointDistance(double x, double y) const
int max(int i, int j)
Returns bigger value form two given decimals.
Element interface for LevelSetPCS class representing level-set like material interface.
ConnectivityTable * giveConnectivityTable()
Returns receiver's associated connectivity table.
long int levelSetVersion
Level set values version.
double macbra(double x)
Returns the positive part of given float.
virtual void updatePosition(TimeStep *tStep)
Updates the position of interface according to state reached in given solution step.
Abstract base class for all finite elements.
#define _IFT_LevelSetPCS_levelSetValues
int giveNumberOfElements() const
Returns number of elements in domain.
virtual double giveCoordinate(int i)
double reinit_err
Reinitialization error limit.
void FMMReinitialization(FloatArray &ls)
Reinitializes the level set representation using fast marching method.
#define _IFT_LevelSetPCS_ci1
Class implementing an array of integers.
int & at(int i)
Coefficient access function.
virtual int read(int *data, int count)=0
Reads count integer values into array pointed by data.
int ci1
Indexes of nodal coordinates used to init levelset using initialRefMatVol.
#define _IFT_LevelSetPCS_refmatpoly_y
virtual int giveNumberOfDofManagers() const
virtual void giveElementMaterialMixture(FloatArray &answer, int ielem)
Returns volumetric (or other based measure) of relative material contents in given element...
double giveTimeIncrement()
Returns solution step associated time increment.
virtual int giveNumberOfNodes() const
Returns number of nodes of receiver.
void solve(FloatArray &dmanValues, const std::list< int > &bcDofMans, double F)
Solution of problem.
virtual int write(const int *data, int count)=0
Writes count integer values from array pointed by data.
virtual void LS_PCS_computeVOFFractions(FloatArray &answer, FloatArray &fi)=0
Returns VOF fractions for each material on element according to nodal values of level set function (p...
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Restores the receiver state previously written in stream.
void giveUnknownVector(FloatArray &answer, const IntArray &dofMask, ValueModeType mode, TimeStep *tStep, bool padding=false)
Assembles the vector of unknowns in global c.s for given dofs of receiver.
#define OOFEM_LOG_INFO(...)
Element * giveElement(int n)
Service for accessing particular domain fe element.
double dotProduct(const FloatArray &x) const
Computes the dot product (or inner product) of receiver and argument.
#define _IFT_LevelSetPCS_ci2
int reinit_alg
Type of reinitialization algorithm to use.
#define _IFT_LevelSetPCS_reinit_alg
#define _IFT_LevelSetPCS_nsd
SpatialLocalizer * giveSpatialLocalizer()
Returns receiver's associated spatial localizer.
contextIOResultType restoreYourself(DataStream &stream)
Class representing connectivity table.
virtual double LS_PCS_computeS(LevelSetPCS *ls, TimeStep *tStep)=0
Evaluates S in level set equation of the form where .
virtual void giveMaterialMixtureAt(FloatArray &answer, FloatArray &position)
Returns relative material contents at given point.
TimeStep * givePreviousStep()
Returns pointer to previous solution step.
double reinit_dt
Time step used in reinitialization of LS (if apply).
void beTProductOf(const FloatMatrix &aMatrix, const FloatArray &anArray)
Receiver becomes the result of the product of aMatrix^T and anArray.
double at(int i, int j) const
Coefficient access function.
virtual Element * giveElementContainingPoint(const FloatArray &coords, const IntArray *regionList=NULL)=0
Returns the element, containing given point and belonging to one of the region in region list...
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Class representing vector of real numbers.
Implementation of matrix containing floating point numbers.
const IntArray * giveDofManConnectivityArray(int dofman)
IRResultType
Type defining the return values of InputRecord reading operations.
void setCoords(double x, double y)
void redistance(TimeStep *tStep)
Reinitializes the level set representation by solving to steady state.
double computeNorm() const
Computes the norm (or length) of the vector.
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Stores receiver state to output stream.
long int elemVofLevelSetVersion
virtual void LS_PCS_computedN(FloatMatrix &answer)=0
Returns gradient of shape functions.
void zero()
Zeroes all coefficients of receiver.
virtual Interface * giveInterface(InterfaceType t)
Interface requesting service.
virtual bool computeLocalCoordinates(FloatArray &answer, const FloatArray &gcoords)
Computes the element local coordinates from given global coordinates.
long ContextMode
Context mode (mask), defining the type of information written/read to/from context.
Class representing vertex.
virtual double LS_PCS_computeVolume()=0
Returns receiver's volume.
double evalElemfContribution(PCSEqType t, int ie, TimeStep *tStep)
int giveSize() const
Returns the size of receiver.
Node * giveNode(int n)
Service for accessing particular domain node.
the oofem namespace is to define a context or scope in which all oofem names are defined.
#define _IFT_LevelSetPCS_refmatpoly_x
double negbra(double x)
Returns the negative part of given float.
DofManager * giveDofManager(int n)
Service for accessing particular domain dof manager.
#define _IFT_LevelSetPCS_reinit_err
FloatArray previousLevelSetValues
void pcs_stage1(FloatArray &ls, FloatArray &fs, FloatArray &w, TimeStep *tStep, PCSEqType t)
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
Class representing solution step.
void resize(int s)
Resizes receiver towards requested size.