48#ifdef __MPI_PARALLEL_MODE
63 omp_lock_t NonlocalMaterialExtensionInterface::updateDomainBeforeNonlocAverageLock;
67NonlocalMaterialExtensionInterface :: NonlocalMaterialExtensionInterface(
Domain *d) :
Interface()
101 omp_init_lock(&NonlocalMaterialExtensionInterface::updateDomainBeforeNonlocAverageLock);
106NonlocalMaterialExtensionInterface :: updateDomainBeforeNonlocAverage(
TimeStep *tStep)
const
114 omp_set_lock(&NonlocalMaterialExtensionInterface::updateDomainBeforeNonlocAverageLock);
116 omp_unset_lock(&NonlocalMaterialExtensionInterface::updateDomainBeforeNonlocAverageLock);
123 elem->updateBeforeNonlocalAverage(tStep);
129 omp_unset_lock(&NonlocalMaterialExtensionInterface::updateDomainBeforeNonlocAverageLock);
134NonlocalMaterialExtensionInterface :: buildNonlocalPointTable(
GaussPoint *gp)
const
136 double elemVolume, integrationVolume = 0.;
157 FloatArray gpCoords, jGpCoords, shiftedGpCoords;
159 OOFEM_ERROR(
"computeGlobalCoordinates of target failed");
181 for (
int ix = -nx; ix <= nx; ix++ ) {
182 SpatialLocalizer :: elementContainerType elemSet;
183 shiftedGpCoords = gpCoords;
184 shiftedGpCoords.
at(1) += ix *
px;
187#ifdef NMEI_USE_ALL_ELEMENTS_IN_SUPPORT
188 this->
domain->giveSpatialLocalizer()->giveAllElementsWithNodesWithinBox(elemSet, shiftedGpCoords,
suprad);
192 this->
domain->giveSpatialLocalizer()->giveAllElementsWithIpWithinBox_EvenIfEmpty(elemSet, shiftedGpCoords,
suprad);
195 iList->reserve(elemSet.giveSize());
196 for (
auto elindx : elemSet ) {
207#ifdef NMEI_USE_ALL_ELEMENTS_IN_SUPPORT
216 iList->push_back(ir);
217 integrationVolume += elemVolume;
220 OOFEM_ERROR(
"computeGlobalCoordinates of target failed");
225 iList->shrink_to_fit();
232 NonlocalMaterialExtensionInterface :: rebuildNonlocalPointTable(
GaussPoint *gp,
IntArray *contributingElems)
const
234 double weight, elemVolume, integrationVolume = 0.;
235 double cl = this->cl;
248 if ( contributingElems == NULL ) {
253 int _size = contributingElems->
giveSize();
255 OOFEM_ERROR(
"computeGlobalCoordinates of target failed");
266 iList->reserve(_size);
267 for (
int _e = 1; _e <= _size; _e++ ) {
278#ifdef NMEI_USE_ALL_ELEMENTS_IN_SUPPORT
287 iList->push_back(ir);
288 integrationVolume += elemVolume;
291 OOFEM_ERROR(
"computeGlobalCoordinates of target failed");
298#ifdef __MPI_PARALLEL_MODE
299 #ifdef __VERBOSE_PARALLEL
301 for (
auto &lir : *iList ) {
302 fprintf(stderr,
"%d,%d(%e)", lir.nearGp->giveElement()->giveGlobalNumber(), lir.nearGp->giveNumber(), lir.weight);
305 fprintf(stderr,
"\n");
314 NonlocalMaterialExtensionInterface :: modifyNonlocalWeightFunctionAround(
GaussPoint *gp)
const
332 OOFEM_ERROR(
"NonlocalMaterialExtensionInterface :: modifyNonlocalWeightFunctionAround is implemented only for 1D and 2D problems, sorry.\n");
352 double xgp = coords.
at(1);
353 double ygp = coords.
at(2);
355 double xngp, yngp, damgp;
356 for (
auto lip : *list ) {
359 ngpElem = ( lip.nearGp )->giveElement();
367 for (
int i = 1; i <= 2 *
gridSize + 1; i++ ) {
368 for (
int j = 1; j <= 2 *
gridSize + 1; j++ ) {
370 speed.
at(i, j) = damgp;
375 for (
int i = 1; i <= 2 *
gridSize + 1; i++ ) {
376 for (
int j = 1; j <= 2 *
gridSize + 1; j++ ) {
378 if ( dist2 < minDist2.
at(i, j) ) {
379 minDist2.
at(i, j) = dist2;
380 speed.
at(i, j) = damgp;
388 for (
int i = 1; i <= 2 *
gridSize + 1; i++ ) {
389 for (
int j = 1; j <= 2 *
gridSize + 1; j++ ) {
402 center.
at(1, 1) = center.
at(1, 2) = ( double )
gridSize + 1;
409 for (
auto lip : *list ) {
411 ngpElem = ( lip.nearGp )->giveElement();
417 }
else if ( j > 2 *
gridSize + 1 ) {
423 }
else if ( i > 2 *
gridSize + 1 ) {
453NonlocalMaterialExtensionInterface :: modifyNonlocalWeightFunction_1D_Around(
GaussPoint *gp)
const
456 std :: vector< localIntegrationRecord > :: iterator postarget;
459 for (
auto pos = list->begin(); pos != list->end(); ++pos ) {
460 if ( pos->nearGp == gp ) {
468 double xtarget = coords.
at(1);
470 double wsum = 0., xprev, damageprev = 0.;
475 for (
auto pos = postarget; pos != list->end(); ++pos ) {
476 Element *nearElem = ( pos->nearGp )->giveElement();
478 double x = coords.
at(1);
488 if ( pos != postarget ) {
502 for (
auto pos = postarget; pos != list->begin(); --pos ) {
503 Element *nearElem = ( pos->nearGp )->giveElement();
505 double x = coords.
at(1);
515 if ( pos != postarget ) {
528 auto pos = list->begin();
529 if ( pos != postarget ) {
530 Element *nearElem = ( pos->nearGp )->giveElement();
532 double x = coords.
at(1);
557NonlocalMaterialExtensionInterface :: computeModifiedLength(
double length,
double dam1,
double dam2)
const
568NonlocalMaterialExtensionInterface :: computeDistanceModifier(
double cl,
double damage)
const
571 case 2:
return 1. / (
Rf /
cl + ( 1. -
Rf /
cl ) * pow(1. - damage,
exponent) );
573 case 3:
if ( damage == 0. ) {
576 return 1. / ( 1. - ( 1. -
Rf /
cl ) * pow(damage,
exponent) );
579 case 4:
return 1. / pow(
Rf /
cl, damage);
581 case 5:
return ( 2. *
cl ) / (
cl +
Rf + (
cl -
Rf ) * cos(
M_PI * damage) );
583 case 6:
return 1. / sqrt(1. - damage);
589std :: vector< localIntegrationRecord > *
590NonlocalMaterialExtensionInterface :: giveIPIntegrationList(
GaussPoint *gp)
const
608NonlocalMaterialExtensionInterface :: endIPNonlocalAverage(
GaussPoint *gp)
const
623NonlocalMaterialExtensionInterface :: computeWeightFunction(
double cl,
double distance)
const
638 aux = ( 1. - aux * aux );
639 return aux * aux / iwf;
642 return exp(-aux * aux) / iwf;
646 return exp(-aux) / iwf;
658 double r = sqrt(x * x + y * y);
659 double sum = exp(-r /
cl);
663 r = sqrt(x * x + y * y);
664 sum += 2. * exp(-r /
cl);
667 return sum * h / iwf;
680 NonlocalMaterialExtensionInterface :: computeWeightFunction(
const double cl,
const FloatArray &src,
const FloatArray &coord)
const
686NonlocalMaterialExtensionInterface :: giveIntegralOfWeightFunction(
double cl,
const int spatial_dimension)
const
688 const double pi =
M_PI;
691 switch ( spatial_dimension ) {
692 case 1:
return cl * 16. / 15.;
694 case 2:
return cl *
cl * pi / 3.;
696 case 3:
return cl *
cl *
cl * pi * 32. / 105.;
702 switch ( spatial_dimension ) {
703 case 1:
return cl * sqrt(pi);
705 case 2:
return cl *
cl * pi;
707 case 3:
return cl *
cl *
cl * sqrt(pi * pi * pi);
714 switch ( spatial_dimension ) {
715 case 1:
return cl * 2.;
717 case 2:
return cl *
cl * 2. * pi;
719 case 3:
return cl *
cl *
cl * 8. * pi;
725 switch ( spatial_dimension ) {
726 case 1:
return cl * 2.;
728 case 2:
return cl *
cl * pi;
730 case 3:
return cl *
cl *
cl * ( 4. / 3. ) * pi;
740NonlocalMaterialExtensionInterface :: maxValueOfWeightFunction()
747NonlocalMaterialExtensionInterface :: evaluateSupportRadius(
double cl)
const
766NonlocalMaterialExtensionInterface :: initializeFrom(
InputRecord &ir)
770 if (
regionMap.giveSize() != this->giveDomain()->giveNumberOfRegions() ) {
826 if ( nlvariation == 1 ) {
830 }
else if ( nlvariation == 2 ) {
833 }
else if ( nlvariation == 3 ) {
925NonlocalMaterialExtensionInterface :: applyBarrierConstraints(
const FloatArray &gpCoords,
const FloatArray &jGpCoords,
double &weight)
const
927 int ib, nbarrier =
domain->giveNumberOfNonlocalBarriers();
928 bool shieldFlag =
false;
930 for ( ib = 1; ib <= nbarrier; ib++ ) {
931 domain->giveNonlocalBarrier(ib)->applyConstraint(
cl, gpCoords, jGpCoords, weight, shieldFlag, *
this);
954NonlocalMaterialExtensionInterface :: giveDistanceBasedInteractionRadius(
const FloatArray &gpCoords)
const
958 int ib, nbarrier =
domain->giveNumberOfNonlocalBarriers();
959 for ( ib = 1; ib <= nbarrier; ib++ ) {
960 temp =
domain->giveNonlocalBarrier(ib)->calculateMinimumDistanceFromBoundary(gpCoords);
967 double newradius = 0.0;
977 return newradius *
cl0;
987NonlocalMaterialStatusExtensionInterface :: ~NonlocalMaterialStatusExtensionInterface()
double length(const Vector &a)
StateCounterType giveNonlocalUpdateStateCounter()
Returns the value of nonlocalUpdateStateCounter.
void setNonlocalUpdateStateCounter(StateCounterType val)
sets the value of nonlocalUpdateStateCounter
std ::vector< std ::unique_ptr< Element > > & giveElements()
int giveNumberOfRegions() const
Returns number of regions. Currently regions corresponds to cross section models.
int giveGlobalNumber() const
virtual int computeGlobalCoordinates(FloatArray &answer, const FloatArray &lcoords)
virtual Material * giveMaterial()
virtual IntegrationRule * giveDefaultIntegrationRulePtr()
virtual double computeVolumeAround(GaussPoint *gp)
Index giveSize() const
Returns the size of receiver.
double at(std::size_t i, std::size_t j) const
int giveNumber()
Returns number of receiver.
const FloatArray & giveNaturalCoordinates() const
Returns coordinate array of receiver.
IntegrationPointStatus * giveMaterialStatus(IntegrationPointStatusIDType key=IPSID_Default)
Element * giveElement()
Returns corresponding element to receiver.
double giveSolutionValueAt(int i, int j)
Output methods.
void unFreeze()
Set all flags to "unfrozen".
void setZeroValues(FloatMatrix *gridCoords)
Methods setting the values of the unknown field at selected points (e.g., zero times).
FloatMatrix & givePrescribedField()
void setMethod(int o, double i, int c)
Set the details of the algorithm to be used.
int giveNumberOfIntegrationPoints() const
virtual bool hasProperty(int aProperty, GaussPoint *gp) const
virtual double give(int aProperty, GaussPoint *gp) const
virtual double computeWeightFunction(const double cl, const double distance) const
Domain * giveDomain()
Returns reference to domain.
int averType
Parameter specifying how the weight function should be adjusted due to damage.
@ NLVT_DistanceBasedLinear
@ NLVT_DistanceBasedExponential
double exponent
Parameter used as an exponent by models with evolving characteristic length.
NlVariationType nlvar
Parameter specifying the type of nonlocal variation.
double giveDistanceBasedInteractionRadius(const FloatArray &gpCoords) const
virtual double giveNonlocalMetricModifierAt(GaussPoint *gp) const
double giveIntegralOfWeightFunction(double cl, const int spatial_dimension) const
bool permanentNonlocTableFlag
Flag indicating whether to keep nonlocal interaction tables of integration points cached.
double computeModifiedLength(double length, double dam1, double dam2) const
ScalingType
Type characterizing the scaling approach.
void buildNonlocalPointTable(GaussPoint *gp) const
void applyBarrierConstraints(const FloatArray &gpCoords, const FloatArray &jGpCoords, double &weight) const
double suprad
Support radius.
virtual double evaluateSupportRadius(double cl) const
AveragedVarType
Type characterizing the averaged (nonlocal) variable.
double Rf
Final value of interaction radius, for a model with evolving characteristic length.
virtual int hasBoundedSupport() const
double computeDistanceModifier(double cl, double damage) const
ScalingType scaling
Parameter specifying the type of scaling of nonlocal weight function.
double initDiag
Optional parameters setting details of the fast marching method.
double dist2FromGridNode(double x, double y, int j, int i) const
void manipulateWeight(double &weight, GaussPoint *gp, GaussPoint *jGp) const
int mapToGridPoint(double x, double x0) const
double mm
For "undernonlocal" or "overnonlocal" formulation.
WeightFunctionType weightFun
Parameter specifying the type of nonlocal weight function.
NonlocalMaterialExtensionInterface(Domain *d)
IntArray regionMap
Map indicating regions to skip (region - cross section model).
AveragedVarType averagedVar
Parameter specifying the type of averaged (nonlocal) variable.
int gridSize
Grid on which the eikonal equation will be solved (used by eikonal nonlocal models).
double mapToGridCoord(double x, double x0) const
void modifyNonlocalWeightFunction_1D_Around(GaussPoint *gp) const
std ::vector< localIntegrationRecord > * giveIPIntegrationList(GaussPoint *gp) const
void clear()
clears the integration list of receiver
void setIntegrationScale(double val)
Sets associated integration scale.
std ::vector< localIntegrationRecord > integrationDomainList
List containing localIntegrationRecord values.
double giveVolumeAround()
Returns associated volume.
void setVolumeAround(double val)
Sets associated integration scale.
double integrationScale
Nonlocal volume around the corresponding integration point.
std ::vector< localIntegrationRecord > * giveIntegrationDomainList()
double volumeAround
Local volume around the corresponding integration point.
StateCounterType giveSolutionStateCounter()
#define OOFEM_WARNING(...)
#define OOFEM_LOG_DEBUG(...)
double sum(const FloatArray &x)
@ NonlocalMaterialStatusExtensionInterfaceType
double distance(const FloatArray &x, const FloatArray &y)
#define _IFT_NonlocalMaterialExtensionInterface_r
#define _IFT_NonlocalMaterialExtensionInterface_scalingtype
#define _IFT_NonlocalMaterialExtensionInterface_px
#define _IFT_NonlocalMaterialExtensionInterface_regionmap
#define _IFT_NonlocalMaterialExtensionInterface_centdiff
#define _IFT_NonlocalMaterialExtensionInterface_m
#define _IFT_NonlocalMaterialExtensionInterface_averagedquantity
#define _IFT_NonlocalMaterialExtensionInterface_initdiag
#define _IFT_NonlocalMaterialExtensionInterface_rf
#define _IFT_NonlocalMaterialExtensionInterface_averagingtype
#define _IFT_NonlocalMaterialExtensionInterface_order
#define _IFT_NonlocalMaterialExtensionInterface_permanentNonlocTableFlag
#define _IFT_NonlocalMaterialExtensionInterface_wft
#define _IFT_NonlocalMaterialExtensionInterface_nonlocalvariation
#define _IFT_NonlocalMaterialExtensionInterface_beta
#define _IFT_NonlocalMaterialExtensionInterface_exp
#define _IFT_NonlocalMaterialExtensionInterface_zeta
#define _IFT_NonlocalMaterialExtensionInterface_gridsize
GaussPoint * nearGp
Reference to influencing integration point.
double weight
Corresponding integration weight.