PipeWithScalarField

model PipeWithScalarField "Visualizing a pipe with scalar field quantities along the pipe axis"
    extends Modelica.Mechanics.MultiBody.Interfaces.PartialVisualizer;

    parameter Boolean animation = true "= true, if animation shall be enabled";
    parameter Modelica.SIunits.Radius rOuter "Outer radius of pipe"
        annotation (Dialog(enable = animation));
    parameter Modelica.SIunits.Length length "Length of pipe"
        annotation (Dialog(enable = animation));
    parameter Real xsi[:](each min = 0, each max = 1) = Modelica.Math.Vectors.relNodePositions(12) "[:] Relative position along the pipe with x[1] = 0, x[end] = 1"
        annotation (Dialog(enable = animation));
    input Real T[size(xsi, 1)] "[:] Scalar values at position xsi*length (will be visualized by color)"
        annotation (Dialog(enable = animation));
    parameter Real T_min "Minimum value of T that corresponds to colorMap[1,:]"
        annotation (Dialog(enable = animation));
    parameter Real T_max "Maximum value of T that corresponds to colorMap[end,:]"
        annotation (Dialog(enable = animation));

    replaceable function colorMap = Modelica.Mechanics.MultiBody.Visualizers.Colors.ColorMaps.jet constrainedby Modelica.Mechanics.MultiBody.Interfaces.partialColorMap "Function defining the color map"
        annotation (
            choicesAllMatching = true,
            Dialog(
                enable = animation,
                group = "Color coding"),
            Documentation(info = "<html>\n<p>This replaceable function defines a particular color map.</p>\n<!--a placeholder to fulfill minimum documentation length-->\n</html>"));

    parameter Integer n_colors = 64 "Number of colors in the colorMap"
        annotation (Dialog(
            enable = animation,
            group = "Color coding"));
    parameter Types.SpecularCoefficient specularCoefficient = 0.7 "Reflection of ambient light (= 0: light is completely absorbed)"
        annotation (Dialog(
            enable = animation,
            group = "Color coding"));
    parameter Real transparency = 0 "Transparency of shape: 0 (= opaque) ... 1 (= fully transparent)"
        annotation (Dialog(
            enable = animation,
            group = "Color coding"));
    parameter Integer n_rOuter = 30 "Number of points along outer radius"
        annotation (Dialog(
            enable = animation,
            tab = "Discretization"));
    parameter Integer n_length = 20 "Number of points along length"
        annotation (Dialog(
            enable = animation,
            tab = "Discretization"));
protected
    Advanced.PipeWithScalarField pipe(redeclare function colorMap = colorMap, rOuter = rOuter, length = length, xsi = xsi, T = T, T_min = T_min, T_max = T_max, n_colors = n_colors, n_rOuter = n_rOuter, n_length = n_length, specularCoefficient = specularCoefficient, transparency = transparency, R = frame_a.R, r_0 = frame_a.r_0) if world.enableAnimation and animation annotation (Placement(transformation(extent = {
        {-20, -10}, 
        {0, 10}})));
equation
    frame_a.f = zeros(3);
    frame_a.t = zeros(3);

    annotation (
        Icon(graphics = {
            Text(
                extent = {
                    {-150, 50}, 
                    {150, 90}},
                lineColor = {0, 0, 255},
                textString = "%name"), 
            Bitmap(
                extent = {
                    {-100, -62}, 
                    {98, 58}},
                fileName = "modelica://Modelica/Resources/Images/Mechanics/MultiBody/Visualizers/PipeWithScalarFieldIcon.png")}),
        Documentation(
            info = "<html>\n<p>\nModel <strong>PipeWithScalarField</strong> visualizes a pipe and a scalar\nfield along the pipe axis. The latter is shown by mapping the scalar\nfield to color values with a color map and utilizing this color\nat the perimeter associated with the corresponding axis location.\nTypically the scalar field value is a temperature, but might\nbe also another quantity.\nPredefined color maps are available from\n<a href=\"modelica://Modelica.Mechanics.MultiBody.Visualizers.Colors.ColorMaps\">MultiBody.Visualizers.Colors.ColorMaps</a>\nand can be selected via parameter \"colorMap\".\nA color map with the corresponding scalar field values can be exported\nas vector-graphics in svg-format with function\n<a href=\"modelica://Modelica.Mechanics.MultiBody.Visualizers.Colors.colorMapToSvg\">MultiBody.Visualizers.Colors.colorMapToSvg</a>.\nConnector frame_a of this component is located in the center of the\ncircle at the left side of the pipe and the pipe axis is oriented\nalong the x-axis of frame_a, see figure below in which frame_a is visualized\nwith a coordinate system:\n</p>\n\n<blockquote>\n<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Visualizers/PipeWithScalarField.png\">\n</blockquote>\n\n<p>\nThe color coding is shown in the next figure. It was generated with\n<a href=\"modelica://Modelica.Mechanics.MultiBody.Visualizers.Colors.colorMapToSvg\">MultiBody.Visualizers.Colors.colorMapToSvg</a>\nusing the following call:\n</p>\n\n<blockquote>\n<pre>\ncolorMapToSvg(Modelica.Mechanics.MultiBody.Visualizers.Colors.ColorMaps.jet(),\n              height=50, nScalars=6, T_max=100, caption=\"Temperature in C\");\n</pre>\n</blockquote>\n\n<blockquote>\n<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Visualizers/PipeWithScalarField-ColorMap.png\">\n</blockquote>\n</html>",
            revisions = "<html>\n  <ul>\n  <li> July 2010 by Martin Otter<br>\n       Adapted to the new Surface model.</li>\n  <li> July 2005 by Dirk Zimmer (practical training at DLR)<br>\n       First version to visualize a multi-level tyre wheel model.</li>\n  </ul>\n</html>"));
end PipeWithScalarField;