Skip to content

Commit bdbbe05

Browse files
committed
Merge branch 'master' into Release-10.0
2 parents 66eb9fa + 1e22ea3 commit bdbbe05

File tree

60 files changed

+4295
-338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+4295
-338
lines changed

applications/CoSimulationApplication/custom_processes/data_transfer_3D_1D_process.cpp

Lines changed: 353 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
// KRATOS / ___|___/ ___|(_)_ __ ___ _ _| | __ _| |_(_) ___ _ ___
2+
// | | / _ \___ \| | '_ ` _ \| | | | |/ _` | __| |/ _ \| '_ |
3+
// | |__| (_) |__) | | | | | | | |_| | | (_| | |_| | (_) | | | |
4+
// \____\___/____/|_|_| |_| |_|\__,_|_|\__,_|\__|_|\___/|_| |_|
5+
//
6+
// License: BSD License
7+
// license: CoSimulationApplication/license.txt
8+
//
9+
// Main authors: Vicente Mataix Ferrandiz
10+
//
11+
12+
#pragma once
13+
14+
// System includes
15+
16+
// External includes
17+
18+
// Project includes
19+
#include "includes/define.h"
20+
#include "includes/model_part.h"
21+
#include "includes/kratos_parameters.h"
22+
#include "processes/process.h"
23+
24+
/* The mappers includes */
25+
#include "spaces/ublas_space.h"
26+
#include "mappers/mapper_flags.h"
27+
#include "factories/mapper_factory.h"
28+
29+
namespace Kratos
30+
{
31+
///@addtogroup CoSimulationApplication
32+
///@{
33+
34+
///@}
35+
///@name Functions
36+
///@{
37+
38+
///@}
39+
///@name Kratos Classes
40+
///@{
41+
42+
/**
43+
* @class PointElement
44+
* @ingroup CoSimulationApplication
45+
* @brief Custom Point container to be used by the search
46+
* @details It stores the pointer of a certain element
47+
* @author Vicente Mataix Ferrandiz
48+
*/
49+
class PointElement
50+
: public Point
51+
{
52+
public:
53+
54+
///@name Type Definitions
55+
///@{
56+
57+
/// Base class definition
58+
typedef Point BaseType;
59+
60+
/// Counted pointer of PointElement
61+
KRATOS_CLASS_POINTER_DEFINITION( PointElement );
62+
63+
///@}
64+
///@name Life Cycle
65+
///@{
66+
67+
/// Default constructors
68+
PointElement():
69+
BaseType()
70+
{}
71+
72+
PointElement(const double X, const double Y, const double Z)
73+
: BaseType(X, Y, Z)
74+
{}
75+
76+
PointElement(Element::Pointer pElement):
77+
mpElement(pElement)
78+
{
79+
UpdatePoint();
80+
}
81+
82+
83+
///@}
84+
///@name Operators
85+
///@{
86+
87+
///@}
88+
///@name Operations
89+
///@{
90+
91+
/**
92+
* @brief Returns the element associated to the point
93+
* @return mpElement The reference to the element associated to the point
94+
*/
95+
Element::Pointer pGetElement()
96+
{
97+
return mpElement;
98+
}
99+
100+
/**
101+
* @brief This function updates the database, using as base for the coordinates the condition center
102+
*/
103+
void UpdatePoint()
104+
{
105+
noalias(this->Coordinates()) = mpElement->GetGeometry().Center().Coordinates();
106+
}
107+
108+
private:
109+
///@}
110+
///@name Member Variables
111+
///@{
112+
113+
Element::Pointer mpElement = nullptr; // The element instance
114+
115+
///@}
116+
117+
}; // Class PointElement
118+
119+
#define DEFINE_MAPPER_FACTORY_SERIAL \
120+
using SparseSpace = UblasSpace<double, boost::numeric::ublas::compressed_matrix<double>, boost::numeric::ublas::vector<double>>; \
121+
using DenseSpace = UblasSpace<double, DenseMatrix<double>, DenseVector<double>>; \
122+
using MapperFactoryType = MapperFactory<SparseSpace, DenseSpace>; \
123+
using MapperType = Mapper<SparseSpace, DenseSpace>;
124+
125+
/**
126+
* @class DataTransfer3D1DProcess
127+
* @ingroup CoSimulationApplication
128+
* @brief This utility includes auxiliary methods to transfer from 3D domains to 1D domains and viceversa
129+
* @author Vicente Mataix Ferrandiz
130+
*/
131+
class KRATOS_API(CO_SIMULATION_APPLICATION) DataTransfer3D1DProcess
132+
: public Process
133+
{
134+
public:
135+
///@name Type Definitions
136+
///@{
137+
138+
/// Pointer definition of DataTransfer3D1DProcess
139+
KRATOS_CLASS_POINTER_DEFINITION(DataTransfer3D1DProcess);
140+
141+
/// Geometry definition
142+
using GeometryType = Geometry<Node>;
143+
144+
// Define mapper factory
145+
DEFINE_MAPPER_FACTORY_SERIAL
146+
147+
///@}
148+
///@name Life Cycle
149+
///@{
150+
151+
/// Default constructor.
152+
DataTransfer3D1DProcess(
153+
ModelPart& rFirstModelPart,
154+
ModelPart& rSecondModelPart,
155+
Parameters ThisParameters = Parameters(R"({})")
156+
);
157+
158+
159+
///@}
160+
///@name Operators
161+
///@{
162+
163+
void operator()()
164+
{
165+
Execute();
166+
}
167+
168+
///@}
169+
///@name Operations
170+
///@{
171+
172+
/**
173+
* @brief This method executes the process
174+
*/
175+
void Execute() override;
176+
177+
/**
178+
* @brief This method provides the defaults parameters to avoid conflicts between the different constructors
179+
*/
180+
const Parameters GetDefaultParameters() const override;
181+
182+
///@}
183+
private:
184+
///@name Private member Variables
185+
///@{
186+
187+
ModelPart& mr3DModelPart; /// The 3D model part
188+
ModelPart& mr1DModelPart; /// The 1D model part
189+
Parameters mThisParameters; /// The parameters containing the configuration
190+
MapperType::Pointer mpMapper = nullptr; /// The mapper pointer
191+
std::vector<const Variable<double>*> mOriginListVariables; /// The list of variables to be transferred (origin)
192+
std::vector<const Variable<double>*> mDestinationListVariables; /// The list of variables to be transferred (destination)
193+
194+
///@}
195+
///@name Private Operations
196+
///@{
197+
198+
/**
199+
* @brief This method interpolates from the 3D to the 1D
200+
*/
201+
void InterpolateFrom3Dto1D();
202+
203+
/**
204+
* @brief This method interpolates from the 1D to the 3D
205+
*/
206+
void InterpolateFrom1Dto3D();
207+
208+
/**
209+
* @brief This method computes the list of variables to interpolate
210+
* @param rOriginListVariables The list of origin variables to interpolate
211+
* @param rDestinationListVariables The list of destination variables to interpolate
212+
*/
213+
void GetVariablesList(
214+
std::vector<const Variable<double>*>& rOriginListVariables,
215+
std::vector<const Variable<double>*>& rDestinationListVariables
216+
);
217+
218+
/**
219+
* @brief This method computes maximum length of the elements
220+
* @param rModelPart The model part to compute
221+
* @return The maximum length
222+
*/
223+
static double GetMaxLength(const ModelPart& rModelPart);
224+
225+
///@}
226+
}; // Class DataTransfer3D1DProcess
227+
228+
///@}
229+
230+
///@} addtogroup block
231+
232+
} // namespace Kratos.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// KRATOS / ___|___/ ___|(_)_ __ ___ _ _| | __ _| |_(_) ___ _ ___
2+
// | | / _ \___ \| | '_ ` _ \| | | | |/ _` | __| |/ _ \| '_ |
3+
// | |__| (_) |__) | | | | | | | |_| | | (_| | |_| | (_) | | | |
4+
// \____\___/____/|_|_| |_| |_|\__,_|_|\__,_|\__|_|\___/|_| |_|
5+
//
6+
// License: BSD License
7+
// license: CoSimulationApplication/license.txt
8+
//
9+
// Main authors:
10+
//
11+
12+
// System includes
13+
14+
// External includes
15+
16+
// Project includes
17+
#include "includes/define.h"
18+
#include "custom_python/add_custom_processes_to_python.h"
19+
#include "custom_processes/data_transfer_3D_1D_process.h"
20+
21+
namespace Kratos::Python{
22+
23+
void AddCustomProcessesToPython(pybind11::module& m)
24+
{
25+
namespace py = pybind11;
26+
27+
py::class_< DataTransfer3D1DProcess, DataTransfer3D1DProcess::Pointer, Process>(m, "DataTransfer3D1DProcess")
28+
.def(py::init<ModelPart&, ModelPart&>())
29+
.def(py::init<ModelPart&, ModelPart&, Parameters>())
30+
;
31+
}
32+
33+
} // namespace Kratos::Python.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// KRATOS / ___|___/ ___|(_)_ __ ___ _ _| | __ _| |_(_) ___ _ ___
2+
// | | / _ \___ \| | '_ ` _ \| | | | |/ _` | __| |/ _ \| '_ |
3+
// | |__| (_) |__) | | | | | | | |_| | | (_| | |_| | (_) | | | |
4+
// \____\___/____/|_|_| |_| |_|\__,_|_|\__,_|\__|_|\___/|_| |_|
5+
//
6+
// License: BSD License
7+
// license: CoSimulationApplication/license.txt
8+
//
9+
// Main authors:
10+
//
11+
12+
#pragma once
13+
14+
// System includes
15+
#include <pybind11/pybind11.h>
16+
17+
// External includes
18+
19+
// Project includes
20+
#include "includes/define.h"
21+
22+
namespace Kratos::Python {
23+
24+
void AddCustomProcessesToPython(pybind11::module& m);
25+
26+
} // namespace Kratos::Python.

applications/CoSimulationApplication/custom_python/co_simulation_python_application.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "custom_python/add_co_sim_io_to_python.h"
2424
#include "custom_python/add_custom_io_to_python.h"
2525
#include "custom_python/add_custom_utilities_to_python.h"
26+
#include "custom_python/add_custom_processes_to_python.h"
2627

2728
namespace Kratos::Python {
2829

@@ -39,6 +40,7 @@ PYBIND11_MODULE(KratosCoSimulationApplication,m)
3940
AddCoSimIOToPython(m);
4041
AddCustomIOToPython(m);
4142
AddCustomUtilitiesToPython(m);
43+
AddCustomProcessesToPython(m);
4244

4345
KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, SCALAR_DISPLACEMENT );
4446
KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, SCALAR_ROOT_POINT_DISPLACEMENT );

0 commit comments

Comments
 (0)