14 #if !defined(KRATOS_DISTANCE_CALCULATION_ELEMENT_H_INCLUDED )
15 #define KRATOS_DISTANCE_CALCULATION_ELEMENT_H_INCLUDED
32 #include "utilities/geometry_utilities.h"
66 template<
unsigned int TDim >
151 Element(NewId, pGeometry, pProperties)
177 PropertiesType::Pointer pProperties)
const override
191 GeometryType::Pointer pGeom,
192 PropertiesType::Pointer pProperties)
const override
202 const unsigned int number_of_points = TDim+1;
207 if (rLeftHandSideMatrix.size1() != number_of_points)
208 rLeftHandSideMatrix.
resize(number_of_points, number_of_points,
false);
210 if (rRightHandSideVector.size() != number_of_points)
211 rRightHandSideVector.
resize(number_of_points,
false);
219 for(
unsigned int i=0;
i<number_of_points;
i++)
221 distances[
i] =
GetGeometry()[
i].FastGetSolutionStepValue(DISTANCE);
227 const double coeff1 = rCurrentProcessInfo.
Has(VARIATIONAL_REDISTANCE_COEFFICIENT_FIRST) ? rCurrentProcessInfo[VARIATIONAL_REDISTANCE_COEFFICIENT_FIRST] : 0.01;
228 const double coeff2 = rCurrentProcessInfo.
Has(VARIATIONAL_REDISTANCE_COEFFICIENT_SECOND) ? rCurrentProcessInfo[VARIATIONAL_REDISTANCE_COEFFICIENT_SECOND] : 0.1;
229 const unsigned int step = rCurrentProcessInfo[FRACTIONAL_STEP];
241 if(dgauss < 0.0) source=-1.0;
242 noalias(rRightHandSideVector) = source*Area*
N;
244 noalias(rRightHandSideVector) -=
prod(rLeftHandSideMatrix,distances);
248 unsigned int nboundary = 0;
249 for(
unsigned int i=0;
i<TDim+1;
i++)
252 if(nboundary == TDim)
255 for(
unsigned int i=0;
i<TDim+1;
i++)
262 double normDn =
norm_2(DN_out);
263 for(
unsigned int i=0;
i<TDim+1;
i++)
266 rRightHandSideVector[
i] += coeff1*source*normDn*Area*(TDim-1);
277 if( dgauss * (this->
GetValue(DISTANCE)) < 0.0 )
278 std::cout <<
"Element " << this->
Id() <<
" changed sign while redistancing!!" << std::endl;
286 noalias(rRightHandSideVector) = Area*(1.0 - grad_norm)*
prod(DN_DX,
grad);
314 const ProcessInfo& rCurrentProcessInfo)
const override
317 unsigned int number_of_nodes = TDim+1;
318 if (rResult.size() != number_of_nodes)
319 rResult.resize(number_of_nodes,
false);
321 for (
unsigned int i = 0;
i < number_of_nodes;
i++)
331 const ProcessInfo& rCurrentProcessInfo)
const override
333 unsigned int number_of_nodes = TDim+1;
335 if (rElementalDofList.size() != number_of_nodes)
336 rElementalDofList.resize(number_of_nodes);
338 for (
unsigned int i = 0;
i < number_of_nodes;
i++)
367 if(ErrorCode != 0)
return ErrorCode;
377 if(this->
GetGeometry()[
i].SolutionStepsDataHas(DISTANCE) ==
false)
392 if (rRightHandSideVector.size() != 0)
393 rRightHandSideVector.
resize(0,
false);
407 "time_integration" : ["static"],
408 "framework" : "eulerian",
409 "symmetric_lhs" : true,
410 "positive_definite_lhs" : true,
413 "nodal_historical" : ["DISTANCE"],
414 "nodal_non_historical" : [],
417 "required_variables" : ["DISTANCE"],
418 "required_dofs" : ["DISTANCE"],
419 "flags_used" : ["BOUNDARY"],
420 "compatible_geometries" : ["Triangle2D3","Tetrahedra3D4"],
421 "element_integrates_in_time" : false,
422 "compatible_constitutive_laws": {
427 "required_polynomial_degree_of_geometry" : 1,
429 "This element is intended to be used in combination with the VariationalDistanceCalculationProcess. It implements a two-step resolution of an Eikonal equation in order to obtain a distance field with unit gradient norm."
431 return specifications;
435 std::string
Info()
const override
437 std::stringstream buffer;
438 buffer <<
"DistanceCalculationElementSimplex #" <<
Id();
445 rOStream <<
"DistanceCalculationElementSimplex" << TDim <<
"D";
508 void save(
Serializer& rSerializer)
const override
564 template<
unsigned int TDim >
572 template<
unsigned int TDim >
577 rOStream << std::endl;
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
bool Has(const Variable< TDataType > &rThisVariable) const
Checks if the data container has a value associated with a given variable.
Definition: data_value_container.h:382
A stabilized element for the incompressible Navier-Stokes equations.
Definition: distance_calculation_element_simplex.h:68
Geometry< NodeType > GeometryType
Geometry type (using with given NodeType)
Definition: distance_calculation_element_simplex.h:80
Matrix MatrixType
Matrix type for local contributions to the linear system.
Definition: distance_calculation_element_simplex.h:89
const Parameters GetSpecifications() const override
This method provides the specifications/requirements of the element.
Definition: distance_calculation_element_simplex.h:404
~DistanceCalculationElementSimplex() override
Destructor.
Definition: distance_calculation_element_simplex.h:155
DistanceCalculationElementSimplex(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties)
Constuctor using geometry and properties.
Definition: distance_calculation_element_simplex.h:150
Element::Pointer Create(IndexType NewId, GeometryType::Pointer pGeom, PropertiesType::Pointer pProperties) const override
Create a new element of this type.
Definition: distance_calculation_element_simplex.h:190
Element::Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const override
Create a new element of this type.
Definition: distance_calculation_element_simplex.h:176
void GetDofList(DofsVectorType &rElementalDofList, const ProcessInfo &rCurrentProcessInfo) const override
Returns a list of the element's Dofs.
Definition: distance_calculation_element_simplex.h:330
DistanceCalculationElementSimplex(IndexType NewId=0)
Default constuctor.
Definition: distance_calculation_element_simplex.h:122
Kratos::Matrix ShapeFunctionDerivativesType
Type for a matrix containing the shape function gradients.
Definition: distance_calculation_element_simplex.h:107
PointerVectorSet< DofType > DofsArrayType
Definition: distance_calculation_element_simplex.h:101
DistanceCalculationElementSimplex(IndexType NewId, const NodesArrayType &ThisNodes)
Constructor using an array of nodes.
Definition: distance_calculation_element_simplex.h:131
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: distance_calculation_element_simplex.h:443
Kratos::Vector ShapeFunctionsType
Type for shape function values container.
Definition: distance_calculation_element_simplex.h:104
GeometryType::ShapeFunctionsGradientsType ShapeFunctionDerivativesArrayType
Type for an array of shape function gradient matrices.
Definition: distance_calculation_element_simplex.h:110
void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Calculate the element's local contribution to the system for the current step.
Definition: distance_calculation_element_simplex.h:198
std::size_t SizeType
Definition: distance_calculation_element_simplex.h:93
DistanceCalculationElementSimplex(IndexType NewId, GeometryType::Pointer pGeometry)
Constructor using a geometry object.
Definition: distance_calculation_element_simplex.h:140
Node NodeType
Node type (default is: Node)
Definition: distance_calculation_element_simplex.h:77
std::vector< std::size_t > EquationIdVectorType
Definition: distance_calculation_element_simplex.h:97
int Check(const ProcessInfo &rCurrentProcessInfo) const override
Checks the input and that all required Kratos variables have been registered.
Definition: distance_calculation_element_simplex.h:361
void EquationIdVector(EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const override
Provides the global indices for each one of this element's local rows.
Definition: distance_calculation_element_simplex.h:313
Dof< double > DofType
Definition: distance_calculation_element_simplex.h:95
void CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Definition: distance_calculation_element_simplex.h:388
std::string Info() const override
Turn back information as a string.
Definition: distance_calculation_element_simplex.h:435
Vector VectorType
Vector type for local contributions to the linear system.
Definition: distance_calculation_element_simplex.h:86
std::vector< DofType::Pointer > DofsVectorType
Definition: distance_calculation_element_simplex.h:99
std::size_t IndexType
Definition: distance_calculation_element_simplex.h:91
KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(DistanceCalculationElementSimplex)
Pointer definition of DistanceCalculationElementSimplex.
Geometry< NodeType >::PointsArrayType NodesArrayType
Definition of nodes container type, redefined from GeometryType.
Definition: distance_calculation_element_simplex.h:83
Dof represents a degree of freedom (DoF).
Definition: dof.h:86
Base class for all Elements.
Definition: element.h:60
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: element.h:1135
virtual int Check(const ProcessInfo &rCurrentProcessInfo) const
Definition: element.h:904
std::size_t IndexType
Definition: flags.h:74
bool Is(Flags const &rOther) const
Definition: flags.h:274
bool IsNot(Flags const &rOther) const
Definition: flags.h:291
TVariableType::Type & GetValue(const TVariableType &rThisVariable)
Definition: geometrical_object.h:248
GeometryType & GetGeometry()
Returns the reference of the geometry.
Definition: geometrical_object.h:158
void SetValue(const TVariableType &rThisVariable, typename TVariableType::Type const &rValue)
Definition: geometrical_object.h:238
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
IndexType const & Id() const
Id of this Geometry.
Definition: geometry.h:964
static void CalculateGeometryData(const GeometryType &rGeometry, BoundedMatrix< double, 4, 3 > &rDN_DX, array_1d< double, 4 > &rN, double &rVolume)
This function is designed to compute the shape function derivatives, shape functions and volume in 3D...
Definition: geometry_utilities.h:176
IndexType Id() const
Definition: indexed_object.h:107
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
This class defines the node.
Definition: node.h:65
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
#define KRATOS_SERIALIZE_SAVE_BASE_CLASS(Serializer, BaseType)
Definition: define.h:812
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_SERIALIZE_LOAD_BASE_CLASS(Serializer, BaseType)
Definition: define.h:815
#define KRATOS_ERROR
Definition: exception.h:161
static double max(double a, double b)
Definition: GeometryFunctions.h:79
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
AMatrix::MatrixRow< const TExpressionType > row(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression, std::size_t RowIndex)
Definition: amatrix_interface.h:649
AMatrix::TransposeMatrix< const T > trans(const T &TheMatrix)
Definition: amatrix_interface.h:486
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
int step
Definition: face_heat.py:88
grad
Definition: hinsberg_optimization.py:148
def load(f)
Definition: ode_solve.py:307
N
Definition: sensitivityMatrix.py:29
integer i
Definition: TensorModule.f:17