Skip to content
Snippets Groups Projects
Commit b8660aba authored by Van Dung NGUYEN's avatar Van Dung NGUYEN
Browse files

correct shifted BC

parent 5bcb4308
Branches
Tags
1 merge request!23Update jl_gurs
......@@ -338,7 +338,9 @@ void nonLinearShiftedPeriodicBC::setShiftPBCNormal(const double n1, const double
_shiftPBCNormal[1] = n2;
_shiftPBCNormal[2] = n3;
printf("set Shifted PBC = [%f %f %f]\n",n1,n2,n3);
if (_shiftPBCNormal.norm()> 0.){
_shiftPBCNormal.normalize();
}
};
void nonLinearShiftedPeriodicBC::setShiftPBCNormal(const SVector3& n){
this->setShiftPBCNormal(n[0],n[1],n[2]);
......@@ -350,6 +352,21 @@ void nonLinearShiftedPeriodicBC::updateWithSolver(const nonLinearMechSolver* s){
printf("shitfed with lost of solution uniqueness normal : n = [%f %f %f]",_shiftPBCNormal[0],_shiftPBCNormal[1],_shiftPBCNormal[2]);
};
nonLinearGeneralPeriodicBC::nonLinearGeneralPeriodicBC(const int tag, const int dim):nonLinearPeriodicBC(tag,dim),
_pbcNormal(0.){};
nonLinearGeneralPeriodicBC::nonLinearGeneralPeriodicBC(const nonLinearGeneralPeriodicBC& src):nonLinearPeriodicBC(src),
_pbcNormal(src._pbcNormal){};
void nonLinearGeneralPeriodicBC::setPBCNormal(const double n1, const double n2, const double n3){
_pbcNormal[0] = n1;
_pbcNormal[1] = n1;
_pbcNormal[2] = n2;
if (_pbcNormal.norm() >0){
_pbcNormal.normalize();
}
};
nonLinearDisplacementBC::nonLinearDisplacementBC( const int tag, const int dim):
nonLinearMicroBC(tag,dim){};
......
......@@ -507,6 +507,25 @@ class nonLinearShiftedPeriodicBC : public nonLinearPeriodicBC{
void setShiftPBCNormal(const double n1, const double n2, const double n3);
};
class nonLinearGeneralPeriodicBC : public nonLinearPeriodicBC{
protected:
#ifndef SWIG
SVector3 _pbcNormal; // unit normal of PBC plane
#endif //SWIG
public:
nonLinearGeneralPeriodicBC(const int tag, const int dim);
#ifndef SWIG
nonLinearGeneralPeriodicBC(const nonLinearGeneralPeriodicBC& src);
virtual ~nonLinearGeneralPeriodicBC(){};
virtual nonLinearMicroBC::whichBCType getType() const {return nonLinearMicroBC::GeneralPBC;};
virtual nonLinearMicroBC* clone() const {return new nonLinearGeneralPeriodicBC(*this);};
const SVector3& getPBCNormal() const {return _pbcNormal;};
void setPBCNormal(const SVector3& n) {_pbcNormal = n;}
#endif //SWIG
void setPBCNormal(const double n1, const double n2, const double n3);
};
class nonLinearDisplacementBC : public nonLinearMicroBC{
......
......@@ -1679,12 +1679,6 @@ void pbcConstraintElementGroup::createShiftedLagrangeConstraintElementGroup(){
nonLinearShiftedPeriodicBC* pbc = static_cast<nonLinearShiftedPeriodicBC*>(_solver->getMicroBC());
const SVector3& normal = pbc->getShiftPBCNormal();
normal.print("normal");
if (normal.norm() < 1e-10){
printf("no shifted if normal is zero pbcConstraintElementGroup::createShiftedLagrangeConstraintElementGroup \n");
this->createLagrangeConstraintElementGroup();
return;
}
int dim = _solver->getMicroBC()->getDim();
const std::vector<groupOfElements*>& bgroup = _solver->getMicroBC()->getBoundaryGroupOfElements();
......@@ -2105,12 +2099,6 @@ void pbcConstraintElementGroup::createCornerConstraintElementGroupShiftedBPC(){
nonLinearShiftedPeriodicBC* spbc = static_cast<nonLinearShiftedPeriodicBC*>(_solver->getMicroBC());
const SVector3& normal = spbc->getShiftPBCNormal();
normal.print("normal");
if (normal.norm() < 1e-10){
this->createCornerConstraintElementGroup();
}
else{
if (spbc->getPBCMethod() == nonLinearPeriodicBC::LIM){
if (_cVertices.size() > 0){
constraintElement* cel = new periodicMeshConstraint(_solver->getMicroBC() ,_LagSpace,_MultSpace,-1,_v1);
......@@ -2120,7 +2108,6 @@ void pbcConstraintElementGroup::createCornerConstraintElementGroupShiftedBPC(){
else{
Msg::Fatal("this method is not implemented to impose shiftedPBC");
}
}
}
......@@ -2508,29 +2495,7 @@ void pbcConstraintElementGroup::createCornerConstraintElementGroup(){
};
void pbcConstraintElementGroup::createConstraintGroup(){
constraintElement::allPositiveDof.clear();
if (_fullDG){
if (_solver->getMicroBC()->getType()==nonLinearMicroBC::LDBC){
Msg::Info("Imposing linear displacement BC");
this->createLinearDisplacementConstraintElementGroup_DG();
}
else if (_solver->getMicroBC()->getType()==nonLinearMicroBC::MKBC){
Msg::Info("Imposing minimal kinematical BC");
this->createMinimalKinematicConstraintElementGroup_DG();
}
else if (_solver->getMicroBC()->getType() == nonLinearMicroBC::MIXBC){
Msg::Info("imposing mixed BC");
this->createMixBCConstraintElementGroup_DG();
}
else{
Msg::Error("this boundary condition type is not implemented");
};
}
else{
if (_solver->getMicroBC()->getType() == nonLinearMicroBC::PBC){
void pbcConstraintElementGroup::createPBCConstraintGroup(){
nonLinearPeriodicBC* pbc = static_cast<nonLinearPeriodicBC*>(_solver->getMicroBC());
if (pbc->getPBCMethod() == nonLinearPeriodicBC::CEM){
......@@ -2562,9 +2527,19 @@ void pbcConstraintElementGroup::createConstraintGroup(){
Msg::Fatal("this method is not implemented to impose PBC");
}
this->createCornerConstraintElementGroup();
}
else if (_solver->getMicroBC()->getType() == nonLinearMicroBC::ShiftedPBC){
};
void pbcConstraintElementGroup::createShiftedPBCConstraintGroup(){
nonLinearShiftedPeriodicBC* spbc = static_cast<nonLinearShiftedPeriodicBC*>(_solver->getMicroBC());
const SVector3& normal = spbc->getShiftPBCNormal();
if (normal.norm() < 1e-10){
printf("because shifted vector is null, usual PBC is used\n");
this->createPBCConstraintGroup();
}
else{
//
printf("PBC is shifted using Lagrange interpolation method\n");
spbc->setPBCMethod(nonLinearPeriodicBC::LIM);
if (spbc->getPBCMethod() == nonLinearPeriodicBC::LIM){
Msg::Info("Imposing PBC by lagrange formulation");
......@@ -2575,6 +2550,36 @@ void pbcConstraintElementGroup::createConstraintGroup(){
};
this->createCornerConstraintElementGroupShiftedBPC();
}
};
void pbcConstraintElementGroup::createConstraintGroup(){
constraintElement::allPositiveDof.clear();
if (_fullDG){
if (_solver->getMicroBC()->getType()==nonLinearMicroBC::LDBC){
Msg::Info("Imposing linear displacement BC");
this->createLinearDisplacementConstraintElementGroup_DG();
}
else if (_solver->getMicroBC()->getType()==nonLinearMicroBC::MKBC){
Msg::Info("Imposing minimal kinematical BC");
this->createMinimalKinematicConstraintElementGroup_DG();
}
else if (_solver->getMicroBC()->getType() == nonLinearMicroBC::MIXBC){
Msg::Info("imposing mixed BC");
this->createMixBCConstraintElementGroup_DG();
}
else{
Msg::Error("this boundary condition type is not implemented");
};
}
else{
if (_solver->getMicroBC()->getType() == nonLinearMicroBC::PBC){
this->createPBCConstraintGroup();
}
else if (_solver->getMicroBC()->getType() == nonLinearMicroBC::ShiftedPBC){
this->createShiftedPBCConstraintGroup();
}
else if (_solver->getMicroBC()->getType()==nonLinearMicroBC::LDBC){
Msg::Info("Imposing linear displacement BC");
......
......@@ -256,6 +256,8 @@ class pbcConstraintElementGroup{
void createOrthogonalMixBCConstraintElementGroupDirectionFollowing();
void createPBCConstraintGroup();
void createShiftedPBCConstraintGroup();
SVector3 getUniformDisp(MVertex* v);
SVector3 getPerturbation(dofManager<double>* pmanager, MVertex* v);
......
......@@ -69,7 +69,7 @@ microBC.setOrder(1)
microBC.setBCPhysical(1,4,3,2)
method =1 # Periodic mesh = 0, Langrange interpolation = 1, Cubic spline interpolation =2, FE linear= 3, FE Quad = 4
degree = 5 # Order used for polynomial interpolation
addvertex = 0 # Polynomial interpolation by mesh vertex = 0, Polynomial interpolation by virtual vertex
addvertex = 1 # Polynomial interpolation by mesh vertex = 0, Polynomial interpolation by virtual vertex
microBC.setPeriodicBCOptions(method, degree,bool(addvertex))
theta = pi/10;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment