Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Modify coordinate_transformation_utilities.h to allow transformation back to global coordinates #12327

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
227 changes: 133 additions & 94 deletions kratos/utilities/coordinate_transformation_utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,95 +465,7 @@ class CoordinateTransformationUtils {
virtual void Rotate(TLocalVectorType& rLocalVector,
GeometryType& rGeometry) const
{
//const unsigned int LocalSize = rLocalVector.size(); // We expect this to work both with elements (4 nodes) and conditions (3 nodes)

//unsigned int Index = 0;

if (rLocalVector.size() > 0)
{
if(mBlockSize != mDomainSize) //Monolithic case
{
for(unsigned int j = 0; j < rGeometry.PointsNumber(); ++j)
{
if( this->IsSlip(rGeometry[j]) )
{
if(mDomainSize == 3)
{
array_1d<double,4> aux,aux1;
BoundedMatrix<double,4,4> rRot;
LocalRotationOperator3D<4>(rRot,rGeometry[j]);

for(unsigned int k=0; k<4; k++)
aux[k] = rLocalVector[j*mBlockSize+k];

noalias(aux1) = prod(rRot,aux);

for(unsigned int k=0; k<4; k++)
rLocalVector[j*mBlockSize+k] = aux1[k];
}
else
{
array_1d<double,3> aux,aux1;
BoundedMatrix<double,3,3> rRot;
LocalRotationOperator2D<3>(rRot,rGeometry[j]);

for(unsigned int k=0; k<3; k++)
{
aux[k] = rLocalVector[j*mBlockSize+k];
}

noalias(aux1) = prod(rRot,aux);

for(unsigned int k=0; k<3; k++)
rLocalVector[j*mBlockSize+k] = aux1[k];
}
}
//Index += mBlockSize;
}

}
else //fractional step case
{
for(unsigned int j = 0; j < rGeometry.PointsNumber(); ++j)
{
if( this->IsSlip(rGeometry[j]) )
{
if(mDomainSize == 3)
{
array_1d<double,3> aux,aux1;
BoundedMatrix<double,3,3> rRot;
LocalRotationOperatorPure(rRot,rGeometry[j]);

for(unsigned int k=0; k<3; k++)
aux[k] = rLocalVector[j*mBlockSize+k];

noalias(aux1) = prod(rRot,aux);

for(unsigned int k=0; k<3; k++)
rLocalVector[j*mBlockSize+k] = aux1[k];
}
else
{
array_1d<double,2> aux,aux1;
BoundedMatrix<double,2,2> rRot;
LocalRotationOperatorPure(rRot,rGeometry[j]);

for(unsigned int k=0; k<2; k++)
aux[k] = rLocalVector[j*mBlockSize+k];

noalias(aux1) = prod(rRot,aux);

for(unsigned int k=0; k<2; k++)
rLocalVector[j*mBlockSize+k] = aux1[k];
}
}
//Index += mBlockSize;
}

}

}

RotateRHSAux(rLocalVector, rGeometry);
VeronikaSinger marked this conversation as resolved.
Show resolved Hide resolved
}

/// Apply slip boundary conditions to the rotated local contributions.
Expand Down Expand Up @@ -753,7 +665,118 @@ class CoordinateTransformationUtils {
///@name Protected Operations
///@{

template<unsigned int TDim, unsigned int TBlockSize, unsigned int TSkip = 0>
template<bool TToGlobalCoord = false>
void RotateRHSAux(TLocalVectorType& rLocalVector,
GeometryType& rGeometry) const
{
if (rLocalVector.size() > 0)
{
if(mBlockSize != mDomainSize) //Monolithic case
{
for(unsigned int j = 0; j < rGeometry.PointsNumber(); ++j)
{
if( this->IsSlip(rGeometry[j]) )
{
if(mDomainSize == 3)
{
array_1d<double,4> aux,aux1;
BoundedMatrix<double,4,4> rRot;
LocalRotationOperator3D<4>(rRot,rGeometry[j]);

for(unsigned int k=0; k<4; k++)
aux[k] = rLocalVector[j*mBlockSize+k];

if constexpr (TToGlobalCoord)
{
noalias(aux1) = prod(trans(rRot),aux);
} else{
noalias(aux1) = prod(rRot,aux);
}

for(unsigned int k=0; k<4; k++)
rLocalVector[j*mBlockSize+k] = aux1[k];
}
else
{
array_1d<double,3> aux,aux1;
BoundedMatrix<double,3,3> rRot;
LocalRotationOperator2D<3>(rRot,rGeometry[j]);

for(unsigned int k=0; k<3; k++)
{
aux[k] = rLocalVector[j*mBlockSize+k];
}

if constexpr (TToGlobalCoord)
{
noalias(aux1) = prod(trans(rRot),aux);
} else{
noalias(aux1) = prod(rRot,aux);
}

for(unsigned int k=0; k<3; k++)
rLocalVector[j*mBlockSize+k] = aux1[k];
}
}
//Index += mBlockSize;
}

}
else //fractional step case
{
for(unsigned int j = 0; j < rGeometry.PointsNumber(); ++j)
{
if( this->IsSlip(rGeometry[j]) )
{
if(mDomainSize == 3)
{
array_1d<double,3> aux,aux1;
BoundedMatrix<double,3,3> rRot;
LocalRotationOperatorPure(rRot,rGeometry[j]);

for(unsigned int k=0; k<3; k++)
aux[k] = rLocalVector[j*mBlockSize+k];

if constexpr (TToGlobalCoord)
{
noalias(aux1) = prod(trans(rRot),aux);
} else{
noalias(aux1) = prod(rRot,aux);
}

for(unsigned int k=0; k<3; k++)
rLocalVector[j*mBlockSize+k] = aux1[k];
}
else
{
array_1d<double,2> aux,aux1;
BoundedMatrix<double,2,2> rRot;
LocalRotationOperatorPure(rRot,rGeometry[j]);

for(unsigned int k=0; k<2; k++)
aux[k] = rLocalVector[j*mBlockSize+k];

if constexpr (TToGlobalCoord)
{
noalias(aux1) = prod(trans(rRot),aux);
} else{
noalias(aux1) = prod(rRot,aux);
}

for(unsigned int k=0; k<2; k++)
rLocalVector[j*mBlockSize+k] = aux1[k];
}
}
//Index += mBlockSize;
}

}

}

}

template<unsigned int TDim, unsigned int TBlockSize, unsigned int TSkip = 0, bool TToGlobalCoord = false>
void RotateAux(TLocalMatrixType& rLocalMatrix,
TLocalVectorType& rLocalVector,
GeometryType& rGeometry) const
Expand All @@ -766,6 +789,8 @@ class CoordinateTransformationUtils {
DenseVector<bool> NeedRotation( NumBlocks, false);

std::vector< BoundedMatrix<double,TBlockSize,TBlockSize> > rRot(NumBlocks);
BoundedMatrix<double,TBlockSize,TBlockSize> tmp;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation.


for(unsigned int j = 0; j < NumBlocks; ++j)
{
if( this->IsSlip(rGeometry[j]) )
Expand All @@ -775,14 +800,20 @@ class CoordinateTransformationUtils {

if constexpr (TDim == 2) LocalRotationOperator2D<TBlockSize,TSkip>(rRot[j],rGeometry[j]);
else LocalRotationOperator3D<TBlockSize,TSkip>(rRot[j],rGeometry[j]);

if constexpr (TToGlobalCoord)
{
noalias(tmp) = trans(rRot[j]);
rRot[j] = tmp;
}
}

//Index += TBlockSize;
}

if(rotations_needed > 0)
{
BoundedMatrix<double,TBlockSize,TBlockSize> mat_block, tmp;
BoundedMatrix<double,TBlockSize,TBlockSize> mat_block;
array_1d<double,TBlockSize> aux, aux1;

for(unsigned int i=0; i<NumBlocks; i++)
Expand Down Expand Up @@ -833,7 +864,7 @@ class CoordinateTransformationUtils {
}

//to be used when there is only velocity (no additional pressure or other var block)
template<unsigned int TDim>
template<unsigned int TDim, bool TToGlobalCoord = false>
void RotateAuxPure(TLocalMatrixType& rLocalMatrix,
TLocalVectorType& rLocalVector,
GeometryType& rGeometry) const
Expand All @@ -846,6 +877,8 @@ class CoordinateTransformationUtils {
DenseVector<bool> NeedRotation( NumBlocks, false);

std::vector< BoundedMatrix<double,TDim,TDim> > rRot(NumBlocks);
BoundedMatrix<double,TDim,TDim> tmp;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation.


for(unsigned int j = 0; j < NumBlocks; ++j)
{
if( this->IsSlip(rGeometry[j]) )
Expand All @@ -854,14 +887,20 @@ class CoordinateTransformationUtils {
rotations_needed++;

LocalRotationOperatorPure(rRot[j],rGeometry[j]);
}

if constexpr (TToGlobalCoord)
{
noalias(tmp) = trans(rRot[j]);
rRot[j] = tmp;
}
}

//Index += mBlockSize;
}

if(rotations_needed > 0)
{
BoundedMatrix<double,TDim,TDim> mat_block, tmp;
BoundedMatrix<double,TDim,TDim> mat_block;
array_1d<double,TDim> aux, aux1;

for(unsigned int i=0; i<NumBlocks; i++)
Expand Down
Loading