-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10634 from KratosMultiphysics/cosim/tetra-line-da…
…ta-transfer [CoSimulationApplication] 3D domain (volume) - 1D domain (line) data transfer operator
- Loading branch information
Showing
14 changed files
with
3,312 additions
and
0 deletions.
There are no files selected for viewing
353 changes: 353 additions & 0 deletions
353
applications/CoSimulationApplication/custom_processes/data_transfer_3D_1D_process.cpp
Large diffs are not rendered by default.
Oops, something went wrong.
232 changes: 232 additions & 0 deletions
232
applications/CoSimulationApplication/custom_processes/data_transfer_3D_1D_process.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,232 @@ | ||
// KRATOS / ___|___/ ___|(_)_ __ ___ _ _| | __ _| |_(_) ___ _ ___ | ||
// | | / _ \___ \| | '_ ` _ \| | | | |/ _` | __| |/ _ \| '_ | | ||
// | |__| (_) |__) | | | | | | | |_| | | (_| | |_| | (_) | | | | | ||
// \____\___/____/|_|_| |_| |_|\__,_|_|\__,_|\__|_|\___/|_| |_| | ||
// | ||
// License: BSD License | ||
// license: CoSimulationApplication/license.txt | ||
// | ||
// Main authors: Vicente Mataix Ferrandiz | ||
// | ||
|
||
#pragma once | ||
|
||
// System includes | ||
|
||
// External includes | ||
|
||
// Project includes | ||
#include "includes/define.h" | ||
#include "includes/model_part.h" | ||
#include "includes/kratos_parameters.h" | ||
#include "processes/process.h" | ||
|
||
/* The mappers includes */ | ||
#include "spaces/ublas_space.h" | ||
#include "mappers/mapper_flags.h" | ||
#include "factories/mapper_factory.h" | ||
|
||
namespace Kratos | ||
{ | ||
///@addtogroup CoSimulationApplication | ||
///@{ | ||
|
||
///@} | ||
///@name Functions | ||
///@{ | ||
|
||
///@} | ||
///@name Kratos Classes | ||
///@{ | ||
|
||
/** | ||
* @class PointElement | ||
* @ingroup CoSimulationApplication | ||
* @brief Custom Point container to be used by the search | ||
* @details It stores the pointer of a certain element | ||
* @author Vicente Mataix Ferrandiz | ||
*/ | ||
class PointElement | ||
: public Point | ||
{ | ||
public: | ||
|
||
///@name Type Definitions | ||
///@{ | ||
|
||
/// Base class definition | ||
typedef Point BaseType; | ||
|
||
/// Counted pointer of PointElement | ||
KRATOS_CLASS_POINTER_DEFINITION( PointElement ); | ||
|
||
///@} | ||
///@name Life Cycle | ||
///@{ | ||
|
||
/// Default constructors | ||
PointElement(): | ||
BaseType() | ||
{} | ||
|
||
PointElement(const double X, const double Y, const double Z) | ||
: BaseType(X, Y, Z) | ||
{} | ||
|
||
PointElement(Element::Pointer pElement): | ||
mpElement(pElement) | ||
{ | ||
UpdatePoint(); | ||
} | ||
|
||
|
||
///@} | ||
///@name Operators | ||
///@{ | ||
|
||
///@} | ||
///@name Operations | ||
///@{ | ||
|
||
/** | ||
* @brief Returns the element associated to the point | ||
* @return mpElement The reference to the element associated to the point | ||
*/ | ||
Element::Pointer pGetElement() | ||
{ | ||
return mpElement; | ||
} | ||
|
||
/** | ||
* @brief This function updates the database, using as base for the coordinates the condition center | ||
*/ | ||
void UpdatePoint() | ||
{ | ||
noalias(this->Coordinates()) = mpElement->GetGeometry().Center().Coordinates(); | ||
} | ||
|
||
private: | ||
///@} | ||
///@name Member Variables | ||
///@{ | ||
|
||
Element::Pointer mpElement = nullptr; // The element instance | ||
|
||
///@} | ||
|
||
}; // Class PointElement | ||
|
||
#define DEFINE_MAPPER_FACTORY_SERIAL \ | ||
using SparseSpace = UblasSpace<double, boost::numeric::ublas::compressed_matrix<double>, boost::numeric::ublas::vector<double>>; \ | ||
using DenseSpace = UblasSpace<double, DenseMatrix<double>, DenseVector<double>>; \ | ||
using MapperFactoryType = MapperFactory<SparseSpace, DenseSpace>; \ | ||
using MapperType = Mapper<SparseSpace, DenseSpace>; | ||
|
||
/** | ||
* @class DataTransfer3D1DProcess | ||
* @ingroup CoSimulationApplication | ||
* @brief This utility includes auxiliary methods to transfer from 3D domains to 1D domains and viceversa | ||
* @author Vicente Mataix Ferrandiz | ||
*/ | ||
class KRATOS_API(CO_SIMULATION_APPLICATION) DataTransfer3D1DProcess | ||
: public Process | ||
{ | ||
public: | ||
///@name Type Definitions | ||
///@{ | ||
|
||
/// Pointer definition of DataTransfer3D1DProcess | ||
KRATOS_CLASS_POINTER_DEFINITION(DataTransfer3D1DProcess); | ||
|
||
/// Geometry definition | ||
using GeometryType = Geometry<Node>; | ||
|
||
// Define mapper factory | ||
DEFINE_MAPPER_FACTORY_SERIAL | ||
|
||
///@} | ||
///@name Life Cycle | ||
///@{ | ||
|
||
/// Default constructor. | ||
DataTransfer3D1DProcess( | ||
ModelPart& rFirstModelPart, | ||
ModelPart& rSecondModelPart, | ||
Parameters ThisParameters = Parameters(R"({})") | ||
); | ||
|
||
|
||
///@} | ||
///@name Operators | ||
///@{ | ||
|
||
void operator()() | ||
{ | ||
Execute(); | ||
} | ||
|
||
///@} | ||
///@name Operations | ||
///@{ | ||
|
||
/** | ||
* @brief This method executes the process | ||
*/ | ||
void Execute() override; | ||
|
||
/** | ||
* @brief This method provides the defaults parameters to avoid conflicts between the different constructors | ||
*/ | ||
const Parameters GetDefaultParameters() const override; | ||
|
||
///@} | ||
private: | ||
///@name Private member Variables | ||
///@{ | ||
|
||
ModelPart& mr3DModelPart; /// The 3D model part | ||
ModelPart& mr1DModelPart; /// The 1D model part | ||
Parameters mThisParameters; /// The parameters containing the configuration | ||
MapperType::Pointer mpMapper = nullptr; /// The mapper pointer | ||
std::vector<const Variable<double>*> mOriginListVariables; /// The list of variables to be transferred (origin) | ||
std::vector<const Variable<double>*> mDestinationListVariables; /// The list of variables to be transferred (destination) | ||
|
||
///@} | ||
///@name Private Operations | ||
///@{ | ||
|
||
/** | ||
* @brief This method interpolates from the 3D to the 1D | ||
*/ | ||
void InterpolateFrom3Dto1D(); | ||
|
||
/** | ||
* @brief This method interpolates from the 1D to the 3D | ||
*/ | ||
void InterpolateFrom1Dto3D(); | ||
|
||
/** | ||
* @brief This method computes the list of variables to interpolate | ||
* @param rOriginListVariables The list of origin variables to interpolate | ||
* @param rDestinationListVariables The list of destination variables to interpolate | ||
*/ | ||
void GetVariablesList( | ||
std::vector<const Variable<double>*>& rOriginListVariables, | ||
std::vector<const Variable<double>*>& rDestinationListVariables | ||
); | ||
|
||
/** | ||
* @brief This method computes maximum length of the elements | ||
* @param rModelPart The model part to compute | ||
* @return The maximum length | ||
*/ | ||
static double GetMaxLength(const ModelPart& rModelPart); | ||
|
||
///@} | ||
}; // Class DataTransfer3D1DProcess | ||
|
||
///@} | ||
|
||
///@} addtogroup block | ||
|
||
} // namespace Kratos. |
33 changes: 33 additions & 0 deletions
33
applications/CoSimulationApplication/custom_python/add_custom_processes_to_python.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// KRATOS / ___|___/ ___|(_)_ __ ___ _ _| | __ _| |_(_) ___ _ ___ | ||
// | | / _ \___ \| | '_ ` _ \| | | | |/ _` | __| |/ _ \| '_ | | ||
// | |__| (_) |__) | | | | | | | |_| | | (_| | |_| | (_) | | | | | ||
// \____\___/____/|_|_| |_| |_|\__,_|_|\__,_|\__|_|\___/|_| |_| | ||
// | ||
// License: BSD License | ||
// license: CoSimulationApplication/license.txt | ||
// | ||
// Main authors: | ||
// | ||
|
||
// System includes | ||
|
||
// External includes | ||
|
||
// Project includes | ||
#include "includes/define.h" | ||
#include "custom_python/add_custom_processes_to_python.h" | ||
#include "custom_processes/data_transfer_3D_1D_process.h" | ||
|
||
namespace Kratos::Python{ | ||
|
||
void AddCustomProcessesToPython(pybind11::module& m) | ||
{ | ||
namespace py = pybind11; | ||
|
||
py::class_< DataTransfer3D1DProcess, DataTransfer3D1DProcess::Pointer, Process>(m, "DataTransfer3D1DProcess") | ||
.def(py::init<ModelPart&, ModelPart&>()) | ||
.def(py::init<ModelPart&, ModelPart&, Parameters>()) | ||
; | ||
} | ||
|
||
} // namespace Kratos::Python. |
26 changes: 26 additions & 0 deletions
26
applications/CoSimulationApplication/custom_python/add_custom_processes_to_python.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// KRATOS / ___|___/ ___|(_)_ __ ___ _ _| | __ _| |_(_) ___ _ ___ | ||
// | | / _ \___ \| | '_ ` _ \| | | | |/ _` | __| |/ _ \| '_ | | ||
// | |__| (_) |__) | | | | | | | |_| | | (_| | |_| | (_) | | | | | ||
// \____\___/____/|_|_| |_| |_|\__,_|_|\__,_|\__|_|\___/|_| |_| | ||
// | ||
// License: BSD License | ||
// license: CoSimulationApplication/license.txt | ||
// | ||
// Main authors: | ||
// | ||
|
||
#pragma once | ||
|
||
// System includes | ||
#include <pybind11/pybind11.h> | ||
|
||
// External includes | ||
|
||
// Project includes | ||
#include "includes/define.h" | ||
|
||
namespace Kratos::Python { | ||
|
||
void AddCustomProcessesToPython(pybind11::module& m); | ||
|
||
} // namespace Kratos::Python. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.