randomise.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "randomise.H"
00028 #include "addToRunTimeSelectionTable.H"
00029
00030
00031
00032 namespace Foam
00033 {
00034 namespace calcTypes
00035 {
00036 defineTypeNameAndDebug(randomise, 0);
00037 addToRunTimeSelectionTable(calcType, randomise, dictionary);
00038 }
00039 }
00040
00041
00042
00043
00044 Foam::calcTypes::randomise::randomise()
00045 :
00046 calcType()
00047 {}
00048
00049
00050
00051
00052 Foam::calcTypes::randomise::~randomise()
00053 {}
00054
00055
00056
00057
00058 void Foam::calcTypes::randomise::init()
00059 {
00060 argList::validArgs.append("randomise");
00061 argList::validArgs.append("perturbation");
00062 argList::validArgs.append("fieldName");
00063 }
00064
00065
00066 void Foam::calcTypes::randomise::preCalc
00067 (
00068 const argList& args,
00069 const Time& runTime,
00070 const fvMesh& mesh
00071 )
00072 {}
00073
00074
00075 void Foam::calcTypes::randomise::calc
00076 (
00077 const argList& args,
00078 const Time& runTime,
00079 const fvMesh& mesh
00080 )
00081 {
00082 const stringList& params = args.additionalArgs();
00083 const scalar pertMag = readScalar(IStringStream(params[1])());
00084 const word& fieldName = params[2];
00085
00086 Random rand(1234567);
00087
00088 IOobject fieldHeader
00089 (
00090 fieldName,
00091 runTime.timeName(),
00092 mesh,
00093 IOobject::MUST_READ
00094 );
00095
00096
00097 if (fieldHeader.headerOk())
00098 {
00099 bool processed = false;
00100
00101 writeRandomField<vector>
00102 (
00103 fieldHeader,
00104 pertMag,
00105 rand,
00106 mesh,
00107 processed
00108 );
00109 writeRandomField<sphericalTensor>
00110 (
00111 fieldHeader,
00112 pertMag,
00113 rand,
00114 mesh,
00115 processed
00116 );
00117 writeRandomField<symmTensor>
00118 (
00119 fieldHeader,
00120 pertMag,
00121 rand,
00122 mesh,
00123 processed
00124 );
00125 writeRandomField<tensor>
00126 (
00127 fieldHeader,
00128 pertMag,
00129 rand,
00130 mesh,
00131 processed
00132 );
00133
00134 if (!processed)
00135 {
00136 FatalError
00137 << "Unable to process " << fieldName << nl
00138 << "No call to randomise for fields of type "
00139 << fieldHeader.headerClassName() << nl << nl
00140 << exit(FatalError);
00141 }
00142 }
00143 else
00144 {
00145 Info<< " No " << fieldName << endl;
00146 }
00147 }
00148
00149
00150
Copyright © 2000-2009 OpenCFD Ltd