49 #ifndef KRATOS_PERIODIC_CONDITION_UTILITIES_H
50 #define KRATOS_PERIODIC_CONDITION_UTILITIES_H
163 mrModelPart(ThisModelPart),
192 const double FlagValue)
199 for(ModelPart::NodesContainerType::ptr_iterator itNode = mrModelPart.
Nodes().ptr_begin();
200 itNode != mrModelPart.
Nodes().ptr_end(); itNode++)
202 if( (**itNode).FastGetSolutionStepValue(rFlagVar,0) == FlagValue)
203 mCandidateNodes.push_back(*itNode);
206 if(mCandidateNodes.size() == 0)
KRATOS_THROW_ERROR(std::invalid_argument,
"No nodes found for periodic conditions generation",
"");
228 template<
class TReference >
230 Properties::Pointer pProperties,
231 const std::string& rConditionLabel,
232 const double Tolerance = 1
e-4)
237 if(mpSearchStrategy == 0)
238 KRATOS_THROW_ERROR(std::logic_error,
"PeriodicConditionUtilities error: GenerateConditions() called without a spatial search structure. Please call SetUpSearchStructure() first.",
"")
255 double ResultDistance = 0.0;
260 unsigned int ConditionCount = 0;
261 for(PointVector::iterator itNode = mCandidateNodes.begin(); itNode != mCandidateNodes.end(); itNode++)
263 this->MoveNode(**itNode,ImageNode,MovementRef);
265 SecondNode = mpSearchStrategy->SearchNearestPoint(ImageNode,ResultDistance);
266 if(ResultDistance < Tolerance)
271 Condition::Pointer pNewCondition = rCondition.
Create(++Id,ConditionNodes,pProperties);
272 rConditions.push_back(pNewCondition);
278 std::cout <<
"Found " << ConditionCount <<
" node pairs in periodic boundary." << std::endl;
298 const std::string& rConditionLabel,
299 const double TranslationX,
300 const double TranslationY,
301 const double TranslationZ = 0.0)
306 if(mpSearchStrategy == 0)
307 KRATOS_THROW_ERROR(std::logic_error,
"PeriodicConditionUtilities error: DefinePeriodicBoundary() called without a spatial search structure. Please call SetUpSearchStructure() first.",
"")
310 const double Tolerance = 1
e-4;
313 Translation[0] = TranslationX;
314 Translation[1] = TranslationY;
315 Translation[2] = TranslationZ;
325 rProperties.
GetValue(PERIODIC_VARIABLES).Add(rVariable);
343 virtual std::string
Info()
const
345 return "PeriodicConditionUtilities";
351 rOStream <<
"PeriodicConditionUtilities";
422 tree::Pointer mpSearchStrategy;
438 void MoveNode(
const Node& rInNode, Node& rOutNode,
const Node& rCentreNode )
440 rOutNode.Coordinates() = rInNode.Coordinates() + 2.0 * ( rCentreNode.Coordinates() - rInNode.Coordinates() );
486 rOStream << std::endl;
Definition: bins_static.h:35
Base class for all Conditions.
Definition: condition.h:59
virtual Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const
It creates a new condition pointer.
Definition: condition.h:205
static const TComponentType & Get(const std::string &rName)
Retrieves a component with the specified name.
Definition: kratos_components.h:114
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
ConditionsContainerType::ContainerType & ConditionsArray(IndexType ThisIndex=0)
Definition: model_part.h:1401
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
ConditionIterator ConditionsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1371
This class defines the node.
Definition: node.h:65
Auxiliary utilitiy to define periodic boundary conditions for flow problems.
Definition: periodic_condition_utilities.h:121
Bins< 3, PointType, PointVector, PointTypePointer, PointIterator, DistanceIterator > StaticBins
Definition: periodic_condition_utilities.h:143
Node PointType
Definition: periodic_condition_utilities.h:134
std::size_t SizeType
Definition: periodic_condition_utilities.h:131
void SetUpSearchStructure(Variable< double > const &rFlagVar, const double FlagValue)
Set a spatial search structure that will be used to find the periodic boundary node pairs.
Definition: periodic_condition_utilities.h:191
PeriodicConditionUtilities(ModelPart &ThisModelPart, SizeType ThisDomainSize)
Default constructor.
Definition: periodic_condition_utilities.h:161
std::vector< PointType::Pointer > PointVector
Definition: periodic_condition_utilities.h:136
Node::Pointer PointTypePointer
Definition: periodic_condition_utilities.h:135
void DefinePeriodicBoundary(Properties::Pointer pNewProperties, const std::string &rConditionLabel, const double TranslationX, const double TranslationY, const double TranslationZ=0.0)
Find node pairs to define periodic boundary conditions.
Definition: periodic_condition_utilities.h:297
virtual ~PeriodicConditionUtilities()
Destructor.
Definition: periodic_condition_utilities.h:169
Tree< StaticBins > tree
Definition: periodic_condition_utilities.h:149
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: periodic_condition_utilities.h:349
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: periodic_condition_utilities.h:355
KRATOS_CLASS_POINTER_DEFINITION(PeriodicConditionUtilities)
Pointer definition of PeriodicConditionUtilities.
std::vector< PointType::Pointer >::iterator PointIterator
Definition: periodic_condition_utilities.h:137
virtual std::string Info() const
Turn back information as a string.
Definition: periodic_condition_utilities.h:343
std::vector< double >::iterator DistanceIterator
Definition: periodic_condition_utilities.h:139
void GenerateConditions(const TReference &MovementRef, Properties::Pointer pProperties, const std::string &rConditionLabel, const double Tolerance=1e-4)
Generate a set of conditions linking each node in the periodic boundary to its image on the other sid...
Definition: periodic_condition_utilities.h:229
std::vector< double > DistanceVector
Definition: periodic_condition_utilities.h:138
std::size_t IndexType
Definition: periodic_condition_utilities.h:129
void AddPeriodicVariable(Properties &rProperties, Variable< double > &rVariable)
Definition: periodic_condition_utilities.h:322
CoordinatesArrayType const & Coordinates() const
Definition: point.h:215
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
TContainerType & GetContainer()
Definition: pointer_vector.h:334
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
TVariableType::Type & GetValue(const TVariableType &rVariable)
Definition: properties.h:228
A generic tree data structure for spatial partitioning.
Definition: tree.h:190
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::shared_ptr< T > shared_ptr
Definition: smart_pointers.h:27
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::vector< PointTypePointer > PointVector
Definition: internal_variables_interpolation_process.h:53
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
e
Definition: run_cpp_mpi_tests.py:31