Skip to content

Commit

Permalink
PDEModelica fag and new built-in file
Browse files Browse the repository at this point in the history
--PDE flag changed to --grammar="PDEModelica"
New PDEModelicaBuiltin file. Loading enabled by the flag.
  • Loading branch information
Jan Šilar authored and OpenModelica-Hudson committed Feb 10, 2016
1 parent c1ec6d8 commit 554b2a6
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 26 deletions.
18 changes: 17 additions & 1 deletion Compiler/FrontEnd/Builtin.mo
Expand Up @@ -550,7 +550,7 @@ public function getInitialFunctions
algorithm
(initialProgram,initialSCodeProgram) := matchcontinue ()
local
String fileModelica,fileMetaModelica,fileParModelica;
String fileModelica,fileMetaModelica,fileParModelica,filePDEModelica;
list<tuple<Integer,tuple<Absyn.Program,SCode.Program>>> assocLst;
list<Absyn.Class> classes,classes1,classes2;
Absyn.Program p;
Expand Down Expand Up @@ -606,6 +606,22 @@ algorithm
assocLst = getGlobalRoot(Global.builtinIndex);
setGlobalRoot(Global.builtinIndex, (Flags.MODELICA,(p,sp))::assocLst);
then (p,sp);
case ()
equation
true = intEq(Flags.getConfigEnum(Flags.GRAMMAR), Flags.PDEMODELICA);
fileModelica = Settings.getInstallationDirectoryPath() + "/lib/omc/ModelicaBuiltin.mo";
filePDEModelica = Settings.getInstallationDirectoryPath() + "/lib/omc/PDEModelicaBuiltin.mo";
Error.assertionOrAddSourceMessage(System.regularFileExists(fileModelica),Error.FILE_NOT_FOUND_ERROR,{fileModelica},Absyn.dummyInfo);
Error.assertionOrAddSourceMessage(System.regularFileExists(filePDEModelica),Error.FILE_NOT_FOUND_ERROR,{filePDEModelica},Absyn.dummyInfo);
Absyn.PROGRAM(classes=classes1,within_=Absyn.TOP()) = Parser.parsebuiltin(fileModelica,"UTF-8");
Absyn.PROGRAM(classes=classes2,within_=Absyn.TOP()) = Parser.parsebuiltin(filePDEModelica,"UTF-8");
classes = listAppend(classes1,classes2);
p = Absyn.PROGRAM(classes,Absyn.TOP());
sp = List.map(classes, SCodeUtil.translateClass);
assocLst = getGlobalRoot(Global.builtinIndex);
setGlobalRoot(Global.builtinIndex, (Flags.PDEMODELICA,(p,sp))::assocLst);
then (p,sp);

else
equation
Error.addMessage(Error.INTERNAL_ERROR, {"Builtin.getInitialFunctions failed."});
Expand Down
22 changes: 0 additions & 22 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -664,28 +664,6 @@ function inStream
end inStream;


/*PDE extension built-ins*/
/*function pder "Partial space derivative of the input expression in the first argument with respect to second argument"
input Real u(unit="'p");
input Real x(unit="'q");
output Real du(unit="'p/'q");
external "builtin";
annotation(Documentation(info="<html>
See <a href=\"???\">der()</a>
</html>"));
end pder;
*/

record DomainLineSegment1D
record Region
end Region;
parameter Real L=1;
constant Integer N=10;
parameter Real dx = L / (N-1);
parameter Real[N] x = array(i*dx for i in 0:N-1);
Region left, right, interior;
end DomainLineSegment1D;

/* Extension for uncertainty computations */
record Distribution
String name "the name of the distibution, e.g \"normal\" ";
Expand Down
42 changes: 42 additions & 0 deletions Compiler/FrontEnd/PDEModelicaBuiltin.mo
@@ -0,0 +1,42 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-2014, Open Source Modelica Consortium (OSMC),
* c/o Linköpings universitet, Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
* THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
* RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
* ACCORDING TO RECIPIENTS CHOICE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from OSMC, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
*/

/*PDEModelica extension built-ins*/

record DomainLineSegment1D
record Region
end Region;
parameter Real L=1;
constant Integer N=10;
parameter Real dx = L / (N-1);
parameter Real[N] x = array(i*dx for i in 0:N-1);
Region left, right, interior;
end DomainLineSegment1D;
2 changes: 1 addition & 1 deletion Compiler/Makefile.in
Expand Up @@ -81,7 +81,7 @@ endif
$(SUSANMO): simcode

builtin:
cp FrontEnd/ModelicaBuiltin.mo FrontEnd/MetaModelicaBuiltin.mo $(builddir_lib)
cp FrontEnd/ModelicaBuiltin.mo FrontEnd/MetaModelicaBuiltin.mo FrontEnd/PDEModelicaBuiltin.mo $(builddir_lib)

.PRECIOUS: Makefile

Expand Down
5 changes: 3 additions & 2 deletions Compiler/Util/Flags.mo
Expand Up @@ -161,6 +161,7 @@ public constant Integer MODELICA = 1;
public constant Integer METAMODELICA = 2;
public constant Integer PARMODELICA = 3;
public constant Integer OPTIMICA = 4;
public constant Integer PDEMODELICA = 5;

// DEBUG FLAGS
public
Expand Down Expand Up @@ -661,8 +662,8 @@ constant ConfigFlag TARGET = CONFIG_FLAG(5, "target", NONE(), EXTERNAL(),
Util.gettext("Sets the target compiler to use."));

constant ConfigFlag GRAMMAR = CONFIG_FLAG(6, "grammar", SOME("g"), EXTERNAL(),
ENUM_FLAG(MODELICA, {("Modelica", MODELICA), ("MetaModelica", METAMODELICA), ("ParModelica", PARMODELICA), ("Optimica", OPTIMICA)}),
SOME(STRING_OPTION({"Modelica", "MetaModelica", "ParModelica", "Optimica"})),
ENUM_FLAG(MODELICA, {("Modelica", MODELICA), ("MetaModelica", METAMODELICA), ("ParModelica", PARMODELICA), ("Optimica", OPTIMICA), ("PDEModelica", PDEMODELICA)}),
SOME(STRING_OPTION({"Modelica", "MetaModelica", "ParModelica", "Optimica", "PDEModelica"})),
Util.gettext("Sets the grammar and semantics to accept."));

constant ConfigFlag ANNOTATION_VERSION = CONFIG_FLAG(7, "annotationVersion",
Expand Down

0 comments on commit 554b2a6

Please sign in to comment.