39 for (
int xyz = 1; xyz <= myArray.giveSize(); xyz++ ) {
40 if (
dynamic_cast< IntArray *
>(& myArray) ) {
41 printf(
"%u ", myArray.at(xyz) );
43 printf(
"%f ", myArray.at(xyz) );
56void logDataMsg(
const char *c, T myArray,
const char *c2) {
75 ActiveBoundaryCondition :: initializeFrom(ir);
97 for (
int i = 1; i <= this->
giveDomain()->giveNumberOfSpatialDimensions(); i++) {
98 int DofID = this->
domain->giveNextFreeDofID();
100 myNode->appendDof( newDof );
107SolutionbasedShapeFunction :: giveInternalDofManager(
int i)
116 if ( dof == myDof ) {
124SolutionbasedShapeFunction :: init()
131 for (
auto &n :this->
giveDomain()->giveDofManagers() ) {
132 for (
int j = 1; j <=
maxCoord.giveSize(); j++ ) {
140SolutionbasedShapeFunction :: computeCorrectionFactors(
modeStruct &myMode,
IntArray &Dofs,
double &am,
double &ap)
146 double A0p = 0.0, App = 0.0, A0m = 0.0, Amm = 0.0, Bp = 0.0, Bm = 0.0, c0 = 0.0, cp = 0.0, cm = 0.0;
153 for (
int i = 0; i < BoundaryList.
giveSize() / 2; i++ ) {
154 int ElementID = BoundaryList[2 * i];
155 int Boundary = BoundaryList[2 * i + 1];
164 nodeValues.
resize( this->
dofs.giveSize(), bnodes.giveSize() );
172 for (
auto &gp: *iRule ) {
173 const FloatArray &lcoords = gp->giveNaturalCoordinates();
189 for (
int l = 1; l <= zNodes.
giveSize(); l++ ) {
190 int nodeID = zNodes.
at(l);
191 for (
int m = 1; m <= this->
dofs.giveSize(); m++ ) {
192 zPhi.
at(m) +=
N.at(nodeID) * nodeValues.
at(m, nodeID);
198 for (
int l = 1; l <= pNodes.
giveSize(); l++ ) {
199 int nodeID = pNodes.
at(l);
200 for (
int m = 1; m <= this->
dofs.giveSize(); m++ ) {
201 pPhi.at(m) +=
N.at(nodeID) * nodeValues.
at(m, nodeID);
206 for (
int l = 1; l <= mNodes.
giveSize(); l++ ) {
207 int nodeID = mNodes.
at(l);
208 for (
int m = 1; m <= this->
dofs.giveSize(); m++ ) {
209 mPhi.at(m) +=
N.at(nodeID) * nodeValues.
at(m, nodeID);
214 cp += pPhi.dotProduct(normal, 3) * detJ;
215 cm += mPhi.dotProduct(normal, 3) * detJ;
217 App += pPhi.dotProduct(pPhi, 3) * detJ;
218 Amm += mPhi.dotProduct(mPhi, 3) * detJ;
227 am = -( A0m * cp * cp - Bm * cp * cp - A0p * cm * cp + App * c0 * cm + Bp * cm * cp ) / ( App * cm * cm + Amm * cp * cp );
228 ap = -( A0p * cm * cm - Bp * cm * cm - A0m * cm * cp + Amm * c0 * cp + Bm * cm * cp ) / ( App * cm * cm + Amm * cp * cp );
238 for (
int j = 1; j <= bnodes.
giveSize(); j++ ) {
243 bool isMinus =
false;
249 }
else if ( isPlus ) {
251 }
else if ( isMinus ) {
256 for (
size_t k = 0; k < mode.
SurfaceData.size(); k++ ) {
258 int IndexOfDofIDItem = 0;
259 for (
int l = 1; l <=
dofs.giveSize(); l++ ) {
261 IndexOfDofIDItem = l;
265 nodeValues.
at(IndexOfDofIDItem, j) = mode.
SurfaceData[k].value;
288 double out = shapeFunctionValues.
dotProduct(gamma);
300 FloatArray values, masterContribs2, d, values2;
302 masterContribs.
resize( this->
giveDomain()->giveNumberOfSpatialDimensions() );
303 masterContribs2.
resize( this->
giveDomain()->giveNumberOfSpatialDimensions() );
307 bool isPlus, isMinus, isZero, found;
310 for (
int i = 0; i < this->
giveDomain()->giveNumberOfSpatialDimensions(); i++ ) {
315 for (
size_t j = 0; j < ms.
SurfaceData.size(); j++ ) {
335 factor = isPlus ?
modes[i].ap : factor;
336 factor = isMinus ?
modes[i].am : factor;
337 factor = isZero ? 1.0 : factor;
339 masterContribs[i] = factor * values.
at(1);
344SolutionbasedShapeFunction :: giveNumberOfMasterDofs(
ActiveDof *dof)
346 return this->
giveDomain()->giveNumberOfSpatialDimensions();
350SolutionbasedShapeFunction :: giveMasterDof(
ActiveDof *dof,
int mdof)
356SolutionbasedShapeFunction :: loadProblem()
358 for (
int i = 0; i < this->
domain->giveNumberOfSpatialDimensions(); i++ ) {
359 OOFEM_LOG_INFO(
"************************** Instanciating microproblem from file %s for dimension %u\n",
filename.c_str(), i);
365 myEngngModel->checkProblemConsistency();
366 myEngngModel->initMetaStepAttributes( myEngngModel->giveMetaStep(1) );
368 myEngngModel->init();
369 this->
setLoads(*myEngngModel, i + 1);
372 for (
auto &elem : myEngngModel->giveDomain(1)->giveElements() ) {
378 for (
int k = 1; k <= elem->giveNumberOfDofManagers(); k++ ) {
381 for (
Dof *dof: *dman ) {
382 if ( dof->giveBcId() != 0 ) {
387 if ( vlockCount == 30 ) {
388 OOFEM_WARNING(
"Element over-constrained (%u)! Center coordinate: %f, %f, %f\n", elem->giveNumber(), centerCoord.
at(1) / 10, centerCoord.
at(2) / 10, centerCoord.
at(3) / 10);
396 std :: string originalFilename;
397 originalFilename = myEngngModel->giveOutputBaseFileName();
399 if (i==0) originalFilename = originalFilename +
"_X";
400 if (i==1) originalFilename = originalFilename +
"_Y";
401 if (i==2) originalFilename = originalFilename +
"_Z";
403 myEngngModel->letOutputBaseFileNameBe(originalFilename +
"_1_Base");
417 double am=1.0, ap=1.0;
431 myEngngModel->letOutputBaseFileNameBe(originalFilename +
"_2_Updated");
435 modes.push_back(std::move(mode));
442SolutionbasedShapeFunction :: updateModelWithFactors(
modeStruct &m)
445 for (
size_t j = 0; j < m.
SurfaceData.size(); j++ ) {
463SolutionbasedShapeFunction :: setLoads(
EngngModel &myEngngModel,
int d)
478 myBodyLoad->initializeFrom(ir);
483 blArray = elem->giveBodyLoadArray();
496 for (
int i = 1; i <= answer.
giveSize(); i++ ) {
501 std :: vector< FloatArray >checkcoords;
502 std :: vector< int >permuteIndex;
511 if ( this->
giveDomain()->giveNumberOfSpatialDimensions() == 2 ) {
520 for (
int i = 1; i <= coords.
giveSize(); i++ ) {
522 permuteIndex.push_back(i);
525 thisMask = thisMask + ( 0x01 << ( i - 1 ) );
529 for (
int i = 0; i < _s; i++ ) {
530 int mask = i, counter = 1;
533 for (
int j = 1; j <= n; j++ ) {
535 if ( ( mask & 1 ) == 0 ) {
536 newCoord.
at( permuteIndex.at(counter - 1) ) =
minCoord.at( permuteIndex.at(counter - 1) ) + d;
538 newCoord.
at( permuteIndex.at(counter - 1) ) =
maxCoord.at( permuteIndex.at(counter - 1) ) - d;
543 checkcoords.emplace_back(newCoord);
551 * tempCoord = coords;
553 checkcoords.push_back(tempCoord);
556 for (
size_t i = 0; i < checkcoords.size(); i++ ) {
560 for (
int j = 1; j <= values.
giveSize(); j++ ) {
561 answer.
at(j) = values.
at(j);
564 for (
int j = 1; j <= values.
giveSize(); j++ ) {
565 answer.
at(j) += values.
at(j) / ( ( double ) pow(2.0, n) );
580 if ( elementAtCoords == NULL ) {
591 for (
int i = 1; i <= dofIDs.
giveSize(); i++ ) {
592 for (
int j = 1; j <= eldofids.
giveSize(); j++ ) {
593 if ( dofIDs.
at(i) == eldofids.
at(j) ) {
594 answer.
at(i) = values.
at(j);
602SolutionbasedShapeFunction :: setBoundaryConditionOnDof(
Dof *d,
double value)
615 myBC->initializeFrom(ir);
626SolutionbasedShapeFunction :: initializeSurfaceData(
modeStruct &mode)
638 for (
int i = 0; i < BoundaryList.
giveSize() / 2; i++ ) {
639 int ElementID = BoundaryList[2 * i];
640 int Boundary = BoundaryList[2 * i + 1];
650 for (
int k = 1; k <= bnodes.giveSize(); k++ ) {
665 lcoords.
at(1) = 0.33333;
666 lcoords.
at(2) = 0.33333;
672 printf(
"i=%u\tj=%u\t(%f\t%f\t%f)\n", i, j, normal.
at(1), normal.
at(2), normal.
at(3) );
673 for (
int k = 1; k <= normal.
giveSize(); k++ ) {
674 if ( fabs( ( fabs( normal.
at(k) ) - 1 ) ) < 1e-4 ) {
676 if ( normal.
at(k) > 0.5 ) {
679 if ( normal.
at(k) < -0.5 ) {
682 if ( addTo != NULL ) {
683 for (
int l = 1; l <= bnodes.giveSize(); l++ ) {
684 bool isSurface =
false;
705 for (
int i = 1; i < pNodes.
giveSize(); i++ ) {
706 printf(
"%u, ", pNodes.
at(i) );
710 for (
int i = 1; i < mNodes.
giveSize(); i++ ) {
711 printf(
"%u, ", mNodes.
at(i) );
722 if ( pNodes.
at(i) == mNodes.
at(j) ) {
741 for (
int i = 1; i <= pNodes.
giveSize(); i++ ) {
742 printf(
"%u, ", pNodes.
at(i) );
746 for (
int i = 1; i <= mNodes.
giveSize(); i++ ) {
747 printf(
"%u, ", mNodes.
at(i) );
751 for (
int i = 1; i <= zNodes.
giveSize(); i++ ) {
752 printf(
"%u, ", zNodes.
at(i) );
757 for (
int i = 1; i <= pNodes.
giveSize(); i++ ) {
759 printf(
"%f, %f, %f; ", coords->
at(1), coords->
at(2), coords->
at(3) );
763 for (
int i = 1; i <= mNodes.
giveSize(); i++ ) {
765 printf(
"%f, %f, %f; ", coords->
at(1), coords->
at(2), coords->
at(3) );
769 for (
int i = 1; i <= zNodes.
giveSize(); i++ ) {
771 printf(
"%f, %f, %f; ", coords->
at(1), coords->
at(2), coords->
at(3) );
778SolutionbasedShapeFunction :: whichBoundary(
const FloatArray &coord,
bool &isPlus,
bool &isMinus,
bool &isZero)
784 for (
int k = 1; k <= coord.
giveSize(); k++ ) {
785 isPlus = isPlus || ( fabs( coord.
at(k) -
maxCoord.at(k) ) <
TOL );
786 isMinus = isMinus || ( fabs( coord.
at(k) -
minCoord.at(k) ) <
TOL );
789 isZero = isPlus && isMinus;
793SolutionbasedShapeFunction :: copyDofManagersToSurfaceData(
modeStruct &mode,
IntArray nodeList,
bool isPlus,
bool isMinus,
bool isZeroBoundary)
795 for (
int i = 1; i <= nodeList.
giveSize(); i++ ) {
804 for (
int j=1; j<=this->
dofs.giveSize(); j++) {
805 for (
Dof *d: *dman ){
809 if (d->giveDofID() == this->dofs.at(j)) {
819 mode.
SurfaceData.emplace_back(std::move(surfaceData));
#define _IFT_BoundaryCondition_PrescribedValue
[rn,optional] Prescribed value of all DOFs
#define REGISTER_BoundaryCondition(class)
void setPrescribedValue(double s)
const FloatArray & giveCoordinates() const
Dof * giveDofWithID(int dofID) const
DofIDItem giveDofID() const
DofManager * giveDofManager() const
virtual void setBcId(int bcId)
Overwrites the boundary condition id (0-inactive BC), intended for specific purposes such as coupling...
SpatialLocalizer * giveSpatialLocalizer()
int giveNumberOfBoundaryConditions() const
Returns number of boundary conditions in domain.
DofManager * giveDofManager(int n)
Element * giveElement(int n)
void setBoundaryCondition(int i, std::unique_ptr< GeneralBoundaryCondition > obj)
Sets i-th component. The component will be further managed and maintained by domain object.
std ::vector< std ::unique_ptr< Element > > & giveElements()
virtual void giveElementDofIDMask(IntArray &answer) const
virtual FEInterpolation * giveInterpolation() const
DofManager * giveDofManager(int i) const
int giveDofManagerNumber(int i) const
virtual void computeField(ValueModeType mode, TimeStep *tStep, const FloatArray &lcoords, FloatArray &answer)
virtual Element_Geometry_Type giveGeometryType() const =0
Domain * giveDomain(int n)
virtual std::unique_ptr< IntegrationRule > giveBoundaryIntegrationRule(int order, int boundary, const Element_Geometry_Type) const
virtual IntArray boundaryGiveNodes(int boundary, const Element_Geometry_Type) const =0
virtual double boundaryGiveTransformationJacobian(int boundary, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const =0
virtual void boundaryLocal2Global(FloatArray &answer, int boundary, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const =0
virtual double boundaryEvalNormal(FloatArray &answer, int boundary, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const =0
virtual void boundaryEvalN(FloatArray &answer, int boundary, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const =0
Domain * giveDomain() const
Domain * domain
Link to domain object, useful for communicating with other FEM components.
double dotProduct(const FloatArray &x) const
Index giveSize() const
Returns the size of receiver.
virtual void printYourself() const
void zero()
Zeroes all coefficients of receiver.
void add(const FloatArray &src)
void resize(Index rows, Index cols)
void zero()
Zeroes all coefficient of receiver.
double at(std::size_t i, std::size_t j) const
IntArray dofs
Dofs that b.c. is applied to (relevant for Dirichlet type b.c.s).
int giveSetNumber() const
void insertSorted(int value, int allocChunk=0)
void resizeWithValues(int n, int allocChunk=0)
const IntArray & giveBoundaryList()
void computeCorrectionFactors(modeStruct &myMode, IntArray &Dofs, double &am, double &ap)
void giveValueAtPoint(FloatArray &answer, const FloatArray &coords, IntArray &dofID, EngngModel &myEngngModel)
giveValueAtPoint
void setLoads(EngngModel &myEngngModel, int d)
void computeBaseFunctionValueAt(FloatArray &answer, const FloatArray &coords, IntArray &dofIDs, EngngModel &myEngngModel)
void initializeSurfaceData(modeStruct &mode)
std ::vector< modeStruct > modes
void computeDofTransformation(ActiveDof *dof, FloatArray &masterContribs) override
void copyDofManagersToSurfaceData(modeStruct &mode, IntArray nodeList, bool isPlus, bool isMinus, bool isZero)
double giveUnknown(PrimaryField &field, ValueModeType mode, TimeStep *tStep, ActiveDof *dof) override
void updateModelWithFactors(modeStruct &m)
void splitBoundaryNodeIDs(modeStruct &mode, Element &e, IntArray &boundary, IntArray &pList, IntArray &mList, IntArray &zList, FloatMatrix &nodeValues)
bool useCorrectionFactors
void setBoundaryConditionOnDof(Dof *d, double value)
void whichBoundary(const FloatArray &coord, bool &isPlus, bool &isMinus, bool &isZero)
virtual int init(bool force=false)
virtual Element * giveElementClosestToPoint(FloatArray &lcoords, FloatArray &closest, const FloatArray &coords, int region=0)=0
#define OOFEM_WARNING(...)
#define _IFT_GeneralBoundaryCondition_timeFunct
#define _IFT_Load_components
#define OOFEM_LOG_INFO(...)
FloatArrayF< N > min(const FloatArrayF< N > &a, const FloatArrayF< N > &b)
FloatArrayF< N > max(const FloatArrayF< N > &a, const FloatArrayF< N > &b)
std::unique_ptr< EngngModel > InstanciateProblem(DataReader &dr, problemMode mode, int contextFlag, EngngModel *_master, bool parallelFlag)
void logDataMsg(const char *c, T myArray)
ClassFactory & classFactory
#define _IFT_SolutionbasedShapeFunction_DumpSnapshots
#define _IFT_SolutionbasedShapeFunction_Externalset
#define _IFT_SolutionbasedShapeFunction_ShapeFunctionFile
#define _IFT_SolutionbasedShapeFunction_UseCorrectionFactors
std::unique_ptr< EngngModel > myEngngModel
std ::vector< SurfaceDataStruct > SurfaceData