Commit Graph

127 Commits

Author SHA1 Message Date
Mark OLESEN
152eceeb56 Use factory Clone for patch fields 2024-01-23 11:22:19 +00:00
Mark Olesen
987dbe4589 ENH: use factory Clone method for handling member clone() methods
- reduces code clutter, simplifies modification for new types.
  Handled classes:

    Function1, PatchFunction1, coordinateRotation, coordinateSystem,
    particle, liquidProperties, solidProperties
2024-01-09 11:56:45 +00:00
Mark Olesen
fc86e52451 ENH: extrapolateInternal() method for patch fields
- provides a more succinct way of writing

      {fa,fv}PatchField<Type>::patchInternalField(*this)

  as well as a consistent naming that can be used for patches derived
  from valuePointPatchField

ENH: readGradientEntry helper method for fixedGradient conditions

- simplifies coding and logic.
- support different read construct modes for fixedGradient
2023-06-19 17:47:03 +02:00
Mark Olesen
139a8fc6ff STYLE: use SPDX-style for scripts 2023-05-10 18:23:13 +02:00
Mark Olesen
188e61af16 STYLE: use readValueEntry in BCs. Assign Zero for refValue/refGrad 2023-04-04 09:56:55 +02:00
Mark Olesen
70d526cd82 ENH: neg(x) instead of '1 - pos0(x)' for less-than 0 check
- fewer operations

ENH: replace 'neg(x)*a + pos0(x)*b' with 'lerp(a, b, pos0(x))'

- uses pos0 as a 0-1 selector. Fewer operations.
2023-02-21 10:05:27 +01:00
Mark Olesen
fe4688c27f ENH: patch fields writeValueEntry method (frequently used)
- add base-level readValueEntry, readMixedEntries methods
  that allow optional or mandatory reading.

STYLE: wording for patch fields comments
2023-02-20 11:13:43 +01:00
Mark Olesen
27a7ae2d1d ENH: use simpler lookupPatchField form 2023-02-13 20:08:48 +01:00
mattijs
eb3c806ff9 COMP: dynamicCode: add missing default constructor
Used copy constructor for dictionary. Probably not
necessary.
2021-12-13 13:20:04 +00:00
Mark Olesen
9a5125111e ENH: add coded Function1 (#2282)
- update coded templates with qualified names

GIT: add in missing PatchFunction1 constant() method

- was missed in a previous commit
2021-12-03 20:56:10 +01:00
Mark Olesen
f7c7fa94a3 ENH: add Function1 constant() member
- marks if the value is considered to be independent of 'x'.
  Propagate into PatchFunction1 instead ad hoc checks there.

- adjust method name in PatchFunction1 to 'whichDb()' to reflect
  final changes in Function1 method names.

ENH: add a Function1 'none' placeholder function

- This is principally useful for interfaces that expect a Function1
  but where it is not necessarily used by a particular submodel.

TUT: update Function1 creation to use objectRegistry
2021-12-03 15:32:37 +01:00
Andrew Heather
098aec4962 ENH: Function1's - added objectRegistry access 2021-11-26 11:22:36 +00:00
Mark Olesen
fd82f3e47a ENH: distinguish between compressible/incompressible coded source
- previously had codeAddSup used for both incompressible and
  compressible source terms. However, it was not actually possible to
  use it for compressible sources since any references to the 'rho'
  parameter would cause a compilation error for the incompressible case.

  Added 'codeAddSupRho' to distinguish the compressible case.
  User must supply one or both of them on input.
2021-11-09 21:48:42 +01:00
Mark Olesen
b59ae32d68 ENH: provide dictionary access for coded BCs etc (#1922)
- in some cases, additional dictionary inputs are useful for extending
  the input parameters or functionality of dynamic coded conditions.

  Typically this can be used to provide a simple set of dictionary
  inputs that are used to drive specific code, but allows changing the
  inputs without causing a recompilation.

  Accessed with this type of code:
  ```
  const dictionary& dict = this->codeContext();
  ```

boundary conditions and function objects:

* specify an additional codeContext dictionary entry:
  ```
  codeContext
  {
      ...
  }
  ```

PatchFunction1:

* The code context dictionary is simply the dictionary used to specify
  the PatchFunction1 coefficients.

  To replicated persistant data, use local member static data.
  Eg,
  ```
  code
  #{
      // Persistent (Member) Data
      static autoPtr<Function1<scalar>> baseVel;
      static autoPtr<Function1<vector>> baseDir;
      ...
  #}
  ```

fvOptions:

* currently not applicable
2021-06-07 10:28:15 +02:00
Mark Olesen
b0891824fa ENH: improve codeTemplates
- meshTools include/library for many (most) coded items

- add PatchFunction1 include for coded BCs to provide ready access
  to Function1 and PatchFunction1
2021-06-07 09:48:21 +02:00
Mark Olesen
d4ac96cdf3 ENH: support use of 'vector' in #calc directive (fixes #2039) 2021-03-29 16:00:11 +02:00
Mark Olesen
9f7a400952 GIT: remove old "removed-file" dependency stubs, version file (#1994) 2021-02-10 12:43:07 +01:00
Mark Olesen
c9b34c52bb COMP: bad template for foamNewFunctionObject (closes #1987) 2021-01-22 12:46:31 +01:00
Mark Olesen
2f2dcdcf6f ENH: Function1 and PatchFunction1 improvements (#1917)
- easier support for non-mandatory functions.

  In some boundary conditions it can be desirable to support
  additional functions, but not necessarily require them. Make this
  easier to support with a Function1, PatchFunction1 NewIfPresent()
  selector.

- support for compatibility lookups

- harmonize branching logic and error handling between Function1 and
  PatchFunction1.

ENH: refactor a base class for Function1, PatchFunction1

- includes base characteristics, patch or scalar information

ENH: additional creation macros

- makeConcreteFunction1, makeConcretePatchFunction1Type for adding a
  non-templated function into the correct templated selection table.
  makeScalarPatchFunction1 for similarity with makeScalarFunction1
2020-11-19 16:57:45 +01:00
Mark Olesen
e11c072bc4 CONFIG: incorrect BC code templates (fixes #1885)
- autoPtr to Function requires clone() method, not optional copy/move
  argument.

- fix bad character range for 'sed'
2020-10-20 14:23:40 +02:00
Kutalmis Bercin
a5c6516e23 DOC: elaborate the usage of function objects
ENH: update libs of etc/caseDicts/postProcess items
  ENH: ensure destructor=default
  ENH: ensure constness
  ENH: ensure no 'copy construct' and 'no copy assignment' exist
  TUT: add examples of function objects with full set
       of settings into a TUT if unavailable
  TUT: update pisoFoam/RAS/cavity tutorial in terms of usage
2020-06-08 15:43:47 +01:00
Mark Olesen
3e43edf056 ENH: unify use of dictionary method names
- previously introduced `getOrDefault` as a dictionary _get_ method,
  now complete the transition and use it everywhere instead of
  `lookupOrDefault`. This avoids mixed usage of the two methods that
  are identical in behaviour, makes for shorter names, and promotes
  the distinction between "lookup" access (ie, return a token stream,
  locate and return an entry) and "get" access (ie, the above with
  conversion to concrete types such as scalar, label etc).
2020-06-02 17:26:03 +02:00
Mark Olesen
09d9c5cc03 ENH: consistent autoPtr handling in PatchFunction1 2020-05-23 16:02:35 +02:00
mattijs
7f936ad01f ENH: coded version of PatchFunction1. See #1709. 2020-05-20 10:38:39 +01:00
Andrew Heather
ae2ab06312 REL: Release preparations 2019-12-23 09:49:23 +00:00
Mark Olesen
b61d4ab488 STYLE: adjust deprecations for OSspecific
- skip processing OSspecific/MSwindows since this can cause duplicate
  doxygen entries

STYLE: adjust formatting in code templates

STYLE: use std::string methods without extra qualifications
2019-12-13 11:08:12 +01:00
Mark Olesen
b0c88dff58 ENH: treat self-assignment as no-op instead of a Fatal (#1473)
- this can help if using std algorithms that return a const reference
  such as std::min() does.
2019-11-05 11:10:49 +01:00
Andrew Heather
fdf8d10ab4 Merge commit 'e9219558d7' into develop-v1906 2019-12-05 11:47:19 +00:00
OpenFOAM bot
e9219558d7 GIT: Header file updates 2019-10-31 14:48:44 +00:00
Mark Olesen
c5ed28d0e3 STYLE: extraneous space in template parameter 2019-10-30 12:54:06 +01:00
Mark Olesen
a85c55bbb5 ENH: ensure that content changes in coded objects are noticed (#1293)
- for codedFunctionObject and CodedSource the main code snippets
  were not included in the SHA1 calculation, which meant that many
  changes would not be noticed and no new library would be compiled.

  As a workaround, a dummy 'code' entry could be used solely for the
  purposes of generating a SHA1, but this is easily forgotten.

  We now allow tracking of the dynamicCodeContext for the coded
  objects and append to the SHA1 hasher with specific entries.
  This should solve the previous misbehaviour.

  We additionally add information about the ordering of the code
  sections. Suppose we have a coded function object (all code
  segments are optional) with the following:

      codeExecute "";
      codeWrite   #{ Info<< "Called\n"; #};

  which we subsequently change to this:

      codeExecute #{ Info<< "Called\n"; #};
      codeWrite   "";

  If the code strings are simply concatenated together, the SHA1 hashes
  will be identical. We thus 'salt' with their semantic locations,
  choosing tags that are unlikely to occur within the code strings
  themselves.

- simplify the coded templates with constexpr for the SHA1sum
  information.

- Correct the CodedSource to use 'codeConstrain' instead of
  'codeSetValue' for consistency with the underlying functions.
2019-05-01 14:00:54 +02:00
OpenFOAM bot
154029ddd0 BOT: Cleaned up header files 2019-02-06 12:28:23 +00:00
Mark Olesen
b0fafd18fe STYLE: reorganize some legacy and less frequently used components
- older emacs tools into legacy
- old process tools

* Less frequently used scripts into bin/tools/

  - findEmptyMake
  - foamAllHC
  - foamUpdateCaseFileHeader

* Infrastructure file (only used by foamNewApp)

  - wmake/wmakeFilesAndOptions -> wmake/scripts/wmakeFilesAndOptions

* Merge wmakeRoot convenience as 'wmake -pwd'
* Remove obsolete wmakePrintBuild (superseded by wmakeBuildInfo)
* Remove unused mergeHistory file
2019-01-26 11:30:50 +01:00
Mark Olesen
1dd7362aed ENH: wmakeRoot for locating the root directory 2019-01-18 10:58:07 +01:00
Mark Olesen
efdbeae27e ENH: use dictionary::get<> instead of pTraits (#762)
- check Istream in readBool in operator>> variant (#1033)
2018-11-20 10:10:39 +01:00
Mark Olesen
8eddcc072a ENH: avoid readScalar, readLabel etc from dictionary (#762, #1033)
- use the dictionary 'get' methods instead of readScalar for
  additional checking

     Unchecked:  readScalar(dict.lookup("key"));
     Checked:    dict.get<scalar>("key");

- In templated classes that also inherit from a dictionary, an additional
  'template' keyword will be required. Eg,

     this->coeffsDict().template get<scalar>("key");

  For this common use case, the predefined getXXX shortcuts may be
  useful. Eg,

     this->coeffsDict().getScalar("key");
2018-10-12 08:14:47 +02:00
Mark Olesen
9129dbd46f Merge remote-tracking branch 'origin/master' into develop 2018-10-11 11:01:16 +02:00
Andrew Heather
4b7c21bc3c BUG: foamNewSource - corrected Make/options for app mode. Closes #1006 2018-10-09 09:47:54 +01:00
Mark Olesen
13778f7647 ENH: use dictionary::readEntry for detection of input errors (#762, #1033)
- instead of   dict.lookup(name) >> val;
  can use      dict.readEntry(name, val);

  for checking of input token sizes.
  This helps catch certain types of input errors:

  {

      key1 ;                // <- Missing value
      key2 1234             // <- Missing ';' terminator
      key3 val;
  }

STYLE: readIfPresent() instead of 'if found ...' in a few more places.
2018-10-05 10:15:13 +02:00
Mark Olesen
dc521b95df STYLE: consistent use of '= delete' 2018-05-30 12:03:17 +02:00
mattijs
977a9894b4 ENH: codedMotionSolver: motion solver with user-supplied coding 2018-05-21 08:59:01 +01:00
Mark Olesen
dd8341f659 ENH: make format of ExecutionTime = ... output configurable (issue #788)
- controlled by the the 'printExecutionFormat' InfoSwitch in
  etc/controlDict

      // Style for "ExecutionTime = " output
      // - 0 = seconds (with trailing 's')
      // - 1 = day-hh:mm:ss

   ExecutionTime = 112135.2 s  ClockTime = 113017 s

   ExecutionTime = 1-07:08:55.20  ClockTime = 1-07:23:37

- Callable via the new Time::printExecutionTime() method,
  which also helps to reduce clutter in the applications.
  Eg,

     runTime.printExecutionTime(Info);

  vs

     Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
         << "  ClockTime = " << runTime.elapsedClockTime() << " s"
         << nl << endl;

--

ENH: return elapsedClockTime() and clockTimeIncrement as double

- previously returned as time_t, which is less portable.
2018-04-27 15:00:34 +02:00
Mark Olesen
ef922b6917 STYLE: adjust codeTemplates to use '= delete' 2018-04-19 07:38:31 +02:00
Mark Olesen
5947f9a337 ENH: more succinct output from command-line errors.
- unknown options or missing option values now emit a shorter message
  without the entire usage. This makes it easier to identify the errors
  and is better aligned with the behaviour of GNU system tools.

  ====
     $ simpleFoam -case
     Using: OpenFOAM-plus (see www.OpenFOAM.com)
     Build: plus-01234

     Error: option '-case' requires an argument

     See 'simpleFoam -help' for usage
  ====

- provide for reduced (-help) and full (-help-full) usage information.
  In many cases the reduced usage provided sufficient and easier
  to find the information.

- make -srcDoc an alias for -doc-source

- no warnings about option aliases for future dates.
2017-11-24 10:27:11 +01:00
Mark Olesen
c0ba7bf05a STYLE: use Ostream writeEntry when writing key/value entries
- makes for clearer code

ENH: make writeIfDifferent part of Ostream
2017-11-06 00:49:24 +01:00
Henry Weller
56bfc75949 Rationalize the "pos" function
"pos" now returns 1 if the argument is greater than 0, otherwise it returns 0.
This is consistent with the common mathematical definition of the "pos" function:

https://en.wikipedia.org/wiki/Sign_(mathematics)

However the previous implementation in which 1 was also returned for a 0
argument is useful in many situations so the "pos0" has been added which returns
1 if the argument is greater or equal to 0.  Additionally the "neg0" has been
added which returns 1 if if the argument is less than or equal to 0.
2017-06-22 14:32:18 +01:00
Henry Weller
f96db2d600 BUG: codedFvOptionTemplate: updated 'setValue' to 'constrain'
Resolves bug-report https://bugs.openfoam.org/view.php?id=2579
2017-06-13 16:52:16 +01:00
Mark Olesen
2b249e1ad3 STYLE: avoid default copyright assignment when generating from code templates 2017-07-11 08:58:52 +02:00
Mark Olesen
9097801105 STYLE: additional divisions for code templates 2017-07-11 08:48:10 +02:00
Mark Olesen
2af602c2f4 STYLE: for Istream/Ostream check() use FUNCTION_NAME in messages 2017-05-26 10:59:16 +02:00